Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <time.h>
21 : : #include <sfx2/sfxbasecontroller.hxx>
22 : :
23 : : #include <com/sun/star/awt/KeyEvent.hpp>
24 : : #include <com/sun/star/awt/KeyModifier.hpp>
25 : : #include <com/sun/star/awt/MouseEvent.hpp>
26 : : #include <com/sun/star/awt/MouseButton.hpp>
27 : : #include <com/sun/star/util/XCloseable.hpp>
28 : : #include <com/sun/star/util/XCloseBroadcaster.hpp>
29 : : #include <com/sun/star/util/XCloseListener.hpp>
30 : : #include <com/sun/star/util/CloseVetoException.hpp>
31 : : #include <com/sun/star/document/XViewDataSupplier.hpp>
32 : : #include <cppuhelper/implbase1.hxx>
33 : : #include <cppuhelper/implbase2.hxx>
34 : : #include <com/sun/star/frame/FrameActionEvent.hpp>
35 : : #include <com/sun/star/frame/FrameAction.hpp>
36 : : #include <com/sun/star/frame/CommandGroup.hpp>
37 : : #include <com/sun/star/frame/XFrame.hpp>
38 : : #include <com/sun/star/frame/XBorderResizeListener.hpp>
39 : : #include <com/sun/star/lang/DisposedException.hpp>
40 : : #include <com/sun/star/lang/EventObject.hpp>
41 : : #include <com/sun/star/lang/XEventListener.hpp>
42 : : #include <com/sun/star/lang/XComponent.hpp>
43 : : #include <com/sun/star/container/XIndexAccess.hpp>
44 : : #include <cppuhelper/interfacecontainer.hxx>
45 : : #include <cppuhelper/typeprovider.hxx>
46 : : #include <basic/sbstar.hxx>
47 : : #include <uno/mapping.hxx>
48 : : #include <sfx2/viewsh.hxx>
49 : : #include <sfx2/docfac.hxx>
50 : : #include <sfx2/viewfrm.hxx>
51 : : #include <sfx2/objsh.hxx>
52 : : #include <sfx2/app.hxx>
53 : : #include <sfx2/msgpool.hxx>
54 : : #include <sfx2/dispatch.hxx>
55 : : #include <sfx2/userinputinterception.hxx>
56 : :
57 : : #include <viewimp.hxx>
58 : : #include <sfx2/unoctitm.hxx>
59 : : #include <sfx2/childwin.hxx>
60 : : #include <sfx2/sfxsids.hrc>
61 : : #include <workwin.hxx>
62 : : #include <sfx2/objface.hxx>
63 : :
64 : : #include <osl/mutex.hxx>
65 : : #include <tools/diagnose_ex.h>
66 : : #include <comphelper/sequence.hxx>
67 : : #include <rtl/ustrbuf.hxx>
68 : : #include <toolkit/helper/convert.hxx>
69 : : #include <framework/titlehelper.hxx>
70 : : #include <comphelper/processfactory.hxx>
71 : :
72 : : #include <boost/unordered_map.hpp>
73 : :
74 : : #include <sfx2/event.hxx>
75 : : #include "sfx2/viewfac.hxx"
76 : :
77 : : #define OMULTITYPEINTERFACECONTAINERHELPER ::cppu::OMultiTypeInterfaceContainerHelper
78 : : #define OINTERFACECONTAINERHELPER ::cppu::OInterfaceContainerHelper
79 : : #define XCLOSELISTENER ::com::sun::star::util::XCloseListener
80 : : #define FRAMEACTIONEVENT ::com::sun::star::frame::FrameActionEvent
81 : : #define EVENTOBJECT ::com::sun::star::lang::EventObject
82 : : #define OTYPECOLLECTION ::cppu::OTypeCollection
83 : : #define OIMPLEMENTATIONID ::cppu::OImplementationId
84 : : #define XCOMPONENT ::com::sun::star::lang::XComponent
85 : : #define XINTERFACE ::com::sun::star::uno::XInterface
86 : : #define XKEYHANDLER ::com::sun::star::awt::XKeyHandler
87 : :
88 : : #define TIMEOUT_START_RESCHEDULE 10L /* 10th s */
89 : :
90 : : using namespace ::com::sun::star;
91 : : using ::com::sun::star::uno::Reference;
92 : : using ::com::sun::star::uno::RuntimeException;
93 : : using ::com::sun::star::uno::UNO_QUERY_THROW;
94 : : using ::com::sun::star::uno::UNO_SET_THROW;
95 : : using ::com::sun::star::lang::DisposedException;
96 : : using ::com::sun::star::awt::XWindow;
97 : : using ::com::sun::star::frame::XController;
98 : : using ::com::sun::star::frame::XDispatchProvider;
99 : : using ::com::sun::star::document::XViewDataSupplier;
100 : : using ::com::sun::star::container::XIndexAccess;
101 : : using ::com::sun::star::beans::PropertyValue;
102 : : using ::com::sun::star::uno::Sequence;
103 : : using ::com::sun::star::uno::UNO_QUERY;
104 : : using ::com::sun::star::uno::Exception;
105 : : using ::com::sun::star::frame::XFrame;
106 : : using ::com::sun::star::frame::XFrameActionListener;
107 : : using ::com::sun::star::util::XCloseListener;
108 : : using ::com::sun::star::task::XStatusIndicator;
109 : : using ::com::sun::star::frame::XTitle;
110 : : namespace css = ::com::sun::star;
111 : :
112 : : struct GroupIDToCommandGroup
113 : : {
114 : : sal_Int16 nGroupID;
115 : : sal_Int16 nCommandGroup;
116 : : };
117 : :
118 : : // Please update when a new command group is added
119 : : const sal_Int16 MAX_COMMANDGROUP = com::sun::star::frame::CommandGroup::CONTROLS;
120 : :
121 : : static sal_Bool bGroupIDMapInitialized = sal_False;
122 : : static GroupIDToCommandGroup GroupIDCommandGroupMap[] =
123 : : {
124 : : { GID_INTERN , com::sun::star::frame::CommandGroup::INTERNAL },
125 : : { GID_APPLICATION , com::sun::star::frame::CommandGroup::APPLICATION },
126 : : { GID_DOCUMENT , com::sun::star::frame::CommandGroup::DOCUMENT },
127 : : { GID_VIEW , com::sun::star::frame::CommandGroup::VIEW },
128 : : { GID_EDIT , com::sun::star::frame::CommandGroup::EDIT },
129 : : { GID_MACRO , com::sun::star::frame::CommandGroup::MACRO },
130 : : { GID_OPTIONS , com::sun::star::frame::CommandGroup::OPTIONS },
131 : : { GID_MATH , com::sun::star::frame::CommandGroup::MATH },
132 : : { GID_NAVIGATOR , com::sun::star::frame::CommandGroup::NAVIGATOR },
133 : : { GID_INSERT , com::sun::star::frame::CommandGroup::INSERT },
134 : : { GID_FORMAT , com::sun::star::frame::CommandGroup::FORMAT },
135 : : { GID_TEMPLATE , com::sun::star::frame::CommandGroup::TEMPLATE },
136 : : { GID_TEXT , com::sun::star::frame::CommandGroup::TEXT },
137 : : { GID_FRAME , com::sun::star::frame::CommandGroup::FRAME },
138 : : { GID_GRAPHIC , com::sun::star::frame::CommandGroup::GRAPHIC },
139 : : { GID_TABLE , com::sun::star::frame::CommandGroup::TABLE },
140 : : { GID_ENUMERATION , com::sun::star::frame::CommandGroup::ENUMERATION },
141 : : { GID_DATA , com::sun::star::frame::CommandGroup::DATA },
142 : : { GID_SPECIAL , com::sun::star::frame::CommandGroup::SPECIAL },
143 : : { GID_IMAGE , com::sun::star::frame::CommandGroup::IMAGE },
144 : : { GID_CHART , com::sun::star::frame::CommandGroup::CHART },
145 : : { GID_EXPLORER , com::sun::star::frame::CommandGroup::EXPLORER },
146 : : { GID_CONNECTOR , com::sun::star::frame::CommandGroup::CONNECTOR },
147 : : { GID_MODIFY , com::sun::star::frame::CommandGroup::MODIFY },
148 : : { GID_DRAWING , com::sun::star::frame::CommandGroup::DRAWING },
149 : : { GID_CONTROLS , com::sun::star::frame::CommandGroup::CONTROLS },
150 : : { 0 , 0 }
151 : : };
152 : :
153 : : typedef boost::unordered_map< sal_Int16, sal_Int16 > GroupHashMap;
154 : :
155 : :
156 : 0 : sal_Int16 MapGroupIDToCommandGroup( sal_Int16 nGroupID )
157 : : {
158 [ # # ][ # # ]: 0 : static GroupHashMap mHashMap;
[ # # ][ # # ]
159 : :
160 [ # # ]: 0 : if ( !bGroupIDMapInitialized )
161 : : {
162 : 0 : sal_Int32 i = 0;
163 [ # # ]: 0 : while ( GroupIDCommandGroupMap[i].nGroupID != 0 )
164 : : {
165 : : mHashMap.insert( GroupHashMap::value_type(
166 : : GroupIDCommandGroupMap[i].nGroupID,
167 [ # # ][ # # ]: 0 : GroupIDCommandGroupMap[i].nCommandGroup ));
168 : 0 : ++i;
169 : : }
170 : 0 : bGroupIDMapInitialized = sal_True;
171 : : }
172 : :
173 [ # # ]: 0 : GroupHashMap::const_iterator pIter = mHashMap.find( nGroupID );
174 [ # # ][ # # ]: 0 : if ( pIter != mHashMap.end() )
175 [ # # ]: 0 : return pIter->second;
176 : : else
177 : 0 : return com::sun::star::frame::CommandGroup::INTERNAL;
178 : : }
179 : :
180 : 346 : sal_uInt32 Get10ThSec()
181 : : {
182 : 346 : sal_uInt32 n10Ticks = 10 * (sal_uInt32)clock();
183 : 346 : return n10Ticks / CLOCKS_PER_SEC;
184 : : }
185 : :
186 : : sal_Int32 m_nInReschedule = 0; /// static counter for rescheduling
187 : :
188 : 0 : void reschedule()
189 : : {
190 [ # # ]: 0 : if ( m_nInReschedule == 0 )
191 : : {
192 : 0 : ++m_nInReschedule;
193 : 0 : Application::Reschedule();
194 : 0 : --m_nInReschedule;
195 : : }
196 : 0 : }
197 : :
198 [ # # ]: 0 : class SfxStatusIndicator : public ::cppu::WeakImplHelper2< ::com::sun::star::task::XStatusIndicator, ::com::sun::star::lang::XEventListener >
199 : : {
200 : : friend class SfxBaseController;
201 : : ::com::sun::star::uno::Reference < XController > xOwner;
202 : : ::com::sun::star::uno::Reference < ::com::sun::star::task::XStatusIndicator > xProgress;
203 : : SfxWorkWindow* pWorkWindow;
204 : : sal_Int32 _nRange;
205 : : sal_Int32 _nValue;
206 : : long _nStartTime;
207 : : public:
208 : 0 : SfxStatusIndicator(SfxBaseController* pController, SfxWorkWindow* pWork)
209 : : : xOwner( pController )
210 [ # # ][ # # ]: 0 : , pWorkWindow( pWork )
211 : : {
212 : 0 : ++m_refCount;
213 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComponent(
214 [ # # ]: 0 : (static_cast< ::cppu::OWeakObject* >(pController)), ::com::sun::star::uno::UNO_QUERY );
215 [ # # ]: 0 : if (xComponent.is())
216 [ # # ][ # # ]: 0 : xComponent->addEventListener(this);
[ # # ]
217 : 0 : --m_refCount;
218 : 0 : }
219 : :
220 : : virtual void SAL_CALL start(const ::rtl::OUString& aText, sal_Int32 nRange) throw(::com::sun::star::uno::RuntimeException);
221 : : virtual void SAL_CALL end(void) throw(::com::sun::star::uno::RuntimeException);
222 : : virtual void SAL_CALL setText(const ::rtl::OUString& aText) throw(::com::sun::star::uno::RuntimeException);
223 : : virtual void SAL_CALL setValue(sal_Int32 nValue) throw(::com::sun::star::uno::RuntimeException);
224 : : virtual void SAL_CALL reset() throw(::com::sun::star::uno::RuntimeException);
225 : :
226 : : virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
227 : : };
228 : :
229 : 0 : void SAL_CALL SfxStatusIndicator::start(const ::rtl::OUString& aText, sal_Int32 nRange) throw(::com::sun::star::uno::RuntimeException)
230 : : {
231 [ # # ]: 0 : SolarMutexGuard aGuard;
232 [ # # ]: 0 : if ( xOwner.is() )
233 : : {
234 : 0 : _nRange = nRange;
235 : 0 : _nValue = 0;
236 : :
237 [ # # ]: 0 : if ( !xProgress.is() )
238 [ # # ][ # # ]: 0 : xProgress = pWorkWindow->GetStatusIndicator();
239 : :
240 [ # # ]: 0 : if ( xProgress.is() )
241 [ # # ][ # # ]: 0 : xProgress->start( aText, nRange );
242 : :
243 : 0 : _nStartTime = Get10ThSec();
244 [ # # ]: 0 : reschedule();
245 [ # # ]: 0 : }
246 : 0 : }
247 : :
248 : 0 : void SAL_CALL SfxStatusIndicator::end(void) throw(::com::sun::star::uno::RuntimeException)
249 : : {
250 [ # # ]: 0 : SolarMutexGuard aGuard;
251 [ # # ]: 0 : if ( xOwner.is() )
252 : : {
253 [ # # ]: 0 : if ( !xProgress.is() )
254 [ # # ][ # # ]: 0 : xProgress = pWorkWindow->GetStatusIndicator();
255 : :
256 [ # # ]: 0 : if ( xProgress.is() )
257 [ # # ][ # # ]: 0 : xProgress->end();
258 : :
259 [ # # ]: 0 : reschedule();
260 [ # # ]: 0 : }
261 : 0 : }
262 : :
263 : 0 : void SAL_CALL SfxStatusIndicator::setText(const ::rtl::OUString& aText) throw(::com::sun::star::uno::RuntimeException)
264 : : {
265 [ # # ]: 0 : SolarMutexGuard aGuard;
266 [ # # ]: 0 : if ( xOwner.is() )
267 : : {
268 [ # # ]: 0 : if ( !xProgress.is() )
269 [ # # ][ # # ]: 0 : xProgress = pWorkWindow->GetStatusIndicator();
270 : :
271 [ # # ]: 0 : if ( xProgress.is() )
272 [ # # ][ # # ]: 0 : xProgress->setText( aText );
273 : :
274 [ # # ]: 0 : reschedule();
275 [ # # ]: 0 : }
276 : 0 : }
277 : :
278 : 0 : void SAL_CALL SfxStatusIndicator::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException)
279 : : {
280 [ # # ]: 0 : SolarMutexGuard aGuard;
281 [ # # ]: 0 : if ( xOwner.is() )
282 : : {
283 : 0 : _nValue = nValue;
284 : :
285 [ # # ]: 0 : if ( !xProgress.is() )
286 [ # # ][ # # ]: 0 : xProgress = pWorkWindow->GetStatusIndicator();
287 : :
288 [ # # ]: 0 : if ( xProgress.is() )
289 [ # # ][ # # ]: 0 : xProgress->setValue( nValue );
290 : :
291 : 0 : sal_Bool bReschedule = (( Get10ThSec() - _nStartTime ) > TIMEOUT_START_RESCHEDULE );
292 [ # # ]: 0 : if ( bReschedule )
293 [ # # ]: 0 : reschedule();
294 [ # # ]: 0 : }
295 : 0 : }
296 : :
297 : 0 : void SAL_CALL SfxStatusIndicator::reset() throw(::com::sun::star::uno::RuntimeException)
298 : : {
299 [ # # ]: 0 : SolarMutexGuard aGuard;
300 [ # # ]: 0 : if ( xOwner.is() )
301 : : {
302 [ # # ]: 0 : if ( !xProgress.is() )
303 [ # # ][ # # ]: 0 : xProgress = pWorkWindow->GetStatusIndicator();
304 : :
305 [ # # ]: 0 : if ( xProgress.is() )
306 [ # # ][ # # ]: 0 : xProgress->reset();
307 : :
308 [ # # ]: 0 : reschedule();
309 [ # # ]: 0 : }
310 : 0 : }
311 : :
312 : 0 : void SAL_CALL SfxStatusIndicator::disposing( const com::sun::star::lang::EventObject& /*Source*/ ) throw(::com::sun::star::uno::RuntimeException)
313 : : {
314 [ # # ]: 0 : SolarMutexGuard aGuard;
315 [ # # ]: 0 : xOwner = 0;
316 [ # # ]: 0 : xProgress.clear();
317 : 0 : }
318 : :
319 : : //________________________________________________________________________________________________________
320 : : // declaration IMPL_SfxBaseController_ListenerHelper
321 : : //________________________________________________________________________________________________________
322 : :
323 : : class IMPL_SfxBaseController_ListenerHelper : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XFrameActionListener >
324 : : {
325 : : public:
326 : : IMPL_SfxBaseController_ListenerHelper( SfxBaseController* pController ) ;
327 : : virtual ~IMPL_SfxBaseController_ListenerHelper() ;
328 : : virtual void SAL_CALL frameAction( const FRAMEACTIONEVENT& aEvent ) throw (RUNTIMEEXCEPTION) ;
329 : : virtual void SAL_CALL disposing( const EVENTOBJECT& aEvent ) throw (RUNTIMEEXCEPTION) ;
330 : :
331 : : private:
332 : :
333 : : SfxBaseController* m_pController ;
334 : :
335 : : } ; // class IMPL_SfxBaseController_ListenerContainer
336 : :
337 : : class IMPL_SfxBaseController_CloseListenerHelper : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XCloseListener >
338 : : {
339 : : public:
340 : : IMPL_SfxBaseController_CloseListenerHelper( SfxBaseController* pController ) ;
341 : : virtual ~IMPL_SfxBaseController_CloseListenerHelper() ;
342 : : virtual void SAL_CALL queryClosing( const EVENTOBJECT& aEvent, sal_Bool bDeliverOwnership )
343 : : throw (RUNTIMEEXCEPTION, com::sun::star::util::CloseVetoException) ;
344 : : virtual void SAL_CALL notifyClosing( const EVENTOBJECT& aEvent ) throw (RUNTIMEEXCEPTION) ;
345 : : virtual void SAL_CALL disposing( const EVENTOBJECT& aEvent ) throw (RUNTIMEEXCEPTION) ;
346 : :
347 : : private:
348 : :
349 : : SfxBaseController* m_pController;
350 : :
351 : : } ; // class IMPL_SfxBaseController_ListenerContainer
352 : :
353 : 1727 : IMPL_SfxBaseController_CloseListenerHelper::IMPL_SfxBaseController_CloseListenerHelper( SfxBaseController* pController )
354 : 1727 : : m_pController ( pController )
355 : : {
356 : 1727 : }
357 : :
358 : 1428 : IMPL_SfxBaseController_CloseListenerHelper::~IMPL_SfxBaseController_CloseListenerHelper()
359 : : {
360 [ - + ]: 2856 : }
361 : :
362 : 0 : void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::disposing( const EVENTOBJECT& /*aEvent*/ ) throw( ::com::sun::star::uno::RuntimeException )
363 : : {
364 : 0 : }
365 : :
366 : 3230 : void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::queryClosing( const EVENTOBJECT& aEvent, sal_Bool bDeliverOwnership )
367 : : throw (RUNTIMEEXCEPTION, com::sun::star::util::CloseVetoException)
368 : : {
369 [ + - ]: 3230 : SolarMutexGuard aGuard;
370 [ + - ]: 3230 : SfxViewShell* pShell = m_pController->GetViewShell_Impl();
371 [ + - ][ + - ]: 3230 : if ( m_pController != NULL && pShell )
372 : : {
373 [ + - ]: 3230 : sal_Bool bCanClose = (sal_Bool) pShell->PrepareClose( sal_False );
374 [ - + ]: 3230 : if ( !bCanClose )
375 : : {
376 [ # # ][ # # ]: 0 : if ( bDeliverOwnership && ( !pShell->GetWindow() || !pShell->GetWindow()->IsReallyVisible() ) )
[ # # ][ # # ]
[ # # ]
377 : : {
378 : : // ignore OwnerShip in case of visible frame (will be closed by user)
379 [ # # ]: 0 : uno::Reference < frame::XModel > xModel( aEvent.Source, uno::UNO_QUERY );
380 [ # # ]: 0 : if ( xModel.is() )
381 [ # # ]: 0 : pShell->TakeOwnerShip_Impl();
382 : : else
383 [ # # ]: 0 : pShell->TakeFrameOwnerShip_Impl();
384 : : }
385 : :
386 [ # # ][ # # ]: 0 : throw com::sun::star::util::CloseVetoException(::rtl::OUString("Controller disagree ..."),static_cast< ::cppu::OWeakObject*>(this));
387 : : }
388 [ + - ]: 3230 : }
389 : 3230 : }
390 : :
391 : 1612 : void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::notifyClosing( const EVENTOBJECT& /*aEvent*/ ) throw (RUNTIMEEXCEPTION)
392 : : {
393 : 1612 : }
394 : :
395 : : //________________________________________________________________________________________________________
396 : : // declaration IMPL_SfxBaseController_DataContainer
397 : : //________________________________________________________________________________________________________
398 : :
399 [ + - ][ + - ]: 1428 : struct IMPL_SfxBaseController_DataContainer
[ + - ][ + - ]
400 : : {
401 : : Reference< XFrame > m_xFrame ;
402 : : Reference< XFrameActionListener > m_xListener ;
403 : : Reference< XCloseListener > m_xCloseListener ;
404 : : ::sfx2::UserInputInterception m_aUserInputInterception;
405 : : OMULTITYPEINTERFACECONTAINERHELPER m_aListenerContainer ;
406 : : OINTERFACECONTAINERHELPER m_aInterceptorContainer ;
407 : : Reference< XStatusIndicator > m_xIndicator ;
408 : : SfxViewShell* m_pViewShell ;
409 : : SfxBaseController* m_pController ;
410 : : sal_Bool m_bDisposing ;
411 : : sal_Bool m_bSuspendState ;
412 : : Reference< XTitle > m_xTitleHelper ;
413 : : Sequence< PropertyValue > m_aCreationArgs ;
414 : :
415 : 1727 : IMPL_SfxBaseController_DataContainer( MUTEX& aMutex ,
416 : : SfxViewShell* pViewShell ,
417 : : SfxBaseController* pController )
418 [ + - ]: 1727 : : m_xListener ( new IMPL_SfxBaseController_ListenerHelper( pController ) )
419 [ + - ]: 1727 : , m_xCloseListener ( new IMPL_SfxBaseController_CloseListenerHelper( pController ) )
420 : : , m_aUserInputInterception ( *pController, aMutex )
421 : : , m_aListenerContainer ( aMutex )
422 : : , m_aInterceptorContainer ( aMutex )
423 : : , m_pViewShell ( pViewShell )
424 : : , m_pController ( pController )
425 : : , m_bDisposing ( sal_False )
426 [ + - ][ + - ]: 5181 : , m_bSuspendState ( sal_False )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
427 : : {
428 : 1727 : }
429 : :
430 : : } ; // struct IMPL_SfxBaseController_DataContainer
431 : :
432 : : //________________________________________________________________________________________________________
433 : : // IMPL_SfxBaseController_ListenerHelper constructor
434 : : //________________________________________________________________________________________________________
435 : :
436 : 1727 : IMPL_SfxBaseController_ListenerHelper::IMPL_SfxBaseController_ListenerHelper( SfxBaseController* pController )
437 : 1727 : : m_pController ( pController )
438 : : {
439 : 1727 : }
440 : :
441 : : //________________________________________________________________________________________________________
442 : : // IMPL_SfxBaseController_ListenerHelper destructor
443 : : //________________________________________________________________________________________________________
444 : :
445 : 1428 : IMPL_SfxBaseController_ListenerHelper::~IMPL_SfxBaseController_ListenerHelper()
446 : : {
447 [ - + ]: 2856 : }
448 : :
449 : 4112 : void SAL_CALL IMPL_SfxBaseController_ListenerHelper::frameAction( const FRAMEACTIONEVENT& aEvent ) throw( RUNTIMEEXCEPTION )
450 : : {
451 [ + - ]: 4112 : SolarMutexGuard aGuard;
452 [ + - ][ + - ]: 20560 : if (
[ + - + - ]
[ + - ]
453 : : ( m_pController != NULL ) &&
454 [ + - ][ + - ]: 8224 : ( aEvent.Frame == m_pController->getFrame() ) &&
[ + - ][ # # ]
455 [ + - ][ + - ]: 8224 : ( m_pController->GetViewShell_Impl() && m_pController->GetViewShell_Impl()->GetWindow() != NULL )
456 : : )
457 : : {
458 [ + + ]: 4112 : if ( aEvent.Action == ::com::sun::star::frame::FrameAction_FRAME_UI_ACTIVATED )
459 : : {
460 [ + - ][ + - ]: 1114 : if ( !m_pController->GetViewShell_Impl()->GetUIActiveIPClient_Impl() )
[ + - ]
461 [ + - ][ + - ]: 1114 : m_pController->GetViewShell_Impl()->GetViewFrame()->MakeActive_Impl( sal_False );
462 : : }
463 [ - + ]: 2998 : else if ( aEvent.Action == ::com::sun::star::frame::FrameAction_CONTEXT_CHANGED )
464 : : {
465 [ # # ][ # # ]: 0 : m_pController->GetViewShell_Impl()->GetViewFrame()->GetBindings().ContextChanged_Impl();
466 : : }
467 [ + - ]: 4112 : }
468 : 4112 : }
469 : :
470 : : //________________________________________________________________________________________________________
471 : : // IMPL_SfxBaseController_ListenerHelper -> XEventListener
472 : : //________________________________________________________________________________________________________
473 : :
474 : 1636 : void SAL_CALL IMPL_SfxBaseController_ListenerHelper::disposing( const EVENTOBJECT& /*aEvent*/ ) throw( ::com::sun::star::uno::RuntimeException )
475 : : {
476 [ + - ]: 1636 : SolarMutexGuard aGuard;
477 [ + - ][ + - ]: 1636 : if ( m_pController && m_pController->getFrame().is() )
[ - + ][ + - ]
[ - + # # ]
478 [ # # ][ # # ]: 1636 : m_pController->getFrame()->removeFrameActionListener( this ) ;
[ # # ][ # # ]
[ + - ]
479 : 1636 : }
480 : :
481 : : //________________________________________________________________________________________________________
482 : : // SfxBaseController -> constructor
483 : : //________________________________________________________________________________________________________
484 : : DBG_NAME(sfx2_SfxBaseController)
485 : 1727 : SfxBaseController::SfxBaseController( SfxViewShell* pViewShell )
486 [ + - ][ + - ]: 1727 : : m_pData ( new IMPL_SfxBaseController_DataContainer( m_aMutex, pViewShell, this ))
[ + - ]
487 : : {
488 : : DBG_CTOR(sfx2_SfxBaseController,NULL);
489 [ + - ]: 1727 : m_pData->m_pViewShell->SetController( this );
490 : 1727 : }
491 : :
492 : : //________________________________________________________________________________________________________
493 : : // SfxBaseController -> destructor
494 : : //________________________________________________________________________________________________________
495 : :
496 [ + - ]: 1428 : SfxBaseController::~SfxBaseController()
497 : : {
498 : : DBG_DTOR(sfx2_SfxBaseController,NULL);
499 [ + - ][ + - ]: 1428 : delete m_pData;
500 [ - + ]: 1462 : }
501 : :
502 : : //________________________________________________________________________________________________________
503 : : // SfxBaseController -> XController2
504 : : //________________________________________________________________________________________________________
505 : :
506 : 1727 : Reference< XWindow > SAL_CALL SfxBaseController::getComponentWindow() throw (RuntimeException)
507 : : {
508 [ + - ]: 1727 : SolarMutexGuard aGuard;
509 [ - + ]: 1727 : if ( !m_pData->m_pViewShell )
510 [ # # ]: 0 : throw DisposedException();
511 : :
512 [ + - ][ + - ]: 1727 : return Reference< XWindow >( GetViewFrame_Impl().GetFrame().GetWindow().GetComponentInterface(), UNO_QUERY_THROW );
[ + - ][ + - ]
[ + - ][ + - ]
513 : : }
514 : :
515 : 0 : ::rtl::OUString SAL_CALL SfxBaseController::getViewControllerName() throw (RuntimeException)
516 : : {
517 [ # # ]: 0 : SolarMutexGuard aGuard;
518 [ # # ][ # # ]: 0 : if ( !m_pData->m_pViewShell || !m_pData->m_pViewShell->GetObjectShell() )
[ # # ][ # # ]
519 [ # # ]: 0 : throw DisposedException();
520 : :
521 [ # # ][ # # ]: 0 : const SfxObjectFactory& rDocFac( m_pData->m_pViewShell->GetObjectShell()->GetFactory() );
522 [ # # ][ # # ]: 0 : sal_uInt16 nViewNo = rDocFac.GetViewNo_Impl( GetViewFrame_Impl().GetCurViewId(), rDocFac.GetViewFactoryCount() );
[ # # ][ # # ]
523 : : OSL_ENSURE( nViewNo < rDocFac.GetViewFactoryCount(), "SfxBaseController::getViewControllerName: view ID not found in view factories!" );
524 : :
525 : 0 : ::rtl::OUString sViewName;
526 [ # # ][ # # ]: 0 : if ( nViewNo < rDocFac.GetViewFactoryCount() )
527 [ # # ][ # # ]: 0 : sViewName = rDocFac.GetViewFactory( nViewNo ).GetAPIViewName();
[ # # ][ # # ]
528 : :
529 [ # # ]: 0 : return sViewName;
530 : : }
531 : :
532 : 1727 : Sequence< PropertyValue > SAL_CALL SfxBaseController::getCreationArguments() throw (RuntimeException)
533 : : {
534 [ + - ]: 1727 : SolarMutexGuard aGuard;
535 [ + - ][ + - ]: 1727 : if ( !m_pData->m_pViewShell || !m_pData->m_pViewShell->GetObjectShell() )
[ - + ][ - + ]
536 [ # # ]: 0 : throw DisposedException();
537 : :
538 [ + - ][ + - ]: 1727 : return m_pData->m_aCreationArgs;
539 : : }
540 : :
541 : 1727 : void SfxBaseController::SetCreationArguments_Impl( const Sequence< PropertyValue >& i_rCreationArgs )
542 : : {
543 : : OSL_ENSURE( m_pData->m_aCreationArgs.getLength() == 0, "SfxBaseController::SetCreationArguments_Impl: not intended to be called twice!" );
544 : 1727 : m_pData->m_aCreationArgs = i_rCreationArgs;
545 : 1727 : }
546 : :
547 : 1727 : SfxViewFrame& SfxBaseController::GetViewFrame_Impl() const
548 : : {
549 [ - + ][ # # ]: 1727 : ENSURE_OR_THROW( m_pData->m_pViewShell, "not to be called without a view shell" );
[ # # ][ # # ]
550 : 1727 : SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame();
551 [ # # ][ # # ]: 1727 : ENSURE_OR_THROW( pActFrame, "a view shell without a view frame is pretty pathological" );
[ # # ][ - + ]
552 : 1727 : return *pActFrame;
553 : : }
554 : :
555 : : //________________________________________________________________________________________________________
556 : : // SfxBaseController -> XController2 -> XController
557 : : //________________________________________________________________________________________________________
558 : :
559 : 3363 : void SAL_CALL SfxBaseController::attachFrame( const REFERENCE< XFRAME >& xFrame ) throw( ::com::sun::star::uno::RuntimeException )
560 : : {
561 [ + - ]: 3363 : REFERENCE< XFRAME > xTemp( getFrame() ) ;
562 : :
563 [ + - ]: 3363 : SolarMutexGuard aGuard;
564 [ + + ]: 3363 : if ( xTemp.is() )
565 : : {
566 [ + - ][ + - ]: 1636 : xTemp->removeFrameActionListener( m_pData->m_xListener ) ;
567 [ + - ]: 1636 : REFERENCE < ::com::sun::star::util::XCloseBroadcaster > xCloseable( xTemp, com::sun::star::uno::UNO_QUERY );
568 [ + - ]: 1636 : if ( xCloseable.is() )
569 [ + - ][ + - ]: 1636 : xCloseable->removeCloseListener( m_pData->m_xCloseListener );
570 : : }
571 : :
572 [ + - ]: 3363 : m_pData->m_xFrame = xFrame;
573 : :
574 [ + + ]: 3363 : if ( xFrame.is() )
575 : : {
576 [ + - ][ + - ]: 1727 : xFrame->addFrameActionListener( m_pData->m_xListener ) ;
577 [ + - ]: 1727 : REFERENCE < ::com::sun::star::util::XCloseBroadcaster > xCloseable( xFrame, com::sun::star::uno::UNO_QUERY );
578 [ + - ]: 1727 : if ( xCloseable.is() )
579 [ + - ][ + - ]: 1727 : xCloseable->addCloseListener( m_pData->m_xCloseListener );
580 : :
581 [ + - ]: 1727 : if ( m_pData->m_pViewShell )
582 : : {
583 [ + - ]: 1727 : ConnectSfxFrame_Impl( E_CONNECT );
584 : :
585 : : // attaching the frame to the controller is the last step in the creation of a new view, so notify this
586 [ + - ][ + - ]: 1727 : SfxViewEventHint aHint( SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ), m_pData->m_pViewShell->GetObjectShell(), uno::Reference< frame::XController2 >( this ) );
[ + - ][ + - ]
587 [ + - ][ + - ]: 1727 : SFX_APP()->NotifyEvent( aHint );
[ + - ]
588 : 1727 : }
589 [ + - ]: 3363 : }
590 : 3363 : }
591 : :
592 : : //________________________________________________________________________________________________________
593 : : // SfxBaseController -> XController
594 : : //________________________________________________________________________________________________________
595 : :
596 : 1727 : sal_Bool SAL_CALL SfxBaseController::attachModel( const REFERENCE< XMODEL >& xModel ) throw( ::com::sun::star::uno::RuntimeException )
597 : : {
598 [ + - ][ + - ]: 1727 : if ( m_pData->m_pViewShell && xModel.is() && xModel != m_pData->m_pViewShell->GetObjectShell()->GetModel() )
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ]
[ - + # # ]
599 : : {
600 : : // don't allow to reattach a model!
601 : : OSL_FAIL("Can't reattach model!");
602 : 0 : return sal_False;
603 : : }
604 : :
605 [ + - ]: 1727 : REFERENCE < ::com::sun::star::util::XCloseBroadcaster > xCloseable( xModel, com::sun::star::uno::UNO_QUERY );
606 [ + - ]: 1727 : if ( xCloseable.is() )
607 [ + - ][ + - ]: 1727 : xCloseable->addCloseListener( m_pData->m_xCloseListener );
608 : 1727 : return sal_True;
609 : : }
610 : :
611 : : //________________________________________________________________________________________________________
612 : : // SfxBaseController -> XController
613 : : //________________________________________________________________________________________________________
614 : :
615 : 6 : sal_Bool SAL_CALL SfxBaseController::suspend( sal_Bool bSuspend ) throw( ::com::sun::star::uno::RuntimeException )
616 : : {
617 [ + - ]: 6 : SolarMutexGuard aGuard;
618 : :
619 : : // ignore dublicate calls, which doesnt change anything real
620 [ - + ]: 6 : if (bSuspend == m_pData->m_bSuspendState)
621 : 0 : return sal_True;
622 : :
623 [ + - ]: 6 : if ( bSuspend == sal_True )
624 : : {
625 [ - + ]: 6 : if ( !m_pData->m_pViewShell )
626 : : {
627 : 0 : m_pData->m_bSuspendState = sal_True;
628 : 0 : return sal_True;
629 : : }
630 : :
631 [ + - ][ - + ]: 6 : if ( !m_pData->m_pViewShell->PrepareClose() )
632 : 0 : return sal_False;
633 : :
634 [ + - ][ + - ]: 6 : if ( getFrame().is() )
635 [ + - ][ + - ]: 6 : getFrame()->removeFrameActionListener( m_pData->m_xListener ) ;
[ + - ]
636 [ + - ]: 6 : SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame() ;
637 : :
638 : : // More Views on the same document?
639 [ + - ]: 6 : SfxObjectShell* pDocShell = m_pData->m_pViewShell->GetObjectShell() ;
640 : 6 : sal_Bool bOther = sal_False ;
641 : :
642 [ + - ][ + - ]: 10 : for ( const SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); !bOther && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ) )
[ + - ][ + + ]
[ + + ]
643 : 4 : bOther = (pFrame != pActFrame);
644 : :
645 [ + - ][ + - ]: 6 : sal_Bool bRet = bOther || pDocShell->PrepareClose();
[ + - ]
646 [ + - ]: 6 : if ( bRet )
647 : : {
648 [ + - ]: 6 : ConnectSfxFrame_Impl( E_DISCONNECT );
649 : 6 : m_pData->m_bSuspendState = sal_True;
650 : : }
651 : :
652 : 6 : return bRet;
653 : : }
654 : : else
655 : : {
656 [ # # ][ # # ]: 0 : if ( getFrame().is() )
657 [ # # ][ # # ]: 0 : getFrame()->addFrameActionListener( m_pData->m_xListener ) ;
[ # # ]
658 : :
659 [ # # ]: 0 : if ( m_pData->m_pViewShell )
660 : : {
661 [ # # ]: 0 : ConnectSfxFrame_Impl( E_RECONNECT );
662 : : }
663 : :
664 : 0 : m_pData->m_bSuspendState = sal_False;
665 : 0 : return sal_True ;
666 [ + - ]: 6 : }
667 : : }
668 : :
669 : : //________________________________________________________________________________________________________
670 : : // SfxBaseController -> XController
671 : : //________________________________________________________________________________________________________
672 : :
673 : 2 : ANY SfxBaseController::getViewData() throw( ::com::sun::star::uno::RuntimeException )
674 : : {
675 : 2 : ANY aAny;
676 [ + - ]: 2 : String sData1;
677 [ + - ]: 2 : SolarMutexGuard aGuard;
678 [ + - ]: 2 : if ( m_pData->m_pViewShell )
679 : : {
680 [ + - ]: 2 : m_pData->m_pViewShell->WriteUserData( sData1 ) ;
681 [ + - ]: 2 : ::rtl::OUString sData( sData1 );
682 [ + - ]: 2 : aAny <<= sData ;
683 : : }
684 : :
685 [ + - ][ + - ]: 2 : return aAny ;
686 : : }
687 : :
688 : : //________________________________________________________________________________________________________
689 : : // SfxBaseController -> XController
690 : : //________________________________________________________________________________________________________
691 : :
692 : 0 : void SAL_CALL SfxBaseController::restoreViewData( const ANY& aValue ) throw( ::com::sun::star::uno::RuntimeException )
693 : : {
694 [ # # ]: 0 : SolarMutexGuard aGuard;
695 [ # # ]: 0 : if ( m_pData->m_pViewShell )
696 : : {
697 : 0 : ::rtl::OUString sData;
698 : 0 : aValue >>= sData ;
699 [ # # ][ # # ]: 0 : m_pData->m_pViewShell->ReadUserData( sData ) ;
[ # # ]
700 [ # # ]: 0 : }
701 : 0 : }
702 : :
703 : : //________________________________________________________________________________________________________
704 : : // SfxBaseController -> XController
705 : : //________________________________________________________________________________________________________
706 : :
707 : 14844 : REFERENCE< XFRAME > SAL_CALL SfxBaseController::getFrame() throw( ::com::sun::star::uno::RuntimeException )
708 : : {
709 [ + - ]: 14844 : SolarMutexGuard aGuard;
710 [ + - ]: 14844 : return m_pData->m_xFrame;
711 : : }
712 : :
713 : : //________________________________________________________________________________________________________
714 : : // SfxBaseController -> XController
715 : : //________________________________________________________________________________________________________
716 : :
717 : 302087 : REFERENCE< XMODEL > SAL_CALL SfxBaseController::getModel() throw( ::com::sun::star::uno::RuntimeException )
718 : : {
719 [ + - ]: 302087 : SolarMutexGuard aGuard;
720 [ + + ][ + - ]: 302087 : return m_pData->m_pViewShell ? m_pData->m_pViewShell->GetObjectShell()->GetModel() : REFERENCE < XMODEL > () ;
[ + - ][ + - ]
721 : : }
722 : :
723 : : //________________________________________________________________________________________________________
724 : : // SfxBaseController -> XDispatchProvider
725 : : //________________________________________________________________________________________________________
726 : :
727 : 277706 : REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOURL& aURL ,
728 : : const ::rtl::OUString& sTargetFrameName,
729 : : sal_Int32 eSearchFlags ) throw( RUNTIMEEXCEPTION )
730 : : {
731 [ + - ]: 277706 : SolarMutexGuard aGuard;
732 : 277706 : REFERENCE< XDISPATCH > xDisp;
733 [ + - ]: 277706 : if ( m_pData->m_pViewShell )
734 : : {
735 : 277706 : SfxViewFrame* pAct = m_pData->m_pViewShell->GetViewFrame() ;
736 [ + - ]: 277706 : if ( !m_pData->m_bDisposing )
737 : : {
738 [ + + ]: 277706 : if ( sTargetFrameName == "_beamer" )
739 : : {
740 : 2 : SfxViewFrame *pFrame = m_pData->m_pViewShell->GetViewFrame();
741 [ + - ]: 2 : if ( eSearchFlags & ( ::com::sun::star::frame::FrameSearchFlag::CREATE ))
742 [ + - ]: 2 : pFrame->SetChildWindow( SID_BROWSER, sal_True );
743 [ + - ]: 2 : SfxChildWindow* pChildWin = pFrame->GetChildWindow( SID_BROWSER );
744 : 2 : REFERENCE < XFRAME > xFrame;
745 [ + - ]: 2 : if ( pChildWin )
746 [ + - ][ + - ]: 2 : xFrame = ( pChildWin->GetFrame() );
747 [ + - ]: 2 : if ( xFrame.is() )
748 [ + - ][ + - ]: 2 : xFrame->setName( sTargetFrameName );
749 : :
750 [ + - ]: 2 : Reference< XDispatchProvider > xProv( xFrame, ::com::sun::star::uno::UNO_QUERY );
751 [ + - ]: 2 : if ( xProv.is() )
752 [ + - ][ + - ]: 2 : return xProv->queryDispatch( aURL, sTargetFrameName, ::com::sun::star::frame::FrameSearchFlag::SELF );
[ + - ][ - + ]
753 : : }
754 : :
755 [ + + ]: 277704 : if ( aURL.Protocol == ".uno:" )
756 : : {
757 [ + - ]: 277692 : rtl::OUString aMasterCommand = SfxOfficeDispatch::GetMasterUnoCommand( aURL );
758 : 277692 : sal_Bool bMasterCommand( !aMasterCommand.isEmpty() );
759 : :
760 : 277692 : pAct = m_pData->m_pViewShell->GetViewFrame() ;
761 [ + - ]: 277692 : SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pAct );
762 : :
763 : 277692 : const SfxSlot* pSlot( 0 );
764 [ + + ]: 277692 : if ( bMasterCommand )
765 [ + - ][ + - ]: 206 : pSlot = rSlotPool.GetUnoSlot( aMasterCommand );
[ + - ]
766 : : else
767 [ + - ][ + - ]: 277486 : pSlot = rSlotPool.GetUnoSlot( aURL.Path );
[ + - ]
768 [ + + ][ + - ]: 277692 : if ( pSlot && ( !pAct->GetFrame().IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) )
[ + - ][ - + ]
[ # # ][ + + ]
769 [ + - ]: 271765 : return pAct->GetBindings().GetDispatch( pSlot, aURL, bMasterCommand );
770 : : else
771 : : {
772 : : // try to find parent SfxViewFrame
773 : 5927 : uno::Reference< frame::XFrame > xParentFrame;
774 [ + - ][ + - ]: 5927 : uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame().GetFrameInterface();
775 [ + - ]: 5927 : if ( xOwnFrame.is() )
776 [ + - ][ + - ]: 5927 : xParentFrame = uno::Reference< frame::XFrame >( xOwnFrame->getCreator(), uno::UNO_QUERY );
[ + - ][ + - ]
777 : :
778 [ + - ]: 5927 : if ( xParentFrame.is() )
779 : : {
780 : : // TODO/LATER: in future probably SfxViewFrame hirarchy should be the same as XFrame hirarchy
781 : : // SfxViewFrame* pParentFrame = pAct->GetParentViewFrame();
782 : :
783 : : // search the related SfxViewFrame
784 : 5927 : SfxViewFrame* pParentFrame = NULL;
785 [ + - ][ + - ]: 9491 : for ( SfxViewFrame* pFrame = SfxViewFrame::GetFirst();
[ + + ]
786 : : pFrame;
787 : : pFrame = SfxViewFrame::GetNext( *pFrame ) )
788 : : {
789 [ + - ][ + - ]: 3564 : if ( pFrame->GetFrame().GetFrameInterface() == xParentFrame )
[ + - ][ - + ]
790 : : {
791 : 0 : pParentFrame = pFrame;
792 : 0 : break;
793 : : }
794 : : }
795 : :
796 [ - + ]: 5927 : if ( pParentFrame )
797 : : {
798 [ # # ]: 0 : SfxSlotPool& rFrameSlotPool = SfxSlotPool::GetSlotPool( pParentFrame );
799 : 0 : const SfxSlot* pSlot2( 0 );
800 [ # # ]: 0 : if ( bMasterCommand )
801 [ # # ][ # # ]: 0 : pSlot2 = rFrameSlotPool.GetUnoSlot( aMasterCommand );
[ # # ]
802 : : else
803 [ # # ][ # # ]: 0 : pSlot2 = rFrameSlotPool.GetUnoSlot( aURL.Path );
[ # # ]
804 : :
805 [ # # ]: 0 : if ( pSlot2 )
806 [ # # ]: 5927 : return pParentFrame->GetBindings().GetDispatch( pSlot2, aURL, bMasterCommand );
807 : : }
808 [ - + ][ + - ]: 5927 : }
809 [ + + ]: 277692 : }
810 : : }
811 [ - + ]: 12 : else if ( aURL.Protocol == "slot:" )
812 : : {
813 : 0 : sal_uInt16 nId = (sal_uInt16) aURL.Path.toInt32();
814 : :
815 : 0 : pAct = m_pData->m_pViewShell->GetViewFrame() ;
816 [ # # ][ # # ]: 0 : if (nId >= SID_VERB_START && nId <= SID_VERB_END)
817 : : {
818 [ # # ]: 0 : const SfxSlot* pSlot = m_pData->m_pViewShell->GetVerbSlot_Impl(nId);
819 [ # # ]: 0 : if ( pSlot )
820 [ # # ]: 0 : return pAct->GetBindings().GetDispatch( pSlot, aURL, sal_False );
821 : : }
822 : :
823 [ # # ]: 0 : SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pAct );
824 [ # # ]: 0 : const SfxSlot* pSlot = rSlotPool.GetSlot( nId );
825 [ # # ][ # # ]: 0 : if ( pSlot && ( !pAct->GetFrame().IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) )
[ # # ][ # # ]
[ # # ][ # # ]
826 [ # # ]: 0 : return pAct->GetBindings().GetDispatch( pSlot, aURL, sal_False );
827 : : else
828 : : {
829 : : // try to find parent SfxViewFrame
830 : 0 : uno::Reference< frame::XFrame > xParentFrame;
831 [ # # ][ # # ]: 0 : uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame().GetFrameInterface();
832 [ # # ]: 0 : if ( xOwnFrame.is() )
833 [ # # ][ # # ]: 0 : xParentFrame = uno::Reference< frame::XFrame >( xOwnFrame->getCreator(), uno::UNO_QUERY );
[ # # ][ # # ]
834 : :
835 [ # # ]: 0 : if ( xParentFrame.is() )
836 : : {
837 : : // TODO/LATER: in future probably SfxViewFrame hirarchy should be the same as XFrame hirarchy
838 : : // SfxViewFrame* pParentFrame = pAct->GetParentViewFrame();
839 : :
840 : : // search the related SfxViewFrame
841 : 0 : SfxViewFrame* pParentFrame = NULL;
842 [ # # ][ # # ]: 0 : for ( SfxViewFrame* pFrame = SfxViewFrame::GetFirst();
[ # # ]
843 : : pFrame;
844 : : pFrame = SfxViewFrame::GetNext( *pFrame ) )
845 : : {
846 [ # # ][ # # ]: 0 : if ( pFrame->GetFrame().GetFrameInterface() == xParentFrame )
[ # # ][ # # ]
847 : : {
848 : 0 : pParentFrame = pFrame;
849 : 0 : break;
850 : : }
851 : : }
852 : :
853 [ # # ]: 0 : if ( pParentFrame )
854 : : {
855 [ # # ]: 0 : SfxSlotPool& rSlotPool2 = SfxSlotPool::GetSlotPool( pParentFrame );
856 [ # # ][ # # ]: 0 : const SfxSlot* pSlot2 = rSlotPool2.GetUnoSlot( aURL.Path );
[ # # ]
857 [ # # ]: 0 : if ( pSlot2 )
858 [ # # ]: 0 : return pParentFrame->GetBindings().GetDispatch( pSlot2, aURL, sal_False );
859 : : }
860 [ # # ][ # # ]: 0 : }
861 : : }
862 : : }
863 [ - + ][ # # ]: 12 : else if( sTargetFrameName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("_self")) || sTargetFrameName.isEmpty() )
[ + - ]
864 : : {
865 : : // check for already loaded URL ... but with additional jumpmark!
866 [ + - ]: 12 : REFERENCE< XMODEL > xModel = getModel();
867 [ + - ][ - + ]: 12 : if( xModel.is() && !aURL.Mark.isEmpty() )
[ - + ]
868 : : {
869 [ # # ]: 0 : SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pAct );
870 [ # # ]: 0 : const SfxSlot* pSlot = rSlotPool.GetSlot( SID_JUMPTOMARK );
871 [ # # ][ # # ]: 0 : if( !aURL.Main.isEmpty() && aURL.Main == xModel->getURL() && pSlot )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
872 [ # # ][ # # ]: 12 : return REFERENCE< XDISPATCH >( new SfxOfficeDispatch( pAct->GetBindings(), pAct->GetDispatcher(), pSlot, aURL) );
873 [ + - ]: 12 : }
874 : : }
875 : : }
876 : : }
877 : :
878 [ + - ]: 277706 : return xDisp;
879 : : }
880 : :
881 : : //________________________________________________________________________________________________________
882 : : // SfxBaseController -> XDispatchProvider
883 : : //________________________________________________________________________________________________________
884 : :
885 : 0 : uno::Sequence< REFERENCE< XDISPATCH > > SAL_CALL SfxBaseController::queryDispatches( const uno::Sequence< DISPATCHDESCRIPTOR >& seqDescripts ) throw( ::com::sun::star::uno::RuntimeException )
886 : : {
887 : : // Create return list - which must have same size then the given descriptor
888 : : // It's not allowed to pack it!
889 : 0 : sal_Int32 nCount = seqDescripts.getLength();
890 : 0 : uno::Sequence< REFERENCE< XDISPATCH > > lDispatcher( nCount );
891 : :
892 [ # # ]: 0 : for( sal_Int32 i=0; i<nCount; ++i )
893 : : {
894 [ # # ]: 0 : lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL ,
895 : 0 : seqDescripts[i].FrameName ,
896 [ # # ][ # # ]: 0 : seqDescripts[i].SearchFlags );
897 : : }
898 : :
899 : 0 : return lDispatcher;
900 : : }
901 : :
902 : : //________________________________________________________________________________________________________
903 : : // SfxBaseController -> XControllerBorder
904 : : //________________________________________________________________________________________________________
905 : :
906 : 0 : frame::BorderWidths SAL_CALL SfxBaseController::getBorder()
907 : : throw ( uno::RuntimeException )
908 : : {
909 : 0 : frame::BorderWidths aResult;
910 : :
911 [ # # ]: 0 : SolarMutexGuard aGuard;
912 [ # # ]: 0 : if ( m_pData->m_pViewShell )
913 : : {
914 [ # # ]: 0 : SvBorder aBorder = m_pData->m_pViewShell->GetBorderPixel();
915 : 0 : aResult.Left = aBorder.Left();
916 : 0 : aResult.Top = aBorder.Top();
917 : 0 : aResult.Right = aBorder.Right();
918 : 0 : aResult.Bottom = aBorder.Bottom();
919 : : }
920 : :
921 [ # # ]: 0 : return aResult;
922 : : }
923 : :
924 : 4 : void SAL_CALL SfxBaseController::addBorderResizeListener( const uno::Reference< frame::XBorderResizeListener >& xListener )
925 : : throw ( uno::RuntimeException )
926 : : {
927 : 4 : m_pData->m_aListenerContainer.addInterface( ::getCppuType((const uno::Reference< frame::XBorderResizeListener >*)0),
928 : 8 : xListener );
929 : 4 : }
930 : :
931 : 4 : void SAL_CALL SfxBaseController::removeBorderResizeListener( const uno::Reference< frame::XBorderResizeListener >& xListener )
932 : : throw ( uno::RuntimeException )
933 : : {
934 : 4 : m_pData->m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< frame::XBorderResizeListener >*)0),
935 : 8 : xListener );
936 : 4 : }
937 : :
938 : 0 : awt::Rectangle SAL_CALL SfxBaseController::queryBorderedArea( const awt::Rectangle& aPreliminaryRectangle )
939 : : throw ( uno::RuntimeException )
940 : : {
941 [ # # ]: 0 : SolarMutexGuard aGuard;
942 [ # # ]: 0 : if ( m_pData->m_pViewShell )
943 : : {
944 [ # # ]: 0 : Rectangle aTmpRect = VCLRectangle( aPreliminaryRectangle );
945 [ # # ]: 0 : m_pData->m_pViewShell->QueryObjAreaPixel( aTmpRect );
946 [ # # ]: 0 : return AWTRectangle( aTmpRect );
947 : : }
948 : :
949 [ # # ]: 0 : return aPreliminaryRectangle;
950 : : }
951 : :
952 : 8299 : void SfxBaseController::BorderWidthsChanged_Impl()
953 : : {
954 : : ::cppu::OInterfaceContainerHelper* pContainer = m_pData->m_aListenerContainer.getContainer(
955 : 8299 : ::getCppuType( ( const uno::Reference< frame::XBorderResizeListener >*) NULL ) );
956 [ - + ]: 8299 : if ( pContainer )
957 : : {
958 [ # # ]: 0 : frame::BorderWidths aBWidths = getBorder();
959 [ # # ]: 0 : uno::Reference< uno::XInterface > xThis( static_cast< ::cppu::OWeakObject* >(this), uno::UNO_QUERY );
960 : :
961 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
962 [ # # ]: 0 : while (pIterator.hasMoreElements())
963 : : {
964 : : try
965 : : {
966 [ # # ][ # # ]: 0 : ((frame::XBorderResizeListener*)pIterator.next())->borderWidthsChanged( xThis, aBWidths );
967 : : }
968 [ # # # # ]: 0 : catch (const uno::RuntimeException&)
969 : : {
970 [ # # ]: 0 : pIterator.remove();
971 : : }
972 [ # # ]: 0 : }
973 : : }
974 : 8299 : }
975 : :
976 : : //________________________________________________________________________________________________________
977 : : // SfxBaseController -> XComponent
978 : : //________________________________________________________________________________________________________
979 : :
980 : 1636 : void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::RuntimeException )
981 : : {
982 [ + - ]: 1636 : SolarMutexGuard aGuard;
983 [ + - ]: 1636 : Reference< XController > xTmp( this );
984 : 1636 : m_pData->m_bDisposing = sal_True ;
985 : :
986 [ + - ]: 1636 : EVENTOBJECT aEventObject;
987 [ + - ][ + - ]: 1636 : aEventObject.Source = *this ;
988 [ + - ]: 1636 : m_pData->m_aListenerContainer.disposeAndClear( aEventObject ) ;
989 : :
990 [ + - ][ + - ]: 1636 : if ( m_pData->m_pController && m_pData->m_pController->getFrame().is() )
[ + - ][ + - ]
[ + - # # ]
991 [ + - ][ + - ]: 1636 : m_pData->m_pController->getFrame()->removeFrameActionListener( m_pData->m_xListener ) ;
[ + - ]
992 : :
993 [ + - ]: 1636 : if ( m_pData->m_pViewShell )
994 : : {
995 : 1636 : SfxViewFrame* pFrame = m_pData->m_pViewShell->GetViewFrame() ;
996 [ + - ][ + + ]: 1636 : if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell )
[ + + ][ + - ]
997 [ + - ][ + - ]: 1620 : pFrame->GetFrame().SetIsClosing_Impl();
998 [ + - ]: 1636 : m_pData->m_pViewShell->DiscardClients_Impl();
999 : 1636 : m_pData->m_pViewShell->pImp->m_bControllerSet = false;
1000 : :
1001 [ + - ]: 1636 : if ( pFrame )
1002 : : {
1003 [ + - ]: 1636 : EVENTOBJECT aObject;
1004 [ + - ][ + - ]: 1636 : aObject.Source = *this ;
1005 : :
1006 [ + - ]: 1636 : SfxObjectShell* pDoc = pFrame->GetObjectShell() ;
1007 [ + - ]: 1636 : SfxViewFrame *pView = SfxViewFrame::GetFirst(pDoc);
1008 [ + + ]: 3236 : while( pView )
1009 : : {
1010 : : // if there is another ViewFrame or currently the ViewShell in my ViewFrame is switched (PagePreview)
1011 [ + + ][ + - ]: 1618 : if ( pView != pFrame || pView->GetViewShell() != m_pData->m_pViewShell )
[ + + ][ + + ]
1012 : 18 : break;
1013 [ + - ]: 1600 : pView = SfxViewFrame::GetNext( *pView, pDoc );
1014 : : }
1015 : :
1016 [ + - ][ + - ]: 1636 : SFX_APP()->NotifyEvent( SfxViewEventHint(SFX_EVENT_CLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEVIEW ), pDoc, uno::Reference< frame::XController2 >( this ) ) );
[ + - ][ + - ]
[ + - ][ + - ]
1017 [ + + ]: 1636 : if ( !pView )
1018 [ + - ][ + - ]: 1618 : SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), pDoc) );
[ + - ][ + - ]
[ + - ]
1019 : :
1020 [ + - ]: 1636 : REFERENCE< XMODEL > xModel = pDoc->GetModel();
1021 [ + - ]: 1636 : REFERENCE < ::com::sun::star::util::XCloseable > xCloseable( xModel, com::sun::star::uno::UNO_QUERY );
1022 [ + - ]: 1636 : if ( xModel.is() )
1023 : : {
1024 [ + - ][ + - ]: 1636 : xModel->disconnectController( this );
[ + - ]
1025 [ + - ]: 1636 : if ( xCloseable.is() )
1026 [ + - ][ + - ]: 1636 : xCloseable->removeCloseListener( m_pData->m_xCloseListener );
1027 : : }
1028 : :
1029 : 1636 : REFERENCE < XFRAME > aXFrame;
1030 [ + - ]: 1636 : attachFrame( aXFrame );
1031 : :
1032 [ + - ][ + - ]: 1636 : m_pData->m_xListener->disposing( aObject );
1033 : 1636 : SfxViewShell *pShell = m_pData->m_pViewShell;
1034 : 1636 : m_pData->m_pViewShell = NULL;
1035 [ + - ][ + + ]: 1636 : if ( pFrame->GetViewShell() == pShell )
1036 : : {
1037 : : // Enter registrations only allowed if we are the owner!
1038 [ + - ][ + - ]: 1620 : if ( pFrame->GetFrame().OwnsBindings_Impl() )
[ + - ]
1039 [ + - ]: 1620 : pFrame->GetBindings().ENTERREGISTRATIONS();
1040 [ + - ][ + - ]: 1620 : pFrame->GetFrame().SetFrameInterface_Impl( aXFrame );
1041 [ + - ][ + - ]: 1620 : pFrame->GetFrame().DoClose_Impl();
1042 [ + - ]: 1636 : }
1043 : : }
1044 [ + - ][ + - ]: 1636 : }
1045 : 1636 : }
1046 : :
1047 : : //________________________________________________________________________________________________________
1048 : : // SfxBaseController -> XComponent
1049 : : //________________________________________________________________________________________________________
1050 : :
1051 : 2293 : void SAL_CALL SfxBaseController::addEventListener( const REFERENCE< XEVENTLISTENER >& aListener ) throw( ::com::sun::star::uno::RuntimeException )
1052 : : {
1053 : 2293 : m_pData->m_aListenerContainer.addInterface( ::getCppuType((const REFERENCE< XEVENTLISTENER >*)0), aListener );
1054 : 2293 : }
1055 : :
1056 : : //________________________________________________________________________________________________________
1057 : : // SfxBaseController -> XComponent
1058 : : //________________________________________________________________________________________________________
1059 : :
1060 : 1930 : void SAL_CALL SfxBaseController::removeEventListener( const REFERENCE< XEVENTLISTENER >& aListener ) throw( ::com::sun::star::uno::RuntimeException )
1061 : : {
1062 : 1930 : m_pData->m_aListenerContainer.removeInterface( ::getCppuType((const REFERENCE< XEVENTLISTENER >*)0), aListener );
1063 : 1930 : }
1064 : :
1065 : 1636 : void SfxBaseController::ReleaseShell_Impl()
1066 : : {
1067 [ + - ]: 1636 : SolarMutexGuard aGuard;
1068 [ - + ]: 1636 : if ( m_pData->m_pViewShell )
1069 : : {
1070 [ # # ]: 0 : SfxObjectShell* pDoc = m_pData->m_pViewShell->GetObjectShell() ;
1071 [ # # ]: 0 : REFERENCE< XMODEL > xModel = pDoc->GetModel();
1072 [ # # ]: 0 : REFERENCE < ::com::sun::star::util::XCloseable > xCloseable( xModel, com::sun::star::uno::UNO_QUERY );
1073 [ # # ]: 0 : if ( xModel.is() )
1074 : : {
1075 [ # # ][ # # ]: 0 : xModel->disconnectController( this );
[ # # ]
1076 [ # # ]: 0 : if ( xCloseable.is() )
1077 [ # # ][ # # ]: 0 : xCloseable->removeCloseListener( m_pData->m_xCloseListener );
1078 : : }
1079 : 0 : m_pData->m_pViewShell = 0;
1080 : :
1081 : 0 : REFERENCE < XFRAME > aXFrame;
1082 [ # # ]: 0 : attachFrame( aXFrame );
1083 [ + - ]: 1636 : }
1084 : 1636 : }
1085 : :
1086 : 13682 : SfxViewShell* SfxBaseController::GetViewShell_Impl() const
1087 : : {
1088 : 13682 : return m_pData->m_pViewShell;
1089 : : }
1090 : :
1091 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > SAL_CALL SfxBaseController::getStatusIndicator( ) throw (::com::sun::star::uno::RuntimeException)
1092 : : {
1093 [ # # ]: 0 : SolarMutexGuard aGuard;
1094 [ # # ][ # # ]: 0 : if ( m_pData->m_pViewShell && !m_pData->m_xIndicator.is() )
[ # # ]
1095 [ # # ][ # # ]: 0 : m_pData->m_xIndicator = new SfxStatusIndicator( this, m_pData->m_pViewShell->GetViewFrame()->GetFrame().GetWorkWindow_Impl() );
[ # # ][ # # ]
[ # # ]
1096 [ # # ]: 0 : return m_pData->m_xIndicator;
1097 : : }
1098 : :
1099 : 0 : void SAL_CALL SfxBaseController::registerContextMenuInterceptor( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor ) throw( RUNTIMEEXCEPTION )
1100 : :
1101 : : {
1102 [ # # ]: 0 : m_pData->m_aInterceptorContainer.addInterface( xInterceptor );
1103 : :
1104 [ # # ]: 0 : SolarMutexGuard aGuard;
1105 [ # # ]: 0 : if ( m_pData->m_pViewShell )
1106 [ # # ][ # # ]: 0 : m_pData->m_pViewShell->AddContextMenuInterceptor_Impl( xInterceptor );
1107 : 0 : }
1108 : :
1109 : 0 : void SAL_CALL SfxBaseController::releaseContextMenuInterceptor( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor ) throw( RUNTIMEEXCEPTION )
1110 : :
1111 : : {
1112 [ # # ]: 0 : m_pData->m_aInterceptorContainer.removeInterface( xInterceptor );
1113 : :
1114 [ # # ]: 0 : SolarMutexGuard aGuard;
1115 [ # # ]: 0 : if ( m_pData->m_pViewShell )
1116 [ # # ][ # # ]: 0 : m_pData->m_pViewShell->RemoveContextMenuInterceptor_Impl( xInterceptor );
1117 : 0 : }
1118 : :
1119 : 0 : void SAL_CALL SfxBaseController::addKeyHandler( const ::com::sun::star::uno::Reference< XKEYHANDLER >& xHandler ) throw (::com::sun::star::uno::RuntimeException)
1120 : : {
1121 [ # # ]: 0 : SolarMutexGuard aGuard;
1122 [ # # ][ # # ]: 0 : m_pData->m_aUserInputInterception.addKeyHandler( xHandler );
1123 : 0 : }
1124 : :
1125 : 0 : void SAL_CALL SfxBaseController::removeKeyHandler( const ::com::sun::star::uno::Reference< XKEYHANDLER >& xHandler ) throw (::com::sun::star::uno::RuntimeException)
1126 : : {
1127 [ # # ]: 0 : SolarMutexGuard aGuard;
1128 [ # # ][ # # ]: 0 : m_pData->m_aUserInputInterception.removeKeyHandler( xHandler );
1129 : 0 : }
1130 : :
1131 : 0 : void SAL_CALL SfxBaseController::addMouseClickHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseClickHandler >& xHandler ) throw (::com::sun::star::uno::RuntimeException)
1132 : : {
1133 [ # # ]: 0 : SolarMutexGuard aGuard;
1134 [ # # ][ # # ]: 0 : m_pData->m_aUserInputInterception.addMouseClickHandler( xHandler );
1135 : 0 : }
1136 : :
1137 : 0 : void SAL_CALL SfxBaseController::removeMouseClickHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseClickHandler >& xHandler ) throw (::com::sun::star::uno::RuntimeException)
1138 : : {
1139 [ # # ]: 0 : SolarMutexGuard aGuard;
1140 [ # # ][ # # ]: 0 : m_pData->m_aUserInputInterception.removeMouseClickHandler( xHandler );
1141 : 0 : }
1142 : :
1143 : 0 : ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL SfxBaseController::getSupportedCommandGroups()
1144 : : throw (::com::sun::star::uno::RuntimeException)
1145 : : {
1146 [ # # ]: 0 : SolarMutexGuard aGuard;
1147 : :
1148 [ # # ]: 0 : std::list< sal_Int16 > aGroupList;
1149 [ # # ]: 0 : SfxViewFrame* pViewFrame( m_pData->m_pViewShell->GetFrame() );
1150 [ # # ]: 0 : SfxSlotPool* pPool = &SfxSlotPool::GetSlotPool( pViewFrame );
1151 : :
1152 [ # # ][ # # ]: 0 : SfxSlotPool* pSlotPool = pPool ? pPool : &SFX_SLOTPOOL();
1153 : 0 : const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
1154 : :
1155 : : // Select Group ( Group 0 is internal )
1156 [ # # ][ # # ]: 0 : for ( sal_uInt16 i=0; i<pSlotPool->GetGroupCount(); i++ )
1157 : : {
1158 [ # # ]: 0 : String aName = pSlotPool->SeekGroup( i );
1159 [ # # ]: 0 : const SfxSlot* pSfxSlot = pSlotPool->FirstSlot();
1160 [ # # ]: 0 : while ( pSfxSlot )
1161 : : {
1162 [ # # ]: 0 : if ( pSfxSlot->GetMode() & nMode )
1163 : : {
1164 [ # # ]: 0 : sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
1165 [ # # ]: 0 : aGroupList.push_back( nCommandGroup );
1166 : : break;
1167 : : }
1168 [ # # ]: 0 : pSfxSlot = pSlotPool->NextSlot();
1169 : : }
1170 [ # # ]: 0 : }
1171 : :
1172 : : ::com::sun::star::uno::Sequence< sal_Int16 > aSeq =
1173 [ # # ]: 0 : comphelper::containerToSequence< sal_Int16 >( aGroupList );
1174 [ # # ]: 0 : return aSeq;
1175 : : }
1176 : :
1177 : 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > SAL_CALL SfxBaseController::getConfigurableDispatchInformation( sal_Int16 nCmdGroup )
1178 : : throw (::com::sun::star::uno::RuntimeException)
1179 : : {
1180 [ # # ]: 0 : std::list< ::com::sun::star::frame::DispatchInformation > aCmdList;
1181 : :
1182 [ # # ]: 0 : SolarMutexGuard aGuard;
1183 [ # # ]: 0 : if ( m_pData->m_pViewShell )
1184 : : {
1185 : 0 : const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
1186 : :
1187 [ # # ]: 0 : SfxViewFrame* pViewFrame( m_pData->m_pViewShell->GetFrame() );
1188 [ # # ]: 0 : SfxSlotPool* pPool( &SfxSlotPool::GetSlotPool( pViewFrame ));
1189 : 0 : rtl::OUString aCmdPrefix( ".uno:" );
1190 : :
1191 [ # # ][ # # ]: 0 : SfxSlotPool* pSlotPool = pPool ? pPool : &SFX_SLOTPOOL();
1192 [ # # ][ # # ]: 0 : for ( sal_uInt16 i=0; i<pSlotPool->GetGroupCount(); i++ )
1193 : : {
1194 [ # # ]: 0 : String aName = pSlotPool->SeekGroup( i );
1195 [ # # ]: 0 : const SfxSlot* pSfxSlot = pSlotPool->FirstSlot();
1196 [ # # ]: 0 : if ( pSfxSlot )
1197 : : {
1198 [ # # ]: 0 : sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
1199 [ # # ]: 0 : if ( nCommandGroup == nCmdGroup )
1200 : : {
1201 [ # # ]: 0 : while ( pSfxSlot )
1202 : : {
1203 [ # # ]: 0 : if ( pSfxSlot->GetMode() & nMode )
1204 : : {
1205 : 0 : ::com::sun::star::frame::DispatchInformation aCmdInfo;
1206 [ # # ]: 0 : ::rtl::OUStringBuffer aBuf( aCmdPrefix );
1207 [ # # ]: 0 : aBuf.appendAscii( pSfxSlot->GetUnoName() );
1208 [ # # ]: 0 : aCmdInfo.Command = aBuf.makeStringAndClear();
1209 : 0 : aCmdInfo.GroupId = nCommandGroup;
1210 [ # # ]: 0 : aCmdList.push_back( aCmdInfo );
1211 : : }
1212 [ # # ]: 0 : pSfxSlot = pSlotPool->NextSlot();
1213 : : }
1214 : : }
1215 : : }
1216 [ # # ]: 0 : }
1217 : : }
1218 : :
1219 : : ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > aSeq =
1220 [ # # ]: 0 : comphelper::containerToSequence< ::com::sun::star::frame::DispatchInformation, std::list< ::com::sun::star::frame::DispatchInformation > >( aCmdList );
1221 : :
1222 [ # # ]: 0 : return aSeq;
1223 : : }
1224 : :
1225 : 0 : sal_Bool SfxBaseController::HandleEvent_Impl( NotifyEvent& rEvent )
1226 : : {
1227 : 0 : return m_pData->m_aUserInputInterception.handleNotifyEvent( rEvent );
1228 : : }
1229 : :
1230 : 0 : sal_Bool SfxBaseController::HasKeyListeners_Impl()
1231 : : {
1232 : 0 : return m_pData->m_aUserInputInterception.hasKeyHandlers();
1233 : : }
1234 : :
1235 : 0 : sal_Bool SfxBaseController::HasMouseClickListeners_Impl()
1236 : : {
1237 : 0 : return m_pData->m_aUserInputInterception.hasMouseClickListeners();
1238 : : }
1239 : :
1240 : 1733 : void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect )
1241 : : {
1242 [ - + ][ # # ]: 1733 : ENSURE_OR_THROW( m_pData->m_pViewShell, "not to be called without a view shell" );
[ # # ][ # # ]
1243 : 1733 : SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame();
1244 [ # # ][ # # ]: 1733 : ENSURE_OR_THROW( pViewFrame, "a view shell without a view frame is pretty pathological" );
[ # # ][ - + ]
1245 : :
1246 : 1733 : const bool bConnect = ( i_eConnect != E_DISCONNECT );
1247 : :
1248 : : // disable window and dispatcher
1249 : 1733 : pViewFrame->Enable( bConnect );
1250 : 1733 : pViewFrame->GetDispatcher()->Lock( !bConnect );
1251 : :
1252 [ + + ]: 1733 : if ( bConnect )
1253 : : {
1254 [ + - ]: 1727 : if ( i_eConnect == E_CONNECT )
1255 : : {
1256 [ + - - + ]: 3454 : if ( ( m_pData->m_pViewShell->GetObjectShell() != NULL )
[ - + ]
1257 : 1727 : && ( m_pData->m_pViewShell->GetObjectShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
1258 : : )
1259 : : {
1260 : 0 : SfxViewFrame* pViewFrm = m_pData->m_pViewShell->GetViewFrame();
1261 [ # # ]: 0 : if ( !pViewFrm->GetFrame().IsInPlace() )
1262 : : {
1263 : : // for outplace embedded objects, we want the layout manager to keep the content window
1264 : : // size constant, if possible
1265 : : try
1266 : : {
1267 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xFrameProps( m_pData->m_xFrame, uno::UNO_QUERY_THROW );
1268 : : uno::Reference< beans::XPropertySet > xLayouterProps(
1269 [ # # ][ # # ]: 0 : xFrameProps->getPropertyValue( ::rtl::OUString( "LayoutManager" ) ), uno::UNO_QUERY_THROW );
[ # # ]
1270 [ # # ][ # # ]: 0 : xLayouterProps->setPropertyValue( ::rtl::OUString( "PreserveContentSize" ), uno::makeAny( sal_True ) );
[ # # ][ # # ]
1271 : : }
1272 : 0 : catch (const uno::Exception&)
1273 : : {
1274 : : DBG_UNHANDLED_EXCEPTION();
1275 : : }
1276 : : }
1277 : : }
1278 : : }
1279 : :
1280 : : // upon DISCONNECT, we did *not* pop the shells from the stack (this is done elsewhere), so upon
1281 : : // RECONNECT, we're not allowed to push them
1282 [ + - ]: 1727 : if ( i_eConnect != E_RECONNECT )
1283 : : {
1284 : 1727 : pViewFrame->GetDispatcher()->Push( *m_pData->m_pViewShell );
1285 [ - + ]: 1727 : if ( m_pData->m_pViewShell->GetSubShell() )
1286 : 0 : pViewFrame->GetDispatcher()->Push( *m_pData->m_pViewShell->GetSubShell() );
1287 : 1727 : m_pData->m_pViewShell->PushSubShells_Impl();
1288 : 1727 : pViewFrame->GetDispatcher()->Flush();
1289 : : }
1290 : :
1291 : 1727 : Window* pEditWin = m_pData->m_pViewShell->GetWindow();
1292 [ + - ][ + - ]: 1727 : if ( pEditWin && m_pData->m_pViewShell->IsShowView_Impl() )
[ + - ]
1293 : 1727 : pEditWin->Show();
1294 : :
1295 [ + + ]: 1727 : if ( SfxViewFrame::Current() == pViewFrame )
1296 : 16 : pViewFrame->GetDispatcher()->Update_Impl( sal_True );
1297 : :
1298 : 1727 : Window* pFrameWin = &pViewFrame->GetWindow();
1299 [ + - ]: 1727 : if ( pFrameWin != &pViewFrame->GetFrame().GetWindow() )
1300 : 1727 : pFrameWin->Show();
1301 : :
1302 [ + - ]: 1727 : if ( i_eConnect == E_CONNECT )
1303 : : {
1304 [ + - ][ + - ]: 1727 : ::comphelper::NamedValueCollection aDocumentArgs( getModel()->getArgs() );
[ + - ][ + - ]
[ + - ]
1305 : :
1306 [ + - ]: 1727 : const sal_Int16 nPluginMode = aDocumentArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) );
1307 : 1727 : const bool bHasPluginMode = ( nPluginMode != 0 );
1308 : :
1309 [ + - ]: 1727 : SfxFrame& rFrame = pViewFrame->GetFrame();
1310 [ + - ]: 1727 : SfxObjectShell& rDoc = *m_pData->m_pViewShell->GetObjectShell();
1311 [ + - ][ + + ]: 1727 : if ( !rFrame.IsMarkedHidden_Impl() )
1312 : : {
1313 [ + - ][ + - ]: 1707 : if ( rDoc.IsHelpDocument() || ( nPluginMode == 2 ) )
[ - + ][ - + ]
1314 [ # # ]: 0 : pViewFrame->GetDispatcher()->HideUI( sal_True );
1315 : : else
1316 [ + - ]: 1707 : pViewFrame->GetDispatcher()->HideUI( sal_False );
1317 : :
1318 [ + - ][ - + ]: 1707 : if ( rFrame.IsInPlace() )
1319 : 0 : pViewFrame->LockAdjustPosSizePixel();
1320 : :
1321 [ - + ]: 1707 : if ( nPluginMode == 3 )
1322 [ # # ]: 0 : rFrame.GetWorkWindow_Impl()->SetInternalDockingAllowed( sal_False );
1323 : :
1324 [ + - ][ + - ]: 1707 : if ( !rFrame.IsInPlace() )
1325 [ + - ]: 1707 : pViewFrame->GetDispatcher()->Update_Impl();
1326 [ + - ]: 1707 : pViewFrame->Show();
1327 [ + - ][ + - ]: 1707 : rFrame.GetWindow().Show();
1328 [ + - ][ - + ]: 1707 : if ( !rFrame.IsInPlace() || ( nPluginMode == 3 ) )
[ # # ][ + - ]
1329 [ + - ][ + - ]: 1707 : pViewFrame->MakeActive_Impl( rFrame.GetFrameInterface()->isActive() );
[ + - ][ + - ]
1330 : :
1331 [ + - ][ - + ]: 1707 : if ( rFrame.IsInPlace() )
1332 : : {
1333 : 0 : pViewFrame->UnlockAdjustPosSizePixel();
1334 : : // force resize for OLE server to fix layout problems of writer and math
1335 : : // see i53651
1336 [ # # ]: 0 : if ( nPluginMode == 3 )
1337 [ # # ]: 0 : pViewFrame->Resize( sal_True );
1338 : : }
1339 : : }
1340 : : else
1341 : : {
1342 : : DBG_ASSERT( !rFrame.IsInPlace() && !bHasPluginMode, "Special modes not compatible with hidden mode!" );
1343 [ + - ][ + - ]: 20 : rFrame.GetWindow().Show();
1344 : : }
1345 : :
1346 : : // UpdateTitle now, hidden TopFrames have otherwise no Name!
1347 [ + - ]: 1727 : pViewFrame->UpdateTitle();
1348 : :
1349 [ + - ][ + - ]: 1727 : if ( !rFrame.IsInPlace() )
1350 [ + - ]: 1727 : pViewFrame->Resize( sal_True );
1351 : :
1352 : : // if there's a JumpMark given, then, well, jump to it
1353 [ + - ][ + - ]: 1727 : ::comphelper::NamedValueCollection aViewArgs( getCreationArguments() );
[ + - ]
1354 [ + - ]: 1727 : const ::rtl::OUString sJumpMark = aViewArgs.getOrDefault( "JumpMark", ::rtl::OUString() );
1355 : 1727 : const bool bHasJumpMark = !sJumpMark.isEmpty();
1356 : : OSL_ENSURE( ( !m_pData->m_pViewShell->GetObjectShell()->IsLoading() )
1357 : : || ( sJumpMark.isEmpty() ),
1358 : : "SfxBaseController::ConnectSfxFrame_Impl: so this code wasn't dead?" );
1359 : : // Before CWS autorecovery, there was code which postponed jumping to the Mark to a later time
1360 : : // (SfxObjectShell::PositionView_Impl), but it seems this branch was never used, since this method
1361 : : // here is never called before the load process finished. At least not with a non-empty jump mark
1362 [ - + ]: 1727 : if ( !sJumpMark.isEmpty() )
1363 [ # # ][ # # ]: 0 : m_pData->m_pViewShell->JumpToMark( sJumpMark );
[ # # ]
1364 : :
1365 : : // if no plugin mode and no jump mark was supplied, check whether the document itself can provide view data, and
1366 : : // if so, forward it to the view/shell.
1367 [ + - ][ + - ]: 1727 : if ( !bHasPluginMode && !bHasJumpMark )
1368 : : {
1369 : : // Note that this might not be the ideal place here. Restoring view data should, IMO, be the
1370 : : // responsibility of the loader, not an implementation detail burried here deep within the controller's
1371 : : // implementation.
1372 : : // What I think should be done to replace the below code:
1373 : : // - change SfxBaseController::restoreViewData to also accept a PropertyValue[] (it currently accepts
1374 : : // a string only), and forward it to its ViewShell's ReadUserDataSequence
1375 : : // - change the frame loader so that when a new document is loaded (as opposed to an existing
1376 : : // document being loaded into a new frame), the model's view data is examine the very same
1377 : : // way as below, and the proper view data is set via XController::restoreViewData
1378 : : // - extend SfxViewFrame::SwitchToViewShell_Impl. Currently, it cares for the case where a non-PrintPreview
1379 : : // view is exchanged, and sets the old view's data at the model. It should also care for the other
1380 : : // way, were the PrintPreview view is left: in this case, the new view should also be initialized
1381 : : // with the model's view data
1382 : : try
1383 : : {
1384 [ + - ][ + - ]: 1727 : Reference< XViewDataSupplier > xViewDataSupplier( getModel(), UNO_QUERY_THROW );
1385 [ + - ][ + - ]: 1727 : Reference< XIndexAccess > xViewData( xViewDataSupplier->getViewData() );
1386 : :
1387 : : // find the view data item whose ViewId matches the ID of the view we're just connecting to
1388 [ + - ]: 1727 : const SfxObjectFactory& rDocFactory( rDoc.GetFactory() );
1389 [ + + ][ + - ]: 1727 : const sal_Int32 nCount = xViewData.is() ? xViewData->getCount() : 0;
[ + - ]
1390 : 1727 : sal_Int32 nViewDataIndex = 0;
1391 [ + + ]: 2023 : for ( sal_Int32 i=0; i<nCount; ++i )
1392 : : {
1393 [ + - ][ + - ]: 1715 : const ::comphelper::NamedValueCollection aViewData( xViewData->getByIndex(i) );
[ + - ]
1394 [ + - ]: 1715 : ::rtl::OUString sViewId( aViewData.getOrDefault( "ViewId", ::rtl::OUString() ) );
1395 [ + + ]: 1715 : if ( sViewId.isEmpty() )
1396 : 279 : continue;
1397 : :
1398 [ + - ][ + - ]: 1436 : const SfxViewFactory* pViewFactory = rDocFactory.GetViewFactoryByViewName( sViewId );
[ + - ]
1399 [ + + ]: 1436 : if ( pViewFactory == NULL )
1400 : 1 : continue;
1401 : :
1402 [ + - ][ + + ]: 1435 : if ( pViewFactory->GetOrdinal() == pViewFrame->GetCurViewId() )
1403 : : {
1404 : 1435 : nViewDataIndex = i;
1405 : : break;
1406 : : }
1407 [ + + + ]: 1715 : }
[ + - ]
[ + + + ]
1408 [ + + ]: 1727 : if ( nViewDataIndex < nCount )
1409 : : {
1410 [ + - ]: 1715 : Sequence< PropertyValue > aViewData;
1411 [ + - ][ + - ]: 1715 : OSL_VERIFY( xViewData->getByIndex( nViewDataIndex ) >>= aViewData );
[ + - ]
1412 [ + + ]: 1715 : if ( aViewData.getLength() > 0 )
1413 [ + - ][ + - ]: 1715 : m_pData->m_pViewShell->ReadUserDataSequence( aViewData, sal_True );
1414 [ # # ]: 1727 : }
1415 : : }
1416 [ # # ]: 0 : catch (const Exception&)
1417 : : {
1418 : : DBG_UNHANDLED_EXCEPTION();
1419 : : }
1420 [ + - ][ + - ]: 1727 : }
1421 : : }
1422 : : }
1423 : :
1424 : : // invalidate slot corresponding to the view shell
1425 : 1733 : const sal_uInt16 nViewNo = m_pData->m_pViewShell->GetObjectShell()->GetFactory().GetViewNo_Impl( pViewFrame->GetCurViewId(), USHRT_MAX );
1426 : : DBG_ASSERT( nViewNo != USHRT_MAX, "view shell id not found" );
1427 [ + - ]: 1733 : if ( nViewNo != USHRT_MAX )
1428 : 1733 : pViewFrame->GetBindings().Invalidate( nViewNo + SID_VIEWSHELL0 );
1429 : 1733 : }
1430 : :
1431 : : //=============================================================================
1432 : 8500 : css::uno::Reference< css::frame::XTitle > SfxBaseController::impl_getTitleHelper ()
1433 : : {
1434 [ + - ]: 8500 : SolarMutexGuard aGuard;
1435 : :
1436 [ + + ]: 8500 : if ( ! m_pData->m_xTitleHelper.is ())
1437 : : {
1438 [ + - ]: 1727 : css::uno::Reference< css::frame::XModel > xModel = getModel ();
1439 [ + - ]: 1727 : css::uno::Reference< css::frame::XUntitledNumbers > xUntitledProvider(xModel , css::uno::UNO_QUERY );
1440 [ + - ]: 1727 : css::uno::Reference< css::frame::XController > xThis (static_cast< css::frame::XController* >(this), css::uno::UNO_QUERY_THROW);
1441 : :
1442 [ + - ][ + - ]: 1727 : ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(::comphelper::getProcessServiceFactory());
1443 [ + - ][ + - ]: 1727 : m_pData->m_xTitleHelper = css::uno::Reference< css::frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pHelper), css::uno::UNO_QUERY_THROW);
1444 : :
1445 [ + - ]: 1727 : pHelper->setOwner (xThis );
1446 [ + - ]: 1727 : pHelper->connectWithUntitledNumbers (xUntitledProvider);
1447 : : }
1448 : :
1449 [ + - ]: 8500 : return m_pData->m_xTitleHelper;
1450 : : }
1451 : :
1452 : : //=============================================================================
1453 : : // css::frame::XTitle
1454 : 6755 : ::rtl::OUString SAL_CALL SfxBaseController::getTitle()
1455 : : throw (css::uno::RuntimeException)
1456 : : {
1457 [ + - ][ + - ]: 6755 : return impl_getTitleHelper()->getTitle ();
1458 : : }
1459 : :
1460 : : //=============================================================================
1461 : : // css::frame::XTitle
1462 : 0 : void SAL_CALL SfxBaseController::setTitle(const ::rtl::OUString& sTitle)
1463 : : throw (css::uno::RuntimeException)
1464 : : {
1465 [ # # ][ # # ]: 0 : impl_getTitleHelper()->setTitle (sTitle);
1466 : 0 : }
1467 : :
1468 : : //=============================================================================
1469 : : // css::frame::XTitleChangeBroadcaster
1470 : 1727 : void SAL_CALL SfxBaseController::addTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener)
1471 : : throw (css::uno::RuntimeException)
1472 : : {
1473 [ + - ][ + - ]: 1727 : css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper(), css::uno::UNO_QUERY);
1474 [ + - ]: 1727 : if (xBroadcaster.is ())
1475 [ + - ][ + - ]: 1727 : xBroadcaster->addTitleChangeListener (xListener);
1476 : 1727 : }
1477 : :
1478 : : //=============================================================================
1479 : : // css::frame::XTitleChangeBroadcaster
1480 : 18 : void SAL_CALL SfxBaseController::removeTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener)
1481 : : throw (css::uno::RuntimeException)
1482 : : {
1483 [ + - ][ + - ]: 18 : css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper(), css::uno::UNO_QUERY);
1484 [ + - ]: 18 : if (xBroadcaster.is ())
1485 [ + - ][ + - ]: 18 : xBroadcaster->removeTitleChangeListener (xListener);
1486 : 18 : }
1487 : :
1488 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|