[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - framework/inc framework/source include/vcl vcl/Library_vcl.mk vcl/source

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Fri Dec 11 02:28:26 PST 2015


 framework/inc/uielement/toolbarmanager.hxx    |   13 --
 framework/source/uielement/toolbarmanager.cxx |  145 --------------------------
 include/vcl/button.hxx                        |    4 
 include/vcl/buttonstatuslistener.hxx          |   45 --------
 include/vcl/commandinfoprovider.hxx           |    4 
 include/vcl/toolbox.hxx                       |   13 +-
 include/vcl/vclstatuslistener.hxx             |   99 +++++++++++++++++
 vcl/Library_vcl.mk                            |    1 
 vcl/source/control/button.cxx                 |   12 +-
 vcl/source/control/buttonstatuslistener.cxx   |   66 -----------
 vcl/source/helper/commandinfoprovider.cxx     |   36 ++++++
 vcl/source/window/toolbox.cxx                 |   32 ++++-
 vcl/source/window/toolbox2.cxx                |   11 +
 13 files changed, 197 insertions(+), 284 deletions(-)

New commits:
commit df9e93750bb7ff39f4346f0e23a0493409b31c2b
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Fri Dec 4 16:28:27 2015 +0100

    tdf#85767 Enable rotated/flipped icons in the Sidebar
    
    This is a combination of 3 commits:
    * Make buttonstatuslistener a generic listener for any widgets
      ac97f32307feb488c86d6fa962258fe79320d31b
    * Move icon rotation/flip handling from ToolbarManager to vcl's Toolbar
      c5fe98905deac6de4f9e76a17097ce83fe381ac3
    * These should still be virtual.
      e20df218257c45c5daa234daafac9609d53aa77f
    
    Change-Id: I34e2446660ec94d60654b4db40ce1bbb8014477f
    Reviewed-on: https://gerrit.libreoffice.org/20466
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx
index 655228a..f109f14 100644
--- a/framework/inc/uielement/toolbarmanager.hxx
+++ b/framework/inc/uielement/toolbarmanager.hxx
@@ -61,7 +61,6 @@ namespace framework
 
 typedef ::cppu::WeakImplHelper<
            css::frame::XFrameActionListener,
-           css::frame::XStatusListener,
            css::lang::XComponent,
            css::ui::XUIConfigurationListener
         > ToolbarManager_Base;
@@ -80,9 +79,6 @@ class ToolBarManager : public ToolbarManager_Base
         // XFrameActionListener
         virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& Action ) throw ( css::uno::RuntimeException, std::exception ) override;
 
-        // XStatusListener
-        virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override;
-
         // XEventListener
         virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception ) override;
 
@@ -147,8 +143,6 @@ class ToolBarManager : public ToolbarManager_Base
         void UpdateController( css::uno::Reference< css::frame::XToolbarController > xController);
         //end
         void AddFrameActionListener();
-        void AddImageOrientationListener();
-        void UpdateImageOrientation();
         void ImplClearPopupMenu( ToolBox *pToolBar );
         void RequestImages();
         ToolBoxItemBits ConvertStyleToToolboxItemBits( sal_Int32 nStyle );
@@ -170,11 +164,7 @@ class ToolBarManager : public ToolbarManager_Base
              m_bSmallSymbols : 1,
              m_bAddedToTaskPaneList : 1,
              m_bFrameActionRegistered : 1,
-             m_bUpdateControllers : 1,
-             m_bImageOrientationRegistered : 1,
-             m_bImageMirrored : 1;
-
-        long m_lImageRotation;
+             m_bUpdateControllers : 1;
 
         VclPtr<ToolBox> m_pToolBar;
 
@@ -191,7 +181,6 @@ class ToolBarManager : public ToolbarManager_Base
         css::uno::Reference< css::frame::XUIControllerFactory >      m_xToolbarControllerFactory;
         css::uno::Reference< css::ui::XImageManager >                m_xModuleImageManager;
         css::uno::Reference< css::ui::XImageManager >                m_xDocImageManager;
-        css::uno::Reference< css::lang::XComponent >                 m_xImageOrientationListener;
         css::uno::Reference< css::ui::XUIConfigurationManager >      m_xUICfgMgr;
         css::uno::Reference< css::ui::XUIConfigurationManager >      m_xDocUICfgMgr;
 
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 49588d7..bb80b25 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -60,8 +60,6 @@
 #include <unotools/mediadescriptor.hxx>
 #include <comphelper/processfactory.hxx>
 #include <svtools/miscopt.hxx>
-#include <svl/imageitm.hxx>
-#include <svtools/framestatuslistener.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/menu.hxx>
 #include <vcl/syswin.hxx>
@@ -103,39 +101,6 @@ static const char HELPID_PREFIX_TESTTOOL[]     = ".HelpId:";
 
 static const sal_uInt16 STARTID_CUSTOMIZE_POPUPMENU = 1000;
 
-class ImageOrientationListener : public svt::FrameStatusListener
-{
-    public:
-        ImageOrientationListener( const Reference< XStatusListener >& rReceiver,
-                                  const Reference< XComponentContext >& rxContext,
-                                  const Reference< XFrame >& rFrame );
-        virtual ~ImageOrientationListener();
-
-        virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override;
-
-    private:
-        Reference< XStatusListener > m_xReceiver;
-};
-
-ImageOrientationListener::ImageOrientationListener(
-    const Reference< XStatusListener >& rReceiver,
-    const Reference< XComponentContext >& rxContext,
-    const Reference< XFrame >& rFrame ) :
-    FrameStatusListener( rxContext, rFrame ),
-    m_xReceiver( rReceiver )
-{
-}
-
-ImageOrientationListener::~ImageOrientationListener()
-{
-}
-
-void SAL_CALL ImageOrientationListener::statusChanged( const FeatureStateEvent& Event )
-throw ( RuntimeException, std::exception )
-{
-    if ( m_xReceiver.is() )
-        m_xReceiver->statusChanged( Event );
-}
 
 static sal_Int16 getImageTypeFromBools( bool bBig )
 {
@@ -180,9 +145,6 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
     m_bAddedToTaskPaneList( true ),
     m_bFrameActionRegistered( false ),
     m_bUpdateControllers( false ),
-    m_bImageOrientationRegistered( false ),
-    m_bImageMirrored( false ),
-    m_lImageRotation( 0 ),
     m_pToolBar( pToolBar ),
     m_aResourceName( rResourceName ),
     m_xFrame( rFrame ),
@@ -348,61 +310,6 @@ void ToolBarManager::RefreshImages()
     m_pToolBar->SetOutputSizePixel( aSize );
 }
 
-void ToolBarManager::UpdateImageOrientation()
-{
-    SolarMutexGuard g;
-
-    if ( m_xUICommandLabels.is() )
-    {
-        sal_Int32 i;
-        Sequence< OUString > aSeqMirrorCmd;
-        Sequence< OUString > aSeqRotateCmd;
-        m_xUICommandLabels->getByName(
-            UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST ) >>= aSeqMirrorCmd;
-        m_xUICommandLabels->getByName(
-            UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST ) >>= aSeqRotateCmd;
-
-        CommandToInfoMap::iterator pIter;
-        for ( i = 0; i < aSeqMirrorCmd.getLength(); i++ )
-        {
-            OUString aMirrorCmd = aSeqMirrorCmd[i];
-            pIter = m_aCommandMap.find( aMirrorCmd );
-            if ( pIter != m_aCommandMap.end() )
-                pIter->second.bMirrored = true;
-        }
-        for ( i = 0; i < aSeqRotateCmd.getLength(); i++ )
-        {
-            OUString aRotateCmd = aSeqRotateCmd[i];
-            pIter = m_aCommandMap.find( aRotateCmd );
-            if ( pIter != m_aCommandMap.end() )
-                pIter->second.bRotated = true;
-        }
-    }
-
-    for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); nPos++ )
-    {
-        sal_uInt16 nId = m_pToolBar->GetItemId( nPos );
-        if ( nId > 0 )
-        {
-            OUString aCmd = m_pToolBar->GetItemCommand( nId );
-
-            CommandToInfoMap::const_iterator pIter = m_aCommandMap.find( aCmd );
-            if ( pIter != m_aCommandMap.end() )
-            {
-                if ( pIter->second.bRotated )
-                {
-                    m_pToolBar->SetItemImageMirrorMode( nId, false );
-                    m_pToolBar->SetItemImageAngle( nId, m_lImageRotation );
-                }
-                if ( pIter->second.bMirrored )
-                {
-                    m_pToolBar->SetItemImageMirrorMode( nId, m_bImageMirrored );
-                }
-            }
-        }
-    }
-}
-
 void ToolBarManager::UpdateControllers()
 {
 
@@ -479,24 +386,6 @@ throw ( RuntimeException, std::exception )
     }
 }
 
-void SAL_CALL ToolBarManager::statusChanged( const css::frame::FeatureStateEvent& Event )
-throw ( css::uno::RuntimeException, std::exception )
-{
-    SolarMutexGuard g;
-    if ( m_bDisposed )
-        return;
-
-    if ( Event.FeatureURL.Complete == ".uno:ImageOrientation" )
-    {
-        SfxImageItem aItem( 1, 0 );
-        aItem.PutValue( Event.State, 0 );
-
-        m_lImageRotation = aItem.GetRotation();
-        m_bImageMirrored = aItem.IsMirrored();
-        UpdateImageOrientation();
-    }
-}
-
 void SAL_CALL ToolBarManager::disposing( const EventObject& Source ) throw ( RuntimeException, std::exception )
 {
     {
@@ -535,14 +424,6 @@ void SAL_CALL ToolBarManager::disposing( const EventObject& Source ) throw ( Run
             }
         }
 
-        if ( m_xImageOrientationListener.is() )
-        {
-            ImageOrientationListener* pImageOrientation =
-                static_cast<ImageOrientationListener*>(m_xImageOrientationListener.get());
-            pImageOrientation->unbindListener();
-            m_xImageOrientationListener.clear();
-        }
-
         m_xDocImageManager.clear();
         m_xModuleImageManager.clear();
 
@@ -611,14 +492,6 @@ void SAL_CALL ToolBarManager::dispose() throw( RuntimeException, std::exception
             }
         }
 
-        if ( m_xImageOrientationListener.is() )
-        {
-            ImageOrientationListener* pImageOrientation =
-                static_cast<ImageOrientationListener*>(m_xImageOrientationListener.get());
-            pImageOrientation->unbindListener();
-            m_xImageOrientationListener.clear();
-        }
-
         m_xFrame.clear();
         m_xContext.clear();
         Reference< XComponent > xCompGAM( m_xGlobalAcceleratorManager, UNO_QUERY );
@@ -993,7 +866,6 @@ void ToolBarManager::CreateControllers()
     }
 
     AddFrameActionListener();
-    AddImageOrientationListener();
 }
 
 void ToolBarManager::AddFrameActionListener()
@@ -1006,23 +878,6 @@ void ToolBarManager::AddFrameActionListener()
     }
 }
 
-void ToolBarManager::AddImageOrientationListener()
-{
-    if ( !m_bImageOrientationRegistered && m_xFrame.is() )
-    {
-        m_bImageOrientationRegistered = true;
-        ImageOrientationListener* pImageOrientation = new ImageOrientationListener(
-            Reference< XStatusListener >( static_cast< ::cppu::OWeakObject *>( this ), UNO_QUERY ),
-            m_xContext,
-            m_xFrame );
-        m_xImageOrientationListener.set( static_cast< ::cppu::OWeakObject *>(
-                                        pImageOrientation ), UNO_QUERY );
-        pImageOrientation->addStatusListener(
-            ".uno:ImageOrientation");
-        pImageOrientation->bindListener();
-    }
-}
-
 ToolBoxItemBits ToolBarManager::ConvertStyleToToolboxItemBits( sal_Int32 nStyle )
 {
     ToolBoxItemBits nItemBits( ToolBoxItemBits::NONE );
diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx
index 93d5b99..9665dfd 100644
--- a/include/vcl/button.hxx
+++ b/include/vcl/button.hxx
@@ -94,7 +94,7 @@ public:
     virtual bool        set_property(const OString &rKey, const OString &rValue) override;
 
     /// Sets the button state according to the FeatureStateEvent emitted by an Uno state change.
-    virtual void        SetStateUno(const css::frame::FeatureStateEvent& rEvent);
+    virtual void        statusChanged(const css::frame::FeatureStateEvent& rEvent);
 
 protected:
 
@@ -187,7 +187,7 @@ public:
 
     void            SetState( TriState eState );
     TriState        GetState() const { return meState; }
-    virtual void    SetStateUno(const css::frame::FeatureStateEvent& rEvent) override;
+    virtual void    statusChanged(const css::frame::FeatureStateEvent& rEvent) override;
 
     void            Check( bool bCheck = true );
     bool            IsChecked() const;
diff --git a/include/vcl/buttonstatuslistener.hxx b/include/vcl/buttonstatuslistener.hxx
deleted file mode 100644
index 7721895..0000000
--- a/include/vcl/buttonstatuslistener.hxx
+++ /dev/null
@@ -1,45 +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/.
- */
-
-#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
diff --git a/include/vcl/commandinfoprovider.hxx b/include/vcl/commandinfoprovider.hxx
index 4fc88b7..8871de6 100644
--- a/include/vcl/commandinfoprovider.hxx
+++ b/include/vcl/commandinfoprovider.hxx
@@ -96,6 +96,9 @@ public:
         const OUString& rsCommandName,
         const css::uno::Reference<css::frame::XFrame>& rxFrame);
 
+    bool IsRotated(const OUString& rsCommandName);
+    bool IsMirrored(const OUString& rsCommandName);
+
     /** Do not call.  Should be part of a local and hidden interface.
     */
     void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame);
@@ -121,6 +124,7 @@ public:
     css::uno::Sequence<css::beans::PropertyValue> GetCommandProperties (
         const OUString& rsCommandName);
     OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName);
+    bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName);
     static OUString RetrieveShortcutsFromConfiguration(
         const css::uno::Reference<css::ui::XAcceleratorConfiguration>& rxConfiguration,
         const OUString& rsCommandName);
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index e0b4fd7..12a0b70 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -20,13 +20,16 @@
 #ifndef INCLUDED_VCL_TOOLBOX_HXX
 #define INCLUDED_VCL_TOOLBOX_HXX
 
-#include <com/sun/star/frame/XFrame.hpp>
+#include <vcl/vclstatuslistener.hxx>
 #include <rsc/rsc-vcl-shared-types.hxx>
 #include <vcl/dllapi.h>
 #include <vcl/dockwin.hxx>
 #include <vcl/image.hxx>
 #include <vector>
 
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/FeatureStateEvent.hpp>
+
 class Timer;
 class UserDrawEvent;
 struct ImplToolItem;
@@ -94,6 +97,7 @@ private:
     long                mnBottomBorder;
     long                mnLastResizeDY;
     long                mnActivateCount;
+    long                mnImagesRotationAngle;
     sal_uInt16          mnLastFocusItemId;
     sal_uInt16          mnFocusPos;
     sal_uInt16          mnOutStyle;
@@ -128,7 +132,8 @@ private:
                         mbMenuStrings:1,
                         mbIsShift:1,
                         mbIsKeyEvent:1,
-                        mbChangingHighlight:1;
+                        mbChangingHighlight:1,
+                        mbImagesMirrored:1;
     WindowAlign         meAlign;
     WindowAlign         meDockAlign;
     ButtonType          meButtonType;
@@ -143,6 +148,8 @@ private:
     Link<CommandEvent const *, void> maCommandHandler;
     Link<StateChangedType const *, void> maStateChangedHandler;
     Link<DataChangedEvent const *, void> maDataChangedHandler;
+    /** StatusListener. Notifies about rotated images etc */
+    rtl::Reference<VclStatusListener<ToolBox>> mpStatusListener;
 
 public:
     using Window::ImplInit;
@@ -356,6 +363,7 @@ public:
     void                SetItemImage( sal_uInt16 nItemId, const Image& rImage );
     Image               GetItemImage( sal_uInt16 nItemId ) const;
     Image               GetItemImageOriginal( sal_uInt16 nItemId ) const;
+    void                UpdateImageOrientation();
     void                SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 );
     void                SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror );
     void                SetItemText( sal_uInt16 nItemId, const OUString& rText );
@@ -499,6 +507,7 @@ public:
     void                ChangeHighlight( sal_uInt16 nPos );
 
     void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout );
+    void statusChanged(const css::frame::FeatureStateEvent& rEvent);
 };
 
 inline void ToolBox::CheckItem( sal_uInt16 nItemId, bool bCheck )
diff --git a/vcl/source/control/buttonstatuslistener.cxx b/include/vcl/vclstatuslistener.hxx
similarity index 57%
rename from vcl/source/control/buttonstatuslistener.cxx
rename to include/vcl/vclstatuslistener.hxx
index bad5452..87e0a02 100644
--- a/vcl/source/control/buttonstatuslistener.cxx
+++ b/include/vcl/vclstatuslistener.hxx
@@ -7,18 +7,45 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <vcl/buttonstatuslistener.hxx>
+#ifndef INCLUDED_VCL_VCLSTATUSLISTENER_HXX
+#define INCLUDED_VCL_VCLSTATUSLISTENER_HXX
+
+#include <cppuhelper/implbase.hxx>
 #include <comphelper/processfactory.hxx>
+#include <vcl/vclptr.hxx>
 
 #include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XStatusListener.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;
+template <class T> class VclStatusListener : public cppu::WeakImplHelper < css::frame::XStatusListener>
+{
+public:
+    VclStatusListener<T>(T* widget, const rtl::OUString& aCommand);
+
+private:
+    VclPtr<T> mWidget; /** The widget 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:
+    void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& rEvent)
+        throw(css::uno::RuntimeException, std::exception) override;
+
+    void SAL_CALL disposing(const css::lang::EventObject& /*Source*/)
+        throw( css::uno::RuntimeException, std::exception ) override;
+
+    void dispose();
+};
+
+template<class T>
+VclStatusListener<T>::VclStatusListener(T* widget, const rtl::OUString& aCommand) {
+    mWidget = widget;
 
     css::uno::Reference<css::uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
     css::uno::Reference<css::frame::XDesktop2> xDesktop = css::frame::Desktop::create(xContext);
@@ -42,25 +69,31 @@ ButtonStatusListener::ButtonStatusListener(Button* button, const rtl::OUString&
     mxDispatch->addStatusListener(this, maCommandURL);
 }
 
-void ButtonStatusListener::statusChanged(const css::frame::FeatureStateEvent& rEvent)
+template<class T>
+void VclStatusListener<T>::statusChanged(const css::frame::FeatureStateEvent& rEvent)
             throw(css::uno::RuntimeException, std::exception)
 {
-    mButton->SetStateUno(rEvent);
+    mWidget->statusChanged(rEvent);
 }
 
-void ButtonStatusListener::disposing(const css::lang::EventObject& /*Source*/)
+template<class T>
+void VclStatusListener<T>::disposing(const css::lang::EventObject& /*Source*/)
             throw( css::uno::RuntimeException, std::exception )
 {
     mxDispatch.clear();
 }
 
-void ButtonStatusListener::dispose()
+template<class T>
+void VclStatusListener<T>::dispose()
 {
     if (mxDispatch.is()) {
         mxDispatch->removeStatusListener(this, maCommandURL);
         mxDispatch.clear();
     }
-    mButton.clear();
+    mWidget.clear();
 }
 
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
+
+#endif // INCLUDED_VCL_VCLSTATUSLISTENER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 25f2d85..b0804a0 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -205,7 +205,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/window/winproc \
     vcl/source/window/wrkwin \
     vcl/source/control/button \
-    vcl/source/control/buttonstatuslistener \
     vcl/source/control/combobox \
     vcl/source/control/ctrl \
     vcl/source/control/edit \
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index b3390a3..d831794 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/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx
index fcc8aec..95f252a 100644
--- a/vcl/source/helper/commandinfoprovider.cxx
+++ b/vcl/source/helper/commandinfoprovider.cxx
@@ -276,6 +276,16 @@ sal_Int32 CommandInfoProvider::GetPropertiesForCommand (
     return nValue;
 }
 
+bool CommandInfoProvider::IsRotated(const OUString& rsCommandName)
+{
+    return ResourceHasKey("private:resource/image/commandrotateimagelist", rsCommandName);
+}
+
+bool CommandInfoProvider::IsMirrored(const OUString& rsCommandName)
+{
+    return ResourceHasKey("private:resource/image/commandmirrorimagelist", rsCommandName);
+}
+
 void CommandInfoProvider::SetFrame (const Reference<frame::XFrame>& rxFrame)
 {
     if (rxFrame != mxCachedDataFrame)
@@ -399,6 +409,32 @@ OUString CommandInfoProvider::RetrieveShortcutsFromConfiguration(
     return OUString();
 }
 
+bool CommandInfoProvider::ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName)
+{
+    Sequence< OUString > aSequence;
+    try
+    {
+        const OUString sModuleIdentifier (GetModuleIdentifier());
+        if (!sModuleIdentifier.isEmpty())
+        {
+            Reference<container::XNameAccess> xNameAccess  = frame::theUICommandDescription::get(mxContext);
+            Reference<container::XNameAccess> xUICommandLabels;
+            if (xNameAccess->getByName(sModuleIdentifier) >>= xUICommandLabels) {
+                xUICommandLabels->getByName(rsResourceName) >>= aSequence;
+                for ( sal_Int32 i = 0; i < aSequence.getLength(); i++ )
+                {
+                    if (aSequence[i] == rsCommandName)
+                        return true;
+                }
+            }
+        }
+    }
+    catch (Exception&)
+    {
+    }
+    return false;
+}
+
 Sequence<beans::PropertyValue> CommandInfoProvider::GetCommandProperties(const OUString& rsCommandName)
 {
     Sequence<beans::PropertyValue> aProperties;
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 4105b58..e0e8492 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -17,23 +17,25 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <tools/debug.hxx>
-#include <tools/rc.h>
-#include <tools/poly.hxx>
-
+#include <vcl/toolbox.hxx>
 #include <vcl/event.hxx>
 #include <vcl/decoview.hxx>
 #include <vcl/accel.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/help.hxx>
 #include <vcl/spin.h>
-#include <vcl/toolbox.hxx>
 #include <vcl/bitmap.hxx>
 #include <vcl/mnemonic.hxx>
 #include <vcl/gradient.hxx>
 #include <vcl/layout.hxx>
 #include <vcl/menu.hxx>
 #include <vcl/settings.hxx>
+#include <vcl/vclstatuslistener.hxx>
+
+#include <tools/debug.hxx>
+#include <tools/rc.h>
+#include <tools/poly.hxx>
+#include <svl/imageitm.hxx>
 
 #include <svdata.hxx>
 #include <window.h>
@@ -1397,6 +1399,7 @@ void ToolBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
     mnLastFocusItemId = 0;
     mnKeyModifier     = 0;
     mnActivateCount   = 0;
+    mpStatusListener  = new VclStatusListener<ToolBox>(this, ".uno:ImageOrientation");
 
     mpIdle = new Idle("toolbox update");
     mpIdle->SetPriority( SchedulerPriority::RESIZE );
@@ -1657,6 +1660,10 @@ void ToolBox::dispose()
             pSVData->maCtrlData.mpTBDragMgr = nullptr;
         }
     }
+
+    if (mpStatusListener.is())
+        mpStatusListener->dispose();
+
     mpFloatWin.clear();
 
     delete mpIdle;
@@ -4540,6 +4547,21 @@ void ToolBox::DataChanged( const DataChangedEvent& rDCEvt )
     maDataChangedHandler.Call( &rDCEvt );
 }
 
+void ToolBox::statusChanged( const css::frame::FeatureStateEvent& Event )
+{
+    // Update image mirroring/rotation
+    if ( Event.FeatureURL.Complete == ".uno:ImageOrientation" )
+    {
+        SfxImageItem aItem( 1, 0 );
+        aItem.PutValue( Event.State, 0 );
+
+        mbImagesMirrored = aItem.IsMirrored();
+        mnImagesRotationAngle = aItem.GetRotation();
+
+        UpdateImageOrientation();
+    }
+}
+
 bool ToolBox::PrepareToggleFloatingMode()
 {
     return DockingWindow::PrepareToggleFloatingMode();
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index dddb65f..0c916f6 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -1232,6 +1232,17 @@ void ToolBox::SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror )
     }
 }
 
+void ToolBox::UpdateImageOrientation()
+{
+    for (std::vector<ImplToolItem>::const_iterator it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it)
+    {
+        if (vcl::CommandInfoProvider::Instance().IsMirrored(it->maCommandStr))
+            SetItemImageMirrorMode(it->mnId, mbImagesMirrored);
+        if (vcl::CommandInfoProvider::Instance().IsRotated(it->maCommandStr))
+            SetItemImageAngle(it->mnId, mnImagesRotationAngle);
+    }
+}
+
 Image ToolBox::GetItemImage(sal_uInt16 nItemId) const
 {
     ImplToolItem* pItem = ImplGetItem(nItemId);


More information about the Libreoffice-commits mailing list