[Libreoffice-commits] core.git: framework/source framework/util officecfg/registry

Maxim Monastirsky momonasmon at gmail.com
Fri Nov 20 05:24:38 PST 2015


 framework/source/uielement/popuptoolbarcontroller.cxx           |   58 ++++++++++
 framework/util/fwk.component                                    |    4 
 officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu |    5 
 3 files changed, 63 insertions(+), 4 deletions(-)

New commits:
commit 4f69d0810e76f17b2a24f74dc99c4b8a31ac63b7
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Fri Nov 20 12:25:18 2015 +0200

    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 at cib.de>
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx
index 66c4ef4..4055cbc 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 4f5edfd..418f815 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"/>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index c603356..23b95fe 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -942,10 +942,7 @@
           <value/>
         </prop>
         <prop oor:name="Controller">
-          <value>com.sun.star.comp.framework.GenericPopupToolbarController</value>
-        </prop>
-        <prop oor:name="Value">
-          <value>.uno:SaveAsMenu</value>
+          <value>com.sun.star.comp.framework.SaveToolbarController</value>
         </prop>
       </node>
       <node oor:name="org.apache.openoffice.comp.framework.NewToolbarController" oor:op="replace">


More information about the Libreoffice-commits mailing list