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 : :
21 : : #ifdef SOLARIS
22 : : #include <ctime>
23 : : #endif
24 : :
25 : : #include <string> // prevent conflict with STL includes
26 : : #include <com/sun/star/uno/Reference.h>
27 : : #include <com/sun/star/frame/XFrame.hpp>
28 : : #include <com/sun/star/awt/XWindow.hpp>
29 : : #include <com/sun/star/util/URL.hpp>
30 : : #include <com/sun/star/util/URLTransformer.hpp>
31 : : #include <com/sun/star/util/XURLTransformer.hpp>
32 : : #include <com/sun/star/frame/XController.hpp>
33 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
34 : : #include <com/sun/star/document/MacroExecMode.hpp>
35 : : #include <com/sun/star/document/UpdateDocMode.hpp>
36 : : #include <com/sun/star/frame/XComponentLoader.hpp>
37 : : #include <com/sun/star/beans/PropertyValue.hpp>
38 : : #include <com/sun/star/beans/XPropertySet.hpp>
39 : : #include <com/sun/star/frame/XLayoutManager.hpp>
40 : : #include <com/sun/star/frame/status/ItemStatus.hpp>
41 : : #include <com/sun/star/frame/status/ItemState.hpp>
42 : : #include <com/sun/star/ui/XUIElementFactory.hpp>
43 : : #include <com/sun/star/frame/XModuleManager.hpp>
44 : : #include <com/sun/star/container/XNameAccess.hpp>
45 : : #include <com/sun/star/ui/XUIFunctionListener.hpp>
46 : : #include <com/sun/star/frame/status/Visibility.hpp>
47 : : #include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
48 : : #include <svl/eitem.hxx>
49 : : #include <svl/stritem.hxx>
50 : : #include <svl/intitem.hxx>
51 : : #include <svl/imageitm.hxx>
52 : : #include <svl/visitem.hxx>
53 : : #include <svl/urlbmk.hxx>
54 : : #include <vcl/toolbox.hxx>
55 : : #include <unotools/moduleoptions.hxx>
56 : :
57 : : #include <svtools/imagemgr.hxx>
58 : : #include <comphelper/processfactory.hxx>
59 : : #include <framework/addonmenu.hxx>
60 : : #include <framework/addonsoptions.hxx>
61 : : #include <framework/menuconfiguration.hxx>
62 : : #include <framework/sfxhelperfunctions.hxx>
63 : : #include <vcl/taskpanelist.hxx>
64 : : #include <toolkit/helper/vclunohelper.hxx>
65 : : #include <svtools/menuoptions.hxx>
66 : : #include <svtools/miscopt.hxx>
67 : :
68 : : #include <sfx2/tbxctrl.hxx>
69 : : #include <sfx2/mnumgr.hxx>
70 : : #include <sfx2/dispatch.hxx>
71 : : #include "fltfnc.hxx"
72 : : #include <sfx2/msg.hxx>
73 : : #include <sfx2/msgpool.hxx>
74 : : #include "statcach.hxx"
75 : : #include <sfx2/viewfrm.hxx>
76 : : #include "arrdecl.hxx"
77 : : #include "sfxtypes.hxx"
78 : : #include <sfx2/genlink.hxx>
79 : : #include "sfx2/sfxresid.hxx"
80 : : #include <sfx2/sfx.hrc>
81 : : #include <sfx2/module.hxx>
82 : : #include <sfx2/docfile.hxx>
83 : : #include <sfx2/docfac.hxx>
84 : : #include "referers.hxx"
85 : : #include <sfx2/frmhtmlw.hxx>
86 : : #include <sfx2/app.hxx>
87 : : #include <sfx2/unoctitm.hxx>
88 : : #include "helpid.hrc"
89 : : #include "workwin.hxx"
90 : : #include "sfx2/imgmgr.hxx"
91 : : #include "virtmenu.hxx"
92 : : #include "sfx2/imagemgr.hxx"
93 : :
94 : : using namespace ::com::sun::star::beans;
95 : : using namespace ::com::sun::star::frame;
96 : : using namespace ::com::sun::star::frame::status;
97 : : using namespace ::com::sun::star::lang;
98 : : using namespace ::com::sun::star::uno;
99 : : using namespace ::com::sun::star::util;
100 : : using namespace ::com::sun::star::container;
101 : : using namespace ::com::sun::star::frame;
102 : : using namespace ::com::sun::star::ui;
103 : :
104 : : //====================================================================
105 : :
106 [ # # ]: 233 : SFX_IMPL_TOOLBOX_CONTROL_ARG(SfxToolBoxControl, SfxStringItem, sal_True);
107 [ + - ]: 1643 : SFX_IMPL_TOOLBOX_CONTROL(SfxAppToolBoxControl_Impl, SfxStringItem);
108 : :
109 : 0 : static Window* GetTopMostParentSystemWindow( Window* pWindow )
110 : : {
111 : : OSL_ASSERT( pWindow );
112 [ # # ]: 0 : if ( pWindow )
113 : : {
114 : : // ->manually search topmost system window
115 : : // required because their might be another system window between this and the top window
116 : 0 : pWindow = pWindow->GetParent();
117 : 0 : SystemWindow* pTopMostSysWin = NULL;
118 [ # # ]: 0 : while ( pWindow )
119 : : {
120 [ # # ]: 0 : if ( pWindow->IsSystemWindow() )
121 : 0 : pTopMostSysWin = (SystemWindow*)pWindow;
122 : 0 : pWindow = pWindow->GetParent();
123 : : }
124 : 0 : pWindow = pTopMostSysWin;
125 : : OSL_ASSERT( pWindow );
126 : 0 : return pWindow;
127 : : }
128 : :
129 : 0 : return NULL;
130 : : }
131 : :
132 : 69396 : svt::ToolboxController* SAL_CALL SfxToolBoxControllerFactory( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const ::rtl::OUString& aCommandURL )
133 : : {
134 [ + - ]: 69396 : SolarMutexGuard aGuard;
135 : :
136 : 69396 : URL aTargetURL;
137 : 69396 : aTargetURL.Complete = aCommandURL;
138 [ + - ][ + - ]: 69396 : Reference < XURLTransformer > xTrans( URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
139 [ + - ][ + - ]: 69396 : xTrans->parseStrict( aTargetURL );
140 [ - + ]: 69396 : if ( !aTargetURL.Arguments.isEmpty() )
141 : 0 : return NULL;
142 : :
143 : 69396 : SfxObjectShell* pObjShell = NULL;
144 : 69396 : Reference < XController > xController;
145 : 69396 : Reference < XModel > xModel;
146 [ + - ]: 69396 : if ( rFrame.is() )
147 : : {
148 [ + - ][ + - ]: 69396 : xController = rFrame->getController();
[ + - ]
149 [ + - ]: 69396 : if ( xController.is() )
150 [ + - ][ + - ]: 69396 : xModel = xController->getModel();
[ + - ]
151 : : }
152 : :
153 [ + + ]: 69396 : if ( xModel.is() )
154 : : {
155 : : // Get tunnel from model to retrieve the SfxObjectShell pointer from it
156 [ + - ]: 69356 : ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( xModel, UNO_QUERY );
157 [ + - ]: 69356 : if ( xObj.is() )
158 : : {
159 [ + - ][ + - ]: 69356 : ::com::sun::star::uno::Sequence < sal_Int8 > aSeq = SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence();
[ + - ]
160 [ + - ][ + - ]: 69356 : sal_Int64 nHandle = xObj->getSomething( aSeq );
161 [ + + ]: 69356 : if ( nHandle )
162 [ + - ]: 69356 : pObjShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
163 : 69356 : }
164 : : }
165 : :
166 [ + + ][ + - ]: 69396 : SfxModule* pModule = pObjShell ? pObjShell->GetModule() : NULL;
167 : 69396 : SfxSlotPool* pSlotPool = 0;
168 : :
169 [ + + ]: 69396 : if ( pModule )
170 [ + - ]: 68370 : pSlotPool = pModule->GetSlotPool();
171 : : else
172 [ + - ]: 1026 : pSlotPool = &(SfxSlotPool::GetSlotPool( NULL ));
173 : :
174 [ + - ][ + - ]: 69396 : const SfxSlot* pSlot = pSlotPool->GetUnoSlot( aTargetURL.Path );
[ + - ]
175 [ + + ]: 69396 : if ( pSlot )
176 : : {
177 : 68534 : sal_uInt16 nSlotId = pSlot->GetSlotId();
178 [ + - ]: 68534 : if ( nSlotId > 0 )
179 [ + - ][ + + ]: 68534 : return SfxToolBoxControl::CreateControl( nSlotId, nID, pToolbox, pModule );
180 : : }
181 : :
182 [ + - ]: 69396 : return NULL;
183 : : }
184 : :
185 : 36060 : struct SfxToolBoxControl_Impl
186 : : {
187 : : ToolBox* pBox;
188 : : sal_Bool bShowString;
189 : : sal_uInt16 nSelectModifier;
190 : : SfxTbxCtrlFactory* pFact;
191 : : sal_uInt16 nTbxId;
192 : : sal_uInt16 nSlotId;
193 : : SfxPopupWindow* mpFloatingWindow;
194 : : SfxPopupWindow* mpPopupWindow;
195 : : Reference< XUIElement > mxUIElement;
196 : :
197 : : DECL_LINK( WindowEventListener, VclSimpleEvent* );
198 : : };
199 : :
200 : 0 : IMPL_LINK( SfxToolBoxControl_Impl, WindowEventListener, VclSimpleEvent*, pEvent )
201 : : {
202 [ # # # # : 0 : if ( pEvent &&
# # # # ]
[ # # ]
203 : 0 : pEvent->ISA( VclWindowEvent ) &&
204 : 0 : (( pEvent->GetId() == VCLEVENT_WINDOW_MOVE ) ||
205 : 0 : ( pEvent->GetId() == VCLEVENT_WINDOW_ACTIVATE )))
206 : : {
207 : 0 : Window* pWindow( ((VclWindowEvent*)pEvent)->GetWindow() );
208 [ # # ][ # # ]: 0 : if (( pWindow == mpFloatingWindow ) &&
209 : : ( mpPopupWindow != 0 ))
210 : : {
211 [ # # ]: 0 : delete mpPopupWindow;
212 : 0 : mpPopupWindow = 0;
213 : : }
214 : : }
215 : :
216 : 0 : return 1;
217 : : }
218 : :
219 : : //--------------------------------------------------------------------
220 : :
221 : 18030 : SfxToolBoxControl::SfxToolBoxControl(
222 : : sal_uInt16 nSlotID,
223 : : sal_uInt16 nID,
224 : : ToolBox& rBox,
225 : : sal_Bool bShowStringItems )
226 [ + - ]: 18030 : : svt::ToolboxController()
227 : : {
228 [ + - ][ + - ]: 18030 : pImpl = new SfxToolBoxControl_Impl;
229 : :
230 : 18030 : pImpl->pBox = &rBox;
231 : 18030 : pImpl->bShowString = bShowStringItems;
232 : 18030 : pImpl->nSelectModifier = 0;
233 : 18030 : pImpl->pFact = 0;
234 : 18030 : pImpl->nTbxId = nID;
235 : 18030 : pImpl->nSlotId = nSlotID;
236 : 18030 : pImpl->mpFloatingWindow = 0;
237 : 18030 : pImpl->mpPopupWindow = 0;
238 : 18030 : }
239 : :
240 : : //--------------------------------------------------------------------
241 : :
242 [ + - ]: 18030 : SfxToolBoxControl::~SfxToolBoxControl()
243 : : {
244 [ - + ]: 18030 : if ( pImpl->mxUIElement.is() )
245 : : {
246 [ # # ]: 0 : Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY );
247 [ # # ][ # # ]: 0 : xComponent->dispose();
248 : : }
249 [ + - ]: 18030 : pImpl->mxUIElement = 0;
250 [ + - ][ + - ]: 18030 : delete pImpl;
251 [ - + ]: 18030 : }
252 : :
253 : : //--------------------------------------------------------------------
254 : :
255 : 75904 : ToolBox& SfxToolBoxControl::GetToolBox() const
256 : : {
257 : 75904 : return *pImpl->pBox;
258 : : }
259 : 120456 : unsigned short SfxToolBoxControl::GetId() const
260 : : {
261 : 120456 : return pImpl->nTbxId;
262 : : }
263 : 129 : unsigned short SfxToolBoxControl::GetSlotId() const
264 : : {
265 : 129 : return pImpl->nSlotId;
266 : : }
267 : :
268 : : //--------------------------------------------------------------------
269 : :
270 : 17826 : void SAL_CALL SfxToolBoxControl::dispose() throw (::com::sun::star::uno::RuntimeException)
271 : : {
272 [ + - ]: 17826 : if ( m_bDisposed )
273 : 17826 : return;
274 : :
275 [ + - ]: 17826 : svt::ToolboxController::dispose();
276 : :
277 : : // Remove and destroy our item window at our toolbox
278 [ + - ]: 17826 : SolarMutexGuard aGuard;
279 [ + - ]: 17826 : Window* pWindow = pImpl->pBox->GetItemWindow( pImpl->nTbxId );
280 [ + - ]: 17826 : pImpl->pBox->SetItemWindow( pImpl->nTbxId, 0 );
281 [ + + ][ + - ]: 17826 : delete pWindow;
282 : :
283 : : // Dispose an open sub toolbar. It's possible that we have an open
284 : : // sub toolbar while we get disposed. Therefore we have to dispose
285 : : // it now! Not doing so would result in a crash. The sub toolbar
286 : : // gets destroyed asynchronously and would access a non-existing
287 : : // parent toolbar!
288 [ - + ]: 17826 : if ( pImpl->mxUIElement.is() )
289 : : {
290 [ # # ]: 0 : Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY );
291 [ # # ][ # # ]: 0 : xComponent->dispose();
292 : : }
293 [ + - ]: 17826 : pImpl->mxUIElement = 0;
294 : :
295 : : // Delete my popup windows
296 [ - + ][ # # ]: 17826 : delete pImpl->mpFloatingWindow;
297 [ - + ][ # # ]: 17826 : delete pImpl->mpPopupWindow;
298 : :
299 : 17826 : pImpl->mpFloatingWindow = 0;
300 [ + - ]: 17826 : pImpl->mpPopupWindow = 0;
301 : : }
302 : :
303 : : //--------------------------------------------------------------------
304 : 9756 : void SfxToolBoxControl::RegisterToolBoxControl( SfxModule* pMod, SfxTbxCtrlFactory* pFact)
305 : : {
306 : 9756 : SFX_APP()->RegisterToolBoxControl_Impl( pMod, pFact );
307 : 9756 : }
308 : :
309 : 68534 : SfxToolBoxControl* SfxToolBoxControl::CreateControl( sal_uInt16 nSlotId, sal_uInt16 nTbxId, ToolBox *pBox, SfxModule* pMod )
310 : : {
311 [ + - ]: 68534 : SolarMutexGuard aGuard;
312 : :
313 : : SfxToolBoxControl *pCtrl;
314 [ + - ]: 68534 : SfxApplication *pApp = SFX_APP();
315 : :
316 : : SfxSlotPool *pSlotPool;
317 [ + + ]: 68534 : if ( pMod )
318 [ + - ]: 68078 : pSlotPool = pMod->GetSlotPool();
319 : : else
320 [ + - ]: 456 : pSlotPool = &SfxSlotPool::GetSlotPool();
321 [ + - ]: 68534 : TypeId aSlotType = pSlotPool->GetSlotType( nSlotId );
322 [ + - ]: 68534 : if ( aSlotType )
323 : : {
324 [ + + ]: 68534 : if ( pMod )
325 : : {
326 [ + - ]: 68078 : SfxTbxCtrlFactArr_Impl *pFactories = pMod->GetTbxCtrlFactories_Impl();
327 [ + - ]: 68078 : if ( pFactories )
328 : : {
329 : 68078 : SfxTbxCtrlFactArr_Impl &rFactories = *pFactories;
330 : : sal_uInt16 nFactory;
331 : 68078 : const sal_uInt16 nCount = rFactories.size();
332 : :
333 : : // search for a factory with the given slot id
334 [ + + ]: 3241540 : for( nFactory = 0; nFactory < nCount; ++nFactory )
335 [ + + ][ + + ]: 3189462 : if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == nSlotId) )
[ + + ]
336 : 16000 : break;
337 : :
338 [ + + ]: 68078 : if( nFactory == nCount )
339 : : {
340 : : // if no factory exists for the given slot id, see if we
341 : : // have a generic factory with the correct slot type and slot id == 0
342 [ + + ]: 2810742 : for ( nFactory = 0; nFactory < nCount; ++nFactory )
343 [ + + ][ + + ]: 2758664 : if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == 0) )
[ + + ]
344 : 516 : break;
345 : : }
346 : :
347 [ + + ]: 68078 : if( nFactory < nCount )
348 : : {
349 [ + - ]: 16516 : pCtrl = rFactories[nFactory]->pCtor( nSlotId, nTbxId, *pBox );
350 : 16516 : pCtrl->pImpl->pFact = rFactories[nFactory];
351 : 16516 : return pCtrl;
352 : : }
353 : : }
354 : : }
355 : :
356 [ + - ]: 52018 : SfxTbxCtrlFactArr_Impl &rFactories = pApp->GetTbxCtrlFactories_Impl();
357 : : sal_uInt16 nFactory;
358 : 52018 : const sal_uInt16 nCount = rFactories.size();
359 : :
360 [ + + ]: 607036 : for( nFactory = 0; nFactory < nCount; ++nFactory )
361 [ + + ][ + + ]: 556328 : if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == nSlotId) )
[ + + ]
362 : 1310 : break;
363 : :
364 [ + + ]: 52018 : if( nFactory == nCount )
365 : : {
366 : : // if no factory exists for the given slot id, see if we
367 : : // have a generic factory with the correct slot type and slot id == 0
368 [ + + ]: 602840 : for( nFactory = 0; nFactory < nCount; ++nFactory )
369 [ + + ][ - + ]: 552132 : if( (rFactories[nFactory]->nTypeId == aSlotType) && (rFactories[nFactory]->nSlotId == 0) )
[ - + ]
370 : 0 : break;
371 : : }
372 : :
373 [ + + ]: 52018 : if( nFactory < nCount )
374 : : {
375 [ + - ]: 1310 : pCtrl = rFactories[nFactory]->pCtor( nSlotId, nTbxId, *pBox );
376 : 1310 : pCtrl->pImpl->pFact = rFactories[nFactory];
377 : 1310 : return pCtrl;
378 : : }
379 : : }
380 : :
381 [ + - ]: 68534 : return NULL;
382 : : }
383 : :
384 : 7206 : SfxItemState SfxToolBoxControl::GetItemState(
385 : : const SfxPoolItem* pState )
386 : : /* [Description]
387 : :
388 : : Static method for determining the status of the SfxPoolItem-pointer,
389 : : used in the method <SfxControllerItem::StateChanged(const SfxPoolItem*)>.
390 : :
391 : : [Return value]
392 : :
393 : : SfxItemState SFX_ITEM_UNKNOWN
394 : : Enabled, however no further status information is available.
395 : : Typical for <Slot>s, which are temporarily disabled a
396 : : anyway but other than that do not change their appearance.
397 : :
398 : : SFX_ITEM_DISABLED
399 : : Disabled, no further status information is available.
400 : : All other displayed values should be reset to the default
401 : : if possible.
402 : :
403 : : SFX_ITEM_DONTCARE
404 : : Enabled but there were only ambiguous values available
405 : : (i.e. none that could be queried).
406 : :
407 : : SFX_ITEM_AVAILABLE
408 : : Enabled and with available values which can be queried
409 : : through'pState'. The type is thus by the Slot clearly
410 : : defined in the entire Program.
411 : : */
412 : :
413 : : {
414 : : return !pState
415 : : ? SFX_ITEM_DISABLED
416 : 836 : : IsInvalidItem(pState)
417 : : ? SFX_ITEM_DONTCARE
418 : 836 : : pState->ISA(SfxVoidItem) && !pState->Which()
419 : : ? SFX_ITEM_UNKNOWN
420 [ + + + - : 8878 : : SFX_ITEM_AVAILABLE;
- + # # ]
421 : : }
422 : :
423 : 0 : void SfxToolBoxControl::Dispatch(
424 : : const Reference< XDispatchProvider >& rProvider,
425 : : const rtl::OUString& rCommand,
426 : : Sequence< ::PropertyValue >& aArgs )
427 : : {
428 [ # # ]: 0 : if ( rProvider.is() )
429 : : {
430 : 0 : ::com::sun::star::util::URL aTargetURL;
431 : 0 : aTargetURL.Complete = rCommand;
432 [ # # ][ # # ]: 0 : Reference < XURLTransformer > xTrans( URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
433 [ # # ][ # # ]: 0 : xTrans->parseStrict( aTargetURL );
434 : :
435 [ # # ][ # # ]: 0 : Reference < XDispatch > xDispatch = rProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
436 [ # # ]: 0 : if ( xDispatch.is() )
437 [ # # ][ # # ]: 0 : xDispatch->dispatch( aTargetURL, aArgs );
438 : : }
439 : 0 : }
440 : :
441 : 0 : void SfxToolBoxControl::Dispatch( const ::rtl::OUString& aCommand, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs )
442 : : {
443 : 0 : Reference < XController > xController;
444 : :
445 [ # # ]: 0 : SolarMutexGuard aGuard;
446 [ # # ][ # # ]: 0 : if ( getFrameInterface().is() )
447 [ # # ][ # # ]: 0 : xController = getFrameInterface()->getController();
[ # # ][ # # ]
448 : :
449 [ # # ]: 0 : Reference < XDispatchProvider > xProvider( xController, UNO_QUERY );
450 [ # # ]: 0 : if ( xProvider.is() )
451 : : {
452 : 0 : ::com::sun::star::util::URL aTargetURL;
453 : 0 : aTargetURL.Complete = aCommand;
454 [ # # ][ # # ]: 0 : getURLTransformer()->parseStrict( aTargetURL );
[ # # ]
455 : :
456 [ # # ][ # # ]: 0 : Reference < XDispatch > xDispatch = xProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
457 [ # # ]: 0 : if ( xDispatch.is() )
458 [ # # ][ # # ]: 0 : xDispatch->dispatch( aTargetURL, aArgs );
459 [ # # ]: 0 : }
460 : 0 : }
461 : :
462 : : // XInterface
463 : 183249 : Any SAL_CALL SfxToolBoxControl::queryInterface( const Type & rType )
464 : : throw(::com::sun::star::uno::RuntimeException)
465 : : {
466 : : ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
467 : : (static_cast< ::com::sun::star::awt::XDockableWindowListener* >(this)),
468 [ + - ]: 183249 : (static_cast< ::com::sun::star::frame::XSubToolbarController* >(this)));
469 [ + + ][ + - ]: 183249 : return (aRet.hasValue() ? aRet : svt::ToolboxController::queryInterface( rType ));
470 : : }
471 : :
472 : 536001 : void SAL_CALL SfxToolBoxControl::acquire() throw()
473 : : {
474 : 536001 : OWeakObject::acquire();
475 : 536001 : }
476 : :
477 : 536001 : void SAL_CALL SfxToolBoxControl::release() throw()
478 : : {
479 : 536001 : OWeakObject::release();
480 : 536001 : }
481 : :
482 : 0 : void SAL_CALL SfxToolBoxControl::disposing( const ::com::sun::star::lang::EventObject& aEvent )
483 : : throw( ::com::sun::star::uno::RuntimeException )
484 : : {
485 : 0 : svt::ToolboxController::disposing( aEvent );
486 : 0 : }
487 : :
488 : : // XStatusListener
489 : 41901 : void SAL_CALL SfxToolBoxControl::statusChanged( const FeatureStateEvent& rEvent )
490 : : throw ( ::com::sun::star::uno::RuntimeException )
491 : : {
492 : 41901 : SfxViewFrame* pViewFrame = NULL;
493 : 41901 : Reference < XController > xController;
494 : :
495 [ + - ]: 41901 : SolarMutexGuard aGuard;
496 [ + - ][ + - ]: 41901 : if ( getFrameInterface().is() )
497 [ + - ][ + - ]: 41901 : xController = getFrameInterface()->getController();
[ + - ][ + - ]
498 : :
499 [ + - ]: 41901 : Reference < XDispatchProvider > xProvider( xController, UNO_QUERY );
500 [ + - ]: 41901 : if ( xProvider.is() )
501 : : {
502 [ + - ][ + - ]: 41901 : Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 );
503 [ + + ]: 41901 : if ( xDisp.is() )
504 : : {
505 [ + - ]: 41867 : Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY );
506 : 41867 : SfxOfficeDispatch* pDisp = NULL;
507 [ + - ]: 41867 : if ( xTunnel.is() )
508 : : {
509 [ + - ][ + - ]: 41867 : sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier());
[ + - ]
510 : 41867 : pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation ));
511 : : }
512 : :
513 [ + - ]: 41867 : if ( pDisp )
514 [ + - ][ + - ]: 41867 : pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame();
515 : 41901 : }
516 : : }
517 : :
518 : 41901 : sal_uInt16 nSlotId = 0;
519 [ + - ]: 41901 : SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame );
520 [ + - ][ + - ]: 41901 : const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path );
[ + - ]
521 [ + - ]: 41901 : if ( pSlot )
522 : 41901 : nSlotId = pSlot->GetSlotId();
523 [ # # ]: 0 : else if ( m_aCommandURL == rEvent.FeatureURL.Path )
524 [ # # ]: 0 : nSlotId = GetSlotId();
525 : :
526 [ + - ]: 41901 : if ( nSlotId > 0 )
527 : : {
528 [ - + ]: 41901 : if ( rEvent.Requery )
529 [ # # ]: 0 : svt::ToolboxController::statusChanged( rEvent );
530 : : else
531 : : {
532 : 41901 : SfxItemState eState = SFX_ITEM_DISABLED;
533 : 41901 : SfxPoolItem* pItem = NULL;
534 [ + + ]: 41901 : if ( rEvent.IsEnabled )
535 : : {
536 : 31085 : eState = SFX_ITEM_AVAILABLE;
537 : 31085 : ::com::sun::star::uno::Type pType = rEvent.State.getValueType();
538 : :
539 [ + + ][ + - ]: 31085 : if ( pType == ::getVoidCppuType() )
540 : : {
541 [ + - ][ + - ]: 8345 : pItem = new SfxVoidItem( nSlotId );
542 : 8345 : eState = SFX_ITEM_UNKNOWN;
543 : : }
544 [ + - ][ + + ]: 22740 : else if ( pType == ::getBooleanCppuType() )
545 : : {
546 : 6105 : sal_Bool bTemp = false;
547 : 6105 : rEvent.State >>= bTemp ;
548 [ + - ][ + - ]: 6105 : pItem = new SfxBoolItem( nSlotId, bTemp );
549 : : }
550 [ + - ][ - + ]: 16635 : else if ( pType == ::getCppuType((const sal_uInt16*)0) )
551 : : {
552 : 0 : sal_uInt16 nTemp = 0;
553 : 0 : rEvent.State >>= nTemp ;
554 [ # # ][ # # ]: 0 : pItem = new SfxUInt16Item( nSlotId, nTemp );
555 : : }
556 [ + - ][ - + ]: 16635 : else if ( pType == ::getCppuType((const sal_uInt32*)0) )
557 : : {
558 : 0 : sal_uInt32 nTemp = 0;
559 : 0 : rEvent.State >>= nTemp ;
560 [ # # ][ # # ]: 0 : pItem = new SfxUInt32Item( nSlotId, nTemp );
561 : : }
562 [ + - ][ + + ]: 16635 : else if ( pType == ::getCppuType((const ::rtl::OUString*)0) )
563 : : {
564 : 2680 : ::rtl::OUString sTemp ;
565 : 2680 : rEvent.State >>= sTemp ;
566 [ + - ][ + - ]: 2680 : pItem = new SfxStringItem( nSlotId, sTemp );
[ + - ][ + - ]
567 : : }
568 [ + - ][ - + ]: 13955 : else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) )
569 : : {
570 : 0 : ItemStatus aItemStatus;
571 [ # # ]: 0 : rEvent.State >>= aItemStatus;
572 : 0 : eState = aItemStatus.State;
573 [ # # ][ # # ]: 0 : pItem = new SfxVoidItem( nSlotId );
574 : : }
575 [ + - ][ - + ]: 13955 : else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::Visibility*)0) )
576 : : {
577 : 0 : Visibility aVisibilityStatus;
578 [ # # ]: 0 : rEvent.State >>= aVisibilityStatus;
579 [ # # ][ # # ]: 0 : pItem = new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible );
580 : : }
581 : : else
582 : : {
583 [ + - ]: 13955 : if ( pSlot )
584 [ + - ]: 13955 : pItem = pSlot->GetType()->CreateItem();
585 [ + - ]: 13955 : if ( pItem )
586 : : {
587 : 13955 : pItem->SetWhich( nSlotId );
588 [ + - ]: 13955 : pItem->PutValue( rEvent.State );
589 : : }
590 : : else
591 [ # # ][ # # ]: 0 : pItem = new SfxVoidItem( nSlotId );
592 : 31085 : }
593 : : }
594 : :
595 [ + - ]: 41901 : StateChanged( nSlotId, eState, pItem );
596 [ + + ][ + - ]: 41901 : delete pItem;
597 : : }
598 [ + - ]: 41901 : }
599 : 41901 : }
600 : :
601 : : // XSubToolbarController
602 : 17052 : ::sal_Bool SAL_CALL SfxToolBoxControl::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException)
603 : : {
604 : 17052 : return sal_False;
605 : : }
606 : :
607 : 0 : ::rtl::OUString SAL_CALL SfxToolBoxControl::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException)
608 : : {
609 : 0 : return rtl::OUString();
610 : : }
611 : :
612 : 0 : void SAL_CALL SfxToolBoxControl::functionSelected( const ::rtl::OUString& /*aCommand*/ ) throw (::com::sun::star::uno::RuntimeException)
613 : : {
614 : : // must be implemented by sub-class
615 : 0 : }
616 : :
617 : 0 : void SAL_CALL SfxToolBoxControl::updateImage() throw (::com::sun::star::uno::RuntimeException)
618 : : {
619 : : // must be implemented by sub-class
620 : 0 : }
621 : :
622 : : // XToolbarController
623 : 0 : void SAL_CALL SfxToolBoxControl::execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException)
624 : : {
625 [ # # ]: 0 : SolarMutexGuard aGuard;
626 [ # # ][ # # ]: 0 : Select( (sal_uInt16)KeyModifier );
627 : 0 : }
628 : 0 : void SAL_CALL SfxToolBoxControl::click() throw (::com::sun::star::uno::RuntimeException)
629 : : {
630 [ # # ]: 0 : SolarMutexGuard aGuard;
631 [ # # ][ # # ]: 0 : Click();
632 : 0 : }
633 : :
634 : 0 : void SAL_CALL SfxToolBoxControl::doubleClick() throw (::com::sun::star::uno::RuntimeException)
635 : : {
636 [ # # ]: 0 : SolarMutexGuard aGuard;
637 [ # # ][ # # ]: 0 : DoubleClick();
638 : 0 : }
639 : :
640 : 0 : Reference< ::com::sun::star::awt::XWindow > SAL_CALL SfxToolBoxControl::createPopupWindow() throw (::com::sun::star::uno::RuntimeException)
641 : : {
642 [ # # ]: 0 : SolarMutexGuard aGuard;
643 [ # # ]: 0 : Window* pWindow = CreatePopupWindow();
644 [ # # ]: 0 : if ( pWindow )
645 [ # # ]: 0 : return VCLUnoHelper::GetInterface( pWindow );
646 : : else
647 [ # # ]: 0 : return Reference< ::com::sun::star::awt::XWindow >();
648 : : }
649 : :
650 : 17826 : Reference< ::com::sun::star::awt::XWindow > SAL_CALL SfxToolBoxControl::createItemWindow( const Reference< ::com::sun::star::awt::XWindow >& rParent ) throw (::com::sun::star::uno::RuntimeException)
651 : : {
652 [ + - ]: 17826 : SolarMutexGuard aGuard;
653 [ + - ][ + - ]: 17826 : return VCLUnoHelper::GetInterface( CreateItemWindow( VCLUnoHelper::GetWindow( rParent )));
[ + - ][ + - ]
654 : : }
655 : :
656 : : // XDockableWindowListener
657 : 0 : void SAL_CALL SfxToolBoxControl::startDocking( const ::com::sun::star::awt::DockingEvent& )
658 : : throw (::com::sun::star::uno::RuntimeException)
659 : : {
660 : 0 : }
661 : 0 : ::com::sun::star::awt::DockingData SAL_CALL SfxToolBoxControl::docking( const ::com::sun::star::awt::DockingEvent& )
662 : : throw (::com::sun::star::uno::RuntimeException)
663 : : {
664 : 0 : return ::com::sun::star::awt::DockingData();
665 : : }
666 : :
667 : 0 : void SAL_CALL SfxToolBoxControl::endDocking( const ::com::sun::star::awt::EndDockingEvent& )
668 : : throw (::com::sun::star::uno::RuntimeException)
669 : : {
670 : 0 : }
671 : :
672 : 0 : sal_Bool SAL_CALL SfxToolBoxControl::prepareToggleFloatingMode( const ::com::sun::star::lang::EventObject& )
673 : : throw (::com::sun::star::uno::RuntimeException)
674 : : {
675 : 0 : return sal_False;
676 : : }
677 : :
678 : 0 : void SAL_CALL SfxToolBoxControl::toggleFloatingMode( const ::com::sun::star::lang::EventObject& )
679 : : throw (::com::sun::star::uno::RuntimeException)
680 : : {
681 : 0 : }
682 : :
683 : 0 : void SAL_CALL SfxToolBoxControl::closed( const ::com::sun::star::lang::EventObject& )
684 : : throw (::com::sun::star::uno::RuntimeException)
685 : : {
686 : 0 : }
687 : :
688 : 0 : void SAL_CALL SfxToolBoxControl::endPopupMode( const ::com::sun::star::awt::EndPopupModeEvent& aEvent )
689 : : throw (::com::sun::star::uno::RuntimeException)
690 : : {
691 [ # # ]: 0 : SolarMutexGuard aGuard;
692 : :
693 : 0 : ::rtl::OUString aSubToolBarResName;
694 [ # # ]: 0 : if ( pImpl->mxUIElement.is() )
695 : : {
696 [ # # ]: 0 : Reference< XPropertySet > xPropSet( pImpl->mxUIElement, UNO_QUERY );
697 [ # # ]: 0 : if ( xPropSet.is() )
698 : : {
699 : : try
700 : : {
701 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( ::rtl::OUString( "ResourceURL" )) >>= aSubToolBarResName;
[ # # # ]
702 : : }
703 [ # # ]: 0 : catch ( com::sun::star::beans::UnknownPropertyException& )
704 : : {
705 : : }
706 [ # # ]: 0 : catch ( com::sun::star::lang::WrappedTargetException& )
707 : : {
708 : : }
709 : : }
710 : :
711 [ # # ]: 0 : Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY );
712 [ # # ][ # # ]: 0 : xComponent->dispose();
713 : : }
714 [ # # ]: 0 : pImpl->mxUIElement = 0;
715 : :
716 : : // if the toolbar was teared-off recreate it and place it at the given position
717 [ # # ]: 0 : if( aEvent.bTearoff )
718 : : {
719 : 0 : Reference< XUIElement > xUIElement;
720 [ # # ]: 0 : Reference< XLayoutManager > xLayoutManager = getLayoutManager();
721 : :
722 [ # # ]: 0 : if ( !xLayoutManager.is() )
723 : 0 : return;
724 : :
725 [ # # ][ # # ]: 0 : xLayoutManager->createElement( aSubToolBarResName );
726 [ # # ][ # # ]: 0 : xUIElement = xLayoutManager->getElement( aSubToolBarResName );
[ # # ]
727 [ # # ]: 0 : if ( xUIElement.is() )
728 : : {
729 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::awt::XWindow > xParent = getFrameInterface()->getContainerWindow();
[ # # ]
730 : :
731 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::awt::XWindow > xSubToolBar( xUIElement->getRealInterface(), UNO_QUERY );
[ # # ]
732 [ # # ]: 0 : Reference< ::com::sun::star::beans::XPropertySet > xProp( xUIElement, UNO_QUERY );
733 [ # # ][ # # ]: 0 : if ( xSubToolBar.is() && xProp.is() )
[ # # ]
734 : : {
735 : 0 : rtl::OUString aPersistentString( "Persistent" );
736 : : try
737 : : {
738 [ # # ]: 0 : Window* pTbxWindow = VCLUnoHelper::GetWindow( xSubToolBar );
739 [ # # ][ # # ]: 0 : if ( pTbxWindow && pTbxWindow->GetType() == WINDOW_TOOLBOX )
[ # # ][ # # ]
740 : : {
741 : 0 : Any a;
742 [ # # ][ # # ]: 0 : a = xProp->getPropertyValue( aPersistentString );
743 [ # # ][ # # ]: 0 : xProp->setPropertyValue( aPersistentString, makeAny( sal_False ));
[ # # ]
744 : :
745 [ # # ][ # # ]: 0 : xLayoutManager->hideElement( aSubToolBarResName );
746 [ # # ][ # # ]: 0 : xLayoutManager->floatWindow( aSubToolBarResName );
747 : :
748 [ # # ][ # # ]: 0 : xLayoutManager->setElementPos( aSubToolBarResName, aEvent.FloatingPosition );
749 [ # # ][ # # ]: 0 : xLayoutManager->showElement( aSubToolBarResName );
750 : :
751 [ # # ][ # # ]: 0 : xProp->setPropertyValue( rtl::OUString( "Persistent" ), a );
752 : : }
753 : : }
754 [ # # # ]: 0 : catch ( ::com::sun::star::uno::RuntimeException& )
755 : : {
756 : 0 : throw;
757 : : }
758 [ # # ]: 0 : catch ( ::com::sun::star::uno::Exception& )
759 : : {
760 : 0 : }
761 : 0 : }
762 [ # # ][ # # ]: 0 : }
763 [ # # ][ # # ]: 0 : }
[ # # ]
764 : : }
765 : :
766 : 0 : ::Size SfxToolBoxControl::getPersistentFloatingSize( const Reference< XFrame >& /*xFrame*/, const ::rtl::OUString& /*rSubToolBarResName*/ )
767 : : {
768 : 0 : ::Size aToolboxSize;
769 : 0 : return aToolboxSize;
770 : : }
771 : :
772 : 0 : void SfxToolBoxControl::createAndPositionSubToolBar( const ::rtl::OUString& rSubToolBarResName )
773 : : {
774 [ # # ]: 0 : SolarMutexGuard aGuard;
775 : :
776 [ # # ]: 0 : if ( pImpl->pBox )
777 : : {
778 [ # # ][ # # ]: 0 : static WeakReference< XUIElementFactory > xWeakUIElementFactory;
[ # # ][ # # ]
779 : :
780 : 0 : sal_uInt16 nItemId = pImpl->pBox->GetDownItemId();
781 : :
782 [ # # ]: 0 : if ( !nItemId )
783 : 0 : return;
784 : :
785 : : // create element with factory
786 [ # # ]: 0 : Reference< XMultiServiceFactory > xServiceManager = getServiceManager();
787 [ # # ]: 0 : Reference< XFrame > xFrame = getFrameInterface();
788 : 0 : Reference< XUIElement > xUIElement;
789 : 0 : Reference< XUIElementFactory > xUIEementFactory;
790 : :
791 [ # # ][ # # ]: 0 : xUIEementFactory = xWeakUIElementFactory;
792 [ # # ]: 0 : if ( !xUIEementFactory.is() )
793 : : {
794 : : xUIEementFactory = Reference< XUIElementFactory >(
795 [ # # ]: 0 : xServiceManager->createInstance(
796 : 0 : rtl::OUString( "com.sun.star.ui.UIElementFactoryManager" )),
797 [ # # ][ # # ]: 0 : UNO_QUERY );
[ # # ]
798 [ # # ]: 0 : xWeakUIElementFactory = xUIEementFactory;
799 : : }
800 : :
801 [ # # ]: 0 : Sequence< PropertyValue > aPropSeq( 3 );
802 [ # # ]: 0 : aPropSeq[0].Name = rtl::OUString( "Frame" );
803 [ # # ][ # # ]: 0 : aPropSeq[0].Value <<= xFrame;
804 [ # # ]: 0 : aPropSeq[1].Name = rtl::OUString( "Persistent" );
805 [ # # ][ # # ]: 0 : aPropSeq[1].Value <<= sal_False;
806 [ # # ]: 0 : aPropSeq[2].Name = rtl::OUString( "PopupMode" );
807 [ # # ][ # # ]: 0 : aPropSeq[2].Value <<= sal_True;
808 : :
809 : : try
810 : : {
811 [ # # ][ # # ]: 0 : xUIElement = xUIEementFactory->createUIElement( rSubToolBarResName, aPropSeq );
[ # # ]
[ # # # ]
812 : : }
813 [ # # ]: 0 : catch ( ::com::sun::star::container::NoSuchElementException& )
814 : : {
815 : : }
816 [ # # ]: 0 : catch ( IllegalArgumentException& )
817 : : {
818 : : }
819 : :
820 [ # # ]: 0 : if ( xUIElement.is() )
821 : : {
822 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::awt::XWindow > xParent = getFrameInterface()->getContainerWindow();
[ # # ]
823 : :
824 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::awt::XWindow > xSubToolBar( xUIElement->getRealInterface(), UNO_QUERY );
[ # # ]
825 [ # # ]: 0 : if ( xSubToolBar.is() )
826 : : {
827 [ # # ]: 0 : Reference< ::com::sun::star::awt::XDockableWindow > xDockWindow( xSubToolBar, UNO_QUERY );
828 [ # # ]: 0 : xDockWindow->addDockableWindowListener( Reference< ::com::sun::star::awt::XDockableWindowListener >(
829 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >( this ), UNO_QUERY ));
830 [ # # ][ # # ]: 0 : xDockWindow->enableDocking( sal_True );
831 : :
832 : : // keep refererence to UIElement to avoid its destruction
833 [ # # ]: 0 : if ( pImpl->mxUIElement.is() )
834 : : {
835 [ # # ]: 0 : Reference< XComponent > xComponent( pImpl->mxUIElement, UNO_QUERY );
836 [ # # ][ # # ]: 0 : xComponent->dispose();
837 : : }
838 [ # # ]: 0 : pImpl->mxUIElement = xUIElement;
839 : :
840 : 0 : Window* pParentTbxWindow( pImpl->pBox );
841 [ # # ]: 0 : Window* pTbxWindow = VCLUnoHelper::GetWindow( xSubToolBar );
842 : 0 : ToolBox* pToolBar( 0 );
843 [ # # ][ # # ]: 0 : if ( pTbxWindow && pTbxWindow->GetType() == WINDOW_TOOLBOX )
[ # # ][ # # ]
844 : 0 : pToolBar = (ToolBox *)pTbxWindow;
845 : :
846 [ # # ]: 0 : if ( pToolBar )
847 : : {
848 [ # # ]: 0 : pToolBar->SetParent( pParentTbxWindow );
849 [ # # ]: 0 : ::Size aSize = getPersistentFloatingSize( xFrame, rSubToolBarResName );
850 [ # # ][ # # ]: 0 : if ( aSize.Width() == 0 || aSize.Height() == 0 )
[ # # ]
851 : : {
852 : : // calc and set size for popup mode
853 [ # # ]: 0 : aSize = pToolBar->CalcPopupWindowSizePixel();
854 : : }
855 [ # # ]: 0 : pToolBar->SetSizePixel( aSize );
856 : :
857 : : // open subtoolbox in popup mode
858 [ # # ][ # # ]: 0 : Window::GetDockingManager()->StartPopupMode( pImpl->pBox, pToolBar );
859 : 0 : }
860 : 0 : }
861 [ # # ]: 0 : }
862 [ # # ][ # # ]: 0 : }
863 : : }
864 : :
865 : : //--------------------------------------------------------------------
866 : :
867 : 0 : void SfxToolBoxControl::SetPopupWindow( SfxPopupWindow* pWindow )
868 : : {
869 : 0 : pImpl->mpPopupWindow = pWindow;
870 : 0 : pImpl->mpPopupWindow->SetPopupModeEndHdl( LINK( this, SfxToolBoxControl, PopupModeEndHdl ));
871 : 0 : pImpl->mpPopupWindow->SetDeleteLink_Impl( LINK( this, SfxToolBoxControl, ClosePopupWindow ));
872 : 0 : }
873 : :
874 : : //--------------------------------------------------------------------
875 : :
876 : 0 : IMPL_LINK_NOARG(SfxToolBoxControl, PopupModeEndHdl)
877 : : {
878 [ # # ]: 0 : if ( pImpl->mpPopupWindow->IsVisible() )
879 : : {
880 : : // Replace floating window with popup window and destroy
881 : : // floating window instance.
882 [ # # ]: 0 : delete pImpl->mpFloatingWindow;
883 : 0 : pImpl->mpFloatingWindow = pImpl->mpPopupWindow;
884 : 0 : pImpl->mpPopupWindow = 0;
885 : : // We also need to know when the user tries to use the
886 : : // floating window.
887 [ # # ]: 0 : pImpl->mpFloatingWindow->AddEventListener( LINK( pImpl, SfxToolBoxControl_Impl, WindowEventListener ));
888 : : }
889 : : else
890 : : {
891 : : // Popup window has been closed by the user. No replacement, instance
892 : : // will destroy itself.
893 : 0 : pImpl->mpPopupWindow = 0;
894 : : }
895 : :
896 : 0 : return 1;
897 : : }
898 : :
899 : : //--------------------------------------------------------------------
900 : 0 : IMPL_LINK( SfxToolBoxControl, ClosePopupWindow, SfxPopupWindow *, pWindow )
901 : : {
902 [ # # ]: 0 : if ( pWindow == pImpl->mpFloatingWindow )
903 : 0 : pImpl->mpFloatingWindow = 0;
904 : : else
905 : 0 : pImpl->mpPopupWindow = 0;
906 : :
907 : 0 : return 1;
908 : : }
909 : :
910 : : //--------------------------------------------------------------------
911 : :
912 : 11220 : void SfxToolBoxControl::StateChanged
913 : : (
914 : : sal_uInt16 nId,
915 : : SfxItemState eState,
916 : : const SfxPoolItem* pState
917 : : )
918 : : {
919 : : DBG_ASSERT( pImpl->pBox != 0, "setting state to dangling ToolBox" );
920 : :
921 [ - + ][ # # ]: 11220 : if ( GetId() >= SID_OBJECTMENU0 && GetId() <= SID_OBJECTMENU_LAST )
[ - + ]
922 : 11220 : return;
923 : :
924 : : // enabled/disabled-Flag correcting the lump sum
925 : 11220 : pImpl->pBox->EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
926 : :
927 : 11220 : sal_uInt16 nItemBits = pImpl->pBox->GetItemBits( GetId() );
928 : 11220 : nItemBits &= ~TIB_CHECKABLE;
929 : 11220 : TriState eTri = STATE_NOCHECK;
930 [ + - + ]: 11220 : switch ( eState )
931 : : {
932 : : case SFX_ITEM_AVAILABLE:
933 : : {
934 [ + + ]: 5446 : if ( pState->ISA(SfxBoolItem) )
935 : : {
936 : : // BoolItem for checking
937 [ - + ]: 2436 : if ( ((const SfxBoolItem*)pState)->GetValue() )
938 : 0 : eTri = STATE_CHECK;
939 : 2436 : nItemBits |= TIB_CHECKABLE;
940 : : }
941 [ + + - + ]: 4417 : else if ( pState->ISA(SfxEnumItemInterface) &&
[ - + ]
942 : 1407 : ((SfxEnumItemInterface *)pState)->HasBoolValue())
943 : : {
944 : : // EnumItem is handled as Bool
945 [ # # ]: 0 : if ( ((const SfxEnumItemInterface *)pState)->GetBoolValue() )
946 : 0 : eTri = STATE_CHECK;
947 : 0 : nItemBits |= TIB_CHECKABLE;
948 : : }
949 [ - + ][ # # ]: 3010 : else if ( pImpl->bShowString && pState->ISA(SfxStringItem) )
[ - + ]
950 : 0 : pImpl->pBox->SetItemText(nId, ((const SfxStringItem*)pState)->GetValue() );
951 : 5446 : break;
952 : : }
953 : :
954 : : case SFX_ITEM_DONTCARE:
955 : : {
956 : 0 : eTri = STATE_DONTKNOW;
957 : 0 : nItemBits |= TIB_CHECKABLE;
958 : : }
959 : : }
960 : :
961 : 11220 : pImpl->pBox->SetItemState( GetId(), eTri );
962 : 11220 : pImpl->pBox->SetItemBits( GetId(), nItemBits );
963 : : }
964 : :
965 : : //--------------------------------------------------------------------
966 : :
967 : 0 : void SfxToolBoxControl::Select( sal_uInt16 nModifier )
968 : : {
969 : 0 : pImpl->nSelectModifier = nModifier;
970 : 0 : Select( sal_Bool((nModifier & KEY_MOD1)!=0) );
971 : 0 : }
972 : :
973 : : //--------------------------------------------------------------------
974 : :
975 : 0 : void SfxToolBoxControl::Select( sal_Bool /*bMod1*/ )
976 : : {
977 : 0 : svt::ToolboxController::execute( pImpl->nSelectModifier );
978 : 0 : }
979 : :
980 : : //--------------------------------------------------------------------
981 : :
982 : 0 : void SfxToolBoxControl::DoubleClick()
983 : : {
984 : 0 : }
985 : :
986 : : //--------------------------------------------------------------------
987 : :
988 : 0 : void SfxToolBoxControl::Click()
989 : : {
990 : 0 : }
991 : :
992 : : //--------------------------------------------------------------------
993 : :
994 : 0 : SfxPopupWindowType SfxToolBoxControl::GetPopupWindowType() const
995 : : {
996 : 0 : return SFX_POPUPWINDOW_NONE;
997 : : }
998 : :
999 : : //--------------------------------------------------------------------
1000 : :
1001 : 0 : SfxPopupWindow* SfxToolBoxControl::CreatePopupWindow()
1002 : : {
1003 : 0 : return 0;
1004 : : }
1005 : :
1006 : 0 : SfxPopupWindow* SfxToolBoxControl::CreatePopupWindowCascading()
1007 : : {
1008 : 0 : return 0;
1009 : : }
1010 : :
1011 : : //--------------------------------------------------------------------
1012 : :
1013 : 15372 : Window* SfxToolBoxControl::CreateItemWindow( Window * )
1014 : : {
1015 : 15372 : return 0;
1016 : : }
1017 : :
1018 : : //--------------------------------------------------------------------
1019 : :
1020 : 0 : SfxFrameStatusListener::SfxFrameStatusListener(
1021 : : const Reference< XMultiServiceFactory >& rServiceManager,
1022 : : const Reference< XFrame >& xFrame,
1023 : : SfxStatusListenerInterface* pCallee ) :
1024 : : svt::FrameStatusListener( rServiceManager, xFrame ),
1025 : 0 : m_pCallee( pCallee )
1026 : : {
1027 : 0 : }
1028 : :
1029 : : //--------------------------------------------------------------------
1030 : :
1031 : 0 : SfxFrameStatusListener::~SfxFrameStatusListener()
1032 : : {
1033 [ # # ]: 0 : }
1034 : :
1035 : : //--------------------------------------------------------------------
1036 : :
1037 : : // XStatusListener
1038 : 0 : void SAL_CALL SfxFrameStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent )
1039 : : throw ( ::com::sun::star::uno::RuntimeException )
1040 : : {
1041 : 0 : SfxViewFrame* pViewFrame = NULL;
1042 : 0 : Reference < XController > xController;
1043 : :
1044 [ # # ]: 0 : SolarMutexGuard aGuard;
1045 [ # # ]: 0 : if ( m_xFrame.is() )
1046 [ # # ][ # # ]: 0 : xController = m_xFrame->getController();
[ # # ]
1047 : :
1048 [ # # ]: 0 : Reference < XDispatchProvider > xProvider( xController, UNO_QUERY );
1049 [ # # ]: 0 : if ( xProvider.is() )
1050 : : {
1051 [ # # ][ # # ]: 0 : Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 );
1052 [ # # ]: 0 : if ( xDisp.is() )
1053 : : {
1054 [ # # ]: 0 : Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY );
1055 : 0 : SfxOfficeDispatch* pDisp = NULL;
1056 [ # # ]: 0 : if ( xTunnel.is() )
1057 : : {
1058 [ # # ][ # # ]: 0 : sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier());
[ # # ]
1059 : 0 : pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation ));
1060 : : }
1061 : :
1062 [ # # ]: 0 : if ( pDisp )
1063 [ # # ][ # # ]: 0 : pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame();
1064 : 0 : }
1065 : : }
1066 : :
1067 : 0 : sal_uInt16 nSlotId = 0;
1068 [ # # ]: 0 : SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame );
1069 [ # # ][ # # ]: 0 : const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path );
[ # # ]
1070 [ # # ]: 0 : if ( pSlot )
1071 : 0 : nSlotId = pSlot->GetSlotId();
1072 : :
1073 [ # # ]: 0 : if ( nSlotId > 0 )
1074 : : {
1075 [ # # ]: 0 : if ( rEvent.Requery )
1076 : : {
1077 : : // requery for the notified state
1078 [ # # ]: 0 : addStatusListener( rEvent.FeatureURL.Complete );
1079 : : }
1080 : : else
1081 : : {
1082 : 0 : SfxItemState eState = SFX_ITEM_DISABLED;
1083 : 0 : SfxPoolItem* pItem = NULL;
1084 [ # # ]: 0 : if ( rEvent.IsEnabled )
1085 : : {
1086 : 0 : eState = SFX_ITEM_AVAILABLE;
1087 : 0 : ::com::sun::star::uno::Type pType = rEvent.State.getValueType();
1088 : :
1089 [ # # ][ # # ]: 0 : if ( pType == ::getVoidCppuType() )
1090 : : {
1091 [ # # ][ # # ]: 0 : pItem = new SfxVoidItem( nSlotId );
1092 : 0 : eState = SFX_ITEM_UNKNOWN;
1093 : : }
1094 [ # # ][ # # ]: 0 : else if ( pType == ::getBooleanCppuType() )
1095 : : {
1096 : 0 : sal_Bool bTemp = false;
1097 : 0 : rEvent.State >>= bTemp ;
1098 [ # # ][ # # ]: 0 : pItem = new SfxBoolItem( nSlotId, bTemp );
1099 : : }
1100 [ # # ][ # # ]: 0 : else if ( pType == ::getCppuType((const sal_uInt16*)0) )
1101 : : {
1102 : 0 : sal_uInt16 nTemp = 0;
1103 : 0 : rEvent.State >>= nTemp ;
1104 [ # # ][ # # ]: 0 : pItem = new SfxUInt16Item( nSlotId, nTemp );
1105 : : }
1106 [ # # ][ # # ]: 0 : else if ( pType == ::getCppuType((const sal_uInt32*)0) )
1107 : : {
1108 : 0 : sal_uInt32 nTemp = 0;
1109 : 0 : rEvent.State >>= nTemp ;
1110 [ # # ][ # # ]: 0 : pItem = new SfxUInt32Item( nSlotId, nTemp );
1111 : : }
1112 [ # # ][ # # ]: 0 : else if ( pType == ::getCppuType((const ::rtl::OUString*)0) )
1113 : : {
1114 : 0 : ::rtl::OUString sTemp ;
1115 : 0 : rEvent.State >>= sTemp ;
1116 [ # # ][ # # ]: 0 : pItem = new SfxStringItem( nSlotId, sTemp );
[ # # ][ # # ]
1117 : : }
1118 [ # # ][ # # ]: 0 : else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) )
1119 : : {
1120 : 0 : ItemStatus aItemStatus;
1121 [ # # ]: 0 : rEvent.State >>= aItemStatus;
1122 : 0 : eState = aItemStatus.State;
1123 [ # # ][ # # ]: 0 : pItem = new SfxVoidItem( nSlotId );
1124 : : }
1125 [ # # ][ # # ]: 0 : else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::Visibility*)0) )
1126 : : {
1127 : 0 : Visibility aVisibilityStatus;
1128 [ # # ]: 0 : rEvent.State >>= aVisibilityStatus;
1129 [ # # ][ # # ]: 0 : pItem = new SfxVisibilityItem( nSlotId, aVisibilityStatus.bVisible );
1130 : : }
1131 : : else
1132 : : {
1133 [ # # ]: 0 : if ( pSlot )
1134 [ # # ]: 0 : pItem = pSlot->GetType()->CreateItem();
1135 [ # # ]: 0 : if ( pItem )
1136 : : {
1137 : 0 : pItem->SetWhich( nSlotId );
1138 [ # # ]: 0 : pItem->PutValue( rEvent.State );
1139 : : }
1140 : : else
1141 [ # # ][ # # ]: 0 : pItem = new SfxVoidItem( nSlotId );
1142 : 0 : }
1143 : : }
1144 : :
1145 [ # # ]: 0 : if ( m_pCallee )
1146 [ # # ]: 0 : m_pCallee->StateChanged( nSlotId, eState, pItem );
1147 [ # # ][ # # ]: 0 : delete pItem;
1148 : : }
1149 [ # # ]: 0 : }
1150 : 0 : }
1151 : :
1152 : : //--------------------------------------------------------------------
1153 : :
1154 : 0 : SfxPopupWindow::SfxPopupWindow(
1155 : : sal_uInt16 nId,
1156 : : const Reference< XFrame >& rFrame,
1157 : : WinBits nBits ) :
1158 : : FloatingWindow( SFX_APP()->GetTopWindow(), nBits )
1159 : : , m_bFloating(sal_False)
1160 : : , m_bCascading( sal_False )
1161 : : , m_nId( nId )
1162 : : , m_xFrame( rFrame )
1163 [ # # ]: 0 : , m_pStatusListener( 0 )
1164 : : {
1165 [ # # ][ # # ]: 0 : m_xServiceManager = ::comphelper::getProcessServiceFactory();
1166 : :
1167 [ # # ]: 0 : Window* pWindow = GetTopMostParentSystemWindow( this );
1168 [ # # ]: 0 : if ( pWindow )
1169 [ # # ][ # # ]: 0 : ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
1170 : 0 : }
1171 : :
1172 : : //--------------------------------------------------------------------
1173 : :
1174 : 0 : SfxPopupWindow::SfxPopupWindow(
1175 : : sal_uInt16 nId,
1176 : : const Reference< XFrame >& rFrame,
1177 : : const ResId &rId ) :
1178 : : FloatingWindow( SFX_APP()->GetTopWindow(), rId )
1179 : : , m_bFloating(sal_False)
1180 : : , m_bCascading( sal_False )
1181 : : , m_nId( nId )
1182 : : , m_xFrame( rFrame )
1183 [ # # ]: 0 : , m_pStatusListener( 0 )
1184 : : {
1185 [ # # ][ # # ]: 0 : m_xServiceManager = ::comphelper::getProcessServiceFactory();
1186 : :
1187 [ # # ]: 0 : Window* pWindow = GetTopMostParentSystemWindow( this );
1188 [ # # ]: 0 : if ( pWindow )
1189 [ # # ][ # # ]: 0 : ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
1190 : 0 : }
1191 : :
1192 : : //--------------------------------------------------------------------
1193 : :
1194 : 0 : SfxPopupWindow::SfxPopupWindow(
1195 : : sal_uInt16 nId,
1196 : : const Reference< XFrame >& rFrame,
1197 : : Window* pParentWindow,
1198 : : WinBits nBits ) :
1199 : : FloatingWindow( pParentWindow, nBits )
1200 : : , m_bFloating(sal_False)
1201 : : , m_bCascading( sal_False )
1202 : : , m_nId( nId )
1203 : : , m_xFrame( rFrame )
1204 [ # # ]: 0 : , m_pStatusListener( 0 )
1205 : : {
1206 [ # # ][ # # ]: 0 : m_xServiceManager = ::comphelper::getProcessServiceFactory();
1207 : :
1208 [ # # ]: 0 : Window* pWindow = GetTopMostParentSystemWindow( this );
1209 [ # # ]: 0 : if ( pWindow )
1210 [ # # ][ # # ]: 0 : ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
1211 : 0 : }
1212 : :
1213 : : //--------------------------------------------------------------------
1214 : :
1215 : 0 : SfxPopupWindow::~SfxPopupWindow()
1216 : : {
1217 [ # # ]: 0 : if ( m_xStatusListener.is() )
1218 : : {
1219 [ # # ][ # # ]: 0 : m_xStatusListener->dispose();
1220 : 0 : m_xStatusListener.clear();
1221 : : }
1222 : :
1223 [ # # ]: 0 : Window* pWindow = GetTopMostParentSystemWindow( this );
1224 [ # # ]: 0 : if ( pWindow )
1225 [ # # ][ # # ]: 0 : ((SystemWindow *)pWindow)->GetTaskPaneList()->RemoveWindow( this );
1226 [ # # ]: 0 : }
1227 : :
1228 : : //--------------------------------------------------------------------
1229 : :
1230 : 0 : SfxFrameStatusListener* SfxPopupWindow::GetOrCreateStatusListener()
1231 : : {
1232 [ # # ]: 0 : if ( !m_xStatusListener.is() )
1233 : : {
1234 : : m_pStatusListener = new SfxFrameStatusListener(
1235 : : m_xServiceManager,
1236 : : m_xFrame,
1237 [ # # ]: 0 : this );
1238 : : m_xStatusListener = Reference< XComponent >( static_cast< cppu::OWeakObject* >(
1239 [ # # ][ # # ]: 0 : m_pStatusListener ), UNO_QUERY );
1240 : : }
1241 : :
1242 : 0 : return m_pStatusListener;
1243 : : }
1244 : :
1245 : : //--------------------------------------------------------------------
1246 : :
1247 : 0 : void SfxPopupWindow::BindListener()
1248 : : {
1249 : 0 : GetOrCreateStatusListener();
1250 [ # # ]: 0 : if ( m_xStatusListener.is() )
1251 : 0 : m_pStatusListener->bindListener();
1252 : 0 : }
1253 : :
1254 : : //--------------------------------------------------------------------
1255 : :
1256 : 0 : void SfxPopupWindow::UnbindListener()
1257 : : {
1258 : 0 : GetOrCreateStatusListener();
1259 [ # # ]: 0 : if ( m_xStatusListener.is() )
1260 : 0 : m_pStatusListener->unbindListener();
1261 : 0 : }
1262 : :
1263 : : //--------------------------------------------------------------------
1264 : :
1265 : 0 : void SfxPopupWindow::AddStatusListener( const rtl::OUString& rCommandURL )
1266 : : {
1267 : 0 : GetOrCreateStatusListener();
1268 [ # # ]: 0 : if ( m_xStatusListener.is() )
1269 : 0 : m_pStatusListener->addStatusListener( rCommandURL );
1270 : 0 : }
1271 : :
1272 : : //--------------------------------------------------------------------
1273 : :
1274 : 0 : sal_Bool SfxPopupWindow::Close()
1275 : : {
1276 : 0 : m_bFloating = sal_False;
1277 : 0 : FloatingWindow::Close();
1278 : :
1279 : 0 : Delete();
1280 : 0 : return sal_True;
1281 : : }
1282 : :
1283 : : //--------------------------------------------------------------------
1284 : :
1285 : 0 : void SfxPopupWindow::PopupModeEnd()
1286 : : {
1287 : : //! to allow PopupModeEndHdl to be called
1288 : 0 : FloatingWindow::PopupModeEnd();
1289 : :
1290 [ # # ]: 0 : if ( IsVisible() )
1291 : : {
1292 : : // was teared-off
1293 : 0 : DeleteFloatingWindow();
1294 : 0 : m_bFloating = sal_True;
1295 : : }
1296 : : else
1297 : 0 : Close();
1298 : 0 : }
1299 : :
1300 : : //--------------------------------------------------------------------
1301 : :
1302 : 0 : void SfxPopupWindow::DeleteFloatingWindow()
1303 : : {
1304 [ # # ]: 0 : if ( m_bFloating )
1305 : : {
1306 : 0 : Hide();
1307 : 0 : Delete();
1308 : : }
1309 : 0 : }
1310 : :
1311 : : //--------------------------------------------------------------------
1312 : :
1313 : 0 : void SfxPopupWindow::MouseMove( const ::MouseEvent& rMEvt )
1314 : : {
1315 [ # # ]: 0 : if ( m_bCascading == sal_False )
1316 : 0 : FloatingWindow::MouseMove( rMEvt );
1317 : : else
1318 : : {
1319 : : // Forward MouseMove-Event to Children
1320 : 0 : ::Point aPos = rMEvt.GetPosPixel();
1321 [ # # ]: 0 : ::Point aScrPos = OutputToScreenPixel( aPos );
1322 : 0 : sal_uInt16 i = 0;
1323 [ # # ]: 0 : Window* pWindow = GetChild( i );
1324 [ # # ]: 0 : while ( pWindow )
1325 : : {
1326 : : ::MouseEvent aMEvt( pWindow->ScreenToOutputPixel( aScrPos ),
1327 : 0 : rMEvt.GetClicks(), rMEvt.GetMode(),
1328 [ # # ][ # # ]: 0 : rMEvt.GetButtons(), rMEvt.GetModifier() );
1329 [ # # ]: 0 : pWindow->MouseMove( rMEvt );
1330 [ # # ]: 0 : pWindow->Update();
1331 : 0 : i++;
1332 [ # # ]: 0 : pWindow = GetChild( i );
1333 : : }
1334 : : }
1335 : 0 : }
1336 : :
1337 : : //--------------------------------------------------------------------
1338 : :
1339 : 0 : void SfxPopupWindow::StartCascading()
1340 : : {
1341 : 0 : m_bCascading= sal_True;
1342 : 0 : }
1343 : :
1344 : : //--------------------------------------------------------------------
1345 : :
1346 : 0 : SfxPopupWindow* SfxPopupWindow::Clone() const
1347 : :
1348 : : /* [Description]
1349 : :
1350 : : This method must be overloaded to show this Popup also in the
1351 : : Presentation-mode. It is called when a Show() would be meaningless
1352 : : since the parent is no presentation window.
1353 : : When create a new window the bew Top-Window will be used automatically,
1354 : : so that the Parent becomes the presentation window and and that the new
1355 : : Popup therefore becomes visible.
1356 : : */
1357 : :
1358 : : {
1359 : 0 : return 0;
1360 : : }
1361 : :
1362 : : //--------------------------------------------------------------------
1363 : :
1364 : 0 : void SfxPopupWindow::StateChanged(
1365 : : sal_uInt16 /*nSID*/,
1366 : : SfxItemState eState,
1367 : : const SfxPoolItem* /*pState*/ )
1368 : : /* [Description]
1369 : :
1370 : : See also <SfxControllerItem::StateChanged()>. In addition the Popup
1371 : : will become hidden when eState==SFX_ITEM_DISABLED and in all other
1372 : : cases it will be shown again if it is floating. In general this requires
1373 : : to call the Base class.
1374 : :
1375 : : Due to the parent the presentation mode is handled in a special way.
1376 : : */
1377 : :
1378 : : {
1379 [ # # ]: 0 : if ( SFX_ITEM_DISABLED == eState )
1380 : : {
1381 : 0 : Hide();
1382 : : }
1383 [ # # ]: 0 : else if ( m_bFloating )
1384 : : {
1385 : 0 : Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1386 : : }
1387 : 0 : }
1388 : :
1389 : : //--------------------------------------------------------------------
1390 : :
1391 : 0 : void SfxPopupWindow::Delete()
1392 : : {
1393 [ # # ]: 0 : if ( m_aDeleteLink.IsSet() )
1394 : 0 : m_aDeleteLink.Call( this );
1395 [ # # ]: 0 : delete this;
1396 : 0 : }
1397 : :
1398 : : //--------------------------------------------------------------------
1399 : :
1400 : 1177 : SfxAppToolBoxControl_Impl::SfxAppToolBoxControl_Impl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox )
1401 : : : SfxToolBoxControl( nSlotId, nId, rBox )
1402 [ + - ]: 1177 : , pMenu( 0 )
1403 : : {
1404 [ + - ]: 1177 : rBox.SetHelpId( nId, HID_TBXCONTROL_FILENEW );
1405 [ + - ][ + - ]: 1177 : rBox.SetItemBits( nId, rBox.GetItemBits( nId ) | TIB_DROPDOWN);
1406 : :
1407 : : // Determine the current background color of the menus
1408 [ + - ]: 1177 : const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
1409 : 1177 : m_nSymbolsStyle = rSettings.GetSymbolsStyle();
1410 [ + - ]: 1177 : m_bShowMenuImages = rSettings.GetUseImagesInMenus();
1411 : :
1412 [ + - ][ + - ]: 1177 : SetImage( String() );
[ + - ]
1413 : 1177 : }
1414 : :
1415 [ + - ]: 1177 : SfxAppToolBoxControl_Impl::~SfxAppToolBoxControl_Impl()
1416 : : {
1417 [ + + ][ + - ]: 1177 : delete pMenu;
1418 [ - + ]: 2354 : }
1419 : :
1420 : : //_____________________________________________________
1421 : : /*
1422 : : it return the existing state of the given URL in the popupmenu of this toolbox control.
1423 : :
1424 : : If the given URL can be located as an action command of one menu item of the
1425 : : popup menu of this control, we return sal_True. Otherwhise we return sal_False.
1426 : : Further we return a fallback URL, in case we have to return sal_False. Because
1427 : : the outside code must select a valid item of the popup menu everytime ...
1428 : : and we define it here. By the way this m ethod was written to handle
1429 : : error situations gracefully. E.g. it can be called during creation time
1430 : : but then we have no valid menu. For this case we know another fallback URL.
1431 : : Then we return the private:factory/ URL of the default factory.
1432 : :
1433 : : @param *pMenu
1434 : : pounts to the popup menu, on which item we try to locate the given URL
1435 : : Can be NULL! Search will be supressed then.
1436 : :
1437 : : @param sURL
1438 : : the URL for searching
1439 : :
1440 : : @param pFallback
1441 : : contains the fallback URL in case we return FALSE
1442 : : Must point to valid memory!
1443 : :
1444 : : @param pImage
1445 : : contains the image of the menu for the URL.
1446 : :
1447 : : @return sal_True - if URL could be located as an item of the popup menu.
1448 : : sal_False - otherwhise.
1449 : : */
1450 : 3021 : sal_Bool Impl_ExistURLInMenu( const PopupMenu *pMenu ,
1451 : : String &sURL ,
1452 : : String *pFallback ,
1453 : : Image *pImage )
1454 : : {
1455 : 3021 : sal_Bool bValidFallback = sal_False;
1456 [ + + ][ + - ]: 3021 : if (pMenu && sURL.Len())
[ + + ]
1457 : : {
1458 : 1844 : sal_uInt16 c = pMenu->GetItemCount();
1459 [ + - ]: 4856 : for (sal_uInt16 p=0; p<c; ++p)
1460 : : {
1461 [ + - ]: 3012 : sal_uInt16 nId = pMenu->GetItemId(p);
1462 [ + - ][ + - ]: 3012 : String aCmd( pMenu->GetItemCommand(nId) );
1463 : :
1464 [ + + ][ + - ]: 3012 : if (!bValidFallback && aCmd.Len())
[ + + ]
1465 : : {
1466 [ + - ]: 1844 : *pFallback = aCmd;
1467 : 1844 : bValidFallback = sal_True;
1468 : : }
1469 : :
1470 [ + - ][ + + ]: 3012 : if (aCmd.Search(sURL)==0)//match even if the menu command is more detailed (maybe an additional query) #i28667#
1471 : : {
1472 [ + - ]: 1844 : sURL = aCmd;
1473 [ + - ][ + - ]: 1844 : *pImage = pMenu->GetItemImage( nId );
[ + - ]
1474 : 3012 : return sal_True;
1475 : : }
1476 [ + - ][ + + ]: 3012 : }
1477 : : }
1478 : :
1479 [ + - ]: 1177 : if (!bValidFallback)
1480 : : {
1481 [ + - ]: 1177 : *pFallback = DEFINE_CONST_UNICODE("private:factory/");
1482 [ + - ][ + - ]: 1177 : *pFallback += String(SvtModuleOptions().GetDefaultModuleName());
[ + - ][ + - ]
1483 : : }
1484 : :
1485 : 3021 : return sal_False;
1486 : : }
1487 : :
1488 : : long Select_Impl( void* pHdl, void* pVoid );
1489 : :
1490 : 0 : SfxPopupWindow* SfxAppToolBoxControl_Impl::CreatePopupWindow()
1491 : : {
1492 [ # # ]: 0 : ToolBox& rBox = GetToolBox();
1493 [ # # ][ # # ]: 0 : ::Rectangle aRect( rBox.GetItemRect( GetId() ) );
1494 : :
1495 [ # # ]: 0 : if ( !pMenu )
1496 : : {
1497 [ # # ]: 0 : ::framework::MenuConfiguration aConf( m_xServiceManager );
1498 [ # # ]: 0 : if ( m_aCommandURL == ".uno:AddDirect" )
1499 [ # # ][ # # ]: 0 : pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU );
1500 : : else
1501 [ # # ][ # # ]: 0 : pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_WIZARDMENU );
[ # # ]
1502 : : }
1503 : :
1504 [ # # ]: 0 : if ( pMenu )
1505 : : {
1506 [ # # ]: 0 : pMenu->SetSelectHdl( Link( NULL, Select_Impl ) );
1507 [ # # ]: 0 : pMenu->SetActivateHdl( LINK( this, SfxAppToolBoxControl_Impl, Activate ));
1508 [ # # ][ # # ]: 0 : rBox.SetItemDown( GetId(), sal_True );
1509 [ # # ]: 0 : sal_uInt16 nSelected = pMenu->Execute( &rBox, aRect, POPUPMENU_EXECUTE_DOWN );
1510 [ # # ]: 0 : if ( nSelected )
1511 : : {
1512 [ # # ][ # # ]: 0 : aLastURL = pMenu->GetItemCommand( nSelected );
1513 [ # # ][ # # ]: 0 : SetImage( pMenu->GetItemCommand( nSelected ) );
1514 : : }
1515 : :
1516 [ # # ][ # # ]: 0 : rBox.SetItemDown( GetId(), sal_False );
1517 : : }
1518 : :
1519 : 0 : return 0;
1520 : : }
1521 : :
1522 : 3021 : void SfxAppToolBoxControl_Impl::SetImage( const String &rURL )
1523 : : {
1524 : : /* We accept URL's here only, which exist as items of our internal popup menu.
1525 : : All other ones will be ignored and a fallback is used ... */
1526 [ + - ]: 3021 : String aURL = rURL;
1527 [ + - ]: 3021 : String sFallback;
1528 [ + - ]: 3021 : Image aMenuImage;
1529 [ + - ]: 3021 : sal_Bool bValid = Impl_ExistURLInMenu(pMenu,aURL,&sFallback,&aMenuImage);
1530 [ + + ]: 3021 : if (!bValid)
1531 [ + - ]: 1177 : aURL = sFallback;
1532 : :
1533 [ + - ][ + - ]: 3021 : sal_Bool bBig = SvtMiscOptions().AreCurrentSymbolsLarge();
[ + - ]
1534 [ + - ][ + - ]: 3021 : Image aImage = SvFileInformationManager::GetImageNoDefault( INetURLObject( aURL ), bBig );
[ + - ][ + - ]
1535 [ - + ]: 3021 : if ( !aImage )
1536 : 0 : aImage = !!aMenuImage ? aMenuImage :
1537 [ # # ][ # # ]: 0 : SvFileInformationManager::GetImage( INetURLObject( aURL ), bBig );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ]
1538 [ + - ][ + - ]: 3021 : Size aBigSize( GetToolBox().GetDefaultImageSize() );
1539 [ - + ][ # # ]: 3021 : if ( bBig && aImage.GetSizePixel() != aBigSize )
[ # # ][ - + ]
[ - + # # ]
1540 : : {
1541 [ # # ]: 0 : BitmapEx aScaleBmpEx( aImage.GetBitmapEx() );
1542 [ # # ]: 0 : aScaleBmpEx.Scale( aBigSize, BMP_SCALE_BEST );
1543 [ # # ][ # # ]: 0 : GetToolBox().SetItemImage( GetId(), Image( aScaleBmpEx ) );
[ # # ][ # # ]
[ # # ][ # # ]
1544 : : }
1545 : : else
1546 [ + - ][ + - ]: 3021 : GetToolBox().SetItemImage( GetId(), aImage );
[ + - ]
1547 [ + - ][ + - ]: 3021 : aLastURL = aURL;
[ + - ][ + - ]
[ + - ]
1548 : 3021 : }
1549 : :
1550 : 1876 : void SfxAppToolBoxControl_Impl::StateChanged
1551 : : (
1552 : : sal_uInt16 nSlotId,
1553 : : SfxItemState eState,
1554 : : const SfxPoolItem* pState
1555 : : )
1556 : : {
1557 [ + - ][ + + ]: 1876 : if ( pState && pState->ISA(SfxStringItem) )
[ + + ]
1558 : : {
1559 : : // Important step for following SetImage() call!
1560 : : // It needs the valid pMenu item to fullfill it's specification
1561 : : // to check for supported URLs ...
1562 [ + + ]: 1844 : if ( !pMenu )
1563 : : {
1564 [ + - ]: 1104 : ::framework::MenuConfiguration aConf( m_xServiceManager );
1565 : : // This toolbox controller is used for two popup menus (new documents and wizards!). Create the correct
1566 : : // popup menu according to the slot ID our controller has been initialized with.
1567 [ + - ]: 1104 : if ( nSlotId == SID_NEWDOCDIRECT )
1568 [ + - ][ + - ]: 1104 : pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU );
1569 : : else
1570 [ # # ][ # # ]: 1104 : pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_WIZARDMENU );
[ + - ]
1571 : : }
1572 : :
1573 : 1844 : GetToolBox().EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
1574 : 1844 : SetImage(((const SfxStringItem*)pState)->GetValue());
1575 : : }
1576 : : else
1577 : 32 : SfxToolBoxControl::StateChanged( nSlotId, eState, pState );
1578 : 1876 : }
1579 : :
1580 : : //--------------------------------------------------------------------
1581 : :
1582 : 0 : void SfxAppToolBoxControl_Impl::Select( sal_Bool bMod1 )
1583 : : {
1584 [ # # ]: 0 : if( aLastURL.Len() )
1585 : : {
1586 : 0 : URL aTargetURL;
1587 : 0 : Reference< XDispatch > xDispatch;
1588 [ # # ][ # # ]: 0 : Reference< XDispatchProvider > xDispatchProvider( getFrameInterface(), UNO_QUERY );
1589 : :
1590 [ # # ]: 0 : if ( xDispatchProvider.is() )
1591 : : {
1592 [ # # ]: 0 : aTargetURL.Complete = aLastURL;
1593 [ # # ][ # # ]: 0 : getURLTransformer()->parseStrict( aTargetURL );
[ # # ]
1594 : :
1595 : 0 : ::rtl::OUString aTarget( ::rtl::OUString("_default"));
1596 [ # # ]: 0 : if ( pMenu )
1597 : : {
1598 : : ::framework::MenuConfiguration::Attributes* pMenuAttributes =
1599 [ # # ][ # # ]: 0 : (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( pMenu->GetCurItemId() );
1600 : :
1601 [ # # ]: 0 : if ( pMenuAttributes )
1602 : 0 : aTarget = pMenuAttributes->aTargetFrame;
1603 : : }
1604 : :
1605 [ # # ][ # # ]: 0 : xDispatch = xDispatchProvider->queryDispatch( aTargetURL, aTarget, 0 );
[ # # ]
1606 : :
1607 [ # # ]: 0 : if ( xDispatch.is() )
1608 : : {
1609 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
1610 : :
1611 [ # # ]: 0 : aArgs[0].Name = ::rtl::OUString("Referer");
1612 [ # # ][ # # ]: 0 : aArgs[0].Value = makeAny( ::rtl::OUString(SFX_REFERER_USER ) );
1613 : :
1614 [ # # ][ # # ]: 0 : ExecuteInfo* pExecuteInfo = new ExecuteInfo;
1615 [ # # ]: 0 : pExecuteInfo->xDispatch = xDispatch;
1616 : 0 : pExecuteInfo->aTargetURL = aTargetURL;
1617 [ # # ]: 0 : pExecuteInfo->aArgs = aArgs;
1618 [ # # ][ # # ]: 0 : Application::PostUserEvent( STATIC_LINK(0, SfxAppToolBoxControl_Impl, ExecuteHdl_Impl), pExecuteInfo );
[ # # ]
1619 : 0 : }
1620 : 0 : }
1621 : : }
1622 : : else
1623 : 0 : SfxToolBoxControl::Select( bMod1 );
1624 : 0 : }
1625 : :
1626 : : //--------------------------------------------------------------------
1627 : 0 : long Select_Impl( void* /*pHdl*/, void* pVoid )
1628 : : {
1629 : 0 : Menu* pMenu = (Menu*)pVoid;
1630 [ # # ][ # # ]: 0 : String aURL( pMenu->GetItemCommand( pMenu->GetCurItemId() ) );
[ # # ]
1631 : :
1632 [ # # ]: 0 : if( !aURL.Len() )
1633 : 0 : return 0;
1634 : :
1635 : : Reference < ::com::sun::star::frame::XFramesSupplier > xDesktop =
1636 [ # # ][ # # ]: 0 : Reference < ::com::sun::star::frame::XFramesSupplier >( ::comphelper::getProcessServiceFactory()->createInstance(
1637 [ # # ][ # # ]: 0 : DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
[ # # ][ # # ]
[ # # ]
1638 [ # # ]: 0 : Reference < ::com::sun::star::frame::XFrame > xFrame( xDesktop, UNO_QUERY );
1639 : :
1640 : 0 : URL aTargetURL;
1641 [ # # ]: 0 : aTargetURL.Complete = aURL;
1642 [ # # ][ # # ]: 0 : Reference < XURLTransformer > xTrans( URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
1643 [ # # ][ # # ]: 0 : xTrans->parseStrict( aTargetURL );
1644 : :
1645 [ # # ]: 0 : Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
1646 : 0 : Reference < XDispatch > xDisp;
1647 [ # # ]: 0 : if ( xProv.is() )
1648 : : {
1649 [ # # ]: 0 : if ( aTargetURL.Protocol.compareToAscii("slot:") == COMPARE_EQUAL )
1650 [ # # ][ # # ]: 0 : xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
[ # # ]
1651 : : else
1652 : : {
1653 : 0 : ::rtl::OUString aTargetFrame( ::rtl::OUString("_blank") );
1654 : : ::framework::MenuConfiguration::Attributes* pMenuAttributes =
1655 [ # # ][ # # ]: 0 : (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( pMenu->GetCurItemId() );
1656 : :
1657 [ # # ]: 0 : if ( pMenuAttributes )
1658 : 0 : aTargetFrame = pMenuAttributes->aTargetFrame;
1659 : :
1660 [ # # ][ # # ]: 0 : xDisp = xProv->queryDispatch( aTargetURL, aTargetFrame , 0 );
[ # # ]
1661 : : }
1662 : : }
1663 : :
1664 [ # # ]: 0 : if ( xDisp.is() )
1665 : : {
1666 [ # # ][ # # ]: 0 : SfxAppToolBoxControl_Impl::ExecuteInfo* pExecuteInfo = new SfxAppToolBoxControl_Impl::ExecuteInfo;
1667 [ # # ]: 0 : pExecuteInfo->xDispatch = xDisp;
1668 : 0 : pExecuteInfo->aTargetURL = aTargetURL;
1669 [ # # ][ # # ]: 0 : pExecuteInfo->aArgs = Sequence< PropertyValue >();
[ # # ]
1670 [ # # ][ # # ]: 0 : Application::PostUserEvent( STATIC_LINK( 0, SfxAppToolBoxControl_Impl, ExecuteHdl_Impl), pExecuteInfo );
1671 : : }
1672 : :
1673 [ # # ]: 0 : return sal_True;
1674 : : }
1675 : :
1676 : 0 : IMPL_LINK( SfxAppToolBoxControl_Impl, Activate, Menu *, pActMenu )
1677 : : {
1678 [ # # ]: 0 : if ( pActMenu )
1679 : : {
1680 : 0 : const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
1681 : 0 : sal_uIntPtr nSymbolsStyle = rSettings.GetSymbolsStyle();
1682 : 0 : sal_Bool bShowMenuImages = rSettings.GetUseImagesInMenus();
1683 : :
1684 [ # # ][ # # ]: 0 : if (( nSymbolsStyle != m_nSymbolsStyle ) ||
1685 : : ( bShowMenuImages != m_bShowMenuImages ))
1686 : : {
1687 : 0 : m_nSymbolsStyle = nSymbolsStyle;
1688 : 0 : m_bShowMenuImages = bShowMenuImages;
1689 : :
1690 : 0 : sal_uInt16 nCount = pActMenu->GetItemCount();
1691 [ # # ]: 0 : for ( sal_uInt16 nSVPos = 0; nSVPos < nCount; nSVPos++ )
1692 : : {
1693 : 0 : sal_uInt16 nId = pActMenu->GetItemId( nSVPos );
1694 [ # # ]: 0 : if ( pActMenu->GetItemType( nSVPos ) != MENUITEM_SEPARATOR )
1695 : : {
1696 [ # # ]: 0 : if ( bShowMenuImages )
1697 : : {
1698 : 0 : sal_Bool bImageSet = sal_False;
1699 : 0 : ::rtl::OUString aImageId;
1700 : : ::framework::MenuConfiguration::Attributes* pMenuAttributes =
1701 [ # # ]: 0 : (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( nId );
1702 : :
1703 [ # # ]: 0 : if ( pMenuAttributes )
1704 : 0 : aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes
1705 : :
1706 [ # # ]: 0 : if ( !aImageId.isEmpty() )
1707 : : {
1708 : 0 : Reference< ::com::sun::star::frame::XFrame > xFrame;
1709 [ # # ]: 0 : Image aImage = GetImage( xFrame, aImageId, false );
1710 [ # # ]: 0 : if ( !!aImage )
1711 : : {
1712 : 0 : bImageSet = sal_True;
1713 [ # # ]: 0 : pActMenu->SetItemImage( nId, aImage );
1714 [ # # ]: 0 : }
1715 : : }
1716 : :
1717 [ # # ][ # # ]: 0 : String aCmd( pActMenu->GetItemCommand( nId ) );
1718 [ # # ][ # # ]: 0 : if ( !bImageSet && aCmd.Len() )
[ # # ]
1719 : : {
1720 : : Image aImage = SvFileInformationManager::GetImage(
1721 [ # # ][ # # ]: 0 : INetURLObject(aCmd), false );
[ # # ][ # # ]
1722 [ # # ]: 0 : if ( !!aImage )
1723 [ # # ][ # # ]: 0 : pActMenu->SetItemImage( nId, aImage );
1724 [ # # ]: 0 : }
1725 : : }
1726 : : else
1727 [ # # ]: 0 : pActMenu->SetItemImage( nId, Image() );
1728 : : }
1729 : : }
1730 : : }
1731 : :
1732 : 0 : return sal_True;
1733 : : }
1734 : :
1735 : 0 : return sal_False;
1736 : : }
1737 : :
1738 : : //--------------------------------------------------------------------
1739 : :
1740 : 0 : IMPL_STATIC_LINK_NOINSTANCE( SfxAppToolBoxControl_Impl, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
1741 : : {
1742 : : /* i62706: Don't catch all exceptions. We hide all problems here and are not able
1743 : : to handle them on higher levels.
1744 : : try
1745 : : {
1746 : : */
1747 : : // Asynchronous execution as this can lead to our own destruction!
1748 : : // Framework can recycle our current frame and the layout manager disposes all user interface
1749 : : // elements if a component gets detached from its frame!
1750 : 0 : pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs );
1751 [ # # ]: 0 : delete pExecuteInfo;
1752 : 0 : return 0;
1753 : : }
1754 : :
1755 : : //--------------------------------------------------------------------
1756 : :
1757 : 0 : void SfxAppToolBoxControl_Impl::Click( )
1758 : : {
1759 : 0 : }
1760 : :
1761 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|