Kaydet (Commit) 06448120 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

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
dd69bde3, so that updateImage
method is called once an icon refreshing is requested.

Change-Id: I6bd15638665f917ed7060886cd7835cdcd1a34f9
üst e93b4d20
......@@ -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
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment