You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2012/06/28 19:30:05 UTC

svn commit: r1355082 - in /incubator/ooo/trunk/main: sc/source/core/data/ sc/source/filter/xml/ sfx2/source/doc/ svl/inc/svl/ svl/source/items/ sw/inc/ sw/source/core/unocore/ sw/source/ui/app/

Author: alg
Date: Thu Jun 28 17:30:03 2012
New Revision: 1355082

URL: http://svn.apache.org/viewvc?rev=1355082&view=rev
Log:
#120077# ALG: Reverted r1354011, adapted all usages of SfxStyleSheetIterator and CreateIterator to use boost::shared_ptr

Modified:
    incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx
    incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx
    incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx
    incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx
    incubator/ooo/trunk/main/svl/inc/svl/style.hxx
    incubator/ooo/trunk/main/svl/source/items/style.cxx
    incubator/ooo/trunk/main/sw/inc/docstyle.hxx
    incubator/ooo/trunk/main/sw/source/core/unocore/unoframe.cxx
    incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx
    incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx

Modified: incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx Thu Jun 28 17:30:03 2012
@@ -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)

Modified: incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx Thu Jun 28 17:30:03 2012
@@ -119,12 +119,9 @@ sal_Bool __EXPORT ScStyleSheet::SetParen
 	SfxStyleSheetBase* pStyle = rPool.Find( aEffName, nFamily );
 	if (!pStyle)
 	{
-        // memory leak #i120077#
-        SfxStyleSheetIterator aIter(&rPool, nFamily, SFXSTYLEBIT_ALL);
-
-        pStyle = aIter.First();
-
-        if (pStyle)
+		SfxStyleSheetIteratorPtr pIter = rPool.CreateIterator( nFamily, SFXSTYLEBIT_ALL );
+		pStyle = pIter->First();
+		if (pStyle)
 			aEffName = pStyle->GetName();
 	}
 

Modified: incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx Thu Jun 28 17:30:03 2012
@@ -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:
 
-    void AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const sal_Bool bExportDefaults);
-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::AddFon
 
 ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(
 	ScXMLExport& rExportP ) :
-	XMLFontAutoStylePool( rExportP ),
-    mpEditEnginePool(0)
+	XMLFontAutoStylePool( rExportP )
 {
 	sal_uInt16 aWhichIds[3] = { ATTR_FONT, ATTR_CJK_FONT,
 								ATTR_CTL_FONT };
@@ -100,19 +96,20 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAu
 	AddFontItems(aWhichIds, 3, pItemPool, sal_True);
 	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());
-		
-        // #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 );
+    	pItr = rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SFX_STYLE_FAMILY_PAGE, 0xFFFF);
+    }
+
+	if(pItr)
+	{
+		SfxStyleSheetBase* pStyle(pItr->First());
+		SfxItemPool* pPageEditPool(EditEngine::CreatePool());
 		EditEngine aEditEngine(pPageEditPool);
-		
-        while (pStyle)
+		while (pStyle)
 		{
 			const SfxItemPool& rPagePool(pStyle->GetPool().GetPool());
 			for (sal_uInt8 j = 0; j < 4; ++j)
@@ -145,19 +142,11 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAu
 					}
 				}
 			}
-			pStyle = aIter.Next();
+			pStyle = pItr->Next();
 		}
 	}
 }
 
-ScXMLFontAutoStylePool_Impl::~ScXMLFontAutoStylePool_Impl()
-{
-	if(mpEditEnginePool)
-	{
-        // memory leak #i120077#
-		SfxItemPool::Free(mpEditEnginePool);  
-	}
-}
 
 XMLFontAutoStylePool* ScXMLExport::CreateFontAutoStylePool()
 {

Modified: incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx (original)
+++ incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx Thu Jun 28 17:30:03 2012
@@ -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();
-			
-            if ( !pStyle )
-            {
-                return sal_True;
-            }
+			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();
             

Modified: incubator/ooo/trunk/main/svl/inc/svl/style.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svl/inc/svl/style.hxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svl/inc/svl/style.hxx (original)
+++ incubator/ooo/trunk/main/svl/inc/svl/style.hxx Thu Jun 28 17:30:03 2012
@@ -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);
 

Modified: incubator/ooo/trunk/main/svl/source/items/style.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svl/source/items/style.cxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svl/source/items/style.cxx (original)
+++ incubator/ooo/trunk/main/svl/source/items/style.cxx Thu Jun 28 17:30:03 2012
@@ -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::GetStreamN
 
 
 
+SfxStyleSheetIteratorPtr SfxStyleSheetBasePool::CreateIterator
+(
+ SfxStyleFamily eFam,
+ sal_uInt16 mask
+)
+{
+	return SfxStyleSheetIteratorPtr(new SfxStyleSheetIterator(this,eFam,mask));
+}
+
+
 SfxStyleSheetBase* SfxStyleSheetBasePool::Create
 (
 	const XubString& rName,

Modified: incubator/ooo/trunk/main/sw/inc/docstyle.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/inc/docstyle.hxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/inc/docstyle.hxx (original)
+++ incubator/ooo/trunk/main/sw/inc/docstyle.hxx Thu Jun 28 17:30:03 2012
@@ -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();

Modified: incubator/ooo/trunk/main/sw/source/core/unocore/unoframe.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/unocore/unoframe.cxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/unocore/unoframe.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/unocore/unoframe.cxx Thu Jun 28 17:30:03 2012
@@ -174,7 +174,7 @@ sal_Bool BaseFrameProperties_Impl::GetPr
 }
 
 //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,

Modified: incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx Thu Jun 28 17:30:03 2012
@@ -860,14 +860,14 @@ uno::Sequence< OUString > SwXStyleFamily
     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 );
 		}
     }

Modified: incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx?rev=1355082&r1=1355081&r2=1355082&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx Thu Jun 28 17:30:03 2012
@@ -2230,6 +2230,11 @@ void  SwDocStyleSheetPool::Replace( SfxS
 	}
 }
 
+SfxStyleSheetIteratorPtr SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, sal_uInt16 _nMask )
+{
+    return SfxStyleSheetIteratorPtr(new SwStyleSheetIterator( this, eFam, _nMask ));
+}
+
 void SwDocStyleSheetPool::dispose()
 {
 	mxStyleSheet.clear();