summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-11-20 12:25:18 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2015-11-20 13:24:10 +0000
commit4f69d0810e76f17b2a24f74dc99c4b8a31ac63b7 (patch)
treecd53fba26ef5287e3339e591bf1856e0423be43c /framework
parent6c1c9c4a57ca29c2ba8749a945a476f082ccac44 (diff)
Change the bits of the save button dynamically
When the save slot is disabled, we want it to become a dropdown only instead of disabling it. Change-Id: I22fb04c8a0c9afc0a1af8f031a584cdaa99484f9 Reviewed-on: https://gerrit.libreoffice.org/20079 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uielement/popuptoolbarcontroller.cxx58
-rw-r--r--framework/util/fwk.component4
2 files changed, 62 insertions, 0 deletions
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx
index 66c4ef45c587..4055cbcd8944 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -302,6 +302,56 @@ ToolBoxItemBits GenericPopupToolbarController::getDropDownStyle() const
return m_bSplitButton ? ToolBoxItemBits::DROPDOWN : ToolBoxItemBits::DROPDOWNONLY;
}
+class SaveToolbarController : public PopupMenuToolbarController
+{
+public:
+ SaveToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException, std::exception ) override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw ( css::uno::RuntimeException ) override;
+ virtual sal_Bool SAL_CALL supportsService( OUString const & rServiceName ) throw ( css::uno::RuntimeException ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw ( css::uno::RuntimeException ) override;
+};
+
+SaveToolbarController::SaveToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
+ : PopupMenuToolbarController( rxContext, ".uno:SaveAsMenu" )
+{
+}
+
+void SaveToolbarController::statusChanged( const css::frame::FeatureStateEvent& rEvent )
+ throw ( css::uno::RuntimeException, std::exception )
+{
+ ToolBox* pToolBox = nullptr;
+ sal_uInt16 nId = 0;
+ if ( getToolboxId( nId, &pToolBox ) )
+ {
+ pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) & ~( rEvent.IsEnabled ? ToolBoxItemBits::DROPDOWNONLY : ToolBoxItemBits::DROPDOWN ) );
+ pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ( rEvent.IsEnabled ? ToolBoxItemBits::DROPDOWN : ToolBoxItemBits::DROPDOWNONLY ) );
+ }
+}
+
+OUString SaveToolbarController::getImplementationName()
+ throw ( css::uno::RuntimeException )
+{
+ return OUString("com.sun.star.comp.framework.SaveToolbarController");
+}
+
+sal_Bool SaveToolbarController::supportsService( OUString const & rServiceName )
+ throw ( css::uno::RuntimeException )
+{
+ return cppu::supportsService( this, rServiceName );
+}
+
+css::uno::Sequence< OUString > SaveToolbarController::getSupportedServiceNames()
+ throw ( css::uno::RuntimeException )
+{
+ css::uno::Sequence<OUString> aRet { "com.sun.star.frame.ToolbarController" };
+ return aRet;
+}
+
class NewToolbarController : public PopupMenuToolbarController
{
public:
@@ -554,6 +604,14 @@ com_sun_star_comp_framework_GenericPopupToolbarController_get_implementation(
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_SaveToolbarController_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new SaveToolbarController(context));
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
org_apache_openoffice_comp_framework_NewToolbarController_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 4f5edfdf2318..418f8159d5f2 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -192,6 +192,10 @@
constructor="com_sun_star_comp_framework_GenericPopupToolbarController_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
+ <implementation name="com.sun.star.comp.framework.SaveToolbarController"
+ constructor="com_sun_star_comp_framework_SaveToolbarController_get_implementation">
+ <service name="com.sun.star.frame.ToolbarController"/>
+ </implementation>
<implementation name="org.apache.openoffice.comp.framework.NewToolbarController"
constructor="org_apache_openoffice_comp_framework_NewToolbarController_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>