summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2015-12-04 16:28:27 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2015-12-07 11:29:42 +0000
commitc5fe98905deac6de4f9e76a17097ce83fe381ac3 (patch)
tree06fd82303f00a8e64e0498c817944b98fc2ec36d /vcl/source
parentebe80ac6713b67b1801ede3d1e9038cb2c93cb11 (diff)
Make buttonstatuslistener a generic listener for any widgets
Change-Id: I966b06e1169f8a06d08be811f78e98a2e3d7580c Reviewed-on: https://gerrit.libreoffice.org/20401 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/control/button.cxx12
-rw-r--r--vcl/source/control/buttonstatuslistener.cxx66
2 files changed, 6 insertions, 72 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index b3390a37cf19..d831794b0c54 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -32,10 +32,10 @@
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
#include <vcl/button.hxx>
-#include <vcl/buttonstatuslistener.hxx>
#include <vcl/salnativewidgets.hxx>
#include <vcl/edit.hxx>
#include <vcl/layout.hxx>
+#include <vcl/vclstatuslistener.hxx>
#include <svids.hrc>
#include <svdata.hxx>
@@ -82,7 +82,7 @@ public:
SymbolAlign meSymbolAlign;
/** StatusListener. Updates the button as the slot state changes */
- rtl::Reference<ButtonStatusListener> mpStatusListener;
+ rtl::Reference<VclStatusListener<Button>> mpStatusListener;
};
ImplCommonButtonData::ImplCommonButtonData() : maFocusRect(), mnSeparatorX(0), mnButtonState(DrawButtonFlags::NONE),
@@ -117,7 +117,7 @@ void Button::SetCommandHandler(const OUString& aCommand)
maCommand = aCommand;
SetClickHdl( LINK( this, Button, dispatchCommandHandler) );
- mpButtonData->mpStatusListener = new ButtonStatusListener(this, aCommand);
+ mpButtonData->mpStatusListener = new VclStatusListener<Button>(this, aCommand);
}
void Button::Click()
@@ -617,7 +617,7 @@ bool Button::set_property(const OString &rKey, const OString &rValue)
return true;
}
-void Button::SetStateUno(const css::frame::FeatureStateEvent& rEvent)
+void Button::statusChanged(const css::frame::FeatureStateEvent& rEvent)
{
Enable(rEvent.IsEnabled);
}
@@ -1606,9 +1606,9 @@ void PushButton::SetState( TriState eState )
}
}
-void PushButton::SetStateUno(const css::frame::FeatureStateEvent& rEvent)
+void PushButton::statusChanged(const css::frame::FeatureStateEvent& rEvent)
{
- Button::SetStateUno(rEvent);
+ Button::statusChanged(rEvent);
if (rEvent.State.has<bool>())
SetPressed(rEvent.State.get<bool>());
}
diff --git a/vcl/source/control/buttonstatuslistener.cxx b/vcl/source/control/buttonstatuslistener.cxx
deleted file mode 100644
index bad5452daacf..000000000000
--- a/vcl/source/control/buttonstatuslistener.cxx
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- 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/.
- */
-
-#include <vcl/buttonstatuslistener.hxx>
-#include <comphelper/processfactory.hxx>
-
-#include <com/sun/star/frame/Desktop.hpp>
-#include <com/sun/star/frame/XDispatch.hpp>
-#include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/frame/XStatusListener.hpp>
-#include <com/sun/star/util/URL.hpp>
-#include <com/sun/star/util/URLTransformer.hpp>
-
-ButtonStatusListener::ButtonStatusListener(Button* button, const rtl::OUString& aCommand) {
- mButton = button;
-
- css::uno::Reference<css::uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
- css::uno::Reference<css::frame::XDesktop2> xDesktop = css::frame::Desktop::create(xContext);
-
- css::uno::Reference<css::frame::XFrame> xFrame(xDesktop->getActiveFrame());
- if (!xFrame.is())
- xFrame = css::uno::Reference<css::frame::XFrame>(xDesktop, css::uno::UNO_QUERY);
-
- css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(xFrame, css::uno::UNO_QUERY);
- if (!xDispatchProvider.is())
- return;
-
- maCommandURL.Complete = aCommand;
- css::uno::Reference<css::util::XURLTransformer> xParser = css::util::URLTransformer::create(xContext);
- xParser->parseStrict(maCommandURL);
-
- mxDispatch = xDispatchProvider->queryDispatch(maCommandURL, "", 0);
- if (!mxDispatch.is())
- return;
-
- mxDispatch->addStatusListener(this, maCommandURL);
-}
-
-void ButtonStatusListener::statusChanged(const css::frame::FeatureStateEvent& rEvent)
- throw(css::uno::RuntimeException, std::exception)
-{
- mButton->SetStateUno(rEvent);
-}
-
-void ButtonStatusListener::disposing(const css::lang::EventObject& /*Source*/)
- throw( css::uno::RuntimeException, std::exception )
-{
- mxDispatch.clear();
-}
-
-void ButtonStatusListener::dispose()
-{
- if (mxDispatch.is()) {
- mxDispatch->removeStatusListener(this, maCommandURL);
- mxDispatch.clear();
- }
- mButton.clear();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file