bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svtools / toolboxcontroller.hxx
blob5d86aeb359302e3e8afa439965e86458e8cda112
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVTOOLS_TOOLBOXCONTROLLER_HXX
21 #define INCLUDED_SVTOOLS_TOOLBOXCONTROLLER_HXX
23 #include <svtools/svtdllapi.h>
24 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <com/sun/star/frame/XStatusListener.hpp>
26 #include <com/sun/star/frame/XToolbarController.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/util/XUpdatable.hpp>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <cppuhelper/implbase.hxx>
31 #include <cppuhelper/interfacecontainer.hxx>
32 #include <comphelper/broadcasthelper.hxx>
33 #include <comphelper/proparrhlp.hxx>
34 #include <comphelper/propertycontainer.hxx>
35 #include <cppuhelper/propshlp.hxx>
36 #include <tools/link.hxx>
38 #include <unordered_map>
40 namespace com :: sun :: star :: frame { class XDispatch; }
41 namespace com :: sun :: star :: frame { class XFrame; }
42 namespace com :: sun :: star :: frame { class XLayoutManager; }
43 namespace com :: sun :: star :: uno { class XComponentContext; }
44 namespace com :: sun :: star :: util { class XURLTransformer; }
46 class ToolBox;
48 namespace svt
51 typedef cppu::WeakImplHelper<
52 css::frame::XStatusListener, css::frame::XToolbarController,
53 css::lang::XInitialization, css::util::XUpdatable,
54 css::lang::XComponent >
55 ToolboxController_Base;
57 class SVT_DLLPUBLIC ToolboxController :
58 public ToolboxController_Base,
59 public ::comphelper::OMutexAndBroadcastHelper,
60 public ::comphelper::OPropertyContainer,
61 public ::comphelper::OPropertyArrayUsageHelper< ToolboxController >
63 private:
64 bool m_bSupportVisible;
65 public:
66 ToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
67 const css::uno::Reference< css::frame::XFrame >& xFrame,
68 const OUString& aCommandURL );
69 ToolboxController();
70 virtual ~ToolboxController() override;
72 css::uno::Reference< css::frame::XFrame > getFrameInterface() const;
73 const css::uno::Reference< css::uno::XComponentContext >& getContext() const;
74 css::uno::Reference< css::frame::XLayoutManager > getLayoutManager() const;
76 void updateStatus( const OUString& aCommandURL );
77 void updateStatus();
79 // XInterface
80 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
81 virtual void SAL_CALL acquire() throw () override;
82 virtual void SAL_CALL release() throw () override;
83 virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
85 // XInitialization
86 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
88 // XUpdatable
89 virtual void SAL_CALL update() override;
91 // XComponent
92 virtual void SAL_CALL dispose() override;
93 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
94 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
96 // XEventListener
97 using cppu::OPropertySetHelper::disposing;
98 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
100 // XStatusListener
101 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override = 0;
103 // XToolbarController
104 virtual void SAL_CALL execute( sal_Int16 KeyModifier ) override;
105 virtual void SAL_CALL click() override;
106 virtual void SAL_CALL doubleClick() override;
107 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override;
108 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) override;
109 // OPropertySetHelper
110 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
111 virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& rConvertedValue, css::uno::Any& rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue) override;
112 // XPropertySet
113 virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
114 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
115 // OPropertyArrayUsageHelper
116 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
119 const OUString& getCommandURL() const { return m_aCommandURL; }
120 const OUString& getModuleName() const { return m_sModuleName; }
122 void dispatchCommand( const OUString& sCommandURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs, const OUString &rTarget = OUString() );
124 void enable( bool bEnable );
126 protected:
127 bool getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox );
128 struct Listener
130 Listener( const css::util::URL& rURL, const css::uno::Reference< css::frame::XDispatch >& rDispatch ) :
131 aURL( rURL ), xDispatch( rDispatch ) {}
133 css::util::URL const aURL;
134 css::uno::Reference< css::frame::XDispatch > xDispatch;
137 struct DispatchInfo
139 css::uno::Reference< css::frame::XDispatch > mxDispatch;
140 const css::util::URL maURL;
141 const css::uno::Sequence< css::beans::PropertyValue > maArgs;
143 DispatchInfo( const css::uno::Reference< css::frame::XDispatch >& xDispatch,
144 const css::util::URL& rURL,
145 const css::uno::Sequence< css::beans::PropertyValue >& rArgs )
146 : mxDispatch( xDispatch )
147 , maURL( rURL )
148 , maArgs( rArgs )
152 DECL_STATIC_LINK( ToolboxController, ExecuteHdl_Impl, void*, void );
154 typedef std::unordered_map< OUString,
155 css::uno::Reference< css::frame::XDispatch > > URLToDispatchMap;
157 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
158 void addStatusListener( const OUString& aCommandURL );
159 void removeStatusListener( const OUString& aCommandURL );
160 void bindListener();
161 void unbindListener();
162 bool isBound() const;
163 // TODO remove
164 const css::uno::Reference< css::util::XURLTransformer >& getURLTransformer() const { return m_xUrlTransformer;}
165 // TODO remove
166 const css::uno::Reference< css::awt::XWindow >& getParent() const { return m_xParentWindow;}
168 bool m_bInitialized : 1,
169 m_bDisposed : 1;
170 sal_uInt16 m_nToolBoxId;
171 css::uno::Reference< css::frame::XFrame > m_xFrame;
172 css::uno::Reference< css::uno::XComponentContext > m_xContext;
173 OUString m_aCommandURL;
174 URLToDispatchMap m_aListenerMap;
175 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
177 css::uno::Reference< css::awt::XWindow > m_xParentWindow;
178 css::uno::Reference< css::util::XURLTransformer > m_xUrlTransformer;
179 OUString m_sModuleName;
184 #endif // INCLUDED_SVTOOLS_TOOLBOXCONTROLLER_HXX
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */