Kaydet (Commit) 900d3eb3 authored tarafından Rob Snelders's avatar Rob Snelders Kaydeden (comit) Michael Meeks

Added the Adding and removing of color charts

üst e8216218
...@@ -43,7 +43,8 @@ SvxChartColorTable::SvxChartColorTable() ...@@ -43,7 +43,8 @@ SvxChartColorTable::SvxChartColorTable()
{} {}
SvxChartColorTable::SvxChartColorTable( const SvxChartColorTable & _rSource ) : SvxChartColorTable::SvxChartColorTable( const SvxChartColorTable & _rSource ) :
m_aColorEntries( _rSource.m_aColorEntries ) m_aColorEntries( _rSource.m_aColorEntries ),
nNextElementNumber( m_aColorEntries.size() + 1 )
{} {}
// accessors // accessors
...@@ -79,6 +80,7 @@ ColorData SvxChartColorTable::getColorData( size_t _nIndex ) const ...@@ -79,6 +80,7 @@ ColorData SvxChartColorTable::getColorData( size_t _nIndex ) const
void SvxChartColorTable::clear() void SvxChartColorTable::clear()
{ {
m_aColorEntries.clear(); m_aColorEntries.clear();
nNextElementNumber = 1;
} }
void SvxChartColorTable::append( const XColorEntry & _rEntry ) void SvxChartColorTable::append( const XColorEntry & _rEntry )
...@@ -86,6 +88,12 @@ void SvxChartColorTable::append( const XColorEntry & _rEntry ) ...@@ -86,6 +88,12 @@ void SvxChartColorTable::append( const XColorEntry & _rEntry )
m_aColorEntries.push_back( _rEntry ); m_aColorEntries.push_back( _rEntry );
} }
void SvxChartColorTable::remove( size_t _nIndex )
{
if (m_aColorEntries.size() > 0)
m_aColorEntries.erase( m_aColorEntries.begin() + _nIndex);
}
void SvxChartColorTable::replace( size_t _nIndex, const XColorEntry & _rEntry ) void SvxChartColorTable::replace( size_t _nIndex, const XColorEntry & _rEntry )
{ {
DBG_ASSERT( _nIndex <= m_aColorEntries.size(), DBG_ASSERT( _nIndex <= m_aColorEntries.size(),
...@@ -113,25 +121,37 @@ void SvxChartColorTable::useDefault() ...@@ -113,25 +121,37 @@ void SvxChartColorTable::useDefault()
clear(); clear();
String aResName( CUI_RES( RID_SVXSTR_DIAGRAM_ROW ) ); for( sal_Int32 i=0; i<ROW_COLOR_COUNT; i++ )
String aPrefix, aPostfix, aName;
xub_StrLen nPos = aResName.SearchAscii( "$(ROW)" );
if( nPos != STRING_NOTFOUND )
{ {
aPrefix = String( aResName, 0, nPos ); append( XColorEntry( aColors[ i % sizeof( aColors ) ], getNextDefaultName() ));
aPostfix = String( aResName, nPos + sizeof( "$(ROW)" ) - 1, STRING_LEN );
} }
else }
aPrefix = aResName;
for( sal_Int32 i=0; i<ROW_COLOR_COUNT; i++ ) String SvxChartColorTable::getNextDefaultName()
{ {
aName = aPrefix; String aName;
aName.Append( String::CreateFromInt32( i + 1 ));
aName.Append( aPostfix );
append( XColorEntry( aColors[ i % sizeof( aColors ) ], aName )); if (sDefaultNamePrefix.Len() == 0)
{
String aResName( CUI_RES( RID_SVXSTR_DIAGRAM_ROW ) );
xub_StrLen nPos = aResName.SearchAscii( "$(ROW)" );
if( nPos != STRING_NOTFOUND )
{
sDefaultNamePrefix = String( aResName, 0, nPos );
sDefaultNamePostfix = String( aResName, nPos + sizeof( "$(ROW)" ) - 1, STRING_LEN );
}
else
{
sDefaultNamePrefix = aResName;
}
} }
aName = sDefaultNamePrefix;
aName.Append( String::CreateFromInt32 ( nNextElementNumber ) );
aName.Append( sDefaultNamePostfix );
nNextElementNumber++;
return aName;
} }
// comparison // comparison
......
...@@ -44,6 +44,9 @@ class SvxChartColorTable ...@@ -44,6 +44,9 @@ class SvxChartColorTable
{ {
private: private:
::std::vector< XColorEntry > m_aColorEntries; ::std::vector< XColorEntry > m_aColorEntries;
int nNextElementNumber;
String sDefaultNamePrefix;
String sDefaultNamePostfix;
public: public:
SvxChartColorTable(); SvxChartColorTable();
...@@ -57,8 +60,10 @@ public: ...@@ -57,8 +60,10 @@ public:
// mutators // mutators
void clear(); void clear();
void append( const XColorEntry & _rEntry ); void append( const XColorEntry & _rEntry );
void remove( size_t _nIndex );
void replace( size_t _nIndex, const XColorEntry & _rEntry ); void replace( size_t _nIndex, const XColorEntry & _rEntry );
void useDefault(); void useDefault();
String getNextDefaultName();
// comparison // comparison
bool operator==( const SvxChartColorTable & _rOther ) const; bool operator==( const SvxChartColorTable & _rOther ) const;
...@@ -70,7 +75,7 @@ public: ...@@ -70,7 +75,7 @@ public:
class SvxChartOptions : public ::utl::ConfigItem class SvxChartOptions : public ::utl::ConfigItem
{ {
private: private:
SvxChartColorTable maDefColors; SvxChartColorTable maDefColors;
sal_Bool mbIsInitialized; sal_Bool mbIsInitialized;
::com::sun::star::uno::Sequence< ::rtl::OUString > ::com::sun::star::uno::Sequence< ::rtl::OUString >
......
...@@ -60,11 +60,15 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage( Window* pParent, const SfxItemSe ...@@ -60,11 +60,15 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage( Window* pParent, const SfxItemSe
aLbChartColors ( this, CUI_RES( LB_CHART_COLOR_LIST ) ), aLbChartColors ( this, CUI_RES( LB_CHART_COLOR_LIST ) ),
aGbColorBox ( this, CUI_RES( FL_COLOR_BOX ) ), aGbColorBox ( this, CUI_RES( FL_COLOR_BOX ) ),
aValSetColorBox ( this, CUI_RES( CT_COLOR_BOX ) ), aValSetColorBox ( this, CUI_RES( CT_COLOR_BOX ) ),
aPBDefault ( this, CUI_RES( PB_RESET_TO_DEFAULT ) ) aPBDefault ( this, CUI_RES( PB_RESET_TO_DEFAULT ) ),
aPBAdd ( this, CUI_RES( PB_ADD_CHART_COLOR ) ),
aPBRemove ( this, CUI_RES( PB_REMOVE_CHART_COLOR ) )
{ {
FreeResource(); FreeResource();
aPBDefault.SetClickHdl( LINK( this, SvxDefaultColorOptPage, ResetToDefaults ) ); aPBDefault.SetClickHdl( LINK( this, SvxDefaultColorOptPage, ResetToDefaults ) );
aPBAdd.SetClickHdl( LINK( this, SvxDefaultColorOptPage, AddChartColor ) );
aPBRemove.SetClickHdl( LINK( this, SvxDefaultColorOptPage, RemoveChartColor ) );
aLbChartColors.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, ListClickedHdl ) ); aLbChartColors.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, ListClickedHdl ) );
aValSetColorBox.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, BoxClickedHdl ) ); aValSetColorBox.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, BoxClickedHdl ) );
...@@ -195,6 +199,44 @@ IMPL_LINK( SvxDefaultColorOptPage, ResetToDefaults, void *, EMPTYARG ) ...@@ -195,6 +199,44 @@ IMPL_LINK( SvxDefaultColorOptPage, ResetToDefaults, void *, EMPTYARG )
return 0L; return 0L;
} }
// AddChartColor
// ------------
IMPL_LINK( SvxDefaultColorOptPage, AddChartColor, void *, EMPTYARG )
{
if( pColorConfig )
{
ColorData black = RGB_COLORDATA( 0x00, 0x00, 0x00 );
pColorConfig->GetColorTable().append (XColorEntry ( black, pColorConfig->GetColorTable().getNextDefaultName()));
aLbChartColors.Clear();
aLbChartColors.FillBox( pColorConfig->GetColorTable() );
aLbChartColors.GetFocus();
}
return 0L;
}
// RemoveChartColor
// ----------------
IMPL_LINK( SvxDefaultColorOptPage, RemoveChartColor, void *, EMPTYARG )
{
if( pColorConfig )
{
pColorConfig->GetColorTable().remove( aLbChartColors.GetSelectEntryPos() );
aLbChartColors.Clear();
aLbChartColors.FillBox( pColorConfig->GetColorTable() );
aLbChartColors.GetFocus();
}
return 0L;
}
// ListClickedHdl // ListClickedHdl
// -------------- // --------------
......
...@@ -34,4 +34,5 @@ ...@@ -34,4 +34,5 @@
#define CT_COLOR_BOX 4 #define CT_COLOR_BOX 4
#define PB_RESET_TO_DEFAULT 5 #define PB_RESET_TO_DEFAULT 5
#define PB_ADD_CHART_COLOR 6
#define PB_REMOVE_CHART_COLOR 7
...@@ -56,17 +56,21 @@ public: ...@@ -56,17 +56,21 @@ public:
class SvxDefaultColorOptPage : public SfxTabPage class SvxDefaultColorOptPage : public SfxTabPage
{ {
private: private:
FixedLine aGbChartColors; FixedLine aGbChartColors;
ChartColorLB aLbChartColors; ChartColorLB aLbChartColors;
FixedLine aGbColorBox; FixedLine aGbColorBox;
ValueSet aValSetColorBox; ValueSet aValSetColorBox;
PushButton aPBDefault; PushButton aPBDefault;
PushButton aPBAdd;
PushButton aPBRemove;
SvxChartOptions* pChartOptions; SvxChartOptions* pChartOptions;
SvxChartColorTableItem* pColorConfig; SvxChartColorTableItem* pColorConfig;
XColorTable* pColorTab; XColorTable* pColorTab;
DECL_LINK( ResetToDefaults, void * ); DECL_LINK( ResetToDefaults, void * );
DECL_LINK( AddChartColor, void * );
DECL_LINK( RemoveChartColor, void * );
DECL_LINK( ListClickedHdl, ChartColorLB * ); DECL_LINK( ListClickedHdl, ChartColorLB * );
DECL_LINK( BoxClickedHdl, ValueSet * ); DECL_LINK( BoxClickedHdl, ValueSet * );
......
...@@ -39,7 +39,7 @@ TabPage RID_OPTPAGE_CHART_DEFCOLORS ...@@ -39,7 +39,7 @@ TabPage RID_OPTPAGE_CHART_DEFCOLORS
Text [ en-US ] = "Default Colors"; Text [ en-US ] = "Default Colors";
FixedLine FL_CHART_COLOR_LIST FixedLine FL_CHART_COLOR_LIST
{ {
Pos = MAP_APPFONT ( 6 , 3 ) ; Pos = MAP_APPFONT ( 6 , 3 ) ;
Size = MAP_APPFONT ( 80 , 8 ) ; Size = MAP_APPFONT ( 80 , 8 ) ;
Text [ en-US ] = "Chart colors"; Text [ en-US ] = "Chart colors";
Text [ x-comment ] = " "; Text [ x-comment ] = " ";
...@@ -48,7 +48,7 @@ TabPage RID_OPTPAGE_CHART_DEFCOLORS ...@@ -48,7 +48,7 @@ TabPage RID_OPTPAGE_CHART_DEFCOLORS
{ {
HelpID = "cui:ListBox:RID_OPTPAGE_CHART_DEFCOLORS:LB_CHART_COLOR_LIST"; HelpID = "cui:ListBox:RID_OPTPAGE_CHART_DEFCOLORS:LB_CHART_COLOR_LIST";
Border = TRUE; Border = TRUE;
Pos = MAP_APPFONT ( 12 , 15 ); Pos = MAP_APPFONT ( 12 , 15 );
Size = MAP_APPFONT ( 68 , 152 ); Size = MAP_APPFONT ( 68 , 152 );
DropDown = FALSE; DropDown = FALSE;
TabStop = TRUE ; TabStop = TRUE ;
...@@ -56,17 +56,31 @@ TabPage RID_OPTPAGE_CHART_DEFCOLORS ...@@ -56,17 +56,31 @@ TabPage RID_OPTPAGE_CHART_DEFCOLORS
FixedLine FL_COLOR_BOX FixedLine FL_COLOR_BOX
{ {
Pos = MAP_APPFONT ( 92 , 3 ) ; Pos = MAP_APPFONT ( 92 , 3 ) ;
Size = MAP_APPFONT ( 106 , 8 ) ; Size = MAP_APPFONT ( 106 , 8 ) ;
Text [ en-US ] = "Color table" ; Text [ en-US ] = "Color table" ;
Text [ x-comment ] = " "; Text [ x-comment ] = " ";
}; };
Control CT_COLOR_BOX Control CT_COLOR_BOX
{ {
Border = TRUE; Border = TRUE;
Pos = MAP_APPFONT ( 98 , 15 ); Pos = MAP_APPFONT ( 98 , 15 );
Size = MAP_APPFONT ( 94 , 152 ); Size = MAP_APPFONT ( 94 , 152 );
TabStop = TRUE ; TabStop = TRUE ;
}; };
PushButton PB_ADD_CHART_COLOR
{
Pos = MAP_APPFONT ( 204 , 15 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
Text [ en-US ] = "~Add";
Text [ x-comment ] = " ";
};
PushButton PB_REMOVE_CHART_COLOR
{
Pos = MAP_APPFONT ( 204 , 32 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
Text [ en-US ] = "~Remove";
Text [ x-comment ] = " ";
};
PushButton PB_RESET_TO_DEFAULT PushButton PB_RESET_TO_DEFAULT
{ {
HelpID = "cui:PushButton:RID_OPTPAGE_CHART_DEFCOLORS:PB_RESET_TO_DEFAULT"; HelpID = "cui:PushButton:RID_OPTPAGE_CHART_DEFCOLORS:PB_RESET_TO_DEFAULT";
......
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