Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <uielement/toolbarmanager.hxx>
30 : :
31 : : #include <uielement/toolbar.hxx>
32 : : #include <uielement/generictoolbarcontroller.hxx>
33 : : #include <threadhelp/resetableguard.hxx>
34 : : #include "services.h"
35 : : #include "general.h"
36 : : #include "properties.h"
37 : : #include <framework/imageproducer.hxx>
38 : : #include <framework/sfxhelperfunctions.hxx>
39 : : #include <classes/fwkresid.hxx>
40 : : #include <classes/resource.hrc>
41 : : #include <framework/addonsoptions.hxx>
42 : : #include <uielement/toolbarmerger.hxx>
43 : :
44 : : #include <com/sun/star/ui/ItemType.hpp>
45 : : #include <com/sun/star/frame/XDispatchProvider.hpp>
46 : : #include <com/sun/star/beans/XPropertySet.hpp>
47 : : #include <com/sun/star/awt/XDockableWindow.hpp>
48 : : #include <com/sun/star/frame/XLayoutManager.hpp>
49 : : #include <com/sun/star/ui/DockingArea.hpp>
50 : : #include <com/sun/star/graphic/XGraphic.hpp>
51 : : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
52 : : #include <com/sun/star/frame/XModuleManager.hpp>
53 : : #include <com/sun/star/ui/XUIElementSettings.hpp>
54 : : #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
55 : : #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
56 : : #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
57 : : #include <com/sun/star/ui/ImageType.hpp>
58 : : #include <com/sun/star/ui/UIElementType.hpp>
59 : : #include <comphelper/sequence.hxx>
60 : : #include <com/sun/star/frame/status/Visibility.hpp>
61 : : #include <com/sun/star/lang/DisposedException.hpp>
62 : : #include <com/sun/star/util/URLTransformer.hpp>
63 : :
64 : : #include <svtools/imgdef.hxx>
65 : : #include <svtools/toolboxcontroller.hxx>
66 : : #include <unotools/cmdoptions.hxx>
67 : : #include <toolkit/unohlp.hxx>
68 : : #include <comphelper/componentcontext.hxx>
69 : : #include <comphelper/mediadescriptor.hxx>
70 : : #include <svtools/miscopt.hxx>
71 : : #include <svl/imageitm.hxx>
72 : : #include <svtools/framestatuslistener.hxx>
73 : : #include <vcl/svapp.hxx>
74 : : #include <vcl/menu.hxx>
75 : : #include <vcl/syswin.hxx>
76 : : #include <vcl/taskpanelist.hxx>
77 : : #include <rtl/logfile.hxx>
78 : : #include <svtools/menuoptions.hxx>
79 : : #include <unotools/cmdoptions.hxx>
80 : : #include <boost/bind.hpp>
81 : : #include <svtools/acceleratorexecute.hxx>
82 : :
83 : : //_________________________________________________________________________________________________________________
84 : : // namespaces
85 : : //_________________________________________________________________________________________________________________
86 : :
87 : : using rtl::OUString;
88 : :
89 : : using namespace ::com::sun::star::awt;
90 : : using namespace ::com::sun::star::beans;
91 : : using namespace ::com::sun::star::uno;
92 : : using namespace ::com::sun::star::lang;
93 : : using namespace ::com::sun::star::frame;
94 : : using namespace ::com::sun::star::graphic;
95 : : using namespace ::com::sun::star::util;
96 : : using namespace ::com::sun::star::container;
97 : : using namespace ::com::sun::star::frame;
98 : : using namespace ::com::sun::star::ui;
99 : : using namespace ::com::sun::star;
100 : :
101 : : namespace framework
102 : : {
103 : :
104 : : static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
105 : : static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
106 : : static const char ITEM_DESCRIPTOR_TOOLTIP[] = "Tooltip";
107 : : static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer";
108 : : static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
109 : : static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
110 : : static const char ITEM_DESCRIPTOR_VISIBLE[] = "IsVisible";
111 : : static const char ITEM_DESCRIPTOR_WIDTH[] = "Width";
112 : : static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
113 : :
114 : : static const sal_Int32 ITEM_DESCRIPTOR_COMMANDURL_LEN = RTL_CONSTASCII_LENGTH(ITEM_DESCRIPTOR_COMMANDURL);
115 : : static const sal_Int32 ITEM_DESCRIPTOR_HELPURL_LEN = RTL_CONSTASCII_LENGTH(ITEM_DESCRIPTOR_HELPURL);
116 : : static const sal_Int32 ITEM_DESCRIPTOR_TOOLTIP_LEN = RTL_CONSTASCII_LENGTH(ITEM_DESCRIPTOR_TOOLTIP);
117 : : static const sal_Int32 ITEM_DESCRIPTOR_CONTAINER_LEN = RTL_CONSTASCII_LENGTH(ITEM_DESCRIPTOR_CONTAINER);
118 : : static const sal_Int32 ITEM_DESCRIPTOR_LABEL_LEN = RTL_CONSTASCII_LENGTH(ITEM_DESCRIPTOR_LABEL);
119 : : static const sal_Int32 ITEM_DESCRIPTOR_TYPE_LEN = RTL_CONSTASCII_LENGTH(ITEM_DESCRIPTOR_TYPE);
120 : : static const sal_Int32 ITEM_DESCRIPTOR_VISIBLE_LEN = RTL_CONSTASCII_LENGTH(ITEM_DESCRIPTOR_VISIBLE);
121 : : static const sal_Int32 ITEM_DESCRIPTOR_WIDTH_LEN = RTL_CONSTASCII_LENGTH(ITEM_DESCRIPTOR_WIDTH);
122 : : static const sal_Int32 ITEM_DESCRIPTOR_STYLE_LEN = RTL_CONSTASCII_LENGTH(ITEM_DESCRIPTOR_STYLE);
123 : :
124 : : static const char HELPID_PREFIX_TESTTOOL[] = ".HelpId:";
125 : : static const sal_uInt16 STARTID_CUSTOMIZE_POPUPMENU = 1000;
126 : :
127 : : #define MENUPREFIX "private:resource/menubar/"
128 : :
129 : : class ImageOrientationListener : public svt::FrameStatusListener
130 : : {
131 : : public:
132 : : ImageOrientationListener( const Reference< XStatusListener > rReceiver,
133 : : const Reference< XMultiServiceFactory > rServiceManager,
134 : : const Reference< XFrame > rFrame );
135 : : virtual ~ImageOrientationListener();
136 : :
137 : : virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
138 : :
139 : : private:
140 : : Reference< XStatusListener > m_xReceiver;
141 : : };
142 : :
143 : 2548 : ImageOrientationListener::ImageOrientationListener(
144 : : const Reference< XStatusListener > rReceiver,
145 : : const Reference< XMultiServiceFactory > rServiceManager,
146 : : const Reference< XFrame > rFrame ) :
147 : : FrameStatusListener( rServiceManager, rFrame ),
148 : 2548 : m_xReceiver( rReceiver )
149 : : {
150 : 2548 : }
151 : :
152 : 2548 : ImageOrientationListener::~ImageOrientationListener()
153 : : {
154 [ - + ]: 5096 : }
155 : :
156 : 4165 : void SAL_CALL ImageOrientationListener::statusChanged( const FeatureStateEvent& Event )
157 : : throw ( RuntimeException )
158 : : {
159 [ + - ]: 4165 : if ( m_xReceiver.is() )
160 : 4165 : m_xReceiver->statusChanged( Event );
161 : 4165 : }
162 : :
163 : : //*****************************************************************************************************************
164 : :
165 : 2548 : static sal_Int16 getImageTypeFromBools( sal_Bool bBig )
166 : : {
167 : 2548 : sal_Int16 n( 0 );
168 [ - + ]: 2548 : if ( bBig )
169 : 0 : n |= ::com::sun::star::ui::ImageType::SIZE_LARGE;
170 : 2548 : return n;
171 : : }
172 : :
173 : 0 : static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > getLayoutManagerFromFrame(
174 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
175 : : {
176 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
177 : :
178 [ # # ]: 0 : Reference< XPropertySet > xPropSet( rFrame, UNO_QUERY );
179 [ # # ]: 0 : if ( xPropSet.is() )
180 : : {
181 : : try
182 : : {
183 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( ::rtl::OUString( "LayoutManager" )) >>= xLayoutManager;
[ # # ]
184 : : }
185 [ # # # ]: 0 : catch (const RuntimeException&)
186 : : {
187 : 0 : throw;
188 : : }
189 [ # # ]: 0 : catch (const Exception&)
190 : : {
191 : : }
192 : : }
193 : :
194 : 0 : return xLayoutManager;
195 : : }
196 : :
197 : : //*****************************************************************************************************************
198 : : // XInterface, XTypeProvider, XServiceInfo
199 : : //*****************************************************************************************************************
200 [ + + ][ + - ]: 136740 : DEFINE_XINTERFACE_6 ( ToolBarManager ,
201 : : OWeakObject ,
202 : : DIRECT_INTERFACE( ::com::sun::star::lang::XTypeProvider ),
203 : : DIRECT_INTERFACE( ::com::sun::star::lang::XComponent ),
204 : : DIRECT_INTERFACE( ::com::sun::star::frame::XFrameActionListener ),
205 : : DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationListener ),
206 : : DIRECT_INTERFACE( ::com::sun::star::frame::XStatusListener ),
207 : : DERIVED_INTERFACE( ::com::sun::star::lang::XEventListener, ::com::sun::star::frame::XFrameActionListener )
208 : : )
209 : :
210 [ # # ][ # # ]: 0 : DEFINE_XTYPEPROVIDER_6 ( ToolBarManager ,
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
211 : : ::com::sun::star::lang::XTypeProvider ,
212 : : ::com::sun::star::lang::XComponent ,
213 : : ::com::sun::star::ui::XUIConfigurationListener ,
214 : : ::com::sun::star::frame::XFrameActionListener ,
215 : : ::com::sun::star::frame::XStatusListener ,
216 : : ::com::sun::star::lang::XEventListener
217 : : )
218 : :
219 : 3709 : ToolBarManager::ToolBarManager( const Reference< XMultiServiceFactory >& rServiceManager,
220 : : const Reference< XFrame >& rFrame,
221 : : const rtl::OUString& rResourceName,
222 : : ToolBar* pToolBar ) :
223 [ + - ]: 3709 : ThreadHelpBase( &Application::GetSolarMutex() ),
224 : : OWeakObject(),
225 : : m_bDisposed( sal_False ),
226 [ + - ][ + - ]: 3709 : m_bSmallSymbols( !SvtMiscOptions().AreCurrentSymbolsLarge() ),
[ + - ]
227 : : m_bModuleIdentified( sal_False ),
228 : : m_bAddedToTaskPaneList( sal_True ),
229 : : m_bFrameActionRegistered( sal_False ),
230 : : m_bUpdateControllers( sal_False ),
231 : : m_bImageOrientationRegistered( sal_False ),
232 : : m_bImageMirrored( sal_False ),
233 : : m_lImageRotation( 0 ),
234 : : m_pToolBar( pToolBar ),
235 : : m_aResourceName( rResourceName ),
236 : : m_xFrame( rFrame ),
237 [ + - ]: 3709 : m_aListenerContainer( m_aLock.getShareableOslMutex() ),
238 : : m_xServiceManager( rServiceManager ),
239 [ + - ][ + - ]: 3709 : m_nSymbolsStyle( SvtMiscOptions().GetCurrentSymbolsStyle() ),
[ + - ]
240 [ + - ][ + - ]: 18545 : m_bAcceleratorCfg( sal_False )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
241 : : {
242 : 3709 : Window* pWindow = m_pToolBar;
243 [ + - ][ + - ]: 7454 : while ( pWindow && !pWindow->IsSystemWindow() )
[ + + ][ + + ]
244 [ + - ]: 3745 : pWindow = pWindow->GetParent();
245 : :
246 [ + - ]: 3709 : if ( pWindow )
247 [ + - ][ + - ]: 3709 : ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( m_pToolBar );
248 : :
249 [ + - ]: 3709 : if ( m_xServiceManager.is() )
250 : : {
251 : : m_xToolbarControllerRegistration = Reference< XUIControllerRegistration >(
252 [ + - ]: 3709 : m_xServiceManager->createInstance( SERVICENAME_TOOLBARCONTROLLERFACTORY ),
253 [ + - ][ + - ]: 3709 : UNO_QUERY );
[ + - ][ + - ]
254 : :
255 : : m_xURLTransformer.set(
256 : : URLTransformer::create(
257 [ + - ][ + - ]: 3709 : ::comphelper::ComponentContext(m_xServiceManager).getUNOContext()) );
[ + - ][ + - ]
[ + - ]
258 : : }
259 : :
260 [ + - ]: 3709 : m_pToolBar->SetSelectHdl( LINK( this, ToolBarManager, Select) );
261 [ + - ]: 3709 : m_pToolBar->SetActivateHdl( LINK( this, ToolBarManager, Activate) );
262 [ + - ]: 3709 : m_pToolBar->SetDeactivateHdl( LINK( this, ToolBarManager, Deactivate) );
263 [ + - ]: 3709 : m_pToolBar->SetClickHdl( LINK( this, ToolBarManager, Click ) );
264 [ + - ][ + - ]: 3709 : m_pToolBar->SetDropdownClickHdl( LINK( this, ToolBarManager, DropdownClick ) );
265 [ + - ]: 3709 : m_pToolBar->SetDoubleClickHdl( LINK( this, ToolBarManager, DoubleClick ) );
266 [ + - ]: 3709 : m_pToolBar->SetStateChangedHdl( LINK( this, ToolBarManager, StateChanged ) );
267 [ + - ]: 3709 : m_pToolBar->SetDataChangedHdl( LINK( this, ToolBarManager, DataChanged ) );
268 [ + - ][ + - ]: 3709 : m_pToolBar->SetToolboxButtonSize( m_bSmallSymbols ? TOOLBOX_BUTTONSIZE_SMALL : TOOLBOX_BUTTONSIZE_LARGE );
269 : :
270 : : // enables a menu for clipped items and customization
271 [ + - ]: 3709 : SvtCommandOptions aCmdOptions;
272 : 3709 : sal_uInt16 nMenuType = TOOLBOX_MENUTYPE_CLIPPEDITEMS;
273 [ + - ][ + - ]: 3709 : if ( !aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, ::rtl::OUString("CreateDialog")))
274 : 3709 : nMenuType |= TOOLBOX_MENUTYPE_CUSTOMIZE;
275 : :
276 [ + - ]: 3709 : m_pToolBar->SetCommandHdl( LINK( this, ToolBarManager, Command ) );
277 [ + - ]: 3709 : m_pToolBar->SetMenuType( nMenuType );
278 [ + - ][ + - ]: 3709 : m_pToolBar->SetMenuButtonHdl( LINK( this, ToolBarManager, MenuButton ) );
279 [ + - ][ + - ]: 3709 : m_pToolBar->GetMenu()->SetSelectHdl( LINK( this, ToolBarManager, MenuSelect ) );
280 [ + - ][ + - ]: 3709 : m_pToolBar->GetMenu()->SetDeactivateHdl( LINK( this, ToolBarManager, MenuDeactivate ) );
281 : :
282 : : // set name for testtool, the useful part is after the last '/'
283 : 3709 : sal_Int32 idx = rResourceName.lastIndexOf('/');
284 : 3709 : idx++; // will become 0 if '/' not found: use full string
285 : 3709 : ::rtl::OString aHelpIdAsString( HELPID_PREFIX_TESTTOOL );
286 : 3709 : ::rtl::OUString aToolbarName = rResourceName.copy( idx );
287 [ + - ]: 3709 : aHelpIdAsString += rtl::OUStringToOString( aToolbarName, RTL_TEXTENCODING_UTF8 );;
288 [ + - ]: 3709 : m_pToolBar->SetHelpId( aHelpIdAsString );
289 : :
290 [ + - ]: 3709 : m_aAsyncUpdateControllersTimer.SetTimeout( 50 );
291 [ + - ]: 3709 : m_aAsyncUpdateControllersTimer.SetTimeoutHdl( LINK( this, ToolBarManager, AsyncUpdateControllersHdl ) );
292 : :
293 [ + - ][ + - ]: 3709 : SvtMiscOptions().AddListenerLink( LINK( this, ToolBarManager, MiscOptionsChanged ) );
[ + - ][ + - ]
[ + - ]
294 : 3709 : }
295 : :
296 [ + - ][ + - ]: 3527 : ToolBarManager::~ToolBarManager()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
297 : : {
298 : : OSL_ASSERT( m_pToolBar == 0 );
299 : : OSL_ASSERT( !m_bAddedToTaskPaneList );
300 [ - + ]: 7054 : }
301 : :
302 : 3527 : void ToolBarManager::Destroy()
303 : : {
304 : : OSL_ASSERT( m_pToolBar != 0 );
305 [ + - ]: 3527 : ResetableGuard aGuard( m_aLock );
306 [ + - ]: 3527 : if ( m_bAddedToTaskPaneList )
307 : : {
308 : 3527 : Window* pWindow = m_pToolBar;
309 [ + - ][ + - ]: 10575 : while ( pWindow && !pWindow->IsSystemWindow() )
[ + + ][ + + ]
310 [ + - ]: 7048 : pWindow = pWindow->GetParent();
311 : :
312 [ + - ]: 3527 : if ( pWindow )
313 [ + - ][ + - ]: 3527 : ((SystemWindow *)pWindow)->GetTaskPaneList()->RemoveWindow( m_pToolBar );
314 : 3527 : m_bAddedToTaskPaneList = sal_False;
315 : : }
316 : :
317 : : // Delete the additional add-ons data
318 [ + - ][ + + ]: 96900 : for ( sal_uInt16 i = 0; i < m_pToolBar->GetItemCount(); i++ )
319 : : {
320 [ + - ]: 93373 : sal_uInt16 nItemId = m_pToolBar->GetItemId( i );
321 [ + + ]: 93373 : if ( nItemId > 0 )
322 [ + - ][ - + ]: 71790 : delete static_cast< AddonsParams* >( m_pToolBar->GetItemData( nItemId ));
323 : : }
324 : :
325 : : // Hide toolbar as lazy delete can destroy the toolbar much later.
326 [ + - ]: 3527 : m_pToolBar->Hide();
327 : : /* #i99167# removed change for i93173 since there is some weird crash */
328 : : // #i93173# delete toolbar lazily as we can still be in one of its handlers
329 [ + - ]: 3527 : m_pToolBar->doLazyDelete();
330 : :
331 [ + - ]: 3527 : Link aEmpty;
332 : 3527 : m_pToolBar->SetSelectHdl( aEmpty );
333 : 3527 : m_pToolBar->SetActivateHdl( aEmpty );
334 : 3527 : m_pToolBar->SetDeactivateHdl( aEmpty );
335 : 3527 : m_pToolBar->SetClickHdl( aEmpty );
336 [ + - ]: 3527 : m_pToolBar->SetDropdownClickHdl( aEmpty );
337 : 3527 : m_pToolBar->SetDoubleClickHdl( aEmpty );
338 : 3527 : m_pToolBar->SetStateChangedHdl( aEmpty );
339 : 3527 : m_pToolBar->SetDataChangedHdl( aEmpty );
340 : 3527 : m_pToolBar->SetCommandHdl( aEmpty );
341 : :
342 : 3527 : m_pToolBar = 0;
343 : :
344 [ + - ][ + - ]: 3527 : SvtMiscOptions().RemoveListenerLink( LINK( this, ToolBarManager, MiscOptionsChanged ) );
[ + - ][ + - ]
[ + - ]
345 : 3527 : }
346 : :
347 : 37705 : ToolBox* ToolBarManager::GetToolBar() const
348 : : {
349 [ + - ]: 37705 : ResetableGuard aGuard( m_aLock );
350 [ + - ]: 37705 : return m_pToolBar;
351 : : }
352 : :
353 : 0 : void ToolBarManager::CheckAndUpdateImages()
354 : : {
355 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
356 : 0 : sal_Bool bRefreshImages = sal_False;
357 : :
358 [ # # ]: 0 : SvtMiscOptions aMiscOptions;
359 [ # # ]: 0 : bool bCurrentSymbolsSmall = !aMiscOptions.AreCurrentSymbolsLarge();
360 [ # # ]: 0 : if ( m_bSmallSymbols != bCurrentSymbolsSmall )
361 : : {
362 : 0 : bRefreshImages = sal_True;
363 : 0 : m_bSmallSymbols = bCurrentSymbolsSmall;
364 : : }
365 : :
366 [ # # ]: 0 : sal_Int16 nCurrentSymbolsStyle = aMiscOptions.GetCurrentSymbolsStyle();
367 [ # # ]: 0 : if ( m_nSymbolsStyle != nCurrentSymbolsStyle )
368 : : {
369 : 0 : bRefreshImages = sal_True;
370 : 0 : m_nSymbolsStyle = nCurrentSymbolsStyle;
371 : : }
372 : :
373 : : // Refresh images if requested
374 [ # # ]: 0 : if ( bRefreshImages )
375 [ # # ][ # # ]: 0 : RefreshImages();
[ # # ]
376 : 0 : }
377 : :
378 : 0 : void ToolBarManager::RefreshImages()
379 : : {
380 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
381 : :
382 [ # # ][ # # ]: 0 : sal_Bool bBigImages( SvtMiscOptions().AreCurrentSymbolsLarge() );
[ # # ]
383 [ # # ][ # # ]: 0 : for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); nPos++ )
384 : : {
385 [ # # ]: 0 : sal_uInt16 nId( m_pToolBar->GetItemId( nPos ) );
386 : :
387 [ # # ]: 0 : if ( nId > 0 )
388 : : {
389 [ # # ][ # # ]: 0 : ::rtl::OUString aCommandURL = m_pToolBar->GetItemCommand( nId );
390 [ # # ]: 0 : Image aImage = GetImageFromURL( m_xFrame, aCommandURL, bBigImages );
391 : : // Try also to query for add-on images before giving up and use an
392 : : // empty image.
393 [ # # ]: 0 : if ( !aImage )
394 [ # # ][ # # ]: 0 : aImage = QueryAddonsImage( aCommandURL, bBigImages );
[ # # ]
395 [ # # ][ # # ]: 0 : m_pToolBar->SetItemImage( nId, aImage );
396 : : }
397 : : }
398 : :
399 [ # # ][ # # ]: 0 : m_pToolBar->SetToolboxButtonSize( bBigImages ? TOOLBOX_BUTTONSIZE_LARGE : TOOLBOX_BUTTONSIZE_SMALL );
400 [ # # ]: 0 : ::Size aSize = m_pToolBar->CalcWindowSizePixel();
401 [ # # ][ # # ]: 0 : m_pToolBar->SetOutputSizePixel( aSize );
402 : 0 : }
403 : :
404 : 4165 : void ToolBarManager::UpdateImageOrientation()
405 : : {
406 [ + - ]: 4165 : ResetableGuard aGuard( m_aLock );
407 : :
408 [ + - ]: 4165 : if ( m_xUICommandLabels.is() )
409 : : {
410 : : sal_Int32 i;
411 [ + - ]: 4165 : Sequence< rtl::OUString > aSeqMirrorCmd;
412 [ + - ]: 4165 : Sequence< rtl::OUString > aSeqRotateCmd;
413 [ + - ]: 4165 : m_xUICommandLabels->getByName(
414 [ + - ][ + - ]: 4165 : rtl::OUString( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST )) >>= aSeqMirrorCmd;
415 [ + - ]: 4165 : m_xUICommandLabels->getByName(
416 [ + - ][ + - ]: 4165 : rtl::OUString( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST )) >>= aSeqRotateCmd;
417 : :
418 : 4165 : CommandToInfoMap::iterator pIter;
419 [ + + ]: 112455 : for ( i = 0; i < aSeqMirrorCmd.getLength(); i++ )
420 : : {
421 [ + - ]: 108290 : rtl::OUString aMirrorCmd = aSeqMirrorCmd[i];
422 [ + - ]: 108290 : pIter = m_aCommandMap.find( aMirrorCmd );
423 [ + + ]: 108290 : if ( pIter != m_aCommandMap.end() )
424 [ + - ]: 16576 : pIter->second.bMirrored = sal_True;
425 : 108290 : }
426 [ + + ]: 133280 : for ( i = 0; i < aSeqRotateCmd.getLength(); i++ )
427 : : {
428 [ + - ]: 129115 : rtl::OUString aRotateCmd = aSeqRotateCmd[i];
429 [ + - ]: 129115 : pIter = m_aCommandMap.find( aRotateCmd );
430 [ + + ]: 129115 : if ( pIter != m_aCommandMap.end() )
431 [ + - ]: 26936 : pIter->second.bRotated = sal_True;
432 [ + - ][ + - ]: 133280 : }
433 : : }
434 : :
435 [ + - ][ + + ]: 166388 : for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); nPos++ )
436 : : {
437 [ + - ]: 162223 : sal_uInt16 nId = m_pToolBar->GetItemId( nPos );
438 [ + + ]: 162223 : if ( nId > 0 )
439 : : {
440 [ + - ][ + - ]: 124770 : rtl::OUString aCmd = m_pToolBar->GetItemCommand( nId );
441 : :
442 [ + - ]: 124770 : CommandToInfoMap::const_iterator pIter = m_aCommandMap.find( aCmd );
443 [ + - ]: 124770 : if ( pIter != m_aCommandMap.end() )
444 : : {
445 [ + - ][ + + ]: 124770 : if ( pIter->second.bRotated )
446 : : {
447 [ + - ]: 26936 : m_pToolBar->SetItemImageMirrorMode( nId, sal_False );
448 [ + - ]: 26936 : m_pToolBar->SetItemImageAngle( nId, m_lImageRotation );
449 : : }
450 [ + - ][ + + ]: 124770 : if ( pIter->second.bMirrored )
451 : : {
452 [ + - ]: 16576 : m_pToolBar->SetItemImageMirrorMode( nId, m_bImageMirrored );
453 : : }
454 : 124770 : }
455 : : }
456 [ + - ]: 4165 : }
457 : 4165 : }
458 : :
459 : 2596 : void ToolBarManager::UpdateControllers()
460 : : {
461 : : RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ToolBarManager::UpdateControllers" );
462 : :
463 [ + - ][ - + ]: 2596 : if( SvtMiscOptions().DisableUICustomization() )
464 : : {
465 : 0 : Any a;
466 : 0 : Reference< XLayoutManager > xLayoutManager;
467 [ # # ]: 0 : Reference< XPropertySet > xFramePropSet( m_xFrame, UNO_QUERY );
468 [ # # ]: 0 : if ( xFramePropSet.is() )
469 [ # # ][ # # ]: 0 : a = xFramePropSet->getPropertyValue( ::rtl::OUString( "LayoutManager" ));
470 [ # # ]: 0 : a >>= xLayoutManager;
471 [ # # ][ # # ]: 0 : Reference< XDockableWindow > xDockable( VCLUnoHelper::GetInterface( m_pToolBar ), UNO_QUERY );
472 [ # # ][ # # ]: 0 : if ( xLayoutManager.is() && xDockable.is() )
[ # # ]
473 : : {
474 : 0 : ::com::sun::star::awt::Point aPoint;
475 : 0 : aPoint.X = aPoint.Y = SAL_MAX_INT32;
476 [ # # ][ # # ]: 0 : xLayoutManager->dockWindow( m_aResourceName, DockingArea_DOCKINGAREA_DEFAULT, aPoint );
477 [ # # ][ # # ]: 0 : xLayoutManager->lockWindow( m_aResourceName );
478 : 0 : }
479 : : }
480 : :
481 [ + - ]: 2596 : if ( !m_bUpdateControllers )
482 : : {
483 : 2596 : m_bUpdateControllers = sal_True;
484 [ + - ]: 2596 : ToolBarControllerMap::iterator pIter = m_aControllerMap.begin();
485 : :
486 [ + - ][ + + ]: 71304 : while ( pIter != m_aControllerMap.end() )
487 : : {
488 : : try
489 : : {
490 [ + - ][ + - ]: 68708 : Reference< XUpdatable > xUpdatable( pIter->second, UNO_QUERY );
491 [ + + ]: 68708 : if ( xUpdatable.is() )
492 [ + - ][ + - ]: 68708 : xUpdatable->update();
[ # # ]
493 : : }
494 [ # # ]: 0 : catch (const Exception&)
495 : : {
496 : : }
497 : 68708 : ++pIter;
498 : : }
499 : : }
500 : 2596 : m_bUpdateControllers = sal_False;
501 : 2596 : }
502 : :
503 : : //for update toolbar controller via Support Visible
504 : 1922 : void ToolBarManager::UpdateController( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XToolbarController > xController)
505 : : {
506 : : RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ToolBarManager::UpdateControllers" );
507 : :
508 [ + - ]: 1922 : if ( !m_bUpdateControllers )
509 : : {
510 : 1922 : m_bUpdateControllers = sal_True;
511 : : try
512 [ + - ]: 1922 : { if(xController.is())
513 : : {
514 [ + - ]: 1922 : Reference< XUpdatable > xUpdatable( xController, UNO_QUERY );
515 [ + - ]: 1922 : if ( xUpdatable.is() )
516 [ + - ][ + - ]: 1922 : xUpdatable->update();
[ # # ]
517 : : }
518 : : }
519 : 0 : catch (const Exception&)
520 : : {
521 : : }
522 : :
523 : :
524 : : }
525 : 1922 : m_bUpdateControllers = sal_False;
526 : 1922 : }
527 : :
528 : 7570 : void ToolBarManager::frameAction( const FrameActionEvent& Action )
529 : : throw ( RuntimeException )
530 : : {
531 [ + - ]: 7570 : ResetableGuard aGuard( m_aLock );
532 [ - + ]: 7570 : if ( Action.Action == FrameAction_CONTEXT_CHANGED )
533 [ # # ][ + - ]: 7570 : m_aAsyncUpdateControllersTimer.Start();
534 : 7570 : }
535 : :
536 : 4165 : void SAL_CALL ToolBarManager::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
537 : : throw ( ::com::sun::star::uno::RuntimeException )
538 : : {
539 [ + - ]: 4165 : ResetableGuard aGuard( m_aLock );
540 [ - + ]: 4165 : if ( m_bDisposed )
541 : 4165 : return;
542 : :
543 [ + - ]: 4165 : if ( Event.FeatureURL.Complete == ".uno:ImageOrientation" )
544 : : {
545 [ + - ]: 4165 : SfxImageItem aItem( 1, 0 );
546 [ + - ]: 4165 : aItem.PutValue( Event.State );
547 : :
548 [ + - ]: 4165 : m_lImageRotation = aItem.GetRotation();
549 [ + - ]: 4165 : m_bImageMirrored = aItem.IsMirrored();
550 [ + - ][ + - ]: 4165 : UpdateImageOrientation();
551 [ + - ][ + - ]: 4165 : }
552 : : }
553 : :
554 : 0 : void SAL_CALL ToolBarManager::disposing( const EventObject& Source ) throw ( RuntimeException )
555 : : {
556 : : {
557 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
558 [ # # ]: 0 : if ( m_bDisposed )
559 [ # # ][ # # ]: 0 : return;
560 : : }
561 : :
562 : 0 : RemoveControllers();
563 : :
564 : : {
565 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
566 [ # # ]: 0 : if ( m_xDocImageManager.is() )
567 : : {
568 : : try
569 : : {
570 [ # # ]: 0 : m_xDocImageManager->removeConfigurationListener(
571 : : Reference< XUIConfigurationListener >(
572 [ # # ][ # # ]: 0 : static_cast< OWeakObject* >( this ), UNO_QUERY ));
[ # # ]
573 : : }
574 [ # # ]: 0 : catch (const Exception&)
575 : : {
576 : : }
577 : : }
578 : :
579 [ # # ]: 0 : if ( m_xModuleImageManager.is() )
580 : : {
581 : : try
582 : : {
583 [ # # ]: 0 : m_xModuleImageManager->removeConfigurationListener(
584 : : Reference< XUIConfigurationListener >(
585 [ # # ][ # # ]: 0 : static_cast< OWeakObject* >( this ), UNO_QUERY ));
[ # # ]
586 : : }
587 [ # # ]: 0 : catch (const Exception&)
588 : : {
589 : : }
590 : : }
591 : :
592 [ # # ]: 0 : if ( m_xImageOrientationListener.is() )
593 : : {
594 : : ImageOrientationListener* pImageOrientation =
595 [ # # ][ # # ]: 0 : (ImageOrientationListener*)m_xImageOrientationListener.get();
596 [ # # ]: 0 : pImageOrientation->unbindListener();
597 : 0 : m_xImageOrientationListener.clear();
598 : : }
599 : :
600 : 0 : m_xDocImageManager.clear();
601 : 0 : m_xModuleImageManager.clear();
602 : :
603 [ # # ][ # # ]: 0 : if ( Source.Source == Reference< XInterface >( m_xFrame, UNO_QUERY ))
[ # # ]
604 : 0 : m_xFrame.clear();
605 : :
606 [ # # ]: 0 : m_xServiceManager.clear();
607 : : }
608 : : }
609 : :
610 : : // XComponent
611 : 3527 : void SAL_CALL ToolBarManager::dispose() throw( RuntimeException )
612 : : {
613 [ + - ]: 3527 : Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
614 : :
615 [ + - ]: 3527 : EventObject aEvent( xThis );
616 [ + - ]: 3527 : m_aListenerContainer.disposeAndClear( aEvent );
617 : :
618 : : {
619 [ + - ]: 3527 : ResetableGuard aGuard( m_aLock );
620 : :
621 : : // stop timer to prevent timer events after dispose
622 [ + - ]: 3527 : m_aAsyncUpdateControllersTimer.Stop();
623 : :
624 [ + - ]: 3527 : RemoveControllers();
625 : :
626 [ + + ]: 3527 : if ( m_xDocImageManager.is() )
627 : : {
628 : : try
629 : : {
630 [ + - ]: 2444 : m_xDocImageManager->removeConfigurationListener(
631 : : Reference< XUIConfigurationListener >(
632 [ + - ][ + - ]: 2444 : static_cast< OWeakObject* >( this ), UNO_QUERY ));
[ # # ]
633 : : }
634 [ # # ]: 0 : catch (const Exception&)
635 : : {
636 : : }
637 : : }
638 : 3527 : m_xDocImageManager.clear();
639 [ + + ]: 3527 : if ( m_xModuleImageManager.is() )
640 : : {
641 : : try
642 : : {
643 [ + - ]: 2548 : m_xModuleImageManager->removeConfigurationListener(
644 : : Reference< XUIConfigurationListener >(
645 [ + - ][ + - ]: 2548 : static_cast< OWeakObject* >( this ), UNO_QUERY ));
[ # # ]
646 : : }
647 [ # # ]: 0 : catch (const Exception&)
648 : : {
649 : : }
650 : : }
651 : 3527 : m_xModuleImageManager.clear();
652 : :
653 [ + - ]: 3527 : ImplClearPopupMenu( m_pToolBar );
654 : :
655 : : // We have to destroy our toolbar instance now.
656 [ + - ]: 3527 : Destroy();
657 : :
658 [ + + ][ + - ]: 3527 : if ( m_bFrameActionRegistered && m_xFrame.is() )
[ + + ]
659 : : {
660 : : try
661 : : {
662 [ + - ]: 2548 : m_xFrame->removeFrameActionListener( Reference< XFrameActionListener >(
663 [ + - ][ + - ]: 2548 : static_cast< ::cppu::OWeakObject *>( this ), UNO_QUERY ));
[ # # ]
664 : : }
665 [ # # ]: 0 : catch (const Exception&)
666 : : {
667 : : }
668 : : }
669 : :
670 [ + + ]: 3527 : if ( m_xImageOrientationListener.is() )
671 : : {
672 : : ImageOrientationListener* pImageOrientation =
673 [ + - ][ + - ]: 2548 : (ImageOrientationListener*)m_xImageOrientationListener.get();
674 [ + - ]: 2548 : pImageOrientation->unbindListener();
675 : 2548 : m_xImageOrientationListener.clear();
676 : : }
677 : :
678 : 3527 : m_xFrame.clear();
679 : 3527 : m_xServiceManager.clear();
680 : 3527 : m_xGlobalAcceleratorManager.clear();
681 : 3527 : m_xModuleAcceleratorManager.clear();
682 : 3527 : m_xDocAcceleratorManager.clear();
683 : :
684 [ + - ]: 3527 : m_bDisposed = sal_True;
685 [ + - ]: 3527 : }
686 : 3527 : }
687 : :
688 : 0 : void SAL_CALL ToolBarManager::addEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException )
689 : : {
690 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
691 : :
692 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
693 [ # # ]: 0 : if ( m_bDisposed )
694 [ # # ]: 0 : throw DisposedException();
695 : :
696 [ # # ][ # # ]: 0 : m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
[ # # ]
697 : 0 : }
698 : :
699 : 0 : void SAL_CALL ToolBarManager::removeEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException )
700 : : {
701 : 0 : m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
702 : 0 : }
703 : :
704 : : // XUIConfigurationListener
705 : 0 : void SAL_CALL ToolBarManager::elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
706 : : {
707 : 0 : impl_elementChanged(false,Event);
708 : 0 : }
709 : :
710 : 0 : void SAL_CALL ToolBarManager::elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
711 : : {
712 : 0 : impl_elementChanged(true,Event);
713 : 0 : }
714 : 0 : void ToolBarManager::impl_elementChanged(bool _bRemove,const ::com::sun::star::ui::ConfigurationEvent& Event )
715 : : {
716 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
717 : :
718 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
719 [ # # ]: 0 : if ( m_bDisposed )
720 : 0 : return;
721 : :
722 : 0 : Reference< XNameAccess > xNameAccess;
723 : 0 : sal_Int16 nImageType = sal_Int16();
724 : : sal_Int16 nCurrentImageType = getImageTypeFromBools(
725 [ # # # # ]: 0 : SvtMiscOptions().AreCurrentSymbolsLarge()
[ # # ]
726 : 0 : );
727 : :
728 [ # # ][ # # ]: 0 : if (( Event.aInfo >>= nImageType ) &&
[ # # ][ # # ]
729 : : ( nImageType == nCurrentImageType ) &&
730 [ # # ]: 0 : ( Event.Element >>= xNameAccess ))
731 : : {
732 : 0 : sal_Int16 nImageInfo( 1 );
733 [ # # ]: 0 : Reference< XInterface > xIfacDocImgMgr( m_xDocImageManager, UNO_QUERY );
734 [ # # ][ # # ]: 0 : if ( xIfacDocImgMgr == Event.Source )
735 : 0 : nImageInfo = 0;
736 : :
737 [ # # ][ # # ]: 0 : Sequence< rtl::OUString > aSeq = xNameAccess->getElementNames();
738 [ # # ]: 0 : for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
739 : : {
740 [ # # ][ # # ]: 0 : CommandToInfoMap::iterator pIter = m_aCommandMap.find( aSeq[i] );
741 [ # # ][ # # ]: 0 : if ( pIter != m_aCommandMap.end() && ( pIter->second.nImageInfo >= nImageInfo ))
[ # # ][ # # ]
[ # # # # ]
742 : : {
743 [ # # ]: 0 : if ( _bRemove )
744 : : {
745 [ # # ]: 0 : Image aImage;
746 [ # # ][ # # ]: 0 : if (( pIter->second.nImageInfo == 0 ) && ( pIter->second.nImageInfo == nImageInfo ))
[ # # ][ # # ]
[ # # ]
747 : : {
748 : : // Special case: An image from the document image manager has been removed.
749 : : // It is possible that we have a image at our module image manager. Before
750 : : // we can remove our image we have to ask our module image manager.
751 [ # # ]: 0 : Sequence< rtl::OUString > aCmdURLSeq( 1 );
752 [ # # ]: 0 : Sequence< Reference< XGraphic > > aGraphicSeq;
753 [ # # ][ # # ]: 0 : aCmdURLSeq[0] = pIter->first;
754 [ # # ][ # # ]: 0 : aGraphicSeq = m_xModuleImageManager->getImages( nImageType, aCmdURLSeq );
[ # # ][ # # ]
755 [ # # ][ # # ]: 0 : aImage = Image( aGraphicSeq[0] );
[ # # ][ # # ]
[ # # ][ # # ]
756 : : }
757 : :
758 [ # # ][ # # ]: 0 : setToolBarImage(aImage,pIter);
759 : : } // if ( _bRemove )
760 : : else
761 : : {
762 : 0 : Reference< XGraphic > xGraphic;
763 [ # # ][ # # ]: 0 : if ( xNameAccess->getByName( aSeq[i] ) >>= xGraphic )
[ # # ][ # # ]
[ # # ]
764 : : {
765 [ # # ]: 0 : Image aImage( xGraphic );
766 [ # # ][ # # ]: 0 : setToolBarImage(aImage,pIter);
767 : : }
768 [ # # ]: 0 : pIter->second.nImageInfo = nImageInfo;
769 : : }
770 : : }
771 [ # # ]: 0 : }
772 [ # # ][ # # ]: 0 : }
773 : : }
774 : 71790 : void ToolBarManager::setToolBarImage(const Image& _aImage,const CommandToInfoMap::const_iterator& _pIter)
775 : : {
776 : 71790 : const ::std::vector< sal_uInt16 >& _rIDs = _pIter->second.aIds;
777 : 71790 : m_pToolBar->SetItemImage( _pIter->second.nId, _aImage );
778 [ + - ][ + - ]: 71790 : ::std::for_each(_rIDs.begin(),_rIDs.end(),::boost::bind(&ToolBar::SetItemImage,m_pToolBar,_1,_aImage));
[ + - ][ + - ]
779 : 71790 : }
780 : :
781 : 0 : void SAL_CALL ToolBarManager::elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
782 : : {
783 : 0 : impl_elementChanged(false,Event);
784 : 0 : }
785 : :
786 : 6075 : void ToolBarManager::RemoveControllers()
787 : : {
788 [ + - ]: 6075 : ResetableGuard aGuard( m_aLock );
789 : :
790 [ - + ]: 6075 : if ( m_bDisposed )
791 [ # # ]: 6075 : return;
792 : :
793 [ + - ]: 6075 : m_aSubToolBarControllerMap.clear();
794 : :
795 : :
796 : : // i90033
797 : : // Remove item window pointers from the toolbar. They were
798 : : // destroyed by the dispose() at the XComponent. This is needed
799 : : // as VCL code later tries to access the item window data in certain
800 : : // dtors where the item window is already invalid!
801 [ + - ][ + + ]: 99448 : for ( sal_uInt16 i = 0; i < m_pToolBar->GetItemCount(); i++ )
802 : : {
803 [ + - ]: 93373 : sal_uInt16 nItemId = m_pToolBar->GetItemId( i );
804 [ + + ]: 93373 : if ( nItemId > 0 )
805 : : {
806 [ + - ][ + - ]: 71790 : Reference< XComponent > xComponent( m_aControllerMap[ nItemId ], UNO_QUERY );
807 [ + + ]: 71790 : if ( xComponent.is() )
808 : : {
809 : : try
810 : : {
811 [ + - ][ + - ]: 70647 : xComponent->dispose();
812 : : }
813 [ # # ]: 0 : catch (const Exception&)
814 : : {
815 : : }
816 : : }
817 [ + - ]: 71790 : m_pToolBar->SetItemWindow(nItemId, 0);
818 : : }
819 : : }
820 [ + - ][ + - ]: 6075 : m_aControllerMap.clear();
[ + - ]
821 : : }
822 : :
823 : 123360 : uno::Sequence< beans::PropertyValue > ToolBarManager::GetPropsForCommand( const ::rtl::OUString& rCmdURL )
824 : : {
825 : 123360 : Sequence< PropertyValue > aPropSeq;
826 : :
827 : : // Retrieve properties for command
828 : : try
829 : : {
830 [ + + ]: 123360 : if ( !m_bModuleIdentified )
831 : : {
832 [ + - ][ + - ]: 2548 : Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
[ + - ][ + - ]
833 [ + - ]: 2548 : Reference< XInterface > xIfac( m_xFrame, UNO_QUERY );
834 : :
835 : 2548 : m_bModuleIdentified = sal_True;
836 [ + - ][ + - ]: 2548 : m_aModuleIdentifier = xModuleManager->identify( xIfac );
837 : :
838 [ + - ]: 2548 : if ( !m_aModuleIdentifier.isEmpty() )
839 : : {
840 [ + - ][ + - ]: 2548 : Reference< XNameAccess > xNameAccess( m_xServiceManager->createInstance( SERVICENAME_UICOMMANDDESCRIPTION ), UNO_QUERY );
[ + - ][ + - ]
841 [ + - ]: 2548 : if ( xNameAccess.is() )
842 [ + - ][ + - ]: 2548 : xNameAccess->getByName( m_aModuleIdentifier ) >>= m_xUICommandLabels;
[ + - ]
843 : 2548 : }
844 : : }
845 : :
846 [ + - ]: 123360 : if ( m_xUICommandLabels.is() )
847 : : {
848 [ + - ]: 123360 : if ( !rCmdURL.isEmpty() )
849 [ + - ][ + - ]: 123360 : m_xUICommandLabels->getByName( rCmdURL ) >>= aPropSeq;
[ + - ][ # # ]
850 : : }
851 : : }
852 [ # # ]: 0 : catch (const Exception&)
853 : : {
854 : : }
855 : :
856 : 123360 : return aPropSeq;
857 : : }
858 : :
859 : 71790 : ::rtl::OUString ToolBarManager::RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL )
860 : : {
861 : 71790 : ::rtl::OUString aLabel;
862 [ + - ]: 71790 : Sequence< PropertyValue > aPropSeq;
863 : :
864 : : // Retrieve popup menu labels
865 [ + - ][ + - ]: 71790 : aPropSeq = GetPropsForCommand( aCmdURL );
[ + - ]
866 [ + - ]: 143580 : for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
867 : : {
868 [ + - ][ + + ]: 143580 : if ( aPropSeq[i].Name == "Name" )
869 : : {
870 [ + - ]: 71790 : aPropSeq[i].Value >>= aLabel;
871 : 71790 : break;
872 : : }
873 : : }
874 [ + - ]: 71790 : return aLabel;
875 : : }
876 : :
877 : 51570 : sal_Int32 ToolBarManager::RetrievePropertiesFromCommand( const ::rtl::OUString& aCmdURL )
878 : : {
879 : 51570 : sal_Int32 nProperties(0);
880 [ + - ]: 51570 : Sequence< PropertyValue > aPropSeq;
881 : :
882 : : // Retrieve popup menu labels
883 [ + - ][ + - ]: 51570 : aPropSeq = GetPropsForCommand( aCmdURL );
[ + - ]
884 [ + - ]: 206280 : for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
885 : : {
886 [ + - ][ + + ]: 206280 : if ( aPropSeq[i].Name == "Properties" )
887 : : {
888 [ + - ]: 51570 : aPropSeq[i].Value >>= nProperties;
889 : 51570 : break;
890 : : }
891 : : }
892 [ + - ]: 51570 : return nProperties;
893 : : }
894 : :
895 : 2548 : void ToolBarManager::CreateControllers()
896 : : {
897 : : RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ToolBarManager::CreateControllers" );
898 : :
899 [ + - ]: 2548 : Reference< XMultiComponentFactory > xToolbarControllerFactory( m_xToolbarControllerRegistration, UNO_QUERY );
900 : 2548 : Reference< XComponentContext > xComponentContext;
901 [ + - ]: 2548 : Reference< XPropertySet > xProps( m_xServiceManager, UNO_QUERY );
902 [ + - ]: 2548 : Reference< XWindow > xToolbarWindow = VCLUnoHelper::GetInterface( m_pToolBar );
903 : :
904 : 2548 : css::util::URL aURL;
905 [ + - ][ + - ]: 2548 : sal_Bool bHasDisabledEntries = SvtCommandOptions().HasEntries( SvtCommandOptions::CMDOPTION_DISABLED );
[ + - ]
906 [ + - ]: 2548 : SvtCommandOptions aCmdOptions;
907 : :
908 [ + - ]: 2548 : if ( xProps.is() )
909 [ + - ][ + - ]: 2548 : xProps->getPropertyValue( rtl::OUString( "DefaultContext" )) >>= xComponentContext;
[ + - ]
910 : :
911 [ + - ][ + + ]: 95921 : for ( sal_uInt16 i = 0; i < m_pToolBar->GetItemCount(); i++ )
912 : : {
913 [ + - ]: 93373 : sal_uInt16 nId = m_pToolBar->GetItemId( i );
914 [ + + ]: 93373 : if ( nId == 0 )
915 : 21583 : continue;
916 : :
917 : 71790 : rtl::OUString aLoadURL( ".uno:OpenUrl" );
918 [ + - ][ + - ]: 71790 : rtl::OUString aCommandURL( m_pToolBar->GetItemCommand( nId ));
919 : 71790 : sal_Bool bInit( sal_True );
920 : 71790 : sal_Bool bCreate( sal_True );
921 : 71790 : Reference< XStatusListener > xController;
922 [ + - ]: 71790 : CommandToInfoMap::iterator pCommandIter = m_aCommandMap.find( aCommandURL );
923 [ + - ][ + - ]: 71790 : sal_Int16 nWidth = ( pCommandIter != m_aCommandMap.end() ? pCommandIter->second.nWidth : 0 );
924 : :
925 : 71790 : svt::ToolboxController* pController( 0 );
926 : :
927 [ - + ]: 71790 : if ( bHasDisabledEntries )
928 : : {
929 : 0 : aURL.Complete = aCommandURL;
930 [ # # ][ # # ]: 0 : m_xURLTransformer->parseStrict( aURL );
931 [ # # ][ # # ]: 0 : if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aURL.Path ))
932 : : {
933 [ # # ][ # # ]: 0 : m_aControllerMap[ nId ] = xController;
934 [ # # ]: 0 : m_pToolBar->HideItem( nId );
935 : 0 : continue;
936 : : }
937 : : }
938 : :
939 [ + - ][ + + ]: 143580 : if ( m_xToolbarControllerRegistration.is() &&
[ + + ]
940 [ + - ][ + - ]: 71790 : m_xToolbarControllerRegistration->hasController( aCommandURL, m_aModuleIdentifier ))
941 : : {
942 [ + - ]: 1251 : if ( xToolbarControllerFactory.is() )
943 : : {
944 : 1251 : PropertyValue aPropValue;
945 [ + - ]: 1251 : std::vector< Any > aPropertyVector;
946 : :
947 : 1251 : aPropValue.Name = rtl::OUString( "ModuleName" );
948 [ + - ]: 1251 : aPropValue.Value <<= m_aModuleIdentifier;
949 [ + - ][ + - ]: 1251 : aPropertyVector.push_back( makeAny( aPropValue ));
950 : 1251 : aPropValue.Name = rtl::OUString( "Frame" );
951 [ + - ]: 1251 : aPropValue.Value <<= m_xFrame;
952 [ + - ][ + - ]: 1251 : aPropertyVector.push_back( makeAny( aPropValue ));
953 : 1251 : aPropValue.Name = rtl::OUString( "ServiceManager" );
954 [ + - ]: 1251 : aPropValue.Value <<= m_xServiceManager;
955 [ + - ][ + - ]: 1251 : aPropertyVector.push_back( makeAny( aPropValue ));
956 : 1251 : aPropValue.Name = rtl::OUString( "ParentWindow" );
957 [ + - ]: 1251 : aPropValue.Value <<= xToolbarWindow;
958 [ + - ][ + - ]: 1251 : aPropertyVector.push_back( makeAny( aPropValue ));
959 : :
960 [ - + ]: 1251 : if ( nWidth > 0 )
961 : : {
962 : 0 : aPropValue.Name = rtl::OUString( "Width" );
963 [ # # ]: 0 : aPropValue.Value <<= nWidth;
964 [ # # ][ # # ]: 0 : aPropertyVector.push_back( makeAny( aPropValue ));
965 : : }
966 : :
967 [ + - ]: 1251 : Sequence< Any > aArgs( comphelper::containerToSequence( aPropertyVector ));
968 [ + - ]: 1251 : xController = Reference< XStatusListener >( xToolbarControllerFactory->createInstanceWithArgumentsAndContext(
969 : 1251 : aCommandURL, aArgs, xComponentContext ),
970 [ + - ][ + - ]: 1251 : UNO_QUERY );
[ + - ]
971 [ + - ]: 1251 : bInit = sal_False; // Initialization is done through the factory service
972 : : }
973 : : }
974 : :
975 [ + + ][ + - ]: 71790 : if (( aCommandURL == aLoadURL ) && ( !m_pToolBar->IsItemVisible(nId)))
[ + - ][ + + ]
976 : 1143 : bCreate = sal_False;
977 : :
978 [ + + ][ + - ]: 71790 : if ( !xController.is() && m_pToolBar && bCreate )
[ + + ][ + + ]
979 : : {
980 [ + - ]: 69396 : pController = CreateToolBoxController( m_xFrame, m_pToolBar, nId, aCommandURL );
981 [ + + ]: 69396 : if ( !pController )
982 : : {
983 [ + - ][ - + ]: 51570 : if ( m_pToolBar->GetItemData( nId ) != 0 )
984 : : {
985 : : // retrieve additional parameters
986 [ # # ]: 0 : ::rtl::OUString aControlType = static_cast< AddonsParams* >( m_pToolBar->GetItemData( nId ))->aControlType;
987 : :
988 : : Reference< XStatusListener > xStatusListener(
989 : : ToolBarMerger::CreateController( m_xServiceManager,
990 : : m_xFrame,
991 : : m_pToolBar,
992 : : aCommandURL,
993 : : nId,
994 : : nWidth,
995 [ # # ][ # # ]: 0 : aControlType ), UNO_QUERY );
996 : :
997 [ # # ]: 0 : xController = xStatusListener;
998 : : }
999 : : else
1000 : : {
1001 [ + - ]: 51570 : MenuDescriptionMap::iterator it = m_aMenuMap.find( nId );
1002 [ + - ][ + - ]: 51570 : if ( it == m_aMenuMap.end() )
1003 : : {
1004 : : xController = Reference< XStatusListener >(
1005 [ + - ][ + - ]: 51570 : new GenericToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL ));
[ + - ]
1006 : :
1007 : : // Accessibility support: Set toggle button role for specific commands
1008 [ + - ]: 51570 : sal_Int32 nProps = RetrievePropertiesFromCommand( aCommandURL );
1009 [ + + ]: 51570 : if ( nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON )
1010 [ + - ][ + - ]: 20999 : m_pToolBar->SetItemBits( nId, m_pToolBar->GetItemBits( nId ) | TIB_CHECKABLE );
1011 : : }
1012 : : else
1013 : : xController = Reference< XStatusListener >(
1014 [ # # ][ # # ]: 51570 : new MenuToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL, m_aModuleIdentifier, m_aMenuMap[ nId ] ));
[ # # ][ # # ]
1015 : : }
1016 : : }
1017 [ + - ]: 17826 : else if ( pController )
1018 : : {
1019 [ + - ][ + - ]: 17826 : xController = Reference< XStatusListener >( static_cast< ::cppu::OWeakObject *>( pController ), UNO_QUERY );
[ + - ]
1020 : : }
1021 : : }
1022 : :
1023 : : // Associate ID and controller to be able to retrieve
1024 : : // the controller from the ID later.
1025 [ + - ][ + - ]: 71790 : m_aControllerMap[ nId ] = xController;
1026 : :
1027 : : // Fill sub-toolbars into our hash-map
1028 [ + - ]: 71790 : Reference< XSubToolbarController > xSubToolBar( xController, UNO_QUERY );
1029 [ + + ][ + - ]: 71790 : if ( xSubToolBar.is() && xSubToolBar->opensSubToolbar() )
[ + - ][ + + ]
[ + + ]
1030 : : {
1031 [ + - ][ + - ]: 978 : rtl::OUString aSubToolBarName = xSubToolBar->getSubToolbarName();
1032 [ + - ]: 978 : if ( !aSubToolBarName.isEmpty() )
1033 : : {
1034 : : SubToolBarToSubToolBarControllerMap::iterator pIter =
1035 [ + - ]: 978 : m_aSubToolBarControllerMap.find( aSubToolBarName );
1036 [ + - ][ + - ]: 978 : if ( pIter == m_aSubToolBarControllerMap.end() )
1037 : : {
1038 [ + - ]: 978 : SubToolBarControllerVector aSubToolBarVector;
1039 [ + - ]: 978 : aSubToolBarVector.push_back( xSubToolBar );
1040 : : m_aSubToolBarControllerMap.insert(
1041 : : SubToolBarToSubToolBarControllerMap::value_type(
1042 [ + - ][ + - ]: 978 : aSubToolBarName, aSubToolBarVector ));
1043 : : }
1044 : : else
1045 [ # # ][ # # ]: 978 : pIter->second.push_back( xSubToolBar );
1046 : 978 : }
1047 : : }
1048 : :
1049 [ + - ]: 71790 : Reference< XInitialization > xInit( xController, UNO_QUERY );
1050 [ + + ]: 71790 : if ( xInit.is() )
1051 : : {
1052 [ + + ]: 70647 : if ( bInit )
1053 : : {
1054 : 69396 : PropertyValue aPropValue;
1055 [ + - ]: 69396 : std::vector< Any > aPropertyVector;
1056 : :
1057 : 69396 : aPropValue.Name = ::rtl::OUString( "Frame" );
1058 [ + - ]: 69396 : aPropValue.Value <<= m_xFrame;
1059 [ + - ][ + - ]: 69396 : aPropertyVector.push_back( makeAny( aPropValue ));
1060 : 69396 : aPropValue.Name = ::rtl::OUString( "CommandURL" );
1061 [ + - ]: 69396 : aPropValue.Value <<= aCommandURL;
1062 [ + - ][ + - ]: 69396 : aPropertyVector.push_back( makeAny( aPropValue ));
1063 : 69396 : aPropValue.Name = ::rtl::OUString( "ServiceManager" );
1064 [ + - ]: 69396 : aPropValue.Value <<= m_xServiceManager;
1065 [ + - ][ + - ]: 69396 : aPropertyVector.push_back( makeAny( aPropValue ));
1066 : 69396 : aPropValue.Name = rtl::OUString( "ParentWindow" );
1067 [ + - ]: 69396 : aPropValue.Value <<= xToolbarWindow;
1068 [ + - ][ + - ]: 69396 : aPropertyVector.push_back( makeAny( aPropValue ));
1069 : 69396 : aPropValue.Name = rtl::OUString( "ModuleName" );
1070 [ + - ]: 69396 : aPropValue.Value <<= m_aModuleIdentifier;
1071 [ + - ][ + - ]: 69396 : aPropertyVector.push_back( makeAny( aPropValue ));
1072 : :
1073 [ - + ]: 69396 : if ( nWidth > 0 )
1074 : : {
1075 : 0 : aPropValue.Name = rtl::OUString( "Width" );
1076 [ # # ]: 0 : aPropValue.Value <<= nWidth;
1077 [ # # ][ # # ]: 0 : aPropertyVector.push_back( makeAny( aPropValue ));
1078 : : }
1079 : :
1080 [ + - ]: 69396 : Sequence< Any > aArgs( comphelper::containerToSequence( aPropertyVector ));
1081 [ + - ][ + - ]: 69396 : xInit->initialize( aArgs );
1082 : :
1083 [ + + ]: 69396 : if (pController)
1084 : : {
1085 [ + - + - : 88169 : if(aCommandURL == rtl::OUString( ".uno:SwitchXFormsDesignMode" ) ||
+ + + + ]
[ + - ][ + - ]
[ + + ]
1086 [ + - ][ + - ]: 35652 : aCommandURL == rtl::OUString( ".uno:ViewDataSourceBrowser" ) ||
1087 [ + - ][ + - ]: 35652 : aCommandURL == rtl::OUString( ".uno:ParaLeftToRight" ) ||
1088 [ + + ][ + + ]: 34691 : aCommandURL == rtl::OUString( ".uno:ParaRightToLeft" )
1089 : : )
1090 [ + - ][ + - ]: 1922 : pController->setFastPropertyValue_NoBroadcast(1,makeAny(sal_True));
1091 [ + - ]: 69396 : }
1092 : : }
1093 : :
1094 : : // Request a item window from the toolbar controller and set it at the VCL toolbar
1095 [ + - ]: 70647 : Reference< XToolbarController > xTbxController( xController, UNO_QUERY );
1096 [ + - ][ + - ]: 70647 : if ( xTbxController.is() && xToolbarWindow.is() )
[ + - ]
1097 : : {
1098 [ + - ][ + - ]: 70647 : Reference< XWindow > xWindow = xTbxController->createItemWindow( xToolbarWindow );
1099 [ + + ]: 70647 : if ( xWindow.is() )
1100 : : {
1101 [ + - ]: 3449 : Window* pItemWin = VCLUnoHelper::GetWindow( xWindow );
1102 [ + - ]: 3449 : if ( pItemWin )
1103 : : {
1104 [ + - ]: 3449 : WindowType nType = pItemWin->GetType();
1105 [ + + ][ + - ]: 3449 : if ( nType == WINDOW_LISTBOX || nType == WINDOW_MULTILISTBOX || nType == WINDOW_COMBOBOX )
[ + + ]
1106 [ + - ][ + - ]: 3175 : pItemWin->SetAccessibleName( m_pToolBar->GetItemText( nId ) );
1107 [ + - ]: 3449 : m_pToolBar->SetItemWindow( nId, pItemWin );
1108 : : }
1109 : 70647 : }
1110 : 70647 : }
1111 : : }
1112 : :
1113 : : //for update Controller via support visiable state
1114 [ + - ]: 71790 : Reference< XPropertySet > xPropSet( xController, UNO_QUERY );
1115 [ + + ]: 71790 : if ( xPropSet.is() )
1116 : : {
1117 : : try
1118 : : {
1119 : 70647 : sal_Bool bSupportVisible = sal_True;
1120 [ + - ][ + - ]: 70647 : Any a( xPropSet->getPropertyValue( ::rtl::OUString( "SupportsVisible" )) );
1121 : 70647 : a >>= bSupportVisible;
1122 [ + + ]: 70647 : if (bSupportVisible)
1123 : : {
1124 [ + - ]: 1922 : Reference< XToolbarController > xTbxController( xController, UNO_QUERY );
1125 [ + - ]: 1922 : UpdateController(xTbxController);
1126 : 70647 : }
1127 : : }
1128 [ # # # ]: 0 : catch (const RuntimeException&)
1129 : : {
1130 : 0 : throw;
1131 : : }
1132 [ # # ]: 0 : catch (const Exception&)
1133 : : {
1134 : : }
1135 : : }
1136 [ - + ][ - + ]: 93373 : }
[ + - ]
1137 : :
1138 [ + - ]: 2548 : AddFrameActionListener();
1139 [ + - ][ + - ]: 2548 : AddImageOrientationListener();
1140 : 2548 : }
1141 : :
1142 : 2548 : void ToolBarManager::AddFrameActionListener()
1143 : : {
1144 [ + - ][ + - ]: 2548 : if ( !m_bFrameActionRegistered && m_xFrame.is() )
[ + - ]
1145 : : {
1146 : 2548 : m_bFrameActionRegistered = sal_True;
1147 : 2548 : m_xFrame->addFrameActionListener( Reference< XFrameActionListener >(
1148 [ + - ]: 2548 : static_cast< ::cppu::OWeakObject *>( this ), UNO_QUERY ));
1149 : : }
1150 : 2548 : }
1151 : :
1152 : 2548 : void ToolBarManager::AddImageOrientationListener()
1153 : : {
1154 [ + - ][ + - ]: 2548 : if ( !m_bImageOrientationRegistered && m_xFrame.is() )
[ + - ]
1155 : : {
1156 : 2548 : m_bImageOrientationRegistered = sal_True;
1157 : : ImageOrientationListener* pImageOrientation = new ImageOrientationListener(
1158 : : Reference< XStatusListener >( static_cast< ::cppu::OWeakObject *>( this ), UNO_QUERY ),
1159 : : m_xServiceManager,
1160 [ + - ]: 2548 : m_xFrame );
1161 : : m_xImageOrientationListener = Reference< XComponent >( static_cast< ::cppu::OWeakObject *>(
1162 [ + - ][ + - ]: 2548 : pImageOrientation ), UNO_QUERY );
1163 : : pImageOrientation->addStatusListener(
1164 [ + - ]: 2548 : rtl::OUString( ".uno:ImageOrientation" ));
1165 : 2548 : pImageOrientation->bindListener();
1166 : : }
1167 : 2548 : }
1168 : :
1169 : 71790 : sal_uInt16 ToolBarManager::ConvertStyleToToolboxItemBits( sal_Int32 nStyle )
1170 : : {
1171 : 71790 : sal_uInt16 nItemBits( 0 );
1172 [ + + ]: 71790 : if ( nStyle & ::com::sun::star::ui::ItemStyle::RADIO_CHECK )
1173 : 11080 : nItemBits |= TIB_RADIOCHECK;
1174 [ - + ]: 71790 : if ( nStyle & ::com::sun::star::ui::ItemStyle::ALIGN_LEFT )
1175 : 0 : nItemBits |= TIB_LEFT;
1176 [ - + ]: 71790 : if ( nStyle & ::com::sun::star::ui::ItemStyle::AUTO_SIZE )
1177 : 0 : nItemBits |= TIB_AUTOSIZE;
1178 [ + + ]: 71790 : if ( nStyle & ::com::sun::star::ui::ItemStyle::DROP_DOWN )
1179 : 4941 : nItemBits |= TIB_DROPDOWN;
1180 [ - + ]: 71790 : if ( nStyle & ::com::sun::star::ui::ItemStyle::REPEAT )
1181 : 0 : nItemBits |= TIB_REPEAT;
1182 [ + + ]: 71790 : if ( nStyle & ::com::sun::star::ui::ItemStyle::DROPDOWN_ONLY )
1183 : 26 : nItemBits |= TIB_DROPDOWNONLY;
1184 [ - + ]: 71790 : if ( nStyle & ::com::sun::star::ui::ItemStyle::TEXT )
1185 : 0 : nItemBits |= TIB_TEXT_ONLY;
1186 [ - + ]: 71790 : if ( nStyle & ::com::sun::star::ui::ItemStyle::ICON )
1187 : 0 : nItemBits |= TIB_ICON_ONLY;
1188 : :
1189 : 71790 : return nItemBits;
1190 : : }
1191 : :
1192 : 2548 : void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContainer )
1193 : : {
1194 [ + - ]: 2548 : ::rtl::OString aTbxName = rtl::OUStringToOString( m_aResourceName, RTL_TEXTENCODING_ASCII_US );
1195 : :
1196 : : RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ToolBarManager::FillToolbar" );
1197 : : RTL_LOGFILE_CONTEXT_TRACE1( aLog, "framework (cd100003) ::ToolBarManager::FillToolbar %s", aTbxName.getStr() );
1198 : :
1199 [ + - ]: 2548 : ResetableGuard aGuard( m_aLock );
1200 : :
1201 [ - + ]: 2548 : if ( m_bDisposed )
1202 : 2548 : return;
1203 : :
1204 : 2548 : sal_uInt16 nId( 1 );
1205 : :
1206 : : Reference< XModuleManager > xModuleManager( Reference< XModuleManager >(
1207 [ + - ][ + - ]: 2548 : m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY ));
[ + - ][ + - ]
1208 [ + - ]: 2548 : if ( !m_xDocImageManager.is() )
1209 : : {
1210 [ + - ]: 2548 : Reference< XModel > xModel( GetModelFromFrame() );
1211 [ + + ]: 2548 : if ( xModel.is() )
1212 : : {
1213 [ + - ]: 2546 : Reference< XUIConfigurationManagerSupplier > xSupplier( xModel, UNO_QUERY );
1214 [ + + ]: 2546 : if ( xSupplier.is() )
1215 : : {
1216 [ + - ][ + - ]: 2444 : m_xDocUICfgMgr.set( xSupplier->getUIConfigurationManager(), UNO_QUERY );
[ + - ]
1217 [ + - ][ + - ]: 2444 : m_xDocImageManager = Reference< XImageManager >( m_xDocUICfgMgr->getImageManager(), UNO_QUERY );
[ + - ][ + - ]
1218 [ + - ]: 2444 : m_xDocImageManager->addConfigurationListener(
1219 : : Reference< XUIConfigurationListener >(
1220 [ + - ][ + - ]: 2444 : static_cast< OWeakObject* >( this ), UNO_QUERY ));
1221 : 2546 : }
1222 : 2548 : }
1223 : : }
1224 : :
1225 : : try
1226 : : {
1227 [ + - ]: 2548 : if ( xModuleManager.is() )
1228 [ + - ][ + - ]: 2548 : m_aModuleIdentifier = xModuleManager->identify( Reference< XInterface >( m_xFrame, UNO_QUERY ) );
[ + - ][ # # ]
1229 : : }
1230 [ # # ]: 0 : catch (const Exception&)
1231 : : {
1232 : : }
1233 : :
1234 [ + - ]: 2548 : if ( !m_xModuleImageManager.is() )
1235 : : {
1236 [ + - ]: 2548 : Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier( m_xServiceManager->createInstance(
1237 : 2548 : SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ),
1238 [ + - ][ + - ]: 2548 : UNO_QUERY );
[ + - ]
1239 [ + - ][ + - ]: 2548 : m_xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier );
[ + - ]
1240 [ + - ][ + - ]: 2548 : m_xModuleImageManager = Reference< XImageManager >( m_xUICfgMgr->getImageManager(), UNO_QUERY );
[ + - ][ + - ]
1241 [ + - ]: 2548 : m_xModuleImageManager->addConfigurationListener( Reference< XUIConfigurationListener >(
1242 [ + - ][ + - ]: 2548 : static_cast< OWeakObject* >( this ), UNO_QUERY ));
1243 : : }
1244 : :
1245 [ + - ]: 2548 : RemoveControllers();
1246 : :
1247 : : // reset and fill command map
1248 [ + - ]: 2548 : m_pToolBar->Clear();
1249 [ + - ]: 2548 : m_aControllerMap.clear();
1250 [ + - ]: 2548 : m_aCommandMap.clear();
1251 : :
1252 [ + - ]: 2548 : m_aMenuMap.clear();
1253 : :
1254 [ + - ]: 2548 : CommandInfo aCmdInfo;
1255 [ + - ][ + - ]: 95921 : for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ )
[ + + ]
1256 : : {
1257 [ + - ]: 93373 : Sequence< PropertyValue > aProp;
1258 : 93373 : rtl::OUString aCommandURL;
1259 : 93373 : rtl::OUString aLabel;
1260 : 93373 : rtl::OUString aHelpURL;
1261 : 93373 : rtl::OUString aTooltip;
1262 : 93373 : sal_uInt16 nType( ::com::sun::star::ui::ItemType::DEFAULT );
1263 : 93373 : sal_uInt16 nWidth( 0 );
1264 : 93373 : sal_Bool bIsVisible( sal_True );
1265 : 93373 : sal_uInt32 nStyle( 0 );
1266 : :
1267 : 93373 : Reference< XIndexAccess > aMenuDesc;
1268 : : try
1269 : : {
1270 [ + - ][ + - ]: 93373 : if ( rItemContainer->getByIndex( n ) >>= aProp )
[ + - ][ + - ]
1271 : : {
1272 [ + + ]: 639069 : for ( int i = 0; i < aProp.getLength(); i++ )
1273 : : {
1274 [ + - ][ + + ]: 545696 : if ( aProp[i].Name == ITEM_DESCRIPTOR_COMMANDURL )
1275 : : {
1276 [ + - ]: 93373 : aProp[i].Value >>= aCommandURL;
1277 [ - + ]: 93373 : if ( aCommandURL.compareToAscii(MENUPREFIX, RTL_CONSTASCII_LENGTH(MENUPREFIX) ) == 0 )
1278 : : {
1279 : : try
1280 : : {
1281 : 0 : Reference< XIndexAccess > xMenuContainer;
1282 [ # # ]: 0 : if ( m_xDocUICfgMgr.is() )
1283 [ # # ][ # # ]: 0 : xMenuContainer = m_xDocUICfgMgr->getSettings( aCommandURL, sal_False );
[ # # ]
1284 [ # # ][ # # ]: 0 : if ( !xMenuContainer.is() && m_xUICfgMgr.is() )
[ # # ]
1285 [ # # ][ # # ]: 0 : xMenuContainer = m_xUICfgMgr->getSettings( aCommandURL, sal_False );
[ # # ]
1286 [ # # ][ # # ]: 0 : if ( xMenuContainer.is() && xMenuContainer->getCount() )
[ # # ][ # # ]
[ # # ]
1287 : : {
1288 [ # # ]: 0 : Sequence< PropertyValue > aProps;
1289 : : // drop down menu info is currently
1290 : : // the first ( and only ) menu
1291 : : // in the menusettings container
1292 [ # # ][ # # ]: 0 : xMenuContainer->getByIndex(0) >>= aProps;
[ # # ]
1293 [ # # ]: 0 : for ( sal_Int32 index=0; index<aProps.getLength(); ++index )
1294 : : {
1295 [ # # ][ # # ]: 0 : if ( aProps[ index ].Name == ITEM_DESCRIPTOR_CONTAINER )
1296 : :
1297 : : {
1298 [ # # ][ # # ]: 0 : aProps[ index ].Value >>= aMenuDesc;
1299 : 0 : break;
1300 : : }
1301 [ # # ]: 0 : }
1302 [ # # ]: 0 : }
1303 : : }
1304 [ # # ]: 0 : catch (const Exception&)
1305 : : {
1306 : : }
1307 : : }
1308 : : }
1309 [ + - ][ + + ]: 452323 : else if ( aProp[i].Name == ITEM_DESCRIPTOR_HELPURL )
1310 [ + - ]: 71790 : aProp[i].Value >>= aHelpURL;
1311 [ + - ][ + + ]: 380533 : else if ( aProp[i].Name == ITEM_DESCRIPTOR_TOOLTIP )
1312 [ + - ]: 71790 : aProp[i].Value >>= aTooltip;
1313 [ + - ][ + + ]: 308743 : else if ( aProp[i].Name == ITEM_DESCRIPTOR_LABEL )
1314 [ + - ]: 71790 : aProp[i].Value >>= aLabel;
1315 [ + - ][ + + ]: 236953 : else if ( aProp[i].Name == ITEM_DESCRIPTOR_TYPE )
1316 [ + - ]: 93373 : aProp[i].Value >>= nType;
1317 [ + - ][ + + ]: 143580 : else if ( aProp[i].Name == ITEM_DESCRIPTOR_VISIBLE )
1318 [ + - ]: 71790 : aProp[i].Value >>= bIsVisible;
1319 [ + - ][ - + ]: 71790 : else if ( aProp[i].Name == ITEM_DESCRIPTOR_WIDTH )
1320 [ # # ]: 0 : aProp[i].Value >>= nWidth;
1321 [ + - ][ + - ]: 71790 : else if ( aProp[i].Name == ITEM_DESCRIPTOR_STYLE )
1322 [ + - ]: 71790 : aProp[i].Value >>= nStyle;
1323 : : }
1324 : :
1325 [ + + ][ + - ]: 93373 : if (( nType == ::com::sun::star::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() )
[ + + ]
1326 : : {
1327 [ + - ]: 71790 : ::rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL ));
1328 : :
1329 : 71790 : sal_uInt16 nItemBits = ConvertStyleToToolboxItemBits( nStyle );
1330 [ - + ]: 71790 : if ( aMenuDesc.is() )
1331 [ # # ][ # # ]: 0 : m_aMenuMap[ nId ] = aMenuDesc;
1332 [ + - ][ + - ]: 71790 : m_pToolBar->InsertItem( nId, aString, nItemBits );
[ + - ]
1333 [ + - ][ + - ]: 71790 : m_pToolBar->SetItemCommand( nId, aCommandURL );
[ + - ]
1334 [ - + ]: 71790 : if ( !aTooltip.isEmpty() )
1335 : : {
1336 [ # # ][ # # ]: 0 : m_pToolBar->SetQuickHelpText( nId, aTooltip );
[ # # ]
1337 : : }
1338 : : else
1339 : : {
1340 : 71790 : ::rtl::OUString sQuickHelp( aString );
1341 : 71790 : ::rtl::OUString sShortCut;
1342 [ - + ][ + - ]: 71790 : if( RetrieveShortcut( aCommandURL, sShortCut ) )
1343 : : {
1344 : 0 : sQuickHelp += rtl::OUString( " (" );
1345 : 0 : sQuickHelp += sShortCut;
1346 : 0 : sQuickHelp += rtl::OUString( ")" );
1347 : : }
1348 : :
1349 [ + - ][ + - ]: 71790 : m_pToolBar->SetQuickHelpText( nId, sQuickHelp );
[ + - ]
1350 : : }
1351 : :
1352 [ - + ]: 71790 : if ( !aLabel.isEmpty() )
1353 : : {
1354 [ # # ][ # # ]: 0 : m_pToolBar->SetItemText( nId, aLabel );
[ # # ]
1355 : : }
1356 : : else
1357 : : {
1358 [ + - ][ + - ]: 71790 : m_pToolBar->SetItemText( nId, aString );
[ + - ]
1359 : : }
1360 [ + - ]: 71790 : m_pToolBar->EnableItem( nId, sal_True );
1361 [ + - ]: 71790 : m_pToolBar->SetItemState( nId, STATE_NOCHECK );
1362 : :
1363 : : // Fill command map. It stores all our commands and from what
1364 : : // image manager we got our image. So we can decide if we have to use an
1365 : : // image from a notification message.
1366 [ + - ]: 71790 : CommandToInfoMap::iterator pIter = m_aCommandMap.find( aCommandURL );
1367 [ + - ]: 71790 : if ( pIter == m_aCommandMap.end())
1368 : : {
1369 : 71790 : aCmdInfo.nId = nId;
1370 : 71790 : aCmdInfo.nWidth = nWidth;
1371 [ + - ]: 71790 : const CommandToInfoMap::value_type aValue( aCommandURL, aCmdInfo );
1372 [ + - ]: 71790 : m_aCommandMap.insert( aValue );
1373 : : }
1374 : : else
1375 : : {
1376 [ # # ][ # # ]: 0 : pIter->second.aIds.push_back( nId );
1377 : : }
1378 : :
1379 [ + + ]: 71790 : if ( !bIsVisible )
1380 [ + - ]: 18650 : m_pToolBar->HideItem( nId );
1381 : :
1382 [ # # ]: 71790 : ++nId;
1383 : : }
1384 [ + + ]: 21583 : else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_LINE )
1385 : : {
1386 [ + - ]: 21579 : m_pToolBar->InsertSeparator();
1387 : : }
1388 [ - + ]: 4 : else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_SPACE )
1389 : : {
1390 [ # # ]: 0 : m_pToolBar->InsertSpace();
1391 : : }
1392 [ + - ]: 4 : else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_LINEBREAK )
1393 : : {
1394 [ + - ]: 93373 : m_pToolBar->InsertBreak();
1395 : : }
1396 : : }
1397 : : }
1398 [ # # ]: 0 : catch (const ::com::sun::star::lang::IndexOutOfBoundsException&)
1399 : : {
1400 : : break;
1401 : : }
1402 [ - + ][ - + ]: 93373 : }
[ - + ][ - + ]
[ - + ][ + - ]
[ + - ]
1403 : :
1404 : : // Support add-on toolbar merging here. Working directly on the toolbar object is much
1405 : : // simpler and faster.
1406 : 2548 : const sal_uInt16 TOOLBAR_ITEM_STARTID = 1000;
1407 : :
1408 [ + - ]: 2548 : MergeToolbarInstructionContainer aMergeInstructionContainer;
1409 : :
1410 : : // Retrieve the toolbar name from the resource name
1411 : 2548 : ::rtl::OUString aToolbarName( m_aResourceName );
1412 : 2548 : sal_Int32 nIndex = aToolbarName.lastIndexOf( '/' );
1413 [ + - ][ + - ]: 2548 : if (( nIndex > 0 ) && ( nIndex < aToolbarName.getLength() ))
[ + - ]
1414 : 2548 : aToolbarName = aToolbarName.copy( nIndex+1 );
1415 : :
1416 [ + - ][ + - ]: 2548 : AddonsOptions().GetMergeToolbarInstructions( aToolbarName, aMergeInstructionContainer );
[ + - ]
1417 : :
1418 [ - + ]: 2548 : if ( !aMergeInstructionContainer.empty() )
1419 : : {
1420 : 0 : sal_uInt16 nItemId( TOOLBAR_ITEM_STARTID );
1421 : 0 : const sal_uInt32 nCount = aMergeInstructionContainer.size();
1422 [ # # ]: 0 : for ( sal_uInt32 i=0; i < nCount; i++ )
1423 : : {
1424 [ # # ]: 0 : MergeToolbarInstruction& rInstruction = aMergeInstructionContainer[i];
1425 [ # # ][ # # ]: 0 : if ( ToolBarMerger::IsCorrectContext( rInstruction.aMergeContext, m_aModuleIdentifier ))
1426 : : {
1427 [ # # ]: 0 : ReferenceToolbarPathInfo aRefPoint = ToolBarMerger::FindReferencePoint( m_pToolBar, rInstruction.aMergePoint );
1428 : :
1429 : : // convert the sequence< sequence< propertyvalue > > structure to
1430 : : // something we can better handle. A vector with item data
1431 [ # # ]: 0 : AddonToolbarItemContainer aItems;
1432 [ # # ][ # # ]: 0 : ToolBarMerger::ConvertSeqSeqToVector( rInstruction.aMergeToolbarItems, aItems );
[ # # ]
1433 : :
1434 [ # # ]: 0 : if ( aRefPoint.bResult )
1435 : : {
1436 : : ToolBarMerger::ProcessMergeOperation( m_xFrame,
1437 : : m_pToolBar,
1438 : : aRefPoint.nPos,
1439 : : nItemId,
1440 : : m_aCommandMap,
1441 : : m_aModuleIdentifier,
1442 : : rInstruction.aMergeCommand,
1443 : : rInstruction.aMergeCommandParameter,
1444 [ # # ]: 0 : aItems );
1445 : : }
1446 : : else
1447 : : {
1448 : : ToolBarMerger::ProcessMergeFallback( m_xFrame,
1449 : : m_pToolBar,
1450 : : aRefPoint.nPos,
1451 : : nItemId,
1452 : : m_aCommandMap,
1453 : : m_aModuleIdentifier,
1454 : : rInstruction.aMergeCommand,
1455 : : rInstruction.aMergeFallback,
1456 [ # # ]: 0 : aItems );
1457 : 0 : }
1458 : : }
1459 : : }
1460 : : }
1461 : :
1462 : : // Request images for all toolbar items. Must be done before CreateControllers as
1463 : : // some controllers need access to the image.
1464 [ + - ]: 2548 : RequestImages();
1465 : :
1466 : : // Create controllers after we set the images. There are controllers which needs
1467 : : // an image at the toolbar at creation time!
1468 [ + - ]: 2548 : CreateControllers();
1469 : :
1470 : : // Notify controllers that they are now correctly initialized and can start listening
1471 : : // toolbars that will open in popup mode will be updated immediately to avoid flickering
1472 [ + - ][ - + ]: 2548 : if( m_pToolBar->WillUsePopupMode() )
1473 [ # # ]: 0 : UpdateControllers();
1474 [ + - ][ - + ]: 2548 : else if ( m_pToolBar->IsReallyVisible() )
1475 [ # # ]: 0 : m_aAsyncUpdateControllersTimer.Start();
1476 : :
1477 : : // Try to retrieve UIName from the container property set and set it as the title
1478 : : // if it is not empty.
1479 [ + - ]: 2548 : Reference< XPropertySet > xPropSet( rItemContainer, UNO_QUERY );
1480 [ + - ]: 2548 : if ( xPropSet.is() )
1481 : : {
1482 : : try
1483 : : {
1484 : 2548 : rtl::OUString aUIName;
1485 [ + - ][ + - ]: 2548 : xPropSet->getPropertyValue( rtl::OUString( "UIName" )) >>= aUIName;
1486 [ - + ]: 2548 : if ( !aUIName.isEmpty() )
1487 [ # # ][ # # ]: 2548 : m_pToolBar->SetText( aUIName );
[ # # ][ # # ]
1488 : : }
1489 [ # # ]: 0 : catch (const Exception&)
1490 : : {
1491 : : }
1492 [ + - ][ - + ]: 2548 : }
[ + - ]
1493 : : }
1494 : :
1495 : 2548 : void ToolBarManager::RequestImages()
1496 : : {
1497 : : RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ToolBarManager::RequestImages" );
1498 : :
1499 : : // Request images from image manager
1500 [ + - ]: 2548 : Sequence< rtl::OUString > aCmdURLSeq( m_aCommandMap.size() );
1501 [ + - ]: 2548 : Sequence< Reference< XGraphic > > aDocGraphicSeq;
1502 [ + - ]: 2548 : Sequence< Reference< XGraphic > > aModGraphicSeq;
1503 : :
1504 : 2548 : sal_uInt32 i = 0;
1505 [ + - ]: 2548 : CommandToInfoMap::iterator pIter = m_aCommandMap.begin();
1506 : 2548 : CommandToInfoMap::iterator pEnd = m_aCommandMap.end();
1507 [ + + ]: 74338 : while ( pIter != pEnd )
1508 : : {
1509 [ + - ][ + - ]: 71790 : aCmdURLSeq[i++] = pIter->first;
1510 : 71790 : ++pIter;
1511 : : }
1512 : :
1513 [ + - ][ + - ]: 2548 : sal_Bool bBigImages( SvtMiscOptions().AreCurrentSymbolsLarge() );
[ + - ]
1514 [ + - ][ + - ]: 2548 : sal_Int16 p = getImageTypeFromBools( SvtMiscOptions().AreCurrentSymbolsLarge() );
[ + - ]
1515 : :
1516 [ + + ]: 2548 : if ( m_xDocImageManager.is() )
1517 [ + - ][ + - ]: 2444 : aDocGraphicSeq = m_xDocImageManager->getImages( p, aCmdURLSeq );
[ + - ][ + - ]
1518 [ + - ][ + - ]: 2548 : aModGraphicSeq = m_xModuleImageManager->getImages( p, aCmdURLSeq );
[ + - ][ + - ]
1519 : :
1520 : 2548 : i = 0;
1521 [ + - ]: 2548 : pIter = m_aCommandMap.begin();
1522 [ + + ]: 74338 : while ( pIter != pEnd )
1523 : : {
1524 [ + - ]: 71790 : rtl::OUString aCommandURL = aCmdURLSeq[i];
1525 : :
1526 [ + - ]: 71790 : Image aImage;
1527 [ + + ]: 71790 : if ( aDocGraphicSeq.getLength() > 0 )
1528 [ + - ][ + - ]: 70526 : aImage = Image( aDocGraphicSeq[i] );
[ + - ][ + - ]
1529 [ + - ]: 71790 : if ( !aImage )
1530 : : {
1531 [ + - ][ + - ]: 71790 : aImage = Image( aModGraphicSeq[i] );
[ + - ][ + - ]
1532 : : // Try also to query for add-on images before giving up and use an
1533 : : // empty image.
1534 [ + + ]: 71790 : if ( !aImage )
1535 [ + - ][ + - ]: 1275 : aImage = QueryAddonsImage( aCmdURLSeq[i], bBigImages );
[ + - ][ + - ]
1536 : :
1537 [ + - ]: 71790 : pIter->second.nImageInfo = 1; // mark image as module based
1538 : : }
1539 : : else
1540 : : {
1541 [ # # ]: 0 : pIter->second.nImageInfo = 0; // mark image as document based
1542 : : }
1543 [ + - ]: 71790 : setToolBarImage(aImage,pIter);
1544 : 71790 : ++pIter;
1545 : 71790 : ++i;
1546 [ + - ][ + - ]: 74338 : }
[ + - ][ + - ]
1547 : 2548 : }
1548 : :
1549 : 4 : void ToolBarManager::notifyRegisteredControllers( const rtl::OUString& aUIElementName, const rtl::OUString& aCommand )
1550 : : {
1551 [ + - ]: 4 : ResetableGuard aGuard( m_aLock );
1552 [ - + ]: 4 : if ( !m_aSubToolBarControllerMap.empty() )
1553 : : {
1554 : : SubToolBarToSubToolBarControllerMap::const_iterator pIter =
1555 [ # # ]: 0 : m_aSubToolBarControllerMap.find( aUIElementName );
1556 : :
1557 [ # # ][ # # ]: 0 : if ( pIter != m_aSubToolBarControllerMap.end() )
1558 : : {
1559 [ # # ]: 0 : const SubToolBarControllerVector& rSubToolBarVector = pIter->second;
1560 [ # # ]: 0 : if ( !rSubToolBarVector.empty() )
1561 : : {
1562 [ # # ]: 0 : SubToolBarControllerVector aNotifyVector = rSubToolBarVector;
1563 [ # # ]: 0 : aGuard.unlock();
1564 : :
1565 : 0 : const sal_uInt32 nCount = aNotifyVector.size();
1566 [ # # ]: 0 : for ( sal_uInt32 i=0; i < nCount; i++ )
1567 : : {
1568 : : try
1569 : : {
1570 : 0 : Reference< XSubToolbarController > xController = aNotifyVector[i];
1571 [ # # ]: 0 : if ( xController.is() )
1572 [ # # ][ # # ]: 0 : xController->functionSelected( aCommand );
1573 : : }
1574 [ # # # ]: 0 : catch (const RuntimeException&)
1575 : : {
1576 : 0 : throw;
1577 : : }
1578 [ # # ]: 0 : catch (const Exception&)
1579 : : {
1580 : : }
1581 : 0 : }
1582 : : }
1583 : : }
1584 [ + - ]: 4 : }
1585 : 4 : }
1586 : 2 : long ToolBarManager::HandleClick(void ( SAL_CALL XToolbarController::*_pClick )())
1587 : : {
1588 [ + - ]: 2 : ResetableGuard aGuard( m_aLock );
1589 : :
1590 [ - + ]: 2 : if ( m_bDisposed )
1591 : 0 : return 1;
1592 : :
1593 : 2 : sal_uInt16 nId( m_pToolBar->GetCurItemId() );
1594 [ + - ]: 2 : ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
1595 [ + - ][ + - ]: 2 : if ( pIter != m_aControllerMap.end() )
1596 : : {
1597 [ + - ][ + - ]: 2 : Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
1598 : :
1599 [ + - ]: 2 : if ( xController.is() )
1600 [ + - ][ - + ]: 2 : (xController.get()->*_pClick)( );
[ + - ]
1601 : : } // if ( pIter != m_aControllerMap.end() )
1602 [ + - ]: 2 : return 1;
1603 : : }
1604 : :
1605 : 2 : IMPL_LINK_NOARG(ToolBarManager, Click)
1606 : : {
1607 : 2 : return HandleClick(&XToolbarController::click);
1608 : : }
1609 : :
1610 : 0 : IMPL_LINK_NOARG(ToolBarManager, DropdownClick)
1611 : : {
1612 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
1613 : :
1614 [ # # ]: 0 : if ( m_bDisposed )
1615 : 0 : return 1;
1616 : :
1617 : 0 : sal_uInt16 nId( m_pToolBar->GetCurItemId() );
1618 [ # # ]: 0 : ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
1619 [ # # ][ # # ]: 0 : if ( pIter != m_aControllerMap.end() )
1620 : : {
1621 [ # # ][ # # ]: 0 : Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
1622 : :
1623 [ # # ]: 0 : if ( xController.is() )
1624 : : {
1625 [ # # ][ # # ]: 0 : Reference< XWindow > xWin = xController->createPopupWindow();
1626 [ # # ]: 0 : if ( xWin.is() )
1627 [ # # ][ # # ]: 0 : xWin->setFocus();
1628 : 0 : }
1629 : : }
1630 [ # # ]: 0 : return 1;
1631 : : }
1632 : :
1633 : 0 : IMPL_LINK_NOARG(ToolBarManager, DoubleClick)
1634 : : {
1635 : 0 : return HandleClick(&XToolbarController::doubleClick);
1636 : : }
1637 : :
1638 : 3527 : void ToolBarManager::ImplClearPopupMenu( ToolBox *pToolBar )
1639 : : {
1640 [ - + ]: 3527 : if ( m_bDisposed )
1641 : 3527 : return;
1642 : :
1643 : 3527 : PopupMenu *pMenu = pToolBar->GetMenu();
1644 : :
1645 : : // remove config entries from menu, so we have a clean menu to start with
1646 : : // remove submenu first
1647 : 3527 : PopupMenu* pItemMenu = pMenu->GetPopupMenu( 1 );
1648 [ - + ]: 3527 : if( pItemMenu )
1649 : : {
1650 : 0 : pItemMenu->Clear();
1651 [ # # ]: 0 : delete pItemMenu;
1652 : 0 : pItemMenu = NULL;
1653 : 0 : pMenu->SetPopupMenu( 1, pItemMenu );
1654 : : }
1655 : :
1656 : : // remove all items that were not added by the toolbar itself
1657 : : sal_uInt16 i;
1658 [ - + ]: 3527 : for( i=0; i<pMenu->GetItemCount(); )
1659 : : {
1660 [ # # ]: 0 : if( pMenu->GetItemId( i ) < TOOLBOX_MENUITEM_START )
1661 : 0 : pMenu->RemoveItem( i );
1662 : : else
1663 : 0 : i++;
1664 : : }
1665 : : }
1666 : :
1667 : 0 : IMPL_LINK( ToolBarManager, MenuDeactivate, Menu*, pMenu )
1668 : : {
1669 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
1670 : :
1671 [ # # ]: 0 : if ( m_bDisposed )
1672 : 0 : return 1;
1673 : :
1674 [ # # ][ # # ]: 0 : if( pMenu != m_pToolBar->GetMenu() )
1675 : 0 : return 1;
1676 : :
1677 [ # # ]: 0 : ImplClearPopupMenu( m_pToolBar );
1678 : :
1679 [ # # ]: 0 : return 0;
1680 : : }
1681 : :
1682 : 2548 : Reference< XModel > ToolBarManager::GetModelFromFrame() const
1683 : : {
1684 [ + - ][ + - ]: 2548 : Reference< XController > xController = m_xFrame->getController();
1685 : 2548 : Reference< XModel > xModel;
1686 [ + - ]: 2548 : if ( xController.is() )
1687 [ + - ][ + - ]: 2548 : xModel = xController->getModel();
[ + - ]
1688 : :
1689 : 2548 : return xModel;
1690 : : }
1691 : :
1692 : 0 : sal_Bool ToolBarManager::IsPluginMode() const
1693 : : {
1694 : 0 : sal_Bool bPluginMode( sal_False );
1695 : :
1696 [ # # ]: 0 : if ( m_xFrame.is() )
1697 : : {
1698 [ # # ]: 0 : Reference< XModel > xModel = GetModelFromFrame();
1699 [ # # ]: 0 : if ( xModel.is() )
1700 : : {
1701 [ # # ][ # # ]: 0 : Sequence< PropertyValue > aSeq = xModel->getArgs();
1702 [ # # ]: 0 : comphelper::MediaDescriptor aMediaDescriptor( aSeq );
1703 : : bPluginMode = aMediaDescriptor.getUnpackedValueOrDefault< sal_Bool >(
1704 [ # # ][ # # ]: 0 : comphelper::MediaDescriptor::PROP_VIEWONLY(), sal_False );
[ # # ][ # # ]
1705 : 0 : }
1706 : : }
1707 : :
1708 : 0 : return bPluginMode;
1709 : : }
1710 : :
1711 : 0 : bool ToolBarManager::MenuItemAllowed( sal_uInt16 ) const
1712 : : {
1713 : 0 : return true;
1714 : : }
1715 : :
1716 : 0 : PopupMenu * ToolBarManager::GetToolBarCustomMenu(ToolBox* pToolBar)
1717 : : {
1718 : : // update the list of hidden tool items first
1719 [ # # ]: 0 : pToolBar->UpdateCustomMenu();
1720 : :
1721 [ # # ]: 0 : PopupMenu *pMenu = pToolBar->GetMenu();
1722 : : // remove all entries before inserting new ones
1723 [ # # ]: 0 : ImplClearPopupMenu( pToolBar );
1724 : : // No config menu entries if command ".uno:ConfigureDialog" is not enabled
1725 : 0 : Reference< XDispatch > xDisp;
1726 : 0 : com::sun::star::util::URL aURL;
1727 [ # # ]: 0 : if ( m_xFrame.is() )
1728 : : {
1729 [ # # ]: 0 : Reference< XDispatchProvider > xProv( m_xFrame, UNO_QUERY );
1730 : 0 : aURL.Complete = ::rtl::OUString( ".uno:ConfigureDialog" );
1731 [ # # ][ # # ]: 0 : m_xURLTransformer->parseStrict( aURL );
1732 [ # # ]: 0 : if ( xProv.is() )
1733 [ # # ][ # # ]: 0 : xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 );
[ # # ]
1734 : :
1735 [ # # ][ # # ]: 0 : if ( !xDisp.is() || IsPluginMode() )
[ # # ][ # # ]
1736 [ # # ]: 0 : return 0;
1737 : : }
1738 : :
1739 : : // popup menu for quick customization
1740 [ # # ][ # # ]: 0 : sal_Bool bHideDisabledEntries = !SvtMenuOptions().IsEntryHidingEnabled();
[ # # ]
1741 [ # # ][ # # ]: 0 : PopupMenu aPopupMenu( FwkResId( POPUPMENU_TOOLBAR_QUICKCUSTOMIZATION ));
1742 : :
1743 [ # # ]: 0 : if ( m_pToolBar->IsCustomize() )
1744 : : {
1745 : 0 : sal_uInt16 nPos( 0 );
1746 [ # # ]: 0 : PopupMenu* pItemMenu( aPopupMenu.GetPopupMenu( 1 ));
1747 : :
1748 : 0 : sal_Bool bIsFloating( sal_False );
1749 : :
1750 [ # # ]: 0 : DockingManager* pDockMgr = Window::GetDockingManager();
1751 [ # # ]: 0 : if ( pDockMgr )
1752 [ # # ]: 0 : bIsFloating = pDockMgr->IsFloating( m_pToolBar );
1753 : :
1754 [ # # ]: 0 : if ( !bIsFloating )
1755 : : {
1756 [ # # ]: 0 : aPopupMenu.EnableItem( MENUITEM_TOOLBAR_DOCKTOOLBAR, sal_False );
1757 [ # # ]: 0 : aPopupMenu.EnableItem( MENUITEM_TOOLBAR_DOCKALLTOOLBAR, sal_False );
1758 [ # # ][ # # ]: 0 : Reference< XDockableWindow > xDockable( VCLUnoHelper::GetInterface( m_pToolBar ), UNO_QUERY );
1759 [ # # ]: 0 : if( xDockable.is() )
1760 [ # # ][ # # ]: 0 : aPopupMenu.CheckItem( MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION, xDockable->isLocked() );
[ # # ]
1761 : : }
1762 : : else
1763 [ # # ]: 0 : aPopupMenu.EnableItem( MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION, sal_False );
1764 : :
1765 [ # # ][ # # ]: 0 : if ( SvtMiscOptions().DisableUICustomization() )
[ # # ][ # # ]
1766 : : {
1767 [ # # ]: 0 : aPopupMenu.EnableItem( MENUITEM_TOOLBAR_VISIBLEBUTTON, sal_False );
1768 [ # # ]: 0 : aPopupMenu.EnableItem( MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR, sal_False );
1769 [ # # ]: 0 : aPopupMenu.EnableItem( MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION, sal_False );
1770 : : }
1771 : :
1772 : : // Disable menu item CLOSE if the toolbar has no closer
1773 [ # # ][ # # ]: 0 : if( !(pToolBar->GetFloatStyle() & WB_CLOSEABLE) )
1774 [ # # ]: 0 : aPopupMenu.EnableItem(MENUITEM_TOOLBAR_CLOSE, sal_False);
1775 : :
1776 [ # # ][ # # ]: 0 : for ( nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
1777 : : {
1778 [ # # ][ # # ]: 0 : if ( m_pToolBar->GetItemType(nPos) == TOOLBOXITEM_BUTTON )
1779 : : {
1780 [ # # ]: 0 : sal_uInt16 nId = m_pToolBar->GetItemId(nPos);
1781 [ # # ][ # # ]: 0 : ::rtl::OUString aCommandURL = m_pToolBar->GetItemCommand( nId );
1782 [ # # ][ # # ]: 0 : pItemMenu->InsertItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->GetItemText( nId ), MIB_CHECKABLE );
1783 [ # # ][ # # ]: 0 : pItemMenu->CheckItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->IsItemVisible( nId ) );
1784 [ # # ][ # # ]: 0 : pItemMenu->SetItemCommand( STARTID_CUSTOMIZE_POPUPMENU+nPos, aCommandURL );
[ # # ]
1785 : : pItemMenu->SetItemImage( STARTID_CUSTOMIZE_POPUPMENU+nPos,
1786 : : GetImageFromURL( m_xFrame, aCommandURL, sal_False )
1787 [ # # ][ # # ]: 0 : );
[ # # ]
1788 : : }
1789 : : else
1790 : : {
1791 [ # # ]: 0 : pItemMenu->InsertSeparator();
1792 : : }
1793 : : }
1794 : : }
1795 : : else
1796 : : {
1797 [ # # ]: 0 : sal_uInt16 nPos = aPopupMenu.GetItemPos( MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR );
1798 [ # # ]: 0 : if ( nPos != MENU_ITEM_NOTFOUND )
1799 [ # # ]: 0 : aPopupMenu.RemoveItem( nPos );
1800 : : }
1801 : :
1802 : : // copy all menu items to the toolbar menu
1803 [ # # ][ # # ]: 0 : if( pMenu->GetItemCount() )
1804 [ # # ]: 0 : pMenu->InsertSeparator();
1805 : :
1806 : : sal_uInt16 i;
1807 [ # # ][ # # ]: 0 : for( i=0; i< aPopupMenu.GetItemCount(); i++)
1808 : : {
1809 [ # # ]: 0 : sal_uInt16 nId = aPopupMenu.GetItemId( i );
1810 [ # # ][ # # ]: 0 : if ( MenuItemAllowed( nId ))
1811 [ # # ]: 0 : pMenu->CopyItem( aPopupMenu, i, MENU_APPEND );
1812 : : }
1813 : :
1814 : : // set submenu to toolbar menu
1815 [ # # ][ # # ]: 0 : if( aPopupMenu.GetPopupMenu( 1 ) )
1816 : : {
1817 : : // create an own submenu to avoid auto-delete when resource menu is deleted
1818 [ # # ][ # # ]: 0 : PopupMenu *pItemMenu = new PopupMenu();
1819 : :
1820 [ # # ][ # # ]: 0 : for( i=0; i< aPopupMenu.GetPopupMenu( 1 )->GetItemCount(); i++)
[ # # ]
1821 [ # # ][ # # ]: 0 : pItemMenu->CopyItem( *aPopupMenu.GetPopupMenu( 1 ), i, MENU_APPEND );
1822 : :
1823 [ # # ]: 0 : pMenu->SetPopupMenu( 1, pItemMenu );
1824 : : }
1825 : :
1826 [ # # ]: 0 : if ( bHideDisabledEntries )
1827 [ # # ]: 0 : pMenu->RemoveDisabledEntries();
1828 : :
1829 [ # # ]: 0 : return pMenu;
1830 : : }
1831 : :
1832 : 0 : IMPL_LINK( ToolBarManager, Command, CommandEvent*, pCmdEvt )
1833 : : {
1834 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
1835 : :
1836 [ # # ]: 0 : if ( m_bDisposed )
1837 : 0 : return 1;
1838 [ # # ]: 0 : if ( pCmdEvt->GetCommand() != COMMAND_CONTEXTMENU )
1839 : 0 : return 0;
1840 : :
1841 [ # # ]: 0 : PopupMenu * pMenu = GetToolBarCustomMenu(m_pToolBar);
1842 [ # # ]: 0 : if (pMenu)
1843 : : {
1844 : : // make sure all disabled entries will be shown
1845 : 0 : pMenu->SetMenuFlags( pMenu->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
1846 : 0 : ::Point aPoint( pCmdEvt->GetMousePosPixel() );
1847 [ # # ]: 0 : pMenu->Execute( m_pToolBar, aPoint );
1848 : : }
1849 : :
1850 [ # # ]: 0 : return 0;
1851 : : }
1852 : :
1853 : 0 : IMPL_LINK( ToolBarManager, MenuButton, ToolBox*, pToolBar )
1854 : : {
1855 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
1856 : :
1857 [ # # ]: 0 : if ( m_bDisposed )
1858 : 0 : return 1;
1859 : :
1860 [ # # ]: 0 : pToolBar->UpdateCustomMenu();
1861 : : // remove all entries that do not come from the toolbar itself (fdo#38276)
1862 [ # # ]: 0 : ImplClearPopupMenu( pToolBar );
1863 : :
1864 [ # # ]: 0 : return 0;
1865 : : }
1866 : :
1867 : 0 : IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu )
1868 : : {
1869 : : // We have to hold a reference to ourself as it is possible that we will be disposed and
1870 : : // our refcount could be zero (destruction) otherwise.
1871 [ # # ]: 0 : Reference< XInterface > xInterface( static_cast< OWeakObject* >( this ), UNO_QUERY );
1872 : :
1873 : : {
1874 : : // The guard must be in its own context as the we can get destroyed when our
1875 : : // own xInterface reference get destroyed!
1876 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
1877 : :
1878 [ # # ]: 0 : if ( m_bDisposed )
1879 : 0 : return 1;
1880 : :
1881 [ # # ][ # # : 0 : switch ( pMenu->GetCurItemId() )
# # # # ]
1882 : : {
1883 : : case MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR:
1884 : : {
1885 : 0 : Reference< XDispatch > xDisp;
1886 : 0 : com::sun::star::util::URL aURL;
1887 [ # # ]: 0 : if ( m_xFrame.is() )
1888 : : {
1889 [ # # ]: 0 : Reference< XDispatchProvider > xProv( m_xFrame, UNO_QUERY );
1890 : 0 : aURL.Complete = ::rtl::OUString( ".uno:ConfigureDialog" );
1891 [ # # ][ # # ]: 0 : m_xURLTransformer->parseStrict( aURL );
1892 [ # # ]: 0 : if ( xProv.is() )
1893 [ # # ][ # # ]: 0 : xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 );
[ # # ]
1894 : : }
1895 : :
1896 [ # # ]: 0 : if ( xDisp.is() )
1897 : : {
1898 [ # # ]: 0 : Sequence< PropertyValue > aPropSeq( 1 );
1899 : :
1900 [ # # ]: 0 : aPropSeq[ 0 ].Name =
1901 : 0 : rtl::OUString( "ResourceURL");
1902 [ # # ][ # # ]: 0 : aPropSeq[ 0 ].Value <<= m_aResourceName;
1903 : :
1904 [ # # ][ # # ]: 0 : xDisp->dispatch( aURL, aPropSeq );
[ # # ]
1905 : : }
1906 : 0 : break;
1907 : : }
1908 : :
1909 : : case MENUITEM_TOOLBAR_DOCKTOOLBAR:
1910 : : {
1911 [ # # ][ # # ]: 0 : ExecuteInfo* pExecuteInfo = new ExecuteInfo;
1912 : :
1913 : 0 : pExecuteInfo->aToolbarResName = m_aResourceName;
1914 : 0 : pExecuteInfo->nCmd = EXEC_CMD_DOCKTOOLBAR;
1915 [ # # ][ # # ]: 0 : pExecuteInfo->xLayoutManager = getLayoutManagerFromFrame( m_xFrame );
1916 : :
1917 [ # # ][ # # ]: 0 : Application::PostUserEvent( STATIC_LINK(0, ToolBarManager, ExecuteHdl_Impl), pExecuteInfo );
1918 : 0 : break;
1919 : : }
1920 : :
1921 : : case MENUITEM_TOOLBAR_DOCKALLTOOLBAR:
1922 : : {
1923 [ # # ][ # # ]: 0 : ExecuteInfo* pExecuteInfo = new ExecuteInfo;
1924 : :
1925 : 0 : pExecuteInfo->aToolbarResName = m_aResourceName;
1926 : 0 : pExecuteInfo->nCmd = EXEC_CMD_DOCKALLTOOLBARS;
1927 [ # # ][ # # ]: 0 : pExecuteInfo->xLayoutManager = getLayoutManagerFromFrame( m_xFrame );
1928 : :
1929 [ # # ][ # # ]: 0 : Application::PostUserEvent( STATIC_LINK(0, ToolBarManager, ExecuteHdl_Impl), pExecuteInfo );
1930 : 0 : break;
1931 : : }
1932 : :
1933 : : case MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION:
1934 : : {
1935 [ # # ]: 0 : Reference< XLayoutManager > xLayoutManager = getLayoutManagerFromFrame( m_xFrame );
1936 [ # # ]: 0 : if ( xLayoutManager.is() )
1937 : : {
1938 [ # # ][ # # ]: 0 : Reference< XDockableWindow > xDockable( VCLUnoHelper::GetInterface( m_pToolBar ), UNO_QUERY );
1939 : :
1940 [ # # ][ # # ]: 0 : if( xDockable->isLocked() )
[ # # ]
1941 [ # # ][ # # ]: 0 : xLayoutManager->unlockWindow( m_aResourceName );
1942 : : else
1943 [ # # ][ # # ]: 0 : xLayoutManager->lockWindow( m_aResourceName );
1944 : : }
1945 : 0 : break;
1946 : : }
1947 : :
1948 : : case MENUITEM_TOOLBAR_CLOSE:
1949 : : {
1950 [ # # ][ # # ]: 0 : ExecuteInfo* pExecuteInfo = new ExecuteInfo;
1951 : :
1952 : 0 : pExecuteInfo->aToolbarResName = m_aResourceName;
1953 : 0 : pExecuteInfo->nCmd = EXEC_CMD_CLOSETOOLBAR;
1954 [ # # ][ # # ]: 0 : pExecuteInfo->xLayoutManager = getLayoutManagerFromFrame( m_xFrame );
1955 [ # # ][ # # ]: 0 : pExecuteInfo->xWindow = VCLUnoHelper::GetInterface( m_pToolBar );
1956 : :
1957 [ # # ][ # # ]: 0 : Application::PostUserEvent( STATIC_LINK(0, ToolBarManager, ExecuteHdl_Impl), pExecuteInfo );
1958 : : }
1959 : :
1960 : : default:
1961 : : {
1962 [ # # ]: 0 : sal_uInt16 nId = pMenu->GetCurItemId();
1963 [ # # ][ # # ]: 0 : if(( nId > 0 ) && ( nId < TOOLBOX_MENUITEM_START ))
1964 : : {
1965 : : // toggle toolbar button visibility
1966 [ # # ][ # # ]: 0 : rtl::OUString aCommand = pMenu->GetItemCommand( nId );
1967 : :
1968 [ # # ]: 0 : Reference< XLayoutManager > xLayoutManager = getLayoutManagerFromFrame( m_xFrame );
1969 [ # # ]: 0 : if ( xLayoutManager.is() )
1970 : : {
1971 [ # # ][ # # ]: 0 : Reference< XUIElementSettings > xUIElementSettings( xLayoutManager->getElement( m_aResourceName ), UNO_QUERY );
[ # # ]
1972 [ # # ]: 0 : if ( xUIElementSettings.is() )
1973 : : {
1974 [ # # ][ # # ]: 0 : Reference< XIndexContainer > xItemContainer( xUIElementSettings->getSettings( sal_True ), UNO_QUERY );
[ # # ]
1975 [ # # ][ # # ]: 0 : sal_Int32 nCount = xItemContainer->getCount();
1976 [ # # ]: 0 : for ( sal_Int32 i = 0; i < nCount; i++ )
1977 : : {
1978 [ # # ]: 0 : Sequence< PropertyValue > aProp;
1979 : 0 : sal_Int32 nVisibleIndex( -1 );
1980 : 0 : rtl::OUString aCommandURL;
1981 : 0 : sal_Bool bVisible( sal_False );
1982 : :
1983 [ # # ][ # # ]: 0 : if ( xItemContainer->getByIndex( i ) >>= aProp )
[ # # ][ # # ]
1984 : : {
1985 [ # # ]: 0 : for ( sal_Int32 j = 0; j < aProp.getLength(); j++ )
1986 : : {
1987 [ # # ][ # # ]: 0 : if ( aProp[j].Name == ITEM_DESCRIPTOR_COMMANDURL )
1988 : : {
1989 [ # # ]: 0 : aProp[j].Value >>= aCommandURL;
1990 : : }
1991 [ # # ][ # # ]: 0 : else if ( aProp[j].Name == ITEM_DESCRIPTOR_VISIBLE )
1992 : : {
1993 [ # # ]: 0 : aProp[j].Value >>= bVisible;
1994 : 0 : nVisibleIndex = j;
1995 : : }
1996 : : }
1997 : :
1998 [ # # ][ # # ]: 0 : if (( aCommandURL == aCommand ) && ( nVisibleIndex >= 0 ))
[ # # ]
1999 : : {
2000 : : // We have found the requested item, toggle the visible flag
2001 : : // and write back the configuration settings to the toolbar
2002 [ # # ][ # # ]: 0 : aProp[nVisibleIndex].Value = makeAny( !bVisible );
2003 : : try
2004 : : {
2005 [ # # ][ # # ]: 0 : xItemContainer->replaceByIndex( i, makeAny( aProp ));
[ # # ]
2006 [ # # ][ # # ]: 0 : xUIElementSettings->setSettings( Reference< XIndexAccess >( xItemContainer, UNO_QUERY ));
[ # # ]
2007 [ # # ]: 0 : Reference< XPropertySet > xPropSet( xUIElementSettings, UNO_QUERY );
2008 [ # # ]: 0 : if ( xPropSet.is() )
2009 : : {
2010 : 0 : Reference< XUIConfigurationPersistence > xUICfgMgr;
2011 [ # # ][ # # ]: 0 : if (( xPropSet->getPropertyValue( rtl::OUString( "ConfigurationSource" )) >>= xUICfgMgr ) && ( xUICfgMgr.is() ))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# ][ # # ]
2012 [ # # ][ # # ]: 0 : xUICfgMgr->store();
2013 [ # # ]: 0 : }
2014 : : }
2015 [ # # ]: 0 : catch (const Exception&)
2016 : : {
2017 : : }
2018 : :
2019 : : break;
2020 : : }
2021 : : }
2022 [ # # ][ # # ]: 0 : }
[ # # ]
2023 : 0 : }
2024 : 0 : }
2025 : : }
2026 : 0 : break;
2027 : : }
2028 : : }
2029 : :
2030 : : // remove all entries - deactivate is not reliable
2031 : : // The method checks if we are already disposed and in that case does nothing!
2032 [ # # ][ # # ]: 0 : ImplClearPopupMenu( m_pToolBar );
[ # # ]
2033 : : }
2034 : :
2035 : 0 : return 1;
2036 : : }
2037 : :
2038 : 2 : IMPL_LINK_NOARG(ToolBarManager, Select)
2039 : : {
2040 [ - + ]: 2 : if ( m_bDisposed )
2041 : 0 : return 1;
2042 : :
2043 : 2 : sal_Int16 nKeyModifier( (sal_Int16)m_pToolBar->GetModifier() );
2044 : 2 : sal_uInt16 nId( m_pToolBar->GetCurItemId() );
2045 : :
2046 [ + - ]: 2 : ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
2047 [ + - ][ + - ]: 2 : if ( pIter != m_aControllerMap.end() )
2048 : : {
2049 [ + - ][ + - ]: 2 : Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
2050 : :
2051 [ + - ]: 2 : if ( xController.is() )
2052 [ + - ][ + - ]: 2 : xController->execute( nKeyModifier );
2053 : : }
2054 : :
2055 : 2 : return 1;
2056 : : }
2057 : :
2058 : 2 : IMPL_LINK_NOARG(ToolBarManager, Activate)
2059 : : {
2060 : 2 : return 1;
2061 : : }
2062 : :
2063 : 2 : IMPL_LINK_NOARG(ToolBarManager, Deactivate)
2064 : : {
2065 : 2 : return 1;
2066 : : }
2067 : :
2068 : 15326 : IMPL_LINK( ToolBarManager, StateChanged, StateChangedType*, pStateChangedType )
2069 : : {
2070 [ - + ]: 15326 : if ( m_bDisposed )
2071 : 0 : return 1;
2072 : :
2073 [ - + ]: 15326 : if ( *pStateChangedType == STATE_CHANGE_CONTROLBACKGROUND )
2074 : : {
2075 : 0 : CheckAndUpdateImages();
2076 : : }
2077 [ + + ]: 15326 : else if ( *pStateChangedType == STATE_CHANGE_VISIBLE )
2078 : : {
2079 [ + + ]: 7220 : if ( m_pToolBar->IsReallyVisible() )
2080 : 3515 : m_aAsyncUpdateControllersTimer.Start();
2081 : : }
2082 [ + + ]: 8106 : else if ( *pStateChangedType == STATE_CHANGE_INITSHOW )
2083 : : {
2084 : 3697 : m_aAsyncUpdateControllersTimer.Start();
2085 : : }
2086 : 15326 : return 1;
2087 : : }
2088 : :
2089 : 12 : IMPL_LINK( ToolBarManager, DataChanged, DataChangedEvent*, pDataChangedEvent )
2090 : : {
2091 [ - + # # : 24 : if ((( pDataChangedEvent->GetType() == DATACHANGED_SETTINGS ) ||
- + ][ - + ]
2092 : 0 : ( pDataChangedEvent->GetType() == DATACHANGED_DISPLAY )) &&
2093 : 12 : ( pDataChangedEvent->GetFlags() & SETTINGS_STYLE ))
2094 : : {
2095 : 0 : CheckAndUpdateImages();
2096 : : }
2097 : :
2098 [ - + ]: 12 : for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
2099 : : {
2100 : 0 : const sal_uInt16 nId = m_pToolBar->GetItemId(nPos);
2101 : 0 : Window* pWindow = m_pToolBar->GetItemWindow( nId );
2102 [ # # ]: 0 : if ( pWindow )
2103 : : {
2104 : 0 : const DataChangedEvent& rDCEvt( *pDataChangedEvent );
2105 : 0 : pWindow->DataChanged( rDCEvt );
2106 : : }
2107 : : }
2108 : :
2109 [ + - + - ]: 24 : if ( !m_pToolBar->IsFloatingMode() &&
[ + - ]
2110 : 12 : m_pToolBar->IsVisible() )
2111 : : {
2112 : : // Resize toolbar, layout manager is resize listener and will calc
2113 : : // the layout automatically.
2114 [ + - ]: 12 : ::Size aSize( m_pToolBar->CalcWindowSizePixel() );
2115 [ + - ]: 12 : m_pToolBar->SetOutputSizePixel( aSize );
2116 : : }
2117 : :
2118 : 12 : return 1;
2119 : : }
2120 : :
2121 : 0 : IMPL_LINK_NOARG(ToolBarManager, MiscOptionsChanged)
2122 : : {
2123 : 0 : CheckAndUpdateImages();
2124 : 0 : return 0;
2125 : : }
2126 : :
2127 : 2604 : IMPL_LINK_NOARG(ToolBarManager, AsyncUpdateControllersHdl)
2128 : : {
2129 : : // The guard must be in its own context as the we can get destroyed when our
2130 : : // own xInterface reference get destroyed!
2131 [ + - ]: 2604 : Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
2132 : :
2133 [ + - ]: 2604 : ResetableGuard aGuard( m_aLock );
2134 : :
2135 [ + + ]: 2604 : if ( m_bDisposed )
2136 : 8 : return 1;
2137 : :
2138 : : // Request to update our controllers
2139 [ + - ]: 2596 : m_aAsyncUpdateControllersTimer.Stop();
2140 [ + - ]: 2596 : UpdateControllers();
2141 : :
2142 [ + - ]: 2604 : return 0;
2143 : : }
2144 : :
2145 : 0 : IMPL_STATIC_LINK_NOINSTANCE( ToolBarManager, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
2146 : : {
2147 : : try
2148 : : {
2149 : : // Asynchronous execution as this can lead to our own destruction!
2150 [ # # # # : 0 : if (( pExecuteInfo->nCmd == EXEC_CMD_CLOSETOOLBAR ) &&
# # ][ # # ]
2151 : 0 : ( pExecuteInfo->xLayoutManager.is() ) &&
2152 : 0 : ( pExecuteInfo->xWindow.is() ))
2153 : : {
2154 : : // Use docking window close to close the toolbar. The toolbar layout manager is
2155 : : // listener and will react correctly according to the context sensitive
2156 : : // flag of our toolbar.
2157 [ # # ]: 0 : Window* pWin = VCLUnoHelper::GetWindow( pExecuteInfo->xWindow );
2158 [ # # ]: 0 : DockingWindow* pDockWin = dynamic_cast< DockingWindow* >( pWin );
2159 [ # # ]: 0 : if ( pDockWin )
2160 [ # # ]: 0 : pDockWin->Close();
2161 : : }
2162 [ # # # # ]: 0 : else if (( pExecuteInfo->nCmd == EXEC_CMD_DOCKTOOLBAR ) &&
[ # # ]
2163 : 0 : ( pExecuteInfo->xLayoutManager.is() ))
2164 : : {
2165 : 0 : ::com::sun::star::awt::Point aPoint;
2166 : 0 : aPoint.X = aPoint.Y = SAL_MAX_INT32;
2167 [ # # ]: 0 : pExecuteInfo->xLayoutManager->dockWindow( pExecuteInfo->aToolbarResName,
2168 : : DockingArea_DOCKINGAREA_DEFAULT,
2169 [ # # ]: 0 : aPoint );
2170 : : }
2171 [ # # # # ]: 0 : else if (( pExecuteInfo->nCmd == EXEC_CMD_DOCKALLTOOLBARS ) &&
[ # # ]
2172 : 0 : ( pExecuteInfo->xLayoutManager.is() ))
2173 : : {
2174 [ # # ][ # # ]: 0 : pExecuteInfo->xLayoutManager->dockAllWindows( UIElementType::TOOLBAR );
2175 : : }
2176 : : }
2177 : 0 : catch (const Exception&)
2178 : : {
2179 : : }
2180 : :
2181 [ # # ]: 0 : delete pExecuteInfo;
2182 [ # # ]: 0 : return 0;
2183 : : }
2184 : :
2185 : 1275 : Image ToolBarManager::QueryAddonsImage( const ::rtl::OUString& aCommandURL, bool bBigImages )
2186 : : {
2187 [ + - ][ + - ]: 1275 : Image aImage = framework::AddonsOptions().GetImageFromURL( aCommandURL, bBigImages );
2188 : 1275 : return aImage;
2189 : : }
2190 : :
2191 : 214106 : bool ToolBarManager::impl_RetrieveShortcutsFromConfiguration(
2192 : : const Reference< XAcceleratorConfiguration >& rAccelCfg,
2193 : : const rtl::OUString& rCommand,
2194 : : rtl::OUString& rShortCut )
2195 : : {
2196 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ToolBarManager::impl_RetrieveShortcutsFromConfiguration" );
2197 [ + - ]: 214106 : if ( rAccelCfg.is() )
2198 : : {
2199 : : try
2200 : : {
2201 [ + - ]: 214106 : com::sun::star::awt::KeyEvent aKeyEvent;
2202 [ + - ]: 214106 : Sequence< OUString > aCommands(1);
2203 [ + - ]: 214106 : aCommands[0] = rCommand;
2204 : :
2205 [ + - ][ + - ]: 214106 : Sequence< Any > aSeqKeyCode( rAccelCfg->getPreferredKeyEventsForCommandList( aCommands ) );
2206 [ + - ]: 214106 : if( aSeqKeyCode.getLength() == 1 )
2207 : : {
2208 [ + - ][ + - ]: 214106 : if ( aSeqKeyCode[0] >>= aKeyEvent )
[ - + ]
2209 : : {
2210 [ # # ][ # # ]: 0 : rShortCut = svt::AcceleratorExecute::st_AWTKey2VCLKey( aKeyEvent ).GetName();
[ # # ][ # # ]
2211 : 214106 : return true;
2212 : : }
2213 [ + - ][ - + ]: 214106 : }
[ + - ][ - + ]
[ + - ][ + - ]
[ # # ]
2214 : : }
2215 : 0 : catch (const IllegalArgumentException&)
2216 : : {
2217 : : }
2218 : : }
2219 : :
2220 : 214106 : return false;
2221 : : }
2222 : :
2223 : 71790 : bool ToolBarManager::RetrieveShortcut( const rtl::OUString& rCommandURL, rtl::OUString& rShortCut )
2224 : : {
2225 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ToolBarManager::RetrieveShortcuts" );
2226 [ + - ]: 71790 : if ( m_bModuleIdentified )
2227 : : {
2228 : 71790 : Reference< XAcceleratorConfiguration > xDocAccelCfg( m_xDocAcceleratorManager );
2229 : 71790 : Reference< XAcceleratorConfiguration > xModuleAccelCfg( m_xModuleAcceleratorManager );
2230 : 71790 : Reference< XAcceleratorConfiguration > xGlobalAccelCfg( m_xGlobalAcceleratorManager );
2231 : :
2232 [ + + ]: 71790 : if ( !m_bAcceleratorCfg )
2233 : : {
2234 : : // Retrieve references on demand
2235 : 2548 : m_bAcceleratorCfg = sal_True;
2236 [ + - ]: 2548 : if ( !xDocAccelCfg.is() )
2237 : : {
2238 [ + - ][ + - ]: 2548 : Reference< XController > xController = m_xFrame->getController();
2239 : 2548 : Reference< XModel > xModel;
2240 [ + - ]: 2548 : if ( xController.is() )
2241 : : {
2242 [ + - ][ + - ]: 2548 : xModel = xController->getModel();
[ + - ]
2243 [ + + ]: 2548 : if ( xModel.is() )
2244 : : {
2245 [ + - ]: 2546 : Reference< XUIConfigurationManagerSupplier > xSupplier( xModel, UNO_QUERY );
2246 [ + + ]: 2546 : if ( xSupplier.is() )
2247 : : {
2248 [ + - ][ + - ]: 2444 : Reference< XUIConfigurationManager > xDocUICfgMgr( xSupplier->getUIConfigurationManager(), UNO_QUERY );
[ + - ]
2249 [ + - ]: 2444 : if ( xDocUICfgMgr.is() )
2250 : : {
2251 [ + - ][ + - ]: 2444 : xDocAccelCfg = Reference< XAcceleratorConfiguration >( xDocUICfgMgr->getShortCutManager(), UNO_QUERY );
[ + - ][ + - ]
2252 [ + - ]: 2444 : m_xDocAcceleratorManager = xDocAccelCfg;
2253 : 2444 : }
2254 : 2546 : }
2255 : : }
2256 : 2548 : }
2257 : : }
2258 : :
2259 [ + - ]: 2548 : if ( !xModuleAccelCfg.is() )
2260 : : {
2261 [ + - ]: 2548 : Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier( m_xServiceManager->createInstance(
2262 : 2548 : SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ),
2263 [ + - ][ + - ]: 2548 : UNO_QUERY );
[ + - ]
2264 : : try
2265 : : {
2266 [ + - ][ + - ]: 2548 : Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier );
2267 [ + - ]: 2548 : if ( xUICfgMgr.is() )
2268 : : {
2269 [ + - ][ + - ]: 2548 : xModuleAccelCfg = Reference< XAcceleratorConfiguration >( xUICfgMgr->getShortCutManager(), UNO_QUERY );
[ + - ][ + - ]
2270 [ + - ]: 2548 : m_xModuleAcceleratorManager = xModuleAccelCfg;
2271 : 2548 : }
2272 : : }
2273 [ # # # ]: 0 : catch (const RuntimeException&)
2274 : : {
2275 : 0 : throw;
2276 : : }
2277 [ # # ]: 0 : catch (const Exception&)
2278 : : {
2279 : 2548 : }
2280 : : }
2281 : :
2282 [ + - ]: 2548 : if ( !xGlobalAccelCfg.is() )
2283 : : {
2284 [ + - ]: 2548 : xGlobalAccelCfg = Reference< XAcceleratorConfiguration >( m_xServiceManager->createInstance(
2285 : 2548 : SERVICENAME_GLOBALACCELERATORCONFIGURATION ),
2286 [ + - ][ + - ]: 2548 : UNO_QUERY );
[ + - ][ + - ]
2287 [ + - ]: 2548 : m_xGlobalAcceleratorManager = xGlobalAccelCfg;
2288 : : }
2289 : : }
2290 : :
2291 : 71790 : bool bFound = false;
2292 : :
2293 [ + - ]: 71790 : if ( m_xGlobalAcceleratorManager.is() )
2294 [ + - ]: 71790 : bFound = impl_RetrieveShortcutsFromConfiguration( xGlobalAccelCfg, rCommandURL, rShortCut );
2295 [ + - ][ + - ]: 71790 : if ( !bFound && m_xModuleAcceleratorManager.is() )
[ + - ]
2296 [ + - ]: 71790 : bFound = impl_RetrieveShortcutsFromConfiguration( xModuleAccelCfg, rCommandURL, rShortCut );
2297 [ + - ][ + + ]: 71790 : if ( !bFound && m_xDocAcceleratorManager.is() )
[ + + ]
2298 [ + - ]: 70526 : impl_RetrieveShortcutsFromConfiguration( xGlobalAccelCfg, rCommandURL, rShortCut );
2299 : :
2300 [ - + ]: 71790 : if( bFound )
2301 [ - + ][ - + ]: 71790 : return true;
[ + - ]
2302 : : }
2303 : 71790 : return false;
2304 : : }
2305 : :
2306 [ + - ][ + - ]: 699 : }
2307 : :
2308 : :
2309 : :
2310 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|