summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-07-06 22:35:15 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2015-07-06 22:49:09 +0300
commit064481201341d92af2ec1387bb53a9c4b480217f (patch)
tree55d0b8b03a011dd4c606b3b848377151ca0797ca /svx
parente93b4d20d88ab70489e4daad5e8640b34d06b28f (diff)
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
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx21
-rw-r--r--svx/source/tbxctrls/tbxcolorupdate.cxx5
2 files changed, 24 insertions, 2 deletions
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index e2268963124d..65337b3076f5 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 47840407348c..282589d6822a 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)