1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
12 #include <svtools/toolboxcontroller.hxx>
13 #include <com/sun/star/frame/XDispatchProvider.hpp>
18 * A dispatcher that serves as a proxy for style commands with arguments
19 * i.e. .uno:StyleApply?... in order to provide useful status updates to
20 * generic UI elements such as toolbars or menubar. It listens to special
21 * status commands, and computes a boolean status out of them. Then it
22 * forwards that boolean status to the listener, as if it was the status
23 * of the original command.
25 * Note that the implementation is minimal: Although the UI element appears
26 * to be the owner of the dispatcher, it's still responsible, as usual, to
27 * call removeStatusListener same amount of times as addStatusListener,
28 * otherwise the dispatcher might not be destructed. In addition this
29 * implementation might hold a hard reference on the owner, and it's the
30 * responsibility of the owner to destroy the dispatcher first, in order
33 class StyleDispatcher final
: public cppu::WeakImplHelper
< css::frame::XDispatch
, css::frame::XStatusListener
>
36 StyleDispatcher( const css::uno::Reference
< css::frame::XFrame
>& rFrame
,
37 css::uno::Reference
< css::util::XURLTransformer
> xUrlTransformer
,
38 const css::util::URL
& rURL
);
41 void SAL_CALL
dispatch( const css::util::URL
& rURL
, const css::uno::Sequence
< css::beans::PropertyValue
>& rArguments
) override
;
42 void SAL_CALL
addStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& rListener
, const css::util::URL
& rURL
) override
;
43 void SAL_CALL
removeStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& rListener
, const css::util::URL
& rURL
) override
;
46 void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) override
;
49 void SAL_CALL
disposing( const css::lang::EventObject
& rSource
) override
;
52 OUString m_aStyleName
, m_aCommand
, m_aStatusCommand
;
53 css::uno::Reference
< css::util::XURLTransformer
> m_xUrlTransformer
;
54 css::uno::Reference
< css::frame::XDispatchProvider
> m_xFrame
;
55 css::uno::Reference
< css::frame::XDispatch
> m_xStatusDispatch
;
56 css::uno::Reference
< css::frame::XStatusListener
> m_xOwner
;
59 class StyleToolbarController final
: public svt::ToolboxController
62 StyleToolbarController( const css::uno::Reference
< css::uno::XComponentContext
>& rContext
,
63 const css::uno::Reference
< css::frame::XFrame
>& rFrame
,
64 const OUString
& rCommand
);
67 void SAL_CALL
update() override
;
70 void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) override
;
73 void SAL_CALL
dispose() override
;
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */