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