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

Related: fdo#84844 Prepare border color status update

The Sidebar button handles also the color of diagonal lines.

Change-Id: I26d75472a8c9ca482274797127994d4546b1b3e8
üst 4d447ebc
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
SvxColorToolBoxControl SvxColorToolBoxControl
---------------------- ----------------------
Item type: SvxColorItem Item type: SvxColorItem
SvxLineItem
SfxBoolItem SfxBoolItem
XLineColorItem XLineColorItem
and XFillColorItem and XFillColorItem
...@@ -216,6 +217,19 @@ public: ...@@ -216,6 +217,19 @@ public:
}; };
class BorderColorStatus
{
Color maColor;
Color maTLBRColor;
Color maBLTRColor;
public:
BorderColorStatus();
~BorderColorStatus();
void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
Color GetColor();
};
// class SvxColorToolBoxControl -------------------------------------- // class SvxColorToolBoxControl --------------------------------------
class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
...@@ -224,6 +238,7 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl ...@@ -224,6 +238,7 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater; ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
PaletteManager mPaletteManager; PaletteManager mPaletteManager;
BorderColorStatus maBorderColorStatus;
bool bSidebarType; bool bSidebarType;
DECL_LINK( SelectedHdl, Color* ); DECL_LINK( SelectedHdl, Color* );
public: public:
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <svx/PaletteManager.hxx> #include <svx/PaletteManager.hxx>
#include <vcl/lstbox.hxx> #include <vcl/lstbox.hxx>
class BorderColorStatus;
class SvxColorWindow_Impl : public SfxPopupWindow class SvxColorWindow_Impl : public SfxPopupWindow
{ {
using FloatingWindow::StateChanged; using FloatingWindow::StateChanged;
...@@ -46,6 +48,7 @@ private: ...@@ -46,6 +48,7 @@ private:
Link maSelectedLink; Link maSelectedLink;
PaletteManager& mrPaletteManager; PaletteManager& mrPaletteManager;
BorderColorStatus& mrBorderColorStatus;
DECL_LINK( SelectHdl, SvxColorValueSet* ); DECL_LINK( SelectHdl, SvxColorValueSet* );
DECL_LINK( SelectPaletteHdl, void *); DECL_LINK( SelectPaletteHdl, void *);
...@@ -59,6 +62,7 @@ protected: ...@@ -59,6 +62,7 @@ protected:
public: public:
SvxColorWindow_Impl( const OUString& rCommand, SvxColorWindow_Impl( const OUString& rCommand,
PaletteManager& rPaletteManager, PaletteManager& rPaletteManager,
BorderColorStatus& rBorderColorStatus,
sal_uInt16 nSlotId, sal_uInt16 nSlotId,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
const OUString& rWndTitle, const OUString& rWndTitle,
......
...@@ -1126,6 +1126,7 @@ void SvxFontNameBox_Impl::Select() ...@@ -1126,6 +1126,7 @@ void SvxFontNameBox_Impl::Select()
SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
PaletteManager& rPaletteManager, PaletteManager& rPaletteManager,
BorderColorStatus& rBorderColorStatus,
sal_uInt16 nSlotId, sal_uInt16 nSlotId,
const Reference< XFrame >& rFrame, const Reference< XFrame >& rFrame,
const OUString& rWndTitle, const OUString& rWndTitle,
...@@ -1136,7 +1137,8 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, ...@@ -1136,7 +1137,8 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
rFrame ), rFrame ),
theSlotId( nSlotId ), theSlotId( nSlotId ),
maCommand( rCommand ), maCommand( rCommand ),
mrPaletteManager( rPaletteManager ) mrPaletteManager( rPaletteManager ),
mrBorderColorStatus( rBorderColorStatus )
{ {
get(mpPaletteListBox, "palette_listbox"); get(mpPaletteListBox, "palette_listbox");
get(mpButtonAutoColor, "auto_color_button"); get(mpButtonAutoColor, "auto_color_button");
...@@ -1217,6 +1219,11 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, ...@@ -1217,6 +1219,11 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
AddStatusListener( ".uno:ColorTableState" ); AddStatusListener( ".uno:ColorTableState" );
AddStatusListener( maCommand ); AddStatusListener( maCommand );
if ( maCommand == ".uno:FrameLineColor" )
{
AddStatusListener( ".uno:BorderTLBR" );
AddStatusListener( ".uno:BorderBLTR" );
}
} }
SvxColorWindow_Impl::~SvxColorWindow_Impl() SvxColorWindow_Impl::~SvxColorWindow_Impl()
...@@ -1230,7 +1237,7 @@ void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt ) ...@@ -1230,7 +1237,7 @@ void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt )
SfxPopupWindow* SvxColorWindow_Impl::Clone() const SfxPopupWindow* SvxColorWindow_Impl::Clone() const
{ {
return new SvxColorWindow_Impl( maCommand, mrPaletteManager, theSlotId, GetFrame(), GetText(), GetParent() ); return new SvxColorWindow_Impl( maCommand, mrPaletteManager, mrBorderColorStatus, theSlotId, GetFrame(), GetText(), GetParent() );
} }
IMPL_LINK(SvxColorWindow_Impl, SelectHdl, SvxColorValueSet*, pColorSet) IMPL_LINK(SvxColorWindow_Impl, SelectHdl, SvxColorValueSet*, pColorSet)
...@@ -1310,40 +1317,133 @@ bool SvxColorWindow_Impl::Close() ...@@ -1310,40 +1317,133 @@ bool SvxColorWindow_Impl::Close()
void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
{ {
if (( SfxItemState::DISABLED != eState ) && pState ) if ( nSID == SID_COLOR_TABLE )
{ {
if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorListItem ))) if ( SfxItemState::DEFAULT == eState && mrPaletteManager.GetPalette() == 0 )
{
if ( mrPaletteManager.GetPalette() == 0 )
{ {
mrPaletteManager.ReloadColorSet(*mpColorSet); mrPaletteManager.ReloadColorSet(*mpColorSet);
mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mrPaletteManager.GetColorCount()); mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mrPaletteManager.GetColorCount());
} }
} }
else if ( SfxItemState::DEFAULT <= eState ) else
{ {
mpColorSet->SetNoSelection(); mpColorSet->SetNoSelection();
Color aColor( COL_TRANSPARENT );
Color aColor; if ( nSID == SID_FRAME_LINECOLOR
|| nSID == SID_ATTR_BORDER_DIAG_TLBR
|| nSID == SID_ATTR_BORDER_DIAG_BLTR )
{
mrBorderColorStatus.StateChanged( nSID, eState, pState );
aColor = mrBorderColorStatus.GetColor();
}
else if ( SfxItemState::DEFAULT <= eState && pState )
{
if ( pState->ISA( SvxColorItem ) ) if ( pState->ISA( SvxColorItem ) )
aColor = static_cast<const SvxColorItem*>(pState)->GetValue(); aColor = static_cast<const SvxColorItem*>(pState)->GetValue();
else if ( pState->ISA( XLineColorItem ) ) else if ( pState->ISA( XLineColorItem ) )
aColor = static_cast<const XLineColorItem*>(pState)->GetColorValue(); aColor = static_cast<const XLineColorItem*>(pState)->GetColorValue();
else if ( pState->ISA( XFillColorItem ) ) else if ( pState->ISA( XFillColorItem ) )
aColor = static_cast<const XFillColorItem*>(pState)->GetColorValue(); aColor = static_cast<const XFillColorItem*>(pState)->GetColorValue();
}
if ( aColor == COL_TRANSPARENT )
return;
for ( size_t i = 1; i <= mpColorSet->GetItemCount(); ++i ) for ( size_t i = 1; i <= mpColorSet->GetItemCount(); ++i )
{ {
if ( aColor == mpColorSet->GetItemColor(i) ) if ( aColor == mpColorSet->GetItemColor(i) )
{ {
mpColorSet->SelectItem(i); mpColorSet->SelectItem(i);
return; break;
}
}
} }
}
BorderColorStatus::BorderColorStatus() :
maColor( COL_TRANSPARENT ),
maTLBRColor( COL_TRANSPARENT ),
maBLTRColor( COL_TRANSPARENT )
{
}
BorderColorStatus::~BorderColorStatus()
{
}
void BorderColorStatus::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState )
{
if ( SfxItemState::DEFAULT <= eState && pState )
{
if ( nSID == SID_FRAME_LINECOLOR && pState->ISA( SvxColorItem ) )
{
maColor = static_cast< const SvxColorItem* >(pState)->GetValue();
} }
else if ( pState->ISA( SvxLineItem ) )
{
const SvxBorderLine* pLine = static_cast< const SvxLineItem* >(pState)->GetLine();
Color aColor ( COL_TRANSPARENT );
if ( pLine )
aColor = pLine->GetColor();
if ( nSID == SID_ATTR_BORDER_DIAG_TLBR )
maTLBRColor = aColor;
else if ( nSID == SID_ATTR_BORDER_DIAG_BLTR )
maBLTRColor = aColor;
} }
} }
else if ( nSID == SID_FRAME_LINECOLOR )
maColor = COL_TRANSPARENT;
else if ( nSID == SID_ATTR_BORDER_DIAG_TLBR )
maTLBRColor = COL_TRANSPARENT;
else if ( nSID == SID_ATTR_BORDER_DIAG_BLTR )
maBLTRColor = COL_TRANSPARENT;
} }
Color BorderColorStatus::GetColor()
{
bool bHasColor = maColor != COL_TRANSPARENT;
bool bHasTLBRColor = maTLBRColor != COL_TRANSPARENT;
bool bHasBLTRColor = maBLTRColor != COL_TRANSPARENT;
if ( !bHasColor && bHasTLBRColor && !bHasBLTRColor )
return maTLBRColor;
else if ( !bHasColor && !bHasTLBRColor && bHasBLTRColor )
return maBLTRColor;
else if ( bHasColor && bHasTLBRColor && !bHasBLTRColor )
{
if ( maColor == maTLBRColor )
return maColor;
else
return maBLTRColor;
}
else if ( bHasColor && !bHasTLBRColor && bHasBLTRColor )
{
if ( maColor == maBLTRColor )
return maColor;
else
return maTLBRColor;
}
else if ( !bHasColor && bHasTLBRColor && bHasBLTRColor )
{
if ( maTLBRColor == maBLTRColor )
return maTLBRColor;
else
return maColor;
}
else if ( bHasColor && bHasTLBRColor && bHasBLTRColor )
{
if ( maColor == maTLBRColor && maColor == maBLTRColor )
return maColor;
else
return COL_TRANSPARENT;
}
return maColor;
}
SvxFrameWindow_Impl::SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, vcl::Window* pParentWindow ) : SvxFrameWindow_Impl::SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, vcl::Window* pParentWindow ) :
SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ), SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
aFrameSet ( this, WinBits( WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ), aFrameSet ( this, WinBits( WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
...@@ -2357,6 +2457,8 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( ...@@ -2357,6 +2457,8 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
case SID_FRAME_LINECOLOR: case SID_FRAME_LINECOLOR:
addStatusListener( OUString( ".uno:FrameLineColor" )); addStatusListener( OUString( ".uno:FrameLineColor" ));
addStatusListener( OUString( ".uno:BorderTLBR" ));
addStatusListener( OUString( ".uno:BorderBLTR" ));
mPaletteManager.SetLastColor( COL_BLUE ); mPaletteManager.SetLastColor( COL_BLUE );
break; break;
...@@ -2399,6 +2501,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow() ...@@ -2399,6 +2501,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
new SvxColorWindow_Impl( new SvxColorWindow_Impl(
m_aCommandURL, m_aCommandURL,
mPaletteManager, mPaletteManager,
maBorderColorStatus,
GetSlotId(), GetSlotId(),
m_xFrame, m_xFrame,
SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ), SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
...@@ -2435,6 +2538,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow() ...@@ -2435,6 +2538,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE ); FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE );
pColorWin->StartSelection(); pColorWin->StartSelection();
SetPopupWindow( pColorWin ); SetPopupWindow( pColorWin );
if ( !bSidebarType )
pColorWin->SetSelectedHdl( LINK( this, SvxColorToolBoxControl, SelectedHdl ) ); pColorWin->SetSelectedHdl( LINK( this, SvxColorToolBoxControl, SelectedHdl ) );
return pColorWin; return pColorWin;
} }
...@@ -2449,34 +2553,29 @@ IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, Color*, pColor) ...@@ -2449,34 +2553,29 @@ IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, Color*, pColor)
void SvxColorToolBoxControl::StateChanged( void SvxColorToolBoxControl::StateChanged(
sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
{ {
ToolBox& rTbx = GetToolBox();
sal_uInt16 nId = GetId();
rTbx.EnableItem( nId, SfxItemState::DISABLED != eState );
rTbx.SetItemState( nId, ( SfxItemState::DONTCARE == eState ) ? TRISTATE_INDET : TRISTATE_FALSE );
if ( nSID == SID_ATTR_CHAR_COLOR_EXT || nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT ) if ( nSID == SID_ATTR_CHAR_COLOR_EXT || nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT )
SfxToolBoxControl::StateChanged( nSID, eState, pState );
else if ( bSidebarType )
{ {
if ( pState && SfxItemState::DONTCARE != eState ) Color aColor( COL_TRANSPARENT );
if ( nSID == SID_FRAME_LINECOLOR
|| nSID == SID_ATTR_BORDER_DIAG_TLBR
|| nSID == SID_ATTR_BORDER_DIAG_BLTR )
{ {
const SfxBoolItem* pBool = static_cast< const SfxBoolItem* >( pState ); maBorderColorStatus.StateChanged( nSID, eState, pState );
rTbx.CheckItem( nId, pBool && pBool->GetValue() ); aColor = maBorderColorStatus.GetColor();
} }
} else if ( SfxItemState::DEFAULT <= eState && pState )
else if ( bSidebarType && SfxItemState::DEFAULT <= eState )
{ {
Color aColor;
if ( pState->ISA( SvxColorItem ) ) if ( pState->ISA( SvxColorItem ) )
aColor = static_cast< const SvxColorItem* >(pState)->GetValue(); aColor = static_cast< const SvxColorItem* >(pState)->GetValue();
else if ( pState->ISA( XLineColorItem ) ) else if ( pState->ISA( XLineColorItem ) )
aColor = static_cast< const XLineColorItem* >(pState)->GetColorValue(); aColor = static_cast< const XLineColorItem* >(pState)->GetColorValue();
else if ( pState->ISA( XFillColorItem ) ) else if ( pState->ISA( XFillColorItem ) )
aColor = static_cast< const XFillColorItem* >(pState)->GetColorValue(); aColor = static_cast< const XFillColorItem* >(pState)->GetColorValue();
pBtnUpdater->Update( aColor );
} }
else if ( bSidebarType ) pBtnUpdater->Update( aColor );
{
pBtnUpdater->Update( COL_TRANSPARENT );
} }
} }
......
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