diff options
author | Michael Meeks <michael.meeks@novell.com> | 2011-09-23 14:05:07 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2011-09-24 08:33:46 +0100 |
commit | c8dc73720883333a13187865cd0d69b64af6b4b5 (patch) | |
tree | c9037bb6e79fd49507f2de1cf2b22f7159572720 /cui/source/options/optchart.cxx | |
parent | 7fc35af5fd3171cc9bf43d2c27660afcf407d3f6 (diff) |
re-factor XPropertyList derivatives to use a rtl::Reference
This cleans up a lot of lifecycle nasties and cleans up some serious
cut/paste code duplication issues at the same time. Cleanup the
naming of ColorTable -> ColorList to match the impl. too
Diffstat (limited to 'cui/source/options/optchart.cxx')
-rw-r--r-- | cui/source/options/optchart.cxx | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index 0279a352b6df..9200d647cf31 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -81,7 +81,7 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage( Window* pParent, const SfxItemSe aValSetColorBox.Show(); pChartOptions = new SvxChartOptions; - pColorTab = new XColorList( SvtPathOptions().GetPalettePath() ); + pColorList = XColorList::CreateStdColorList(); const SfxPoolItem* pItem = NULL; if ( rInAttrs.GetItemState( SID_SCH_EDITOPTIONS, sal_False, &pItem ) == SFX_ITEM_SET ) @@ -102,18 +102,17 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage( Window* pParent, const SfxItemSe SvxDefaultColorOptPage::~SvxDefaultColorOptPage() { // save changes - pChartOptions->SetDefaultColors( pColorConfig->GetColorTable() ); + pChartOptions->SetDefaultColors( pColorConfig->GetColorList() ); pChartOptions->Commit(); delete pColorConfig; - delete pColorTab; delete pChartOptions; } void SvxDefaultColorOptPage::Construct() { if( pColorConfig ) - aLbChartColors.FillBox( pColorConfig->GetColorTable() ); + aLbChartColors.FillBox( pColorConfig->GetColorList() ); FillColorBox(); @@ -143,9 +142,9 @@ void SvxDefaultColorOptPage::Reset( const SfxItemSet& ) void SvxDefaultColorOptPage::FillColorBox() { - if( !pColorTab ) return; + if( !pColorList.is() ) return; - long nCount = pColorTab->Count(); + long nCount = pColorList->Count(); XColorEntry* pColorEntry; if( nCount > 104 ) @@ -153,7 +152,7 @@ void SvxDefaultColorOptPage::FillColorBox() for( long i = 0; i < nCount; i++ ) { - pColorEntry = pColorTab->GetColor( i ); + pColorEntry = pColorList->GetColor( i ); aValSetColorBox.InsertItem( (sal_uInt16) i + 1, pColorEntry->GetColor(), pColorEntry->GetName() ); } } @@ -161,16 +160,16 @@ void SvxDefaultColorOptPage::FillColorBox() long SvxDefaultColorOptPage::GetColorIndex( const Color& rCol ) { - if( pColorTab ) + if( pColorList.is() ) { - long nCount = pColorTab->Count(); + long nCount = pColorList->Count(); XColorEntry* pColorEntry; for( long i = nCount - 1; i >= 0; i-- ) // default chart colors are at the end of the table { - pColorEntry = pColorTab->GetColor( i ); + pColorEntry = pColorList->GetColor( i ); if( pColorEntry && pColorEntry->GetColor() == rCol ) - return SAL_STATIC_CAST( XPropertyList*, pColorTab )->Get( pColorEntry->GetName() ); + return pColorList->Get( pColorEntry->GetName() ); } } return -1L; @@ -189,10 +188,10 @@ IMPL_LINK( SvxDefaultColorOptPage, ResetToDefaults, void *, EMPTYARG ) { if( pColorConfig ) { - pColorConfig->GetColorTable().useDefault(); + pColorConfig->GetColorList().useDefault(); aLbChartColors.Clear(); - aLbChartColors.FillBox( pColorConfig->GetColorTable() ); + aLbChartColors.FillBox( pColorConfig->GetColorList() ); aLbChartColors.GetFocus(); aLbChartColors.SelectEntryPos( 0 ); @@ -211,13 +210,13 @@ IMPL_LINK( SvxDefaultColorOptPage, AddChartColor, void *, EMPTYARG ) { ColorData black = RGB_COLORDATA( 0x00, 0x00, 0x00 ); - pColorConfig->GetColorTable().append (XColorEntry ( black, pColorConfig->GetColorTable().getDefaultName(pColorConfig->GetColorTable().size()))); + pColorConfig->GetColorList().append (XColorEntry ( black, pColorConfig->GetColorList().getDefaultName(pColorConfig->GetColorList().size()))); aLbChartColors.Clear(); - aLbChartColors.FillBox( pColorConfig->GetColorTable() ); + aLbChartColors.FillBox( pColorConfig->GetColorList() ); aLbChartColors.GetFocus(); - aLbChartColors.SelectEntryPos( pColorConfig->GetColorTable().size() - 1 ); + aLbChartColors.SelectEntryPos( pColorConfig->GetColorList().size() - 1 ); aPBRemove.Enable( sal_True ); } @@ -236,21 +235,21 @@ IMPL_LINK( SvxDefaultColorOptPage, RemoveChartColor, PushButton*, pButton ) if( pColorConfig ) { - OSL_ENSURE(pColorConfig->GetColorTable().size() > 1, "don't delete the last chart color"); + OSL_ENSURE(pColorConfig->GetColorList().size() > 1, "don't delete the last chart color"); QueryBox aQuery(pButton, CUI_RES(RID_OPTQB_COLOR_CHART_DELETE)); aQuery.SetText(String(CUI_RES(RID_OPTSTR_COLOR_CHART_DELETE))); if(RET_YES == aQuery.Execute()) { - pColorConfig->GetColorTable().remove( nIndex ); + pColorConfig->GetColorList().remove( nIndex ); aLbChartColors.Clear(); - aLbChartColors.FillBox( pColorConfig->GetColorTable() ); + aLbChartColors.FillBox( pColorConfig->GetColorList() ); aLbChartColors.GetFocus(); if (nIndex == aLbChartColors.GetEntryCount() && aLbChartColors.GetEntryCount() > 0) - aLbChartColors.SelectEntryPos( pColorConfig->GetColorTable().size() - 1 ); + aLbChartColors.SelectEntryPos( pColorConfig->GetColorList().size() - 1 ); else if (aLbChartColors.GetEntryCount() > 0) aLbChartColors.SelectEntryPos( nIndex ); else @@ -261,30 +260,20 @@ IMPL_LINK( SvxDefaultColorOptPage, RemoveChartColor, PushButton*, pButton ) return 0L; } -// ListClickedHdl -// -------------- - -IMPL_LINK( SvxDefaultColorOptPage, ListClickedHdl, ChartColorLB*, pColorList ) +IMPL_LINK( SvxDefaultColorOptPage, ListClickedHdl, ChartColorLB*, _pColorList ) { - Color aCol = pColorList->GetSelectEntryColor(); + Color aCol = _pColorList->GetSelectEntryColor(); long nIndex = GetColorIndex( aCol ); if( nIndex == -1 ) // not found - { aValSetColorBox.SetNoSelection(); - } else - { aValSetColorBox.SelectItem( (sal_uInt16)nIndex + 1 ); // ValueSet is 1-based - } return 0L; } -// BoxClickedHdl -// ------------- - IMPL_LINK( SvxDefaultColorOptPage, BoxClickedHdl, ValueSet*, EMPTYARG ) { sal_uInt16 nIdx = aLbChartColors.GetSelectEntryPos(); |