Bump version to 21.06.18.1
[LibreOffice.git] / sfx2 / inc / unoctitm.hxx
blob263958e9e56cf04f8ab2b26c95e078b0d548aaa3
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 .
19 #pragma once
21 #include <memory>
22 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
23 #include <com/sun/star/lang/XUnoTunnel.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include <cppuhelper/interfacecontainer.hxx>
26 #include <cppuhelper/weakref.hxx>
28 #include <svl/lstner.hxx>
29 #include <sfx2/ctrlitem.hxx>
30 #include <osl/mutex.hxx>
32 namespace com::sun::star::frame { class XFrame; }
33 namespace com::sun::star::frame { class XNotifyingDispatch; }
34 namespace com::sun::star::frame { class XStatusListener; }
35 namespace com::sun::star::frame { struct FeatureStateEvent; }
37 class SfxBindings;
38 class SfxDispatcher;
39 class SfxSlot;
41 typedef cppu::OMultiTypeInterfaceContainerHelperVar<OUString>
42 SfxStatusDispatcher_Impl_ListenerContainer;
44 class SfxStatusDispatcher : public cppu::WeakImplHelper<css::frame::XNotifyingDispatch>
46 ::osl::Mutex aMutex;
47 SfxStatusDispatcher_Impl_ListenerContainer aListeners;
49 public:
51 SfxStatusDispatcher();
53 // XDispatch
54 virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL,
55 const css::uno::Sequence< css::beans::PropertyValue >& aArgs,
56 const css::uno::Reference< css::frame::XDispatchResultListener >& rListener ) override;
57 virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) override;
58 virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) override;
59 virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) override;
61 // Something else
62 void ReleaseAll();
63 SfxStatusDispatcher_Impl_ListenerContainer& GetListeners()
64 { return aListeners; }
67 class SfxSlotServer;
68 class SfxDispatchController_Impl;
69 class SfxOfficeDispatch final : public cppu::ImplInheritanceHelper<SfxStatusDispatcher, css::lang::XUnoTunnel>
71 friend class SfxDispatchController_Impl;
72 std::unique_ptr<SfxDispatchController_Impl> pImpl;
73 public:
74 SfxOfficeDispatch( SfxBindings& rBind,
75 SfxDispatcher* pDispat,
76 const SfxSlot* pSlot,
77 const css::util::URL& rURL );
78 SfxOfficeDispatch( SfxDispatcher* pDispat,
79 const SfxSlot* pSlot,
80 const css::util::URL& rURL );
81 virtual ~SfxOfficeDispatch() override;
83 virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL,
84 const css::uno::Sequence< css::beans::PropertyValue >& aArgs,
85 const css::uno::Reference< css::frame::XDispatchResultListener >& rListener ) override;
86 virtual void SAL_CALL dispatch( const css::util::URL& aURL,
87 const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) override;
88 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener > & xControl,
89 const css::util::URL& aURL) override;
91 // XUnoTunnel
92 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override ;
93 static const css::uno::Sequence< sal_Int8 >& impl_getStaticIdentifier();
95 static bool IsMasterUnoCommand( const css::util::URL& aURL );
96 static OUString GetMasterUnoCommand( const css::util::URL& aURL );
98 void SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame);
100 void SetMasterUnoCommand( bool bSet );
102 SfxDispatcher* GetDispatcher_Impl();
104 sal_uInt16 GetId() const;
107 class SfxDispatchController_Impl
108 : public SfxControllerItem
109 , public SfxListener
111 css::util::URL aDispatchURL;
112 SfxDispatcher* pDispatcher;
113 SfxBindings* pBindings;
114 const SfxPoolItem* pLastState;
115 SfxOfficeDispatch* pDispatch;
116 bool bMasterSlave;
117 bool bVisible;
118 css::uno::WeakReference< css::frame::XFrame > xFrame;
120 static void addParametersToArgs( const css::util::URL& aURL,
121 css::uno::Sequence< css::beans::PropertyValue >& rArgs );
122 static MapUnit GetCoreMetric( SfxItemPool const & rPool, sal_uInt16 nSlot );
124 void sendStatusChanged(const OUString& rURL, const css::frame::FeatureStateEvent& rEvent);
126 public:
127 SfxDispatchController_Impl( SfxOfficeDispatch* pDisp,
128 SfxBindings* pBind,
129 SfxDispatcher* pDispat,
130 const SfxSlot* pSlot,
131 const css::util::URL& rURL );
132 virtual ~SfxDispatchController_Impl() override;
134 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
136 static OUString getSlaveCommand( const css::util::URL& rURL );
138 void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, SfxSlotServer const * pServ );
139 virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override;
140 void setMasterSlaveCommand( bool bSet );
141 /// @throws css::uno::RuntimeException
142 void dispatch( const css::util::URL& aURL,
143 const css::uno::Sequence< css::beans::PropertyValue >& aArgs,
144 const css::uno::Reference< css::frame::XDispatchResultListener >& rListener );
145 /// @throws css::uno::RuntimeException
146 void addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL);
147 void UnBindController();
148 SfxDispatcher* GetDispatcher();
149 void SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame);
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */