LibreOffice Module framework (master) 1
desktop.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <sal/config.h>
23
24#include <memory>
25#include <vector>
26
27#include "framecontainer.hxx"
28#include "fwkdllapi.h"
30
31#include <com/sun/star/frame/XUntitledNumbers.hpp>
32#include <com/sun/star/frame/XController.hpp>
33#include <com/sun/star/frame/XDesktop2.hpp>
34#include <com/sun/star/frame/XTerminateListener.hpp>
35#include <com/sun/star/frame/XTask.hpp>
36#include <com/sun/star/frame/XFramesSupplier.hpp>
37#include <com/sun/star/frame/XFrames.hpp>
38#include <com/sun/star/lang/XServiceInfo.hpp>
39#include <com/sun/star/frame/XDispatchProvider.hpp>
40#include <com/sun/star/frame/XTasksSupplier.hpp>
41#include <com/sun/star/container/XEnumerationAccess.hpp>
42#include <com/sun/star/frame/XDispatchResultListener.hpp>
43#include <com/sun/star/lang/XEventListener.hpp>
44#include <com/sun/star/lang/XComponent.hpp>
45#include <com/sun/star/task/XInteractionHandler.hpp>
46#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
47#include <com/sun/star/uno/XComponentContext.hpp>
48
53#include <rtl/ref.hxx>
55
56namespace framework{
57
59{
64};
65
66/*-************************************************************************************************************
67 @short implement the topframe of frame tree
68 @descr This is the root of the frame tree. The desktop has no window, is not visible but he is the logical
69 "masternode" to build the hierarchy.
70
71 @implements XInterface
72 XTypeProvider
73 XServiceInfo
74 XDesktop
75 XComponentLoader
76 XTasksSupplier
77 XDispatchProvider
78 XFramesSupplier
79 XFrame
80 XComponent
81 XPropertySet
82 XFastPropertySet
83 XMultiPropertySet
84 XDispatchResultListener
85 XEventListener
86 XInteractionHandler
87
88 @devstatus ready to use
89 @threadsafe yes
90*//*-*************************************************************************************************************/
91typedef cppu::WeakComponentImplHelper<
92 css::lang::XServiceInfo ,
93 css::frame::XDesktop2 ,
94 css::frame::XTasksSupplier ,
95 css::frame::XDispatchResultListener , // => XEventListener
96 css::task::XInteractionHandler ,
97 css::frame::XUntitledNumbers > Desktop_BASE;
98
100 public Desktop_BASE,
102{
103 // internal used types, const etcpp.
104 private:
105
107 typedef ::std::vector< css::uno::Reference< css::frame::XTerminateListener > > TTerminateListenerList;
108
109 // public methods
110 public:
111
112 // constructor / destructor
113 Desktop( css::uno::Reference< css::uno::XComponentContext > xContext );
114 virtual ~Desktop( ) override;
115
116 void constructorInit();
117
118 // XServiceInfo
119 virtual OUString SAL_CALL getImplementationName() override;
120
121 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
122
123 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
124
125 // XInterface
126 virtual void SAL_CALL acquire() noexcept override
127 { OWeakObject::acquire(); }
128 virtual void SAL_CALL release() noexcept override
129 { OWeakObject::release(); }
130 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override;
131
132 // XTypeProvider
133 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
134
163 virtual sal_Bool SAL_CALL terminate() override;
164
184 virtual void SAL_CALL addTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) override;
185
204 virtual void SAL_CALL removeTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) override;
205
206 virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getComponents ( ) override;
207 virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getCurrentComponent ( ) override;
208 virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getCurrentFrame ( ) override;
209
210 // XComponentLoader
211 virtual css::uno::Reference< css::lang::XComponent > SAL_CALL loadComponentFromURL ( const OUString& sURL ,
212 const OUString& sTargetFrameName ,
213 sal_Int32 nSearchFlags ,
214 const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override;
215
216 // XTasksSupplier
217 virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getTasks ( ) override;
218 virtual css::uno::Reference< css::frame::XTask > SAL_CALL getActiveTask ( ) override;
219
220 // XDispatchProvider
221 virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL ,
222 const OUString& sTargetFrameName ,
223 sal_Int32 nSearchFlags ) override;
224 virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches ( const css::uno::Sequence< css::frame::DispatchDescriptor >& lQueries ) override;
225
226 // XDispatchProviderInterception
227 virtual void SAL_CALL registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) override;
228 virtual void SAL_CALL releaseDispatchProviderInterceptor ( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) override;
229
230 // XFramesSupplier
231 virtual css::uno::Reference< css::frame::XFrames > SAL_CALL getFrames ( ) override;
232 virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getActiveFrame ( ) override;
233 virtual void SAL_CALL setActiveFrame ( const css::uno::Reference< css::frame::XFrame >& xFrame ) override;
234
235 // XFrame
236 // Attention: findFrame() is implemented only! Other methods make no sense for our desktop!
237 virtual css::uno::Reference< css::frame::XFrame > SAL_CALL findFrame ( const OUString& sTargetFrameName ,
238 sal_Int32 nSearchFlags ) override;
239 virtual void SAL_CALL initialize ( const css::uno::Reference< css::awt::XWindow >& xWindow ) override;
240 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getContainerWindow ( ) override;
241 virtual void SAL_CALL setCreator ( const css::uno::Reference< css::frame::XFramesSupplier >& xCreator ) override;
242 virtual css::uno::Reference< css::frame::XFramesSupplier > SAL_CALL getCreator ( ) override;
243 virtual OUString SAL_CALL getName ( ) override;
244 virtual void SAL_CALL setName ( const OUString& sName ) override;
245 virtual sal_Bool SAL_CALL isTop ( ) override;
246 virtual void SAL_CALL activate ( ) override;
247 virtual void SAL_CALL deactivate ( ) override;
248 virtual sal_Bool SAL_CALL isActive ( ) override;
249 virtual sal_Bool SAL_CALL setComponent ( const css::uno::Reference< css::awt::XWindow >& xComponentWindow ,
250 const css::uno::Reference< css::frame::XController >& xController ) override;
251 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getComponentWindow ( ) override;
252 virtual css::uno::Reference< css::frame::XController > SAL_CALL getController ( ) override;
253 virtual void SAL_CALL contextChanged ( ) override;
254 virtual void SAL_CALL addFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) override;
255 virtual void SAL_CALL removeFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) override;
256
257 // XComponent
258 virtual void SAL_CALL disposing() override;
259 virtual void SAL_CALL addEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
260 virtual void SAL_CALL removeEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
261
262 // XDispatchResultListener
263 virtual void SAL_CALL dispatchFinished ( const css::frame::DispatchResultEvent& aEvent ) override;
264
265 // XEventListener
266 virtual void SAL_CALL disposing ( const css::lang::EventObject& aSource ) override;
267
268 // XInteractionHandler
269 virtual void SAL_CALL handle ( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) override;
270
271 // css.frame.XUntitledNumbers
272 virtual ::sal_Int32 SAL_CALL leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent ) override;
273
274 // css.frame.XUntitledNumbers
275 virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) override;
276
277 // css.frame.XUntitledNumbers
278 virtual void SAL_CALL releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent ) override;
279
280 // css.frame.XUntitledNumbers
281 virtual OUString SAL_CALL getUntitledPrefix() override;
282
283 // we need this wrapped terminate()-call to terminate even the QuickStarter
284 // non-virtual and non-UNO for now
286 bool terminateQuickstarterToo();
287
288 void shutdown();
289
290 private:
291 // OPropertySetHelper
292 virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue ,
293 css::uno::Any& aOldValue ,
294 sal_Int32 nHandle ,
295 const css::uno::Any& aValue ) override;
296 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
297 const css::uno::Any& aValue ) override;
299 virtual void SAL_CALL getFastPropertyValue ( css::uno::Any& aValue ,
300 sal_Int32 nHandle ) const override;
301 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper ( ) override;
302 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo ( ) override;
303
304 css::uno::Reference< css::lang::XComponent > impl_getFrameComponent ( const css::uno::Reference< css::frame::XFrame >& xFrame ) const;
305
321 bool impl_sendQueryTerminationEvent(TTerminateListenerList& lCalledListener);
322
336 void impl_sendCancelTerminationEvent(const TTerminateListenerList& lCalledListener);
337
345 void impl_sendTerminateToClipboard();
346
353 void impl_sendNotifyTerminationEvent();
354
370 bool impl_closeFrames(bool bAllowUI);
371
372 private:
373
375
379
384
395
396 css::uno::Reference< css::uno::XComponentContext > m_xContext;
399 css::uno::Reference< css::frame::XFrames > m_xFramesHelper;
400 css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchHelper;
403 std::unique_ptr<SvtCommandOptions> m_xCommandOptions;
404 OUString m_sName;
405 OUString m_sTitle;
406 css::uno::Reference< css::frame::XDispatchRecorderSupplier > m_xDispatchRecorderSupplier;
407
411 css::uno::Reference< css::frame::XTerminateListener > m_xPipeTerminator;
412
418 css::uno::Reference< css::frame::XTerminateListener > m_xQuickLauncher;
419
427 css::uno::Reference< css::frame::XTerminateListener > m_xSWThreadManager;
428
442 css::uno::Reference< css::frame::XTerminateListener > m_xSfxTerminator;
443
444 css::uno::Reference< css::frame::XUntitledNumbers > m_xTitleNumberGenerator;
445
446 std::vector<css::uno::Reference<css::frame::XTerminateListener>> m_xComponentDllListeners;
447
448}; // class Desktop
449
451 css::uno::Reference<css::uno::XComponentContext> const & context);
452
453} // namespace framework
454
455/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) SAL_OVERRIDE
virtual void SAL_CALL acquire() noexcept override
Definition: desktop.hxx:126
comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer
array of child tasks (children of desktop are tasks; and tasks are also frames - But pure frames are ...
Definition: desktop.hxx:398
bool m_bSession
when true, the call came from session manager the method is Desktop::terminateQuickstarterToo() this ...
Definition: desktop.hxx:394
OUString m_sName
ref counted class to support disabling commands defined by configuration file
Definition: desktop.hxx:404
FrameContainer m_aChildTaskContainer
reference to factory, which has create this instance
Definition: desktop.hxx:397
ELoadState m_eLoadState
helper to dispatch something for new tasks, created by "_blank"!
Definition: desktop.hxx:401
css::uno::Reference< css::frame::XTerminateListener > m_xSWThreadManager
special terminate listener which loads images asynchronous for current open documents.
Definition: desktop.hxx:427
bool m_bIsShutdown
check flag to protect us against dispose before terminate! see dispose() for further information!
Definition: desktop.hxx:383
std::vector< css::uno::Reference< css::frame::XTerminateListener > > m_xComponentDllListeners
Definition: desktop.hxx:446
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: desktop.hxx:396
bool m_bSuspendQuickstartVeto
hold information about state of asynchron loading of component for loadComponentFromURL()!
Definition: desktop.hxx:402
css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchHelper
helper for XFrames, XIndexAccess, XElementAccess and implementation of a childcontainer!
Definition: desktop.hxx:400
bool m_bIsTerminated
check flag to protect against multiple terminate runs
Definition: desktop.hxx:378
virtual void SAL_CALL release() noexcept override
Definition: desktop.hxx:128
css::uno::Reference< css::frame::XTerminateListener > m_xSfxTerminator
special terminate listener shutting down the SfxApplication.
Definition: desktop.hxx:442
css::uno::Reference< css::frame::XTerminateListener > m_xPipeTerminator
special terminate listener to close pipe and block external requests during/after termination process...
Definition: desktop.hxx:411
css::uno::Reference< css::frame::XTerminateListener > m_xQuickLauncher
special terminate listener shown inside system tray (quick starter) Will hinder the office on shutdow...
Definition: desktop.hxx:418
css::uno::Reference< css::frame::XFrames > m_xFramesHelper
container for ALL Listener
Definition: desktop.hxx:399
css::uno::Reference< css::frame::XDispatchRecorderSupplier > m_xDispatchRecorderSupplier
Definition: desktop.hxx:406
::std::vector< css::uno::Reference< css::frame::XTerminateListener > > TTerminateListenerList
used temporary to know which listener was already called or not.
Definition: desktop.hxx:107
css::uno::Reference< css::frame::XUntitledNumbers > m_xTitleNumberGenerator
Definition: desktop.hxx:444
OUString m_sTitle
Definition: desktop.hxx:405
TransactionManager m_aTransactionManager
Definition: desktop.hxx:374
std::unique_ptr< SvtCommandOptions > m_xCommandOptions
don't ask quickstart for a veto
Definition: desktop.hxx:403
#define FWK_DLLPUBLIC
Definition: fwkdllapi.h:19
bool isActive()
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
@ E_NOTSET
Definition: desktop.hxx:60
@ E_SUCCESSFUL
Definition: desktop.hxx:61
@ E_INTERACTION
Definition: desktop.hxx:63
@ E_FAILED
Definition: desktop.hxx:62
FWK_DLLPUBLIC const rtl::Reference< Desktop > & getDesktop(css::uno::Reference< css::uno::XComponentContext > const &context)
Definition: desktop.cxx:1759
cppu::WeakComponentImplHelper< css::lang::XServiceInfo, css::frame::XDesktop2, css::frame::XTasksSupplier, css::frame::XDispatchResultListener, css::task::XInteractionHandler, css::frame::XUntitledNumbers > Desktop_BASE
Definition: desktop.hxx:97
unsigned char sal_Bool