1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SFX2_UNOCTITM_HXX
20 #define INCLUDED_SFX2_UNOCTITM_HXX
23 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
24 #include <com/sun/star/lang/XUnoTunnel.hpp>
25 #include <cppuhelper/implbase.hxx>
26 #include <cppuhelper/interfacecontainer.hxx>
27 #include <cppuhelper/weakref.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
; }
41 typedef cppu::OMultiTypeInterfaceContainerHelperVar
<OUString
>
42 SfxStatusDispatcher_Impl_ListenerContainer
;
44 class SfxStatusDispatcher
: public cppu::WeakImplHelper
<css::frame::XNotifyingDispatch
>
47 SfxStatusDispatcher_Impl_ListenerContainer aListeners
;
51 SfxStatusDispatcher();
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
;
63 SfxStatusDispatcher_Impl_ListenerContainer
& GetListeners()
64 { return aListeners
; }
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
;
74 SfxOfficeDispatch( SfxBindings
& rBind
,
75 SfxDispatcher
* pDispat
,
77 const css::util::URL
& rURL
);
78 SfxOfficeDispatch( SfxDispatcher
* pDispat
,
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
;
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();
105 class SfxDispatchController_Impl
: public SfxControllerItem
107 css::util::URL aDispatchURL
;
108 SfxDispatcher
* pDispatcher
;
109 SfxBindings
* pBindings
;
110 const SfxPoolItem
* pLastState
;
111 SfxOfficeDispatch
* pDispatch
;
114 css::uno::WeakReference
< css::frame::XFrame
> xFrame
;
116 static void addParametersToArgs( const css::util::URL
& aURL
,
117 css::uno::Sequence
< css::beans::PropertyValue
>& rArgs
);
118 static MapUnit
GetCoreMetric( SfxItemPool
const & rPool
, sal_uInt16 nSlot
);
120 void sendStatusChanged(const OUString
& rURL
, const css::frame::FeatureStateEvent
& rEvent
);
123 SfxDispatchController_Impl( SfxOfficeDispatch
* pDisp
,
125 SfxDispatcher
* pDispat
,
126 const SfxSlot
* pSlot
,
127 const css::util::URL
& rURL
);
128 virtual ~SfxDispatchController_Impl() override
;
130 static OUString
getSlaveCommand( const css::util::URL
& rURL
);
132 void StateChanged( sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
, SfxSlotServer
const * pServ
);
133 virtual void StateChanged( sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
) override
;
134 void setMasterSlaveCommand( bool bSet
);
135 /// @throws css::uno::RuntimeException
136 void dispatch( const css::util::URL
& aURL
,
137 const css::uno::Sequence
< css::beans::PropertyValue
>& aArgs
,
138 const css::uno::Reference
< css::frame::XDispatchResultListener
>& rListener
);
139 /// @throws css::uno::RuntimeException
140 void addStatusListener(const css::uno::Reference
< css::frame::XStatusListener
> & xControl
, const css::util::URL
& aURL
);
141 void UnBindController();
142 SfxDispatcher
* GetDispatcher();
143 void SetFrame(const css::uno::Reference
< css::frame::XFrame
>& xFrame
);
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */