/src/libreoffice/framework/source/services/frame.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #include <sal/config.h> |
21 | | |
22 | | #include <utility> |
23 | | |
24 | | #include <dispatch/dispatchprovider.hxx> |
25 | | #include <dispatch/interceptionhelper.hxx> |
26 | | #include <dispatch/windowcommanddispatch.hxx> |
27 | | #include <loadenv/loadenv.hxx> |
28 | | #include <helper/oframes.hxx> |
29 | | #include <framework/framecontainer.hxx> |
30 | | #include <framework/titlehelper.hxx> |
31 | | #include <svtools/openfiledroptargetlistener.hxx> |
32 | | #include <classes/taskcreator.hxx> |
33 | | #include <loadenv/targethelper.hxx> |
34 | | #include <framework/framelistanalyzer.hxx> |
35 | | #include <helper/dockingareadefaultacceptor.hxx> |
36 | | #include <dispatch/dispatchinformationprovider.hxx> |
37 | | |
38 | | #include <pattern/window.hxx> |
39 | | #include <properties.h> |
40 | | #include <targets.h> |
41 | | |
42 | | #include <com/sun/star/awt/Toolkit.hpp> |
43 | | #include <com/sun/star/awt/XDevice.hpp> |
44 | | #include <com/sun/star/awt/XTopWindow.hpp> |
45 | | #include <com/sun/star/awt/PosSize.hpp> |
46 | | #include <com/sun/star/beans/PropertyAttribute.hpp> |
47 | | #include <com/sun/star/beans/PropertyExistException.hpp> |
48 | | #include <com/sun/star/beans/PropertyValue.hpp> |
49 | | #include <com/sun/star/beans/XPropertySet.hpp> |
50 | | #include <com/sun/star/container/XIndexAccess.hpp> |
51 | | #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> |
52 | | #include <com/sun/star/frame/XFrame2.hpp> |
53 | | #include <com/sun/star/frame/XModel.hpp> |
54 | | #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp> |
55 | | #include <com/sun/star/frame/LayoutManager.hpp> |
56 | | #include <com/sun/star/frame/XDesktop.hpp> |
57 | | #include <com/sun/star/frame/FrameSearchFlag.hpp> |
58 | | #include <com/sun/star/lang/DisposedException.hpp> |
59 | | #include <com/sun/star/task/StatusIndicatorFactory.hpp> |
60 | | #include <com/sun/star/task/theJobExecutor.hpp> |
61 | | #include <com/sun/star/task/XJobExecutor.hpp> |
62 | | #include <com/sun/star/util/CloseVetoException.hpp> |
63 | | #include <com/sun/star/util/URLTransformer.hpp> |
64 | | #include <com/sun/star/util/XURLTransformer.hpp> |
65 | | #include <com/sun/star/util/XCloseable.hpp> |
66 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
67 | | |
68 | | #include <cppuhelper/basemutex.hxx> |
69 | | #include <cppuhelper/compbase.hxx> |
70 | | #include <comphelper/multiinterfacecontainer3.hxx> |
71 | | #include <comphelper/multicontainer2.hxx> |
72 | | #include <cppuhelper/supportsservice.hxx> |
73 | | #include <cppuhelper/weak.hxx> |
74 | | #include <rtl/ref.hxx> |
75 | | #include <sal/log.hxx> |
76 | | #include <vcl/window.hxx> |
77 | | #include <vcl/wrkwin.hxx> |
78 | | #include <vcl/svapp.hxx> |
79 | | |
80 | | #include <toolkit/helper/vclunohelper.hxx> |
81 | | #include <unotools/moduleoptions.hxx> |
82 | | #include <unotools/weakref.hxx> |
83 | | #include <comphelper/diagnose_ex.hxx> |
84 | | #include <unotools/cmdoptions.hxx> |
85 | | #include <vcl/threadex.hxx> |
86 | | #include <mutex> |
87 | | |
88 | | using namespace framework; |
89 | | |
90 | | namespace { |
91 | | |
92 | | // This enum can be used to set different active states of frames |
93 | | enum EActiveState |
94 | | { |
95 | | E_INACTIVE, // I am not a member of active path in tree and I don't have the focus. |
96 | | E_ACTIVE, // I am in the middle of an active path in tree and I don't have the focus. |
97 | | E_FOCUS // I have the focus now. I must be a member of an active path! |
98 | | }; |
99 | | |
100 | | /*-************************************************************************************************************ |
101 | | @short implements a normal frame of hierarchy |
102 | | @descr An instance of this class can be a normal node in a frame tree. A frame supports influencing its |
103 | | subtree, finding of subframes, activate- and deactivate-mechanisms as well as |
104 | | set/get of a frame window, component or controller. |
105 | | *//*-*************************************************************************************************************/ |
106 | | class XFrameImpl: |
107 | | private cppu::BaseMutex, |
108 | | public cppu::PartialWeakComponentImplHelper< |
109 | | css::lang::XServiceInfo, css::frame::XFrame2, css::awt::XWindowListener, |
110 | | css::awt::XTopWindowListener, css::awt::XFocusListener, |
111 | | css::document::XActionLockable, css::util::XCloseable, |
112 | | css::frame::XComponentLoader, css::frame::XTitle, |
113 | | css::frame::XTitleChangeBroadcaster, css::beans::XPropertySet, |
114 | | css::beans::XPropertySetInfo> |
115 | | { |
116 | | public: |
117 | | |
118 | | explicit XFrameImpl(css::uno::Reference< css::uno::XComponentContext > xContext); |
119 | | |
120 | | /// Initialization function after having acquire()'d. |
121 | | void initListeners(); |
122 | | |
123 | | virtual OUString SAL_CALL getImplementationName() override |
124 | 0 | { |
125 | 0 | return u"com.sun.star.comp.framework.Frame"_ustr; |
126 | 0 | } |
127 | | |
128 | | virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override |
129 | 0 | { |
130 | 0 | return cppu::supportsService(this, ServiceName); |
131 | 0 | } |
132 | | |
133 | | virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override |
134 | 0 | { |
135 | 0 | return {u"com.sun.star.frame.Frame"_ustr}; |
136 | 0 | } |
137 | | |
138 | | // XComponentLoader |
139 | | |
140 | | virtual css::uno::Reference< css::lang::XComponent > SAL_CALL loadComponentFromURL( |
141 | | const OUString& sURL, |
142 | | const OUString& sTargetFrameName, |
143 | | sal_Int32 nSearchFlags, |
144 | | const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override; |
145 | | |
146 | | // XFramesSupplier |
147 | | |
148 | | virtual css::uno::Reference < css::frame::XFrames > SAL_CALL getFrames() override; |
149 | | virtual css::uno::Reference < css::frame::XFrame > SAL_CALL getActiveFrame() override; |
150 | | virtual void SAL_CALL setActiveFrame(const css::uno::Reference < css::frame::XFrame > & xFrame) override; |
151 | | |
152 | | // XFrame |
153 | | |
154 | | virtual void SAL_CALL initialize(const css::uno::Reference < css::awt::XWindow > & xWindow) override; |
155 | | virtual css::uno::Reference < css::awt::XWindow > SAL_CALL getContainerWindow() override; |
156 | | virtual void SAL_CALL setCreator(const css::uno::Reference < css::frame::XFramesSupplier > & xCreator) override; |
157 | | virtual css::uno::Reference < css::frame::XFramesSupplier > SAL_CALL getCreator() override; |
158 | | virtual OUString SAL_CALL getName() override; |
159 | | virtual void SAL_CALL setName(const OUString & sName) override; |
160 | | virtual css::uno::Reference < css::frame::XFrame > SAL_CALL findFrame( |
161 | | const OUString & sTargetFrameName, |
162 | | sal_Int32 nSearchFlags) override; |
163 | | virtual sal_Bool SAL_CALL isTop() override; |
164 | | virtual void SAL_CALL activate() override; |
165 | | virtual void SAL_CALL deactivate() override; |
166 | | virtual sal_Bool SAL_CALL isActive() override; |
167 | | virtual void SAL_CALL contextChanged() override; |
168 | | virtual sal_Bool SAL_CALL setComponent( |
169 | | const css::uno::Reference < css::awt::XWindow > & xComponentWindow, |
170 | | const css::uno::Reference < css::frame::XController > & xController) override; |
171 | | virtual css::uno::Reference < css::awt::XWindow > SAL_CALL getComponentWindow() override; |
172 | | virtual css::uno::Reference < css::frame::XController > SAL_CALL getController() override; |
173 | | virtual void SAL_CALL addFrameActionListener(const css::uno::Reference < css::frame::XFrameActionListener > & xListener) override; |
174 | | virtual void SAL_CALL removeFrameActionListener(const css::uno::Reference < css::frame::XFrameActionListener > & xListener) override; |
175 | | |
176 | | // XComponent |
177 | | |
178 | | virtual void SAL_CALL disposing() override; |
179 | | virtual void SAL_CALL addEventListener(const css::uno::Reference < css::lang::XEventListener > & xListener) override; |
180 | | virtual void SAL_CALL removeEventListener(const css::uno::Reference < css::lang::XEventListener > & xListener) override; |
181 | | |
182 | | // XStatusIndicatorFactory |
183 | | |
184 | | virtual css::uno::Reference < css::task::XStatusIndicator > SAL_CALL createStatusIndicator() override; |
185 | | |
186 | | // XDispatchProvider |
187 | | |
188 | | virtual css::uno::Reference < css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL & aURL, |
189 | | const OUString & sTargetFrameName, |
190 | | sal_Int32 nSearchFlags) override; |
191 | | virtual css::uno::Sequence < css::uno::Reference < css::frame::XDispatch > > SAL_CALL queryDispatches( |
192 | | const css::uno::Sequence < css::frame::DispatchDescriptor > & lDescriptor) override; |
193 | | |
194 | | // XDispatchProviderInterception |
195 | | |
196 | | virtual void SAL_CALL registerDispatchProviderInterceptor( |
197 | | const css::uno::Reference < css::frame::XDispatchProviderInterceptor > & xInterceptor) override; |
198 | | virtual void SAL_CALL releaseDispatchProviderInterceptor( |
199 | | const css::uno::Reference < css::frame::XDispatchProviderInterceptor > & xInterceptor) override; |
200 | | |
201 | | // XDispatchInformationProvider |
202 | | |
203 | | virtual css::uno::Sequence < sal_Int16 > SAL_CALL getSupportedCommandGroups() override; |
204 | | virtual css::uno::Sequence < css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation(sal_Int16 nCommandGroup) override; |
205 | | |
206 | | // XWindowListener |
207 | | // Attention: only windowResized() and windowShown() are implemented! All others are empty! |
208 | | |
209 | | virtual void SAL_CALL windowResized(const css::awt::WindowEvent & aEvent) override; |
210 | 0 | virtual void SAL_CALL windowMoved(const css::awt::WindowEvent & /*aEvent*/ ) override {}; |
211 | | virtual void SAL_CALL windowShown(const css::lang::EventObject & aEvent) override; |
212 | | virtual void SAL_CALL windowHidden(const css::lang::EventObject & aEvent) override; |
213 | | |
214 | | // XFocusListener |
215 | | // Attention: focusLost() not implemented yet! |
216 | | |
217 | | virtual void SAL_CALL focusGained(const css::awt::FocusEvent & aEvent) override; |
218 | 0 | virtual void SAL_CALL focusLost(const css::awt::FocusEvent & /*aEvent*/ ) override {}; |
219 | | |
220 | | // XTopWindowListener |
221 | | // Attention: only windowActivated(), windowDeactivated() and windowClosing() are implemented! All others are empty! |
222 | | |
223 | | virtual void SAL_CALL windowActivated(const css::lang::EventObject & aEvent) override; |
224 | | virtual void SAL_CALL windowDeactivated(const css::lang::EventObject & aEvent) override; |
225 | 0 | virtual void SAL_CALL windowOpened(const css::lang::EventObject & /*aEvent*/ ) override {}; |
226 | | virtual void SAL_CALL windowClosing(const css::lang::EventObject & aEvent) override; |
227 | 0 | virtual void SAL_CALL windowClosed(const css::lang::EventObject & /*aEvent*/ ) override {}; |
228 | 0 | virtual void SAL_CALL windowMinimized(const css::lang::EventObject & /*aEvent*/ ) override {}; |
229 | 0 | virtual void SAL_CALL windowNormalized(const css::lang::EventObject & /*aEvent*/ ) override {}; |
230 | | |
231 | | // XEventListener |
232 | | |
233 | | virtual void SAL_CALL disposing(const css::lang::EventObject & aEvent) override; |
234 | | |
235 | | // XActionLockable |
236 | | |
237 | | virtual sal_Bool SAL_CALL isActionLocked() override; |
238 | | virtual void SAL_CALL addActionLock() override; |
239 | | virtual void SAL_CALL removeActionLock() override; |
240 | | virtual void SAL_CALL setActionLocks(sal_Int16 nLock) override; |
241 | | virtual sal_Int16 SAL_CALL resetActionLocks() override; |
242 | | |
243 | | // XCloseable |
244 | | |
245 | | virtual void SAL_CALL close(sal_Bool bDeliverOwnership) override; |
246 | | |
247 | | // XCloseBroadcaster |
248 | | |
249 | | virtual void SAL_CALL addCloseListener(const css::uno::Reference < css::util::XCloseListener > & xListener) override; |
250 | | virtual void SAL_CALL removeCloseListener(const css::uno::Reference < css::util::XCloseListener > & xListener) override; |
251 | | |
252 | | // XTitle |
253 | | |
254 | | virtual OUString SAL_CALL getTitle() override; |
255 | | virtual void SAL_CALL setTitle(const OUString & sTitle) override; |
256 | | |
257 | | // XTitleChangeBroadcaster |
258 | | |
259 | | virtual void SAL_CALL addTitleChangeListener(const css::uno::Reference < css::frame::XTitleChangeListener > & xListener) override; |
260 | | virtual void SAL_CALL removeTitleChangeListener(const css::uno::Reference < css::frame::XTitleChangeListener > & xListenr) override; |
261 | | |
262 | | // XFrame2 attributes |
263 | | |
264 | | virtual css::uno::Reference < css::container::XNameContainer > SAL_CALL getUserDefinedAttributes() override; |
265 | | |
266 | | virtual css::uno::Reference < css::frame::XDispatchRecorderSupplier > SAL_CALL getDispatchRecorderSupplier() override; |
267 | | virtual void SAL_CALL setDispatchRecorderSupplier(const css::uno::Reference < css::frame::XDispatchRecorderSupplier > & ) override; |
268 | | |
269 | | virtual css::uno::Reference < css::uno::XInterface > SAL_CALL getLayoutManager() override; |
270 | | virtual void SAL_CALL setLayoutManager(const css::uno::Reference < css::uno::XInterface > & ) override; |
271 | | |
272 | | // XPropertySet |
273 | | virtual css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; |
274 | | |
275 | | virtual void SAL_CALL setPropertyValue(const OUString & sProperty, const css::uno::Any & aValue) override; |
276 | | |
277 | | virtual css::uno::Any SAL_CALL getPropertyValue(const OUString & sProperty) override; |
278 | | |
279 | | virtual void SAL_CALL addPropertyChangeListener( |
280 | | const OUString & sProperty, |
281 | | const css::uno::Reference < css::beans::XPropertyChangeListener > & xListener) override; |
282 | | |
283 | | virtual void SAL_CALL removePropertyChangeListener( |
284 | | const OUString & sProperty, |
285 | | const css::uno::Reference < css::beans::XPropertyChangeListener > & xListener) override; |
286 | | |
287 | | virtual void SAL_CALL addVetoableChangeListener( |
288 | | const OUString & sProperty, |
289 | | const css::uno::Reference < css::beans::XVetoableChangeListener > & xListener) override; |
290 | | |
291 | | virtual void SAL_CALL removeVetoableChangeListener( |
292 | | const OUString & sProperty, |
293 | | const css::uno::Reference < css::beans::XVetoableChangeListener > & xListener) override; |
294 | | |
295 | | // XPropertySetInfo |
296 | | virtual css::uno::Sequence < css::beans::Property > SAL_CALL getProperties() override; |
297 | | |
298 | | virtual css::beans::Property SAL_CALL getPropertyByName(const OUString & sName) override; |
299 | | |
300 | | virtual sal_Bool SAL_CALL hasPropertyByName(const OUString & sName) override; |
301 | | |
302 | | |
303 | | private: |
304 | | |
305 | | void impl_setPropertyValue(sal_Int32 nHandle, |
306 | | const css::uno::Any& aValue); |
307 | | |
308 | | css::uno::Any impl_getPropertyValue(sal_Int32 nHandle); |
309 | | |
310 | | /** set a new owner for this helper. |
311 | | * |
312 | | * This owner is used as source for all broadcasted events. |
313 | | * Further we hold it weak, because we don't wish to be disposed() .-) |
314 | | */ |
315 | | void impl_setPropertyChangeBroadcaster(XFrameImpl& rBroadcaster); |
316 | | |
317 | | /** add a new property info to the set of supported ones. |
318 | | * |
319 | | * @param aProperty |
320 | | * describes the new property. |
321 | | * |
322 | | * @throw [css::beans::PropertyExistException] |
323 | | * if a property with the same name already exists. |
324 | | * |
325 | | * Note: The consistence of the whole set of properties is not checked here. |
326 | | * Meaning e.g. a handle which exists more than once is not detected. |
327 | | * The owner of this class has to be sure, that no new property |
328 | | * clashes with an existing one. |
329 | | */ |
330 | | void impl_addPropertyInfo(const OUString& rName, FramePropHandle eHandle, const css::uno::Type& rType, sal_Int16 nAttributes); |
331 | | /** mark the object as "dead". |
332 | | */ |
333 | | void impl_disablePropertySet(); |
334 | | |
335 | | bool impl_existsVeto(const css::beans::PropertyChangeEvent& aEvent); |
336 | | |
337 | | void impl_notifyChangeListener(const css::beans::PropertyChangeEvent& aEvent); |
338 | | |
339 | | /*-**************************************************************************************************** |
340 | | @short helper methods |
341 | | @descr The following methods are needed at different points in our code (more than once!). |
342 | | |
343 | | @attention Threadsafe methods are signed by "implts_..."! |
344 | | *//*-*****************************************************************************************************/ |
345 | | |
346 | | // threadsafe |
347 | | void implts_sendFrameActionEvent ( const css::frame::FrameAction& aAction ); |
348 | | void implts_resizeComponentWindow ( ); |
349 | | void implts_setIconOnWindow ( ); |
350 | | void implts_startWindowListening ( ); |
351 | | void implts_stopWindowListening ( ); |
352 | | void implts_checkSuicide ( ); |
353 | | void implts_forgetSubFrames ( ); |
354 | | |
355 | | // non threadsafe |
356 | | void impl_checkMenuCloser ( ); |
357 | | static void impl_setCloser ( const css::uno::Reference< css::frame::XFrame2 >& xFrame , bool bState ); |
358 | | |
359 | | void disableLayoutManager(const css::uno::Reference< css::frame::XLayoutManager2 >& xLayoutManager); |
360 | | |
361 | 50.8M | void checkDisposed() { |
362 | 50.8M | osl::MutexGuard g(rBHelper.rMutex); |
363 | 50.8M | if (rBHelper.bInDispose || rBHelper.bDisposed) { |
364 | 0 | throw css::lang::DisposedException(u"Frame disposed"_ustr); |
365 | 0 | } |
366 | 50.8M | } |
367 | | |
368 | | // variables |
369 | | // -threadsafe by SolarMutex |
370 | | |
371 | | /// reference to factory, which has created this instance |
372 | | css::uno::Reference< css::uno::XComponentContext > m_xContext; |
373 | | /// reference to factory helper to create status indicator objects |
374 | | css::uno::Reference< css::task::XStatusIndicatorFactory > m_xIndicatorFactoryHelper; |
375 | | /// points to an external set progress, which should be used instead of the internal one. |
376 | | css::uno::WeakReference< css::task::XStatusIndicator > m_xIndicatorInterception; |
377 | | /// helper for XDispatch/Provider and interception interfaces |
378 | | rtl::Reference< InterceptionHelper > m_xDispatchHelper; |
379 | | /// helper for XFrames, XIndexAccess and XElementAccess interfaces |
380 | | rtl::Reference< OFrames > m_xFramesHelper; |
381 | | /// container for ALL Listeners |
382 | | comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer; |
383 | | /// parent of this frame |
384 | | css::uno::Reference< css::frame::XFramesSupplier > m_xParent; |
385 | | /// containerwindow of this frame for embedded components |
386 | | css::uno::Reference< css::awt::XWindow > m_xContainerWindow; |
387 | | /// window of the actual component |
388 | | css::uno::Reference< css::awt::XWindow > m_xComponentWindow; |
389 | | /// controller of the actual frame |
390 | | css::uno::Reference< css::frame::XController > m_xController; |
391 | | /// listen to drag & drop |
392 | | rtl::Reference< OpenFileDropTargetListener > m_xDropTargetListener; |
393 | | /// state, if I am a member of an active path in the tree or I have the focus or... |
394 | | EActiveState m_eActiveState; |
395 | | /// name of this frame |
396 | | OUString m_sName; |
397 | | /// frame has no parent or the parent is a task or the desktop |
398 | | bool m_bIsFrameTop; |
399 | | /// due to FrameActionEvent |
400 | | bool m_bConnected; |
401 | | sal_Int16 m_nExternalLockCount; |
402 | | /// is used for dispatch recording and will be set/get from outside. Only the frame provides it! |
403 | | css::uno::Reference< css::frame::XDispatchRecorderSupplier > m_xDispatchRecorderSupplier; |
404 | | /// ref counted class to support disabling commands defined by configuration file |
405 | | SvtCommandOptions m_aCommandOptions; |
406 | | /// in case of CloseVetoException on method close() was thrown by ourselves, we must close ourselves later if no internal processes are running |
407 | | bool m_bSelfClose; |
408 | | /// indicates, if this frame is used in hidden mode or not |
409 | | bool m_bIsHidden; |
410 | | /// The container window has WindowExtendedStyle::DocHidden set. |
411 | | bool m_bDocHidden = false; |
412 | | /// Is used to layout the child windows of the frame. |
413 | | css::uno::Reference< css::frame::XLayoutManager2 > m_xLayoutManager; |
414 | | rtl::Reference< DispatchInformationProvider > m_xDispatchInfoHelper; |
415 | | rtl::Reference< TitleHelper > m_xTitleHelper; |
416 | | |
417 | | std::unique_ptr<WindowCommandDispatch> m_pWindowCommandDispatch; |
418 | | |
419 | | typedef std::unordered_map<OUString, css::beans::Property> TPropInfoHash; |
420 | | TPropInfoHash m_lProps; |
421 | | |
422 | | comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertyChangeListener, OUString> m_lSimpleChangeListener; |
423 | | comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XVetoableChangeListener, OUString> m_lVetoChangeListener; |
424 | | |
425 | | // hold it weak ... otherwise this helper has to be "killed" explicitly .-) |
426 | | unotools::WeakReference< XFrameImpl > m_xBroadcaster; |
427 | | |
428 | | FrameContainer m_aChildFrameContainer; /// array of child frames |
429 | | /** |
430 | | * URL of the file that is being loaded. During the loading we don't have a controller yet. |
431 | | */ |
432 | | OUString m_aURL; |
433 | | }; |
434 | | |
435 | | |
436 | | /*-**************************************************************************************************** |
437 | | @short standard constructor to create instance by factory |
438 | | @descr This constructor initializes a new instance of this class by valid factory, |
439 | | and will be set valid values on its member and base classes. |
440 | | |
441 | | @attention a) Don't use your own reference during a UNO-Service-ctor! There is no guarantee, that you |
442 | | will succeed (e.g. using your reference as parameter to initialize some member). |
443 | | Do such things in the DEFINE_INIT_SERVICE() method, which is called automatically after your ctor!!! |
444 | | b) Base class OBroadcastHelper is a typedef in namespace cppu! |
445 | | The Microsoft compiler has some problems to handle it right by using namespace explicitly ::cppu::OBroadcastHelper. |
446 | | If we write it without a namespace or expand the typedef to OBroadcastHelperVar<...> -> it will be OK!? |
447 | | I don't know why! (other compilers not tested, but it works!) |
448 | | |
449 | | @seealso method DEFINE_INIT_SERVICE() |
450 | | |
451 | | @param xContext is the multi service manager, which creates this instance. |
452 | | The value must be different from NULL! |
453 | | @onerror ASSERT in debug version or nothing in release version. |
454 | | *//*-*****************************************************************************************************/ |
455 | | XFrameImpl::XFrameImpl( css::uno::Reference< css::uno::XComponentContext > xContext ) |
456 | 11.0k | : PartialWeakComponentImplHelper(m_aMutex) |
457 | | // init member |
458 | 11.0k | , m_xContext (std::move( xContext )) |
459 | 11.0k | , m_aListenerContainer ( m_aMutex ) |
460 | 11.0k | , m_eActiveState ( E_INACTIVE ) |
461 | 11.0k | , m_bIsFrameTop ( true ) // I think we are top without a parent and there is no parent yet! |
462 | 11.0k | , m_bConnected ( false ) // There exists no component inside of us => sal_False, we are not connected! |
463 | 11.0k | , m_nExternalLockCount ( 0 ) |
464 | 11.0k | , m_bSelfClose ( false ) // Important! |
465 | 11.0k | , m_bIsHidden ( true ) |
466 | 11.0k | , m_lSimpleChangeListener ( m_aMutex ) |
467 | 11.0k | , m_lVetoChangeListener ( m_aMutex ) |
468 | 11.0k | { |
469 | 11.0k | } |
470 | | |
471 | | void XFrameImpl::initListeners() |
472 | 11.0k | { |
473 | 11.0k | css::uno::Reference< css::uno::XInterface > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY_THROW); |
474 | | |
475 | | // Initialize a new DispatchHelper-object to handle dispatches. |
476 | | // We use this helper as a slave for our interceptor helper, not directly! |
477 | | // But the helper is an event listener in THIS instance! |
478 | 11.0k | rtl::Reference<DispatchProvider> xDispatchProvider = new DispatchProvider( m_xContext, this ); |
479 | | |
480 | 11.0k | m_xDispatchInfoHelper = new DispatchInformationProvider(m_xContext, this); |
481 | | |
482 | | // Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism. |
483 | | // Set created dispatch provider as slowest slave of it. |
484 | | // Hold interception helper by reference only - not by pointer! |
485 | | // So it's easier to destroy it. |
486 | 11.0k | m_xDispatchHelper = new InterceptionHelper( this, xDispatchProvider ); |
487 | | |
488 | | // Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess. |
489 | | // We only hold the member as reference and not as pointer! |
490 | | // Attention: we share our frame container with this helper. Container itself is threadsafe ... So I think we can do that. |
491 | | // But look at dispose() for the right order of deinitialization. |
492 | 11.0k | m_xFramesHelper = new OFrames( this, &m_aChildFrameContainer ); |
493 | | |
494 | | // Initialize the drop target listener. |
495 | | // We only hold the member as reference and not as pointer! |
496 | 11.0k | m_xDropTargetListener = new OpenFileDropTargetListener( m_xContext, this ); |
497 | | |
498 | | // Safe impossible cases |
499 | | // We can't work without these helpers! |
500 | 11.0k | SAL_WARN_IF( !xDispatchProvider.is(), "fwk.frame", "XFrameImpl::XFrameImpl(): Slowest slave for dispatch- and interception helper " |
501 | 11.0k | "is not valid. XDispatchProvider, XDispatch, XDispatchProviderInterception are not full supported!" ); |
502 | 11.0k | SAL_WARN_IF( !m_xDispatchHelper.is(), "fwk.frame", "XFrameImpl::XFrameImpl(): Interception helper is not valid. XDispatchProvider, " |
503 | 11.0k | "XDispatch, XDispatchProviderInterception are not full supported!" ); |
504 | 11.0k | SAL_WARN_IF( !m_xFramesHelper.is(), "fwk.frame", "XFrameImpl::XFrameImpl(): Frames helper is not valid. XFrames, " |
505 | 11.0k | "XIndexAccess and XElementAccess are not supported!" ); |
506 | 11.0k | SAL_WARN_IF( !m_xDropTargetListener.is(), "fwk.frame", "XFrameImpl::XFrameImpl(): DropTarget helper is not valid. " |
507 | 11.0k | "Drag and drop without functionality!" ); |
508 | | |
509 | | // establish notifications for changing of "disabled commands" configuration during runtime |
510 | 11.0k | m_aCommandOptions.EstablishFrameCallback(this); |
511 | | |
512 | | // Create an initial layout manager |
513 | | // Create layout manager and connect it to the newly created frame |
514 | 11.0k | m_xLayoutManager = css::frame::LayoutManager::create(m_xContext); |
515 | | |
516 | | // set information about all supported properties |
517 | 11.0k | impl_setPropertyChangeBroadcaster(*this); |
518 | 11.0k | impl_addPropertyInfo( |
519 | 11.0k | FramePropNames[FramePropHandle::DispatchRecorderSupplier], |
520 | 11.0k | FramePropHandle::DispatchRecorderSupplier, |
521 | 11.0k | cppu::UnoType<css::frame::XDispatchRecorderSupplier>::get(), |
522 | 11.0k | css::beans::PropertyAttribute::TRANSIENT); |
523 | 11.0k | impl_addPropertyInfo( |
524 | 11.0k | FramePropNames[FramePropHandle::IndicatorInterception], |
525 | 11.0k | FramePropHandle::IndicatorInterception, |
526 | 11.0k | cppu::UnoType<css::task::XStatusIndicator>::get(), |
527 | 11.0k | css::beans::PropertyAttribute::TRANSIENT); |
528 | 11.0k | impl_addPropertyInfo( |
529 | 11.0k | FramePropNames[FramePropHandle::IsHidden], |
530 | 11.0k | FramePropHandle::IsHidden, |
531 | 11.0k | cppu::UnoType<bool>::get(), |
532 | 11.0k | css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY); |
533 | 11.0k | impl_addPropertyInfo( |
534 | 11.0k | FramePropNames[FramePropHandle::LayoutManager], |
535 | 11.0k | FramePropHandle::LayoutManager, |
536 | 11.0k | cppu::UnoType<css::frame::XLayoutManager>::get(), |
537 | 11.0k | css::beans::PropertyAttribute::TRANSIENT); |
538 | 11.0k | impl_addPropertyInfo( |
539 | 11.0k | FramePropNames[FramePropHandle::Title], |
540 | 11.0k | FramePropHandle::Title, |
541 | 11.0k | cppu::UnoType<OUString>::get(), |
542 | 11.0k | css::beans::PropertyAttribute::TRANSIENT); |
543 | 11.0k | impl_addPropertyInfo( |
544 | 11.0k | FramePropNames[FramePropHandle::Url], |
545 | 11.0k | FramePropHandle::Url, |
546 | 11.0k | cppu::UnoType<OUString>::get(), |
547 | 11.0k | css::beans::PropertyAttribute::TRANSIENT); |
548 | 11.0k | } |
549 | | |
550 | | /*-************************************************************************************************************ |
551 | | @interface XComponentLoader |
552 | | @short try to load given URL into a task |
553 | | @descr You can give us some information about the content, which you will load into a frame. |
554 | | We search or create this target for you, make a type detection of the given URL and try to load it. |
555 | | As result of this operation we return the new created component or nothing, if loading failed. |
556 | | @param "sURL" , URL, which represents the content |
557 | | @param "sTargetFrameName" , name of target frame or special value like "_self", "_blank" ... |
558 | | @param "nSearchFlags" , optional arguments for frame search, if target is not a special one |
559 | | @param "lArguments" , optional arguments for loading |
560 | | @return A valid component reference, if loading was successful. |
561 | | A null reference otherwise. |
562 | | |
563 | | @onerror We return a null reference. |
564 | | @threadsafe yes |
565 | | *//*-*************************************************************************************************************/ |
566 | | css::uno::Reference< css::lang::XComponent > SAL_CALL XFrameImpl::loadComponentFromURL( |
567 | | const OUString& sURL, |
568 | | const OUString& sTargetFrameName, |
569 | | sal_Int32 nSearchFlags, |
570 | | const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) |
571 | 0 | { |
572 | 0 | checkDisposed(); |
573 | |
|
574 | 0 | css::uno::Reference< css::frame::XComponentLoader > xThis(this); |
575 | |
|
576 | 0 | comphelper::SequenceAsHashMap aDescriptor(lArguments); |
577 | 0 | bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault(u"OnMainThread"_ustr, false); |
578 | |
|
579 | 0 | if (bOnMainThread) |
580 | 0 | { |
581 | | // Make sure that we own the solar mutex, otherwise later |
582 | | // vcl::SolarThreadExecutor::execute() will release the solar mutex, even if it's owned by |
583 | | // another thread, leading to an std::abort() at the end. |
584 | 0 | SolarMutexGuard g; |
585 | |
|
586 | 0 | return vcl::solarthread::syncExecute([this, xThis, sURL, sTargetFrameName, nSearchFlags, lArguments] { |
587 | 0 | return LoadEnv::loadComponentFromURL(xThis, m_xContext, sURL, sTargetFrameName, |
588 | 0 | nSearchFlags, lArguments); |
589 | 0 | }); |
590 | 0 | } |
591 | 0 | else |
592 | 0 | return LoadEnv::loadComponentFromURL(xThis, m_xContext, sURL, sTargetFrameName, |
593 | 0 | nSearchFlags, lArguments); |
594 | 0 | } |
595 | | |
596 | | /*-**************************************************************************************************** |
597 | | @short return access to append or remove children on desktop |
598 | | @descr We don't implement this interface directly. We use a helper class to do this. |
599 | | If you wish to add or delete children to/from the container, call this method to get |
600 | | a reference to the helper. |
601 | | |
602 | | @seealso class OFrames |
603 | | @return A reference to the helper which answers your queries. |
604 | | |
605 | | @onerror A null reference is returned. |
606 | | *//*-*****************************************************************************************************/ |
607 | | css::uno::Reference< css::frame::XFrames > SAL_CALL XFrameImpl::getFrames() |
608 | 0 | { |
609 | 0 | checkDisposed(); |
610 | |
|
611 | 0 | SolarMutexGuard g; |
612 | | // Return access to all child frames to caller. |
613 | | // Our childframe container is implemented in helper class OFrames and used as a reference m_xFramesHelper! |
614 | 0 | return m_xFramesHelper; |
615 | 0 | } |
616 | | |
617 | | /*-**************************************************************************************************** |
618 | | @short get the current active child frame |
619 | | @descr It must be a frame, too. Direct children of a frame are frames only! No task or desktop is accepted. |
620 | | We don't save this information directly in this class. We use our container-helper |
621 | | to do that. |
622 | | |
623 | | @seealso class OFrameContainer |
624 | | @seealso method setActiveFrame() |
625 | | @return A reference to our current active childframe, if any exist. |
626 | | @return A null reference, if nobody is active. |
627 | | |
628 | | @onerror A null reference is returned. |
629 | | *//*-*****************************************************************************************************/ |
630 | | css::uno::Reference< css::frame::XFrame > SAL_CALL XFrameImpl::getActiveFrame() |
631 | 0 | { |
632 | 0 | checkDisposed(); |
633 | |
|
634 | 0 | SolarMutexGuard g; |
635 | | // Return current active frame. |
636 | | // This information is available via the container. |
637 | 0 | return m_aChildFrameContainer.getActive(); |
638 | 0 | } |
639 | | |
640 | | /*-**************************************************************************************************** |
641 | | @short set the new active direct child frame |
642 | | @descr It must be a frame, too. Direct children of frame are frames only! No task or desktop is accepted. |
643 | | We don't save this information directly in this class. We use our container-helper |
644 | | to do that. |
645 | | |
646 | | @seealso class OFrameContainer |
647 | | @seealso method getActiveFrame() |
648 | | |
649 | | @param "xFrame", reference to new active child. It must be an already existing child! |
650 | | @onerror An assertion is thrown and element is ignored, if the given frame isn't already a child of us. |
651 | | *//*-*****************************************************************************************************/ |
652 | | void SAL_CALL XFrameImpl::setActiveFrame( const css::uno::Reference< css::frame::XFrame >& xFrame ) |
653 | 6.21k | { |
654 | 6.21k | checkDisposed(); |
655 | | |
656 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
657 | 6.21k | SolarMutexResettableGuard aWriteLock; |
658 | | |
659 | | // Copy necessary member for threadsafe access! |
660 | | // m_aChildFrameContainer itself is threadsafe and it lives if we live!!! |
661 | 6.21k | css::uno::Reference< css::frame::XFrame > xActiveChild = m_aChildFrameContainer.getActive(); |
662 | 6.21k | EActiveState eActiveState = m_eActiveState; |
663 | | |
664 | 6.21k | aWriteLock.clear(); |
665 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
666 | | |
667 | | // Don't work, if "new" active frame isn't different from current one! |
668 | | // (xFrame==NULL is allowed to UNSET it!) |
669 | 6.21k | if( xActiveChild != xFrame ) |
670 | 0 | { |
671 | | // ... otherwise set new and deactivate old one. |
672 | 0 | m_aChildFrameContainer.setActive( xFrame ); |
673 | 0 | if ( |
674 | 0 | ( eActiveState != E_INACTIVE ) && |
675 | 0 | xActiveChild.is() |
676 | 0 | ) |
677 | 0 | { |
678 | 0 | xActiveChild->deactivate(); |
679 | 0 | } |
680 | 0 | } |
681 | | |
682 | 6.21k | if( xFrame.is() ) |
683 | 0 | { |
684 | | // If last active frame had focus ... |
685 | | // ... reset state to ACTIVE and send right FrameActionEvent for focus lost. |
686 | 0 | if( eActiveState == E_FOCUS ) |
687 | 0 | { |
688 | 0 | aWriteLock.reset(); |
689 | 0 | eActiveState = E_ACTIVE; |
690 | 0 | m_eActiveState = eActiveState; |
691 | 0 | aWriteLock.clear(); |
692 | 0 | implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_UI_DEACTIVATING ); |
693 | 0 | } |
694 | | |
695 | | // If last active frame was active ... |
696 | | // but new one is not it ... |
697 | | // ... set it as the active one. |
698 | 0 | if ( eActiveState == E_ACTIVE && !xFrame->isActive() ) |
699 | 0 | { |
700 | 0 | xFrame->activate(); |
701 | 0 | } |
702 | 0 | } |
703 | 6.21k | else |
704 | | // If this frame is active and has no active subframe anymore it is UI active too |
705 | 6.21k | if( eActiveState == E_ACTIVE ) |
706 | 0 | { |
707 | 0 | aWriteLock.reset(); |
708 | 0 | eActiveState = E_FOCUS; |
709 | 0 | m_eActiveState = eActiveState; |
710 | 0 | aWriteLock.clear(); |
711 | 0 | implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_UI_ACTIVATED ); |
712 | 0 | } |
713 | 6.21k | } |
714 | | |
715 | | /*-**************************************************************************************************** |
716 | | initialize new created layout manager |
717 | | **/ |
718 | | void lcl_enableLayoutManager(const css::uno::Reference< css::frame::XLayoutManager2 >& xLayoutManager, |
719 | | const css::uno::Reference< css::frame::XFrame >& xFrame ) |
720 | 11.0k | { |
721 | | // Provide container window to our layout manager implementation |
722 | 11.0k | xLayoutManager->attachFrame(xFrame); |
723 | | |
724 | 11.0k | xFrame->addFrameActionListener(xLayoutManager); |
725 | | |
726 | 11.0k | rtl::Reference<DockingAreaDefaultAcceptor> xDockingAreaAcceptor = new DockingAreaDefaultAcceptor(xFrame); |
727 | 11.0k | xLayoutManager->setDockingAreaAcceptor(xDockingAreaAcceptor); |
728 | 11.0k | } |
729 | | |
730 | | /*-**************************************************************************************************** |
731 | | deinitialize layout manager |
732 | | **/ |
733 | | void XFrameImpl::disableLayoutManager(const css::uno::Reference< css::frame::XLayoutManager2 >& xLayoutManager) |
734 | 6.21k | { |
735 | 6.21k | removeFrameActionListener(xLayoutManager); |
736 | 6.21k | xLayoutManager->setDockingAreaAcceptor(css::uno::Reference< css::ui::XDockingAreaAcceptor >()); |
737 | 6.21k | xLayoutManager->attachFrame(css::uno::Reference< css::frame::XFrame >()); |
738 | 6.21k | } |
739 | | |
740 | | /*-**************************************************************************************************** |
741 | | @short initialize frame instance |
742 | | @descr A frame needs a window. This method sets a new one, but should only be called once! |
743 | | We use this window to listen for window events and to forward them to our set component. |
744 | | It's used as a parent of component window, too. |
745 | | |
746 | | @seealso method getContainerWindow() |
747 | | @seealso method setComponent() |
748 | | @seealso member m_xContainerWindow |
749 | | |
750 | | @param "xWindow", reference to a new container window - must be valid! |
751 | | @onerror We do nothing. |
752 | | *//*-*****************************************************************************************************/ |
753 | | void SAL_CALL XFrameImpl::initialize( const css::uno::Reference< css::awt::XWindow >& xWindow ) |
754 | 11.0k | { |
755 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
756 | 11.0k | if (!xWindow.is()) |
757 | 0 | throw css::uno::RuntimeException( |
758 | 0 | u"XFrameImpl::initialize() called without a valid container window reference."_ustr, |
759 | 0 | static_cast< css::frame::XFrame* >(this)); |
760 | | |
761 | 11.0k | checkDisposed(); |
762 | | |
763 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
764 | 11.0k | SolarMutexResettableGuard aWriteLock; |
765 | | |
766 | | // This must be the first call of this method! |
767 | | // We should initialize our object and open it for working. |
768 | 11.0k | if ( m_xContainerWindow.is() ) |
769 | 0 | throw css::uno::RuntimeException( |
770 | 0 | u"XFrameImpl::initialized() is called more than once, which is not useful nor allowed."_ustr, |
771 | 0 | static_cast< css::frame::XFrame* >(this)); |
772 | | |
773 | | // Set the new window. |
774 | 11.0k | m_xContainerWindow = xWindow; |
775 | | |
776 | | // if window is initially visible, we will never get a windowShowing event |
777 | 11.0k | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow); |
778 | 11.0k | if (pWindow) |
779 | 11.0k | { |
780 | 11.0k | if (pWindow->IsVisible()) |
781 | 0 | m_bIsHidden = false; |
782 | 11.0k | m_bDocHidden |
783 | 11.0k | = static_cast<bool>(pWindow->GetExtendedStyle() & WindowExtendedStyle::DocHidden); |
784 | 11.0k | } |
785 | | |
786 | 11.0k | css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager = m_xLayoutManager; |
787 | | |
788 | | // Release lock, because we call some impl methods, which are threadsafe by themselves. |
789 | | // If we hold this lock - we will produce our own deadlock! |
790 | 11.0k | aWriteLock.clear(); |
791 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
792 | | |
793 | | // Avoid enabling the layout manager for hidden frames: it's expensive and |
794 | | // provides little value. |
795 | 11.0k | if (xLayoutManager.is() && !m_bDocHidden) |
796 | 11.0k | lcl_enableLayoutManager(xLayoutManager, this); |
797 | | |
798 | | // create progress helper |
799 | 11.0k | css::uno::Reference< css::frame::XFrame > xThis (this); |
800 | 11.0k | { |
801 | 11.0k | css::uno::Reference< css::task::XStatusIndicatorFactory > xIndicatorFactory = |
802 | 11.0k | css::task::StatusIndicatorFactory::createWithFrame(m_xContext, xThis, |
803 | 11.0k | false/*DisableReschedule*/, true/*AllowParentShow*/ ); |
804 | | |
805 | | // SAFE -> ---------------------------------- |
806 | 11.0k | aWriteLock.reset(); |
807 | 11.0k | m_xIndicatorFactoryHelper = std::move(xIndicatorFactory); |
808 | 11.0k | aWriteLock.clear(); |
809 | | // <- SAFE ---------------------------------- |
810 | 11.0k | } |
811 | | |
812 | | // Start listening for events after setting it on helper class. |
813 | | // So superfluous messages are filtered to NULL :-) |
814 | 11.0k | implts_startWindowListening(); |
815 | | |
816 | 11.0k | m_pWindowCommandDispatch.reset(new WindowCommandDispatch(m_xContext, this)); |
817 | | |
818 | | // Initialize title functionality |
819 | 11.0k | m_xTitleHelper = new TitleHelper( m_xContext, xThis, nullptr ); |
820 | 11.0k | } |
821 | | |
822 | | /*-**************************************************************************************************** |
823 | | @short returns currently set container window |
824 | | @descr The ContainerWindow property is used as a container for the component |
825 | | in this frame. So this object implements a container interface too. |
826 | | The instantiation of the container window is done by the user of this class. |
827 | | The frame is the owner of its container window. |
828 | | |
829 | | @seealso method initialize() |
830 | | @return A reference to the currently set containerwindow. |
831 | | |
832 | | @onerror A null reference is returned. |
833 | | *//*-*****************************************************************************************************/ |
834 | | css::uno::Reference< css::awt::XWindow > SAL_CALL XFrameImpl::getContainerWindow() |
835 | 137k | { |
836 | 137k | SolarMutexGuard g; |
837 | 137k | return m_xContainerWindow; |
838 | 137k | } |
839 | | |
840 | | /*-**************************************************************************************************** |
841 | | @short set parent frame |
842 | | @descr We need a parent to support some functionality! e.g. findFrame() |
843 | | By the way, we use the chance to set internal information about our top state. |
844 | | So we must not check this information during every isTop() call. |
845 | | We are top, if our parent is the desktop instance or we have no parent. |
846 | | |
847 | | @seealso getCreator() |
848 | | @seealso findFrame() |
849 | | @seealso isTop() |
850 | | @seealso m_bIsFrameTop |
851 | | |
852 | | @param xCreator |
853 | | valid reference to our new owner frame, which should implement a supplier interface |
854 | | |
855 | | @threadsafe yes |
856 | | *//*-*****************************************************************************************************/ |
857 | | void SAL_CALL XFrameImpl::setCreator( const css::uno::Reference< css::frame::XFramesSupplier >& xCreator ) |
858 | 11.0k | { |
859 | 11.0k | checkDisposed(); |
860 | | |
861 | | /* SAFE { */ |
862 | 11.0k | { |
863 | 11.0k | SolarMutexGuard aWriteLock; |
864 | 11.0k | m_xParent = xCreator; |
865 | 11.0k | } |
866 | | /* } SAFE */ |
867 | | |
868 | 11.0k | css::uno::Reference< css::frame::XDesktop > xIsDesktop( xCreator, css::uno::UNO_QUERY ); |
869 | 11.0k | m_bIsFrameTop = ( xIsDesktop.is() || ! xCreator.is() ); |
870 | 11.0k | } |
871 | | |
872 | | /*-**************************************************************************************************** |
873 | | @short returns current parent frame |
874 | | @descr The Creator is the parent frame container. If it is NULL, the frame is the topmost one. |
875 | | |
876 | | @seealso method setCreator() |
877 | | @return A reference to currently set parent frame container. |
878 | | |
879 | | @onerror A null reference is returned. |
880 | | *//*-*****************************************************************************************************/ |
881 | | css::uno::Reference< css::frame::XFramesSupplier > SAL_CALL XFrameImpl::getCreator() |
882 | 0 | { |
883 | 0 | checkDisposed(); |
884 | 0 | SolarMutexGuard g; |
885 | 0 | return m_xParent; |
886 | 0 | } |
887 | | |
888 | | /*-**************************************************************************************************** |
889 | | @short returns currently set name of frame |
890 | | @descr This name is used to find the target of findFrame() or queryDispatch() calls. |
891 | | |
892 | | @seealso method setName() |
893 | | @return Current set name of frame. |
894 | | |
895 | | @onerror An empty string is returned. |
896 | | *//*-*****************************************************************************************************/ |
897 | | OUString SAL_CALL XFrameImpl::getName() |
898 | 25.1M | { |
899 | 25.1M | SolarMutexGuard g; |
900 | 25.1M | return m_sName; |
901 | 25.1M | } |
902 | | |
903 | | /*-**************************************************************************************************** |
904 | | @short set new name for frame |
905 | | @descr This name is used to find the target of findFrame() or queryDispatch() calls. |
906 | | |
907 | | @attention Special names like "_blank", "_self" aren't allowed... |
908 | | "_beamer" is an exception to this rule! |
909 | | |
910 | | @seealso method getName() |
911 | | |
912 | | @param "sName", new frame name. |
913 | | @onerror We do nothing. |
914 | | *//*-*****************************************************************************************************/ |
915 | | void SAL_CALL XFrameImpl::setName( const OUString& sName ) |
916 | 0 | { |
917 | 0 | SolarMutexGuard g; |
918 | | // Set new name... but look for invalid special target names! |
919 | | // They are not allowed to set. |
920 | 0 | if (TargetHelper::isValidNameForFrame(sName)) |
921 | 0 | m_sName = sName; |
922 | 0 | } |
923 | | |
924 | | /*-**************************************************************************************************** |
925 | | @short search for frames |
926 | | @descr This method searches for a frame with the specified name. |
927 | | Frames may contain other frames (e.g. a frameset) and may |
928 | | be contained in other frames. This hierarchy is searched by |
929 | | this method. |
930 | | First some special names are taken into account, i.e. "", |
931 | | "_self", "_top", "_blank" etc. The nSearchFlags are ignored |
932 | | when comparing these names with sTargetFrameName, further steps are |
933 | | controlled by the search flags. If allowed, the name of the frame |
934 | | itself is compared with the desired one, then ( again if allowed ) |
935 | | the method findFrame() is called for all children, for siblings |
936 | | and as last for the parent frame. |
937 | | If no frame with the given name is found until the top frames container, |
938 | | a new top one is created, if this is allowed by a special |
939 | | flag. The new frame also gets the desired name. |
940 | | |
941 | | @param sTargetFrameName |
942 | | special names (_blank, _self) or real name of target frame |
943 | | @param nSearchFlags |
944 | | optional flags which regulate search for non special target frames |
945 | | |
946 | | @return A reference to found or maybe new created frame. |
947 | | @threadsafe yes |
948 | | *//*-*****************************************************************************************************/ |
949 | | css::uno::Reference< css::frame::XFrame > SAL_CALL XFrameImpl::findFrame( const OUString& sTargetFrameName, |
950 | | sal_Int32 nSearchFlags ) |
951 | 6.21k | { |
952 | 6.21k | css::uno::Reference< css::frame::XFrame > xTarget; |
953 | | |
954 | | // 0) Ignore wrong parameters! |
955 | | // We don't support searching for the following special targets. |
956 | | // If we reject these requests, we don't have to keep checking for such names |
957 | | // in the code that follows. If we do not reject them, very wrong |
958 | | // search results may occur! |
959 | | |
960 | 6.21k | if ( sTargetFrameName == SPECIALTARGET_DEFAULT ) // valid for dispatches - not for findFrame()! |
961 | 0 | { |
962 | 0 | return nullptr; |
963 | 0 | } |
964 | | |
965 | | // I) Check for special defined targets first which must be handled exclusive. |
966 | | // Force using of "if() else if() ..." |
967 | | |
968 | | // get threadsafe some members which are necessary for the functionality that follows |
969 | | /* SAFE { */ |
970 | 6.21k | SolarMutexResettableGuard aReadLock; |
971 | 6.21k | css::uno::Reference< css::frame::XFrame > xParent = m_xParent; |
972 | 6.21k | bool bIsTopFrame = m_bIsFrameTop; |
973 | 6.21k | bool bIsTopWindow = WindowHelper::isTopWindow(m_xContainerWindow); |
974 | 6.21k | aReadLock.clear(); |
975 | | /* } SAFE */ |
976 | | |
977 | | // I.I) "_blank" |
978 | | // Not allowed for a normal frame, but for the desktop. |
979 | | // Use helper class to do so. It uses the desktop automatically. |
980 | | |
981 | 6.21k | if ( sTargetFrameName==SPECIALTARGET_BLANK ) |
982 | 0 | { |
983 | 0 | TaskCreator aCreator(m_xContext); |
984 | 0 | xTarget = aCreator.createTask(sTargetFrameName, {}); |
985 | 0 | } |
986 | | |
987 | | // I.II) "_parent" |
988 | | // It doesn't matter if we have a valid parent or not. User asks for it and gets it. |
989 | | // An empty result is a valid result too. |
990 | | |
991 | 6.21k | else if ( sTargetFrameName==SPECIALTARGET_PARENT ) |
992 | 0 | { |
993 | 0 | xTarget = std::move(xParent); |
994 | 0 | } |
995 | | |
996 | | // I.III) "_top" |
997 | | // If we are not the top frame in this hierarchy, we must forward the request to our parent. |
998 | | // Otherwise we must return ourselves. |
999 | | |
1000 | 6.21k | else if ( sTargetFrameName==SPECIALTARGET_TOP ) |
1001 | 0 | { |
1002 | 0 | if (bIsTopFrame) |
1003 | 0 | xTarget = this; |
1004 | 0 | else if (xParent.is()) // If we are not top - the parent MUST exist. But may it's better to check it again .-) |
1005 | 0 | xTarget = xParent->findFrame(SPECIALTARGET_TOP,0); |
1006 | 0 | } |
1007 | | |
1008 | | // I.IV) "_self", "" |
1009 | | // This means this frame in every case. |
1010 | | |
1011 | 6.21k | else if ( |
1012 | 6.21k | ( sTargetFrameName==SPECIALTARGET_SELF ) || |
1013 | 6.21k | ( sTargetFrameName.isEmpty() ) |
1014 | 6.21k | ) |
1015 | 0 | { |
1016 | 0 | xTarget = this; |
1017 | 0 | } |
1018 | | |
1019 | | // I.V) "_beamer" |
1020 | | // This is a special sub frame of any task. We must return it if we found it among our direct children |
1021 | | // or create it there if it does not already exist. |
1022 | | // Note: such a beamer exists for task(top) frames only! |
1023 | | |
1024 | 6.21k | else if ( sTargetFrameName==SPECIALTARGET_BEAMER ) |
1025 | 6.21k | { |
1026 | | // We are a task => search or create the beamer |
1027 | 6.21k | if (bIsTopWindow) |
1028 | 6.21k | { |
1029 | 6.21k | xTarget = m_aChildFrameContainer.searchOnDirectChildrens(SPECIALTARGET_BEAMER); |
1030 | 6.21k | if ( ! xTarget.is() ) |
1031 | 6.21k | { |
1032 | | /* TODO |
1033 | | Creation not supported yet! |
1034 | | Wait for new layout manager service because we can't plug it |
1035 | | inside already opened document of this frame. |
1036 | | */ |
1037 | 6.21k | } |
1038 | 6.21k | } |
1039 | | // We aren't a task => forward the request to our parent or ignore it. |
1040 | 0 | else if (xParent.is()) |
1041 | 0 | xTarget = xParent->findFrame(SPECIALTARGET_BEAMER,0); |
1042 | 6.21k | } |
1043 | | |
1044 | 0 | else |
1045 | 0 | { |
1046 | | |
1047 | | // II) Otherwise use optional given search flags. |
1048 | | // Force using of combinations of such flags. It means there is no "else" part in the used if() statements. |
1049 | | // But we must break further searches if target was already found. |
1050 | | // Order of using flags is fixed: SELF - CHILDREN - SIBLINGS - PARENT |
1051 | | // TASK and CREATE are handled as special cases. |
1052 | | |
1053 | | // get threadsafe some members which are necessary for the functionality that follows |
1054 | | /* SAFE { */ |
1055 | 0 | aReadLock.reset(); |
1056 | 0 | OUString sOwnName = m_sName; |
1057 | 0 | aReadLock.clear(); |
1058 | | /* } SAFE */ |
1059 | | |
1060 | | // II.I) SELF |
1061 | | // Check for the right name. If it's the searched one return ourselves, otherwise |
1062 | | // ignore this flag. |
1063 | |
|
1064 | 0 | if ( |
1065 | 0 | (nSearchFlags & css::frame::FrameSearchFlag::SELF) && |
1066 | 0 | (sOwnName == sTargetFrameName ) |
1067 | 0 | ) |
1068 | 0 | { |
1069 | 0 | xTarget = this; |
1070 | 0 | } |
1071 | | |
1072 | | // II.II) CHILDREN |
1073 | | // Search among all children for the given target name. |
1074 | | // An empty name value can't occur here - because it must be already handled as "_self" |
1075 | | // before. The used helper function of the container doesn't create any frame. |
1076 | | // It only makes a deep search. |
1077 | |
|
1078 | 0 | if ( |
1079 | 0 | ( ! xTarget.is() ) && |
1080 | 0 | (nSearchFlags & css::frame::FrameSearchFlag::CHILDREN) |
1081 | 0 | ) |
1082 | 0 | { |
1083 | 0 | xTarget = m_aChildFrameContainer.searchOnAllChildrens(sTargetFrameName); |
1084 | 0 | } |
1085 | | |
1086 | | // II.III) TASKS |
1087 | | // This is a special flag. It regulates search only on this task tree or allows searching among |
1088 | | // all the other ones (which are sibling trees of us) as well. |
1089 | | // Upper search must stop at this frame if we are the topmost one and the TASK flag is not set |
1090 | | // or we can ignore it if we have no valid parent. |
1091 | |
|
1092 | 0 | if ( |
1093 | 0 | ( bIsTopFrame && (nSearchFlags & css::frame::FrameSearchFlag::TASKS) ) || |
1094 | 0 | ( ! bIsTopFrame ) |
1095 | 0 | ) |
1096 | 0 | { |
1097 | | |
1098 | | // II.III.I) SIBLINGS |
1099 | | // Search among all our direct siblings, meaning all the children of our parent. |
1100 | | // Use this flag in combination with TASK. We must suppress such an upper search if |
1101 | | // the user has not set it and if we are a top frame. |
1102 | | // Attention: don't forward this request to our parent as a findFrame() call. |
1103 | | // In such cases we must protect ourselves from recursive calls. |
1104 | | // Use a snapshot of our parent. But don't use queryFrames() of XFrames interface. |
1105 | | // Because it returns all siblings and all their children including our children, |
1106 | | // if we call it with the CHILDREN flag. We don't need that - we only need the direct container |
1107 | | // items of our parent to start searches there. So we must use the container interface |
1108 | | // XIndexAccess instead of XFrames. |
1109 | |
|
1110 | 0 | if ( |
1111 | 0 | ( ! xTarget.is() ) && |
1112 | 0 | (nSearchFlags & css::frame::FrameSearchFlag::SIBLINGS) && |
1113 | 0 | ( xParent.is() ) // search among siblings is impossible without a parent |
1114 | 0 | ) |
1115 | 0 | { |
1116 | 0 | css::uno::Reference< css::frame::XFramesSupplier > xSupplier( xParent, css::uno::UNO_QUERY ); |
1117 | 0 | if (xSupplier.is()) |
1118 | 0 | { |
1119 | 0 | css::uno::Reference< css::container::XIndexAccess > xContainer = xSupplier->getFrames(); |
1120 | 0 | if (xContainer.is()) |
1121 | 0 | { |
1122 | 0 | sal_Int32 nCount = xContainer->getCount(); |
1123 | 0 | for( sal_Int32 i=0; i<nCount; ++i ) |
1124 | 0 | { |
1125 | 0 | css::uno::Reference< css::frame::XFrame > xSibling; |
1126 | 0 | if ( |
1127 | | // control unpacking |
1128 | 0 | ( !(xContainer->getByIndex(i)>>=xSibling) ) || |
1129 | | // check for valid items |
1130 | 0 | ( ! xSibling.is() ) || |
1131 | | // ignore ourselves! (We are a part of this container too, but search among our children was already done.) |
1132 | 0 | ( xSibling==static_cast< ::cppu::OWeakObject* >(this) ) |
1133 | 0 | ) |
1134 | 0 | { |
1135 | 0 | continue; |
1136 | 0 | } |
1137 | | |
1138 | | // Don't allow upper search here! Use the appropriate flags to regulate it. |
1139 | | // And only allow deep search among children, if it was allowed for us as well. |
1140 | 0 | sal_Int32 nRightFlags = css::frame::FrameSearchFlag::SELF; |
1141 | 0 | if (nSearchFlags & css::frame::FrameSearchFlag::CHILDREN) |
1142 | 0 | nRightFlags |= css::frame::FrameSearchFlag::CHILDREN; |
1143 | 0 | xTarget = xSibling->findFrame(sTargetFrameName, nRightFlags ); |
1144 | | // perform search and break further searching if a result exists |
1145 | 0 | if (xTarget.is()) |
1146 | 0 | break; |
1147 | 0 | } |
1148 | 0 | } |
1149 | 0 | } |
1150 | 0 | } |
1151 | | |
1152 | | // II.III.II) PARENT |
1153 | | // Forward search to our parent (if it exists). |
1154 | | // To avoid recursive and superfluous calls (which can occur if we allow it |
1155 | | // to search among its children too) we must change the used search flags. |
1156 | |
|
1157 | 0 | if ( |
1158 | 0 | ( ! xTarget.is() ) && |
1159 | 0 | (nSearchFlags & css::frame::FrameSearchFlag::PARENT) && |
1160 | 0 | ( xParent.is() ) |
1161 | 0 | ) |
1162 | 0 | { |
1163 | 0 | if (xParent->getName() == sTargetFrameName) |
1164 | 0 | xTarget = std::move(xParent); |
1165 | 0 | else |
1166 | 0 | { |
1167 | 0 | sal_Int32 nRightFlags = nSearchFlags & ~css::frame::FrameSearchFlag::CHILDREN; |
1168 | 0 | xTarget = xParent->findFrame(sTargetFrameName, nRightFlags); |
1169 | 0 | } |
1170 | 0 | } |
1171 | 0 | } |
1172 | | |
1173 | | // II.IV) CREATE |
1174 | | // If we haven't found any valid target frame by using normal flags, but the user allowed us to create |
1175 | | // a new one, we should do that. The used TaskCreator uses Desktop instance automatically as parent! |
1176 | |
|
1177 | 0 | if ( |
1178 | 0 | ( ! xTarget.is() ) && |
1179 | 0 | (nSearchFlags & css::frame::FrameSearchFlag::CREATE) |
1180 | 0 | ) |
1181 | 0 | { |
1182 | 0 | TaskCreator aCreator(m_xContext); |
1183 | 0 | xTarget = aCreator.createTask(sTargetFrameName, {}); |
1184 | 0 | } |
1185 | 0 | } |
1186 | | |
1187 | 6.21k | return xTarget; |
1188 | 6.21k | } |
1189 | | |
1190 | | /*-**************************************************************************************************** |
1191 | | @descr Returns sal_True, if this frame is a "top frame", otherwise sal_False. |
1192 | | The "m_bIsFrameTop" member must be set in the ctor or setCreator() method. |
1193 | | A top frame is a member of the top frame container or a member of the |
1194 | | task frame container. Both containers can create new frames if the findFrame() |
1195 | | method of their css::frame::XFrame interface is called with a frame name not yet known. |
1196 | | |
1197 | | @seealso ctor |
1198 | | @seealso method setCreator() |
1199 | | @seealso method findFrame() |
1200 | | @return true, if is it a top frame ... false otherwise. |
1201 | | |
1202 | | @onerror No error should occur! |
1203 | | *//*-*****************************************************************************************************/ |
1204 | | sal_Bool SAL_CALL XFrameImpl::isTop() |
1205 | 17.0k | { |
1206 | 17.0k | checkDisposed(); |
1207 | 17.0k | SolarMutexGuard g; |
1208 | | // This information is set in setCreator(). |
1209 | | // We are top, if our parent is a task or the desktop or if no parent exists! |
1210 | 17.0k | return m_bIsFrameTop; |
1211 | 17.0k | } |
1212 | | |
1213 | | /*-**************************************************************************************************** |
1214 | | @short activate frame in hierarchy |
1215 | | @descr This feature is used to mark active paths in our frame hierarchy. |
1216 | | You can be a listener for this event to react to it and change some internal states or something else. |
1217 | | |
1218 | | @seealso method deactivate() |
1219 | | @seealso method isActivate() |
1220 | | @seealso enum EActiveState |
1221 | | @seealso listener mechanism |
1222 | | *//*-*****************************************************************************************************/ |
1223 | | void SAL_CALL XFrameImpl::activate() |
1224 | 0 | { |
1225 | 0 | checkDisposed(); |
1226 | | |
1227 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
1228 | 0 | SolarMutexResettableGuard aWriteLock; |
1229 | | |
1230 | | // Copy necessary member and free the lock. |
1231 | | // It's not necessary for m_aChildFrameContainer, because |
1232 | | // it is threadsafe by itself and lives if we live. |
1233 | 0 | css::uno::Reference< css::frame::XFrame > xActiveChild = m_aChildFrameContainer.getActive(); |
1234 | 0 | css::uno::Reference< css::frame::XFramesSupplier > xParent = m_xParent; |
1235 | 0 | css::uno::Reference< css::frame::XFrame > xThis(this); |
1236 | 0 | EActiveState eState = m_eActiveState; |
1237 | |
|
1238 | 0 | aWriteLock.clear(); |
1239 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
1240 | | |
1241 | | // 1) If I am not active before... |
1242 | 0 | if( eState == E_INACTIVE ) |
1243 | 0 | { |
1244 | | // ... do it then. |
1245 | 0 | aWriteLock.reset(); |
1246 | 0 | eState = E_ACTIVE; |
1247 | 0 | m_eActiveState = eState; |
1248 | 0 | aWriteLock.clear(); |
1249 | | // Deactivate sibling path and forward activation to parent, if any parent exists! |
1250 | 0 | if( xParent.is() ) |
1251 | 0 | { |
1252 | | // Set THIS frame as active child of parent every time and activate it. |
1253 | | // We MUST have a valid path from bottom to top as active path! |
1254 | | // But we must deactivate the old active sibling path first. |
1255 | | |
1256 | | // Attention: deactivation of an active path, deactivates the whole path from bottom to top! |
1257 | | // But we only wish to deactivate the found sibling-tree. |
1258 | | // [ see deactivate() / step 4) for further information! ] |
1259 | |
|
1260 | 0 | xParent->setActiveFrame( xThis ); |
1261 | | |
1262 | | // Then we can activate from here to top. |
1263 | | // Attention: we are ACTIVE now. And the parent will call activate() at us! |
1264 | | // But we do nothing then! We are already activated. |
1265 | 0 | xParent->activate(); |
1266 | 0 | } |
1267 | | // It's necessary to send event NOW, not before. |
1268 | | // Activation goes from bottom to top! |
1269 | | // That's the reason to activate parent first and send event now. |
1270 | 0 | implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_ACTIVATED ); |
1271 | 0 | } |
1272 | | |
1273 | | // 2) I was active before or currently activated and there is a path from here to bottom, who CAN be active. |
1274 | | // But our direct child of path is not active yet. |
1275 | | // (It can be, if activation occurs in the middle of a current path!) |
1276 | | // In this case we activate path to bottom to set focus on the correct frame! |
1277 | 0 | if ( eState == E_ACTIVE && xActiveChild.is() && !xActiveChild->isActive() ) |
1278 | 0 | { |
1279 | 0 | xActiveChild->activate(); |
1280 | 0 | } |
1281 | | |
1282 | | // 3) I was active before or currently activated. But if I have no active child => I will get the focus! |
1283 | 0 | if ( eState == E_ACTIVE && !xActiveChild.is() ) |
1284 | 0 | { |
1285 | 0 | aWriteLock.reset(); |
1286 | 0 | eState = E_FOCUS; |
1287 | 0 | m_eActiveState = eState; |
1288 | 0 | aWriteLock.clear(); |
1289 | 0 | implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_UI_ACTIVATED ); |
1290 | 0 | } |
1291 | 0 | } |
1292 | | |
1293 | | /*-**************************************************************************************************** |
1294 | | @short deactivate frame in hierarchy |
1295 | | @descr This feature is used to deactivate paths in our frame hierarchy. |
1296 | | You can be a listener for this event to react to it and change some internal states or something else. |
1297 | | |
1298 | | @seealso method activate() |
1299 | | @seealso method isActivate() |
1300 | | @seealso enum EActiveState |
1301 | | @seealso listener mechanism |
1302 | | *//*-*****************************************************************************************************/ |
1303 | | void SAL_CALL XFrameImpl::deactivate() |
1304 | 0 | { |
1305 | 0 | checkDisposed(); |
1306 | | |
1307 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
1308 | 0 | SolarMutexResettableGuard aWriteLock; |
1309 | | |
1310 | | // Copy necessary member and free the lock. |
1311 | 0 | css::uno::Reference< css::frame::XFrame > xActiveChild = m_aChildFrameContainer.getActive(); |
1312 | 0 | css::uno::Reference< css::frame::XFramesSupplier > xParent = m_xParent; |
1313 | 0 | css::uno::Reference< css::frame::XFrame > xThis(this); |
1314 | 0 | EActiveState eState = m_eActiveState; |
1315 | |
|
1316 | 0 | aWriteLock.clear(); |
1317 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
1318 | | |
1319 | | // Work only, if there is something to do! |
1320 | 0 | if( eState == E_INACTIVE ) |
1321 | 0 | return; |
1322 | | |
1323 | | |
1324 | | // 1) Deactivate all active children. |
1325 | 0 | if ( xActiveChild.is() && xActiveChild->isActive() ) |
1326 | 0 | { |
1327 | 0 | xActiveChild->deactivate(); |
1328 | 0 | } |
1329 | | |
1330 | | // 2) If I have the focus, I will lose it now. |
1331 | 0 | if( eState == E_FOCUS ) |
1332 | 0 | { |
1333 | | // Set new state INACTIVE(!) and send message to all listeners. |
1334 | | // Don't set ACTIVE as new state. This frame is deactivated the next time due to activate(). |
1335 | 0 | aWriteLock.reset(); |
1336 | 0 | eState = E_ACTIVE; |
1337 | 0 | m_eActiveState = eState; |
1338 | 0 | aWriteLock.clear(); |
1339 | 0 | implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_UI_DEACTIVATING ); |
1340 | 0 | } |
1341 | | |
1342 | | // 3) If I am active, I will be deactivated now. |
1343 | 0 | if( eState == E_ACTIVE ) |
1344 | 0 | { |
1345 | | // Set new state and send message to all listeners. |
1346 | 0 | aWriteLock.reset(); |
1347 | 0 | eState = E_INACTIVE; |
1348 | 0 | m_eActiveState = eState; |
1349 | 0 | aWriteLock.clear(); |
1350 | 0 | implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_DEACTIVATING ); |
1351 | 0 | } |
1352 | | |
1353 | | // 4) If there is a path from here to my parent, |
1354 | | // I am at the top or in the middle of a deactivated subtree and the action was started here. |
1355 | | // I must deactivate all frames from here to top, which are members of the current path. |
1356 | | // Stop, if THIS frame is not the active frame of our parent! |
1357 | 0 | if ( xParent.is() && xParent->getActiveFrame() == xThis ) |
1358 | 0 | { |
1359 | | // We MUST break the path - otherwise we will get the focus instead of our parent! |
1360 | | // Attention: our parent will not call us again - WE ARE NOT ACTIVE YET! |
1361 | | // [ see step 3 and condition "if ( m_eActiveState!=INACTIVE ) ..." in this method! ] |
1362 | 0 | xParent->deactivate(); |
1363 | 0 | } |
1364 | 0 | } |
1365 | | |
1366 | | /*-**************************************************************************************************** |
1367 | | @short returns active state |
1368 | | @descr Call it to get information about current active state of this frame. |
1369 | | |
1370 | | @seealso method activate() |
1371 | | @seealso method deactivate() |
1372 | | @seealso enum EActiveState |
1373 | | @return true if active, false otherwise. |
1374 | | |
1375 | | @onerror No error should occur. |
1376 | | *//*-*****************************************************************************************************/ |
1377 | | sal_Bool SAL_CALL XFrameImpl::isActive() |
1378 | 6.21k | { |
1379 | 6.21k | checkDisposed(); |
1380 | 6.21k | SolarMutexGuard g; |
1381 | 6.21k | return m_eActiveState == E_ACTIVE || m_eActiveState == E_FOCUS; |
1382 | 6.21k | } |
1383 | | |
1384 | | /*-**************************************************************************************************** |
1385 | | @short ??? |
1386 | | *//*-*****************************************************************************************************/ |
1387 | | void SAL_CALL XFrameImpl::contextChanged() |
1388 | 12.4k | { |
1389 | | // Sometimes called during closing object... |
1390 | | // Impl-method itself is threadsafe! |
1391 | | // Send event to all listeners for frame actions. |
1392 | 12.4k | implts_sendFrameActionEvent( css::frame::FrameAction_CONTEXT_CHANGED ); |
1393 | 12.4k | } |
1394 | | |
1395 | | /*-**************************************************************************************************** |
1396 | | @short set new component inside the frame |
1397 | | @descr A frame is a container for a component. Use this method to set, change or release it! |
1398 | | We accept null references! The xComponentWindow will be a child of our container window |
1399 | | and get all window events from us. |
1400 | | |
1401 | | @attention (a) A currently set component can disagree with the suspend() request! |
1402 | | We don't set the new one and return with false then. |
1403 | | (b) It's possible to set: |
1404 | | (b1) a simple component here which supports the window only - no controller; |
1405 | | (b2) a full featured component which supports window and controller; |
1406 | | (b3) or both to NULL if this component should be forgotten. |
1407 | | |
1408 | | @seealso method getComponentWindow() |
1409 | | @seealso method getController() |
1410 | | |
1411 | | @param xComponentWindow |
1412 | | valid reference to new component window which will be a child of internal container window |
1413 | | <NULL/> may be used for releasing. |
1414 | | @param xController |
1415 | | reference to new component controller |
1416 | | (<NULL/> may be used for releasing or setting of a simple component) |
1417 | | |
1418 | | @return <TRUE/> if operation was successful, <FALSE/> otherwise. |
1419 | | |
1420 | | @onerror We return <FALSE/>. |
1421 | | @threadsafe yes |
1422 | | *//*-*****************************************************************************************************/ |
1423 | | sal_Bool SAL_CALL XFrameImpl::setComponent(const css::uno::Reference< css::awt::XWindow >& xComponentWindow, |
1424 | | const css::uno::Reference< css::frame::XController >& xController ) |
1425 | 12.4k | { |
1426 | | |
1427 | | // Ignore this HACK of sfx2! |
1428 | | // It calls us with a valid controller without a valid window - that's not allowed! |
1429 | 12.4k | if ( xController.is() && ! xComponentWindow.is() ) |
1430 | 0 | return true; |
1431 | | |
1432 | 12.4k | checkDisposed(); |
1433 | | |
1434 | | // Get threadsafe some copies of used members. |
1435 | | /* SAFE { */ |
1436 | 12.4k | SolarMutexClearableGuard aReadLock; |
1437 | 12.4k | css::uno::Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow; |
1438 | 12.4k | css::uno::Reference< css::awt::XWindow > xOldComponentWindow = m_xComponentWindow; |
1439 | 12.4k | css::uno::Reference< css::frame::XController > xOldController = m_xController; |
1440 | 12.4k | VclPtr<vcl::Window> pOwnWindow = VCLUnoHelper::GetWindow( xContainerWindow ); |
1441 | 12.4k | bool bHadFocus = pOwnWindow != nullptr && pOwnWindow->HasChildPathFocus(); |
1442 | 12.4k | bool bWasConnected = m_bConnected; |
1443 | 12.4k | aReadLock.clear(); |
1444 | | /* } SAFE */ |
1445 | | |
1446 | | // Stop listening on old window. |
1447 | | // It may cause some trouble. |
1448 | | // But don't forget to listen on new window again or reactivate listening, |
1449 | | // if we reject this setComponent() request and leave this method without changing the old window. |
1450 | 12.4k | implts_stopWindowListening(); |
1451 | | |
1452 | | // Notify all listeners, that this component (if current one exists) will be unloaded. |
1453 | 12.4k | if (bWasConnected) |
1454 | 6.21k | implts_sendFrameActionEvent( css::frame::FrameAction_COMPONENT_DETACHING ); |
1455 | | |
1456 | | // Otherwise release old component first. |
1457 | | // Always release controller before releasing window, |
1458 | | // because controller may want to access its window! |
1459 | | // But check for real changes - the new controller might be the old one. |
1460 | 12.4k | if ( |
1461 | 12.4k | (xOldController.is() ) && |
1462 | 6.21k | (xOldController != xController) |
1463 | 12.4k | ) |
1464 | 6.21k | { |
1465 | | /* ATTENTION |
1466 | | Don't suspend the old controller here. Because the outside caller must do that |
1467 | | by definition. We only have to dispose it here. |
1468 | | */ |
1469 | | |
1470 | | // Before we dispose this controller we should hide it inside this frame instance. |
1471 | | // We hold it alive for the subsequent calls by using xOldController! |
1472 | | /* SAFE {*/ |
1473 | 6.21k | { |
1474 | 6.21k | SolarMutexGuard aWriteLock; |
1475 | 6.21k | m_xController = nullptr; |
1476 | | |
1477 | 6.21k | if (m_xDispatchHelper) |
1478 | 6.21k | { |
1479 | 6.21k | rtl::Reference<DispatchProvider> pDispatchProvider = m_xDispatchHelper->GetSlave(); |
1480 | 6.21k | if (pDispatchProvider) |
1481 | 6.21k | { |
1482 | 6.21k | pDispatchProvider->ClearProtocolHandlers(); |
1483 | 6.21k | } |
1484 | 6.21k | } |
1485 | 6.21k | } |
1486 | | /* } SAFE */ |
1487 | | |
1488 | 6.21k | if (xOldController.is()) |
1489 | 6.21k | { |
1490 | 6.21k | try |
1491 | 6.21k | { |
1492 | 6.21k | xOldController->dispose(); |
1493 | 6.21k | } |
1494 | 6.21k | catch(const css::lang::DisposedException&) |
1495 | 6.21k | {} |
1496 | 6.21k | } |
1497 | 6.21k | xOldController = nullptr; |
1498 | 6.21k | } |
1499 | | |
1500 | | // Now it's time to release the component window. |
1501 | | // If the controller wasn't released successfully, this code block shouldn't be reached. |
1502 | | // Because in case of "suspend()==false" we return immediately with false, see before. |
1503 | | // Check for real changes, too. |
1504 | 12.4k | if ( |
1505 | 12.4k | (xOldComponentWindow.is() ) && |
1506 | 6.21k | (xOldComponentWindow != xComponentWindow) |
1507 | 12.4k | ) |
1508 | 6.21k | { |
1509 | | /* SAFE { */ |
1510 | 6.21k | { |
1511 | 6.21k | SolarMutexGuard aWriteLock; |
1512 | 6.21k | m_xComponentWindow = nullptr; |
1513 | 6.21k | } |
1514 | | /* } SAFE */ |
1515 | | |
1516 | 6.21k | if (xOldComponentWindow.is()) |
1517 | 6.21k | { |
1518 | 6.21k | try |
1519 | 6.21k | { |
1520 | 6.21k | xOldComponentWindow->dispose(); |
1521 | 6.21k | } |
1522 | 6.21k | catch(const css::lang::DisposedException&) |
1523 | 6.21k | { |
1524 | 0 | } |
1525 | 6.21k | } |
1526 | 6.21k | xOldComponentWindow = nullptr; |
1527 | 6.21k | } |
1528 | | |
1529 | | // Now it's time to set the new component. |
1530 | | // By the way, find out our new "load state", meaning if we have a valid component inside. |
1531 | | /* SAFE { */ |
1532 | 12.4k | SolarMutexResettableGuard aWriteLock; |
1533 | 12.4k | m_xComponentWindow = xComponentWindow; |
1534 | 12.4k | m_xController = xController; |
1535 | | |
1536 | | // Clear the URL on the frame itself, now that the controller has it. |
1537 | 12.4k | m_aURL.clear(); |
1538 | | |
1539 | 12.4k | m_bConnected = (m_xComponentWindow.is() || m_xController.is()); |
1540 | 12.4k | bool bIsConnected = m_bConnected; |
1541 | 12.4k | aWriteLock.clear(); |
1542 | | /* } SAFE */ |
1543 | | |
1544 | | // notifies all interested listeners, that current component was changed or a new one was loaded |
1545 | 12.4k | if (bIsConnected && bWasConnected) |
1546 | 0 | implts_sendFrameActionEvent( css::frame::FrameAction_COMPONENT_REATTACHED ); |
1547 | 12.4k | else if (bIsConnected && !bWasConnected) |
1548 | 6.21k | implts_sendFrameActionEvent( css::frame::FrameAction_COMPONENT_ATTACHED ); |
1549 | | |
1550 | | // A new component window doesn't know anything about current active/focus states. |
1551 | | // Set this information on it! |
1552 | 12.4k | if ( bHadFocus && xComponentWindow.is() ) |
1553 | 0 | { |
1554 | 0 | xComponentWindow->setFocus(); |
1555 | 0 | } |
1556 | | |
1557 | | // If it was a new component window, we must resize it to fill out |
1558 | | // our container window. |
1559 | 12.4k | implts_resizeComponentWindow(); |
1560 | | // New component should change our current icon. |
1561 | 12.4k | implts_setIconOnWindow(); |
1562 | | // OK - start listening on new window again or do nothing if it is an empty one. |
1563 | 12.4k | implts_startWindowListening(); |
1564 | | |
1565 | | /* SAFE { */ |
1566 | 12.4k | aWriteLock.reset(); |
1567 | 12.4k | impl_checkMenuCloser(); |
1568 | 12.4k | aWriteLock.clear(); |
1569 | | /* } SAFE */ |
1570 | | |
1571 | 12.4k | return true; |
1572 | 12.4k | } |
1573 | | |
1574 | | /*-**************************************************************************************************** |
1575 | | @short returns currently set component window |
1576 | | @descr Frames are used to display components. The actual displayed component is |
1577 | | held by the m_xComponentWindow property. If the component implements only an |
1578 | | XComponent interface, the communication between the frame and the |
1579 | | component is very restricted. Better integration is achievable through an |
1580 | | XController interface. |
1581 | | If the component wants other objects to be able to get information about its |
1582 | | ResourceDescriptor it has to implement an XModel interface. |
1583 | | This frame is the owner of the component window. |
1584 | | |
1585 | | @seealso method setComponent() |
1586 | | @return css::uno::Reference to currently set component window. |
1587 | | |
1588 | | @onerror A null reference is returned. |
1589 | | *//*-*****************************************************************************************************/ |
1590 | | css::uno::Reference< css::awt::XWindow > SAL_CALL XFrameImpl::getComponentWindow() |
1591 | 25.4M | { |
1592 | 25.4M | checkDisposed(); |
1593 | 25.4M | SolarMutexGuard g; |
1594 | 25.4M | return m_xComponentWindow; |
1595 | 25.4M | } |
1596 | | |
1597 | | /*-**************************************************************************************************** |
1598 | | @short returns currently set controller |
1599 | | @descr Frames are used to display components. The actual displayed component is |
1600 | | held by the m_xComponentWindow property. If the component implements only an |
1601 | | XComponent interface, the communication between the frame and the |
1602 | | component is very restricted. Better integration is achievable through an |
1603 | | XController interface. |
1604 | | If the component wants other objects to be able to get information about its |
1605 | | ResourceDescriptor it has to implement an XModel interface. |
1606 | | This frame is the owner of the component window. |
1607 | | |
1608 | | @seealso method setComponent() |
1609 | | @return css::uno::Reference to currently set controller. |
1610 | | |
1611 | | @onerror A null reference is returned. |
1612 | | *//*-*****************************************************************************************************/ |
1613 | | css::uno::Reference< css::frame::XController > SAL_CALL XFrameImpl::getController() |
1614 | 25.5M | { |
1615 | 25.5M | SolarMutexGuard g; |
1616 | 25.5M | return m_xController; |
1617 | 25.5M | } |
1618 | | |
1619 | | /*-**************************************************************************************************** |
1620 | | @short add/remove listener for activate/deactivate/contextChanged events |
1621 | | @seealso method activate() |
1622 | | @seealso method deactivate() |
1623 | | @seealso method contextChanged() |
1624 | | |
1625 | | @param "xListener" reference to your listener object |
1626 | | @onerror Listener is ignored. |
1627 | | *//*-*****************************************************************************************************/ |
1628 | | void SAL_CALL XFrameImpl::addFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) |
1629 | 61.2k | { |
1630 | 61.2k | checkDisposed(); |
1631 | 61.2k | m_aListenerContainer.addInterface( cppu::UnoType<css::frame::XFrameActionListener>::get(), xListener ); |
1632 | 61.2k | } |
1633 | | |
1634 | | void SAL_CALL XFrameImpl::removeFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) |
1635 | 37.3k | { |
1636 | 37.3k | m_aListenerContainer.removeInterface( cppu::UnoType<css::frame::XFrameActionListener>::get(), xListener ); |
1637 | 37.3k | } |
1638 | | |
1639 | | /*-**************************************************************************************************** |
1640 | | @short support two way mechanism to release a frame |
1641 | | @descr This method asks an internal component (controller) if it accepts this close request. |
1642 | | In case of <TRUE/> nothing will happen (from point of the caller of this close method). |
1643 | | In case of <FALSE/> a CloseVetoException is thrown. After such an exception, the given parameter |
1644 | | <var>bDeliverOwnership</var> regulates what will be the new owner of this instance. |
1645 | | |
1646 | | @attention It's the replacement for XTask::close() which is marked as an obsolete method. |
1647 | | |
1648 | | @param bDeliverOwnership |
1649 | | If parameter is set to <FALSE/> the original caller will be the owner after thrown |
1650 | | veto exception and must try to close this frame again at a later time. Otherwise the |
1651 | | source of the thrown exception is the correct one. It may be the frame itself. |
1652 | | |
1653 | | @throws CloseVetoException |
1654 | | if any internal things will not be closed |
1655 | | |
1656 | | @threadsafe yes |
1657 | | *//*-*****************************************************************************************************/ |
1658 | | void SAL_CALL XFrameImpl::close( sal_Bool bDeliverOwnership ) |
1659 | 6.21k | { |
1660 | 6.21k | checkDisposed(); |
1661 | | |
1662 | | // At the end of this method we might have to dispose ourselves |
1663 | | // without anybody from outside holding a reference to us. |
1664 | | // Thus, it's a good idea to do that ourselves. |
1665 | 6.21k | css::uno::Reference< css::uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) ); |
1666 | | |
1667 | | // Try to close any listeners before we look for currently running internal processes. |
1668 | | // Because if a listener disagrees with this close() request, we have time to finish these |
1669 | | // internal operations too. |
1670 | | // Note: container itself is threadsafe. |
1671 | 6.21k | css::lang::EventObject aSource (static_cast< ::cppu::OWeakObject*>(this)); |
1672 | 6.21k | comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::util::XCloseListener>::get()); |
1673 | 6.21k | if (pContainer!=nullptr) |
1674 | 6.21k | { |
1675 | 6.21k | comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer); |
1676 | 12.4k | while (pIterator.hasMoreElements()) |
1677 | 6.21k | { |
1678 | 6.21k | try |
1679 | 6.21k | { |
1680 | 6.21k | static_cast<css::util::XCloseListener*>(pIterator.next())->queryClosing( aSource, bDeliverOwnership ); |
1681 | 6.21k | } |
1682 | 6.21k | catch( const css::uno::RuntimeException& ) |
1683 | 6.21k | { |
1684 | 0 | pIterator.remove(); |
1685 | 0 | } |
1686 | 6.21k | } |
1687 | 6.21k | } |
1688 | | |
1689 | | // Ok - no listener disagreed with this close() request. |
1690 | | // Check if this frame is used for any load process currently. |
1691 | 6.21k | if (isActionLocked()) |
1692 | 0 | { |
1693 | 0 | if (bDeliverOwnership) |
1694 | 0 | { |
1695 | 0 | SolarMutexGuard g; |
1696 | 0 | m_bSelfClose = true; |
1697 | 0 | } |
1698 | |
|
1699 | 0 | throw css::util::CloseVetoException(u"Frame in use for loading document..."_ustr,static_cast< ::cppu::OWeakObject*>(this)); |
1700 | 0 | } |
1701 | | |
1702 | 6.21k | if ( ! setComponent(nullptr,nullptr) ) |
1703 | 0 | throw css::util::CloseVetoException(u"Component couldn't be detached..."_ustr,static_cast< ::cppu::OWeakObject*>(this)); |
1704 | | |
1705 | | // If closing is allowed, inform all listeners and dispose this frame! |
1706 | 6.21k | pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::util::XCloseListener>::get()); |
1707 | 6.21k | if (pContainer!=nullptr) |
1708 | 6.21k | { |
1709 | 6.21k | comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer); |
1710 | 6.21k | while (pIterator.hasMoreElements()) |
1711 | 0 | { |
1712 | 0 | try |
1713 | 0 | { |
1714 | 0 | static_cast<css::util::XCloseListener*>(pIterator.next())->notifyClosing( aSource ); |
1715 | 0 | } |
1716 | 0 | catch( const css::uno::RuntimeException& ) |
1717 | 0 | { |
1718 | 0 | pIterator.remove(); |
1719 | 0 | } |
1720 | 0 | } |
1721 | 6.21k | } |
1722 | | |
1723 | | /* SAFE { */ |
1724 | 6.21k | { |
1725 | 6.21k | SolarMutexGuard aWriteLock; |
1726 | 6.21k | m_bIsHidden = true; |
1727 | 6.21k | } |
1728 | | /* } SAFE */ |
1729 | 6.21k | impl_checkMenuCloser(); |
1730 | | |
1731 | 6.21k | dispose(); |
1732 | 6.21k | } |
1733 | | |
1734 | | /*-**************************************************************************************************** |
1735 | | @short be a listener for close events! |
1736 | | @descr Adds/remove a CloseListener at this frame instance. If the close() method is called on |
1737 | | this object, any such listeners are informed and can disagree with that by throwing |
1738 | | a CloseVetoException. |
1739 | | |
1740 | | @seealso XFrameImpl::close() |
1741 | | |
1742 | | @param xListener |
1743 | | reference to your listener object |
1744 | | |
1745 | | @onerror Listener is ignored. |
1746 | | |
1747 | | @threadsafe yes |
1748 | | *//*-*****************************************************************************************************/ |
1749 | | void SAL_CALL XFrameImpl::addCloseListener( const css::uno::Reference< css::util::XCloseListener >& xListener ) |
1750 | 6.21k | { |
1751 | 6.21k | checkDisposed(); |
1752 | 6.21k | m_aListenerContainer.addInterface( cppu::UnoType<css::util::XCloseListener>::get(), xListener ); |
1753 | 6.21k | } |
1754 | | |
1755 | | void SAL_CALL XFrameImpl::removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& xListener ) |
1756 | 6.21k | { |
1757 | 6.21k | m_aListenerContainer.removeInterface( cppu::UnoType<css::util::XCloseListener>::get(), xListener ); |
1758 | 6.21k | } |
1759 | | |
1760 | | OUString SAL_CALL XFrameImpl::getTitle() |
1761 | 12.4k | { |
1762 | 12.4k | checkDisposed(); |
1763 | | |
1764 | | // SAFE -> |
1765 | 12.4k | SolarMutexClearableGuard aReadLock; |
1766 | 12.4k | css::uno::Reference< css::frame::XTitle > xTitle(m_xTitleHelper, css::uno::UNO_SET_THROW); |
1767 | 12.4k | aReadLock.clear(); |
1768 | | // <- SAFE |
1769 | | |
1770 | 12.4k | return xTitle->getTitle(); |
1771 | 12.4k | } |
1772 | | |
1773 | | void SAL_CALL XFrameImpl::setTitle( const OUString& sTitle ) |
1774 | 0 | { |
1775 | 0 | checkDisposed(); |
1776 | | |
1777 | | // SAFE -> |
1778 | 0 | SolarMutexClearableGuard aReadLock; |
1779 | 0 | css::uno::Reference< css::frame::XTitle > xTitle(m_xTitleHelper, css::uno::UNO_SET_THROW); |
1780 | 0 | aReadLock.clear(); |
1781 | | // <- SAFE |
1782 | |
|
1783 | 0 | xTitle->setTitle(sTitle); |
1784 | 0 | } |
1785 | | |
1786 | | void SAL_CALL XFrameImpl::addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener) |
1787 | 11.0k | { |
1788 | 11.0k | checkDisposed(); |
1789 | | |
1790 | | // SAFE -> |
1791 | 11.0k | SolarMutexClearableGuard aReadLock; |
1792 | 11.0k | rtl::Reference< TitleHelper > xTitle(m_xTitleHelper); |
1793 | 11.0k | aReadLock.clear(); |
1794 | | // <- SAFE |
1795 | | |
1796 | 11.0k | xTitle->addTitleChangeListener(xListener); |
1797 | 11.0k | } |
1798 | | |
1799 | | void SAL_CALL XFrameImpl::removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) |
1800 | 0 | { |
1801 | 0 | checkDisposed(); |
1802 | | |
1803 | | // SAFE -> |
1804 | 0 | SolarMutexClearableGuard aReadLock; |
1805 | 0 | rtl::Reference< TitleHelper > xTitle(m_xTitleHelper); |
1806 | 0 | aReadLock.clear(); |
1807 | | // <- SAFE |
1808 | |
|
1809 | 0 | xTitle->removeTitleChangeListener(xListener); |
1810 | 0 | } |
1811 | | |
1812 | | css::uno::Reference<css::container::XNameContainer> SAL_CALL XFrameImpl::getUserDefinedAttributes() |
1813 | 0 | { |
1814 | | // optional attribute |
1815 | 0 | return nullptr; |
1816 | 0 | } |
1817 | | |
1818 | | css::uno::Reference<css::frame::XDispatchRecorderSupplier> SAL_CALL XFrameImpl::getDispatchRecorderSupplier() |
1819 | 0 | { |
1820 | 0 | SolarMutexGuard g; |
1821 | 0 | return m_xDispatchRecorderSupplier; |
1822 | 0 | } |
1823 | | |
1824 | | void SAL_CALL XFrameImpl::setDispatchRecorderSupplier(const css::uno::Reference<css::frame::XDispatchRecorderSupplier>& p) |
1825 | 0 | { |
1826 | 0 | checkDisposed(); |
1827 | 0 | SolarMutexGuard g; |
1828 | 0 | m_xDispatchRecorderSupplier.set(p); |
1829 | 0 | } |
1830 | | |
1831 | | css::uno::Reference<css::uno::XInterface> SAL_CALL XFrameImpl::getLayoutManager() |
1832 | 0 | { |
1833 | 0 | SolarMutexGuard g; |
1834 | 0 | return m_xLayoutManager; |
1835 | 0 | } |
1836 | | |
1837 | | void SAL_CALL XFrameImpl::setLayoutManager(const css::uno::Reference<css::uno::XInterface>& p1) |
1838 | 0 | { |
1839 | 0 | checkDisposed(); |
1840 | 0 | SolarMutexGuard g; |
1841 | |
|
1842 | 0 | css::uno::Reference<css::frame::XLayoutManager2> xOldLayoutManager = m_xLayoutManager; |
1843 | 0 | css::uno::Reference<css::frame::XLayoutManager2> xNewLayoutManager(p1, css::uno::UNO_QUERY); |
1844 | |
|
1845 | 0 | if (xOldLayoutManager != xNewLayoutManager) |
1846 | 0 | { |
1847 | 0 | m_xLayoutManager = xNewLayoutManager; |
1848 | 0 | if (xOldLayoutManager.is()) |
1849 | 0 | disableLayoutManager(xOldLayoutManager); |
1850 | 0 | if (xNewLayoutManager.is() && !m_bDocHidden) |
1851 | 0 | lcl_enableLayoutManager(xNewLayoutManager, this); |
1852 | 0 | } |
1853 | 0 | } |
1854 | | |
1855 | | css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL XFrameImpl::getPropertySetInfo() |
1856 | 0 | { |
1857 | 0 | checkDisposed(); |
1858 | 0 | return css::uno::Reference< css::beans::XPropertySetInfo >(this); |
1859 | 0 | } |
1860 | | |
1861 | | void SAL_CALL XFrameImpl::setPropertyValue(const OUString& sProperty, |
1862 | | const css::uno::Any& rValue) |
1863 | 0 | { |
1864 | | // TODO look for e.g. readonly props and reject setProp() call! |
1865 | |
|
1866 | 0 | checkDisposed(); |
1867 | | |
1868 | | // SAFE -> |
1869 | 0 | SolarMutexGuard g; |
1870 | |
|
1871 | 0 | TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); |
1872 | 0 | if (pIt == m_lProps.end()) |
1873 | 0 | throw css::beans::UnknownPropertyException(sProperty); |
1874 | | |
1875 | 0 | css::beans::Property aPropInfo = pIt->second; |
1876 | |
|
1877 | 0 | css::uno::Any aCurrentValue = impl_getPropertyValue(aPropInfo.Handle); |
1878 | |
|
1879 | 0 | bool bWillBeChanged = (aCurrentValue != rValue); |
1880 | 0 | if (! bWillBeChanged) |
1881 | 0 | return; |
1882 | | |
1883 | 0 | css::beans::PropertyChangeEvent aEvent; |
1884 | 0 | aEvent.PropertyName = aPropInfo.Name; |
1885 | 0 | aEvent.Further = false; |
1886 | 0 | aEvent.PropertyHandle = aPropInfo.Handle; |
1887 | 0 | aEvent.OldValue = std::move(aCurrentValue); |
1888 | 0 | aEvent.NewValue = rValue; |
1889 | 0 | aEvent.Source = m_xBroadcaster; |
1890 | |
|
1891 | 0 | if (impl_existsVeto(aEvent)) |
1892 | 0 | throw css::beans::PropertyVetoException(); |
1893 | | |
1894 | 0 | impl_setPropertyValue(aPropInfo.Handle, rValue); |
1895 | |
|
1896 | 0 | impl_notifyChangeListener(aEvent); |
1897 | 0 | } |
1898 | | |
1899 | | css::uno::Any SAL_CALL XFrameImpl::getPropertyValue(const OUString& sProperty) |
1900 | 25.2M | { |
1901 | 25.2M | checkDisposed(); |
1902 | | |
1903 | | // SAFE -> |
1904 | 25.2M | SolarMutexGuard aReadLock; |
1905 | | |
1906 | 25.2M | TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); |
1907 | 25.2M | if (pIt == m_lProps.end()) |
1908 | 0 | throw css::beans::UnknownPropertyException(sProperty); |
1909 | | |
1910 | 25.2M | css::beans::Property aPropInfo = pIt->second; |
1911 | | |
1912 | 25.2M | return impl_getPropertyValue(aPropInfo.Handle); |
1913 | 25.2M | } |
1914 | | |
1915 | | void SAL_CALL XFrameImpl::addPropertyChangeListener( |
1916 | | const OUString& sProperty, |
1917 | | const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) |
1918 | 0 | { |
1919 | 0 | checkDisposed(); |
1920 | | |
1921 | | // SAFE -> |
1922 | 0 | { |
1923 | 0 | SolarMutexGuard aReadLock; |
1924 | |
|
1925 | 0 | TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); |
1926 | 0 | if (pIt == m_lProps.end()) |
1927 | 0 | throw css::beans::UnknownPropertyException(sProperty); |
1928 | 0 | } |
1929 | | // <- SAFE |
1930 | | |
1931 | 0 | m_lSimpleChangeListener.addInterface(sProperty, xListener); |
1932 | 0 | } |
1933 | | |
1934 | | void SAL_CALL XFrameImpl::removePropertyChangeListener( |
1935 | | const OUString& sProperty, |
1936 | | const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) |
1937 | 0 | { |
1938 | | // SAFE -> |
1939 | 0 | { |
1940 | 0 | SolarMutexGuard aReadLock; |
1941 | |
|
1942 | 0 | TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); |
1943 | 0 | if (pIt == m_lProps.end()) |
1944 | 0 | throw css::beans::UnknownPropertyException(sProperty); |
1945 | 0 | } |
1946 | | // <- SAFE |
1947 | | |
1948 | 0 | m_lSimpleChangeListener.removeInterface(sProperty, xListener); |
1949 | 0 | } |
1950 | | |
1951 | | void SAL_CALL XFrameImpl::addVetoableChangeListener( |
1952 | | const OUString& sProperty, |
1953 | | const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) |
1954 | 0 | { |
1955 | 0 | checkDisposed(); |
1956 | | |
1957 | | // SAFE -> |
1958 | 0 | { |
1959 | 0 | SolarMutexGuard aReadLock; |
1960 | |
|
1961 | 0 | TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); |
1962 | 0 | if (pIt == m_lProps.end()) |
1963 | 0 | throw css::beans::UnknownPropertyException(sProperty); |
1964 | 0 | } |
1965 | | // <- SAFE |
1966 | | |
1967 | 0 | m_lVetoChangeListener.addInterface(sProperty, xListener); |
1968 | 0 | } |
1969 | | |
1970 | | void SAL_CALL XFrameImpl::removeVetoableChangeListener( |
1971 | | const OUString& sProperty, |
1972 | | const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) |
1973 | 0 | { |
1974 | | // SAFE -> |
1975 | 0 | { |
1976 | 0 | SolarMutexGuard aReadLock; |
1977 | |
|
1978 | 0 | TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); |
1979 | 0 | if (pIt == m_lProps.end()) |
1980 | 0 | throw css::beans::UnknownPropertyException(sProperty); |
1981 | 0 | } |
1982 | | // <- SAFE |
1983 | | |
1984 | 0 | m_lVetoChangeListener.removeInterface(sProperty, xListener); |
1985 | 0 | } |
1986 | | |
1987 | | css::uno::Sequence< css::beans::Property > SAL_CALL XFrameImpl::getProperties() |
1988 | 0 | { |
1989 | 0 | checkDisposed(); |
1990 | |
|
1991 | 0 | SolarMutexGuard g; |
1992 | |
|
1993 | 0 | sal_Int32 c = static_cast<sal_Int32>(m_lProps.size()); |
1994 | 0 | css::uno::Sequence< css::beans::Property > lProps(c); |
1995 | 0 | auto lPropsRange = asNonConstRange(lProps); |
1996 | 0 | for (auto const& elem : m_lProps) |
1997 | 0 | { |
1998 | 0 | lPropsRange[--c] = elem.second; |
1999 | 0 | } |
2000 | |
|
2001 | 0 | return lProps; |
2002 | 0 | } |
2003 | | |
2004 | | css::beans::Property SAL_CALL XFrameImpl::getPropertyByName(const OUString& sName) |
2005 | 0 | { |
2006 | 0 | checkDisposed(); |
2007 | |
|
2008 | 0 | SolarMutexGuard g; |
2009 | |
|
2010 | 0 | TPropInfoHash::const_iterator pIt = m_lProps.find(sName); |
2011 | 0 | if (pIt == m_lProps.end()) |
2012 | 0 | throw css::beans::UnknownPropertyException(sName); |
2013 | | |
2014 | 0 | return pIt->second; |
2015 | 0 | } |
2016 | | |
2017 | | sal_Bool SAL_CALL XFrameImpl::hasPropertyByName(const OUString& sName) |
2018 | 0 | { |
2019 | 0 | checkDisposed(); |
2020 | |
|
2021 | 0 | SolarMutexGuard g; |
2022 | |
|
2023 | 0 | TPropInfoHash::iterator pIt = m_lProps.find(sName); |
2024 | 0 | bool bExist = (pIt != m_lProps.end()); |
2025 | |
|
2026 | 0 | return bExist; |
2027 | 0 | } |
2028 | | |
2029 | | /*-****************************************************************************************************/ |
2030 | | void XFrameImpl::implts_forgetSubFrames() |
2031 | 6.21k | { |
2032 | | // SAFE -> |
2033 | 6.21k | SolarMutexClearableGuard aReadLock; |
2034 | 6.21k | rtl::Reference< OFrames > xContainer(m_xFramesHelper); |
2035 | 6.21k | aReadLock.clear(); |
2036 | | // <- SAFE |
2037 | | |
2038 | 6.21k | sal_Int32 c = xContainer->getCount(); |
2039 | 6.21k | sal_Int32 i = 0; |
2040 | | |
2041 | 6.21k | for (i=0; i<c; ++i) |
2042 | 0 | { |
2043 | 0 | try |
2044 | 0 | { |
2045 | 0 | css::uno::Reference< css::frame::XFrame > xFrame; |
2046 | 0 | xContainer->getByIndex(i) >>= xFrame; |
2047 | 0 | if (xFrame.is()) |
2048 | 0 | xFrame->setCreator(css::uno::Reference< css::frame::XFramesSupplier >()); |
2049 | 0 | } |
2050 | 0 | catch(const css::uno::Exception&) |
2051 | 0 | { |
2052 | | // Ignore errors here. |
2053 | | // Nobody can guarantee a stable index in multi threaded environments .-) |
2054 | 0 | } |
2055 | 0 | } |
2056 | | |
2057 | 6.21k | SolarMutexGuard g; |
2058 | 6.21k | m_xFramesHelper.clear(); // clear uno reference |
2059 | 6.21k | m_aChildFrameContainer.clear(); // clear container content |
2060 | 6.21k | } |
2061 | | |
2062 | | /*-**************************************************************************************************** |
2063 | | @short destroy instance |
2064 | | @descr The owner of this object calls the dispose method if the object |
2065 | | should be destroyed. All other objects and components, that are registered |
2066 | | as an EventListener are forced to release their references to this object. |
2067 | | Furthermore this frame is removed from its parent frame container to release |
2068 | | this reference. The reference attributes are disposed and released also. |
2069 | | |
2070 | | @attention Look for global description at the beginning of the file, too! |
2071 | | (DisposedException, FairRWLock ..., initialize, dispose) |
2072 | | |
2073 | | @seealso method initialize() |
2074 | | @seealso base class FairRWLockBase! |
2075 | | *//*-*****************************************************************************************************/ |
2076 | | void SAL_CALL XFrameImpl::disposing() |
2077 | 6.21k | { |
2078 | | // We should hold a reference to ourselves, |
2079 | | // because our owner disposes us and releases our reference. |
2080 | | // We might die before finishing this method. |
2081 | 6.21k | css::uno::Reference< css::frame::XFrame > xThis(this); |
2082 | | |
2083 | 6.21k | SAL_INFO("fwk.frame", "[Frame] " << m_sName << " send dispose event to listener"); |
2084 | | |
2085 | | // First operation should be "stop all listening for window events on our container window". |
2086 | | // These events are superfluous but can cause trouble! |
2087 | | // We will die, die and die... |
2088 | 6.21k | implts_stopWindowListening(); |
2089 | | |
2090 | 6.21k | css::uno::Reference<css::frame::XLayoutManager2> layoutMgr; |
2091 | 6.21k | { |
2092 | 6.21k | SolarMutexGuard g; |
2093 | 6.21k | layoutMgr = m_xLayoutManager; |
2094 | 6.21k | } |
2095 | 6.21k | if (layoutMgr.is()) { |
2096 | 6.21k | disableLayoutManager(layoutMgr); |
2097 | 6.21k | } |
2098 | | |
2099 | 6.21k | std::unique_ptr<WindowCommandDispatch> disp; |
2100 | 6.21k | { |
2101 | 6.21k | SolarMutexGuard g; |
2102 | 6.21k | std::swap(disp, m_pWindowCommandDispatch); |
2103 | 6.21k | } |
2104 | 6.21k | disp.reset(); |
2105 | | |
2106 | | // Send message to all listeners and forget their references. |
2107 | 6.21k | css::lang::EventObject aEvent( xThis ); |
2108 | 6.21k | m_aListenerContainer.disposeAndClear( aEvent ); |
2109 | | |
2110 | | // set "end of life" for our property set helper |
2111 | 6.21k | impl_disablePropertySet(); |
2112 | | |
2113 | | // Interception/dispatch chain must be destroyed explicitly. |
2114 | | // Otherwise some dispatches and/or interception objects won't die. |
2115 | 6.21k | rtl::Reference< InterceptionHelper > xDispatchHelper; |
2116 | 6.21k | { |
2117 | 6.21k | SolarMutexGuard g; |
2118 | 6.21k | xDispatchHelper = m_xDispatchHelper; |
2119 | 6.21k | } |
2120 | 6.21k | xDispatchHelper->disposing(aEvent); |
2121 | 6.21k | xDispatchHelper.clear(); |
2122 | | |
2123 | | // Don't show any dialogs, errors or anything else anymore! |
2124 | | // If dispose() without a preceding close() was called somewhere, normally no dialogs |
2125 | | // should exist. Otherwise it's the problem of the outside caller. |
2126 | | // Note: |
2127 | | // (a) Do it after implts_stopWindowListening(). If the order is not followed, |
2128 | | // some activate/deactivate notifications may appear, which can be fatal. |
2129 | | // (b) Don't forget to save the old value of IsDialogCancelEnabled() to |
2130 | | // restore it afterwards (to not kill headless mode). |
2131 | 6.21k | DialogCancelMode old = Application::GetDialogCancelMode(); |
2132 | 6.21k | Application::SetDialogCancelMode( DialogCancelMode::Silent ); |
2133 | | |
2134 | | // We should be alone forever and any further dispose calls are rejected by the preceding lines, |
2135 | | // I hope :-) |
2136 | | |
2137 | | // Free references of our frame tree. |
2138 | | // Force parent container to forget this frame, too |
2139 | | // ( It's contained in m_xParent and so no css::lang::XEventListener for m_xParent! ) |
2140 | | // It's important to do that before we free some other internal structures. |
2141 | | // Because if our parent gets an activate and found us as last possible active frame |
2142 | | // it tries to deactivate us and we run into some trouble (DisposedExceptions!). |
2143 | 6.21k | css::uno::Reference<css::frame::XFramesSupplier> parent; |
2144 | 6.21k | { |
2145 | 6.21k | SolarMutexGuard g; |
2146 | 6.21k | std::swap(parent, m_xParent); |
2147 | 6.21k | } |
2148 | 6.21k | if( parent.is() ) |
2149 | 6.21k | { |
2150 | 6.21k | parent->getFrames()->remove( xThis ); |
2151 | 6.21k | } |
2152 | | |
2153 | | /* } SAFE */ |
2154 | | // Forget our internal component and its window first. |
2155 | | // So we can release our container window later without problems. |
2156 | | // Because this container window is the parent of the component window. |
2157 | | // Note: dispose it forcefully, because suspending must be done inside close() call! |
2158 | | // But try to dispose the controller first before you destroy the window. |
2159 | | // Because the window is used by the controller too. |
2160 | 6.21k | css::uno::Reference< css::lang::XComponent > xDisposableCtrl; |
2161 | 6.21k | css::uno::Reference< css::lang::XComponent > xDisposableComp; |
2162 | 6.21k | { |
2163 | 6.21k | SolarMutexGuard g; |
2164 | 6.21k | xDisposableCtrl = m_xController; |
2165 | 6.21k | xDisposableComp = m_xComponentWindow; |
2166 | 6.21k | } |
2167 | 6.21k | if (xDisposableCtrl.is()) |
2168 | 0 | xDisposableCtrl->dispose(); |
2169 | 6.21k | if (xDisposableComp.is()) |
2170 | 0 | xDisposableComp->dispose(); |
2171 | | |
2172 | 6.21k | impl_checkMenuCloser(); |
2173 | | |
2174 | 6.21k | css::uno::Reference<css::awt::XWindow> contWin; |
2175 | 6.21k | { |
2176 | 6.21k | SolarMutexGuard g; |
2177 | 6.21k | std::swap(contWin, m_xContainerWindow); |
2178 | 6.21k | } |
2179 | 6.21k | if( contWin.is() ) |
2180 | 6.21k | { |
2181 | 6.21k | contWin->setVisible( false ); |
2182 | | // All VclComponents are XComponents; so call dispose before discarding |
2183 | | // a css::uno::Reference< XVclComponent >, because this frame is the owner of the window |
2184 | 6.21k | contWin->dispose(); |
2185 | 6.21k | } |
2186 | | |
2187 | | /*ATTENTION |
2188 | | Clear container after successfully removing from parent container, |
2189 | | because our parent could be the desktop which stands to be disposed as well! |
2190 | | If we have already cleared our own container we lost our child before this could be |
2191 | | removed itself at this instance. |
2192 | | Release m_xFramesHelper after that - it's the same problem between parent and child! |
2193 | | "m_xParent->getFrames()->remove( xThis );" needs this helper. |
2194 | | Otherwise we get a null reference and could finish removing successfully. |
2195 | | => You see: order of calling operations is important!!! |
2196 | | */ |
2197 | 6.21k | implts_forgetSubFrames(); |
2198 | | |
2199 | 6.21k | { |
2200 | 6.21k | SolarMutexGuard g; |
2201 | | |
2202 | | // Release some other references. |
2203 | | // These calls should be easy, I hope :-) |
2204 | 6.21k | m_xDispatchHelper.clear(); |
2205 | 6.21k | m_xDropTargetListener.clear(); |
2206 | 6.21k | m_xDispatchRecorderSupplier.clear(); |
2207 | 6.21k | m_xLayoutManager.clear(); |
2208 | 6.21k | m_xIndicatorFactoryHelper.clear(); |
2209 | | |
2210 | | // It's important to set default values here! |
2211 | | // If maybe later the disposed-behaviour of this implementation is changed somewhere |
2212 | | // and doesn't throw any DisposedExceptions, we must guarantee best matching default values. |
2213 | 6.21k | m_eActiveState = E_INACTIVE; |
2214 | 6.21k | m_sName.clear(); |
2215 | 6.21k | m_bIsFrameTop = false; |
2216 | 6.21k | m_bConnected = false; |
2217 | 6.21k | m_nExternalLockCount = 0; |
2218 | 6.21k | m_bSelfClose = false; |
2219 | 6.21k | m_bIsHidden = true; |
2220 | 6.21k | } |
2221 | | |
2222 | | // Don't forget to restore old value. |
2223 | | // Otherwise no dialogs can be shown anymore in other frames. |
2224 | 6.21k | Application::SetDialogCancelMode( old ); |
2225 | 6.21k | } |
2226 | | |
2227 | | /*-**************************************************************************************************** |
2228 | | @short Be a listener for dispose events! |
2229 | | @descr Adds/remove an EventListener to this object. If the dispose method is called on |
2230 | | this object, the disposing method of the listener is called. |
2231 | | @param "xListener" reference to your listener object. |
2232 | | @onerror Listener is ignored. |
2233 | | *//*-*****************************************************************************************************/ |
2234 | | void SAL_CALL XFrameImpl::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) |
2235 | 6.21k | { |
2236 | 6.21k | checkDisposed(); |
2237 | 6.21k | m_aListenerContainer.addInterface( cppu::UnoType<css::lang::XEventListener>::get(), xListener ); |
2238 | 6.21k | } |
2239 | | |
2240 | | void SAL_CALL XFrameImpl::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) |
2241 | 6.21k | { |
2242 | 6.21k | m_aListenerContainer.removeInterface( cppu::UnoType<css::lang::XEventListener>::get(), xListener ); |
2243 | 6.21k | } |
2244 | | |
2245 | | /*-**************************************************************************************************** |
2246 | | @short create new status indicator |
2247 | | @descr Use returned status indicator to show progresses and some text information. |
2248 | | All created objects share the same dialog! Only the last one can show its information. |
2249 | | |
2250 | | @seealso class StatusIndicatorFactory |
2251 | | @seealso class StatusIndicator |
2252 | | @return A reference to created object. |
2253 | | |
2254 | | @onerror We return a null reference. |
2255 | | *//*-*****************************************************************************************************/ |
2256 | | css::uno::Reference< css::task::XStatusIndicator > SAL_CALL XFrameImpl::createStatusIndicator() |
2257 | 0 | { |
2258 | 0 | checkDisposed(); |
2259 | | |
2260 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
2261 | 0 | SolarMutexClearableGuard aReadLock; |
2262 | | |
2263 | | // Make snapshot of necessary members and define default return value. |
2264 | 0 | css::uno::Reference< css::task::XStatusIndicator > xExternal(m_xIndicatorInterception.get(), css::uno::UNO_QUERY); |
2265 | 0 | css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory = m_xIndicatorFactoryHelper; |
2266 | |
|
2267 | 0 | aReadLock.clear(); |
2268 | | /* UNSAFE AREA ----------------------------------------------------------------------------------------- */ |
2269 | | |
2270 | | // Was set from outside to intercept any progress activities! |
2271 | 0 | if (xExternal.is()) |
2272 | 0 | return xExternal; |
2273 | | |
2274 | | // Or use our own factory as fallback, to create such progress. |
2275 | 0 | if (xFactory.is()) |
2276 | 0 | return xFactory->createStatusIndicator(); |
2277 | | |
2278 | 0 | return css::uno::Reference< css::task::XStatusIndicator >(); |
2279 | 0 | } |
2280 | | |
2281 | | /*-**************************************************************************************************** |
2282 | | @short search for target to load URL |
2283 | | @descr This method searches for a dispatch for the specified DispatchDescriptor. |
2284 | | The FrameSearchFlags and the FrameName of the DispatchDescriptor are |
2285 | | treated as described for findFrame. |
2286 | | |
2287 | | @seealso method findFrame() |
2288 | | @seealso method queryDispatches() |
2289 | | @seealso method set/getName() |
2290 | | @seealso class TargetFinder |
2291 | | |
2292 | | @param "aURL" , URL for loading |
2293 | | @param "sTargetFrameName" , name of target frame |
2294 | | @param "nSearchFlags" , additional flags to regulate search if sTargetFrameName is not clear |
2295 | | @return css::uno::Reference to dispatch handler. |
2296 | | |
2297 | | @onerror A null reference is returned. |
2298 | | *//*-*****************************************************************************************************/ |
2299 | | css::uno::Reference< css::frame::XDispatch > SAL_CALL XFrameImpl::queryDispatch( const css::util::URL& aURL, |
2300 | | const OUString& sTargetFrameName, |
2301 | | sal_Int32 nSearchFlags) |
2302 | 660 | { |
2303 | | // Don't check incoming parameters here! Our helper does it for us and it is not a good idea to do it more than once! |
2304 | | |
2305 | 660 | checkDisposed(); |
2306 | | |
2307 | | // Remove uno and cmd protocol part as we want to support both of them. We store only the command part |
2308 | | // in our hash map. All other protocols are stored with the protocol part. |
2309 | 660 | OUString aCommand( aURL.Main ); |
2310 | 660 | if ( aURL.Protocol.equalsIgnoreAsciiCase(".uno:") ) |
2311 | 660 | aCommand = aURL.Path; |
2312 | | |
2313 | | // Make std::unordered_map lookup if the current URL is in the disabled list |
2314 | 660 | if ( m_aCommandOptions.LookupDisabled( aCommand ) ) |
2315 | 0 | return css::uno::Reference< css::frame::XDispatch >(); |
2316 | 660 | else |
2317 | 660 | { |
2318 | | // We use a helper to support this interface and an interceptor mechanism. |
2319 | 660 | rtl::Reference<InterceptionHelper> disp; |
2320 | 660 | { |
2321 | 660 | SolarMutexGuard g; |
2322 | 660 | disp = m_xDispatchHelper; |
2323 | 660 | } |
2324 | 660 | if (!disp.is()) { |
2325 | 0 | throw css::lang::DisposedException(u"Frame disposed"_ustr); |
2326 | 0 | } |
2327 | 660 | return disp->queryDispatch( aURL, sTargetFrameName, nSearchFlags ); |
2328 | 660 | } |
2329 | 660 | } |
2330 | | |
2331 | | /*-**************************************************************************************************** |
2332 | | @short handle more than one dispatch in the same call |
2333 | | @descr Returns a sequence of dispatches. For details see the queryDispatch method. |
2334 | | For failed dispatches we return empty items in list! |
2335 | | |
2336 | | @seealso method queryDispatch() |
2337 | | |
2338 | | @param "lDescriptor" list of dispatch arguments for queryDispatch()! |
2339 | | @return List of dispatch references. Some elements can be NULL! |
2340 | | |
2341 | | @onerror An empty list is returned. |
2342 | | *//*-*****************************************************************************************************/ |
2343 | | css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL XFrameImpl::queryDispatches( |
2344 | | const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) |
2345 | 0 | { |
2346 | | // Don't check incoming parameters here! Our helper does it for us and it is not a good idea to do it more than once! |
2347 | |
|
2348 | 0 | checkDisposed(); |
2349 | | |
2350 | | // We use a helper to support this interface and an interceptor mechanism. |
2351 | 0 | rtl::Reference<InterceptionHelper> disp; |
2352 | 0 | { |
2353 | 0 | SolarMutexGuard g; |
2354 | 0 | disp = m_xDispatchHelper; |
2355 | 0 | } |
2356 | 0 | if (!disp.is()) { |
2357 | 0 | throw css::lang::DisposedException(u"Frame disposed"_ustr); |
2358 | 0 | } |
2359 | 0 | return disp->queryDispatches( lDescriptor ); |
2360 | 0 | } |
2361 | | |
2362 | | /*-**************************************************************************************************** |
2363 | | @short register/unregister interceptor for dispatch calls |
2364 | | @descr If you wish to handle some dispatches by yourselves, you should be |
2365 | | an interceptor for it. Please see class OInterceptionHelper for further information. |
2366 | | |
2367 | | @seealso class OInterceptionHelper |
2368 | | |
2369 | | @param "xInterceptor", reference to your interceptor implementation. |
2370 | | @onerror Interceptor is ignored. |
2371 | | *//*-*****************************************************************************************************/ |
2372 | | void SAL_CALL XFrameImpl::registerDispatchProviderInterceptor( |
2373 | | const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor ) |
2374 | 6.21k | { |
2375 | | // We use a helper to support this interface and an interceptor mechanism. |
2376 | | // This helper itself is threadsafe and checks incoming parameters, too. |
2377 | | // I think we don't need any lock here! |
2378 | | |
2379 | 6.21k | checkDisposed(); |
2380 | | |
2381 | 6.21k | rtl::Reference< InterceptionHelper > xInterceptionHelper; |
2382 | 6.21k | { |
2383 | 6.21k | SolarMutexGuard g; |
2384 | 6.21k | xInterceptionHelper = m_xDispatchHelper; |
2385 | 6.21k | } |
2386 | 6.21k | if (xInterceptionHelper.is()) { |
2387 | 6.21k | xInterceptionHelper->registerDispatchProviderInterceptor( xInterceptor ); |
2388 | 6.21k | } |
2389 | 6.21k | } |
2390 | | |
2391 | | void SAL_CALL XFrameImpl::releaseDispatchProviderInterceptor( |
2392 | | const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor ) |
2393 | 6.21k | { |
2394 | | // We use a helper to support this interface and an interceptor mechanism. |
2395 | | // This helper itself is threadsafe and checks incoming parameters, too. |
2396 | | // I think we don't need any lock here! |
2397 | | |
2398 | | // Sometimes we are called during our dispose() method |
2399 | | |
2400 | 6.21k | rtl::Reference< InterceptionHelper > xInterceptionHelper; |
2401 | 6.21k | { |
2402 | 6.21k | SolarMutexGuard g; |
2403 | 6.21k | xInterceptionHelper = m_xDispatchHelper; |
2404 | 6.21k | } |
2405 | 6.21k | if (xInterceptionHelper.is()) { |
2406 | 6.21k | xInterceptionHelper->releaseDispatchProviderInterceptor( xInterceptor ); |
2407 | 6.21k | } |
2408 | 6.21k | } |
2409 | | |
2410 | | /*-**************************************************************************************************** |
2411 | | @short provides information about all possible dispatch functions |
2412 | | inside the current frame environment |
2413 | | *//*-*****************************************************************************************************/ |
2414 | | css::uno::Sequence< sal_Int16 > SAL_CALL XFrameImpl::getSupportedCommandGroups() |
2415 | 0 | { |
2416 | 0 | return m_xDispatchInfoHelper->getSupportedCommandGroups(); |
2417 | 0 | } |
2418 | | |
2419 | | css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL XFrameImpl::getConfigurableDispatchInformation( |
2420 | | sal_Int16 nCommandGroup) |
2421 | 0 | { |
2422 | 0 | return m_xDispatchInfoHelper->getConfigurableDispatchInformation(nCommandGroup); |
2423 | 0 | } |
2424 | | |
2425 | | /*-**************************************************************************************************** |
2426 | | @short notifications for window events |
2427 | | @descr We are a listener on our container window to forward it to our component window. |
2428 | | |
2429 | | @seealso method setComponent() |
2430 | | @seealso member m_xContainerWindow |
2431 | | @seealso member m_xComponentWindow |
2432 | | |
2433 | | @param "aEvent" describe source of detected event |
2434 | | *//*-*****************************************************************************************************/ |
2435 | | void SAL_CALL XFrameImpl::windowResized( const css::awt::WindowEvent& ) |
2436 | 0 | { |
2437 | | // Part of dispose-mechanism |
2438 | | |
2439 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
2440 | | // Impl-method is threadsafe! |
2441 | | // If we have a current component window, we must resize it! |
2442 | 0 | implts_resizeComponentWindow(); |
2443 | 0 | } |
2444 | | |
2445 | | void SAL_CALL XFrameImpl::focusGained( const css::awt::FocusEvent& ) |
2446 | 0 | { |
2447 | | // Part of dispose() mechanism |
2448 | | |
2449 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
2450 | 0 | SolarMutexClearableGuard aReadLock; |
2451 | | // Make snapshot of member! |
2452 | 0 | css::uno::Reference< css::awt::XWindow > xComponentWindow = m_xComponentWindow; |
2453 | 0 | aReadLock.clear(); |
2454 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
2455 | |
|
2456 | 0 | if( xComponentWindow.is() ) |
2457 | 0 | { |
2458 | 0 | xComponentWindow->setFocus(); |
2459 | 0 | } |
2460 | 0 | } |
2461 | | |
2462 | | /*-**************************************************************************************************** |
2463 | | @short notifications for window events |
2464 | | @descr We are a listener on our container window to forward it to our component window, |
2465 | | but we are an XTopWindowListener only if we are a top frame! |
2466 | | |
2467 | | @seealso method setComponent() |
2468 | | @seealso member m_xContainerWindow |
2469 | | @seealso member m_xComponentWindow |
2470 | | |
2471 | | @param "aEvent" describe source of detected event |
2472 | | *//*-*****************************************************************************************************/ |
2473 | | void SAL_CALL XFrameImpl::windowActivated( const css::lang::EventObject& ) |
2474 | 0 | { |
2475 | 0 | checkDisposed(); |
2476 | | |
2477 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
2478 | 0 | SolarMutexClearableGuard aReadLock; |
2479 | | // Make snapshot of member! |
2480 | 0 | EActiveState eState = m_eActiveState; |
2481 | 0 | aReadLock.clear(); |
2482 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
2483 | | // Activate the new active path from here to top. |
2484 | 0 | if( eState == E_INACTIVE ) |
2485 | 0 | { |
2486 | 0 | setActiveFrame( css::uno::Reference< css::frame::XFrame >() ); |
2487 | 0 | activate(); |
2488 | 0 | } |
2489 | 0 | } |
2490 | | |
2491 | | void SAL_CALL XFrameImpl::windowDeactivated( const css::lang::EventObject& ) |
2492 | 0 | { |
2493 | | // Sometimes called during dispose() |
2494 | | |
2495 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
2496 | 0 | SolarMutexClearableGuard aReadLock; |
2497 | |
|
2498 | 0 | css::uno::Reference< css::frame::XFrame > xParent = m_xParent; |
2499 | 0 | css::uno::Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow; |
2500 | 0 | EActiveState eActiveState = m_eActiveState; |
2501 | |
|
2502 | 0 | aReadLock.clear(); |
2503 | |
|
2504 | 0 | if( eActiveState == E_INACTIVE ) |
2505 | 0 | return; |
2506 | | |
2507 | | // Deactivation is always done implicitly by activation of another frame. |
2508 | | // Only if no activation is done, deactivations have to be processed if the activated window |
2509 | | // is a parent window of the last active Window! |
2510 | 0 | SolarMutexClearableGuard aSolarGuard; |
2511 | 0 | vcl::Window* pFocusWindow = Application::GetFocusWindow(); |
2512 | 0 | if ( !xContainerWindow.is() || !xParent.is() || |
2513 | 0 | css::uno::Reference< css::frame::XDesktop >( xParent, css::uno::UNO_QUERY ).is() |
2514 | 0 | ) |
2515 | 0 | return; |
2516 | | |
2517 | 0 | css::uno::Reference< css::awt::XWindow > xParentWindow = xParent->getContainerWindow(); |
2518 | 0 | VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); |
2519 | | //#i70261#: dialogs opened from an OLE object will cause a deactivate on the frame of the OLE object |
2520 | | // On Solaris/Linux at that time pFocusWindow is still NULL because the focus handling is different; right after |
2521 | | // the deactivation the focus will be set into the dialog! |
2522 | | // Currently I see no case where a sub frame could get a deactivate with pFocusWindow being NULL permanently |
2523 | | // so for now this case is omitted from handled deactivations |
2524 | 0 | if( pFocusWindow && pParentWindow->IsChild( pFocusWindow ) ) |
2525 | 0 | { |
2526 | 0 | css::uno::Reference< css::frame::XFramesSupplier > xSupplier( xParent, css::uno::UNO_QUERY ); |
2527 | 0 | if( xSupplier.is() ) |
2528 | 0 | { |
2529 | 0 | aSolarGuard.clear(); |
2530 | 0 | xSupplier->setActiveFrame( css::uno::Reference< css::frame::XFrame >() ); |
2531 | 0 | } |
2532 | 0 | } |
2533 | 0 | } |
2534 | | |
2535 | | void SAL_CALL XFrameImpl::windowClosing( const css::lang::EventObject& ) |
2536 | 0 | { |
2537 | 0 | checkDisposed(); |
2538 | | |
2539 | | // deactivate this frame ... |
2540 | 0 | deactivate(); |
2541 | | |
2542 | | // and try to close it |
2543 | | // But do it asynchronously inside the main thread. |
2544 | | // VCL doesn't like to do such things outside its main thread :-( |
2545 | | // Note: the used dispatch makes it asynchronous for us .-) |
2546 | | |
2547 | | /*ATTENTION! |
2548 | | Don't try to suspend the controller here! Because it's done inside used dispatch(). |
2549 | | Otherwise the dialog "would you save your changes?" will be shown more than once. |
2550 | | */ |
2551 | |
|
2552 | 0 | css::util::URL aURL; |
2553 | 0 | aURL.Complete = ".uno:CloseFrame"; |
2554 | 0 | css::uno::Reference< css::util::XURLTransformer > xParser(css::util::URLTransformer::create(m_xContext)); |
2555 | 0 | xParser->parseStrict(aURL); |
2556 | |
|
2557 | 0 | css::uno::Reference< css::frame::XDispatch > xCloser = queryDispatch(aURL, SPECIALTARGET_SELF, 0); |
2558 | 0 | if (xCloser.is()) |
2559 | 0 | xCloser->dispatch(aURL, css::uno::Sequence< css::beans::PropertyValue >()); |
2560 | | |
2561 | | // Attention: if this dispatch works synchronously and fulfills its job, |
2562 | | // this line of code will never be reached. |
2563 | | // Or if it will be reached it will be for sure that all your member are gone .-) |
2564 | 0 | } |
2565 | | |
2566 | | /*-**************************************************************************************************** |
2567 | | @short react for a show event for the internal container window |
2568 | | @descr Normally we don't really need this information. But we can use it to |
2569 | | implement the special feature "trigger first visible task". |
2570 | | |
2571 | | Algorithm: - first we have to check if we are a top (task) frame |
2572 | | It's not enough to be a top frame! Because we MUST have the desktop as parent. |
2573 | | But frames without a parent are top too. So it's not possible to check isTop() here! |
2574 | | We have to look for the type of our parent. |
2575 | | - if we are a task frame, then we have to check if we are the first one. |
2576 | | We use a static variable to do so. They will be reset in order to be sure |
2577 | | that further calls of this method don't do anything. |
2578 | | - Then we have to trigger the right event string on the global job executor. |
2579 | | |
2580 | | @seealso css::task::JobExecutor |
2581 | | |
2582 | | @param aEvent |
2583 | | describes the source of this event |
2584 | | We are not interested in this information. We are interested in the visible state only. |
2585 | | |
2586 | | @threadsafe yes |
2587 | | *//*-*****************************************************************************************************/ |
2588 | | void SAL_CALL XFrameImpl::windowShown( const css::lang::EventObject& ) |
2589 | 0 | { |
2590 | 0 | static std::mutex aFirstVisibleLock; |
2591 | | |
2592 | | /* SAFE { */ |
2593 | 0 | SolarMutexClearableGuard aReadLock; |
2594 | 0 | css::uno::Reference< css::frame::XDesktop > xDesktopCheck( m_xParent, css::uno::UNO_QUERY ); |
2595 | 0 | m_bIsHidden = false; |
2596 | 0 | aReadLock.clear(); |
2597 | | /* } SAFE */ |
2598 | |
|
2599 | 0 | impl_checkMenuCloser(); |
2600 | |
|
2601 | 0 | if (!xDesktopCheck.is()) |
2602 | 0 | return; |
2603 | | |
2604 | 0 | static bool bFirstVisibleTask = true; |
2605 | 0 | std::unique_lock aGuard(aFirstVisibleLock); |
2606 | 0 | bool bMustBeTriggered = bFirstVisibleTask; |
2607 | 0 | bFirstVisibleTask = false; |
2608 | 0 | aGuard.unlock(); |
2609 | |
|
2610 | 0 | if (bMustBeTriggered) |
2611 | 0 | { |
2612 | 0 | css::uno::Reference< css::task::XJobExecutor > xExecutor |
2613 | 0 | = css::task::theJobExecutor::get( m_xContext ); |
2614 | 0 | xExecutor->trigger( u"onFirstVisibleTask"_ustr ); |
2615 | 0 | } |
2616 | 0 | } |
2617 | | |
2618 | | void SAL_CALL XFrameImpl::windowHidden( const css::lang::EventObject& ) |
2619 | 0 | { |
2620 | | /* SAFE { */ |
2621 | 0 | { |
2622 | 0 | SolarMutexGuard aReadLock; |
2623 | 0 | m_bIsHidden = true; |
2624 | 0 | } |
2625 | | /* } SAFE */ |
2626 | |
|
2627 | 0 | impl_checkMenuCloser(); |
2628 | 0 | } |
2629 | | |
2630 | | /*-**************************************************************************************************** |
2631 | | @short called by dispose of our windows! |
2632 | | @descr This object is forced to release all references to the interfaces given |
2633 | | by the parameter source. We are a listener at our container window and |
2634 | | should listen for its disposing. |
2635 | | |
2636 | | @seealso XWindowListener |
2637 | | @seealso XTopWindowListener |
2638 | | @seealso XFocusListener |
2639 | | *//*-*****************************************************************************************************/ |
2640 | | void SAL_CALL XFrameImpl::disposing( const css::lang::EventObject& aEvent ) |
2641 | 0 | { |
2642 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
2643 | 0 | SolarMutexResettableGuard aWriteLock; |
2644 | |
|
2645 | 0 | if( aEvent.Source == m_xContainerWindow ) |
2646 | 0 | { |
2647 | | // NECESSARY: Impl-method itself is threadsafe! |
2648 | 0 | aWriteLock.clear(); |
2649 | 0 | implts_stopWindowListening(); |
2650 | 0 | aWriteLock.reset(); |
2651 | 0 | m_xContainerWindow.clear(); |
2652 | 0 | } |
2653 | 0 | } |
2654 | | |
2655 | | /*-************************************************************************************************************ |
2656 | | @interface com.sun.star.document.XActionLockable |
2657 | | @short implement locking of frame/task from outside |
2658 | | @descr Sometimes we have problems in deciding if closing of a task is allowed. Because frame/task |
2659 | | could be used for pending loading jobs. So you can lock this object from outside and |
2660 | | prevent the instance from closing it during use! But don't do it in a wrong or expensive manner. |
2661 | | Otherwise the task can't die anymore!!! |
2662 | | |
2663 | | @seealso interface XActionLockable |
2664 | | @seealso method BaseDispatcher::implts_loadIt() |
2665 | | @seealso method Desktop::loadComponentFromURL() |
2666 | | @return true if frame/task is locked |
2667 | | false otherwise |
2668 | | @threadsafe yes |
2669 | | *//*-*************************************************************************************************************/ |
2670 | | sal_Bool SAL_CALL XFrameImpl::isActionLocked() |
2671 | 6.21k | { |
2672 | 6.21k | SolarMutexGuard g; |
2673 | 6.21k | return( m_nExternalLockCount!=0); |
2674 | 6.21k | } |
2675 | | |
2676 | | void SAL_CALL XFrameImpl::addActionLock() |
2677 | 0 | { |
2678 | 0 | SolarMutexGuard g; |
2679 | 0 | ++m_nExternalLockCount; |
2680 | 0 | } |
2681 | | |
2682 | | void SAL_CALL XFrameImpl::removeActionLock() |
2683 | 0 | { |
2684 | 0 | { |
2685 | 0 | SolarMutexGuard g; |
2686 | 0 | SAL_WARN_IF( m_nExternalLockCount<=0, "fwk.frame", "XFrameImpl::removeActionLock(): Frame is not locked! " |
2687 | 0 | "Possible multithreading problem detected." ); |
2688 | 0 | --m_nExternalLockCount; |
2689 | 0 | } |
2690 | | |
2691 | 0 | implts_checkSuicide(); |
2692 | 0 | } |
2693 | | |
2694 | | void SAL_CALL XFrameImpl::setActionLocks( sal_Int16 nLock ) |
2695 | 0 | { |
2696 | 0 | SolarMutexGuard g; |
2697 | | // Attention: if resetActionLocks() is called somewhere before and gets e.g. 5 locks |
2698 | | // and tried to set these 5 here after its operations, |
2699 | | // we can't ignore set requests during these two calls! |
2700 | | // So we must add(!) these 5 locks here. |
2701 | 0 | m_nExternalLockCount = m_nExternalLockCount + nLock; |
2702 | 0 | } |
2703 | | |
2704 | | sal_Int16 SAL_CALL XFrameImpl::resetActionLocks() |
2705 | 0 | { |
2706 | 0 | sal_Int16 nCurrentLocks = 0; |
2707 | 0 | { |
2708 | 0 | SolarMutexGuard g; |
2709 | 0 | nCurrentLocks = m_nExternalLockCount; |
2710 | 0 | m_nExternalLockCount = 0; |
2711 | 0 | } |
2712 | | |
2713 | | // Attention: |
2714 | | // external lock count is 0 here every time, but if |
2715 | | // member m_bSelfClose is set to true as well, we call our own close()/dispose(). |
2716 | | // See close() for further information |
2717 | 0 | implts_checkSuicide(); |
2718 | |
|
2719 | 0 | return nCurrentLocks; |
2720 | 0 | } |
2721 | | |
2722 | | void XFrameImpl::impl_setPropertyValue(sal_Int32 nHandle, |
2723 | | const css::uno::Any& aValue) |
2724 | | |
2725 | 0 | { |
2726 | | /* There is no need to lock any mutex here. Because we share the |
2727 | | solar mutex with our base class. And we said to our base class: "don't release it on calling us" .-) |
2728 | | */ |
2729 | | |
2730 | | /* Attention: you can use nHandle only, if you are sure that all supported |
2731 | | properties have a unique handle. That must be guaranteed |
2732 | | inside method initListeners()! |
2733 | | */ |
2734 | 0 | switch (static_cast<FramePropHandle>(nHandle)) |
2735 | 0 | { |
2736 | 0 | case FramePropHandle::Title : |
2737 | 0 | { |
2738 | 0 | OUString sExternalTitle; |
2739 | 0 | aValue >>= sExternalTitle; |
2740 | 0 | setTitle (sExternalTitle); |
2741 | 0 | } |
2742 | 0 | break; |
2743 | | |
2744 | 0 | case FramePropHandle::DispatchRecorderSupplier : |
2745 | 0 | aValue >>= m_xDispatchRecorderSupplier; |
2746 | 0 | break; |
2747 | | |
2748 | 0 | case FramePropHandle::LayoutManager : |
2749 | 0 | { |
2750 | 0 | css::uno::Reference< css::frame::XLayoutManager2 > xOldLayoutManager = m_xLayoutManager; |
2751 | 0 | css::uno::Reference< css::frame::XLayoutManager2 > xNewLayoutManager; |
2752 | 0 | aValue >>= xNewLayoutManager; |
2753 | |
|
2754 | 0 | if (xOldLayoutManager != xNewLayoutManager) |
2755 | 0 | { |
2756 | 0 | m_xLayoutManager = xNewLayoutManager; |
2757 | 0 | if (xOldLayoutManager.is()) |
2758 | 0 | disableLayoutManager(xOldLayoutManager); |
2759 | 0 | if (xNewLayoutManager.is() && !m_bDocHidden) |
2760 | 0 | lcl_enableLayoutManager(xNewLayoutManager, this); |
2761 | 0 | } |
2762 | 0 | } |
2763 | 0 | break; |
2764 | | |
2765 | 0 | case FramePropHandle::IndicatorInterception : |
2766 | 0 | { |
2767 | 0 | css::uno::Reference< css::task::XStatusIndicator > xProgress; |
2768 | 0 | aValue >>= xProgress; |
2769 | 0 | m_xIndicatorInterception = xProgress; |
2770 | 0 | } |
2771 | 0 | break; |
2772 | | |
2773 | 0 | case FramePropHandle::Url: |
2774 | 0 | { |
2775 | 0 | aValue >>= m_aURL; |
2776 | 0 | } |
2777 | 0 | break; |
2778 | 0 | default : |
2779 | 0 | SAL_INFO("fwk.frame", "XFrameImpl::setFastPropertyValue_NoBroadcast(): Invalid handle detected!" ); |
2780 | 0 | break; |
2781 | 0 | } |
2782 | 0 | } |
2783 | | |
2784 | | css::uno::Any XFrameImpl::impl_getPropertyValue(sal_Int32 nHandle) |
2785 | 25.2M | { |
2786 | | /* There is no need to lock any mutex here. Because we share the |
2787 | | solar mutex with our base class. And we said to our base class: "don't release it on calling us" .-) |
2788 | | */ |
2789 | | |
2790 | | /* Attention: you can use nHandle only, if you are sure that all supported |
2791 | | properties have a unique handle. That must be guaranteed |
2792 | | inside method initListeners()! |
2793 | | */ |
2794 | 25.2M | css::uno::Any aValue; |
2795 | 25.2M | switch (static_cast<FramePropHandle>(nHandle)) |
2796 | 25.2M | { |
2797 | 0 | case FramePropHandle::Title : |
2798 | 0 | aValue <<= getTitle (); |
2799 | 0 | break; |
2800 | | |
2801 | 0 | case FramePropHandle::DispatchRecorderSupplier : |
2802 | 0 | aValue <<= m_xDispatchRecorderSupplier; |
2803 | 0 | break; |
2804 | | |
2805 | 25.1M | case FramePropHandle::IsHidden : |
2806 | 25.1M | aValue <<= m_bIsHidden; |
2807 | 25.1M | break; |
2808 | | |
2809 | 48.1k | case FramePropHandle::LayoutManager : |
2810 | 48.1k | aValue <<= m_xLayoutManager; |
2811 | 48.1k | break; |
2812 | | |
2813 | 0 | case FramePropHandle::IndicatorInterception : |
2814 | 0 | { |
2815 | 0 | css::uno::Reference< css::task::XStatusIndicator > xProgress(m_xIndicatorInterception.get(), |
2816 | 0 | css::uno::UNO_QUERY); |
2817 | 0 | aValue <<= xProgress; |
2818 | 0 | } |
2819 | 0 | break; |
2820 | | |
2821 | 0 | case FramePropHandle::Url: |
2822 | 0 | { |
2823 | 0 | aValue <<= m_aURL; |
2824 | 0 | } |
2825 | 0 | break; |
2826 | 0 | default : |
2827 | 0 | SAL_INFO("fwk.frame", "XFrameImpl::getFastPropertyValue(): Invalid handle detected!" ); |
2828 | 0 | break; |
2829 | 25.2M | } |
2830 | | |
2831 | 25.2M | return aValue; |
2832 | 25.2M | } |
2833 | | |
2834 | | void XFrameImpl::impl_setPropertyChangeBroadcaster(XFrameImpl& xBroadcaster) |
2835 | 11.0k | { |
2836 | 11.0k | SolarMutexGuard g; |
2837 | 11.0k | m_xBroadcaster = &xBroadcaster; |
2838 | 11.0k | } |
2839 | | |
2840 | | void XFrameImpl::impl_addPropertyInfo(const OUString& rName, FramePropHandle eHandle, const css::uno::Type& rType, sal_Int16 nAttributes) |
2841 | 66.0k | { |
2842 | 66.0k | SolarMutexGuard g; |
2843 | 66.0k | css::beans::Property aProperty(rName, static_cast<sal_Int32>(eHandle), rType, nAttributes); |
2844 | 66.0k | TPropInfoHash::const_iterator pIt = m_lProps.find(rName); |
2845 | 66.0k | if (pIt != m_lProps.end()) |
2846 | 0 | throw css::beans::PropertyExistException(); |
2847 | 66.0k | m_lProps[rName] = aProperty; |
2848 | 66.0k | } |
2849 | | |
2850 | | void XFrameImpl::impl_disablePropertySet() |
2851 | 6.21k | { |
2852 | 6.21k | SolarMutexGuard g; |
2853 | | |
2854 | 6.21k | css::uno::Reference< css::uno::XInterface > xThis(static_cast< css::beans::XPropertySet* >(this), css::uno::UNO_QUERY); |
2855 | 6.21k | css::lang::EventObject aEvent(xThis); |
2856 | | |
2857 | 6.21k | m_lSimpleChangeListener.disposeAndClear(aEvent); |
2858 | 6.21k | m_lVetoChangeListener.disposeAndClear(aEvent); |
2859 | 6.21k | m_lProps.clear(); |
2860 | 6.21k | } |
2861 | | |
2862 | | bool XFrameImpl::impl_existsVeto(const css::beans::PropertyChangeEvent& aEvent) |
2863 | 0 | { |
2864 | | /* Don't use the lock here! |
2865 | | The used helper is threadsafe and it lives for the whole lifetime of |
2866 | | our own object. |
2867 | | */ |
2868 | 0 | ::comphelper::OInterfaceContainerHelper3<css::beans::XVetoableChangeListener>* pVetoListener = m_lVetoChangeListener.getContainer(aEvent.PropertyName); |
2869 | 0 | if (! pVetoListener) |
2870 | 0 | return false; |
2871 | | |
2872 | 0 | ::comphelper::OInterfaceIteratorHelper3 pListener(*pVetoListener); |
2873 | 0 | while (pListener.hasMoreElements()) |
2874 | 0 | { |
2875 | 0 | try |
2876 | 0 | { |
2877 | 0 | pListener.next()->vetoableChange(aEvent); |
2878 | 0 | } |
2879 | 0 | catch(const css::uno::RuntimeException&) |
2880 | 0 | { pListener.remove(); } |
2881 | 0 | catch(const css::beans::PropertyVetoException&) |
2882 | 0 | { return true; } |
2883 | 0 | } |
2884 | | |
2885 | 0 | return false; |
2886 | 0 | } |
2887 | | |
2888 | | void XFrameImpl::impl_notifyChangeListener(const css::beans::PropertyChangeEvent& aEvent) |
2889 | 0 | { |
2890 | | /* Don't use the lock here! |
2891 | | The used helper is threadsafe and it lives for the whole lifetime of |
2892 | | our own object. |
2893 | | */ |
2894 | 0 | ::comphelper::OInterfaceContainerHelper3<css::beans::XPropertyChangeListener>* pSimpleListener = m_lSimpleChangeListener.getContainer(aEvent.PropertyName); |
2895 | 0 | if (! pSimpleListener) |
2896 | 0 | return; |
2897 | | |
2898 | 0 | ::comphelper::OInterfaceIteratorHelper3 pListener(*pSimpleListener); |
2899 | 0 | while (pListener.hasMoreElements()) |
2900 | 0 | { |
2901 | 0 | try |
2902 | 0 | { |
2903 | 0 | pListener.next()->propertyChange(aEvent); |
2904 | 0 | } |
2905 | 0 | catch(const css::uno::RuntimeException&) |
2906 | 0 | { pListener.remove(); } |
2907 | 0 | } |
2908 | 0 | } |
2909 | | |
2910 | | /*-**************************************************************************************************** |
2911 | | @short send frame action event to our listener |
2912 | | @descr This method is threadsafe AND can be called by our dispose method too! |
2913 | | @param "aAction", describe the event for sending |
2914 | | *//*-*****************************************************************************************************/ |
2915 | | void XFrameImpl::implts_sendFrameActionEvent( const css::frame::FrameAction& aAction ) |
2916 | 24.8k | { |
2917 | | // Sometimes used by dispose() |
2918 | | |
2919 | | // Log information about order of events to file! |
2920 | | // (only activated in debug version!) |
2921 | 24.8k | SAL_INFO( "fwk.frame", |
2922 | 24.8k | "[Frame] " << m_sName << " send event " << |
2923 | 24.8k | (aAction == css::frame::FrameAction_COMPONENT_ATTACHED ? u"COMPONENT ATTACHED"_ustr : |
2924 | 24.8k | (aAction == css::frame::FrameAction_COMPONENT_DETACHING ? u"COMPONENT DETACHING"_ustr : |
2925 | 24.8k | (aAction == css::frame::FrameAction_COMPONENT_REATTACHED ? u"COMPONENT REATTACHED"_ustr : |
2926 | 24.8k | (aAction == css::frame::FrameAction_FRAME_ACTIVATED ? u"FRAME ACTIVATED"_ustr : |
2927 | 24.8k | (aAction == css::frame::FrameAction_FRAME_DEACTIVATING ? u"FRAME DEACTIVATING"_ustr : |
2928 | 24.8k | (aAction == css::frame::FrameAction_CONTEXT_CHANGED ? u"CONTEXT CHANGED"_ustr : |
2929 | 24.8k | (aAction == css::frame::FrameAction_FRAME_UI_ACTIVATED ? u"FRAME UI ACTIVATED"_ustr : |
2930 | 24.8k | (aAction == css::frame::FrameAction_FRAME_UI_DEACTIVATING ? u"FRAME UI DEACTIVATING"_ustr : |
2931 | 24.8k | (aAction == css::frame::FrameAction::FrameAction_MAKE_FIXED_SIZE ? u"MAKE_FIXED_SIZE"_ustr : |
2932 | 24.8k | u"*invalid*"_ustr)))))))))); |
2933 | | |
2934 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
2935 | | // Send css::frame::FrameAction event to all listeners. |
2936 | | // Get container for right listener. |
2937 | | // THE FOLLOWING LINES ARE THREADSAFE!!! |
2938 | | // ( OInterfaceContainerHelper2 is synchronized with m_aListenerContainer! ) |
2939 | 24.8k | comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerContainer.getContainer( |
2940 | 24.8k | cppu::UnoType<css::frame::XFrameActionListener>::get()); |
2941 | | |
2942 | 24.8k | if( pContainer == nullptr ) |
2943 | 0 | return; |
2944 | | |
2945 | | // Build action event. |
2946 | 24.8k | css::frame::FrameActionEvent aFrameActionEvent( static_cast< ::cppu::OWeakObject* >(this), this, aAction ); |
2947 | | |
2948 | | // Get iterator for access to listener. |
2949 | 24.8k | comphelper::OInterfaceIteratorHelper2 aIterator( *pContainer ); |
2950 | | // Send message to all listeners. |
2951 | 142k | while( aIterator.hasMoreElements() ) |
2952 | 118k | { |
2953 | 118k | try |
2954 | 118k | { |
2955 | 118k | static_cast<css::frame::XFrameActionListener*>(aIterator.next())->frameAction( aFrameActionEvent ); |
2956 | 118k | } |
2957 | 118k | catch( const css::uno::RuntimeException& ) |
2958 | 118k | { |
2959 | 6.21k | aIterator.remove(); |
2960 | 6.21k | } |
2961 | 118k | } |
2962 | 24.8k | } |
2963 | | |
2964 | | /*-**************************************************************************************************** |
2965 | | @short helper to resize our component window |
2966 | | @descr A frame contains 2 windows: a container and a component window. |
2967 | | This method resizes the inner component window to the full size of the outer container window. |
2968 | | This method is threadsafe AND can be called by our dispose method too! |
2969 | | *//*-*****************************************************************************************************/ |
2970 | | void XFrameImpl::implts_resizeComponentWindow() |
2971 | 12.4k | { |
2972 | | // usually the LayoutManager does the resizing |
2973 | | // in case there is no LayoutManager resizing has to be done here |
2974 | 12.4k | if ( m_xLayoutManager.is() ) |
2975 | 12.4k | return; |
2976 | | |
2977 | 0 | css::uno::Reference< css::awt::XWindow > xComponentWindow( getComponentWindow() ); |
2978 | 0 | if( !xComponentWindow.is() ) |
2979 | 0 | return; |
2980 | | |
2981 | 0 | css::uno::Reference< css::awt::XDevice > xDevice( getContainerWindow(), css::uno::UNO_QUERY ); |
2982 | | |
2983 | | // Convert relative size to output size. |
2984 | 0 | css::awt::Rectangle aRectangle = getContainerWindow()->getPosSize(); |
2985 | 0 | css::awt::DeviceInfo aInfo = xDevice->getInfo(); |
2986 | 0 | css::awt::Size aSize( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset, |
2987 | 0 | aRectangle.Height - aInfo.TopInset - aInfo.BottomInset ); |
2988 | | |
2989 | | // Resize our component window. |
2990 | 0 | xComponentWindow->setPosSize( 0, 0, aSize.Width, aSize.Height, css::awt::PosSize::POSSIZE ); |
2991 | 0 | } |
2992 | | |
2993 | | /*-**************************************************************************************************** |
2994 | | @short helper to set icon on our container window (if it is a system window!) |
2995 | | @descr We use our internal set controller (if it exists) to specify which factory it represents. |
2996 | | This information can be used to find the right icon. But our controller can tell it to us directly, |
2997 | | too. We should ask its optional property set first. |
2998 | | |
2999 | | @seealso method Window::SetIcon() |
3000 | | @onerror We do nothing. |
3001 | | *//*-*****************************************************************************************************/ |
3002 | | void XFrameImpl::implts_setIconOnWindow() |
3003 | 12.4k | { |
3004 | 12.4k | checkDisposed(); |
3005 | | |
3006 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
3007 | | // Make snapshot of necessary members and release lock. |
3008 | 12.4k | SolarMutexClearableGuard aReadLock; |
3009 | 12.4k | css::uno::Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow; |
3010 | 12.4k | css::uno::Reference< css::frame::XController > xController = m_xController; |
3011 | 12.4k | aReadLock.clear(); |
3012 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
3013 | | |
3014 | 12.4k | if( !(xContainerWindow.is() && xController.is()) ) |
3015 | 6.21k | return; |
3016 | | |
3017 | | |
3018 | | // a) set default value to an invalid one. So we can start further searches for right icon id, if |
3019 | | // first steps failed! |
3020 | | // We must reset it to any fallback value - if no search step returns a valid result. |
3021 | 6.21k | sal_Int32 nIcon = -1; |
3022 | | |
3023 | | // b) try to find information on controller propertyset directly |
3024 | | // Don't forget to catch possible exceptions, because this property is an optional one! |
3025 | 6.21k | css::uno::Reference< css::beans::XPropertySet > xSet( xController, css::uno::UNO_QUERY ); |
3026 | 6.21k | if( xSet.is() ) |
3027 | 6.21k | { |
3028 | 6.21k | try |
3029 | 6.21k | { |
3030 | 6.21k | css::uno::Reference< css::beans::XPropertySetInfo > const xPSI( xSet->getPropertySetInfo(), |
3031 | 6.21k | css::uno::UNO_SET_THROW ); |
3032 | 6.21k | if ( xPSI->hasPropertyByName( u"IconId"_ustr ) ) |
3033 | 0 | xSet->getPropertyValue( u"IconId"_ustr ) >>= nIcon; |
3034 | 6.21k | } |
3035 | 6.21k | catch( css::uno::Exception& ) |
3036 | 6.21k | { |
3037 | 0 | DBG_UNHANDLED_EXCEPTION("fwk"); |
3038 | 0 | } |
3039 | 6.21k | } |
3040 | | |
3041 | | // c) if b) failed, analyze argument list of currently loaded document inside the frame to find the filter. |
3042 | | // It can be used to detect the right factory and these can be used to match factory to icon. |
3043 | 6.21k | if( nIcon == -1 ) |
3044 | 6.21k | { |
3045 | 6.21k | css::uno::Reference< css::frame::XModel > xModel = xController->getModel(); |
3046 | 6.21k | if( xModel.is() ) |
3047 | 6.21k | { |
3048 | 6.21k | SvtModuleOptions::EFactory eFactory = SvtModuleOptions::ClassifyFactoryByModel(xModel); |
3049 | 6.21k | if (eFactory != SvtModuleOptions::EFactory::UNKNOWN_FACTORY) |
3050 | 6.21k | nIcon = SvtModuleOptions().GetFactoryIcon( eFactory ); |
3051 | 6.21k | } |
3052 | 6.21k | } |
3053 | | |
3054 | | // d) if all steps failed, use fallback! |
3055 | 6.21k | if( nIcon == -1 ) |
3056 | 0 | { |
3057 | 0 | nIcon = 0; |
3058 | 0 | } |
3059 | | |
3060 | | // e) set icon on container window now |
3061 | | // Don't forget SolarMutex! We use vcl directly :-( |
3062 | | // Check window pointer for right WorkWindow class too!!! |
3063 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
3064 | 6.21k | { |
3065 | 6.21k | SolarMutexGuard aSolarGuard; |
3066 | 6.21k | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xContainerWindow ); |
3067 | 6.21k | if( |
3068 | 6.21k | ( pWindow != nullptr ) && |
3069 | 6.21k | ( pWindow->GetType() == WindowType::WORKWINDOW ) |
3070 | 6.21k | ) |
3071 | 6.21k | { |
3072 | 6.21k | WorkWindow* pWorkWindow = static_cast<WorkWindow*>(pWindow.get()); |
3073 | 6.21k | pWorkWindow->SetIcon( static_cast<sal_uInt16>(nIcon) ); |
3074 | 6.21k | } |
3075 | 6.21k | } |
3076 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
3077 | 6.21k | } |
3078 | | |
3079 | | /*-************************************************************************************************************ |
3080 | | @short helper to start/stop listening for window events on container window |
3081 | | @descr If we get a new container window, we must set it on an internal member |
3082 | | and stop listening at the old one and start listening at the new one! |
3083 | | But sometimes (in dispose() call!) it's necessary to stop listening without starting |
3084 | | on new connections. So we split this functionality to make it easier to use. |
3085 | | |
3086 | | @seealso method initialize() |
3087 | | @seealso method dispose() |
3088 | | @onerror We do nothing! |
3089 | | @threadsafe yes |
3090 | | *//*-*************************************************************************************************************/ |
3091 | | void XFrameImpl::implts_startWindowListening() |
3092 | 23.4k | { |
3093 | 23.4k | checkDisposed(); |
3094 | | |
3095 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
3096 | | // Make snapshot of necessary members! |
3097 | 23.4k | SolarMutexClearableGuard aReadLock; |
3098 | 23.4k | css::uno::Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow; |
3099 | 23.4k | rtl::Reference< OpenFileDropTargetListener > xDragDropListener = m_xDropTargetListener; |
3100 | 23.4k | css::uno::Reference< css::awt::XWindowListener > xWindowListener(this); |
3101 | 23.4k | css::uno::Reference< css::awt::XFocusListener > xFocusListener(this); |
3102 | 23.4k | css::uno::Reference< css::awt::XTopWindowListener > xTopWindowListener(this); |
3103 | 23.4k | aReadLock.clear(); |
3104 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
3105 | | |
3106 | 23.4k | if( !xContainerWindow.is() ) |
3107 | 0 | return; |
3108 | | |
3109 | 23.4k | xContainerWindow->addWindowListener( xWindowListener); |
3110 | 23.4k | xContainerWindow->addFocusListener ( xFocusListener ); |
3111 | | |
3112 | 23.4k | css::uno::Reference< css::awt::XTopWindow > xTopWindow( xContainerWindow, css::uno::UNO_QUERY ); |
3113 | 23.4k | if( xTopWindow.is() ) |
3114 | 23.4k | { |
3115 | 23.4k | xTopWindow->addTopWindowListener( xTopWindowListener ); |
3116 | | |
3117 | 23.4k | css::uno::Reference< css::awt::XToolkit2 > xToolkit = css::awt::Toolkit::create( m_xContext ); |
3118 | 23.4k | css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = xToolkit->getDropTarget( xContainerWindow ); |
3119 | 23.4k | if( xDropTarget.is() ) |
3120 | 23.4k | { |
3121 | 23.4k | xDropTarget->addDropTargetListener( xDragDropListener ); |
3122 | 23.4k | xDropTarget->setActive( true ); |
3123 | 23.4k | } |
3124 | 23.4k | } |
3125 | 23.4k | } |
3126 | | |
3127 | | void XFrameImpl::implts_stopWindowListening() |
3128 | 18.6k | { |
3129 | | // Sometimes used by dispose() |
3130 | | |
3131 | | /* SAFE AREA ----------------------------------------------------------------------------------------------- */ |
3132 | | // Make snapshot of necessary members! |
3133 | 18.6k | SolarMutexClearableGuard aReadLock; |
3134 | 18.6k | css::uno::Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow; |
3135 | 18.6k | rtl::Reference< OpenFileDropTargetListener > xDragDropListener = m_xDropTargetListener; |
3136 | 18.6k | css::uno::Reference< css::awt::XWindowListener > xWindowListener(this); |
3137 | 18.6k | css::uno::Reference< css::awt::XFocusListener > xFocusListener(this); |
3138 | 18.6k | css::uno::Reference< css::awt::XTopWindowListener > xTopWindowListener(this); |
3139 | 18.6k | aReadLock.clear(); |
3140 | | /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ |
3141 | | |
3142 | 18.6k | if( !xContainerWindow.is() ) |
3143 | 0 | return; |
3144 | | |
3145 | 18.6k | xContainerWindow->removeWindowListener( xWindowListener); |
3146 | 18.6k | xContainerWindow->removeFocusListener ( xFocusListener ); |
3147 | | |
3148 | 18.6k | css::uno::Reference< css::awt::XTopWindow > xTopWindow( xContainerWindow, css::uno::UNO_QUERY ); |
3149 | 18.6k | if( !xTopWindow.is() ) |
3150 | 0 | return; |
3151 | | |
3152 | 18.6k | xTopWindow->removeTopWindowListener( xTopWindowListener ); |
3153 | | |
3154 | 18.6k | css::uno::Reference< css::awt::XToolkit2 > xToolkit = css::awt::Toolkit::create( m_xContext ); |
3155 | 18.6k | css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = |
3156 | 18.6k | xToolkit->getDropTarget( xContainerWindow ); |
3157 | 18.6k | if( xDropTarget.is() ) |
3158 | 18.6k | { |
3159 | 18.6k | xDropTarget->removeDropTargetListener( xDragDropListener ); |
3160 | 18.6k | xDropTarget->setActive( false ); |
3161 | 18.6k | } |
3162 | 18.6k | } |
3163 | | |
3164 | | /*-**************************************************************************************************** |
3165 | | @short helper to force broken close() request again |
3166 | | @descr If we disagree with a close() request, and detect that all external locks are gone, |
3167 | | then we must try to close this frame again. |
3168 | | |
3169 | | @seealso XCloseable::close() |
3170 | | @seealso XFrameImpl::close() |
3171 | | @seealso XFrameImpl::removeActionLock() |
3172 | | @seealso XFrameImpl::resetActionLock() |
3173 | | @seealso m_bSelfClose |
3174 | | @seealso m_nExternalLockCount |
3175 | | |
3176 | | @threadsafe yes |
3177 | | *//*-*****************************************************************************************************/ |
3178 | | void XFrameImpl::implts_checkSuicide() |
3179 | 0 | { |
3180 | | /* SAFE */ |
3181 | 0 | SolarMutexClearableGuard aReadLock; |
3182 | | // in case of lock==0 and saved state of previous close() request m_bSelfClose |
3183 | | // we must force close() again. Because we had disagreed with that before. |
3184 | 0 | bool bSuicide = (m_nExternalLockCount==0 && m_bSelfClose); |
3185 | 0 | m_bSelfClose = false; |
3186 | 0 | aReadLock.clear(); |
3187 | | /* } SAFE */ |
3188 | | // Force close and deliver ownership to source of possible thrown veto exception. |
3189 | | // Attention: because this method is not designed to throw such an exception we must suppress |
3190 | | // it for outside code! |
3191 | 0 | try |
3192 | 0 | { |
3193 | 0 | if (bSuicide) |
3194 | 0 | close(true); |
3195 | 0 | } |
3196 | 0 | catch(const css::util::CloseVetoException&) |
3197 | 0 | {} |
3198 | 0 | catch(const css::lang::DisposedException&) |
3199 | 0 | {} |
3200 | 0 | } |
3201 | | |
3202 | | /** a small helper to enable/disable the menu closer at the menubar of the given frame. |
3203 | | |
3204 | | @param xFrame |
3205 | | we use its layout manager to set/reset a special callback. |
3206 | | Its existence regulates visibility of this closer item. |
3207 | | |
3208 | | @param bState |
3209 | | <TRUE/> enable; <FALSE/> disable this state |
3210 | | */ |
3211 | | // static |
3212 | | void XFrameImpl::impl_setCloser( /*IN*/ const css::uno::Reference< css::frame::XFrame2 >& xFrame , |
3213 | | /*IN*/ bool bState ) |
3214 | 0 | { |
3215 | | // Note: if start module is not installed, no closer has to be shown! |
3216 | 0 | if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::STARTMODULE)) |
3217 | 0 | return; |
3218 | | |
3219 | 0 | try |
3220 | 0 | { |
3221 | 0 | css::uno::Reference< css::beans::XPropertySet > xFrameProps(xFrame, css::uno::UNO_QUERY_THROW); |
3222 | 0 | css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; |
3223 | 0 | xFrameProps->getPropertyValue(FramePropNames[FramePropHandle::LayoutManager]) >>= xLayoutManager; |
3224 | 0 | css::uno::Reference< css::beans::XPropertySet > xLayoutProps(xLayoutManager, css::uno::UNO_QUERY_THROW); |
3225 | 0 | xLayoutProps->setPropertyValue(LayoutManagerPropNames[LayoutManagerPropHandle::MenuBarCloser], css::uno::Any(bState)); |
3226 | 0 | } |
3227 | 0 | catch(const css::uno::RuntimeException&) |
3228 | 0 | { throw; } |
3229 | 0 | catch(const css::uno::Exception&) |
3230 | 0 | {} |
3231 | 0 | } |
3232 | | |
3233 | | /** it checks, which of the top level task frames must have the special menu closer for |
3234 | | switching to the backing window mode. |
3235 | | |
3236 | | It analyzes the current list of visible top level frames. Only the last real document |
3237 | | frame can have this symbol. Not the help frame nor the backing task itself. |
3238 | | Here we do anything related to this closer. We remove it from the old frame and set it |
3239 | | for the new one. |
3240 | | */ |
3241 | | |
3242 | | void XFrameImpl::impl_checkMenuCloser() |
3243 | 24.8k | { |
3244 | | /* SAFE { */ |
3245 | 24.8k | SolarMutexClearableGuard aReadLock; |
3246 | | |
3247 | | // Only top frames, which are part of our desktop hierarchy, can |
3248 | | // do so! By the way, we need the desktop instance to have access |
3249 | | // to all other top level frames too. |
3250 | 24.8k | css::uno::Reference< css::frame::XDesktop > xDesktop (m_xParent, css::uno::UNO_QUERY); |
3251 | 24.8k | css::uno::Reference< css::frame::XFramesSupplier > xTaskSupplier(xDesktop , css::uno::UNO_QUERY); |
3252 | 24.8k | if ( !xDesktop.is() || !xTaskSupplier.is() ) |
3253 | 6.21k | return; |
3254 | | |
3255 | 18.6k | aReadLock.clear(); |
3256 | | /* } SAFE */ |
3257 | | |
3258 | | // Analyze the list of current open tasks. |
3259 | | // Suppress search for other views to the same model. |
3260 | | // It's not needed here and can be very expensive. |
3261 | 18.6k | FrameListAnalyzer aAnalyzer( |
3262 | 18.6k | xTaskSupplier, |
3263 | 18.6k | this, |
3264 | 18.6k | FrameAnalyzerFlags::Hidden | FrameAnalyzerFlags::Help | FrameAnalyzerFlags::BackingComponent); |
3265 | | |
3266 | | // specify the new frame, which must have this special state... |
3267 | 18.6k | css::uno::Reference< css::frame::XFrame2 > xNewCloserFrame; |
3268 | | |
3269 | | // a) |
3270 | | // If there exists at least one other frame, there are two frames currently open. |
3271 | | // But we can only enable this closer, if one of these two tasks includes the help module. |
3272 | | // The "other frame" couldn't be the help. Because then it wouldn't be part of this "other list". |
3273 | | // In such a case it will be separated to the reference aAnalyzer.m_xHelp! |
3274 | | // But we must check, if we ourselves include the help. |
3275 | | // Check aAnalyzer.m_bReferenceIsHelp! |
3276 | 18.6k | if ( |
3277 | 18.6k | (aAnalyzer.m_lOtherVisibleFrames.size()==1) && |
3278 | 0 | ( |
3279 | 0 | (aAnalyzer.m_bReferenceIsHelp ) || |
3280 | 0 | (aAnalyzer.m_bReferenceIsHidden) |
3281 | 0 | ) |
3282 | 18.6k | ) |
3283 | 0 | { |
3284 | | // others[0] can't be the backing component! |
3285 | | // Because it's set at the special member aAnalyzer.m_xBackingComponent ... :-) |
3286 | 0 | xNewCloserFrame.set( aAnalyzer.m_lOtherVisibleFrames[0], css::uno::UNO_QUERY_THROW ); |
3287 | 0 | } |
3288 | | |
3289 | | // b) |
3290 | | // There is no other frame, meaning no other document frame. The help module |
3291 | | // will be handled separately and must(!) be ignored here, except if we ourselves include the help. |
3292 | 18.6k | else if ( |
3293 | 18.6k | (aAnalyzer.m_lOtherVisibleFrames.empty()) && |
3294 | 18.6k | (!aAnalyzer.m_bReferenceIsHelp) && |
3295 | 18.6k | (!aAnalyzer.m_bReferenceIsHidden) && |
3296 | 0 | (!aAnalyzer.m_bReferenceIsBacking) |
3297 | 18.6k | ) |
3298 | 0 | { |
3299 | 0 | xNewCloserFrame = this; |
3300 | 0 | } |
3301 | | |
3302 | | // Look for necessary actions. |
3303 | | // Only if the closer state must be moved from one frame to another one |
3304 | | // or must be enabled/disabled at all. |
3305 | 18.6k | SolarMutexGuard aGuard; |
3306 | | // Holds the only frame, which must show the special closer menu item (can be NULL!) |
3307 | 18.6k | static css::uno::WeakReference< css::frame::XFrame2 > s_xCloserFrame; |
3308 | 18.6k | css::uno::Reference< css::frame::XFrame2 > xCloserFrame (s_xCloserFrame.get(), css::uno::UNO_QUERY); |
3309 | 18.6k | if (xCloserFrame!=xNewCloserFrame) |
3310 | 0 | { |
3311 | 0 | if (xCloserFrame.is()) |
3312 | 0 | impl_setCloser(xCloserFrame, false); |
3313 | 0 | if (xNewCloserFrame.is()) |
3314 | 0 | impl_setCloser(xNewCloserFrame, true); |
3315 | 0 | s_xCloserFrame = xNewCloserFrame; |
3316 | 0 | } |
3317 | 18.6k | } |
3318 | | |
3319 | | } |
3320 | | |
3321 | | extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * |
3322 | | com_sun_star_comp_framework_Frame_get_implementation( |
3323 | | css::uno::XComponentContext *context, |
3324 | | css::uno::Sequence<css::uno::Any> const &) |
3325 | 11.0k | { |
3326 | 11.0k | rtl::Reference<XFrameImpl> inst = new XFrameImpl(context); |
3327 | 11.0k | css::uno::XInterface *acquired_inst = cppu::acquire(inst.get()); |
3328 | | |
3329 | 11.0k | inst->initListeners(); |
3330 | | |
3331 | 11.0k | return acquired_inst; |
3332 | 11.0k | } |
3333 | | |
3334 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |