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/addonstoolbarmanager.hxx>
30 : : #include <uielement/toolbarmerger.hxx>
31 : :
32 : : #include <uielement/toolbar.hxx>
33 : : #include <uielement/generictoolbarcontroller.hxx>
34 : : #include <threadhelp/resetableguard.hxx>
35 : : #include "services.h"
36 : : #include <framework/imageproducer.hxx>
37 : : #include <framework/sfxhelperfunctions.hxx>
38 : : #include <classes/fwkresid.hxx>
39 : : #include <classes/resource.hrc>
40 : : #include <framework/addonsoptions.hxx>
41 : : #include <uielement/comboboxtoolbarcontroller.hxx>
42 : : #include <uielement/imagebuttontoolbarcontroller.hxx>
43 : : #include <uielement/togglebuttontoolbarcontroller.hxx>
44 : : #include <uielement/buttontoolbarcontroller.hxx>
45 : : #include <uielement/spinfieldtoolbarcontroller.hxx>
46 : : #include <uielement/edittoolbarcontroller.hxx>
47 : : #include <uielement/dropdownboxtoolbarcontroller.hxx>
48 : : #include <uielement/toolbarmerger.hxx>
49 : :
50 : : #include <com/sun/star/ui/ItemType.hpp>
51 : : #include <com/sun/star/frame/XToolbarController.hpp>
52 : : #include <com/sun/star/frame/XDispatchProvider.hpp>
53 : : #include <com/sun/star/beans/XPropertySet.hpp>
54 : : #include <com/sun/star/lang/XServiceInfo.hpp>
55 : : #include <com/sun/star/frame/XLayoutManager.hpp>
56 : : #include <com/sun/star/ui/DockingArea.hpp>
57 : : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
58 : :
59 : : #include <svtools/imgdef.hxx>
60 : : #include <svtools/toolboxcontroller.hxx>
61 : : #include <toolkit/unohlp.hxx>
62 : :
63 : : #include <svtools/miscopt.hxx>
64 : : #include <vcl/svapp.hxx>
65 : : #include <vcl/menu.hxx>
66 : : #include <vcl/syswin.hxx>
67 : : #include <vcl/taskpanelist.hxx>
68 : :
69 : : //_________________________________________________________________________________________________________________
70 : : // namespaces
71 : : //_________________________________________________________________________________________________________________
72 : :
73 : : using namespace ::com::sun::star;
74 : : using namespace ::com::sun::star::awt;
75 : : using namespace ::com::sun::star::beans;
76 : : using namespace ::com::sun::star::uno;
77 : : using namespace ::com::sun::star::lang;
78 : : using namespace ::com::sun::star::frame;
79 : : using namespace ::com::sun::star::util;
80 : : using namespace ::com::sun::star::container;
81 : : using namespace ::com::sun::star::frame;
82 : : using namespace ::com::sun::star::ui;
83 : :
84 : : namespace framework
85 : : {
86 : :
87 : : static const char TOOLBOXITEM_SEPARATOR_STR[] = "private:separator";
88 : : static const sal_uInt16 TOOLBOXITEM_SEPARATOR_STR_LEN = sizeof( TOOLBOXITEM_SEPARATOR_STR )-1;
89 : :
90 : 0 : AddonsToolBarManager::AddonsToolBarManager( const Reference< XMultiServiceFactory >& rServiceManager,
91 : : const Reference< XFrame >& rFrame,
92 : : const rtl::OUString& rResourceName,
93 : : ToolBar* pToolBar ) :
94 : 0 : ToolBarManager( rServiceManager, rFrame, rResourceName, pToolBar )
95 : : {
96 [ # # ]: 0 : m_pToolBar->SetMenuType( TOOLBOX_MENUTYPE_CLIPPEDITEMS );
97 [ # # ]: 0 : m_pToolBar->SetSelectHdl( LINK( this, AddonsToolBarManager, Select) );
98 [ # # ]: 0 : m_pToolBar->SetActivateHdl( LINK( this, AddonsToolBarManager, Activate) );
99 [ # # ]: 0 : m_pToolBar->SetDeactivateHdl( LINK( this, AddonsToolBarManager, Deactivate) );
100 [ # # ]: 0 : m_pToolBar->SetClickHdl( LINK( this, AddonsToolBarManager, Click ) );
101 [ # # ]: 0 : m_pToolBar->SetDoubleClickHdl( LINK( this, AddonsToolBarManager, DoubleClick ) );
102 [ # # ]: 0 : m_pToolBar->SetCommandHdl( LINK( this, AddonsToolBarManager, Command ) );
103 [ # # ]: 0 : m_pToolBar->SetStateChangedHdl( LINK( this, AddonsToolBarManager, StateChanged ) );
104 [ # # ]: 0 : m_pToolBar->SetDataChangedHdl( LINK( this, AddonsToolBarManager, DataChanged ) );
105 : 0 : }
106 : :
107 : 0 : AddonsToolBarManager::~AddonsToolBarManager()
108 : : {
109 [ # # ]: 0 : }
110 : :
111 : 0 : static sal_Bool IsCorrectContext( const ::rtl::OUString& rModuleIdentifier, const ::rtl::OUString& aContextList )
112 : : {
113 [ # # ]: 0 : if ( aContextList.isEmpty() )
114 : 0 : return sal_True;
115 : :
116 [ # # ]: 0 : if ( !rModuleIdentifier.isEmpty() )
117 : : {
118 : 0 : sal_Int32 nIndex = aContextList.indexOf( rModuleIdentifier );
119 : 0 : return ( nIndex >= 0 );
120 : : }
121 : :
122 : 0 : return sal_False;
123 : : }
124 : :
125 : 0 : static Image RetrieveImage( Reference< com::sun::star::frame::XFrame >& rFrame,
126 : : const rtl::OUString& aImageId,
127 : : const rtl::OUString& aURL,
128 : : sal_Bool bBigImage
129 : : )
130 : : {
131 : 0 : Image aImage;
132 : :
133 [ # # ]: 0 : if ( !aImageId.isEmpty() )
134 : : {
135 [ # # ][ # # ]: 0 : aImage = framework::AddonsOptions().GetImageFromURL( aImageId, bBigImage );
[ # # ][ # # ]
[ # # ]
136 [ # # ]: 0 : if ( !!aImage )
137 : 0 : return aImage;
138 : : else
139 [ # # ][ # # ]: 0 : aImage = GetImageFromURL( rFrame, aImageId, bBigImage );
[ # # ]
140 [ # # ]: 0 : if ( !!aImage )
141 : 0 : return aImage;
142 : : }
143 : :
144 [ # # ][ # # ]: 0 : aImage = framework::AddonsOptions().GetImageFromURL( aURL, bBigImage );
[ # # ][ # # ]
[ # # ]
145 [ # # ]: 0 : if ( !aImage )
146 [ # # ][ # # ]: 0 : aImage = GetImageFromURL( rFrame, aImageId, bBigImage );
[ # # ]
147 : :
148 : 0 : return aImage;
149 : : }
150 : :
151 : : // XComponent
152 : 0 : void SAL_CALL AddonsToolBarManager::dispose() throw( RuntimeException )
153 : : {
154 [ # # ]: 0 : Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
155 : :
156 : : {
157 : : // Remove addon specific data from toolbar items.
158 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
159 [ # # ][ # # ]: 0 : for ( sal_uInt16 n = 0; n < m_pToolBar->GetItemCount(); n++ )
160 : : {
161 [ # # ]: 0 : sal_uInt16 nId( m_pToolBar->GetItemId( n ) );
162 : :
163 [ # # ]: 0 : if ( nId > 0 )
164 : : {
165 [ # # ]: 0 : AddonsParams* pRuntimeItemData = (AddonsParams*)m_pToolBar->GetItemData( nId );
166 [ # # ]: 0 : if ( pRuntimeItemData )
167 [ # # ]: 0 : delete pRuntimeItemData;
168 [ # # ]: 0 : m_pToolBar->SetItemData( nId, NULL );
169 : : }
170 [ # # ]: 0 : }
171 : : }
172 : :
173 : : // Base class will destroy our m_pToolBar member
174 [ # # ]: 0 : ToolBarManager::dispose();
175 : 0 : }
176 : :
177 : 0 : bool AddonsToolBarManager::MenuItemAllowed( sal_uInt16 nId ) const
178 : : {
179 [ # # ][ # # ]: 0 : if (( nId == MENUITEM_TOOLBAR_VISIBLEBUTTON ) ||
180 : : ( nId == MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR ))
181 : 0 : return false;
182 : : else
183 : 0 : return true;
184 : : }
185 : :
186 : 0 : void AddonsToolBarManager::RefreshImages()
187 : : {
188 [ # # ][ # # ]: 0 : sal_Bool bBigImages( SvtMiscOptions().AreCurrentSymbolsLarge() );
[ # # ]
189 [ # # ][ # # ]: 0 : for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); nPos++ )
190 : : {
191 [ # # ]: 0 : sal_uInt16 nId( m_pToolBar->GetItemId( nPos ) );
192 : :
193 [ # # ]: 0 : if ( nId > 0 )
194 : : {
195 [ # # ][ # # ]: 0 : ::rtl::OUString aCommandURL = m_pToolBar->GetItemCommand( nId );
196 : 0 : ::rtl::OUString aImageId;
197 [ # # ]: 0 : AddonsParams* pRuntimeItemData = (AddonsParams*)m_pToolBar->GetItemData( nId );
198 [ # # ]: 0 : if ( pRuntimeItemData )
199 : 0 : aImageId = pRuntimeItemData->aImageId;
200 : :
201 : : m_pToolBar->SetItemImage(
202 : : nId,
203 : : RetrieveImage( m_xFrame, aImageId, aCommandURL, bBigImages )
204 [ # # ][ # # ]: 0 : );
[ # # ]
205 : : }
206 : : }
207 [ # # ][ # # ]: 0 : m_pToolBar->SetToolboxButtonSize( bBigImages ? TOOLBOX_BUTTONSIZE_LARGE : TOOLBOX_BUTTONSIZE_SMALL );
208 [ # # ]: 0 : ::Size aSize = m_pToolBar->CalcWindowSizePixel();
209 [ # # ]: 0 : m_pToolBar->SetOutputSizePixel( aSize );
210 : 0 : }
211 : :
212 : 0 : void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue > >& rAddonToolbar )
213 : : {
214 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
215 : :
216 [ # # ]: 0 : if ( m_bDisposed )
217 : 0 : return;
218 : :
219 : 0 : sal_uInt16 nId( 1 );
220 : :
221 [ # # ]: 0 : RemoveControllers();
222 : :
223 [ # # ]: 0 : m_pToolBar->Clear();
224 [ # # ]: 0 : m_aControllerMap.clear();
225 : :
226 : 0 : ::rtl::OUString aModuleIdentifier;
227 : : try
228 : : {
229 : : Reference< XModuleManager > xModuleManager(
230 [ # # ][ # # ]: 0 : m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
[ # # ][ # # ]
231 [ # # ][ # # ]: 0 : aModuleIdentifier = xModuleManager->identify( m_xFrame );
[ # # ]
232 : : }
233 [ # # ]: 0 : catch ( const Exception& )
234 : : {
235 : : }
236 : :
237 [ # # ]: 0 : Reference< XMultiComponentFactory > xToolbarControllerFactory( m_xToolbarControllerRegistration, UNO_QUERY );
238 : 0 : Reference< XComponentContext > xComponentContext;
239 [ # # ]: 0 : Reference< XPropertySet > xProps( m_xServiceManager, UNO_QUERY );
240 : :
241 [ # # ]: 0 : if ( xProps.is() )
242 [ # # ][ # # ]: 0 : xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xComponentContext;
[ # # ][ # # ]
243 : :
244 : 0 : sal_uInt32 nElements( 0 );
245 : 0 : sal_Bool bAppendSeparator( sal_False );
246 [ # # ]: 0 : Reference< XWindow > xToolbarWindow = VCLUnoHelper::GetInterface( m_pToolBar );
247 [ # # ]: 0 : for ( sal_uInt32 n = 0; n < (sal_uInt32)rAddonToolbar.getLength(); n++ )
248 : : {
249 : 0 : rtl::OUString aURL;
250 : 0 : rtl::OUString aTitle;
251 : 0 : rtl::OUString aImageId;
252 : 0 : rtl::OUString aContext;
253 : 0 : rtl::OUString aTarget;
254 : 0 : rtl::OUString aControlType;
255 : 0 : sal_uInt16 nWidth( 0 );
256 : :
257 : 0 : const Sequence< PropertyValue >& rSeq = rAddonToolbar[n];
258 : :
259 [ # # ][ # # ]: 0 : ToolBarMerger::ConvertSequenceToValues( rSeq, aURL, aTitle, aImageId, aTarget, aContext, aControlType, nWidth );
[ # # ]
260 : :
261 [ # # ]: 0 : if ( IsCorrectContext( aModuleIdentifier, aContext ))
262 : : {
263 [ # # ]: 0 : if ( aURL.equalsAsciiL( TOOLBOXITEM_SEPARATOR_STR, TOOLBOXITEM_SEPARATOR_STR_LEN ))
264 : : {
265 [ # # ]: 0 : sal_uInt16 nCount = m_pToolBar->GetItemCount();
266 [ # # ][ # # ]: 0 : if ( nCount > 0 && ( m_pToolBar->GetItemType( nCount-1 ) != TOOLBOXITEM_SEPARATOR ) && nElements > 0 )
[ # # ][ # # ]
[ # # ]
267 : : {
268 : 0 : nElements = 0;
269 [ # # ]: 0 : m_pToolBar->InsertSeparator();
270 : : }
271 : : }
272 : : else
273 : : {
274 [ # # ]: 0 : sal_uInt16 nCount = m_pToolBar->GetItemCount();
275 [ # # ][ # # ]: 0 : if ( bAppendSeparator && nCount > 0 && ( m_pToolBar->GetItemType( nCount-1 ) != TOOLBOXITEM_SEPARATOR ))
[ # # ][ # # ]
[ # # ]
276 : : {
277 : : // We have to append a separator first if the last item is not a separator
278 [ # # ]: 0 : m_pToolBar->InsertSeparator();
279 : : }
280 : 0 : bAppendSeparator = sal_False;
281 : :
282 [ # # ][ # # ]: 0 : m_pToolBar->InsertItem( nId, aTitle );
[ # # ]
283 : :
284 [ # # ]: 0 : Image aImage = RetrieveImage( m_xFrame, aImageId, aURL, !m_bSmallSymbols );
285 [ # # ]: 0 : if ( !!aImage )
286 [ # # ]: 0 : m_pToolBar->SetItemImage( nId, aImage );
287 : :
288 : : // Create TbRuntimeItemData to hold additional information we will need in the future
289 [ # # ]: 0 : AddonsParams* pRuntimeItemData = new AddonsParams;
290 : 0 : pRuntimeItemData->aImageId = aImageId;
291 : 0 : pRuntimeItemData->aTarget = aTarget;
292 [ # # ]: 0 : m_pToolBar->SetItemData( nId, pRuntimeItemData );
293 [ # # ][ # # ]: 0 : m_pToolBar->SetItemCommand( nId, aURL );
[ # # ]
294 : :
295 : 0 : Reference< XStatusListener > xController;
296 : :
297 : 0 : sal_Bool bMustBeInit( sal_True );
298 : :
299 : : // Support external toolbar controller for add-ons!
300 [ # # ][ # # ]: 0 : if ( m_xToolbarControllerRegistration.is() &&
[ # # ]
301 [ # # ][ # # ]: 0 : m_xToolbarControllerRegistration->hasController( aURL, m_aModuleIdentifier ))
302 : : {
303 [ # # ]: 0 : if ( xToolbarControllerFactory.is() )
304 : : {
305 [ # # ]: 0 : Sequence< Any > aArgs(5);
306 : 0 : PropertyValue aPropValue;
307 : :
308 [ # # ]: 0 : aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" ));
309 [ # # ]: 0 : aPropValue.Value <<= m_aModuleIdentifier;
310 [ # # ][ # # ]: 0 : aArgs[0] <<= aPropValue;
311 [ # # ]: 0 : aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
312 [ # # ]: 0 : aPropValue.Value <<= m_xFrame;
313 [ # # ][ # # ]: 0 : aArgs[1] <<= aPropValue;
314 [ # # ]: 0 : aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
315 [ # # ]: 0 : aPropValue.Value <<= m_xServiceManager;
316 [ # # ][ # # ]: 0 : aArgs[2] <<= aPropValue;
317 [ # # ]: 0 : aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
318 [ # # ]: 0 : aPropValue.Value <<= xToolbarWindow;
319 [ # # ][ # # ]: 0 : aArgs[3] <<= aPropValue;
320 [ # # ]: 0 : aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ItemId" ));
321 [ # # ]: 0 : aPropValue.Value = makeAny( sal_Int32( nId ));
322 [ # # ][ # # ]: 0 : aArgs[4] <<= aPropValue;
323 : :
324 : : try
325 : : {
326 [ # # ]: 0 : xController = Reference< XStatusListener >( xToolbarControllerFactory->createInstanceWithArgumentsAndContext(
327 : 0 : aURL, aArgs, xComponentContext ),
328 [ # # ][ # # ]: 0 : UNO_QUERY );
[ # # ][ # # ]
329 : : }
330 [ # # ]: 0 : catch ( const uno::Exception& )
331 : : {
332 : : }
333 [ # # ]: 0 : bMustBeInit = sal_False; // factory called init already!
334 : : }
335 : : }
336 : : else
337 : : {
338 : 0 : ::cppu::OWeakObject* pController = 0;
339 : :
340 [ # # ]: 0 : pController = ToolBarMerger::CreateController( m_xServiceManager, m_xFrame, m_pToolBar, aURL, nId, nWidth, aControlType );
341 [ # # ][ # # ]: 0 : xController = Reference< XStatusListener >( pController, UNO_QUERY );
[ # # ]
342 : : }
343 : :
344 : : // insert controller to the map
345 [ # # ][ # # ]: 0 : m_aControllerMap[nId] = xController;
346 : :
347 [ # # ]: 0 : Reference< XInitialization > xInit( xController, UNO_QUERY );
348 [ # # ][ # # ]: 0 : if ( xInit.is() && bMustBeInit )
[ # # ]
349 : : {
350 : 0 : PropertyValue aPropValue;
351 [ # # ]: 0 : Sequence< Any > aArgs( 3 );
352 [ # # ]: 0 : aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
353 [ # # ]: 0 : aPropValue.Value <<= m_xFrame;
354 [ # # ][ # # ]: 0 : aArgs[0] <<= aPropValue;
355 [ # # ]: 0 : aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" ));
356 [ # # ]: 0 : aPropValue.Value <<= aURL;
357 [ # # ][ # # ]: 0 : aArgs[1] <<= aPropValue;
358 [ # # ]: 0 : aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
359 [ # # ]: 0 : aPropValue.Value <<= m_xServiceManager;
360 [ # # ][ # # ]: 0 : aArgs[2] <<= aPropValue;
361 : : try
362 : : {
363 [ # # ][ # # ]: 0 : xInit->initialize( aArgs );
364 : : }
365 [ # # ]: 0 : catch ( const uno::Exception& )
366 : : {
367 [ # # ]: 0 : }
368 : : }
369 : :
370 : : // Request a item window from the toolbar controller and set it at the VCL toolbar
371 [ # # ]: 0 : Reference< XToolbarController > xTbxController( xController, UNO_QUERY );
372 [ # # ][ # # ]: 0 : if ( xTbxController.is() && xToolbarWindow.is() )
[ # # ]
373 : : {
374 [ # # ][ # # ]: 0 : Reference< XWindow > xWindow = xTbxController->createItemWindow( xToolbarWindow );
375 [ # # ]: 0 : if ( xWindow.is() )
376 : : {
377 [ # # ]: 0 : Window* pItemWin = VCLUnoHelper::GetWindow( xWindow );
378 [ # # ]: 0 : if ( pItemWin )
379 : : {
380 [ # # ]: 0 : WindowType nType = pItemWin->GetType();
381 [ # # ][ # # ]: 0 : if ( nType == WINDOW_LISTBOX || nType == WINDOW_MULTILISTBOX || nType == WINDOW_COMBOBOX )
[ # # ]
382 [ # # ][ # # ]: 0 : pItemWin->SetAccessibleName( m_pToolBar->GetItemText( nId ) );
383 [ # # ]: 0 : m_pToolBar->SetItemWindow( nId, pItemWin );
384 : : }
385 [ # # ]: 0 : }
386 : : }
387 : :
388 : : // Notify controller implementation to its listeners. Controller is now useable from outside.
389 [ # # ]: 0 : Reference< XUpdatable > xUpdatable( xController, UNO_QUERY );
390 [ # # ]: 0 : if ( xUpdatable.is() )
391 : : {
392 : : try
393 : : {
394 [ # # ][ # # ]: 0 : xUpdatable->update();
395 : : }
396 [ # # ]: 0 : catch ( const uno::Exception& )
397 : : {
398 : : }
399 : : }
400 : :
401 : 0 : ++nId;
402 [ # # ]: 0 : ++nElements;
403 : : }
404 : : }
405 : 0 : }
406 : :
407 [ # # ][ # # ]: 0 : AddFrameActionListener();
[ # # ]
408 : : }
409 : :
410 : 0 : IMPL_LINK_NOARG(AddonsToolBarManager, Click)
411 : : {
412 [ # # ]: 0 : if ( m_bDisposed )
413 : 0 : return 1;
414 : :
415 : 0 : sal_uInt16 nId( m_pToolBar->GetCurItemId() );
416 [ # # ]: 0 : ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
417 [ # # ][ # # ]: 0 : if ( pIter != m_aControllerMap.end() )
418 : : {
419 [ # # ][ # # ]: 0 : Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
420 : :
421 [ # # ]: 0 : if ( xController.is() )
422 [ # # ][ # # ]: 0 : xController->click();
423 : : }
424 : :
425 : 0 : return 1;
426 : : }
427 : :
428 : 0 : IMPL_LINK_NOARG(AddonsToolBarManager, DoubleClick)
429 : : {
430 [ # # ]: 0 : if ( m_bDisposed )
431 : 0 : return 1;
432 : :
433 : 0 : sal_uInt16 nId( m_pToolBar->GetCurItemId() );
434 [ # # ]: 0 : ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
435 [ # # ][ # # ]: 0 : if ( pIter != m_aControllerMap.end() )
436 : : {
437 [ # # ][ # # ]: 0 : Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
438 : :
439 [ # # ]: 0 : if ( xController.is() )
440 [ # # ][ # # ]: 0 : xController->doubleClick();
441 : : }
442 : :
443 : 0 : return 1;
444 : : }
445 : :
446 : 0 : IMPL_LINK_NOARG(AddonsToolBarManager, Command)
447 : : {
448 [ # # ]: 0 : ResetableGuard aGuard( m_aLock );
449 : :
450 [ # # ]: 0 : if ( m_bDisposed )
451 : 0 : return 1;
452 : :
453 [ # # ]: 0 : return 0;
454 : : }
455 : :
456 : 0 : IMPL_LINK_NOARG(AddonsToolBarManager, Select)
457 : : {
458 [ # # ]: 0 : if ( m_bDisposed )
459 : 0 : return 1;
460 : :
461 : 0 : sal_Int16 nKeyModifier( (sal_Int16)m_pToolBar->GetModifier() );
462 : 0 : sal_uInt16 nId( m_pToolBar->GetCurItemId() );
463 [ # # ]: 0 : ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
464 [ # # ][ # # ]: 0 : if ( pIter != m_aControllerMap.end() )
465 : : {
466 [ # # ][ # # ]: 0 : Reference< XToolbarController > xController( pIter->second, UNO_QUERY );
467 : :
468 [ # # ]: 0 : if ( xController.is() )
469 [ # # ][ # # ]: 0 : xController->execute( nKeyModifier );
470 : : }
471 : :
472 : 0 : return 1;
473 : : }
474 : :
475 : 0 : IMPL_LINK_NOARG(AddonsToolBarManager, Activate)
476 : : {
477 : 0 : return 1;
478 : : }
479 : :
480 : 0 : IMPL_LINK_NOARG(AddonsToolBarManager, Deactivate)
481 : : {
482 : 0 : return 1;
483 : : }
484 : :
485 : 0 : IMPL_LINK( AddonsToolBarManager, StateChanged, StateChangedType*, pStateChangedType )
486 : : {
487 [ # # ]: 0 : if ( *pStateChangedType == STATE_CHANGE_CONTROLBACKGROUND )
488 : : {
489 : 0 : CheckAndUpdateImages();
490 : : }
491 : 0 : return 1;
492 : : }
493 : :
494 : 0 : IMPL_LINK( AddonsToolBarManager, DataChanged, DataChangedEvent*, pDataChangedEvent )
495 : : {
496 [ # # # # : 0 : if ((( pDataChangedEvent->GetType() == DATACHANGED_SETTINGS ) ||
# # ][ # # ]
497 : 0 : ( pDataChangedEvent->GetType() == DATACHANGED_DISPLAY )) &&
498 : 0 : ( pDataChangedEvent->GetFlags() & SETTINGS_STYLE ))
499 : : {
500 : 0 : CheckAndUpdateImages();
501 : : }
502 : :
503 [ # # ]: 0 : for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
504 : : {
505 : 0 : const sal_uInt16 nId = m_pToolBar->GetItemId(nPos);
506 : 0 : Window* pWindow = m_pToolBar->GetItemWindow( nId );
507 [ # # ]: 0 : if ( pWindow )
508 : : {
509 : 0 : const DataChangedEvent& rDCEvt( *pDataChangedEvent );
510 : 0 : pWindow->DataChanged( rDCEvt );
511 : : }
512 : : }
513 : :
514 : 0 : return 1;
515 : : }
516 : :
517 : : }
518 : :
519 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|