Use o3tl::convert in Math
[LibreOffice.git] / sfx2 / inc / unoctitm.hxx
blob5c3926391e90fd361852b8cec1d6680212cf542a
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 <comphelper/multiinterfacecontainer2.hxx>
25 #include <cppuhelper/implbase.hxx>
26 #include <cppuhelper/interfacecontainer.hxx>
27 #include <cppuhelper/weakref.hxx>
29 #include <svl/lstner.hxx>
30 #include <sfx2/ctrlitem.hxx>
31 #include <osl/mutex.hxx>
33 namespace com::sun::star::frame { class XFrame; }
34 namespace com::sun::star::frame { class XNotifyingDispatch; }
35 namespace com::sun::star::frame { class XStatusListener; }
36 namespace com::sun::star::frame { struct FeatureStateEvent; }
38 class SfxBindings;
39 class SfxDispatcher;
40 class SfxSlot;
42 typedef comphelper::OMultiTypeInterfaceContainerHelperVar2<OUString>
43 SfxStatusDispatcher_Impl_ListenerContainer;
45 class SfxStatusDispatcher : public cppu::WeakImplHelper<css::frame::XNotifyingDispatch>
47 ::osl::Mutex aMutex;
48 SfxStatusDispatcher_Impl_ListenerContainer aListeners;
50 public:
52 SfxStatusDispatcher();
54 // XDispatch
55 virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL,
56 const css::uno::Sequence< css::beans::PropertyValue >& aArgs,
57 const css::uno::Reference< css::frame::XDispatchResultListener >& rListener ) override;
58 virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) override;
59 virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) override;
60 virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) override;
62 // Something else
63 void ReleaseAll();
64 SfxStatusDispatcher_Impl_ListenerContainer& GetListeners()
65 { return aListeners; }
68 class SfxSlotServer;
69 class SfxDispatchController_Impl;
70 class SfxOfficeDispatch final : public cppu::ImplInheritanceHelper<SfxStatusDispatcher, css::lang::XUnoTunnel>
72 friend class SfxDispatchController_Impl;
73 std::unique_ptr<SfxDispatchController_Impl> pImpl;
74 public:
75 SfxOfficeDispatch( SfxBindings& rBind,
76 SfxDispatcher* pDispat,
77 const SfxSlot* pSlot,
78 const css::util::URL& rURL );
79 SfxOfficeDispatch( SfxDispatcher* pDispat,
80 const SfxSlot* pSlot,
81 const css::util::URL& rURL );
82 virtual ~SfxOfficeDispatch() override;
84 virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL,
85 const css::uno::Sequence< css::beans::PropertyValue >& aArgs,
86 const css::uno::Reference< css::frame::XDispatchResultListener >& rListener ) override;
87 virtual void SAL_CALL dispatch( const css::util::URL& aURL,
88 const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) override;
89 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener > & xControl,
90 const css::util::URL& aURL) override;
92 // XUnoTunnel
93 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override ;
94 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
96 static bool IsMasterUnoCommand( const css::util::URL& aURL );
97 static OUString GetMasterUnoCommand( const css::util::URL& aURL );
99 void SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame);
101 void SetMasterUnoCommand( bool bSet );
103 SfxDispatcher* GetDispatcher_Impl();
105 sal_uInt16 GetId() const;
108 class SfxDispatchController_Impl final
109 : public SfxControllerItem
110 , public SfxListener
112 css::util::URL aDispatchURL;
113 SfxDispatcher* pDispatcher;
114 SfxBindings* pBindings;
115 const SfxPoolItem* pLastState;
116 SfxOfficeDispatch* pDispatch;
117 bool bMasterSlave;
118 bool bVisible;
119 css::uno::WeakReference< css::frame::XFrame > xFrame;
121 static void addParametersToArgs( const css::util::URL& aURL,
122 css::uno::Sequence< css::beans::PropertyValue >& rArgs );
123 static MapUnit GetCoreMetric( SfxItemPool const & rPool, sal_uInt16 nSlot );
125 void sendStatusChanged(const OUString& rURL, const css::frame::FeatureStateEvent& rEvent);
127 public:
128 SfxDispatchController_Impl( SfxOfficeDispatch* pDisp,
129 SfxBindings* pBind,
130 SfxDispatcher* pDispat,
131 const SfxSlot* pSlot,
132 const css::util::URL& rURL );
133 virtual ~SfxDispatchController_Impl() override;
135 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
137 static OUString getSlaveCommand( const css::util::URL& rURL );
139 void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, SfxSlotServer const * pServ );
140 virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override;
141 void setMasterSlaveCommand( bool bSet );
142 /// @throws css::uno::RuntimeException
143 void dispatch( const css::util::URL& aURL,
144 const css::uno::Sequence< css::beans::PropertyValue >& aArgs,
145 const css::uno::Reference< css::frame::XDispatchResultListener >& rListener );
146 /// @throws css::uno::RuntimeException
147 void addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL);
148 void UnBindController();
149 SfxDispatcher* GetDispatcher();
150 void SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame);
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */