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 /sc | |
parent | remove obsolete Forte NOOPT files (diff) | |
download | core-c8dc73720883333a13187865cd0d69b64af6b4b5.tar.gz core-c8dc73720883333a13187865cd0d69b64af6b4b5.zip |
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 'sc')
-rw-r--r-- | sc/inc/document.hxx | 7 | ||||
-rw-r--r-- | sc/sdi/docsh.sdi | 2 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/documen9.cxx | 21 | ||||
-rw-r--r-- | sc/source/core/data/drwlayer.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/dbgui/scendlg.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh2.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drawsh.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drawsh4.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drtxtob2.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/tabbgcolordlg.cxx | 19 | ||||
-rw-r--r-- | sc/source/ui/optdlg/opredlin.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpview.cxx | 14 |
14 files changed, 54 insertions, 85 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 30a3639989b4..0d1e13de9363 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -235,7 +235,7 @@ private: SfxPrinter* pPrinter; VirtualDevice* pVirtualDevice_100th_mm; ScDrawLayer* pDrawLayer; // SdrModel - XColorList* pColorTable; + rtl::Reference<XColorList> pColorList; ScConditionalFormatList* pCondFormList; // conditional formats ScValidationDataList* pValidationList; // validity SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats @@ -433,8 +433,8 @@ public: void GetDocStat( ScDocStat& rDocStat ); - SC_DLLPUBLIC void InitDrawLayer( SfxObjectShell* pDocShell = NULL ); - XColorList* GetColorTable(); + SC_DLLPUBLIC void InitDrawLayer( SfxObjectShell* pDocShell = NULL ); + rtl::Reference<XColorList> GetColorList(); SC_DLLPUBLIC sfx2::LinkManager* GetLinkManager() const; @@ -1837,7 +1837,6 @@ private: // CLOOK-Impl-methods void ImplDeleteOptions(); void DeleteDrawLayer(); - void DeleteColorTable(); SC_DLLPUBLIC sal_Bool DrawGetPrintArea( ScRange& rRange, sal_Bool bSetHor, sal_Bool bSetVer ) const; void DrawMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ); void DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ); diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi index edf00e877e1f..3cc5609918e2 100644 --- a/sc/sdi/docsh.sdi +++ b/sc/sdi/docsh.sdi @@ -100,7 +100,7 @@ interface TableDocument SID_REIMPORT_AFTER_LOAD [ ExecMethod = Execute; ] SID_AUTO_STYLE [ ExecMethod = Execute; ] - SID_GET_COLORTABLE [ ExecMethod = Execute; ] + SID_GET_COLORLIST [ ExecMethod = Execute; ] FID_CHG_RECORD [ ExecMethod = Execute; StateMethod = GetState; ] SID_DOCUMENT_COMPARE [ ExecMethod = Execute; StateMethod = GetState; ] diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 2c6cee5e1bbd..97d834455659 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -37,6 +37,7 @@ #include <editeng/editeng.hxx> #include <editeng/forbiddencharacterstable.hxx> +#include <svx/xtable.hxx> #include <sfx2/linkmgr.hxx> #include <svx/svdpool.hxx> #include <svx/svdobj.hxx> @@ -135,7 +136,6 @@ ScDocument::ScDocument( ScDocumentMode eMode, pPrinter( NULL ), pVirtualDevice_100th_mm( NULL ), pDrawLayer( NULL ), - pColorTable( NULL ), pCondFormList( NULL ), pValidationList( NULL ), pFormatExchangeList( NULL ), @@ -451,7 +451,6 @@ ScDocument::~ScDocument() xPoolHelper->SourceDocumentGone(); xPoolHelper.clear(); - DeleteColorTable(); delete pScriptTypeData; delete pOtherObjects; delete pRecursionHelper; diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx index f7561608e50d..87115e4c4af5 100644 --- a/sc/source/core/data/documen9.cxx +++ b/sc/source/core/data/documen9.cxx @@ -83,19 +83,15 @@ void ScDocument::BeginDrawUndo() pDrawLayer->BeginCalcUndo(); } -XColorList* ScDocument::GetColorTable() +rtl::Reference<XColorList> ScDocument::GetColorList() { if (pDrawLayer) - return pDrawLayer->GetColorTable(); + return pDrawLayer->GetColorList(); else { - if (!pColorTable) - { - SvtPathOptions aPathOpt; - pColorTable = new XColorList( aPathOpt.GetPalettePath() ); - } - - return pColorTable; + if (!pColorList.is()) + pColorList = XColorList::CreateStdColorList(); + return pColorList; } } @@ -239,7 +235,7 @@ sal_Bool ScDocument::IsChart( const SdrObject* pObject ) IMPL_LINK_INLINE_START( ScDocument, GetUserDefinedColor, sal_uInt16 *, pColorIndex ) { - return (long) &((GetColorTable()->GetColor(*pColorIndex))->GetColor()); + return (long) &((GetColorList()->GetColor(*pColorIndex))->GetColor()); } IMPL_LINK_INLINE_END( ScDocument, GetUserDefinedColor, sal_uInt16 *, pColorIndex ) @@ -248,11 +244,6 @@ void ScDocument::DeleteDrawLayer() delete pDrawLayer; } -void ScDocument::DeleteColorTable() -{ - delete pColorTable; -} - sal_Bool ScDocument::DrawGetPrintArea( ScRange& rRange, sal_Bool bSetHor, sal_Bool bSetVer ) const { return pDrawLayer->GetPrintArea( rRange, bSetHor, bSetVer ); diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 9ef0e337bef5..6e22a8c42625 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -236,17 +236,17 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const String& rName ) : pGlobalDrawPersist = NULL; // nur einmal benutzen SfxObjectShell* pObjSh = pDocument ? pDocument->GetDocumentShell() : NULL; + XColorListRef pXCol = XColorList::GetStdColorList(); if ( pObjSh ) { SetObjectShell( pObjSh ); // set color table - SvxColorTableItem* pColItem = (SvxColorTableItem*) pObjSh->GetItem( SID_COLOR_TABLE ); - XColorList* pXCol = pColItem ? pColItem->GetColorTable() : &XColorList::GetStdColorTable(); - SetColorTable( pXCol ); + SvxColorListItem* pColItem = (SvxColorListItem*) pObjSh->GetItem( SID_COLOR_TABLE ); + if ( pColItem ) + pXCol = pColItem->GetColorList(); } - else - SetColorTable( &XColorList::GetStdColorTable() ); + SetPropertyList( static_cast<XPropertyList *> (pXCol.get()) ); SetSwapGraphics(sal_True); diff --git a/sc/source/ui/dbgui/scendlg.cxx b/sc/source/ui/dbgui/scendlg.cxx index 5e1cbc3121e5..91e0c01c6bc6 100644 --- a/sc/source/ui/dbgui/scendlg.cxx +++ b/sc/source/ui/dbgui/scendlg.cxx @@ -83,14 +83,14 @@ ScNewScenarioDlg::ScNewScenarioDlg( Window* pParent, const String& rName, sal_Bo const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); if ( pItem ) { - XColorList* pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable(); - if (pColorTable) + XColorListRef pColorList = ((SvxColorListItem*)pItem)->GetColorList(); + if (pColorList.is()) { aLbColor.SetUpdateMode( false ); - long nCount = pColorTable->Count(); + long nCount = pColorList->Count(); for ( long n=0; n<nCount; n++ ) { - XColorEntry* pEntry = pColorTable->GetColor(n); + XColorEntry* pEntry = pColorList->GetColor(n); aLbColor.InsertEntry( pEntry->GetColor(), pEntry->GetName() ); } aLbColor.SetUpdateMode( sal_True ); diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index f94bc36acffc..b3ccd3933e83 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -128,7 +128,7 @@ void ScDocShell::InitItems() ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer(); if (pDrawLayer) { - PutItem( SvxColorTableItem ( pDrawLayer->GetColorTable(), SID_COLOR_TABLE ) ); + PutItem( SvxColorListItem ( pDrawLayer->GetColorList(), SID_COLOR_TABLE ) ); PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) ); PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) ); PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) ); @@ -144,7 +144,7 @@ void ScDocShell::InitItems() else { // always use global color table instead of local copy - PutItem( SvxColorTableItem( &XColorList::GetStdColorTable(), SID_COLOR_TABLE ) ); + PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) ); } if ( !aDocument.GetForbiddenCharacters().is() || diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 80034f0f5f53..f8875896f4b5 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -587,12 +587,11 @@ void ScDocShell::Execute( SfxRequest& rReq ) OSL_FAIL("use ScAutoStyleHint instead of SID_AUTO_STYLE"); break; - case SID_GET_COLORTABLE: + case SID_GET_COLORLIST: { - // passende ColorTable ist per PutItem gesetzt worden - SvxColorTableItem* pColItem = (SvxColorTableItem*)GetItem(SID_COLOR_TABLE); - XColorList* pTable = pColItem->GetColorTable(); - rReq.SetReturnValue(OfaPtrItem(SID_GET_COLORTABLE, pTable)); + SvxColorListItem* pColItem = (SvxColorListItem*)GetItem(SID_COLOR_TABLE); + XColorListRef pList = pColItem->GetColorList(); + rReq.SetReturnValue(OfaRefItem<XColorList>(SID_GET_COLORLIST, pList)); } break; diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx index 836d47201712..9eaf8bd52ca9 100644 --- a/sc/source/ui/drawfunc/drawsh.cxx +++ b/sc/source/ui/drawfunc/drawsh.cxx @@ -411,19 +411,9 @@ void ScDrawShell::ExecuteAreaDlg( SfxRequest& rReq, sal_uInt16 nTabPage ) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - OSL_ENSURE(pFact, "Dialogdiet Factory fail!"); - AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( pViewData->GetDialogParent(), - &aNewAttr, - pViewData->GetDocument()->GetDrawLayer(), - pView); - OSL_ENSURE(pDlg, "Dialogdiet fail!"); - - // #i74099# by default, the dialog deletes the current color table if a different one is loaded - // (see SwDrawShell::ExecDrawDlg) - const SvxColorTableItem* pColorItem = - static_cast<const SvxColorTableItem*>( pViewData->GetSfxDocShell()->GetItem(SID_COLOR_TABLE) ); - if (pColorItem->GetColorTable() == &XColorList::GetStdColorTable()) - pDlg->DontDeleteColorTable(); + AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( + pViewData->GetDialogParent(), &aNewAttr, + pViewData->GetDocument()->GetDrawLayer(), pView); if ( nTabPage != 0xffff ) pDlg->SetCurPageId( nTabPage ); diff --git a/sc/source/ui/drawfunc/drawsh4.cxx b/sc/source/ui/drawfunc/drawsh4.cxx index 6f021d82b776..d46593e792f3 100644 --- a/sc/source/ui/drawfunc/drawsh4.cxx +++ b/sc/source/ui/drawfunc/drawsh4.cxx @@ -93,17 +93,15 @@ void ScDrawShell::GetFormTextState(SfxItemSet& rSet) if ( pDocSh ) { const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); - XColorList* pColorTable = NULL; + XColorListRef pColorList; if ( pItem ) - pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable(); + pColorList = ((SvxColorListItem*)pItem)->GetColorList(); pDlg->SetActive(); - if ( pColorTable ) - pDlg->SetColorTable( pColorTable ); - else - { OSL_FAIL( "ColorList not found :-/" ); } + if ( pColorList.is() ) + pDlg->SetColorList( pColorList ); } } SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool()); diff --git a/sc/source/ui/drawfunc/drtxtob2.cxx b/sc/source/ui/drawfunc/drtxtob2.cxx index 4278cc976992..51ef34048bd9 100644 --- a/sc/source/ui/drawfunc/drtxtob2.cxx +++ b/sc/source/ui/drawfunc/drtxtob2.cxx @@ -276,17 +276,15 @@ void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet) if ( pDocSh ) { const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); - XColorList* pColorTable = NULL; + XColorListRef pColorList; if ( pItem ) - pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable(); + pColorList = ((SvxColorListItem*)pItem)->GetColorList(); pDlg->SetActive(); - if ( pColorTable ) - pDlg->SetColorTable( pColorTable ); - else - { OSL_FAIL( "ColorList not found :-/" ); } + if ( pColorList.is() ) + pDlg->SetColorList( pColorList ); } } SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool()); diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx index 961eef00e616..04b878560780 100644 --- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx +++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx @@ -93,8 +93,7 @@ void ScTabBgColorDlg::FillColorValueSets_Impl() { SfxObjectShell* pDocSh = SfxObjectShell::Current(); const SfxPoolItem* pItem = NULL; - XColorList* pColorTable = NULL; - ::boost::scoped_ptr<XColorList> pOwnColorTable; // locally instantiated in case the doc shell doesn't have one. + XColorListRef pColorList; const Size aSize15x15 = Size( 15, 15 ); sal_uInt16 nSelectedItem = 0; @@ -102,16 +101,14 @@ void ScTabBgColorDlg::FillColorValueSets_Impl() OSL_ENSURE( pDocSh, "DocShell not found!" ); if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) ) ) - pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); - if ( !pColorTable ) - { - pOwnColorTable.reset(new XColorList(SvtPathOptions().GetPalettePath())); - pColorTable = pOwnColorTable.get(); - } - if ( pColorTable ) + pColorList = ( (SvxColorListItem*)pItem )->GetColorList(); + if ( !pColorList.is() ) + pColorList = XColorList::CreateStdColorList(); + + if ( pColorList.is() ) { sal_uInt16 i = 0; - long nCount = pColorTable->Count(); + long nCount = pColorList->Count(); XColorEntry* pEntry = NULL; Color aColWhite( COL_WHITE ); String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) ); @@ -120,7 +117,7 @@ void ScTabBgColorDlg::FillColorValueSets_Impl() aTabBgColorSet.SetStyle( nBits ); for ( i = 0; i < nCount; i++ ) { - pEntry = pColorTable->GetColor(i); + pEntry = pColorList->GetColor(i); aTabBgColorSet.InsertItem( i + 1, pEntry->GetColor(), pEntry->GetName() ); if (pEntry->GetColor() == aTabBgColor) nSelectedItem = (i + 1); diff --git a/sc/source/ui/optdlg/opredlin.cxx b/sc/source/ui/optdlg/opredlin.cxx index a93122bb4b55..332eb2d10dc4 100644 --- a/sc/source/ui/optdlg/opredlin.cxx +++ b/sc/source/ui/optdlg/opredlin.cxx @@ -169,10 +169,10 @@ void ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ ) aInsertColorLB.SetUpdateMode( false); aRemoveColorLB.SetUpdateMode( false); - XColorList& rColorTbl = XColorList::GetStdColorTable(); - for( sal_uInt16 i = 0; i < rColorTbl.Count(); ++i ) + XColorListRef xColorLst = XColorList::GetStdColorList(); + for( sal_uInt16 i = 0; i < xColorLst->Count(); ++i ) { - XColorEntry* pEntry = rColorTbl.GetColor( i ); + XColorEntry* pEntry = xColorLst->GetColor( i ); Color aColor = pEntry->GetColor(); String sName = pEntry->GetName(); diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx index 88cbb2e97070..b03d49205c40 100644 --- a/sc/source/ui/optdlg/tpview.cxx +++ b/sc/source/ui/optdlg/tpview.cxx @@ -337,19 +337,17 @@ void ScTpContentOptions::InitGridOpt() // there might be another DocShell here pDocSh = PTR_CAST(ScDocShell, pDocSh); - XColorList* pColorTable = NULL; - + XColorListRef pColorList; if ( pDocSh ) { const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); - if ( pItem ) - pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable(); + pColorList = ((SvxColorListItem*)pItem)->GetColorList(); } else - pColorTable = &XColorList::GetStdColorTable(); + pColorList = XColorList::GetStdColorList(); - if ( !pColorTable ) + if ( !pColorList.is() ) return; //------------------------------------------------------ @@ -358,10 +356,10 @@ void ScTpContentOptions::InitGridOpt() // items from ColorTable - long nCount = pColorTable->Count(); + long nCount = pColorList->Count(); for ( long n=0; n<nCount; n++ ) { - XColorEntry* pEntry = pColorTable->GetColor(n); + XColorEntry* pEntry = pColorList->GetColor(n); aColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() ); } |