[Libreoffice-commits] .: svx/inc svx/source
Caolán McNamara
caolan at kemper.freedesktop.org
Fri Feb 25 08:41:03 PST 2011
svx/inc/svx/extrusioncolorcontrol.hxx | 3 -
svx/inc/svx/tbcontrl.hxx | 6 ++
svx/source/tbxctrls/colorwindow.hxx | 10 ++--
svx/source/tbxctrls/extrusioncontrols.cxx | 9 +++-
svx/source/tbxctrls/tbcontrl.cxx | 62 +++++++++++++++++++-----------
5 files changed, 61 insertions(+), 29 deletions(-)
New commits:
commit e5b3eb2347f6b64c3428fb0a629e1b397571f2fb
Author: Kurosawa Takeshi <taken.spc at gmail.com>
Date: Fri Feb 25 15:45:22 2011 +0000
Resolves fdo#32376 Set default color to the current one in toolbar popup
diff --git a/svx/inc/svx/extrusioncolorcontrol.hxx b/svx/inc/svx/extrusioncolorcontrol.hxx
index 8bd4a93..4b79b88 100644
--- a/svx/inc/svx/extrusioncolorcontrol.hxx
+++ b/svx/inc/svx/extrusioncolorcontrol.hxx
@@ -38,7 +38,8 @@ namespace svx {
class SVX_DLLPUBLIC ExtrusionColorControl : public SfxToolBoxControl
{
private:
- ToolboxButtonColorUpdater* mpBtnUpdater;
+ ToolboxButtonColorUpdater* mpBtnUpdater;
+ Color mLastColor;
public:
SFX_DECL_TOOLBOX_CONTROL();
diff --git a/svx/inc/svx/tbcontrl.hxx b/svx/inc/svx/tbcontrl.hxx
index 66b4861..fd1fb8a 100644
--- a/svx/inc/svx/tbcontrl.hxx
+++ b/svx/inc/svx/tbcontrl.hxx
@@ -287,6 +287,7 @@ public:
class SVX_DLLPUBLIC SvxFontColorToolBoxControl : public SfxToolBoxControl
{
::svx::ToolboxButtonColorUpdater* pBtnUpdater;
+ Color mLastColor;
public:
SFX_DECL_TOOLBOX_CONTROL();
@@ -314,6 +315,7 @@ class SVX_DLLPUBLIC SvxFontColorExtToolBoxControl : public SfxToolBoxControl
// SfxStatusForwarder aForward;
::svx::ToolboxButtonColorUpdater* pBtnUpdater;
+ Color mLastColor;
public:
SFX_DECL_TOOLBOX_CONTROL();
@@ -338,6 +340,8 @@ public:
class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
{
::svx::ToolboxButtonColorUpdater* pBtnUpdater;
+ Color mLastColor;
+
public:
SFX_DECL_TOOLBOX_CONTROL();
SvxColorToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
@@ -398,6 +402,8 @@ public:
class SVX_DLLPUBLIC SvxFrameLineColorToolBoxControl : public SfxToolBoxControl
{
::svx::ToolboxButtonColorUpdater* pBtnUpdater;
+ Color mLastColor;
+
public:
SFX_DECL_TOOLBOX_CONTROL();
SvxFrameLineColorToolBoxControl( USHORT nSlotId,
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 763f2bf..fc49d05 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -19,9 +19,10 @@ class SvxColorWindow_Impl : public SfxPopupWindow
using FloatingWindow::StateChanged;
private:
- const USHORT theSlotId;
- ValueSet aColorSet;
- rtl::OUString maCommand;
+ const USHORT theSlotId;
+ ValueSet aColorSet;
+ rtl::OUString maCommand;
+ const Color mLastColor;
#if _SOLAR__PRIVATE
DECL_LINK( SelectHdl, void * );
@@ -36,7 +37,8 @@ public:
USHORT nSlotId,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
const String& rWndTitle,
- Window* pParentWindow );
+ Window* pParentWindow,
+ const Color rLastColor = COL_AUTO);
~SvxColorWindow_Impl();
void StartSelection();
diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx
index ac1b68a..cca72a1 100644
--- a/svx/source/tbxctrls/extrusioncontrols.cxx
+++ b/svx/source/tbxctrls/extrusioncontrols.cxx
@@ -989,7 +989,8 @@ SFX_IMPL_TOOLBOX_CONTROL( ExtrusionColorControl, SvxColorItem );
ExtrusionColorControl::ExtrusionColorControl(
USHORT nSlotId, USHORT nId, ToolBox& rTbx )
-: SfxToolBoxControl ( nSlotId, nId, rTbx )
+: SfxToolBoxControl ( nSlotId, nId, rTbx ),
+ mLastColor( COL_AUTO )
{
rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
mpBtnUpdater = new ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW );
@@ -1018,7 +1019,8 @@ SfxPopupWindow* ExtrusionColorControl::CreatePopupWindow()
SID_EXTRUSION_3D_COLOR,
m_xFrame,
SVX_RESSTR( RID_SVXSTR_EXTRUSION_COLOR ),
- &GetToolBox() );
+ &GetToolBox(),
+ mLastColor );
pColorWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
pColorWin->StartSelection();
SetPopupWindow( pColorWin );
@@ -1040,7 +1042,10 @@ void ExtrusionColorControl::StateChanged( USHORT nSID, SfxItemState eState, cons
pItem = PTR_CAST( SvxColorItem, pState );
if ( pItem )
+ {
mpBtnUpdater->Update( pItem->GetValue());
+ mLastColor = pItem->GetValue();
+ }
}
rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 316ec00..d1487a3 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -821,13 +821,15 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
USHORT nSlotId,
const Reference< XFrame >& rFrame,
const String& rWndTitle,
- Window* pParentWindow ) :
+ Window* pParentWindow,
+ const ::Color rLastColor ) :
SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_STDPOPUP ) ),
theSlotId( nSlotId ),
aColorSet( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
- maCommand( rCommand )
+ maCommand( rCommand ),
+ mLastColor( rLastColor )
{
SfxObjectShell* pDocSh = SfxObjectShell::Current();
@@ -883,6 +885,8 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
{
pEntry = pColorTable->GetColor(i);
aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() );
+ if( pEntry->GetColor() == mLastColor )
+ aColorSet.SelectItem( i+1 );
}
while ( i < PALETTE_SIZE )
@@ -921,7 +925,7 @@ void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt )
SfxPopupWindow* SvxColorWindow_Impl::Clone() const
{
- return new SvxColorWindow_Impl( maCommand, theSlotId, GetFrame(), GetText(), GetParent() );
+ return new SvxColorWindow_Impl( maCommand, theSlotId, GetFrame(), GetText(), GetParent(), mLastColor );
}
// -----------------------------------------------------------------------
@@ -930,7 +934,6 @@ IMPL_LINK( SvxColorWindow_Impl, SelectHdl, void *, EMPTYARG )
{
USHORT nItemId = aColorSet.GetSelectItemId();
SvxColorItem aColorItem( aColorSet.GetItemColor( nItemId ), theSlotId );
-
/* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
This instance may be deleted in the meantime (i.e. when a dialog is opened
while in Dispatch()), accessing members will crash in this case. */
@@ -2333,7 +2336,8 @@ SvxFontColorToolBoxControl::SvxFontColorToolBoxControl(
: SfxToolBoxControl( nSlotId, nId, rTbx ),
pBtnUpdater( new ::svx::ToolboxButtonColorUpdater(
- nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW ))
+ nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW )),
+ mLastColor( COL_AUTO )
{
rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
}
@@ -2354,7 +2358,7 @@ SfxPopupWindowType SvxFontColorToolBoxControl::GetPopupWindowType() const
// -----------------------------------------------------------------------
-SfxPopupWindow* SvxFontColorToolBoxControl::CreatePopupWindow()
+SfxPopupWindow* SvxFontColorToolBoxControl::CreatePopupWindow()
{
SvxColorWindow_Impl* pColorWin =
new SvxColorWindow_Impl(
@@ -2362,7 +2366,8 @@ SfxPopupWindow* SvxFontColorToolBoxControl::CreatePopupWindow()
SID_ATTR_CHAR_COLOR,
m_xFrame,
SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
- &GetToolBox() );
+ &GetToolBox(),
+ mLastColor);
pColorWin->StartPopupMode( &GetToolBox(),
FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
@@ -2380,13 +2385,16 @@ void SvxFontColorToolBoxControl::StateChanged(
{
USHORT nId = GetId();
ToolBox& rTbx = GetToolBox();
- const SvxColorItem* pItem = 0;
+ const SvxColorItem* pItem = 0;
if ( SFX_ITEM_DONTCARE != eState )
pItem = PTR_CAST( SvxColorItem, pState );
if ( pItem )
- pBtnUpdater->Update( pItem->GetValue());
+ {
+ pBtnUpdater->Update( pItem->GetValue() );
+ mLastColor= pItem->GetValue();
+ }
rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
@@ -2398,7 +2406,8 @@ void SvxFontColorToolBoxControl::StateChanged(
SvxColorToolBoxControl::SvxColorToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
- SfxToolBoxControl( nSlotId, nId, rTbx )
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ mLastColor( COL_AUTO )
{
if ( nSlotId == SID_BACKGROUND_COLOR )
rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
@@ -2433,7 +2442,8 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
SID_BACKGROUND_COLOR,
m_xFrame,
SVX_RESSTR(nResId),
- &GetToolBox() );
+ &GetToolBox(),
+ mLastColor);
pColorWin->StartPopupMode( &GetToolBox(),
FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
@@ -2445,16 +2455,16 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
// -----------------------------------------------------------------------
void SvxColorToolBoxControl::StateChanged(
-
USHORT , SfxItemState eState, const SfxPoolItem* pState )
-
{
- const SvxColorItem* pItem = 0;
+ const SvxColorItem* pItem = 0;
if ( SFX_ITEM_DONTCARE != eState )
pItem = PTR_CAST( SvxColorItem, pState );
- if ( pItem )
+ if ( pItem ) {
pBtnUpdater->Update( pItem->GetValue() );
+ mLastColor= pItem->GetValue();
+ }
USHORT nId = GetId();
ToolBox& rTbx = GetToolBox();
@@ -2472,7 +2482,8 @@ SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl(
ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx ),
- pBtnUpdater(0)
+ pBtnUpdater(0),
+ mLastColor( COL_AUTO )
{
rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
// The following commands are available at the writer module.
@@ -2510,7 +2521,8 @@ SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow()
GetSlotId(),
m_xFrame,
SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
- &GetToolBox() );
+ &GetToolBox(),
+ mLastColor );
if ( GetSlotId() == SID_ATTR_CHAR_COLOR_BACKGROUND )
pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) );
@@ -2549,7 +2561,10 @@ void SvxFontColorExtToolBoxControl::StateChanged(
pItem = PTR_CAST( SvxColorItem, pState );
if ( pItem )
+ {
pBtnUpdater->Update( pItem->GetValue() );
+ mLastColor = pItem->GetValue();
+ }
}
}
@@ -2685,7 +2700,8 @@ SvxFrameLineColorToolBoxControl::SvxFrameLineColorToolBoxControl(
ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx ),
- pBtnUpdater(new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ))
+ pBtnUpdater(new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() )),
+ mLastColor( COL_AUTO )
{
rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
}
@@ -2714,7 +2730,8 @@ SfxPopupWindow* SvxFrameLineColorToolBoxControl::CreatePopupWindow()
SID_FRAME_LINECOLOR,
m_xFrame,
SVX_RESSTR(RID_SVXSTR_FRAME_COLOR),
- &GetToolBox() );
+ &GetToolBox(),
+ mLastColor);
pColorWin->StartPopupMode( &GetToolBox(),
FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
@@ -2726,9 +2743,7 @@ SfxPopupWindow* SvxFrameLineColorToolBoxControl::CreatePopupWindow()
// -----------------------------------------------------------------------
void SvxFrameLineColorToolBoxControl::StateChanged(
-
USHORT , SfxItemState eState, const SfxPoolItem* pState )
-
{
USHORT nId = GetId();
ToolBox& rTbx = GetToolBox();
@@ -2738,9 +2753,12 @@ void SvxFrameLineColorToolBoxControl::StateChanged(
const SvxColorItem* pItem = 0;
if ( SFX_ITEM_DONTCARE != eState )
{
- pItem = PTR_CAST( SvxColorItem, pState );
+ pItem = PTR_CAST( SvxColorItem, pState );
if ( pItem )
+ {
pBtnUpdater->Update( pItem->GetValue());
+ mLastColor = pItem->GetValue();
+ }
}
}
More information about the Libreoffice-commits
mailing list