xref: /trunk/main/framework/source/services/desktop.cxx (revision 531ea755b68a06923ca5d8afa1216255df2c3fff)
16d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
36d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
46d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
56d739b60SAndrew Rist  * distributed with this work for additional information
66d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
76d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
86d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
96d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
116d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
136d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
146d739b60SAndrew Rist  * software distributed under the License is distributed on an
156d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
176d739b60SAndrew Rist  * specific language governing permissions and limitations
186d739b60SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
206d739b60SAndrew Rist  *************************************************************/
216d739b60SAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_framework.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir //_________________________________________________________________________________________________________________
26cdf0e10cSrcweir //  my own includes
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir #include <loadenv/loadenv.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #ifndef __FRAMEWORK_LOADENV_TARGETHELPER_HXX_
31cdf0e10cSrcweir #include <loadenv/targethelper.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #ifndef __FRAMEWORK_DESKTOP_HXX_
35cdf0e10cSrcweir #include <services/desktop.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <helper/ocomponentaccess.hxx>
38cdf0e10cSrcweir #include <dispatch/dispatchprovider.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #ifndef __FRAMEWORK_DISPATCH_INTERCEPTIONHELPER_HXX_
41cdf0e10cSrcweir #include <dispatch/interceptionhelper.hxx>
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir #include <classes/taskcreator.hxx>
44cdf0e10cSrcweir #include <threadhelp/transactionguard.hxx>
45cdf0e10cSrcweir #include <threadhelp/writeguard.hxx>
46cdf0e10cSrcweir #include <threadhelp/readguard.hxx>
47cdf0e10cSrcweir #include <services.h>
48cdf0e10cSrcweir #include <general.h>
49cdf0e10cSrcweir #include <properties.h>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <classes/resource.hrc>
52cdf0e10cSrcweir #include <classes/fwkresid.hxx>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //_________________________________________________________________________________________________________________
55cdf0e10cSrcweir //  interface includes
56cdf0e10cSrcweir //_________________________________________________________________________________________________________________
57cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
58cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
59cdf0e10cSrcweir #include <com/sun/star/awt/XToolkit.hpp>
60cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
61cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
62cdf0e10cSrcweir #include <com/sun/star/awt/WindowDescriptor.hpp>
63cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp>
64cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
65cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
66cdf0e10cSrcweir #include <com/sun/star/task/XInteractionAbort.hpp>
67cdf0e10cSrcweir #include <com/sun/star/task/XInteractionApprove.hpp>
68cdf0e10cSrcweir #include <com/sun/star/document/XInteractionFilterSelect.hpp>
69cdf0e10cSrcweir #include <com/sun/star/document/AmbigousFilterRequest.hpp>
70cdf0e10cSrcweir #include <com/sun/star/task/ErrorCodeRequest.hpp>
71cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveIOException.hpp>
72cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
73cdf0e10cSrcweir #include <com/sun/star/frame/XNotifyingDispatch.hpp>
74cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultState.hpp>
75cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
76cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
77cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
78cdf0e10cSrcweir #include <com/sun/star/document/MacroExecMode.hpp>
79cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp>
80cdf0e10cSrcweir #include <com/sun/star/frame/XTerminateListener2.hpp>
81cdf0e10cSrcweir 
82cdf0e10cSrcweir //_________________________________________________________________________________________________________________
83cdf0e10cSrcweir //  includes of other projects
84cdf0e10cSrcweir //_________________________________________________________________________________________________________________
85cdf0e10cSrcweir #include <cppuhelper/queryinterface.hxx>
86cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
87cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
88cdf0e10cSrcweir #include <cppuhelper/proptypehlp.hxx>
89cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
90cdf0e10cSrcweir #include <rtl/logfile.hxx>
91cdf0e10cSrcweir #include <vcl/svapp.hxx>
92cdf0e10cSrcweir 
93cdf0e10cSrcweir #ifndef __RSC
94cdf0e10cSrcweir #include <tools/errinf.hxx>
95cdf0e10cSrcweir #endif
96cdf0e10cSrcweir #include <comphelper/extract.hxx>
97cdf0e10cSrcweir 
98cdf0e10cSrcweir #include <fwkdllapi.h>
99cdf0e10cSrcweir 
100cdf0e10cSrcweir //_________________________________________________________________________________________________________________
101cdf0e10cSrcweir //  namespace
102cdf0e10cSrcweir //_________________________________________________________________________________________________________________
103cdf0e10cSrcweir 
104cdf0e10cSrcweir namespace framework{
105cdf0e10cSrcweir 
106cdf0e10cSrcweir //_________________________________________________________________________________________________________________
107cdf0e10cSrcweir //  non exported const
108cdf0e10cSrcweir //_________________________________________________________________________________________________________________
109cdf0e10cSrcweir 
110cdf0e10cSrcweir //_________________________________________________________________________________________________________________
111cdf0e10cSrcweir //  non exported definitions
112cdf0e10cSrcweir //_________________________________________________________________________________________________________________
113cdf0e10cSrcweir 
114cdf0e10cSrcweir //_________________________________________________________________________________________________________________
115cdf0e10cSrcweir //  declarations
116cdf0e10cSrcweir //_________________________________________________________________________________________________________________
117cdf0e10cSrcweir 
118cdf0e10cSrcweir //*****************************************************************************************************************
119cdf0e10cSrcweir //  XInterface, XTypeProvider, XServiceInfo
120cdf0e10cSrcweir //*****************************************************************************************************************
DEFINE_XINTERFACE_15(Desktop,OWeakObject,DIRECT_INTERFACE (css::lang::XTypeProvider),DIRECT_INTERFACE (css::lang::XServiceInfo),DIRECT_INTERFACE (css::frame::XDesktop),DIRECT_INTERFACE (css::frame::XComponentLoader),DIRECT_INTERFACE (css::frame::XTasksSupplier),DIRECT_INTERFACE (css::frame::XDispatchProvider),DIRECT_INTERFACE (css::frame::XDispatchProviderInterception),DIRECT_INTERFACE (css::frame::XFramesSupplier),DIRECT_INTERFACE (css::frame::XFrame),DIRECT_INTERFACE (css::lang::XComponent),DIRECT_INTERFACE (css::frame::XDispatchResultListener),DIRECT_INTERFACE (css::lang::XEventListener),DIRECT_INTERFACE (css::task::XInteractionHandler),DIRECT_INTERFACE (css::beans::XPropertySet),DIRECT_INTERFACE (css::frame::XUntitledNumbers))121cdf0e10cSrcweir DEFINE_XINTERFACE_15                    (   Desktop                                                  ,
122cdf0e10cSrcweir                                             OWeakObject                                              ,
123cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XTypeProvider              ),
124cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XServiceInfo               ),
125cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XDesktop                  ),
126cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XComponentLoader          ),
127cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XTasksSupplier            ),
128cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XDispatchProvider         ),
129cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XDispatchProviderInterception),
130cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XFramesSupplier           ),
131cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XFrame                    ),
132cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XComponent                 ),
133cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XDispatchResultListener   ),
134cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XEventListener             ),
135cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::task::XInteractionHandler        ),
136cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::beans::XPropertySet              ),
137cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XUntitledNumbers          )
138cdf0e10cSrcweir                                         )
139cdf0e10cSrcweir 
140cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_15                 (   Desktop                                                 ,
141cdf0e10cSrcweir                                             css::lang::XTypeProvider                                ,
142cdf0e10cSrcweir                                             css::lang::XServiceInfo                                 ,
143cdf0e10cSrcweir                                             css::frame::XDesktop                                    ,
144cdf0e10cSrcweir                                             css::frame::XComponentLoader                            ,
145cdf0e10cSrcweir                                             css::frame::XTasksSupplier                              ,
146cdf0e10cSrcweir                                             css::frame::XDispatchProvider                           ,
147cdf0e10cSrcweir                                             css::frame::XDispatchProviderInterception               ,
148cdf0e10cSrcweir                                             css::frame::XFramesSupplier                             ,
149cdf0e10cSrcweir                                             css::frame::XFrame                                      ,
150cdf0e10cSrcweir                                             css::lang::XComponent                                   ,
151cdf0e10cSrcweir                                             css::frame::XDispatchResultListener                     ,
152cdf0e10cSrcweir                                             css::lang::XEventListener                               ,
153cdf0e10cSrcweir                                             css::task::XInteractionHandler                          ,
154cdf0e10cSrcweir                                             css::beans::XPropertySet                                ,
155cdf0e10cSrcweir                                             css::frame::XUntitledNumbers
156cdf0e10cSrcweir                                         )
157cdf0e10cSrcweir 
158cdf0e10cSrcweir DEFINE_XSERVICEINFO_ONEINSTANCESERVICE  (   Desktop                                                 ,
159cdf0e10cSrcweir                                             ::cppu::OWeakObject                                     ,
160cdf0e10cSrcweir                                             SERVICENAME_DESKTOP                                     ,
161cdf0e10cSrcweir                                             IMPLEMENTATIONNAME_DESKTOP
162cdf0e10cSrcweir                                         )
163cdf0e10cSrcweir 
164cdf0e10cSrcweir DEFINE_INIT_SERVICE                     (   Desktop,
165cdf0e10cSrcweir                                             {
166cdf0e10cSrcweir                                                 /*Attention
167cdf0e10cSrcweir                                                     I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
168cdf0e10cSrcweir                                                     to create a new instance of this class by our own supported service factory.
16953c84c60Smseidel                                                     see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further information!
170cdf0e10cSrcweir                                                 */
171cdf0e10cSrcweir 
172cdf0e10cSrcweir                                                 //-------------------------------------------------------------------------------------------------------------
173cdf0e10cSrcweir                                                 // Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess.
174cdf0e10cSrcweir                                                 // We hold member as reference ... not as pointer too!
175cdf0e10cSrcweir                                                 // Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that.
176cdf0e10cSrcweir                                                 // But look on dispose() for right order of deinitialization.
177cdf0e10cSrcweir                                                 OFrames* pFramesHelper = new OFrames( m_xFactory, this, &m_aChildTaskContainer );
178cdf0e10cSrcweir                                                 m_xFramesHelper = css::uno::Reference< css::frame::XFrames >( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir                                                 //-------------------------------------------------------------------------------------------------------------
181cdf0e10cSrcweir                                                 // Initialize a new dispatchhelper-object to handle dispatches.
182cdf0e10cSrcweir                                                 // We use these helper as slave for our interceptor helper ... not directly!
183cdf0e10cSrcweir                                                 // But he is event listener on THIS instance!
184cdf0e10cSrcweir                                                 DispatchProvider* pDispatchHelper = new DispatchProvider( m_xFactory, this );
185cdf0e10cSrcweir                                                 css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir                                                 //-------------------------------------------------------------------------------------------------------------
188cdf0e10cSrcweir                                                 // Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism.
189cdf0e10cSrcweir                                                 // Set created dispatch provider as slowest slave of it.
190cdf0e10cSrcweir                                                 // Hold interception helper by reference only - not by pointer!
19153c84c60Smseidel                                                 // So it's easier to destroy it.
192cdf0e10cSrcweir                                                 InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider );
193cdf0e10cSrcweir                                                 m_xDispatchHelper = css::uno::Reference< css::frame::XDispatchProvider >( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY );
194cdf0e10cSrcweir 
195cdf0e10cSrcweir                                                 ::rtl::OUStringBuffer sUntitledPrefix (256);
196cdf0e10cSrcweir                                                 sUntitledPrefix.append      (::rtl::OUString( String( FwkResId( STR_UNTITLED_DOCUMENT ))));
197cdf0e10cSrcweir                                                 sUntitledPrefix.appendAscii (" ");
198cdf0e10cSrcweir 
199cdf0e10cSrcweir                                                 ::comphelper::NumberedCollection* pNumbers = new ::comphelper::NumberedCollection ();
200cdf0e10cSrcweir                                                 m_xTitleNumberGenerator = css::uno::Reference< css::frame::XUntitledNumbers >(static_cast< ::cppu::OWeakObject* >(pNumbers), css::uno::UNO_QUERY_THROW);
201cdf0e10cSrcweir                                                 pNumbers->setOwner          ( static_cast< ::cppu::OWeakObject* >(this) );
202cdf0e10cSrcweir                                                 pNumbers->setUntitledPrefix ( sUntitledPrefix.makeStringAndClear ()     );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir                                                 // Safe impossible cases
205cdf0e10cSrcweir                                                 // We can't work without this helper!
2068f79cfd8Smseidel                                                 LOG_ASSERT2( m_xFramesHelper.is  ()==sal_False, "Desktop::Desktop()", "Frames helper is not valid. XFrames, XIndexAccess and XElementAccess are not supported!\n")
207cdf0e10cSrcweir                                                 LOG_ASSERT2( m_xDispatchHelper.is()==sal_False, "Desktop::Desktop()", "Dispatch helper is not valid. XDispatch will not work correctly!\n"                      )
208cdf0e10cSrcweir 
209cdf0e10cSrcweir                                                 // Enable object for real working!
210cdf0e10cSrcweir                                                 // Otherwise all calls will be rejected ...
211cdf0e10cSrcweir                                                 m_aTransactionManager.setWorkingMode( E_WORK );
212cdf0e10cSrcweir                                             }
213cdf0e10cSrcweir                                         )
214cdf0e10cSrcweir 
215cdf0e10cSrcweir /*-************************************************************************************************************//**
216cdf0e10cSrcweir     @short      standard constructor to create instance by factory
217cdf0e10cSrcweir     @descr      This constructor initialize a new instance of this class by valid factory,
218cdf0e10cSrcweir                 and will be set valid values on his member and baseclasses.
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     @attention  a)  Don't use your own reference during an UNO-Service-ctor! There is no guarantee, that you
221cdf0e10cSrcweir                     will get over this. (e.g. using of your reference as parameter to initialize some member)
22207a3d7f1SPedro Giffuni                     Do such things in DEFINE_INIT_SERVICE() method, which is called automatically after your ctor!!!
223cdf0e10cSrcweir                 b)  Baseclass OBroadcastHelper is a typedef in namespace cppu!
22453c84c60Smseidel                     The Microsoft compiler has some problems to handle it right BY using namespace explicitly ::cppu::OBroadcastHelper.
225cda0808aSmseidel                     If we write it without a namespace or expand the typedef to OBroadcastHelperVar<...> -> it will be OK!?
226cdf0e10cSrcweir                     I don't know why! (other compiler not tested .. but it works!)
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     @seealso    method DEFINE_INIT_SERVICE()
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     @param      "xFactory" is the multi service manager, which create this instance.
231cdf0e10cSrcweir                 The value must be different from NULL!
232cdf0e10cSrcweir     @return     -
233cdf0e10cSrcweir 
234*531ea755SJohn Bampton     @onerror    We throw an ASSERT in debug version or do nothing in release version.
235cdf0e10cSrcweir *//*-*************************************************************************************************************/
236cdf0e10cSrcweir Desktop::Desktop( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
237cdf0e10cSrcweir         //  Init baseclasses first
238cdf0e10cSrcweir         //  Attention: Don't change order of initialization!
239cdf0e10cSrcweir         //      ThreadHelpBase is a struct with a lock as member. We can't use a lock as direct member!
240cdf0e10cSrcweir         //      We must garant right initialization and a valid value of this to initialize other baseclasses!
241cdf0e10cSrcweir         :   ThreadHelpBase          ( &Application::GetSolarMutex()                 )
242cdf0e10cSrcweir         ,   TransactionBase         (                                               )
243cdf0e10cSrcweir         ,   ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >           ( m_aLock.getShareableOslMutex()         )
244cdf0e10cSrcweir         ,   ::cppu::OPropertySetHelper  ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
245cdf0e10cSrcweir         ,   ::cppu::OWeakObject     (                                               )
246cdf0e10cSrcweir         // Init member
247cdf0e10cSrcweir         #ifdef ENABLE_ASSERTIONS
248cdf0e10cSrcweir         ,   m_bIsTerminated         ( sal_False                                     )   // see dispose() for further informations!
249cdf0e10cSrcweir         #endif
250cdf0e10cSrcweir         ,   m_xFactory              ( xFactory                                      )
251cdf0e10cSrcweir         ,   m_aChildTaskContainer   (                                               )
252cdf0e10cSrcweir         ,   m_aListenerContainer    ( m_aLock.getShareableOslMutex()                )
253cdf0e10cSrcweir         ,   m_xFramesHelper         (                                               )
254cdf0e10cSrcweir         ,   m_xDispatchHelper       (                                               )
255cdf0e10cSrcweir         ,   m_eLoadState            ( E_NOTSET                                      )
256cdf0e10cSrcweir         ,   m_xLastFrame            (                                               )
257cdf0e10cSrcweir         ,   m_aInteractionRequest   (                                               )
258cdf0e10cSrcweir         ,   m_bSuspendQuickstartVeto( sal_False                                     )
259cdf0e10cSrcweir         ,   m_aCommandOptions       (                                               )
260cdf0e10cSrcweir         ,   m_sName                 (                                               )
261cdf0e10cSrcweir         ,   m_sTitle                (                                               )
262cdf0e10cSrcweir         ,   m_xDispatchRecorderSupplier(                                            )
263cdf0e10cSrcweir         ,   m_xPipeTerminator       (                                               )
264cdf0e10cSrcweir         ,   m_xQuickLauncher        (                                               )
265cdf0e10cSrcweir         ,   m_xSWThreadManager      (                                               )
266cdf0e10cSrcweir         ,   m_xSfxTerminator        (                                               )
267cdf0e10cSrcweir         ,   m_xTitleNumberGenerator (                                               )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     // Safe impossible cases
270cdf0e10cSrcweir     // We don't accept all incoming parameter.
271cdf0e10cSrcweir     LOG_ASSERT2( implcp_ctor( xFactory ), "Desktop::Desktop()", "Invalid parameter detected!")
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir /*-************************************************************************************************************//**
275cdf0e10cSrcweir     @short      standard destructor
27653c84c60Smseidel     @descr      This one do NOTHING! Use dispose() instead of this.
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     @seealso    method dispose()
279cdf0e10cSrcweir 
280cdf0e10cSrcweir     @param      -
281cdf0e10cSrcweir     @return     -
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     @onerror    -
284cdf0e10cSrcweir *//*-*************************************************************************************************************/
~Desktop()285cdf0e10cSrcweir Desktop::~Desktop()
286cdf0e10cSrcweir {
287cdf0e10cSrcweir     LOG_ASSERT2( m_bIsTerminated                       ==sal_False, "Desktop::~Desktop()", "Who forgot to terminate the desktop service?" )
288cdf0e10cSrcweir     LOG_ASSERT2( m_aTransactionManager.getWorkingMode()!=E_CLOSE  , "Desktop::~Desktop()", "Who forgot to dispose this service?"          )
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir //=============================================================================
terminate()292cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::terminate()
293cdf0e10cSrcweir     throw( css::uno::RuntimeException )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     SYNCHRONIZED_START
298cdf0e10cSrcweir         ReadGuard aReadLock( m_aLock );
299cdf0e10cSrcweir 
300cdf0e10cSrcweir         css::uno::Reference< css::frame::XTerminateListener > xPipeTerminator    = m_xPipeTerminator;
301cdf0e10cSrcweir         css::uno::Reference< css::frame::XTerminateListener > xQuickLauncher     = m_xQuickLauncher;
302cdf0e10cSrcweir         css::uno::Reference< css::frame::XTerminateListener > xSWThreadManager   = m_xSWThreadManager;
303cdf0e10cSrcweir         css::uno::Reference< css::frame::XTerminateListener > xSfxTerminator     = m_xSfxTerminator;
304cdf0e10cSrcweir 
305cdf0e10cSrcweir         css::lang::EventObject                                aEvent             ( static_cast< ::cppu::OWeakObject* >(this) );
306cdf0e10cSrcweir         ::sal_Bool                                            bAskQuickStart     = !m_bSuspendQuickstartVeto                  ;
307cdf0e10cSrcweir 
308cdf0e10cSrcweir         aReadLock.unlock();
309cdf0e10cSrcweir     SYNCHRONIZED_END
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
312cdf0e10cSrcweir     // Ask normal terminate listener. They could stop terminate without closing any open document.
313cdf0e10cSrcweir     Desktop::TTerminateListenerList lCalledTerminationListener;
314cdf0e10cSrcweir     ::sal_Bool                      bVeto = sal_False;
315cdf0e10cSrcweir     impl_sendQueryTerminationEvent(lCalledTerminationListener, bVeto);
316cdf0e10cSrcweir     if ( bVeto )
317cdf0e10cSrcweir     {
318cdf0e10cSrcweir         impl_sendCancelTerminationEvent(lCalledTerminationListener);
319cdf0e10cSrcweir         return sal_False;
320cdf0e10cSrcweir     }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
323cdf0e10cSrcweir     // try to close all open frames.
324cdf0e10cSrcweir     // Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past.
325cdf0e10cSrcweir     ::sal_Bool bAllowUI      = sal_True;
326cdf0e10cSrcweir     ::sal_Bool bFramesClosed = impl_closeFrames(bAllowUI);
327cdf0e10cSrcweir     if ( ! bFramesClosed )
328cdf0e10cSrcweir     {
329cdf0e10cSrcweir         impl_sendCancelTerminationEvent(lCalledTerminationListener);
330cdf0e10cSrcweir         return sal_False;
331cdf0e10cSrcweir     }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
334cdf0e10cSrcweir     // Normal listener had no problem ...
335cdf0e10cSrcweir     // all frames was closed ...
336cdf0e10cSrcweir     // now it's time to ask our specialized listener.
337cdf0e10cSrcweir     // They are handled these way because they wish to hinder the office on termination
338cdf0e10cSrcweir     // but they wish also closing of all frames.
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     // Note further:
341cdf0e10cSrcweir     //    We shouldn't ask quicklauncher in case it was allowed from outside only.
342cdf0e10cSrcweir     //    This is special trick to "ignore existing quick starter" for debug purposes.
343cdf0e10cSrcweir 
344cdf0e10cSrcweir     // Attention:
345cdf0e10cSrcweir     // Order of alled listener is important !
346cdf0e10cSrcweir     // some of them are harmless .-)
347cdf0e10cSrcweir     // But some of them can be dangerous. E.g. it would be dangerous if we close our pipe
34853c84c60Smseidel     // and don't terminate in real because another listener throws a veto exception .-)
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     ::sal_Bool bTerminate = sal_False;
351cdf0e10cSrcweir     try
352cdf0e10cSrcweir     {
353cdf0e10cSrcweir         if(
354cdf0e10cSrcweir             ( bAskQuickStart      ) &&
355cdf0e10cSrcweir             ( xQuickLauncher.is() )
356cdf0e10cSrcweir           )
357cdf0e10cSrcweir         {
358cdf0e10cSrcweir             xQuickLauncher->queryTermination( aEvent );
359cdf0e10cSrcweir             lCalledTerminationListener.push_back( xQuickLauncher );
360cdf0e10cSrcweir         }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir         if ( xSWThreadManager.is() )
363cdf0e10cSrcweir         {
364cdf0e10cSrcweir             xSWThreadManager->queryTermination( aEvent );
365cdf0e10cSrcweir             lCalledTerminationListener.push_back( xSWThreadManager );
366cdf0e10cSrcweir         }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir         if ( xPipeTerminator.is() )
369cdf0e10cSrcweir         {
370cdf0e10cSrcweir             xPipeTerminator->queryTermination( aEvent );
371cdf0e10cSrcweir             lCalledTerminationListener.push_back( xPipeTerminator );
372cdf0e10cSrcweir         }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir         if ( xSfxTerminator.is() )
375cdf0e10cSrcweir         {
376cdf0e10cSrcweir             xSfxTerminator->queryTermination( aEvent );
377cdf0e10cSrcweir             lCalledTerminationListener.push_back( xSfxTerminator );
378cdf0e10cSrcweir         }
379cdf0e10cSrcweir 
380cdf0e10cSrcweir         bTerminate = sal_True;
381cdf0e10cSrcweir     }
382cdf0e10cSrcweir     catch(const css::frame::TerminationVetoException&)
383cdf0e10cSrcweir     {
384cdf0e10cSrcweir         bTerminate = sal_False;
385cdf0e10cSrcweir     }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     if ( ! bTerminate )
388cdf0e10cSrcweir         impl_sendCancelTerminationEvent(lCalledTerminationListener);
389cdf0e10cSrcweir     else
390cdf0e10cSrcweir     {
391cdf0e10cSrcweir         #ifdef ENABLE_ASSERTIONS
392cdf0e10cSrcweir             // "Protect" us against dispose before terminate calls!
39353c84c60Smseidel             // see dispose() for further information.
394cdf0e10cSrcweir             /* SAFE AREA --------------------------------------------------------------------------------------- */
395cdf0e10cSrcweir             WriteGuard aWriteLock( m_aLock );
396cdf0e10cSrcweir             m_bIsTerminated = sal_True;
397cdf0e10cSrcweir             aWriteLock.unlock();
398cdf0e10cSrcweir             /* UNSAFE AREA ------------------------------------------------------------------------------------- */
399cdf0e10cSrcweir         #endif
400cdf0e10cSrcweir 
401cdf0e10cSrcweir         impl_sendNotifyTerminationEvent();
402cdf0e10cSrcweir 
403cdf0e10cSrcweir         if(
404cdf0e10cSrcweir             ( bAskQuickStart      ) &&
405cdf0e10cSrcweir             ( xQuickLauncher.is() )
406cdf0e10cSrcweir           )
407cdf0e10cSrcweir         {
408cdf0e10cSrcweir             xQuickLauncher->notifyTermination( aEvent );
409cdf0e10cSrcweir         }
410cdf0e10cSrcweir 
411cdf0e10cSrcweir         if ( xSWThreadManager.is() )
412cdf0e10cSrcweir             xSWThreadManager->notifyTermination( aEvent );
413cdf0e10cSrcweir 
414cdf0e10cSrcweir         if ( xPipeTerminator.is() )
415cdf0e10cSrcweir             xPipeTerminator->notifyTermination( aEvent );
416cdf0e10cSrcweir 
41707a3d7f1SPedro Giffuni         // Must be really the last listener to be called.
418cdf0e10cSrcweir         // Because it shutdown the whole process asynchronous !
419cdf0e10cSrcweir         if ( xSfxTerminator.is() )
420cdf0e10cSrcweir             xSfxTerminator->notifyTermination( aEvent );
421cdf0e10cSrcweir     }
422cdf0e10cSrcweir 
423cdf0e10cSrcweir     return bTerminate;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 
427cdf0e10cSrcweir //=============================================================================
addTerminateListener(const css::uno::Reference<css::frame::XTerminateListener> & xListener)428cdf0e10cSrcweir void SAL_CALL Desktop::addTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener )
429cdf0e10cSrcweir     throw( css::uno::RuntimeException )
430cdf0e10cSrcweir {
431cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir     css::uno::Reference< css::lang::XServiceInfo > xInfo( xListener, css::uno::UNO_QUERY );
434cdf0e10cSrcweir     if ( xInfo.is() )
435cdf0e10cSrcweir     {
436cdf0e10cSrcweir         ::rtl::OUString sImplementationName = xInfo->getImplementationName();
437cdf0e10cSrcweir 
438cdf0e10cSrcweir         // SYCNHRONIZED ->
439cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
440cdf0e10cSrcweir 
441cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_SFXTERMINATOR) )
442cdf0e10cSrcweir         {
443cdf0e10cSrcweir             m_xSfxTerminator = xListener;
444cdf0e10cSrcweir             return;
445cdf0e10cSrcweir         }
446cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_PIPETERMINATOR) )
447cdf0e10cSrcweir         {
448cdf0e10cSrcweir             m_xPipeTerminator = xListener;
449cdf0e10cSrcweir             return;
450cdf0e10cSrcweir         }
451cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_QUICKLAUNCHER) )
452cdf0e10cSrcweir         {
453cdf0e10cSrcweir             m_xQuickLauncher = xListener;
454cdf0e10cSrcweir             return;
455cdf0e10cSrcweir         }
456cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_SWTHREADMANAGER) )
457cdf0e10cSrcweir         {
458cdf0e10cSrcweir             m_xSWThreadManager = xListener;
459cdf0e10cSrcweir             return;
460cdf0e10cSrcweir         }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir         aWriteLock.unlock();
463cdf0e10cSrcweir         // <- SYCNHRONIZED
464cdf0e10cSrcweir     }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir     // No lock required ... container is threadsafe by itself.
467cdf0e10cSrcweir     m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ), xListener );
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
470cdf0e10cSrcweir //=============================================================================
removeTerminateListener(const css::uno::Reference<css::frame::XTerminateListener> & xListener)471cdf0e10cSrcweir void SAL_CALL Desktop::removeTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener )
472cdf0e10cSrcweir     throw( css::uno::RuntimeException )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     css::uno::Reference< css::lang::XServiceInfo > xInfo( xListener, css::uno::UNO_QUERY );
477cdf0e10cSrcweir     if ( xInfo.is() )
478cdf0e10cSrcweir     {
479cdf0e10cSrcweir         ::rtl::OUString sImplementationName = xInfo->getImplementationName();
480cdf0e10cSrcweir 
481cdf0e10cSrcweir         // SYCNHRONIZED ->
482cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
483cdf0e10cSrcweir 
484cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_SFXTERMINATOR) )
485cdf0e10cSrcweir         {
486cdf0e10cSrcweir             m_xSfxTerminator.clear();
487cdf0e10cSrcweir             return;
488cdf0e10cSrcweir         }
489cdf0e10cSrcweir 
490cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_PIPETERMINATOR) )
491cdf0e10cSrcweir         {
492cdf0e10cSrcweir             m_xPipeTerminator.clear();
493cdf0e10cSrcweir             return;
494cdf0e10cSrcweir         }
495cdf0e10cSrcweir 
496cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_QUICKLAUNCHER) )
497cdf0e10cSrcweir         {
498cdf0e10cSrcweir             m_xQuickLauncher.clear();
499cdf0e10cSrcweir             return;
500cdf0e10cSrcweir         }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_SWTHREADMANAGER) )
503cdf0e10cSrcweir         {
504cdf0e10cSrcweir             m_xSWThreadManager.clear();
505cdf0e10cSrcweir             return;
506cdf0e10cSrcweir         }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir         aWriteLock.unlock();
509cdf0e10cSrcweir         // <- SYCNHRONIZED
510cdf0e10cSrcweir     }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir     // No lock required ... container is threadsafe by itself.
513cdf0e10cSrcweir     m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ), xListener );
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir /*-************************************************************************************************************//**
517cdf0e10cSrcweir     @interface  XDesktop
518cdf0e10cSrcweir     @short      get access to create enumerations of all current components
519cdf0e10cSrcweir     @descr      You will be the owner of the returned object and must delete it if you don't use it again.
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     @seealso    class TasksAccess
522cdf0e10cSrcweir     @seealso    class TasksEnumeration
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     @param      -
525cdf0e10cSrcweir     @return     A reference to an XEnumerationAccess-object.
526cdf0e10cSrcweir 
527cdf0e10cSrcweir     @onerror    We return a null-reference.
528cdf0e10cSrcweir     @threadsafe yes
529cdf0e10cSrcweir *//*-*************************************************************************************************************/
getComponents()530cdf0e10cSrcweir css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getComponents() throw( css::uno::RuntimeException )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
533cdf0e10cSrcweir     // Register transaction and reject wrong calls.
534cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     // We use a helper class OComponentAccess to have access on all child components.
537cdf0e10cSrcweir     // Create it on demand and return it as a reference.
538cdf0e10cSrcweir     OComponentAccess* pAccess = new OComponentAccess( this );
539cdf0e10cSrcweir     css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pAccess), css::uno::UNO_QUERY );
540cdf0e10cSrcweir     return xAccess;
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
543cdf0e10cSrcweir /*-************************************************************************************************************//**
544cdf0e10cSrcweir     @interface  XDesktop
545cdf0e10cSrcweir     @short      return the current active component
546cdf0e10cSrcweir     @descr      The most current component is the window, model or the controller of the current active frame.
547cdf0e10cSrcweir 
548cdf0e10cSrcweir     @seealso    method getCurrentFrame()
549cdf0e10cSrcweir     @seealso    method impl_getFrameComponent()
550cdf0e10cSrcweir 
551cdf0e10cSrcweir     @param      -
552cdf0e10cSrcweir     @return     A reference to the component.
553cdf0e10cSrcweir 
554cdf0e10cSrcweir     @onerror    We return a null-reference.
555cdf0e10cSrcweir     @threadsafe yes
556cdf0e10cSrcweir *//*-*************************************************************************************************************/
getCurrentComponent()557cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::getCurrentComponent() throw( css::uno::RuntimeException )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
560cdf0e10cSrcweir     // Register transaction and reject wrong calls.
561cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
562cdf0e10cSrcweir 
563cdf0e10cSrcweir     // Set return value if method failed.
564cdf0e10cSrcweir     css::uno::Reference< css::lang::XComponent > xComponent;
565cdf0e10cSrcweir 
566cdf0e10cSrcweir     // Get reference to current frame ...
567cdf0e10cSrcweir     // ... get component of this frame ... (It can be the window, the model or the controller.)
568cdf0e10cSrcweir     // ... and return the result.
569cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xCurrentFrame = getCurrentFrame();
570cdf0e10cSrcweir     if( xCurrentFrame.is() == sal_True )
571cdf0e10cSrcweir     {
572cdf0e10cSrcweir         xComponent = impl_getFrameComponent( xCurrentFrame );
573cdf0e10cSrcweir     }
574cdf0e10cSrcweir     return xComponent;
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir /*-************************************************************************************************************//**
578cdf0e10cSrcweir     @interface  XDesktop
579cdf0e10cSrcweir     @short      return the current active frame in hierarchy
58007a3d7f1SPedro Giffuni     @descr      There can be more then one different active paths in our frame hierarchy. But only one of them
581cdf0e10cSrcweir                 could be the most active frame (normal he has the focus).
582cdf0e10cSrcweir                 Don't mix it with getActiveFrame()! That will return our current active frame, which must be
583cdf0e10cSrcweir                 a direct child of us and should be a part(!) of an active path.
584cdf0e10cSrcweir 
585cdf0e10cSrcweir     @seealso    method getActiveFrame()
586cdf0e10cSrcweir 
587cdf0e10cSrcweir     @param      -
588cdf0e10cSrcweir     @return     A valid reference, if there is an active frame.
589cdf0e10cSrcweir                 A null reference , otherwise.
590cdf0e10cSrcweir 
591cdf0e10cSrcweir     @onerror    We return a null reference.
592cdf0e10cSrcweir     @threadsafe yes
593cdf0e10cSrcweir *//*-*************************************************************************************************************/
getCurrentFrame()594cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::getCurrentFrame() throw( css::uno::RuntimeException )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
597cdf0e10cSrcweir     // Register transaction and reject wrong calls.
598cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
599cdf0e10cSrcweir 
600b12a77c9Smseidel     // Start search with our direct active frame (if it exists!).
601cdf0e10cSrcweir     // Search on his children for other active frames too.
602cdf0e10cSrcweir     // Stop if no one could be found and return last of found ones.
603cdf0e10cSrcweir     css::uno::Reference< css::frame::XFramesSupplier > xLast = css::uno::Reference< css::frame::XFramesSupplier >( getActiveFrame(), css::uno::UNO_QUERY );
604cdf0e10cSrcweir     if( xLast.is() == sal_True )
605cdf0e10cSrcweir     {
606cdf0e10cSrcweir         css::uno::Reference< css::frame::XFramesSupplier > xNext = css::uno::Reference< css::frame::XFramesSupplier >( xLast->getActiveFrame(), css::uno::UNO_QUERY );
607cdf0e10cSrcweir         while( xNext.is() == sal_True )
608cdf0e10cSrcweir         {
609cdf0e10cSrcweir             xLast = xNext;
610cdf0e10cSrcweir             xNext = css::uno::Reference< css::frame::XFramesSupplier >( xNext->getActiveFrame(), css::uno::UNO_QUERY );
611cdf0e10cSrcweir         }
612cdf0e10cSrcweir     }
613cdf0e10cSrcweir     return css::uno::Reference< css::frame::XFrame >( xLast, css::uno::UNO_QUERY );
614cdf0e10cSrcweir }
615cdf0e10cSrcweir 
616cdf0e10cSrcweir /*-************************************************************************************************************//**
617cdf0e10cSrcweir     @interface  XComponentLoader
618cdf0e10cSrcweir     @short      try to load given URL into a task
61953c84c60Smseidel     @descr      You can give us some information about the content, which you will load into a frame.
620cdf0e10cSrcweir                 We search or create this target for you, make a type detection of given URL and try to load it.
621cdf0e10cSrcweir                 As result of this operation we return the new created component or nothing, if loading failed.
622cdf0e10cSrcweir 
623cdf0e10cSrcweir     @seealso    -
624cdf0e10cSrcweir 
62553c84c60Smseidel     @param      "sURL"              , URL, which represents the content
626cdf0e10cSrcweir     @param      "sTargetFrameName"  , name of target frame or special value like "_self", "_blank" ...
627cdf0e10cSrcweir     @param      "nSearchFlags"      , optional arguments for frame search, if target isn't a special one
628cdf0e10cSrcweir     @param      "lArguments"        , optional arguments for loading
629cdf0e10cSrcweir     @return     A valid component reference, if loading was successfully.
630cdf0e10cSrcweir                 A null reference otherwise.
631cdf0e10cSrcweir 
632cdf0e10cSrcweir     @onerror    We return a null reference.
633cdf0e10cSrcweir     @threadsafe yes
634cdf0e10cSrcweir *//*-*************************************************************************************************************/
loadComponentFromURL(const::rtl::OUString & sURL,const::rtl::OUString & sTargetFrameName,sal_Int32 nSearchFlags,const css::uno::Sequence<css::beans::PropertyValue> & lArguments)635cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::loadComponentFromURL( const ::rtl::OUString&                                 sURL            ,
636cdf0e10cSrcweir                                                                                      const ::rtl::OUString&                                 sTargetFrameName,
637cdf0e10cSrcweir                                                                                            sal_Int32                                        nSearchFlags    ,
638cdf0e10cSrcweir                                                                                      const css::uno::Sequence< css::beans::PropertyValue >& lArguments      ) throw(    css::io::IOException                ,
639cdf0e10cSrcweir                                                                                                                                                                         css::lang::IllegalArgumentException ,
640cdf0e10cSrcweir                                                                                                                                                                         css::uno::RuntimeException          )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
643cdf0e10cSrcweir     // Register transaction and reject wrong calls.
644cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
645cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::Desktop::loadComponentFromURL" );
646cdf0e10cSrcweir 
647cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
648cdf0e10cSrcweir     css::uno::Reference< css::frame::XComponentLoader > xThis(static_cast< css::frame::XComponentLoader* >(this), css::uno::UNO_QUERY);
649cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xFactory;
650cdf0e10cSrcweir     aReadLock.unlock();
651cdf0e10cSrcweir 
652cdf0e10cSrcweir     RTL_LOGFILE_PRODUCT_CONTEXT( aLog2, "PERFORMANCE - Desktop::loadComponentFromURL()" );
653cdf0e10cSrcweir     return LoadEnv::loadComponentFromURL(xThis, xSMGR, sURL, sTargetFrameName, nSearchFlags, lArguments);
654cdf0e10cSrcweir }
655cdf0e10cSrcweir 
656cdf0e10cSrcweir /*-************************************************************************************************************//**
657cdf0e10cSrcweir     @interface  XTasksSupplier
658b12a77c9Smseidel     @short      get access to create enumerations of our taskchilds
659cdf0e10cSrcweir     @descr      Direct childs of desktop are tasks every time.
660cdf0e10cSrcweir                 Call these method to could create enumerations of it.
661cdf0e10cSrcweir 
662cdf0e10cSrcweir But; Don't forget - you will be the owner of returned object and must release it!
663cdf0e10cSrcweir                 We use a helper class to implement the access interface. They hold a weakreference to us.
664cdf0e10cSrcweir                 It can be, that the desktop is dead - but not your tasksaccess-object! Then they will do nothing!
665cdf0e10cSrcweir                 You can't create enumerations then.
666cdf0e10cSrcweir 
6672e3a1b6eSmseidel     @attention  Normally we don't need any lock here. We don't work on internal member!
668cdf0e10cSrcweir 
669cdf0e10cSrcweir     @seealso    class TasksAccess
670cdf0e10cSrcweir 
671cdf0e10cSrcweir     @param      -
672b12a77c9Smseidel     @return     A reference to an accessobject, which can create enumerations of our childtasks.
673cdf0e10cSrcweir 
674cdf0e10cSrcweir     @onerror    A null reference is returned.
675cdf0e10cSrcweir     @threadsafe yes
676cdf0e10cSrcweir *//*-*************************************************************************************************************/
getTasks()677cdf0e10cSrcweir css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getTasks() throw( css::uno::RuntimeException )
678cdf0e10cSrcweir {
679cdf0e10cSrcweir     LOG_WARNING("Desktop::getTasks()", "Use of obsolete interface XTaskSupplier")
680cdf0e10cSrcweir     return NULL;
681cdf0e10cSrcweir     /*
682cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
683cdf0e10cSrcweir 
684cdf0e10cSrcweir     OTasksAccess* pTasksAccess = new OTasksAccess( this, &m_aChildTaskContainer );
685cdf0e10cSrcweir     css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pTasksAccess), css::uno::UNO_QUERY );
686cdf0e10cSrcweir     return xAccess;
687cdf0e10cSrcweir     */
688cdf0e10cSrcweir }
689cdf0e10cSrcweir 
690cdf0e10cSrcweir /*-************************************************************************************************************//**
691cdf0e10cSrcweir     @interface  XTasksSupplier
692b12a77c9Smseidel     @short      return current active task of our direct childs
693cdf0e10cSrcweir     @descr      Desktop childs are tasks only ! If we have an active path from desktop
694cdf0e10cSrcweir                 as top to any frame on bottom, we must have an active direct child. His reference is returned here.
695cdf0e10cSrcweir 
696b12a77c9Smseidel     @attention  a)  Do not confuse it with getCurrentFrame()! The current frame don't must one of our direct childs.
697cdf0e10cSrcweir                     It can be every frame in subtree and must have the focus (Is the last one of an active path!).
698cdf0e10cSrcweir                 b)  We don't need any lock here. Our container is threadsafe himself and live, if we live!
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     @seealso    method getCurrentFrame()
701cdf0e10cSrcweir 
702cdf0e10cSrcweir     @param      -
703b12a77c9Smseidel     @return     A reference to our current active taskchild.
704cdf0e10cSrcweir 
705cdf0e10cSrcweir     @onerror    A null reference is returned.
706cdf0e10cSrcweir     @threadsafe yes
707cdf0e10cSrcweir *//*-*************************************************************************************************************/
getActiveTask()708cdf0e10cSrcweir css::uno::Reference< css::frame::XTask > SAL_CALL Desktop::getActiveTask() throw( css::uno::RuntimeException )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir     /*
711cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
712cdf0e10cSrcweir 
713cdf0e10cSrcweir     return css::uno::Reference< css::frame::XTask >( m_aChildTaskContainer.getActive(), css::uno::UNO_QUERY );
714cdf0e10cSrcweir     */
715cdf0e10cSrcweir     LOG_WARNING("Desktop::getActiveTask()", "Use of obsolete interface XTaskSupplier")
716cdf0e10cSrcweir     return NULL;
717cdf0e10cSrcweir }
718cdf0e10cSrcweir 
719cdf0e10cSrcweir /*-************************************************************************************************************//**
720cdf0e10cSrcweir     @interface  XDispatchProvider
721cdf0e10cSrcweir     @short      search a dispatcher for given URL
722cdf0e10cSrcweir     @descr      We use a helper implementation (class DispatchProvider) to do so.
723cdf0e10cSrcweir                 So we don't must implement this algorithm twice!
724cdf0e10cSrcweir 
725cdf0e10cSrcweir     @attention  We don't need any lock here. Our helper is threadsafe himself and live, if we live!
726cdf0e10cSrcweir 
727cdf0e10cSrcweir     @seealso    class DispatchProvider
728cdf0e10cSrcweir 
729cdf0e10cSrcweir     @param      "aURL"              , URL to dispatch
730cdf0e10cSrcweir     @param      "sTargetFrameName"  , name of target frame, who should dispatch these URL
731cdf0e10cSrcweir     @param      "nSearchFlags"      , flags to regulate the search
732cdf0e10cSrcweir     @param      "lQueries"          , list of queryDispatch() calls!
733cdf0e10cSrcweir     @return     A reference or list of founded dispatch objects for these URL.
734cdf0e10cSrcweir 
735cdf0e10cSrcweir     @onerror    A null reference is returned.
736cdf0e10cSrcweir     @threadsafe yes
737cdf0e10cSrcweir *//*-*************************************************************************************************************/
queryDispatch(const css::util::URL & aURL,const::rtl::OUString & sTargetFrameName,sal_Int32 nSearchFlags)738cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatch > SAL_CALL Desktop::queryDispatch( const css::util::URL&  aURL             ,
739cdf0e10cSrcweir                                                                               const ::rtl::OUString& sTargetFrameName ,
740cdf0e10cSrcweir                                                                                     sal_Int32        nSearchFlags     ) throw( css::uno::RuntimeException )
741cdf0e10cSrcweir {
742cdf0e10cSrcweir     const char UNO_PROTOCOL[] = ".uno:";
743cdf0e10cSrcweir 
744cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
745cdf0e10cSrcweir     // Register transaction and reject wrong calls.
746cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
747cdf0e10cSrcweir 
748cdf0e10cSrcweir     // Remove uno and cmd protocol part as we want to support both of them. We store only the command part
749cdf0e10cSrcweir     // in our hash map. All other protocols are stored with the protocol part.
750cdf0e10cSrcweir     String aCommand( aURL.Main );
751cdf0e10cSrcweir     if ( aURL.Protocol.equalsIgnoreAsciiCaseAsciiL( UNO_PROTOCOL, sizeof( UNO_PROTOCOL )-1 ))
752cdf0e10cSrcweir         aCommand = aURL.Path;
753cdf0e10cSrcweir 
754cdf0e10cSrcweir     // Make hash_map lookup if the current URL is in the disabled list
755cdf0e10cSrcweir     if ( m_aCommandOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aCommand ) )
756cdf0e10cSrcweir         return css::uno::Reference< css::frame::XDispatch >();
757cdf0e10cSrcweir     else
758cdf0e10cSrcweir     {
759cdf0e10cSrcweir         // We use a helper to support these interface and an interceptor mechanism.
760cdf0e10cSrcweir         // Our helper is threadsafe by himself!
761cdf0e10cSrcweir         return m_xDispatchHelper->queryDispatch( aURL, sTargetFrameName, nSearchFlags );
762cdf0e10cSrcweir     }
763cdf0e10cSrcweir }
764cdf0e10cSrcweir 
765cdf0e10cSrcweir //*****************************************************************************************************************
queryDispatches(const css::uno::Sequence<css::frame::DispatchDescriptor> & lQueries)766cdf0e10cSrcweir css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Desktop::queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lQueries ) throw( css::uno::RuntimeException )
767cdf0e10cSrcweir {
768cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
769cdf0e10cSrcweir     // Register transaction and reject wrong calls.
770cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
771cdf0e10cSrcweir 
772cdf0e10cSrcweir     return m_xDispatchHelper->queryDispatches( lQueries );
773cdf0e10cSrcweir }
774cdf0e10cSrcweir 
775cdf0e10cSrcweir /*-************************************************************************************************************//**
776cdf0e10cSrcweir     @interface  XDipsatchProviderInterception
777cdf0e10cSrcweir     @short      supports registration/deregistration of interception objects, which
778cdf0e10cSrcweir                 are interested on special dispatches.
779cdf0e10cSrcweir 
78007a3d7f1SPedro Giffuni     @descr      Its really provided by an internal helper, which is used inside the dispatch api too.
781cdf0e10cSrcweir     @param      xInterceptor
782cdf0e10cSrcweir                 the interceptor object, which wish to be (de)registered.
783cdf0e10cSrcweir 
784cdf0e10cSrcweir     @threadsafe yes
785cdf0e10cSrcweir *//*-*************************************************************************************************************/
registerDispatchProviderInterceptor(const css::uno::Reference<css::frame::XDispatchProviderInterceptor> & xInterceptor)786cdf0e10cSrcweir void SAL_CALL Desktop::registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor)
787cdf0e10cSrcweir     throw( css::uno::RuntimeException)
788cdf0e10cSrcweir {
789cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
790cdf0e10cSrcweir 
791cdf0e10cSrcweir     css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper( m_xDispatchHelper, css::uno::UNO_QUERY );
792cdf0e10cSrcweir     xInterceptionHelper->registerDispatchProviderInterceptor( xInterceptor );
793cdf0e10cSrcweir }
794cdf0e10cSrcweir 
795cdf0e10cSrcweir //*****************************************************************************************************************
releaseDispatchProviderInterceptor(const css::uno::Reference<css::frame::XDispatchProviderInterceptor> & xInterceptor)796cdf0e10cSrcweir void SAL_CALL Desktop::releaseDispatchProviderInterceptor ( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor)
797cdf0e10cSrcweir     throw( css::uno::RuntimeException)
798cdf0e10cSrcweir {
799cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
800cdf0e10cSrcweir 
801cdf0e10cSrcweir     css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper( m_xDispatchHelper, css::uno::UNO_QUERY );
802cdf0e10cSrcweir     xInterceptionHelper->releaseDispatchProviderInterceptor( xInterceptor );
803cdf0e10cSrcweir }
804cdf0e10cSrcweir 
805cdf0e10cSrcweir /*-************************************************************************************************************//**
806cdf0e10cSrcweir     @interface  XFramesSupplier
807cdf0e10cSrcweir     @short      return access to append or remove childs on desktop
808cdf0e10cSrcweir     @descr      We don't implement these interface directly. We use a helper class to do this.
809cdf0e10cSrcweir                 If you wish to add or delete childs to/from the container, call these method to get
810cdf0e10cSrcweir                 a reference to the helper.
811cdf0e10cSrcweir 
812cdf0e10cSrcweir     @attention  Helper is threadsafe himself. So we don't need any lock here.
813cdf0e10cSrcweir 
814cdf0e10cSrcweir     @seealso    class OFrames
815cdf0e10cSrcweir 
816cdf0e10cSrcweir     @param      -
817cdf0e10cSrcweir     @return     A reference to the helper.
818cdf0e10cSrcweir 
819cdf0e10cSrcweir     @onerror    A null reference is returned.
820cdf0e10cSrcweir     @threadsafe yes
821cdf0e10cSrcweir *//*-*************************************************************************************************************/
getFrames()822cdf0e10cSrcweir css::uno::Reference< css::frame::XFrames > SAL_CALL Desktop::getFrames() throw( css::uno::RuntimeException )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
825cdf0e10cSrcweir     // Register transaction and reject wrong calls.
826cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
827cdf0e10cSrcweir 
828cdf0e10cSrcweir     return m_xFramesHelper;
829cdf0e10cSrcweir }
830cdf0e10cSrcweir 
831cdf0e10cSrcweir /*-************************************************************************************************************//**
832cdf0e10cSrcweir     @interface  XFramesSupplier
833cdf0e10cSrcweir     @short      set/get the current active child frame
834cdf0e10cSrcweir     @descr      It must be a task. Direct childs of desktop are tasks only! No frames are accepted.
835b12a77c9Smseidel                 We don't save this information directly in this class. We use our container-helper
836cdf0e10cSrcweir                 to do that.
837cdf0e10cSrcweir 
838cdf0e10cSrcweir     @attention  Helper is threadsafe himself. So we don't need any lock here.
839cdf0e10cSrcweir 
840cdf0e10cSrcweir     @seealso    class OFrameContainer
841cdf0e10cSrcweir 
842cdf0e10cSrcweir     @param      "xFrame", new active frame (must be valid!)
843b12a77c9Smseidel     @return     A reference to our current active childtask, if anyone exist.
844cdf0e10cSrcweir 
845cdf0e10cSrcweir     @onerror    A null reference is returned.
846cdf0e10cSrcweir     @threadsafe yes
847cdf0e10cSrcweir *//*-*************************************************************************************************************/
setActiveFrame(const css::uno::Reference<css::frame::XFrame> & xFrame)848cdf0e10cSrcweir void SAL_CALL Desktop::setActiveFrame( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException )
849cdf0e10cSrcweir {
850cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
851cdf0e10cSrcweir     // Register transaction and reject wrong calls.
852cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
853cdf0e10cSrcweir 
854cdf0e10cSrcweir     // Get old active frame first.
855cdf0e10cSrcweir     // If nothing will change - do nothing!
856cdf0e10cSrcweir     // Otherwise set new active frame ...
857cdf0e10cSrcweir     // and deactivate last frame.
85807a3d7f1SPedro Giffuni     // It's necessary for our FrameActionEvent listener on a frame!
859cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xLastActiveChild = m_aChildTaskContainer.getActive();
860cdf0e10cSrcweir     if( xLastActiveChild != xFrame )
861cdf0e10cSrcweir     {
862cdf0e10cSrcweir         m_aChildTaskContainer.setActive( xFrame );
863cdf0e10cSrcweir         if( xLastActiveChild.is() == sal_True )
864cdf0e10cSrcweir         {
865cdf0e10cSrcweir             xLastActiveChild->deactivate();
866cdf0e10cSrcweir         }
867cdf0e10cSrcweir     }
868cdf0e10cSrcweir }
869cdf0e10cSrcweir 
870cdf0e10cSrcweir //*****************************************************************************************************************
getActiveFrame()871cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::getActiveFrame() throw( css::uno::RuntimeException )
872cdf0e10cSrcweir {
873cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
874cdf0e10cSrcweir     // Register transaction and reject wrong calls.
875cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
876cdf0e10cSrcweir 
877cdf0e10cSrcweir     return m_aChildTaskContainer.getActive();
878cdf0e10cSrcweir }
879cdf0e10cSrcweir 
880cdf0e10cSrcweir /*-************************************************************************************************************//**
881cdf0e10cSrcweir     @interface  XFrame
882cdf0e10cSrcweir     @short      non implemented methods!
883cdf0e10cSrcweir     @descr      Some method make no sense for our desktop! He has no window or parent or ...
884cdf0e10cSrcweir                 So we should implement it empty and warn programmer, if he use it!
885cdf0e10cSrcweir 
886cdf0e10cSrcweir     @seealso    -
887cdf0e10cSrcweir 
888cdf0e10cSrcweir     @param      -
889cdf0e10cSrcweir     @return     -
890cdf0e10cSrcweir 
891cdf0e10cSrcweir     @onerror    -
892cdf0e10cSrcweir     @threadsafe -
893cdf0e10cSrcweir *//*-*************************************************************************************************************/
initialize(const css::uno::Reference<css::awt::XWindow> &)894cdf0e10cSrcweir void SAL_CALL Desktop::initialize( const css::uno::Reference< css::awt::XWindow >& ) throw( css::uno::RuntimeException )
895cdf0e10cSrcweir {
896cdf0e10cSrcweir }
897cdf0e10cSrcweir 
898cdf0e10cSrcweir //*****************************************************************************************************************
getContainerWindow()899cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > SAL_CALL Desktop::getContainerWindow() throw( css::uno::RuntimeException )
900cdf0e10cSrcweir {
901cdf0e10cSrcweir     return css::uno::Reference< css::awt::XWindow >();
902cdf0e10cSrcweir }
903cdf0e10cSrcweir 
904cdf0e10cSrcweir //*****************************************************************************************************************
setCreator(const css::uno::Reference<css::frame::XFramesSupplier> &)905cdf0e10cSrcweir void SAL_CALL Desktop::setCreator( const css::uno::Reference< css::frame::XFramesSupplier >& /*xCreator*/ ) throw( css::uno::RuntimeException )
906cdf0e10cSrcweir {
907cdf0e10cSrcweir }
908cdf0e10cSrcweir 
909cdf0e10cSrcweir //*****************************************************************************************************************
getCreator()910cdf0e10cSrcweir css::uno::Reference< css::frame::XFramesSupplier > SAL_CALL Desktop::getCreator() throw( css::uno::RuntimeException )
911cdf0e10cSrcweir {
912cdf0e10cSrcweir     return css::uno::Reference< css::frame::XFramesSupplier >();
913cdf0e10cSrcweir }
914cdf0e10cSrcweir 
915cdf0e10cSrcweir //*****************************************************************************************************************
getName()916cdf0e10cSrcweir ::rtl::OUString SAL_CALL Desktop::getName() throw( css::uno::RuntimeException )
917cdf0e10cSrcweir {
918cdf0e10cSrcweir     /* SAFE { */
919cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
920cdf0e10cSrcweir     return m_sName;
921cdf0e10cSrcweir     /* } SAFE */
922cdf0e10cSrcweir }
923cdf0e10cSrcweir 
924cdf0e10cSrcweir //*****************************************************************************************************************
setName(const::rtl::OUString & sName)925cdf0e10cSrcweir void SAL_CALL Desktop::setName( const ::rtl::OUString& sName ) throw( css::uno::RuntimeException )
926cdf0e10cSrcweir {
927cdf0e10cSrcweir     /* SAFE { */
928cdf0e10cSrcweir     WriteGuard aWriteLock( m_aLock );
929cdf0e10cSrcweir     m_sName = sName;
930cdf0e10cSrcweir     aWriteLock.unlock();
931cdf0e10cSrcweir     /* } SAFE */
932cdf0e10cSrcweir }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir //*****************************************************************************************************************
isTop()935cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::isTop() throw( css::uno::RuntimeException )
936cdf0e10cSrcweir {
937cdf0e10cSrcweir     return sal_True;
938cdf0e10cSrcweir }
939cdf0e10cSrcweir 
940cdf0e10cSrcweir //*****************************************************************************************************************
activate()941cdf0e10cSrcweir void SAL_CALL Desktop::activate() throw( css::uno::RuntimeException )
942cdf0e10cSrcweir {
94353c84c60Smseidel     // Desktop is active always ... but sometimes our frames try to activate
944cdf0e10cSrcweir     // the complete path from bottom to top ... And our desktop is the topest frame :-(
945cdf0e10cSrcweir     // So - please don't show any assertions here. Do nothing!
946cdf0e10cSrcweir }
947cdf0e10cSrcweir 
948cdf0e10cSrcweir //*****************************************************************************************************************
deactivate()949cdf0e10cSrcweir void SAL_CALL Desktop::deactivate() throw( css::uno::RuntimeException )
950cdf0e10cSrcweir {
951cdf0e10cSrcweir     // Desktop is activae always ... but sometimes our frames try to deactivate
952cdf0e10cSrcweir     // the complete path from bottom to top ... And our desktop is the topest frame :-(
953cdf0e10cSrcweir     // So - please don't show any assertions here. Do nothing!
954cdf0e10cSrcweir }
955cdf0e10cSrcweir 
956cdf0e10cSrcweir //*****************************************************************************************************************
isActive()957cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::isActive() throw( css::uno::RuntimeException )
958cdf0e10cSrcweir {
959cdf0e10cSrcweir     return sal_True;
960cdf0e10cSrcweir }
961cdf0e10cSrcweir 
962cdf0e10cSrcweir //*****************************************************************************************************************
setComponent(const css::uno::Reference<css::awt::XWindow> &,const css::uno::Reference<css::frame::XController> &)963cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::setComponent( const css::uno::Reference< css::awt::XWindow >&       /*xComponentWindow*/ ,
964cdf0e10cSrcweir                                          const css::uno::Reference< css::frame::XController >& /*xController*/      ) throw( css::uno::RuntimeException )
965cdf0e10cSrcweir {
966cdf0e10cSrcweir     return sal_False;
967cdf0e10cSrcweir }
968cdf0e10cSrcweir 
969cdf0e10cSrcweir //*****************************************************************************************************************
getComponentWindow()970cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > SAL_CALL Desktop::getComponentWindow() throw( css::uno::RuntimeException )
971cdf0e10cSrcweir {
972cdf0e10cSrcweir     return css::uno::Reference< css::awt::XWindow >();
973cdf0e10cSrcweir }
974cdf0e10cSrcweir 
975cdf0e10cSrcweir //*****************************************************************************************************************
getController()976cdf0e10cSrcweir css::uno::Reference< css::frame::XController > SAL_CALL Desktop::getController() throw( css::uno::RuntimeException )
977cdf0e10cSrcweir {
978cdf0e10cSrcweir     return css::uno::Reference< css::frame::XController >();
979cdf0e10cSrcweir }
980cdf0e10cSrcweir 
981cdf0e10cSrcweir //*****************************************************************************************************************
contextChanged()982cdf0e10cSrcweir void SAL_CALL Desktop::contextChanged() throw( css::uno::RuntimeException )
983cdf0e10cSrcweir {
984cdf0e10cSrcweir }
985cdf0e10cSrcweir 
986cdf0e10cSrcweir //*****************************************************************************************************************
addFrameActionListener(const css::uno::Reference<css::frame::XFrameActionListener> &)987cdf0e10cSrcweir void SAL_CALL Desktop::addFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& ) throw( css::uno::RuntimeException )
988cdf0e10cSrcweir {
989cdf0e10cSrcweir }
990cdf0e10cSrcweir 
991cdf0e10cSrcweir //*****************************************************************************************************************
992cdf0e10cSrcweir //   css::frame::XFrame
993cdf0e10cSrcweir //*****************************************************************************************************************
removeFrameActionListener(const css::uno::Reference<css::frame::XFrameActionListener> &)994cdf0e10cSrcweir void SAL_CALL Desktop::removeFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& ) throw( css::uno::RuntimeException )
995cdf0e10cSrcweir {
996cdf0e10cSrcweir }
997cdf0e10cSrcweir 
998cdf0e10cSrcweir /*-************************************************************************************************************//**
999cdf0e10cSrcweir     @interface  XFrame
1000cdf0e10cSrcweir     @short      try to find a frame with special parameters
1001cdf0e10cSrcweir     @descr      This method searches for a frame with the specified name.
1002cdf0e10cSrcweir                 Frames may contain other frames (e.g. a frameset) and may
100353c84c60Smseidel                 be contained in other frames. This hierarchie is searched by
1004cdf0e10cSrcweir                 this method.
1005cdf0e10cSrcweir                 First some special names are taken into account, i.e. "",
1006cdf0e10cSrcweir                 "_self", "_top", "_parent" etc. The FrameSearchFlags are ignored
1007cdf0e10cSrcweir                 when comparing these names with aTargetFrameName, further steps are
1008cdf0e10cSrcweir                 controlled by the FrameSearchFlags. If allowed, the name of the frame
1009cdf0e10cSrcweir                 itself is compared with the desired one, then ( again if allowed )
1010cdf0e10cSrcweir                 the method findFrame is called for all children of the frame.
1011cdf0e10cSrcweir                 If no Frame with the given name is found until the top frames container,
1012cdf0e10cSrcweir                 a new top Frame is created, if this is allowed by a special
1013cdf0e10cSrcweir                 FrameSearchFlag. The new Frame also gets the desired name.
1014cdf0e10cSrcweir                 We use a helper to get right search direction and react in a right manner.
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir     @seealso    class TargetFinder
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir     @param      "sTargetFrameName"  , name of searched frame
1019cdf0e10cSrcweir     @param      "nSearchFlags"      , flags to regulate search
1020cdf0e10cSrcweir     @return     A reference to an existing frame in hierarchy, if it exist.
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir     @onerror    A null reference is returned.
1023cdf0e10cSrcweir     @threadsafe yes
1024cdf0e10cSrcweir *//*-*************************************************************************************************************/
findFrame(const::rtl::OUString & sTargetFrameName,sal_Int32 nSearchFlags)1025cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const ::rtl::OUString& sTargetFrameName ,
1026cdf0e10cSrcweir                                                                              sal_Int32        nSearchFlags     ) throw( css::uno::RuntimeException )
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xTarget;
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1031cdf0e10cSrcweir     // 0) Ignore wrong parameter!
1032cdf0e10cSrcweir     //    We doesn't support search for following special targets.
1033cdf0e10cSrcweir     //    If we reject this requests - we mustnt check for such names
1034cdf0e10cSrcweir     //    in following code again and again. If we do not so -wrong
103530acf5e8Spfg     //    search results can occur!
1036cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1037cdf0e10cSrcweir     if (
1038cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_DEFAULT  )   ||    // valid for dispatches - not for findFrame()!
1039cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_MENUBAR  )   ||    // valid for dispatches - not for findFrame()!
1040cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_HELPAGENT)   ||    // valid for dispatches - not for findFrame()!
1041cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_PARENT   )   ||    // we have no parent by definition
1042cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_BEAMER   )         // beamer frames are allowed as child of tasks only -
1043cdf0e10cSrcweir                                                             // and they exist more then ones. We have no idea which our sub tasks is the right one
1044cdf0e10cSrcweir        )
1045cdf0e10cSrcweir     {
1046cdf0e10cSrcweir         return NULL;
1047cdf0e10cSrcweir     }
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1050cdf0e10cSrcweir     // I) check for special defined targets first which must be handled exclusive.
1051cdf0e10cSrcweir     //    force using of "if() else if() ..."
1052cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1053cdf0e10cSrcweir 
105407a3d7f1SPedro Giffuni     // get threadsafe some necessary member which are necessary for following functionality
1055cdf0e10cSrcweir     /* SAFE { */
1056cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
1057cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > xFactory = m_xFactory;
1058cdf0e10cSrcweir     aReadLock.unlock();
1059cdf0e10cSrcweir     /* } SAFE */
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1062cdf0e10cSrcweir     // I.I) "_blank"
1063cdf0e10cSrcweir     //  create a new task as child of this desktop instance
106407a3d7f1SPedro Giffuni     //  Note: Used helper TaskCreator use us automatically ...
1065cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1066cdf0e10cSrcweir     if ( sTargetFrameName==SPECIALTARGET_BLANK )
1067cdf0e10cSrcweir     {
1068cdf0e10cSrcweir         TaskCreator aCreator(xFactory);
1069cdf0e10cSrcweir         xTarget = aCreator.createTask(sTargetFrameName,sal_False);
1070cdf0e10cSrcweir     }
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1073cdf0e10cSrcweir     // I.II) "_top"
1074cdf0e10cSrcweir     //  We are top by definition
1075cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1076cdf0e10cSrcweir     else
1077cdf0e10cSrcweir     if ( sTargetFrameName==SPECIALTARGET_TOP )
1078cdf0e10cSrcweir     {
1079cdf0e10cSrcweir         xTarget = this;
1080cdf0e10cSrcweir     }
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1083cdf0e10cSrcweir     // I.III) "_self", ""
1084cdf0e10cSrcweir     //  This mean this "frame" in every case.
1085cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1086cdf0e10cSrcweir     else
1087cdf0e10cSrcweir     if (
1088cdf0e10cSrcweir         ( sTargetFrameName==SPECIALTARGET_SELF ) ||
1089cdf0e10cSrcweir         ( sTargetFrameName.getLength()<1       )
1090cdf0e10cSrcweir        )
1091cdf0e10cSrcweir     {
1092cdf0e10cSrcweir         xTarget = this;
1093cdf0e10cSrcweir     }
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir     else
1096cdf0e10cSrcweir     {
1097cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
109815289133Smseidel         // II) otherwise use optional given search flags
1099cdf0e10cSrcweir         //  force using of combinations of such flags. means no "else" part of use if() statements.
110015289133Smseidel         //  But we must break further searches if target was already found.
1101cdf0e10cSrcweir         //  Order of using flags is fix: SELF - CHILDREN - SIBLINGS - PARENT
1102cdf0e10cSrcweir         //  TASK and CREATE are handled special.
110307a3d7f1SPedro Giffuni         //  But note: Such flags are not valid for the desktop - especially SIBLINGS or PARENT.
1104cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1105cdf0e10cSrcweir 
110607a3d7f1SPedro Giffuni         // get threadsafe some necessary member which are necessary for following functionality
1107cdf0e10cSrcweir         /* SAFE { */
1108cdf0e10cSrcweir         aReadLock.lock();
1109cdf0e10cSrcweir         ::rtl::OUString sOwnName = m_sName;
1110cdf0e10cSrcweir         aReadLock.unlock();
1111cdf0e10cSrcweir         /* } SAFE */
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1114cdf0e10cSrcweir         // II.I) SELF
111515289133Smseidel         //  Check for right name. If it's the searched one return ourself - otherwise
1116cdf0e10cSrcweir         //  ignore this flag.
1117cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1118cdf0e10cSrcweir         if (
1119cdf0e10cSrcweir             (nSearchFlags &  css::frame::FrameSearchFlag::SELF)  &&
1120cdf0e10cSrcweir             (sOwnName     == sTargetFrameName                 )
1121cdf0e10cSrcweir            )
1122cdf0e10cSrcweir         {
1123cdf0e10cSrcweir             xTarget = this;
1124cdf0e10cSrcweir         }
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1127cdf0e10cSrcweir         // II.II) TASKS
11282e3a1b6eSmseidel         //  This is a special flag. Normally it regulates search inside tasks and forbid access to parent trees.
1129cdf0e10cSrcweir         //  But the desktop exists outside such task trees. They are our sub trees. So the desktop implement
113053c84c60Smseidel         //  a special feature: We use it to start search on our direct children only. That means we suppress
113107a3d7f1SPedro Giffuni         //  search on ALL child frames. May that can be useful to get access on opened document tasks
113207a3d7f1SPedro Giffuni         //  only without filter out all non really required sub frames ...
1133cdf0e10cSrcweir         //  Used helper method on our container doesn't create any frame - its a search only.
1134cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1135cdf0e10cSrcweir         if (
1136cdf0e10cSrcweir             ( ! xTarget.is()                                  ) &&
1137cdf0e10cSrcweir             (nSearchFlags & css::frame::FrameSearchFlag::TASKS)
1138cdf0e10cSrcweir            )
1139cdf0e10cSrcweir         {
1140cdf0e10cSrcweir             xTarget = m_aChildTaskContainer.searchOnDirectChildrens(sTargetFrameName);
1141cdf0e10cSrcweir         }
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1144cdf0e10cSrcweir         // II.III) CHILDREN
1145cdf0e10cSrcweir         //  Search on all children for the given target name.
114630acf5e8Spfg         //  An empty name value can't occur here - because it must be already handled as "_self"
1147cdf0e10cSrcweir         //  before. Used helper function of container doesn't create any frame.
1148cdf0e10cSrcweir         //  It makes a deep search only.
1149cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1150cdf0e10cSrcweir         if (
1151cdf0e10cSrcweir             ( ! xTarget.is()                                     ) &&
1152cdf0e10cSrcweir             (nSearchFlags & css::frame::FrameSearchFlag::CHILDREN)
1153cdf0e10cSrcweir            )
1154cdf0e10cSrcweir         {
1155cdf0e10cSrcweir             xTarget = m_aChildTaskContainer.searchOnAllChildrens(sTargetFrameName);
1156cdf0e10cSrcweir         }
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1159cdf0e10cSrcweir         // II.IV) CREATE
1160cdf0e10cSrcweir         //  If we haven't found any valid target frame by using normal flags - but user allowed us to create
116107a3d7f1SPedro Giffuni         //  a new one ... we should do that. Used TaskCreator use us automatically as parent!
1162cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1163cdf0e10cSrcweir         if (
1164cdf0e10cSrcweir             ( ! xTarget.is()                                   )    &&
1165cdf0e10cSrcweir             (nSearchFlags & css::frame::FrameSearchFlag::CREATE)
1166cdf0e10cSrcweir            )
1167cdf0e10cSrcweir         {
1168cdf0e10cSrcweir             TaskCreator aCreator(xFactory);
1169cdf0e10cSrcweir             xTarget = aCreator.createTask(sTargetFrameName,sal_False);
1170cdf0e10cSrcweir         }
1171cdf0e10cSrcweir     }
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir     return xTarget;
1174cdf0e10cSrcweir }
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir //=============================================================================
dispose()1177cdf0e10cSrcweir void SAL_CALL Desktop::dispose()
1178cdf0e10cSrcweir     throw( css::uno::RuntimeException )
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir     // Safe impossible cases
1181cdf0e10cSrcweir     // It's an programming error if dispose is called before terminate!
1182cdf0e10cSrcweir     LOG_ASSERT2( m_bIsTerminated==sal_False, "Desktop::dispose()", "It's not allowed to dispose the desktop before terminate() is called!" )
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir     SYNCHRONIZED_START
1185cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir         // Look for multiple calls of this method!
118807a3d7f1SPedro Giffuni         // If somewhere call dispose() twice - he will be stopped here really!!!
1189cdf0e10cSrcweir         TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir         // Now - we are alone and its the first call of this method ...
1192cdf0e10cSrcweir         // otherwise call before had thrown a DisposedException / hopefully .-)
119307a3d7f1SPedro Giffuni         // But we dont use the transaction object created before ... we reset it immediately ...
1194cdf0e10cSrcweir         // two lines of code ... for what ?
1195cdf0e10cSrcweir         // The answer: We wished to synchronize concurrent dispose() calls -> OK
1196cdf0e10cSrcweir         // But next line will wait for all currently running transaction (even if they
1197cdf0e10cSrcweir         // are running within the same thread!) So we would block ourself there if aTransaction
1198cdf0e10cSrcweir         // will stay registered .-)
1199cdf0e10cSrcweir         aTransaction.stop();
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir         // Disable this instance for further work.
1202cdf0e10cSrcweir         // This will wait for all current running transactions ...
1203cdf0e10cSrcweir         // and reject all new incoming requests!
1204cdf0e10cSrcweir         m_aTransactionManager.setWorkingMode( E_BEFORECLOSE );
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir         aWriteLock.unlock();
1207cdf0e10cSrcweir     SYNCHRONIZED_END
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir     // Following lines of code can be called outside a synchronized block ...
1210cdf0e10cSrcweir     // Because our transaction manager will block all new requests to this object.
1211cdf0e10cSrcweir     // So nobody can use us any longer.
121207a3d7f1SPedro Giffuni     // Exception: Only removing of listener will work ... and this code can't be dangerous.
1213cdf0e10cSrcweir 
1214cdf0e10cSrcweir     // First we has to kill all listener connections.
1215cdf0e10cSrcweir     // They might rely on our member and can hinder us on releasing them.
1216cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > xThis ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
1217cdf0e10cSrcweir     css::lang::EventObject                      aEvent( xThis );
1218cdf0e10cSrcweir     m_aListenerContainer.disposeAndClear( aEvent );
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir     // Clear our child task container and forget all task references hardly.
12212e3a1b6eSmseidel     // Normally all open document were already closed by our terminate() function before ...
1222cdf0e10cSrcweir     // New opened frames will have a problem now .-)
1223cdf0e10cSrcweir     m_aChildTaskContainer.clear();
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir     // Dispose our helper too.
1226cdf0e10cSrcweir     css::uno::Reference< css::lang::XEventListener > xFramesHelper( m_xFramesHelper, css::uno::UNO_QUERY );
1227cdf0e10cSrcweir     if( xFramesHelper.is() )
1228cdf0e10cSrcweir         xFramesHelper->disposing( aEvent );
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir     // At least clean up other member references.
1231cdf0e10cSrcweir     m_xDispatchHelper.clear();
1232cdf0e10cSrcweir     m_xFramesHelper.clear();
1233cdf0e10cSrcweir     m_xLastFrame.clear();
1234cdf0e10cSrcweir     m_xFactory.clear();
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir     m_xPipeTerminator.clear();
1237cdf0e10cSrcweir     m_xQuickLauncher.clear();
1238cdf0e10cSrcweir     m_xSWThreadManager.clear();
1239cdf0e10cSrcweir     m_xSfxTerminator.clear();
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir     // From this point nothing will work further on this object ...
1242cdf0e10cSrcweir     // excepting our dtor() .-)
1243cdf0e10cSrcweir     m_aTransactionManager.setWorkingMode( E_CLOSE );
1244cdf0e10cSrcweir }
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir /*-************************************************************************************************************//**
1247cdf0e10cSrcweir     @interface  XComponent
1248cdf0e10cSrcweir     @short      add/remove listener for dispose events
124953c84c60Smseidel     @descr      Add an event listener to this object, if you wish to get information
125030acf5e8Spfg                 about our dying!
1251cdf0e10cSrcweir                 You must release this listener reference during your own disposing() method.
1252cdf0e10cSrcweir 
125353c84c60Smseidel     @attention  Our container is threadsafe himself. So we doesn't need any lock here.
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir     @seealso    -
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir     @param      "xListener", reference to valid listener. We don't accept invalid values!
1258cdf0e10cSrcweir     @return     -
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir     @onerror    -
1261cdf0e10cSrcweir     @threadsafe yes
1262cdf0e10cSrcweir *//*-*************************************************************************************************************/
addEventListener(const css::uno::Reference<css::lang::XEventListener> & xListener)1263cdf0e10cSrcweir void SAL_CALL Desktop::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException )
1264cdf0e10cSrcweir {
1265cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1266cdf0e10cSrcweir     // Safe impossible cases
1267cdf0e10cSrcweir     // Method not defined for all incoming parameter.
1268cdf0e10cSrcweir     LOG_ASSERT2( implcp_addEventListener( xListener ), "Desktop::addEventListener()", "Invalid parameter detected!" )
1269cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1270cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir     m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener );
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir //*****************************************************************************************************************
removeEventListener(const css::uno::Reference<css::lang::XEventListener> & xListener)1276cdf0e10cSrcweir void SAL_CALL Desktop::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException )
1277cdf0e10cSrcweir {
1278cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1279cdf0e10cSrcweir     // Safe impossible cases
1280cdf0e10cSrcweir     // Method not defined for all incoming parameter.
1281cdf0e10cSrcweir     LOG_ASSERT2( implcp_removeEventListener( xListener ), "Desktop::removeEventListener()", "Invalid parameter detected!" )
1282cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1283cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir     m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener );
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir /*-************************************************************************************************************//**
1289cdf0e10cSrcweir     @interface  XDispatchResultListener
1290cdf0e10cSrcweir     @short      callback for dispatches
1291cdf0e10cSrcweir     @descr      To support our method "loadComponentFromURL()" we are listener on temp. created dispatcher.
1292cdf0e10cSrcweir                 They call us back in this method "statusChanged()". As source of given state event, they give us a
1293cdf0e10cSrcweir                 reference to the target frame, in which dispatch was loaded! So we can use it to return his component
1294cdf0e10cSrcweir                 to caller! If no target exist ... ??!!
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir     @seealso    method loadComponentFromURL()
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir     @param      "aEvent", state event which (hopefully) valid informations
1299cdf0e10cSrcweir     @return     -
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir     @onerror    -
1302cdf0e10cSrcweir     @threadsafe yes
1303cdf0e10cSrcweir *//*-*************************************************************************************************************/
dispatchFinished(const css::frame::DispatchResultEvent & aEvent)1304cdf0e10cSrcweir void SAL_CALL Desktop::dispatchFinished( const css::frame::DispatchResultEvent& aEvent ) throw( css::uno::RuntimeException )
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1307cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1308cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir     /* SAFE AREA ------------------------------------------------------------------------------------------- */
1311cdf0e10cSrcweir     WriteGuard aWriteLock( m_aLock );
1312cdf0e10cSrcweir     if( m_eLoadState != E_INTERACTION )
1313cdf0e10cSrcweir     {
1314cdf0e10cSrcweir         m_xLastFrame = css::uno::Reference< css::frame::XFrame >();
1315cdf0e10cSrcweir         m_eLoadState = E_FAILED                                   ;
1316cdf0e10cSrcweir         if( aEvent.State == css::frame::DispatchResultState::SUCCESS )
1317cdf0e10cSrcweir         {
1318cdf0e10cSrcweir             css::uno::Reference < css::frame::XFrame > xFrame;
1319cdf0e10cSrcweir             if ( aEvent.Result >>= m_xLastFrame )
1320cdf0e10cSrcweir                 m_eLoadState = E_SUCCESSFUL;
1321cdf0e10cSrcweir         }
1322cdf0e10cSrcweir     }
1323cdf0e10cSrcweir     /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
1324cdf0e10cSrcweir }
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir /*-************************************************************************************************************//**
1327cdf0e10cSrcweir     @interface  XEventListener
1328cdf0e10cSrcweir     @short      not implemented!
132907a3d7f1SPedro Giffuni     @descr      We are a status listener ... and so we must be an event listener too ... But we doesn't need it really!
1330cdf0e10cSrcweir                 We are a temp. listener only and our lifetime isn't smaller then of our temp. used dispatcher.
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir     @seealso    method loadComponentFromURL()
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir     @param      -
1335cdf0e10cSrcweir     @return     -
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir     @onerror    -
1338cdf0e10cSrcweir     @threadsafe -
1339cdf0e10cSrcweir *//*-*************************************************************************************************************/
disposing(const css::lang::EventObject &)1340cdf0e10cSrcweir void SAL_CALL Desktop::disposing( const css::lang::EventObject& ) throw( css::uno::RuntimeException )
1341cdf0e10cSrcweir {
13422e3a1b6eSmseidel     LOG_ERROR( "Desktop::disposing()", "Algorithm error! Normally desktop is temp. listener ... not all the time. So this method shouldn't be called." )
1343cdf0e10cSrcweir }
1344cdf0e10cSrcweir 
1345cdf0e10cSrcweir /*-************************************************************************************************************//**
1346cdf0e10cSrcweir     @interface  XInteractionHandler
134707a3d7f1SPedro Giffuni     @short      callback for loadComponentFromURL for detected exceptions during load process
1348cdf0e10cSrcweir     @descr      In this case we must cancel loading and throw these detected exception again as result
1349cdf0e10cSrcweir                 of our own called method.
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir     @attention  a)
135230acf5e8Spfg                 Normal loop in loadComponentFromURL() breaks on set member m_eLoadState during callback statusChanged().
1353cdf0e10cSrcweir                 But these interaction feature implements second way to do so! So we must look on different callbacks
1354cdf0e10cSrcweir                 for same operation ... and live with it.
1355cdf0e10cSrcweir                 b)
1356cdf0e10cSrcweir                 Search for given continuations too. If any XInteractionAbort exist ... use it to abort further operations
1357cdf0e10cSrcweir                 for currently running operation!
1358cdf0e10cSrcweir 
1359cdf0e10cSrcweir     @seealso    method loadComponentFromURL()
1360cdf0e10cSrcweir     @seealso    member m_eLoadState
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir     @param      "xRequest", request for interaction - normal a wrapped target exception from bottom services
1363cdf0e10cSrcweir     @return     -
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir     @onerror    -
1366cdf0e10cSrcweir     @threadsafe yes
1367cdf0e10cSrcweir *//*-*************************************************************************************************************/
handle(const css::uno::Reference<css::task::XInteractionRequest> & xRequest)1368cdf0e10cSrcweir void SAL_CALL Desktop::handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException )
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1371cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1372cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir     // Don't check incoming request!
137530acf5e8Spfg     // If somewhere starts interaction without right parameter - he made something wrong.
137653c84c60Smseidel     // loadComponentFromURL() waits for these event - otherwise it yield for ever!
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir     // get packed request and work on it first
1379cdf0e10cSrcweir     // Attention: Don't set it on internal member BEFORE interaction is finished - because
1380cdf0e10cSrcweir     // "loadComponentFromURL()" yield tills this member is changed. If we do it before
138153c84c60Smseidel     // interaction finish we can't guarantee right functionality. May be we cancel load process to early...
1382cdf0e10cSrcweir     css::uno::Any aRequest = xRequest->getRequest();
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir     // extract continuations from request
1385cdf0e10cSrcweir     css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations();
1386cdf0e10cSrcweir     css::uno::Reference< css::task::XInteractionAbort >                              xAbort         ;
1387cdf0e10cSrcweir     css::uno::Reference< css::task::XInteractionApprove >                            xApprove       ;
1388cdf0e10cSrcweir     css::uno::Reference< css::document::XInteractionFilterSelect >                   xFilterSelect  ;
1389cdf0e10cSrcweir     sal_Bool                                                                         bAbort         = sal_False;
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir     sal_Int32 nCount=lContinuations.getLength();
1392cdf0e10cSrcweir     for( sal_Int32 nStep=0; nStep<nCount; ++nStep )
1393cdf0e10cSrcweir     {
1394cdf0e10cSrcweir         if( ! xAbort.is() )
1395cdf0e10cSrcweir             xAbort  = css::uno::Reference< css::task::XInteractionAbort >( lContinuations[nStep], css::uno::UNO_QUERY );
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir         if( ! xApprove.is() )
1398cdf0e10cSrcweir             xApprove  = css::uno::Reference< css::task::XInteractionApprove >( lContinuations[nStep], css::uno::UNO_QUERY );
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir         if( ! xFilterSelect.is() )
1401cdf0e10cSrcweir             xFilterSelect = css::uno::Reference< css::document::XInteractionFilterSelect >( lContinuations[nStep], css::uno::UNO_QUERY );
1402cdf0e10cSrcweir     }
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir     // differ between abortable interactions (error, unknown filter ...)
140553c84c60Smseidel     // and other ones (ambiguous but not unknown filter ...)
1406cdf0e10cSrcweir     css::task::ErrorCodeRequest          aErrorCodeRequest     ;
1407cdf0e10cSrcweir     css::document::AmbigousFilterRequest aAmbigousFilterRequest;
1408cdf0e10cSrcweir     if( aRequest >>= aAmbigousFilterRequest )
1409cdf0e10cSrcweir     {
1410cdf0e10cSrcweir         if( xFilterSelect.is() )
1411cdf0e10cSrcweir         {
1412cdf0e10cSrcweir             xFilterSelect->setFilter( aAmbigousFilterRequest.SelectedFilter ); // user selected filter wins!
1413cdf0e10cSrcweir             xFilterSelect->select();
1414cdf0e10cSrcweir         }
1415cdf0e10cSrcweir     }
1416cdf0e10cSrcweir     else
1417cdf0e10cSrcweir     if( aRequest >>= aErrorCodeRequest )
1418cdf0e10cSrcweir     {
1419cdf0e10cSrcweir         sal_Bool bWarning = ((aErrorCodeRequest.ErrCode & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK);
1420cdf0e10cSrcweir         if (xApprove.is() && bWarning)
1421cdf0e10cSrcweir             xApprove->select();
1422cdf0e10cSrcweir         else
1423cdf0e10cSrcweir         if (xAbort.is())
1424cdf0e10cSrcweir         {
1425cdf0e10cSrcweir             xAbort->select();
1426cdf0e10cSrcweir             bAbort = sal_True;
1427cdf0e10cSrcweir         }
1428cdf0e10cSrcweir     }
1429cdf0e10cSrcweir     else
1430cdf0e10cSrcweir     if( xAbort.is() )
1431cdf0e10cSrcweir     {
1432cdf0e10cSrcweir         xAbort->select();
1433cdf0e10cSrcweir         bAbort = sal_True;
1434cdf0e10cSrcweir     }
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir     /* SAFE AREA ------------------------------------------------------------------------------------------- */
1437cdf0e10cSrcweir     // Ok now it's time to break yield loop of loadComponentFromURL().
143807a3d7f1SPedro Giffuni     // But only for really aborted requests!
1439cdf0e10cSrcweir     // For example warnings will be approved and we wait for any success story ...
1440cdf0e10cSrcweir     if (bAbort)
1441cdf0e10cSrcweir     {
1442cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
1443cdf0e10cSrcweir         m_eLoadState          = E_INTERACTION;
1444cdf0e10cSrcweir         m_aInteractionRequest = aRequest     ;
1445cdf0e10cSrcweir         aWriteLock.unlock();
1446cdf0e10cSrcweir     }
1447cdf0e10cSrcweir     /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
1448cdf0e10cSrcweir }
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir //-----------------------------------------------------------------------------
leaseNumber(const css::uno::Reference<css::uno::XInterface> & xComponent)1451cdf0e10cSrcweir ::sal_Int32 SAL_CALL Desktop::leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent )
1452cdf0e10cSrcweir     throw (css::lang::IllegalArgumentException,
1453cdf0e10cSrcweir            css::uno::RuntimeException         )
1454cdf0e10cSrcweir {
1455cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1456cdf0e10cSrcweir     return m_xTitleNumberGenerator->leaseNumber (xComponent);
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir //-----------------------------------------------------------------------------
releaseNumber(::sal_Int32 nNumber)1460cdf0e10cSrcweir void SAL_CALL Desktop::releaseNumber( ::sal_Int32 nNumber )
1461cdf0e10cSrcweir     throw (css::lang::IllegalArgumentException,
1462cdf0e10cSrcweir            css::uno::RuntimeException         )
1463cdf0e10cSrcweir {
1464cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1465cdf0e10cSrcweir     m_xTitleNumberGenerator->releaseNumber (nNumber);
1466cdf0e10cSrcweir }
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir //-----------------------------------------------------------------------------
releaseNumberForComponent(const css::uno::Reference<css::uno::XInterface> & xComponent)1469cdf0e10cSrcweir void SAL_CALL Desktop::releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent )
1470cdf0e10cSrcweir     throw (css::lang::IllegalArgumentException,
1471cdf0e10cSrcweir            css::uno::RuntimeException         )
1472cdf0e10cSrcweir {
1473cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1474cdf0e10cSrcweir     m_xTitleNumberGenerator->releaseNumberForComponent (xComponent);
1475cdf0e10cSrcweir }
1476cdf0e10cSrcweir 
1477cdf0e10cSrcweir //-----------------------------------------------------------------------------
getUntitledPrefix()1478cdf0e10cSrcweir ::rtl::OUString SAL_CALL Desktop::getUntitledPrefix()
1479cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1480cdf0e10cSrcweir {
1481cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1482cdf0e10cSrcweir     return m_xTitleNumberGenerator->getUntitledPrefix ();
1483cdf0e10cSrcweir }
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir /*-************************************************************************************************************//**
1486cdf0e10cSrcweir     @short      try to convert a property value
1487cdf0e10cSrcweir     @descr      This method is called from helperclass "OPropertySetHelper".
1488cdf0e10cSrcweir                 Don't use this directly!
1489cdf0e10cSrcweir                 You must try to convert the value of given DESKTOP_PROPHANDLE and
1490cdf0e10cSrcweir                 return results of this operation. This will be used to ask vetoable
149107a3d7f1SPedro Giffuni                 listener. If no listener has a veto, we will change value really!
1492cdf0e10cSrcweir                 ( in method setFastPropertyValue_NoBroadcast(...) )
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir     @attention  Methods of OPropertySethelper are safed by using our shared osl mutex! (see ctor!)
1495cdf0e10cSrcweir                 So we must use different locks to make our implementation threadsafe.
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1498cdf0e10cSrcweir     @seealso    method setFastPropertyValue_NoBroadcast()
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir     @param      "aConvertedValue"   new converted value of property
1501cdf0e10cSrcweir     @param      "aOldValue"         old value of property
1502cdf0e10cSrcweir     @param      "nHandle"           handle of property
1503cdf0e10cSrcweir     @param      "aValue"            new value of property
150453c84c60Smseidel     @return     sal_True if value will be changed, sal_FALSE otherwise
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir     @onerror    IllegalArgumentException, if you call this with an invalid argument
1507cdf0e10cSrcweir     @threadsafe yes
1508cdf0e10cSrcweir *//*-*************************************************************************************************************/
convertFastPropertyValue(css::uno::Any & aConvertedValue,css::uno::Any & aOldValue,sal_Int32 nHandle,const css::uno::Any & aValue)1509cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::convertFastPropertyValue(       css::uno::Any&   aConvertedValue ,
1510cdf0e10cSrcweir                                                            css::uno::Any&   aOldValue       ,
1511cdf0e10cSrcweir                                                            sal_Int32        nHandle         ,
1512cdf0e10cSrcweir                                                      const css::uno::Any&   aValue          ) throw( css::lang::IllegalArgumentException )
1513cdf0e10cSrcweir {
1514cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1515cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1516cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir     //  Initialize state with sal_False !!!
1519cdf0e10cSrcweir     //  (Handle can be invalid)
1520cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir     switch( nHandle )
1523cdf0e10cSrcweir     {
1524cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO:
1525cdf0e10cSrcweir                 bReturn = PropHelper::willPropertyBeChanged(
1526cdf0e10cSrcweir                     css::uno::makeAny(m_bSuspendQuickstartVeto),
1527cdf0e10cSrcweir                     aValue,
1528cdf0e10cSrcweir                     aOldValue,
1529cdf0e10cSrcweir                     aConvertedValue);
1530cdf0e10cSrcweir                 break;
1531cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER :
1532cdf0e10cSrcweir                 bReturn = PropHelper::willPropertyBeChanged(
1533cdf0e10cSrcweir                     css::uno::makeAny(m_xDispatchRecorderSupplier),
1534cdf0e10cSrcweir                     aValue,
1535cdf0e10cSrcweir                     aOldValue,
1536cdf0e10cSrcweir                     aConvertedValue);
1537cdf0e10cSrcweir                 break;
1538cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_TITLE :
1539cdf0e10cSrcweir                 bReturn = PropHelper::willPropertyBeChanged(
1540cdf0e10cSrcweir                     css::uno::makeAny(m_sTitle),
1541cdf0e10cSrcweir                     aValue,
1542cdf0e10cSrcweir                     aOldValue,
1543cdf0e10cSrcweir                     aConvertedValue);
1544cdf0e10cSrcweir                 break;
1545cdf0e10cSrcweir     }
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir     // Return state of operation.
1548cdf0e10cSrcweir     return bReturn ;
1549cdf0e10cSrcweir }
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir /*-************************************************************************************************************//**
1552cdf0e10cSrcweir     @short      set value of a transient property
1553cdf0e10cSrcweir     @descr      This method is calling from helperclass "OPropertySetHelper".
1554cdf0e10cSrcweir                 Don't use this directly!
1555cdf0e10cSrcweir                 Handle and value are valid everyway! You must set the new value only.
155607a3d7f1SPedro Giffuni                 After this, baseclass send messages to all listener automatically.
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir     @param      "nHandle"   handle of property to change
1561cdf0e10cSrcweir     @param      "aValue"    new value of property
1562cdf0e10cSrcweir     @return     -
1563cdf0e10cSrcweir 
1564cdf0e10cSrcweir     @onerror    An exception is thrown.
1565cdf0e10cSrcweir     @threadsafe yes
1566cdf0e10cSrcweir *//*-*************************************************************************************************************/
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const css::uno::Any & aValue)1567cdf0e10cSrcweir void SAL_CALL Desktop::setFastPropertyValue_NoBroadcast(       sal_Int32        nHandle ,
1568cdf0e10cSrcweir                                                          const css::uno::Any&   aValue  ) throw( css::uno::Exception )
1569cdf0e10cSrcweir {
1570cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1571cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1572cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1573cdf0e10cSrcweir 
1574cdf0e10cSrcweir     switch( nHandle )
1575cdf0e10cSrcweir     {
1576cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO:    aValue >>= m_bSuspendQuickstartVeto;
1577cdf0e10cSrcweir                                                     break;
1578cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER:    aValue >>= m_xDispatchRecorderSupplier;
1579cdf0e10cSrcweir                                                     break;
1580cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_TITLE:    aValue >>= m_sTitle;
1581cdf0e10cSrcweir                                                     break;
1582cdf0e10cSrcweir     }
1583cdf0e10cSrcweir }
1584cdf0e10cSrcweir 
1585cdf0e10cSrcweir /*-************************************************************************************************************//**
1586cdf0e10cSrcweir     @short      get value of a transient property
1587cdf0e10cSrcweir     @descr      This method is calling from helperclass "OPropertySetHelper".
1588cdf0e10cSrcweir                 Don't use this directly!
1589cdf0e10cSrcweir 
1590cdf0e10cSrcweir     @attention  We don't need any mutex or lock here ... We use threadsafe container or methods here only!
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1593cdf0e10cSrcweir 
1594cdf0e10cSrcweir     @param      "nHandle"   handle of property to change
1595cdf0e10cSrcweir     @param      "aValue"    current value of property
1596cdf0e10cSrcweir     @return     -
1597cdf0e10cSrcweir 
1598cdf0e10cSrcweir     @onerror    -
1599cdf0e10cSrcweir     @threadsafe yes
1600cdf0e10cSrcweir *//*-*************************************************************************************************************/
getFastPropertyValue(css::uno::Any & aValue,sal_Int32 nHandle) const1601cdf0e10cSrcweir void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue  ,
1602cdf0e10cSrcweir                                              sal_Int32      nHandle ) const
1603cdf0e10cSrcweir {
1604cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1605cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1606cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir     switch( nHandle )
1609cdf0e10cSrcweir     {
1610cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_ACTIVEFRAME           :   aValue <<= m_aChildTaskContainer.getActive();
1611cdf0e10cSrcweir                                                     break;
1612cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_ISPLUGGED           :   aValue <<= sal_False;
1613cdf0e10cSrcweir                                                     break;
1614cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO:    aValue <<= m_bSuspendQuickstartVeto;
1615cdf0e10cSrcweir                                                     break;
1616cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER:    aValue <<= m_xDispatchRecorderSupplier;
1617cdf0e10cSrcweir                                                     break;
1618cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_TITLE:    aValue <<= m_sTitle;
1619cdf0e10cSrcweir                                                     break;
1620cdf0e10cSrcweir     }
1621cdf0e10cSrcweir }
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir /*-************************************************************************************************************//**
1624cdf0e10cSrcweir     @short      return structure and information about transient properties
1625cdf0e10cSrcweir     @descr      This method is calling from helperclass "OPropertySetHelper".
1626cdf0e10cSrcweir                 Don't use this directly!
1627cdf0e10cSrcweir 
1628cdf0e10cSrcweir     @attention  You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it.
1629cdf0e10cSrcweir                 Because; our baseclass use this mutex to make his code threadsafe. We use our lock!
1630cdf0e10cSrcweir                 So we could have two different mutex/lock mechanism at the same object.
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir     @param      -
1635cdf0e10cSrcweir     @return     structure with property-informations
1636cdf0e10cSrcweir 
1637cdf0e10cSrcweir     @onerror    -
1638cdf0e10cSrcweir     @threadsafe yes
1639cdf0e10cSrcweir *//*-*************************************************************************************************************/
getInfoHelper()1640cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL Desktop::getInfoHelper()
1641cdf0e10cSrcweir {
1642cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1643cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1644cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1645cdf0e10cSrcweir 
1646cdf0e10cSrcweir     // Optimize this method !
1647cdf0e10cSrcweir     // We initialize a static variable only one time. And we don't must use a mutex at every call!
1648cdf0e10cSrcweir     // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
1649cdf0e10cSrcweir     static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL;
1650cdf0e10cSrcweir 
1651cdf0e10cSrcweir     if( pInfoHelper == NULL )
1652cdf0e10cSrcweir     {
1653cdf0e10cSrcweir         // Ready for multithreading
1654cdf0e10cSrcweir         ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
1655cdf0e10cSrcweir         // Control this pointer again, another instance can be faster then these!
1656cdf0e10cSrcweir         if( pInfoHelper == NULL )
1657cdf0e10cSrcweir         {
1658cdf0e10cSrcweir             // Define static member to give structure of properties to baseclass "OPropertySetHelper".
165907a3d7f1SPedro Giffuni             // "impl_getStaticPropertyDescriptor" is a non exported and static function, who will define a static propertytable.
1660cdf0e10cSrcweir             // "sal_True" say: Table is sorted by name.
1661cdf0e10cSrcweir             static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
1662cdf0e10cSrcweir             pInfoHelper = &aInfoHelper;
1663cdf0e10cSrcweir         }
1664cdf0e10cSrcweir     }
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir     return(*pInfoHelper);
1667cdf0e10cSrcweir }
1668cdf0e10cSrcweir 
1669cdf0e10cSrcweir /*-************************************************************************************************************//**
1670cdf0e10cSrcweir     @short      return propertysetinfo
1671cdf0e10cSrcweir     @descr      You can call this method to get information about transient properties
1672cdf0e10cSrcweir                 of this object.
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir     @attention  You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it.
1675cdf0e10cSrcweir                 Because; our baseclass use this mutex to make his code threadsafe. We use our lock!
1676cdf0e10cSrcweir                 So we could have two different mutex/lock mechanism at the same object.
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1679cdf0e10cSrcweir     @seealso    interface XPropertySet
1680cdf0e10cSrcweir     @seealso    interface XMultiPropertySet
1681cdf0e10cSrcweir 
1682cdf0e10cSrcweir     @param      -
1683cdf0e10cSrcweir     @return     reference to object with information [XPropertySetInfo]
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir     @onerror    -
1686cdf0e10cSrcweir     @threadsafe yes
1687cdf0e10cSrcweir *//*-*************************************************************************************************************/
getPropertySetInfo()1688cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException)
1689cdf0e10cSrcweir {
1690cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1691cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1692cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1693cdf0e10cSrcweir 
1694cdf0e10cSrcweir     // Optimize this method !
1695cdf0e10cSrcweir     // We initialize a static variable only one time. And we don't must use a mutex at every call!
1696cdf0e10cSrcweir     // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
1697cdf0e10cSrcweir     static css::uno::Reference< css::beans::XPropertySetInfo >* pInfo = NULL;
1698cdf0e10cSrcweir 
1699cdf0e10cSrcweir     if( pInfo == NULL )
1700cdf0e10cSrcweir     {
1701cdf0e10cSrcweir         // Ready for multithreading
1702cdf0e10cSrcweir         ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
1703cdf0e10cSrcweir         // Control this pointer again, another instance can be faster then these!
1704cdf0e10cSrcweir         if( pInfo == NULL )
1705cdf0e10cSrcweir         {
1706cdf0e10cSrcweir             // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
1707cdf0e10cSrcweir             // (Use method "getInfoHelper()".)
1708cdf0e10cSrcweir             static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1709cdf0e10cSrcweir             pInfo = &xInfo;
1710cdf0e10cSrcweir         }
1711cdf0e10cSrcweir     }
1712cdf0e10cSrcweir 
1713cdf0e10cSrcweir     return (*pInfo);
1714cdf0e10cSrcweir }
1715cdf0e10cSrcweir 
1716cdf0e10cSrcweir /*-************************************************************************************************************//**
1717cdf0e10cSrcweir     @short      return current component of current frame
1718cdf0e10cSrcweir     @descr      The desktop himself has no component. But every frame in subtree.
1719cdf0e10cSrcweir                 If somewhere call getCurrentComponent() at this class, we try to find the right frame and
1720cdf0e10cSrcweir                 then we try to become his component. It can be a VCL-component, the model or the controller
1721cdf0e10cSrcweir                 of founded frame.
1722cdf0e10cSrcweir 
1723cdf0e10cSrcweir     @attention  We don't work on internal member ... so we doesn't need any lock here.
1724cdf0e10cSrcweir 
1725cdf0e10cSrcweir     @seealso    method getCurrentComponent();
1726cdf0e10cSrcweir 
1727cdf0e10cSrcweir     @param      "xFrame", reference to valid frame in hierarchy. Method is not defined for invalid values.
1728cdf0e10cSrcweir                 But we don't check these. Its an IMPL-method and caller must use it right!
1729cdf0e10cSrcweir     @return     A reference to found component.
1730cdf0e10cSrcweir 
1731cdf0e10cSrcweir     @onerror    A null reference is returned.
1732cdf0e10cSrcweir     @threadsafe yes
1733cdf0e10cSrcweir *//*-*************************************************************************************************************/
impl_getFrameComponent(const css::uno::Reference<css::frame::XFrame> & xFrame) const1734cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > Desktop::impl_getFrameComponent( const css::uno::Reference< css::frame::XFrame >& xFrame ) const
1735cdf0e10cSrcweir {
1736cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1737cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1738cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1739cdf0e10cSrcweir 
1740cdf0e10cSrcweir     // Set default return value, if method failed.
1741cdf0e10cSrcweir     css::uno::Reference< css::lang::XComponent > xComponent;
1742cdf0e10cSrcweir     // Does no controller exists?
1743cdf0e10cSrcweir     css::uno::Reference< css::frame::XController > xController = xFrame->getController();
1744cdf0e10cSrcweir     if( xController.is() == sal_False )
1745cdf0e10cSrcweir     {
1746cdf0e10cSrcweir         // Controller not exist - use the VCL-component.
1747cdf0e10cSrcweir         xComponent = css::uno::Reference< css::lang::XComponent >( xFrame->getComponentWindow(), css::uno::UNO_QUERY );
1748cdf0e10cSrcweir     }
1749cdf0e10cSrcweir     else
1750cdf0e10cSrcweir     {
1751cdf0e10cSrcweir         // Does no model exists?
1752cdf0e10cSrcweir         css::uno::Reference< css::frame::XModel > xModel( xController->getModel(), css::uno::UNO_QUERY );
1753cdf0e10cSrcweir         if( xModel.is() == sal_True )
1754cdf0e10cSrcweir         {
1755cdf0e10cSrcweir             // Model exist - use the model as component.
1756cdf0e10cSrcweir             xComponent = css::uno::Reference< css::lang::XComponent >( xModel, css::uno::UNO_QUERY );
1757cdf0e10cSrcweir         }
1758cdf0e10cSrcweir         else
1759cdf0e10cSrcweir         {
1760cdf0e10cSrcweir             // Model not exist - use the controller as component.
1761cdf0e10cSrcweir             xComponent = css::uno::Reference< css::lang::XComponent >( xController, css::uno::UNO_QUERY );
1762cdf0e10cSrcweir         }
1763cdf0e10cSrcweir     }
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir     return xComponent;
1766cdf0e10cSrcweir }
1767cdf0e10cSrcweir 
1768cdf0e10cSrcweir /*-************************************************************************************************************//**
1769cdf0e10cSrcweir     @short      create table with information about properties
1770cdf0e10cSrcweir     @descr      We use a helper class to support properties. These class need some information about this.
1771cdf0e10cSrcweir                 These method create a new static description table with name, type, r/w-flags and so on ...
1772cdf0e10cSrcweir 
1773cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1774cdf0e10cSrcweir     @seealso    method getInfoHelper()
1775cdf0e10cSrcweir 
1776cdf0e10cSrcweir     @param      -
1777cdf0e10cSrcweir     @return     Static table with information about properties.
1778cdf0e10cSrcweir 
1779cdf0e10cSrcweir     @onerror    -
1780cdf0e10cSrcweir     @threadsafe yes
1781cdf0e10cSrcweir *//*-*************************************************************************************************************/
impl_getStaticPropertyDescriptor()1782cdf0e10cSrcweir const css::uno::Sequence< css::beans::Property > Desktop::impl_getStaticPropertyDescriptor()
1783cdf0e10cSrcweir {
1784cdf0e10cSrcweir     // Create a new static property array to initialize sequence!
1785cdf0e10cSrcweir     // Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
1786cdf0e10cSrcweir     // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
1787cdf0e10cSrcweir     // It's necessary for methods of OPropertySetHelper.
1788cdf0e10cSrcweir     // ATTENTION:
1789cdf0e10cSrcweir     //      YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
1790cdf0e10cSrcweir 
1791cdf0e10cSrcweir     static const css::beans::Property pProperties[] =
1792cdf0e10cSrcweir     {
1793cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_ACTIVEFRAME              , DESKTOP_PROPHANDLE_ACTIVEFRAME             , ::getCppuType((const css::uno::Reference< css::lang::XComponent >*)NULL)                , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
1794cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_DISPATCHRECORDERSUPPLIER , DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER, ::getCppuType((const css::uno::Reference< css::frame::XDispatchRecorderSupplier >*)NULL), css::beans::PropertyAttribute::TRANSIENT ),
1795cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_ISPLUGGED                , DESKTOP_PROPHANDLE_ISPLUGGED               , ::getBooleanCppuType()                                                                  , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
1796cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_SUSPENDQUICKSTARTVETO    , DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO   , ::getBooleanCppuType()                                                                  , css::beans::PropertyAttribute::TRANSIENT ),
1797cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_TITLE                    , DESKTOP_PROPHANDLE_TITLE                   , ::getCppuType((const ::rtl::OUString*)NULL)                                             , css::beans::PropertyAttribute::TRANSIENT ),
1798cdf0e10cSrcweir     };
1799cdf0e10cSrcweir     // Use it to initialize sequence!
1800cdf0e10cSrcweir     static const css::uno::Sequence< css::beans::Property > lPropertyDescriptor( pProperties, DESKTOP_PROPCOUNT );
1801cdf0e10cSrcweir     // Return static "PropertyDescriptor"
1802cdf0e10cSrcweir     return lPropertyDescriptor;
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir //=============================================================================
impl_sendQueryTerminationEvent(Desktop::TTerminateListenerList & lCalledListener,::sal_Bool & bVeto)1806cdf0e10cSrcweir void Desktop::impl_sendQueryTerminationEvent(Desktop::TTerminateListenerList& lCalledListener,
1807cdf0e10cSrcweir                                              ::sal_Bool&                      bVeto          )
1808cdf0e10cSrcweir {
1809cdf0e10cSrcweir     bVeto = sal_False;
1810cdf0e10cSrcweir 
1811cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1812cdf0e10cSrcweir 
1813cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ) );
1814cdf0e10cSrcweir     if ( ! pContainer )
1815cdf0e10cSrcweir         return;
1816cdf0e10cSrcweir 
1817cdf0e10cSrcweir     css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
1818cdf0e10cSrcweir 
1819cdf0e10cSrcweir     ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
1820cdf0e10cSrcweir     while ( aIterator.hasMoreElements() )
1821cdf0e10cSrcweir     {
1822cdf0e10cSrcweir         try
1823cdf0e10cSrcweir         {
1824cdf0e10cSrcweir             css::uno::Reference< css::frame::XTerminateListener > xListener(aIterator.next(), css::uno::UNO_QUERY);
1825cdf0e10cSrcweir             if ( ! xListener.is() )
1826cdf0e10cSrcweir                 continue;
1827cdf0e10cSrcweir             xListener->queryTermination( aEvent );
1828cdf0e10cSrcweir             lCalledListener.push_back(xListener);
1829cdf0e10cSrcweir         }
1830cdf0e10cSrcweir         catch( const css::frame::TerminationVetoException& )
1831cdf0e10cSrcweir         {
1832cdf0e10cSrcweir             // first veto will stop notification loop.
1833cdf0e10cSrcweir             bVeto = sal_True;
1834cdf0e10cSrcweir             return;
1835cdf0e10cSrcweir         }
1836cdf0e10cSrcweir         catch( const css::uno::Exception& )
1837cdf0e10cSrcweir         {
1838cdf0e10cSrcweir             // clean up container.
1839cdf0e10cSrcweir             // E.g. dead remote listener objects can make trouble otherwise.
1840cdf0e10cSrcweir             // Iterator implementation allows removing objects during it's used !
1841cdf0e10cSrcweir             aIterator.remove();
1842cdf0e10cSrcweir         }
1843cdf0e10cSrcweir     }
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir 
1846cdf0e10cSrcweir //=============================================================================
impl_sendCancelTerminationEvent(const Desktop::TTerminateListenerList & lCalledListener)1847cdf0e10cSrcweir void Desktop::impl_sendCancelTerminationEvent(const Desktop::TTerminateListenerList& lCalledListener)
1848cdf0e10cSrcweir {
1849cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1850cdf0e10cSrcweir 
1851cdf0e10cSrcweir     css::lang::EventObject                          aEvent( static_cast< ::cppu::OWeakObject* >(this) );
1852cdf0e10cSrcweir     Desktop::TTerminateListenerList::const_iterator pIt;
1853cdf0e10cSrcweir     for (  pIt  = lCalledListener.begin();
1854cdf0e10cSrcweir            pIt != lCalledListener.end  ();
1855cdf0e10cSrcweir          ++pIt                           )
1856cdf0e10cSrcweir     {
1857cdf0e10cSrcweir         try
1858cdf0e10cSrcweir         {
1859cdf0e10cSrcweir             // Note: cancelTermination() is a new and optional interface method !
1860cdf0e10cSrcweir             css::uno::Reference< css::frame::XTerminateListener  > xListener           = *pIt;
1861cdf0e10cSrcweir             css::uno::Reference< css::frame::XTerminateListener2 > xListenerGeneration2(xListener, css::uno::UNO_QUERY);
1862cdf0e10cSrcweir             if ( ! xListenerGeneration2.is() )
1863cdf0e10cSrcweir                 continue;
1864cdf0e10cSrcweir             xListenerGeneration2->cancelTermination( aEvent );
1865cdf0e10cSrcweir         }
1866cdf0e10cSrcweir         catch( const css::uno::Exception& )
1867cdf0e10cSrcweir         {}
1868cdf0e10cSrcweir     }
1869cdf0e10cSrcweir }
1870cdf0e10cSrcweir 
1871cdf0e10cSrcweir //=============================================================================
impl_sendNotifyTerminationEvent()1872cdf0e10cSrcweir void Desktop::impl_sendNotifyTerminationEvent()
1873cdf0e10cSrcweir {
1874cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1875cdf0e10cSrcweir 
1876cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ) );
1877cdf0e10cSrcweir     if ( ! pContainer )
1878cdf0e10cSrcweir         return;
1879cdf0e10cSrcweir 
1880cdf0e10cSrcweir     css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
1881cdf0e10cSrcweir 
1882cdf0e10cSrcweir     ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
1883cdf0e10cSrcweir     while ( aIterator.hasMoreElements() )
1884cdf0e10cSrcweir     {
1885cdf0e10cSrcweir         try
1886cdf0e10cSrcweir         {
1887cdf0e10cSrcweir             css::uno::Reference< css::frame::XTerminateListener > xListener(aIterator.next(), css::uno::UNO_QUERY);
1888cdf0e10cSrcweir             if ( ! xListener.is() )
1889cdf0e10cSrcweir                 continue;
1890cdf0e10cSrcweir             xListener->notifyTermination( aEvent );
1891cdf0e10cSrcweir         }
1892cdf0e10cSrcweir         catch( const css::uno::Exception& )
1893cdf0e10cSrcweir         {
1894cdf0e10cSrcweir             // clean up container.
1895cdf0e10cSrcweir             // E.g. dead remote listener objects can make trouble otherwise.
1896cdf0e10cSrcweir             // Iterator implementation allows removing objects during it's used !
1897cdf0e10cSrcweir             aIterator.remove();
1898cdf0e10cSrcweir         }
1899cdf0e10cSrcweir     }
1900cdf0e10cSrcweir }
1901cdf0e10cSrcweir 
1902cdf0e10cSrcweir //=============================================================================
impl_closeFrames(::sal_Bool bAllowUI)1903cdf0e10cSrcweir ::sal_Bool Desktop::impl_closeFrames(::sal_Bool bAllowUI)
1904cdf0e10cSrcweir {
1905cdf0e10cSrcweir     SYNCHRONIZED_START
1906cdf0e10cSrcweir         ReadGuard aReadLock( m_aLock );
1907cdf0e10cSrcweir         css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > lFrames = m_aChildTaskContainer.getAllElements();
1908cdf0e10cSrcweir         aReadLock.unlock();
1909cdf0e10cSrcweir     SYNCHRONIZED_END
1910cdf0e10cSrcweir 
1911cdf0e10cSrcweir     ::sal_Int32 c                = lFrames.getLength();
1912cdf0e10cSrcweir     ::sal_Int32 i                = 0;
1913cdf0e10cSrcweir     ::sal_Int32 nNonClosedFrames = 0;
1914cdf0e10cSrcweir 
1915cdf0e10cSrcweir     for( i=0; i<c; ++i )
1916cdf0e10cSrcweir     {
1917cdf0e10cSrcweir         try
1918cdf0e10cSrcweir         {
1919cdf0e10cSrcweir             css::uno::Reference< css::frame::XFrame > xFrame = lFrames[i];
1920cdf0e10cSrcweir 
1921cdf0e10cSrcweir             // XController.suspend() will show an UI ...
1922cdf0e10cSrcweir             // Use it in case it was allowed from outside only.
1923cdf0e10cSrcweir             sal_Bool                                       bSuspended = sal_False;
1924cdf0e10cSrcweir             css::uno::Reference< css::frame::XController > xController( xFrame->getController(), css::uno::UNO_QUERY );
1925cdf0e10cSrcweir             if (
1926cdf0e10cSrcweir                 ( bAllowUI         ) &&
1927cdf0e10cSrcweir                 ( xController.is() )
1928cdf0e10cSrcweir                )
1929cdf0e10cSrcweir             {
1930cdf0e10cSrcweir                 bSuspended = xController->suspend( sal_True );
1931cdf0e10cSrcweir                 if ( ! bSuspended )
1932cdf0e10cSrcweir                 {
1933cdf0e10cSrcweir                     ++nNonClosedFrames;
1934cdf0e10cSrcweir                     continue;
1935cdf0e10cSrcweir                 }
1936cdf0e10cSrcweir             }
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir             // Try to close frame (in case no UI was allowed without calling XController->suspend() before!)
1939cdf0e10cSrcweir             // But don't deliver ownership to any other one!
1940cdf0e10cSrcweir             // This method can be called again.
1941cdf0e10cSrcweir             css::uno::Reference< css::util::XCloseable > xClose( xFrame, css::uno::UNO_QUERY );
1942cdf0e10cSrcweir             if ( xClose.is() )
1943cdf0e10cSrcweir             {
1944cdf0e10cSrcweir                 try
1945cdf0e10cSrcweir                 {
1946cdf0e10cSrcweir                     xClose->close(sal_False);
1947cdf0e10cSrcweir                 }
1948cdf0e10cSrcweir                 catch(const css::util::CloseVetoException&)
1949cdf0e10cSrcweir                 {
1950cdf0e10cSrcweir                     // Any internal process of this frame disagree with our request.
1951cdf0e10cSrcweir                     // Safe this state but dont break these loop. Other frames has to be closed!
1952cdf0e10cSrcweir                     ++nNonClosedFrames;
1953cdf0e10cSrcweir 
1954cdf0e10cSrcweir                     // Reactivate controller.
1955cdf0e10cSrcweir                     // It can happen that XController.suspend() returned true ... but a registered close listener
1956cdf0e10cSrcweir                     // throwed these veto exception. Then the controller has to be reactivated. Otherwise
195707a3d7f1SPedro Giffuni                     // these document doesn't work any more.
1958cdf0e10cSrcweir                     if (
1959cdf0e10cSrcweir                         (bSuspended      ) &&
1960cdf0e10cSrcweir                         (xController.is())
1961cdf0e10cSrcweir                        )
1962cdf0e10cSrcweir                         xController->suspend(sal_False);
1963cdf0e10cSrcweir                 }
1964cdf0e10cSrcweir 
1965cdf0e10cSrcweir                 // If interface XClosable interface exists and was used ...
1966cdf0e10cSrcweir                 // it's not allowed to use XComponent->dispose() also !
1967cdf0e10cSrcweir                 continue;
1968cdf0e10cSrcweir             }
1969cdf0e10cSrcweir 
1970cdf0e10cSrcweir             // XClosable not supported ?
1971cdf0e10cSrcweir             // Then we have to dispose these frame hardly.
1972cdf0e10cSrcweir             css::uno::Reference< css::lang::XComponent > xDispose( xFrame, css::uno::UNO_QUERY );
1973cdf0e10cSrcweir             if ( xDispose.is() )
1974cdf0e10cSrcweir                 xDispose->dispose();
1975cdf0e10cSrcweir 
1976cdf0e10cSrcweir             // Don't remove these frame from our child container!
1977cdf0e10cSrcweir             // A frame do it by itself inside close()/dispose() method.
1978cdf0e10cSrcweir         }
1979cdf0e10cSrcweir         catch(const css::lang::DisposedException&)
1980cdf0e10cSrcweir         {
1981cdf0e10cSrcweir             // Dispose frames are closed frames.
1982cdf0e10cSrcweir             // So we can count it here .-)
1983cdf0e10cSrcweir         }
1984cdf0e10cSrcweir     }
1985cdf0e10cSrcweir 
1986cdf0e10cSrcweir     return (nNonClosedFrames < 1);
1987cdf0e10cSrcweir }
1988cdf0e10cSrcweir 
1989cdf0e10cSrcweir //_________________________________________________________________________________________________________________
1990cdf0e10cSrcweir //  debug methods
1991cdf0e10cSrcweir //_________________________________________________________________________________________________________________
1992cdf0e10cSrcweir 
1993cdf0e10cSrcweir /*-----------------------------------------------------------------------------------------------------------------
1994cdf0e10cSrcweir     The follow methods checks the parameter for other functions. If a parameter or his value is non valid,
1995cdf0e10cSrcweir     we return "sal_True". (otherwise sal_False) This mechanism is used to throw an ASSERT!
1996cdf0e10cSrcweir -----------------------------------------------------------------------------------------------------------------*/
1997cdf0e10cSrcweir 
1998cdf0e10cSrcweir #ifdef ENABLE_ASSERTIONS
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir //*****************************************************************************************************************
2001cdf0e10cSrcweir //  We work with valid servicemanager only.
implcp_ctor(const css::uno::Reference<css::lang::XMultiServiceFactory> & xFactory)2002cdf0e10cSrcweir sal_Bool Desktop::implcp_ctor( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
2003cdf0e10cSrcweir {
2004cdf0e10cSrcweir     return(
2005cdf0e10cSrcweir             ( &xFactory     ==  NULL        )   ||
2006cdf0e10cSrcweir             ( xFactory.is() ==  sal_False   )
2007cdf0e10cSrcweir           );
2008cdf0e10cSrcweir }
2009cdf0e10cSrcweir 
2010cdf0e10cSrcweir //*****************************************************************************************************************
2011cdf0e10cSrcweir //  We work with valid listener only.
implcp_addEventListener(const css::uno::Reference<css::lang::XEventListener> & xListener)2012cdf0e10cSrcweir sal_Bool Desktop::implcp_addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
2013cdf0e10cSrcweir {
2014cdf0e10cSrcweir     return(
2015cdf0e10cSrcweir             ( &xListener        ==  NULL        )   ||
2016cdf0e10cSrcweir             ( xListener.is()    ==  sal_False   )
2017cdf0e10cSrcweir           );
2018cdf0e10cSrcweir }
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir //*****************************************************************************************************************
2021cdf0e10cSrcweir //  We work with valid listener only.
implcp_removeEventListener(const css::uno::Reference<css::lang::XEventListener> & xListener)2022cdf0e10cSrcweir sal_Bool Desktop::implcp_removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
2023cdf0e10cSrcweir {
2024cdf0e10cSrcweir     return(
2025cdf0e10cSrcweir             ( &xListener        ==  NULL        )   ||
2026cdf0e10cSrcweir             ( xListener.is()    ==  sal_False   )
2027cdf0e10cSrcweir           );
2028cdf0e10cSrcweir }
2029cdf0e10cSrcweir 
2030cdf0e10cSrcweir #endif  // #ifdef ENABLE_ASSERTIONS
2031cdf0e10cSrcweir 
2032cdf0e10cSrcweir }   // namespace framework
203353c84c60Smseidel 
203453c84c60Smseidel /* vim: set noet sw=4 ts=4: */
2035