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

fdo#46839 Convert line color picker to split button

Change-Id: I4987cc9ffba675009f2d2ae9f6b12ed4ee02fe13
üst 20580178
......@@ -260,6 +260,7 @@
#define RID_SVXSTR_MORE (RID_SVX_START + 198)
#define RID_SVXSTR_CHARFONTNAME_NOTAVAILABLE (RID_SVX_START + 199)
#define RID_SVXSTR_CHARFONTNAME (RID_SVX_START + 200)
#define RID_SVXSTR_LINECOLOR (RID_SVX_START + 201)
// Strings for insert/overwrite mode
#define RID_SVXSTR_INSERT_HELPTEXT (RID_SVX_START + 210)
......
......@@ -30,7 +30,6 @@ class XLineStyleItem;
class XLineDashItem;
class SvxLineBox;
class SvxMetricField;
class SvxColorBox;
// SvxLineStyleController:
......@@ -74,23 +73,6 @@ public:
};
// SvxLineColorController:
class SVX_DLLPUBLIC SvxLineColorToolBoxControl : public SfxToolBoxControl
{
public:
SFX_DECL_TOOLBOX_CONTROL();
SvxLineColorToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
virtual ~SvxLineColorToolBoxControl();
virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
const SfxPoolItem* pState ) SAL_OVERRIDE;
void Update( const SfxPoolItem* pState );
virtual Window* CreateItemWindow( Window *pParent ) SAL_OVERRIDE;
};
// class SvxLineEndWindow
......
......@@ -66,6 +66,11 @@
for 3D extrusion
Execute-Id SID_EXTRUSION_3D_COLOR
SvxLineColorToolBoxControl
--------------------------
Item type: XLineColorItem
Execute-Id SID_ATTR_LINE_COLOR
SvxPatternToolBoxControl
------------------------
Item type: SvxBrushItem
......@@ -230,6 +235,26 @@ public:
};
// class SvxLineColorToolBoxControl --------------------------------------
class SVX_DLLPUBLIC SvxLineColorToolBoxControl : public SfxToolBoxControl
{
::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
Color mLastColor;
DECL_LINK( SelectedHdl, Color* );
public:
SFX_DECL_TOOLBOX_CONTROL();
SvxLineColorToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
virtual ~SvxLineColorToolBoxControl();
virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
const SfxPoolItem* pState ) SAL_OVERRIDE;
virtual SfxPopupWindowType GetPopupWindowType() const SAL_OVERRIDE;
virtual SfxPopupWindow* CreatePopupWindow() SAL_OVERRIDE;
virtual void Select(sal_uInt16 nSelectModifier) SAL_OVERRIDE;
};
// class SvxFrameToolBoxControl ------------------------------------------
class SVX_DLLPUBLIC SvxFrameToolBoxControl : public SfxToolBoxControl
......
......@@ -25,7 +25,7 @@
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:LineWidth" toolbar:helpid="10171"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:helpid="10172"/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:style="dropdown" toolbar:helpid="10172"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FormatArea" toolbar:helpid="10142"/>
<toolbar:toolbarseparator/>
......
......@@ -27,7 +27,7 @@
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:LineWidth" toolbar:helpid="10171"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:helpid="10172"/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:style="dropdown" toolbar:helpid="10172"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FormatArea" toolbar:helpid="10142"/>
<toolbar:toolbarseparator/>
......
......@@ -27,7 +27,7 @@
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:LineWidth" toolbar:helpid="10171"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:helpid="10172"/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:style="dropdown" toolbar:helpid="10172"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FormatArea" toolbar:helpid="10142"/>
<toolbar:toolbarseparator/>
......
......@@ -203,7 +203,7 @@ LinePropertyPanel::LinePropertyPanel(
get(mpLBCapStyle, "linecapstyle");
const sal_uInt16 nIdColor = mpTBColor->GetItemId(UNO_SELECTCOLOR);
mpColorUpdater.reset(new ::svx::ToolboxButtonColorUpdater(SID_ATTR_LINE_COLOR, nIdColor, mpTBColor)),
mpColorUpdater.reset(new ::svx::ToolboxButtonColorUpdater(0 /* not defined, default is transparent */, nIdColor, mpTBColor)),
Initialize();
}
......
......@@ -48,7 +48,6 @@ using namespace ::com::sun::star::lang;
SFX_IMPL_TOOLBOX_CONTROL( SvxLineStyleToolBoxControl, XLineStyleItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxLineColorToolBoxControl, XLineColorItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxLineEndToolBoxControl, SfxBoolItem );
/*************************************************************************
......@@ -262,84 +261,8 @@ Window* SvxLineWidthToolBoxControl::CreateItemWindow( Window *pParent )
return( new SvxMetricField( pParent, m_xFrame ) );
}
/*************************************************************************
|*
|* SvxLineColorToolBoxControl
|*
\************************************************************************/
SvxLineColorToolBoxControl::SvxLineColorToolBoxControl(
sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx )
{
addStatusListener( OUString( ".uno:ColorTableState" ));
}
SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl()
{
}
void SvxLineColorToolBoxControl::StateChanged(
sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
{
SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() );
DBG_ASSERT( pBox, "Window not found" );
if ( nSID != SID_COLOR_TABLE )
{
if ( eState == SFX_ITEM_DISABLED )
{
pBox->Disable();
pBox->SetNoSelection();
}
else
{
pBox->Enable();
if ( eState == SFX_ITEM_AVAILABLE )
{
DBG_ASSERT( pState->ISA(XLineColorItem), "wrong ItemType" );
pBox->Update( (const XLineColorItem*) pState );
}
else
pBox->Update( NULL );
}
}
else
Update( pState );
}
void SvxLineColorToolBoxControl::Update( const SfxPoolItem* pState )
{
if ( pState && ( pState->ISA( SvxColorListItem ) ) )
{
SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() );
DBG_ASSERT( pBox, "Window not found" );
// The list of colors (ColorTable) has changed:
::Color aTmpColor( pBox->GetSelectEntryColor() );
pBox->Clear();
pBox->Fill( ( (SvxColorListItem*)pState )->GetColorList() );
pBox->SelectEntry( aTmpColor );
}
}
Window* SvxLineColorToolBoxControl::CreateItemWindow( Window *pParent )
{
return new SvxColorBox( pParent, m_aCommandURL, m_xFrame );
}
/*************************************************************************
|*
|* SvxLineEndWindow
......
......@@ -87,6 +87,7 @@
#include <svx/tbxcolorupdate.hxx>
#include <editeng/eerdll.hxx>
#include <editeng/editrids.hrc>
#include <svx/xlnclit.hxx>
......@@ -115,6 +116,7 @@ using namespace ::com::sun::star::lang;
SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxColorToolBoxControl, SvxColorItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxLineColorToolBoxControl, XLineColorItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl, SvxBoxItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem );
......@@ -1119,10 +1121,14 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR ) );
}
}
else
else if ( SID_FRAME_LINECOLOR == theSlotId )
{
aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
}
else
{
aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_LINECOLOR ) );
}
if ( pColorList.is() )
{
......@@ -1228,10 +1234,16 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
aColorSet.Clear();
aColorSet.addEntriesForXColorList(*pColorList);
}
else if ((SFX_ITEM_DEFAULT <= eState ) && ( pState->ISA( SvxColorItem )))
else if ( SFX_ITEM_DEFAULT <= eState )
{
aColorSet.SetNoSelection();
const Color rColor = ((const SvxColorItem*)pState)->GetValue();
Color rColor;
if ( pState->ISA( SvxColorItem ) )
rColor = ((const SvxColorItem*)pState)->GetValue();
else if ( pState->ISA( XLineColorItem ) )
rColor = ((const XLineColorItem*)pState)->GetColorValue();
for ( size_t i = 1; i < aColorSet.GetItemCount(); i++ )
{
if ( rColor == aColorSet.GetItemColor(i) )
......@@ -2464,6 +2476,75 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
}
// class SvxLineColorToolBoxControl ----------------------------------------
SvxLineColorToolBoxControl::SvxLineColorToolBoxControl(
sal_uInt16 nSlotId,
sal_uInt16 nId,
ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx ),
mLastColor( COL_BLACK )
{
rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
addStatusListener( OUString( ".uno:XLineColor" ) );
pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) );
}
SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl()
{
}
SfxPopupWindowType SvxLineColorToolBoxControl::GetPopupWindowType() const
{
return SFX_POPUPWINDOW_ONTIMEOUT;
}
SfxPopupWindow* SvxLineColorToolBoxControl::CreatePopupWindow()
{
SvxColorWindow_Impl* pColorWin =
new SvxColorWindow_Impl(
m_aCommandURL,
GetSlotId(),
m_xFrame,
SVX_RESSTR( RID_SVXSTR_LINECOLOR ),
&GetToolBox() );
pColorWin->StartPopupMode( &GetToolBox(),
FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE );
pColorWin->StartSelection();
SetPopupWindow( pColorWin );
pColorWin->SetSelectedHdl( LINK( this, SvxLineColorToolBoxControl, SelectedHdl ) );
return pColorWin;
}
IMPL_LINK(SvxLineColorToolBoxControl, SelectedHdl, Color*, pColor)
{
pBtnUpdater->Update( *pColor );
mLastColor = *pColor;
return 0;
}
void SvxLineColorToolBoxControl::StateChanged(
sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* /*pState*/ )
{
ToolBox& rTbx = GetToolBox();
sal_uInt16 nId = GetId();
rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? TRISTATE_INDET : TRISTATE_FALSE );
}
void SvxLineColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
{
Sequence< PropertyValue > aArgs( 1 );
aArgs[0].Name = "XLineColor";
aArgs[0].Value = makeAny( (sal_uInt32)( mLastColor.GetColor() ));
Dispatch( OUString( ".uno:XLineColor" ), aArgs );
}
// class SvxFrameToolBoxControl ------------------------------------------
......
......@@ -71,6 +71,11 @@ String RID_SVXSTR_FRAME_COLOR
Text [ en-US ] = "Border Color" ;
};
String RID_SVXSTR_LINECOLOR
{
Text [ en-US ] = "Line Color" ;
};
ComboBox RID_SVXTBX_STYLE
{
HelpId = HID_STYLE_LISTBOX ;
......
......@@ -67,6 +67,9 @@ namespace svx
case SID_BACKGROUND_COLOR :
Update( COL_YELLOW );
break;
case SID_ATTR_LINE_COLOR:
Update( COL_BLACK );
break;
default :
Update( COL_TRANSPARENT );
}
......
......@@ -25,7 +25,7 @@
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:LineWidth"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor"/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:style="dropdown"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FormatArea"/>
<toolbar:toolbarseparator/>
......
......@@ -25,7 +25,7 @@
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:LineWidth" toolbar:helpid="10171"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:helpid="10172"/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:style="dropdown" toolbar:helpid="10172"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FormatArea" toolbar:helpid="10142"/>
<toolbar:toolbarseparator/>
......
......@@ -25,7 +25,7 @@
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:LineWidth"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor"/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:style="dropdown"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FormatArea"/>
<toolbar:toolbarseparator/>
......
......@@ -25,7 +25,7 @@
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:LineWidth"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor"/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:style="dropdown"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FormatArea"/>
<toolbar:toolbarseparator/>
......
......@@ -25,7 +25,7 @@
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:LineWidth"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor"/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:style="dropdown"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FormatArea"/>
<toolbar:toolbarseparator/>
......
......@@ -25,7 +25,7 @@
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:LineWidth"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor"/>
<toolbar:toolbaritem xlink:href=".uno:XLineColor" toolbar:style="dropdown"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FormatArea"/>
<toolbar:toolbarseparator/>
......
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