diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2015-11-10 12:48:05 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2015-11-12 11:45:39 +0100 |
commit | ca36bcc05d7159fd4cd8e3489fdf4b4551b696d6 (patch) | |
tree | a46e6b888c9027b282e24b3bc63161be1cda796f /include | |
parent | 6adfbe62f6bb67d7d78c1561e9af5169d7f5bb9a (diff) |
Vcl: Disable buttons if the associated UNO slot is disabled
The goal of this is to have buttons in the Sidebar and NotebookBar automatically disabled
without an additional wrapper.
Change-Id: I8d25cdc6b87323e02daf6969c68582354f301375
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/buttonstatuslistener.hxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/vcl/buttonstatuslistener.hxx b/include/vcl/buttonstatuslistener.hxx new file mode 100644 index 000000000000..772189591114 --- /dev/null +++ b/include/vcl/buttonstatuslistener.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_BUTTONSTATUSLISTENER_HXX +#define INCLUDED_VCL_BUTTONSTATUSLISTENER_HXX + +#include <cppuhelper/implbase.hxx> +#include <vcl/button.hxx> + +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XDispatch.hpp> + + +class VCL_DLLPUBLIC ButtonStatusListener : public cppu::WeakImplHelper < css::frame::XStatusListener> +{ +public: + ButtonStatusListener(Button* button, const rtl::OUString& aCommand); + +private: + VclPtr<Button> mButton; /** The button on which actions are performed */ + + /** Dispatcher. Need to keep a reference to it as long as this StatusListener exists. */ + css::uno::Reference<css::frame::XDispatch> mxDispatch; + css::util::URL maCommandURL; + +public: + virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& rEvent) + throw(css::uno::RuntimeException, std::exception) override; + + virtual void SAL_CALL disposing(const css::lang::EventObject& /*Source*/) + throw( css::uno::RuntimeException, std::exception ) override; + + void dispose(); +}; + +#endif // INCLUDED_VCL_BUTTONSTATUSLISTENER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file |