nss: upgrade to release 3.73
[LibreOffice.git] / include / svtools / toolboxcontroller.hxx
blob0bf372e9502fd17238d1d256c81cc8aef7bef272
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 #pragma once
22 #include <svtools/svtdllapi.h>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include <com/sun/star/frame/XStatusListener.hpp>
25 #include <com/sun/star/frame/XToolbarController.hpp>
26 #include <com/sun/star/lang/XInitialization.hpp>
27 #include <com/sun/star/util/XUpdatable.hpp>
28 #include <com/sun/star/uno/Sequence.hxx>
29 #include <cppuhelper/implbase.hxx>
30 #include <cppuhelper/interfacecontainer.hxx>
31 #include <comphelper/broadcasthelper.hxx>
32 #include <comphelper/proparrhlp.hxx>
33 #include <comphelper/propertycontainer.hxx>
34 #include <cppuhelper/propshlp.hxx>
35 #include <tools/link.hxx>
37 #include <unordered_map>
39 namespace com :: sun :: star :: frame { class XDispatch; }
40 namespace com :: sun :: star :: frame { class XFrame; }
41 namespace com :: sun :: star :: frame { class XLayoutManager; }
42 namespace com :: sun :: star :: uno { class XComponentContext; }
43 namespace com :: sun :: star :: util { class XURLTransformer; }
45 class ToolBox;
47 namespace weld
49 class Builder;
50 class Toolbar;
53 namespace svt
56 typedef cppu::WeakImplHelper<
57 css::frame::XStatusListener, css::frame::XToolbarController,
58 css::lang::XInitialization, css::util::XUpdatable,
59 css::lang::XComponent >
60 ToolboxController_Base;
62 class SVT_DLLPUBLIC ToolboxController :
63 public ToolboxController_Base,
64 public ::comphelper::OMutexAndBroadcastHelper,
65 public ::comphelper::OPropertyContainer,
66 public ::comphelper::OPropertyArrayUsageHelper< ToolboxController >
68 private:
69 bool m_bSupportVisible;
70 public:
71 ToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
72 const css::uno::Reference< css::frame::XFrame >& xFrame,
73 const OUString& aCommandURL );
74 ToolboxController();
75 virtual ~ToolboxController() override;
77 css::uno::Reference< css::frame::XFrame > getFrameInterface() const;
78 const css::uno::Reference< css::uno::XComponentContext >& getContext() const;
79 css::uno::Reference< css::frame::XLayoutManager > getLayoutManager() const;
81 void updateStatus( const OUString& aCommandURL );
82 void updateStatus();
84 // XInterface
85 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
86 virtual void SAL_CALL acquire() throw () override;
87 virtual void SAL_CALL release() throw () override;
88 virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
90 // XInitialization
91 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
93 // XUpdatable
94 virtual void SAL_CALL update() override;
96 // XComponent
97 virtual void SAL_CALL dispose() override;
98 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
99 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
101 // XEventListener
102 using cppu::OPropertySetHelper::disposing;
103 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
105 // XStatusListener
106 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override = 0;
108 // XToolbarController
109 virtual void SAL_CALL execute( sal_Int16 KeyModifier ) override;
110 virtual void SAL_CALL click() override;
111 virtual void SAL_CALL doubleClick() override;
112 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override;
113 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) override;
114 // OPropertySetHelper
115 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
116 virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& rConvertedValue, css::uno::Any& rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue) override;
117 // XPropertySet
118 virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
119 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
120 // OPropertyArrayUsageHelper
121 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
124 const OUString& getCommandURL() const { return m_aCommandURL; }
125 const OUString& getModuleName() const { return m_sModuleName; }
127 void dispatchCommand( const OUString& sCommandURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs, const OUString &rTarget = OUString() );
129 void enable( bool bEnable );
131 bool IsInSidebar() const { return m_bSidebar; }
133 protected:
134 bool getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox );
135 struct Listener
137 Listener( const css::util::URL& rURL, const css::uno::Reference< css::frame::XDispatch >& rDispatch ) :
138 aURL( rURL ), xDispatch( rDispatch ) {}
140 css::util::URL aURL;
141 css::uno::Reference< css::frame::XDispatch > xDispatch;
144 struct DispatchInfo
146 css::uno::Reference< css::frame::XDispatch > mxDispatch;
147 const css::util::URL maURL;
148 const css::uno::Sequence< css::beans::PropertyValue > maArgs;
150 DispatchInfo( const css::uno::Reference< css::frame::XDispatch >& xDispatch,
151 const css::util::URL& rURL,
152 const css::uno::Sequence< css::beans::PropertyValue >& rArgs )
153 : mxDispatch( xDispatch )
154 , maURL( rURL )
155 , maArgs( rArgs )
159 DECL_STATIC_LINK( ToolboxController, ExecuteHdl_Impl, void*, void );
161 typedef std::unordered_map< OUString,
162 css::uno::Reference< css::frame::XDispatch > > URLToDispatchMap;
164 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
165 void addStatusListener( const OUString& aCommandURL );
166 void removeStatusListener( const OUString& aCommandURL );
167 void bindListener();
168 void unbindListener();
170 // TODO remove
171 const css::uno::Reference< css::util::XURLTransformer >& getURLTransformer() const { return m_xUrlTransformer;}
172 // TODO remove
173 const css::uno::Reference< css::awt::XWindow >& getParent() const { return m_xParentWindow;}
175 bool m_bInitialized,
176 m_bDisposed,
177 m_bSidebar;
178 sal_uInt16 m_nToolBoxId;
179 css::uno::Reference< css::frame::XFrame > m_xFrame;
180 css::uno::Reference< css::uno::XComponentContext > m_xContext;
181 OUString m_aCommandURL;
182 URLToDispatchMap m_aListenerMap;
183 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
185 css::uno::Reference< css::awt::XWindow > m_xParentWindow;
186 css::uno::Reference< css::util::XURLTransformer > m_xUrlTransformer;
187 OUString m_sModuleName;
188 weld::Toolbar* m_pToolbar;
189 weld::Builder* m_pBuilder;
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */