Kaydet (Commit) 858c6610 authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Resolves: #i120077# Memory leak fixed in ScXMLFontAutoStylePool_Impl

also checked and fixed memory leaks caused by not deleting
SfxStyleSheetIterator instances.

Found by: Chao Huang
Patch by: Chao Huang
Review by: alg

(cherry picked from commit aee8221b)

Conflicts:
	sc/source/core/data/stlsheet.cxx
	sc/source/filter/xml/xmlfonte.cxx
	sfx2/source/doc/objcont.cxx
	svl/source/items/style.cxx
	sw/source/core/unocore/unostyle.cxx

Resolves: #120077# ALG: Reverted r1354011,

adapted all usages of SfxStyleSheetIterator and CreateIterator to use
boost::shared_ptr

(cherry picked from commit ec1819f2)

Conflicts:
	sc/source/core/data/stlsheet.cxx
	sc/source/filter/xml/xmlfonte.cxx
	sfx2/source/doc/objcont.cxx
	svl/inc/svl/style.hxx
	svl/source/items/style.cxx
	sw/source/core/unocore/unoframe.cxx
	sw/source/core/unocore/unostyle.cxx

26937d4d65562b14de0aea59a7b01cc4334f73c1

Change-Id: If99bf3ee399292ec269d68b36ee78ed63f033215
üst a6f16943
......@@ -1161,9 +1161,8 @@ void ScPatternAttr::UpdateStyleSheet()
//! es wird vorausgesetzt, dass "Standard" immer der erste Eintrag ist!
if (!pStyle)
{
SfxStyleSheetIterator* pIter = pDoc->GetStyleSheetPool()->CreateIterator(
SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
pStyle = (ScStyleSheet*)pIter->First();
SfxStyleSheetIteratorPtr pIter = pDoc->GetStyleSheetPool()->CreateIterator( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
pStyle = dynamic_cast< ScStyleSheet* >(pIter->First());
}
if (pStyle)
......
......@@ -109,7 +109,7 @@ bool ScStyleSheet::SetParent( const String& rParentName )
SfxStyleSheetBase* pStyle = pPool->Find( aEffName, nFamily );
if (!pStyle)
{
SfxStyleSheetIterator* pIter = pPool->CreateIterator( nFamily, SFXSTYLEBIT_ALL );
SfxStyleSheetIteratorPtr pIter = pPool->CreateIterator( nFamily, SFXSTYLEBIT_ALL );
pStyle = pIter->First();
if (pStyle)
aEffName = pStyle->GetName();
......
......@@ -82,7 +82,13 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(
const SfxItemPool* pEditPool(rExportP.GetDocument()->GetEditPool());
AddFontItems(aEditWhichIds, 3, pEditPool, false);
SfxStyleSheetIterator* pItr(rExportP.GetDocument() ? rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SFX_STYLE_FAMILY_PAGE, 0xFFFF) : NULL);
SfxStyleSheetIteratorPtr pItr;
if(rExportP.GetDocument())
{
pItr = rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SFX_STYLE_FAMILY_PAGE, 0xFFFF);
}
if(pItr)
{
SfxStyleSheetBase* pStyle(pItr->First());
......
......@@ -600,8 +600,6 @@ sal_Bool SfxObjectShell::Remove
return bRet;
}
//--------------------------------------------------------------------
void SfxObjectShell::LoadStyles
(
SfxObjectShell &rSource /* the document template from which
......
......@@ -37,10 +37,10 @@
#include <svl/stylesheetuser.hxx>
#include <svl/style.hrc>
#include <boost/shared_ptr.hpp>
class SfxItemSet;
class SfxItemPool;
class SfxStyleSheetBasePool;
class SvStream;
......@@ -192,6 +192,7 @@ private:
friend class SfxStyleSheetBasePool;
};
typedef ::boost::shared_ptr< SfxStyleSheetIterator > SfxStyleSheetIteratorPtr;
//=========================================================================
class SfxStyleSheetBasePool_Impl;
......@@ -228,7 +229,7 @@ public:
SfxItemPool& GetPool();
const SfxItemPool& GetPool() const;
virtual SfxStyleSheetIterator* CreateIterator(SfxStyleFamily, sal_uInt16 nMask);
virtual SfxStyleSheetIteratorPtr CreateIterator(SfxStyleFamily, sal_uInt16 nMask);
virtual sal_uInt16 Count();
virtual SfxStyleSheetBase* operator[](sal_uInt16 nIdx);
......
......@@ -83,10 +83,8 @@ SfxStyleSheetHint::SfxStyleSheetHint
class SfxStyleSheetBasePool_Impl
{
public:
SfxStyleSheetIterator *pIter;
SfxStyleSheetBasePool_Impl() : pIter(0){}
~SfxStyleSheetBasePool_Impl(){delete pIter;}
public:
SfxStyleSheetIteratorPtr pIter;
};
......@@ -532,13 +530,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 = CreateIterator( nSearchFamily, nMask );
pImp->pIter = CreateIterator( nSearchFamily, nMask );
}
return *rpIter;
return *pImp->pIter;
}
SfxStyleSheetBasePool::SfxStyleSheetBasePool( SfxItemPool& r )
......@@ -603,14 +600,13 @@ sal_uInt16 SfxStyleSheetBasePool::GetSearchMask() const
return nMask;
}
SfxStyleSheetIterator* SfxStyleSheetBasePool::CreateIterator
SfxStyleSheetIteratorPtr SfxStyleSheetBasePool::CreateIterator
(
SfxStyleFamily eFam,
sal_uInt16 mask
)
{
return new SfxStyleSheetIterator(this,eFam,mask);
return SfxStyleSheetIteratorPtr(new SfxStyleSheetIterator(this,eFam,mask));
}
SfxStyleSheetBase* SfxStyleSheetBasePool::Create
......
......@@ -208,8 +208,7 @@ public:
void SetOrganizerMode( sal_Bool bMode ) { bOrganizer = bMode; }
sal_Bool IsOrganizerMode() const { return bOrganizer; }
virtual SfxStyleSheetIterator* CreateIterator( SfxStyleFamily,
sal_uInt16 nMask );
virtual SfxStyleSheetIteratorPtr CreateIterator( SfxStyleFamily, sal_uInt16 nMask );
SwDoc& GetDoc() const { return rDoc; }
......
......@@ -785,7 +785,7 @@ uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::Runt
uno::Sequence< OUString > aRet;
if(pBasePool)
{
SfxStyleSheetIterator* pIterator = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL);
SfxStyleSheetIteratorPtr pIterator = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL);
sal_uInt16 nCount = pIterator->Count();
aRet.realloc(nCount);
OUString* pArray = aRet.getArray();
......@@ -795,7 +795,6 @@ uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::Runt
SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
pArray[i] = OUString ( aString );
}
delete pIterator;
}
else
throw uno::RuntimeException();
......
......@@ -2179,10 +2179,9 @@ void SwDocStyleSheetPool::Replace( SfxStyleSheetBase& rSource,
}
}
SfxStyleSheetIterator* SwDocStyleSheetPool::CreateIterator(
SfxStyleFamily eFam, sal_uInt16 _nMask )
SfxStyleSheetIteratorPtr SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, sal_uInt16 _nMask )
{
return new SwStyleSheetIterator( this, eFam, _nMask );
return SfxStyleSheetIteratorPtr(new SwStyleSheetIterator( this, eFam, _nMask ));
}
void SwDocStyleSheetPool::dispose()
......
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