101aa44aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 301aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 401aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 501aa44aaSAndrew Rist * distributed with this work for additional information 601aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 701aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 801aa44aaSAndrew Rist * "License"); you may not use this file except in compliance 901aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at 1001aa44aaSAndrew Rist * 1101aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1201aa44aaSAndrew Rist * 1301aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 1401aa44aaSAndrew Rist * software distributed under the License is distributed on an 1501aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1601aa44aaSAndrew Rist * KIND, either express or implied. See the License for the 1701aa44aaSAndrew Rist * specific language governing permissions and limitations 1801aa44aaSAndrew Rist * under the License. 1901aa44aaSAndrew Rist * 2001aa44aaSAndrew Rist *************************************************************/ 2101aa44aaSAndrew Rist 2201aa44aaSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SVTOOLS_TOOLBOXCONTROLLER_HXX 25cdf0e10cSrcweir #define _SVTOOLS_TOOLBOXCONTROLLER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svtools/svtdllapi.h" 28cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 29cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 30cdf0e10cSrcweir #include <com/sun/star/util/XUpdatable.hpp> 31cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 32cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 33cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp> 34cdf0e10cSrcweir #include <com/sun/star/frame/XToolbarController.hpp> 35cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 36cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp> 37cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 38cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 39cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 40cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 41cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx> 42cdf0e10cSrcweir #include <comphelper/property.hxx> 43cdf0e10cSrcweir #include <comphelper/propertycontainer.hxx> 44cdf0e10cSrcweir #include <cppuhelper/propshlp.hxx> 45cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 46d21a9fb0SAriel Constenla-Haile #include <tools/link.hxx> 47d21a9fb0SAriel Constenla-Haile 48cdf0e10cSrcweir //end 49cdf0e10cSrcweir #ifndef INCLUDED_HASH_MAP 50cdf0e10cSrcweir #include <hash_map> 51cdf0e10cSrcweir #define INCLUDED_HASH_MAP 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir 54cdf0e10cSrcweir class ToolBox; 55cdf0e10cSrcweir 56cdf0e10cSrcweir namespace svt 57cdf0e10cSrcweir { 58d21a9fb0SAriel Constenla-Haile 59cdf0e10cSrcweir class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusListener, 60cdf0e10cSrcweir public ::com::sun::star::frame::XToolbarController, 61cdf0e10cSrcweir public ::com::sun::star::lang::XInitialization, 62cdf0e10cSrcweir public ::com::sun::star::util::XUpdatable, 63cdf0e10cSrcweir public ::com::sun::star::lang::XComponent, 64cdf0e10cSrcweir public ::comphelper::OMutexAndBroadcastHelper,//shizhoubo 65cdf0e10cSrcweir public ::comphelper::OPropertyContainer,//shizhoubo 66cdf0e10cSrcweir public ::comphelper::OPropertyArrayUsageHelper< ToolboxController >,//shizhoubo 67cdf0e10cSrcweir public ::cppu::OWeakObject 68cdf0e10cSrcweir { 69cdf0e10cSrcweir private: 70cdf0e10cSrcweir sal_Bool m_bSupportVisiable; //shizhoubo 71cdf0e10cSrcweir public: 72cdf0e10cSrcweir ToolboxController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager, 73cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, 74cdf0e10cSrcweir const rtl::OUString& aCommandURL ); 75cdf0e10cSrcweir ToolboxController(); 76cdf0e10cSrcweir virtual ~ToolboxController(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > getFrameInterface() const; 79cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getServiceManager() const; 80cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > getLayoutManager() const; 81cdf0e10cSrcweir 82cdf0e10cSrcweir void updateStatus( const rtl::OUString aCommandURL ); 83cdf0e10cSrcweir void updateStatus(); 84cdf0e10cSrcweir 85cdf0e10cSrcweir // XInterface 86cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); 87cdf0e10cSrcweir virtual void SAL_CALL acquire() throw (); 88cdf0e10cSrcweir virtual void SAL_CALL release() throw (); 89cdf0e10cSrcweir 90cdf0e10cSrcweir // XInitialization 91cdf0e10cSrcweir 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); 92cdf0e10cSrcweir 93cdf0e10cSrcweir // XUpdatable 94cdf0e10cSrcweir virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir 96cdf0e10cSrcweir // XComponent 97cdf0e10cSrcweir virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException); 98cdf0e10cSrcweir virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 99cdf0e10cSrcweir virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 100cdf0e10cSrcweir 101cdf0e10cSrcweir // XEventListener 102cdf0e10cSrcweir using cppu::OPropertySetHelper::disposing; 103cdf0e10cSrcweir virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException ); 104cdf0e10cSrcweir 105cdf0e10cSrcweir // XStatusListener 106cdf0e10cSrcweir virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) = 0; 107cdf0e10cSrcweir 108cdf0e10cSrcweir // XToolbarController 109cdf0e10cSrcweir virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException); 110cdf0e10cSrcweir virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException); 111cdf0e10cSrcweir virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException); 112cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException); 113cdf0e10cSrcweir 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); 114cdf0e10cSrcweir // OPropertySetHelper //shizhoubo 115cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const com::sun::star::uno::Any& rValue ) throw(com::sun::star::uno::Exception); 116cdf0e10cSrcweir 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); 117cdf0e10cSrcweir // XPropertySet //shizhoubo 118cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); 119cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 120cdf0e10cSrcweir // OPropertyArrayUsageHelper //shizhoubo 121cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 122cdf0e10cSrcweir 123cdf0e10cSrcweir getCommandURL() const124cdf0e10cSrcweir const rtl::OUString& getCommandURL() const { return m_aCommandURL; } getModuleName() const125d21a9fb0SAriel Constenla-Haile const rtl::OUString& getModuleName() const { return m_sModuleName; } 126cdf0e10cSrcweir 127*7ca83afaSAriel Constenla-Haile void dispatchCommand( const ::rtl::OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs, const rtl::OUString &sTarget = rtl::OUString() ); 128cdf0e10cSrcweir 129cdf0e10cSrcweir void enable( bool bEnable ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir protected: 132cdf0e10cSrcweir bool getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox ); 133cdf0e10cSrcweir void setSupportVisiableProperty(sal_Bool bValue); //shizhoubo 134cdf0e10cSrcweir struct Listener 135cdf0e10cSrcweir { Listenersvt::ToolboxController::Listener136cdf0e10cSrcweir Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) : 137cdf0e10cSrcweir aURL( rURL ), xDispatch( rDispatch ) {} 138cdf0e10cSrcweir 139cdf0e10cSrcweir ::com::sun::star::util::URL aURL; 140cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch; 141cdf0e10cSrcweir }; 142cdf0e10cSrcweir 143*7ca83afaSAriel Constenla-Haile struct DispatchInfo 144*7ca83afaSAriel Constenla-Haile { 145*7ca83afaSAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > mxDispatch; 146*7ca83afaSAriel Constenla-Haile const ::com::sun::star::util::URL maURL; 147*7ca83afaSAriel Constenla-Haile const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > maArgs; 148*7ca83afaSAriel Constenla-Haile DispatchInfosvt::ToolboxController::DispatchInfo149*7ca83afaSAriel Constenla-Haile DispatchInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& xDispatch, 150*7ca83afaSAriel Constenla-Haile const ::com::sun::star::util::URL& rURL, 151*7ca83afaSAriel Constenla-Haile const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs ) 152*7ca83afaSAriel Constenla-Haile : mxDispatch( xDispatch ) 153*7ca83afaSAriel Constenla-Haile , maURL( rURL ) 154*7ca83afaSAriel Constenla-Haile , maArgs( rArgs ) 155*7ca83afaSAriel Constenla-Haile {} 156*7ca83afaSAriel Constenla-Haile }; 157*7ca83afaSAriel Constenla-Haile 158*7ca83afaSAriel Constenla-Haile DECL_STATIC_LINK( ToolboxController, ExecuteHdl_Impl, DispatchInfo* ); 159*7ca83afaSAriel Constenla-Haile 160cdf0e10cSrcweir typedef ::std::hash_map< ::rtl::OUString, 161cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >, 162cdf0e10cSrcweir ::rtl::OUStringHash, 163cdf0e10cSrcweir ::std::equal_to< ::rtl::OUString > > URLToDispatchMap; 164cdf0e10cSrcweir 165cdf0e10cSrcweir // methods to support status forwarder, known by the old sfx2 toolbox controller implementation 166cdf0e10cSrcweir void addStatusListener( const rtl::OUString& aCommandURL ); 167cdf0e10cSrcweir void removeStatusListener( const rtl::OUString& aCommandURL ); 168cdf0e10cSrcweir void bindListener(); 169cdf0e10cSrcweir void unbindListener(); 170cdf0e10cSrcweir sal_Bool isBound() const; 171cdf0e10cSrcweir sal_Bool hasBigImages() const; 172cdf0e10cSrcweir sal_Bool isHighContrast() const; 173d21a9fb0SAriel Constenla-Haile // TODO remove 174cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > getURLTransformer() const; 175d21a9fb0SAriel Constenla-Haile // TODO remove 176cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > getParent() const; 177cdf0e10cSrcweir 178cdf0e10cSrcweir sal_Bool m_bInitialized : 1, 179cdf0e10cSrcweir m_bDisposed : 1; 180d21a9fb0SAriel Constenla-Haile sal_uInt16 m_nToolBoxId; 181cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; 182cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; 183cdf0e10cSrcweir rtl::OUString m_aCommandURL; 184cdf0e10cSrcweir URLToDispatchMap m_aListenerMap; 185cdf0e10cSrcweir ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener 186d21a9fb0SAriel Constenla-Haile 187d21a9fb0SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParentWindow; 188d21a9fb0SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xUrlTransformer; 189d21a9fb0SAriel Constenla-Haile rtl::OUString m_sModuleName; 190d21a9fb0SAriel Constenla-Haile 191cdf0e10cSrcweir }; 192cdf0e10cSrcweir 193cdf0e10cSrcweir } 194cdf0e10cSrcweir 195cdf0e10cSrcweir #endif // _SVTOOLS_TOOLBOXCONTROLLER_HXX 196