[Libreoffice-commits] core.git: include/svx svx/source

Maxim Monastirsky momonasmon at gmail.com
Mon Jul 6 12:51:14 PDT 2015


 include/svx/tbcontrl.hxx               |    4 ++++
 include/svx/tbxcolorupdate.hxx         |    2 +-
 svx/source/tbxctrls/tbcontrl.cxx       |   21 +++++++++++++++++++++
 svx/source/tbxctrls/tbxcolorupdate.cxx |    5 +++--
 4 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit 064481201341d92af2ec1387bb53a9c4b480217f
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Mon Jul 6 22:35:15 2015 +0300

    tdf#83541 Redraw the last used color after theme change
    
    That's not what XSubToolbarController was originally designed for,
    probably, but it has more in common than otherwise. A split button
    offers a dropdown with some functions, and the main part of that
    button updates with the last selection, to easily re-apply it.
    
    This is based on the change made in commit
    dd69bde36a4ee4636933a80c0291486593a37670, so that updateImage
    method is called once an icon refreshing is requested.
    
    Change-Id: I6bd15638665f917ed7060886cd7835cdcd1a34f9

diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 1759f56..9e589ac 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -243,6 +243,10 @@ public:
                               const SfxPoolItem* pState) SAL_OVERRIDE;
     virtual VclPtr<SfxPopupWindow> CreatePopupWindow() SAL_OVERRIDE;
     virtual void Select(sal_uInt16 nSelectModifier) SAL_OVERRIDE;
+
+    // XSubToolbarController
+    virtual sal_Bool SAL_CALL opensSubToolbar() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+    virtual void SAL_CALL updateImage() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 };
 
 class SVX_DLLPUBLIC SvxFrameToolBoxControl : public SfxToolBoxControl
diff --git a/include/svx/tbxcolorupdate.hxx b/include/svx/tbxcolorupdate.hxx
index 1a649e4..d356f88 100644
--- a/include/svx/tbxcolorupdate.hxx
+++ b/include/svx/tbxcolorupdate.hxx
@@ -49,7 +49,7 @@ namespace svx
                                                ToolBox*     ptrTbx);
                     ~ToolboxButtonColorUpdater();
 
-        void        Update( const Color& rColor );
+        void        Update( const Color& rColor, bool bForceUpdate = false );
 
     private:
         sal_uInt16      mnBtnId;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index e226896..65337b3 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -35,6 +35,7 @@
 #include <svl/stritem.hxx>
 #include <sfx2/tplpitem.hxx>
 #include <sfx2/dispatch.hxx>
+#include <sfx2/imagemgr.hxx>
 #include <sfx2/viewsh.hxx>
 #include <sfx2/docfac.hxx>
 #include <sfx2/templdlg.hxx>
@@ -2775,6 +2776,26 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
     Dispatch( aCommand, aArgs );
 }
 
+sal_Bool SvxColorToolBoxControl::opensSubToolbar()
+    throw (css::uno::RuntimeException, std::exception)
+{
+    // For a split button (i.e. bSidebarType == false), we mark this controller as
+    // a sub-toolbar controller, so we get notified (through updateImage method) on
+    // button image changes, and could redraw the last used color on top of it.
+    return !bSidebarType;
+}
+
+void SvxColorToolBoxControl::updateImage()
+    throw (css::uno::RuntimeException, std::exception)
+{
+    Image aImage = GetImage( m_xFrame, m_aCommandURL, hasBigImages() );
+    if ( !!aImage )
+    {
+        GetToolBox().SetItemImage( GetId(), aImage );
+        m_xBtnUpdater->Update( mPaletteManager.GetLastColor(), true );
+    }
+}
+
 SfxToolBoxControl* SvxColorToolBoxControl::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx )
 {
     return new SvxColorToolBoxControl( nSlotId, nId, rTbx );
diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx
index 4784040..282589d 100644
--- a/svx/source/tbxctrls/tbxcolorupdate.cxx
+++ b/svx/source/tbxctrls/tbxcolorupdate.cxx
@@ -76,7 +76,7 @@ namespace svx
     ToolboxButtonColorUpdater::~ToolboxButtonColorUpdater()
     {}
 
-    void ToolboxButtonColorUpdater::Update(const Color& rColor)
+    void ToolboxButtonColorUpdater::Update(const Color& rColor, bool bForceUpdate)
     {
         Image aImage(mpTbx->GetItemImageOriginal(mnBtnId));
         Size aItemSize(mpTbx->GetItemContentSize(mnBtnId));
@@ -93,7 +93,8 @@ namespace svx
         // is COL_BLACK, then (maCurColor != aColor) becomes 'false', therefore we take
         // explicit care of COL_BLACK from the last argument in the condition so that the
         // Update() does its routine job appropriately !
-        if ((maCurColor != aColor) || bSizeChanged || bDisplayModeChanged || (aColor == COL_BLACK))
+        if ((maCurColor != aColor) || (aColor == COL_BLACK) ||
+            bSizeChanged || bDisplayModeChanged || bForceUpdate )
         {
             // create an empty bitmap, and copy the original bitmap inside
             // (so that it grows in case the original bitmap was smaller)


More information about the Libreoffice-commits mailing list