1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SVTOOLS_TOOLBOXCONTROLLER_HXX 29 #define _SVTOOLS_TOOLBOXCONTROLLER_HXX 30 31 #include "svtools/svtdllapi.h" 32 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 33 #include <com/sun/star/lang/XInitialization.hpp> 34 #include <com/sun/star/util/XUpdatable.hpp> 35 #include <com/sun/star/frame/XFrame.hpp> 36 #include <com/sun/star/frame/XDispatch.hpp> 37 #include <com/sun/star/frame/XStatusListener.hpp> 38 #include <com/sun/star/frame/XToolbarController.hpp> 39 #include <com/sun/star/util/XURLTransformer.hpp> 40 #include <com/sun/star/frame/XLayoutManager.hpp> 41 #include <cppuhelper/weak.hxx> 42 #include <cppuhelper/interfacecontainer.hxx> 43 #include <comphelper/broadcasthelper.hxx> 44 #include <com/sun/star/util/XURLTransformer.hpp> 45 //shizhoubo for ToolbarController Visiable 46 #include <comphelper/proparrhlp.hxx> 47 #include <comphelper/property.hxx> 48 #include <comphelper/propertycontainer.hxx> 49 #include <cppuhelper/propshlp.hxx> 50 #include <cppuhelper/interfacecontainer.hxx> 51 //end 52 #ifndef INCLUDED_HASH_MAP 53 #include <hash_map> 54 #define INCLUDED_HASH_MAP 55 #endif 56 57 class ToolBox; 58 59 namespace svt 60 { 61 struct ToolboxController_Impl; 62 63 class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusListener, 64 public ::com::sun::star::frame::XToolbarController, 65 public ::com::sun::star::lang::XInitialization, 66 public ::com::sun::star::util::XUpdatable, 67 public ::com::sun::star::lang::XComponent, 68 public ::comphelper::OMutexAndBroadcastHelper,//shizhoubo 69 public ::comphelper::OPropertyContainer,//shizhoubo 70 public ::comphelper::OPropertyArrayUsageHelper< ToolboxController >,//shizhoubo 71 public ::cppu::OWeakObject 72 { 73 private: 74 sal_Bool m_bSupportVisiable; //shizhoubo 75 public: 76 ToolboxController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager, 77 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, 78 const rtl::OUString& aCommandURL ); 79 ToolboxController(); 80 virtual ~ToolboxController(); 81 82 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > getFrameInterface() const; 83 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getServiceManager() const; 84 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > getLayoutManager() const; 85 86 void updateStatus( const rtl::OUString aCommandURL ); 87 void updateStatus(); 88 89 // XInterface 90 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); 91 virtual void SAL_CALL acquire() throw (); 92 virtual void SAL_CALL release() throw (); 93 94 // XInitialization 95 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 96 97 // XUpdatable 98 virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException); 99 100 // XComponent 101 virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException); 102 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 103 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 104 105 // XEventListener 106 using cppu::OPropertySetHelper::disposing; 107 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException ); 108 109 // XStatusListener 110 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) = 0; 111 112 // XToolbarController 113 virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException); 114 virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException); 115 virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException); 116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException); 117 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createItemWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& Parent ) throw (::com::sun::star::uno::RuntimeException); 118 // OPropertySetHelper //shizhoubo 119 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const com::sun::star::uno::Any& rValue ) throw(com::sun::star::uno::Exception); 120 virtual sal_Bool SAL_CALL convertFastPropertyValue( com::sun::star::uno::Any& rConvertedValue, com::sun::star::uno::Any& rOldValue, sal_Int32 nHandle, const com::sun::star::uno::Any& rValue) throw(com::sun::star::lang::IllegalArgumentException); 121 // XPropertySet //shizhoubo 122 virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); 123 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 124 // OPropertyArrayUsageHelper //shizhoubo 125 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 126 127 128 const rtl::OUString& getCommandURL() const { return m_aCommandURL; } 129 const rtl::OUString& getModuleName() const; 130 131 void dispatchCommand( const ::rtl::OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs ); 132 133 void enable( bool bEnable ); 134 135 protected: 136 bool getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox ); 137 void setSupportVisiableProperty(sal_Bool bValue); //shizhoubo 138 struct Listener 139 { 140 Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) : 141 aURL( rURL ), xDispatch( rDispatch ) {} 142 143 ::com::sun::star::util::URL aURL; 144 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch; 145 }; 146 147 typedef ::std::hash_map< ::rtl::OUString, 148 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >, 149 ::rtl::OUStringHash, 150 ::std::equal_to< ::rtl::OUString > > URLToDispatchMap; 151 152 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation 153 void addStatusListener( const rtl::OUString& aCommandURL ); 154 void removeStatusListener( const rtl::OUString& aCommandURL ); 155 void bindListener(); 156 void unbindListener(); 157 sal_Bool isBound() const; 158 sal_Bool hasBigImages() const; 159 sal_Bool isHighContrast() const; 160 ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > getURLTransformer() const; 161 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > getParent() const; 162 163 sal_Bool m_bInitialized : 1, 164 m_bDisposed : 1; 165 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; 166 ToolboxController_Impl* m_pImpl; 167 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; 168 rtl::OUString m_aCommandURL; 169 URLToDispatchMap m_aListenerMap; 170 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener 171 }; 172 173 } 174 175 #endif // _SVTOOLS_TOOLBOXCONTROLLER_HXX 176