Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _SVTOOLS_TOOLBOXCONTROLLER_HXX
21 : #define _SVTOOLS_TOOLBOXCONTROLLER_HXX
22 :
23 : #include "svtools/svtdllapi.h"
24 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 : #include <com/sun/star/lang/XInitialization.hpp>
26 : #include <com/sun/star/util/XUpdatable.hpp>
27 : #include <com/sun/star/frame/XFrame.hpp>
28 : #include <com/sun/star/frame/XDispatch.hpp>
29 : #include <com/sun/star/frame/XStatusListener.hpp>
30 : #include <com/sun/star/frame/XToolbarController.hpp>
31 : #include <com/sun/star/util/XURLTransformer.hpp>
32 : #include <com/sun/star/frame/XLayoutManager.hpp>
33 : #include <cppuhelper/weak.hxx>
34 : #include <cppuhelper/interfacecontainer.hxx>
35 : #include <comphelper/broadcasthelper.hxx>
36 : #include <comphelper/proparrhlp.hxx>
37 : #include <comphelper/property.hxx>
38 : #include <comphelper/propertycontainer.hxx>
39 : #include <cppuhelper/propshlp.hxx>
40 :
41 : #include <boost/unordered_map.hpp>
42 :
43 : class ToolBox;
44 :
45 : namespace svt
46 : {
47 : struct ToolboxController_Impl;
48 :
49 : class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusListener,
50 : public ::com::sun::star::frame::XToolbarController,
51 : public ::com::sun::star::lang::XInitialization,
52 : public ::com::sun::star::util::XUpdatable,
53 : public ::com::sun::star::lang::XComponent,
54 : public ::comphelper::OMutexAndBroadcastHelper,//shizhoubo
55 : public ::comphelper::OPropertyContainer,//shizhoubo
56 : public ::comphelper::OPropertyArrayUsageHelper< ToolboxController >,//shizhoubo
57 : public ::cppu::OWeakObject
58 : {
59 : private:
60 : sal_Bool m_bSupportVisible; //shizhoubo
61 : public:
62 : ToolboxController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
63 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
64 : const rtl::OUString& aCommandURL );
65 : ToolboxController();
66 : virtual ~ToolboxController();
67 :
68 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > getFrameInterface() const;
69 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getServiceManager() const;
70 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > getLayoutManager() const;
71 :
72 : void updateStatus( const rtl::OUString aCommandURL );
73 : void updateStatus();
74 :
75 : // XInterface
76 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
77 : virtual void SAL_CALL acquire() throw ();
78 : virtual void SAL_CALL release() throw ();
79 :
80 : // XInitialization
81 : 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);
82 :
83 : // XUpdatable
84 : virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException);
85 :
86 : // XComponent
87 : virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
88 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
89 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
90 :
91 : // XEventListener
92 : using cppu::OPropertySetHelper::disposing;
93 : virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
94 :
95 : // XStatusListener
96 : virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) = 0;
97 :
98 : // XToolbarController
99 : virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException);
100 : virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
101 : virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
102 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
103 : 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);
104 : // OPropertySetHelper //shizhoubo
105 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const com::sun::star::uno::Any& rValue ) throw(com::sun::star::uno::Exception);
106 : 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);
107 : // XPropertySet //shizhoubo
108 : virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
109 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
110 : // OPropertyArrayUsageHelper //shizhoubo
111 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
112 :
113 :
114 0 : const rtl::OUString& getCommandURL() const { return m_aCommandURL; }
115 : const rtl::OUString& getModuleName() const;
116 :
117 : void dispatchCommand( const ::rtl::OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
118 :
119 : void enable( bool bEnable );
120 :
121 : protected:
122 : bool getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox );
123 : void setSupportVisibleProperty(sal_Bool bValue); //shizhoubo
124 7080 : struct Listener
125 : {
126 2360 : Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :
127 2360 : aURL( rURL ), xDispatch( rDispatch ) {}
128 :
129 : ::com::sun::star::util::URL aURL;
130 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
131 : };
132 :
133 : typedef ::boost::unordered_map< ::rtl::OUString,
134 : com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >,
135 : ::rtl::OUStringHash,
136 : ::std::equal_to< ::rtl::OUString > > URLToDispatchMap;
137 :
138 : // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
139 : void addStatusListener( const rtl::OUString& aCommandURL );
140 : void removeStatusListener( const rtl::OUString& aCommandURL );
141 : void bindListener();
142 : void unbindListener();
143 : sal_Bool isBound() const;
144 : sal_Bool hasBigImages() const;
145 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > getURLTransformer() const;
146 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > getParent() const;
147 :
148 : sal_Bool m_bInitialized : 1,
149 : m_bDisposed : 1;
150 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
151 : ToolboxController_Impl* m_pImpl;
152 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
153 : rtl::OUString m_aCommandURL;
154 : URLToDispatchMap m_aListenerMap;
155 : ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
156 : };
157 :
158 : }
159 :
160 : #endif // _SVTOOLS_TOOLBOXCONTROLLER_HXX
161 :
162 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|