diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2020-08-13 01:05:59 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2020-08-14 17:03:55 +0200 |
commit | 7bb20ab2e84cf4d84d24bfcd8103946e92f2ae06 (patch) | |
tree | e86cc948a970fb0f68af2dc229527ac79992cb51 /framework/source/uielement/generictoolbarcontroller.cxx | |
parent | c5301f215fec9016c3a75ff4a6a0c6c22f152718 (diff) |
One toolbar generic controller is enough
The one from framework is more feature complete, so use that one.
Change-Id: I499f0ae1d20c588cfc04beebc643819559325882
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100726
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'framework/source/uielement/generictoolbarcontroller.cxx')
-rw-r--r-- | framework/source/uielement/generictoolbarcontroller.cxx | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx index 8bea883d90d6..f8dc874b2902 100644 --- a/framework/source/uielement/generictoolbarcontroller.cxx +++ b/framework/source/uielement/generictoolbarcontroller.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <uielement/generictoolbarcontroller.hxx> +#include <framework/generictoolbarcontroller.hxx> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> @@ -28,6 +28,7 @@ #include <vcl/svapp.hxx> #include <vcl/toolbox.hxx> +#include <vcl/weld.hxx> #include <tools/urlobj.hxx> #include <strings.hrc> #include <classes/fwkresid.hxx> @@ -92,6 +93,20 @@ GenericToolbarController::GenericToolbarController( const Reference< XComponentC { if ( m_bEnumCommand ) addStatusListener( getMasterCommand( aCommand ) ); + + addStatusListener( aCommand ); + + // Initialization is done through ctor + m_bInitialized = true; +} + +GenericToolbarController::GenericToolbarController( const Reference< XComponentContext >& rxContext, + const Reference< XFrame >& rFrame, + weld::Toolbar& rToolbar, + const OUString& aCommand ) : + GenericToolbarController( rxContext, rFrame, nullptr, 0, aCommand ) +{ + m_pToolbar = &rToolbar; } GenericToolbarController::~GenericToolbarController() @@ -104,6 +119,7 @@ void SAL_CALL GenericToolbarController::dispose() svt::ToolboxController::dispose(); + m_pToolbar = nullptr; m_xToolbar.clear(); m_nID = 0; } @@ -159,6 +175,30 @@ void GenericToolbarController::statusChanged( const FeatureStateEvent& Event ) if ( m_bDisposed ) return; + if ( m_pToolbar ) + { + OString sId = m_aCommandURL.toUtf8(); + + m_pToolbar->set_item_sensitive(sId, Event.IsEnabled); + + bool bValue; + OUString aStrValue; + + if ( Event.State >>= bValue ) + { + // Boolean, treat it as checked/unchecked + m_pToolbar->set_item_active(sId, bValue); + } + else if ( Event.State >>= aStrValue ) + { + m_pToolbar->set_item_label(sId, aStrValue); + } + else + m_pToolbar->set_item_active(sId, false); + + return; + } + if ( !m_xToolbar ) return; |