LibreOffice Module sfx2 (master) 1
unoctitm.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <memory>
22#include <com/sun/star/frame/XNotifyingDispatch.hpp>
26
27#include <svl/lstner.hxx>
28#include <sfx2/ctrlitem.hxx>
29#include <mutex>
30
31namespace com::sun::star::frame { class XFrame; }
32namespace com::sun::star::frame { class XNotifyingDispatch; }
33namespace com::sun::star::frame { class XStatusListener; }
34namespace com::sun::star::frame { struct FeatureStateEvent; }
35
36class SfxBindings;
37class SfxDispatcher;
38class SfxSlot;
39
42
43class SfxStatusDispatcher : public cppu::WeakImplHelper<css::frame::XNotifyingDispatch>
44{
45protected:
46 std::mutex maMutex;
48
49public:
50
52
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;
60
61 // Something else
62 void ReleaseAll();
63 void sendStatusChanged(const OUString& rURL, const css::frame::FeatureStateEvent& rEvent);
64 std::vector<OUString> getContainedTypes() { std::unique_lock g(maMutex); return maListeners.getContainedTypes(g); };
65};
66
67class SfxSlotServer;
69class SfxOfficeDispatch final : public cppu::ImplInheritanceHelper<SfxStatusDispatcher>
70{
72 std::unique_ptr<SfxDispatchController_Impl> pImpl;
73public:
75 SfxDispatcher* pDispat,
76 const SfxSlot* pSlot,
77 const css::util::URL& rURL );
79 const SfxSlot* pSlot,
80 const css::util::URL& rURL );
81 virtual ~SfxOfficeDispatch() override;
82
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;
90
91 static bool IsMasterUnoCommand( const css::util::URL& aURL );
92 static OUString GetMasterUnoCommand( const css::util::URL& aURL );
93
94 void SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame);
95
96 void SetMasterUnoCommand( bool bSet );
97
99
100 sal_uInt16 GetId() const;
101};
102
104 : public SfxControllerItem
105 , public SfxListener
106{
107 css::util::URL aDispatchURL;
114 css::uno::WeakReference< css::frame::XFrame > xFrame;
115
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 );
119
120 void sendStatusChanged(const OUString& rURL, const css::frame::FeatureStateEvent& rEvent);
121
122public:
124 SfxBindings* pBind,
125 SfxDispatcher* pDispat,
126 const SfxSlot* pSlot,
127 css::util::URL aURL );
128 virtual ~SfxDispatchController_Impl() override;
129
130 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
131
132 static OUString getSlaveCommand( const css::util::URL& rURL );
133
134 void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, SfxSlotServer const * pServ );
135 virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override;
136 void setMasterSlaveCommand( bool bSet );
138 void dispatch( const css::util::URL& aURL,
139 const css::uno::Sequence< css::beans::PropertyValue >& aArgs,
140 const css::uno::Reference< css::frame::XDispatchResultListener >& rListener );
142 void addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL);
143 void UnBindController();
145 void SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame);
146};
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
MapUnit GetCoreMetric() const
Definition: ctrlitem.cxx:302
void sendStatusChanged(const OUString &rURL, const css::frame::FeatureStateEvent &rEvent)
Definition: unoctitm.cxx:797
css::uno::WeakReference< css::frame::XFrame > xFrame
Definition: unoctitm.hxx:114
void setMasterSlaveCommand(bool bSet)
Definition: unoctitm.cxx:398
static OUString getSlaveCommand(const css::util::URL &rURL)
Definition: unoctitm.cxx:500
virtual ~SfxDispatchController_Impl() override
Definition: unoctitm.cxx:378
SfxDispatcher * pDispatcher
Definition: unoctitm.hxx:108
SfxDispatcher * GetDispatcher()
Definition: unoctitm.cxx:747
const SfxPoolItem * pLastState
Definition: unoctitm.hxx:110
static void addParametersToArgs(const css::util::URL &aURL, css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: unoctitm.cxx:414
void SetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
Definition: unoctitm.cxx:393
void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState, SfxSlotServer const *pServ)
Definition: unoctitm.cxx:802
void dispatch(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs, const css::uno::Reference< css::frame::XDispatchResultListener > &rListener)
Definition: unoctitm.cxx:523
void addStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL)
Definition: unoctitm.cxx:754
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: unoctitm.cxx:886
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: unoctitm.cxx:368
css::util::URL aDispatchURL
Definition: unoctitm.hxx:107
SfxDispatchController_Impl(SfxOfficeDispatch *pDisp, SfxBindings *pBind, SfxDispatcher *pDispat, const SfxSlot *pSlot, css::util::URL aURL)
Definition: unoctitm.cxx:324
SfxOfficeDispatch * pDispatch
Definition: unoctitm.hxx:111
virtual ~SfxOfficeDispatch() override
Definition: unoctitm.cxx:189
std::unique_ptr< SfxDispatchController_Impl > pImpl
Definition: unoctitm.hxx:72
sal_uInt16 GetId() const
Definition: unoctitm.cxx:288
SfxDispatcher * GetDispatcher_Impl()
Definition: unoctitm.cxx:283
virtual void SAL_CALL dispatch(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
Definition: unoctitm.cxx:227
void SetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
Definition: unoctitm.cxx:293
void SetMasterUnoCommand(bool bSet)
Definition: unoctitm.cxx:299
SfxOfficeDispatch(SfxBindings &rBind, SfxDispatcher *pDispat, const SfxSlot *pSlot, const css::util::URL &rURL)
Definition: unoctitm.cxx:176
static OUString GetMasterUnoCommand(const css::util::URL &aURL)
Definition: unoctitm.cxx:311
virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL) override
Definition: unoctitm.cxx:270
static bool IsMasterUnoCommand(const css::util::URL &aURL)
Definition: unoctitm.cxx:306
virtual void SAL_CALL dispatchWithNotification(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs, const css::uno::Reference< css::frame::XDispatchResultListener > &rListener) override
Definition: unoctitm.cxx:256
Definition: msg.hxx:184
virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL) override
Definition: unoctitm.cxx:152
void sendStatusChanged(const OUString &rURL, const css::frame::FeatureStateEvent &rEvent)
Definition: unoctitm.cxx:123
std::mutex maMutex
Definition: unoctitm.hxx:46
virtual void SAL_CALL dispatchWithNotification(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs, const css::uno::Reference< css::frame::XDispatchResultListener > &rListener) override
Definition: unoctitm.cxx:141
SfxStatusDispatcher_Impl_ListenerContainer maListeners
Definition: unoctitm.hxx:47
virtual void SAL_CALL dispatch(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
Definition: unoctitm.cxx:137
virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL) override
Definition: unoctitm.cxx:169
std::vector< OUString > getContainedTypes()
Definition: unoctitm.hxx:64
std::vector< key > getContainedTypes(std::unique_lock< std::mutex > &rGuard) const
MapUnit
SfxItemState
comphelper::OMultiTypeInterfaceContainerHelperVar4< OUString, css::frame::XStatusListener > SfxStatusDispatcher_Impl_ListenerContainer
Definition: unoctitm.hxx:38