diff options
author | Armin Le Grand <alg@apache.org> | 2012-06-28 16:30:03 +0000 |
---|---|---|
committer | Armin Le Grand <alg@apache.org> | 2012-06-28 16:30:03 +0000 |
commit | ec1819f218b94bed1556653e1b2b816a65da61ef (patch) | |
tree | b3a7fc1b326989e8754d48d7aacc779b411d157b | |
parent | b69333045a54fb8ac0d5aabbf01b1fd125985e81 (diff) |
#120077# ALG: Reverted r1354011, adapted all usages of SfxStyleSheetIterator and CreateIterator to use boost::shared_ptr
Notes
Notes:
merged as: 858c6610f3476bb47bb7b4e621a7ac48a9e34a75
-rw-r--r-- | sc/source/core/data/patattr.cxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/stlsheet.cxx | 7 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlfonte.cxx | 39 | ||||
-rw-r--r-- | sfx2/source/doc/objcont.cxx | 13 | ||||
-rw-r--r-- | svl/inc/svl/style.hxx | 12 | ||||
-rw-r--r-- | svl/source/items/style.cxx | 25 | ||||
-rw-r--r-- | sw/inc/docstyle.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/app/docstyle.cxx | 5 |
10 files changed, 54 insertions, 65 deletions
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 91d82259cd4d..4e48d464b1fb 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -1187,17 +1187,15 @@ void ScPatternAttr::UpdateStyleSheet() { if (pName) { - pStyle = dynamic_cast< ScStyleSheet* >(pDoc->GetStyleSheetPool()->Find(*pName, SFX_STYLE_FAMILY_PARA)); + pStyle = (ScStyleSheet*)pDoc->GetStyleSheetPool()->Find(*pName, SFX_STYLE_FAMILY_PARA); // wenn Style nicht gefunden, Standard nehmen, // damit keine leere Anzeige im Toolbox-Controller //! es wird vorausgesetzt, dass "Standard" immer der erste Eintrag ist! if (!pStyle) { - // #i120077# memory leak - SfxStyleSheetIterator aIter(pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL); - - pStyle = dynamic_cast< ScStyleSheet* >(aIter.First()); + SfxStyleSheetIteratorPtr pIter = pDoc->GetStyleSheetPool()->CreateIterator( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL ); + pStyle = dynamic_cast< ScStyleSheet* >(pIter->First()); } if (pStyle) diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index 4a66b4c19659..47375e5a6b6a 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -119,11 +119,8 @@ sal_Bool __EXPORT ScStyleSheet::SetParent( const String& rParentName ) SfxStyleSheetBase* pStyle = rPool.Find( aEffName, nFamily ); if (!pStyle) { - // memory leak #i120077# - SfxStyleSheetIterator aIter(&rPool, nFamily, SFXSTYLEBIT_ALL); - - pStyle = aIter.First(); - + SfxStyleSheetIteratorPtr pIter = rPool.CreateIterator( nFamily, SFXSTYLEBIT_ALL ); + pStyle = pIter->First(); if (pStyle) aEffName = pStyle->GetName(); } diff --git a/sc/source/filter/xml/xmlfonte.cxx b/sc/source/filter/xml/xmlfonte.cxx index bc51902da0d7..3b780d1c8a8d 100644 --- a/sc/source/filter/xml/xmlfonte.cxx +++ b/sc/source/filter/xml/xmlfonte.cxx @@ -45,14 +45,11 @@ class ScXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool { -private: - // #i120077# remember owned pool - SfxItemPool* mpEditEnginePool; - void AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const sal_Bool bExportDefaults); -public: + public: + ScXMLFontAutoStylePool_Impl( ScXMLExport& rExport ); - virtual ~ScXMLFontAutoStylePool_Impl(); + }; void ScXMLFontAutoStylePool_Impl::AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const sal_Bool bExportDefaults) @@ -86,8 +83,7 @@ void ScXMLFontAutoStylePool_Impl::AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl( ScXMLExport& rExportP ) : - XMLFontAutoStylePool( rExportP ), - mpEditEnginePool(0) + XMLFontAutoStylePool( rExportP ) { sal_uInt16 aWhichIds[3] = { ATTR_FONT, ATTR_CJK_FONT, ATTR_CTL_FONT }; @@ -101,17 +97,18 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl( const SfxItemPool* pEditPool(rExportP.GetDocument()->GetEditPool()); AddFontItems(aEditWhichIds, 3, pEditPool, sal_False); - if(rExportP.GetDocument() && rExportP.GetDocument()->GetStyleSheetPool()) + SfxStyleSheetIteratorPtr pItr; + + if(rExportP.GetDocument()) { - // memory leak #i120077# - SfxStyleSheetIterator aIter(rExportP.GetDocument()->GetStyleSheetPool(), SFX_STYLE_FAMILY_PAGE, 0xFFFF); - SfxStyleSheetBase* pStyle(aIter.First()); + pItr = rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SFX_STYLE_FAMILY_PAGE, 0xFFFF); + } - // #i120077# init pool and use it - mpEditEnginePool = EditEngine::CreatePool(); // memory leak #i120077#, to save the SfxItemPool obj into member data for releasing - SfxItemPool* pPageEditPool( mpEditEnginePool ); + if(pItr) + { + SfxStyleSheetBase* pStyle(pItr->First()); + SfxItemPool* pPageEditPool(EditEngine::CreatePool()); EditEngine aEditEngine(pPageEditPool); - while (pStyle) { const SfxItemPool& rPagePool(pStyle->GetPool().GetPool()); @@ -145,19 +142,11 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl( } } } - pStyle = aIter.Next(); + pStyle = pItr->Next(); } } } -ScXMLFontAutoStylePool_Impl::~ScXMLFontAutoStylePool_Impl() -{ - if(mpEditEnginePool) - { - // memory leak #i120077# - SfxItemPool::Free(mpEditEnginePool); - } -} XMLFontAutoStylePool* ScXMLExport::CreateFontAutoStylePool() { diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 78f3ea812092..5529d3951d09 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -759,16 +759,11 @@ sal_Bool SfxObjectShell::Print { SfxStyleSheetBasePool *pStylePool = GetStyleSheetPool(); SetOrganizerSearchMask(pStylePool); - - // memory leak #i120077# - SfxStyleSheetIterator aIter(pStylePool, pStylePool->GetSearchFamily(), pStylePool->GetSearchMask()); - sal_uInt16 nStyles = aIter.Count(); - SfxStyleSheetBase *pStyle = aIter.First(); - + SfxStyleSheetIteratorPtr pIter = pStylePool->CreateIterator( pStylePool->GetSearchFamily(), pStylePool->GetSearchMask() ); + sal_uInt16 nStyles = pIter->Count(); + SfxStyleSheetBase *pStyle = pIter->First(); if ( !pStyle ) - { return sal_True; - } // pepare adaptor for old style StartPage/EndPage printing boost::shared_ptr< Printer > pPrinter( new Printer( rPrt.GetJobSetup() ) ); @@ -867,7 +862,7 @@ sal_Bool SfxObjectShell::Print pPrinter->DrawText(aOutPos, aTmp); aOutPos.Y() += pPrinter->GetTextHeight(); } - pStyle = aIter.Next(); + pStyle = pIter->Next(); } pAdaptor->EndPage(); diff --git a/svl/inc/svl/style.hxx b/svl/inc/svl/style.hxx index 478e966e8836..5ca3d1bd9b84 100644 --- a/svl/inc/svl/style.hxx +++ b/svl/inc/svl/style.hxx @@ -19,33 +19,27 @@ * *************************************************************/ - - #ifndef _SFXSTYLE_HXX #define _SFXSTYLE_HXX #include <com/sun/star/style/XStyle.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> - #include <rtl/ref.hxx> #include <vector> #include <comphelper/weak.hxx> #include <cppuhelper/implbase2.hxx> -#include "svl/svldllapi.h" +#include <svl/svldllapi.h> #include <rsc/rscsfx.hxx> #include <tools/string.hxx> #include <svl/hint.hxx> #include <svl/lstner.hxx> #include <svl/brdcst.hxx> #include <svl/poolitem.hxx> - -#ifndef _SFX_STYLE_HRC #include <svl/style.hrc> -#endif +#include <boost/shared_ptr.hpp> class SfxItemSet; class SfxItemPool; - class SfxStyleSheetBasePool; class SvStream; @@ -199,6 +193,7 @@ private: friend class SfxStyleSheetBasePool; }; +typedef ::boost::shared_ptr< SfxStyleSheetIterator > SfxStyleSheetIteratorPtr; //========================================================================= class SfxStyleSheetBasePool_Impl; @@ -238,6 +233,7 @@ public: SfxItemPool& GetPool(); const SfxItemPool& GetPool() const; + virtual SfxStyleSheetIteratorPtr CreateIterator(SfxStyleFamily, sal_uInt16 nMask); virtual sal_uInt16 Count(); virtual SfxStyleSheetBase* operator[](sal_uInt16 nIdx); diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index b08555cdee21..48223b16380f 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -121,11 +121,9 @@ SfxStyleSheetHint::SfxStyleSheetHint class SfxStyleSheetBasePool_Impl { - public: +public: SfxStyles aStyles; - SfxStyleSheetIterator *pIter; - SfxStyleSheetBasePool_Impl() : pIter(0){} - ~SfxStyleSheetBasePool_Impl(){delete pIter;} + SfxStyleSheetIteratorPtr pIter; }; @@ -583,13 +581,12 @@ void SfxStyleSheetBasePool::Replace( SfxStyleSheetIterator& SfxStyleSheetBasePool::GetIterator_Impl() { - SfxStyleSheetIterator*& rpIter = pImp->pIter; - if( !rpIter || (rpIter->GetSearchMask() != nMask) || (rpIter->GetSearchFamily() != nSearchFamily) ) + if( !pImp->pIter || (pImp->pIter->GetSearchMask() != nMask) || (pImp->pIter->GetSearchFamily() != nSearchFamily) ) { - delete rpIter; - rpIter = new SfxStyleSheetIterator( this, nSearchFamily, nMask ); + pImp->pIter = CreateIterator( nSearchFamily, nMask ); } - return *rpIter; + + return *pImp->pIter; } @@ -668,6 +665,16 @@ String SfxStyleSheetBasePool::GetStreamName() +SfxStyleSheetIteratorPtr SfxStyleSheetBasePool::CreateIterator +( + SfxStyleFamily eFam, + sal_uInt16 mask +) +{ + return SfxStyleSheetIteratorPtr(new SfxStyleSheetIterator(this,eFam,mask)); +} + + SfxStyleSheetBase* SfxStyleSheetBasePool::Create ( const XubString& rName, diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx index b73021152bd6..0ffcdffa627d 100644 --- a/sw/inc/docstyle.hxx +++ b/sw/inc/docstyle.hxx @@ -219,6 +219,8 @@ public: void SetOrganizerMode( sal_Bool bMode ) { bOrganizer = bMode; } sal_Bool IsOrganizerMode() const { return bOrganizer; } + virtual SfxStyleSheetIteratorPtr CreateIterator( SfxStyleFamily, sal_uInt16 nMask ); + SwDoc& GetDoc() const { return rDoc; } void dispose(); diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index a1819ba322de..2daa1cb78d14 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -174,7 +174,7 @@ sal_Bool BaseFrameProperties_Impl::GetProperty(sal_uInt16 nWID, sal_uInt8 nMembe } //Begin Bug 119922:Graphic in header and footer can not be displayed correctly. -//Set default value for "Follow text flow" to false if a previous version didn't support "Follow text flow".
+//Set default value for "Follow text flow" to false if a previous version didn't support "Follow text flow". sal_Bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxItemSet& rFromSet, sal_Bool& rSizeFound, diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index f6af2ff972f8..f126cdbb74db 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -860,14 +860,14 @@ uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::Runt uno::Sequence< OUString > aRet; if(pBasePool) { - SfxStyleSheetIterator aIterator(pBasePool, eFamily, 0xffff); - sal_uInt16 nCount = aIterator.Count(); + SfxStyleSheetIteratorPtr pIterator = pBasePool->CreateIterator(eFamily, 0xffff); + sal_uInt16 nCount = pIterator->Count(); aRet.realloc(nCount); OUString* pArray = aRet.getArray(); String aString; for(sal_uInt16 i = 0; i < nCount; i++) { - SwStyleNameMapper::FillProgName(aIterator[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); + SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ); pArray[i] = OUString ( aString ); } } diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx index 95e82f7004c9..6571453f808a 100644 --- a/sw/source/ui/app/docstyle.cxx +++ b/sw/source/ui/app/docstyle.cxx @@ -2230,6 +2230,11 @@ void SwDocStyleSheetPool::Replace( SfxStyleSheetBase& rSource, } } +SfxStyleSheetIteratorPtr SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, sal_uInt16 _nMask ) +{ + return SfxStyleSheetIteratorPtr(new SwStyleSheetIterator( this, eFam, _nMask )); +} + void SwDocStyleSheetPool::dispose() { mxStyleSheet.clear(); |