Commits

zengliangjun  committed 613495b

update some parallel problem

  • Participants
  • Parent commits 292c64f

Comments (0)

Files changed (17)

File sd/inc/drawdoc.hxx

 #endif
 #include "sddllapi.h"
 #include "sdpage.hxx"
+#include "shapelist_critical.hxx"
 
 namespace com
 {
 	::sd::Outliner*		mpInternalOutliner;  // internal outliner for creation of text objects
 	Timer*			    mpWorkStartupTimer;
 	Timer*              mpOnlineSpellingTimer;
-	sd::ShapeList*		mpOnlineSpellingList;
+	//sd::ShapeList*		mpOnlineSpellingList;
+	sd::ShapeListCritical*	mpOnlineSpellingList;	
 	SvxSearchItem*      mpOnlineSearchItem;
 	List*               mpFrameViewList;
 	List*               mpCustomShowList;

File sd/inc/shapelist_critical.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SHAPELIST_CRITICAL_HXX
+#define _SHAPELIST_CRITICAL_HXX
+
+#include <svx/sdrobjectuser.hxx>
+
+#include <list>
+
+namespace sd
+{
+	class ShapeListCritical : public sdr::ObjectUser
+	{
+	public:
+		ShapeListCritical();
+		virtual ~ShapeListCritical();
+
+		/** adds the given shape to this list */
+		void addShape( SdrObject& rObject );
+
+		/** removes the shape from this list and returns
+			a pointer to the next shape in list or 0*/
+		SdrObject* removeShape( SdrObject& rObject );
+
+		/** removes all shapes from this list */
+		void clear();
+
+		/** returns true if this list is empty */
+		bool isEmpty() const;
+
+		/** returns true if given shape is part of this list */
+		bool hasShape( SdrObject& rObject ) const;
+
+		/** returns the shape following the given shape in the list or 0
+			returns the first shape if pObj is 0 */
+		SdrObject* getNextShape(SdrObject* pObj) const;
+
+		/** returns the shape prior to the given shape in the list or 0
+			returns the last shape if pObj is 0 */
+		SdrObject* getPreviousShape( SdrObject* pObj ) const;
+
+		/**
+		*/
+		SdrObject* getNextShape();
+
+		/**
+		*/
+		void seekShape( sal_uInt32 nIndex );
+
+		/**
+		*/
+		bool hasMore() const;
+
+	private:
+		virtual void ObjectInDestruction(const SdrObject& rObject);
+
+		typedef std::list< SdrObject* > ListImpl;
+		ListImpl maShapeList;
+		ListImpl::iterator maIter;
+	};
+}
+
+#endif	   // _SHAPELIST_HXX

File sd/source/core/drawdoc4.cxx

 
 		pOutl->SetDefaultLanguage( meLanguage );
 
-		mpOnlineSpellingList = new ShapeList;
+		mpOnlineSpellingList = new ShapeListCritical;
 		USHORT nPage;
 
 		for ( nPage = 0; nPage < GetPageCount(); nPage++ )

File sd/source/core/makefile.mk

            $(SLO)$/undoanim.obj\
            $(SLO)$/EffectMigration.obj\
            $(SLO)$/CustomAnimationCloner.obj\
-           $(SLO)$/shapelist.obj
+           $(SLO)$/shapelist.obj\
+           $(SLO)$/shapelist_critical.obj
 
 # --- Tagets -------------------------------------------------------
 

File sd/source/core/sdpage.cxx

 #include <svx/sdr/contact/viewcontact.hxx>
 #include <svx/sdr/contact/objectcontact.hxx>
 #include <svx/unoapi.hxx>
-
+#include <osl/mutex_help.hxx>
 #include <set>
 
 using namespace ::sd;
 */
 SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, BOOL bVertical, const Rectangle& rRect, BOOL /* bInsert */ )
 {
+	PARALLEL_GUARD();
 	sd::UndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
 	const bool bUndo = pUndoManager && pUndoManager->isInListAction() && IsInserted();
 
 		default:
 			break;
 	}
-
+	
 	if (pSdrObj)
 	{
 		pSdrObj->SetEmptyPresObj(bEmptyPresObj);
 	{
 		return;
 	}
-
+	PARALLEL_GUARD();
 	/**************************************************************************
 	* Hintergrund, Titel- und Layout-Bereich werden angelegt
 	**************************************************************************/

File sd/source/core/shapelist_critical.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sd.hxx"
+#include <tools/debug.hxx>
+#include <svx/svdobj.hxx>
+#include "shapelist_critical.hxx"
+#include <osl/mutex_help.hxx>
+#include <algorithm>
+
+using namespace sd;
+
+ShapeListCritical::ShapeListCritical()
+{
+	maIter = maShapeList.end();
+}
+
+ShapeListCritical::~ShapeListCritical()
+{
+	clear();
+}
+
+/** adds the given shape to this list */
+void ShapeListCritical::addShape( SdrObject& rObject )
+{
+	PARALLEL_GUARD();
+	ListImpl::iterator aIter( std::find( maShapeList.begin(), maShapeList.end(), &rObject ) );
+	if( aIter == maShapeList.end() )
+	{
+		maShapeList.push_back(&rObject);
+		rObject.AddObjectUser( *this );
+	}
+	else
+	{
+		DBG_ERROR("sd::ShapeListCritical::addShape(), given shape already part of list!");
+	}
+}
+
+/** removes the given shape from this list */
+SdrObject* ShapeListCritical::removeShape( SdrObject& rObject )
+{
+	PARALLEL_GUARD();
+	ListImpl::iterator aIter( std::find( maShapeList.begin(), maShapeList.end(), &rObject ) );
+	if( aIter != maShapeList.end() )
+	{
+		bool bIterErased = aIter == maIter;
+
+		(*aIter)->RemoveObjectUser(*this);
+		aIter = maShapeList.erase( aIter );
+
+		if( bIterErased )
+			maIter = aIter;
+
+		if( aIter != maShapeList.end() )
+			return (*aIter);
+	}
+	else
+	{
+		DBG_ERROR("sd::ShapeListCritical::removeShape(), given shape not part of list!");
+	}
+	return 0;
+}
+
+/** removes all shapes from this list
+	NOTE: iterators will become invalid */
+void ShapeListCritical::clear()
+{
+	PARALLEL_GUARD();
+	ListImpl aShapeList;
+	aShapeList.swap( maShapeList );
+
+	ListImpl::iterator aIter( aShapeList.begin() );
+	while( aIter != aShapeList.end() )
+		(*aIter++)->RemoveObjectUser(*this);
+
+	maIter = aShapeList.end();
+}
+
+/** returns true if this list is empty */
+bool ShapeListCritical::isEmpty() const
+{
+	PARALLEL_GUARD();
+	return maShapeList.empty();
+}
+
+/** returns true if given shape is part of this list */
+bool ShapeListCritical::hasShape( SdrObject& rObject ) const
+{
+	PARALLEL_GUARD();
+	return std::find( maShapeList.begin(), maShapeList.end(), &rObject )  != maShapeList.end();
+}
+
+SdrObject* ShapeListCritical::getNextShape(SdrObject* pObj) const
+{
+	PARALLEL_GUARD();
+	if( pObj )
+	{
+		ListImpl::const_iterator aIter( std::find( maShapeList.begin(), maShapeList.end(), pObj ) );
+		if( aIter != maShapeList.end() )
+		{
+			aIter++;
+			if( aIter != maShapeList.end() )
+			{
+				return (*aIter);
+			}
+		}
+	}
+	else if( !maShapeList.empty() )
+	{
+		return (*maShapeList.begin());
+	}
+
+	return 0;
+}
+
+SdrObject* ShapeListCritical::getPreviousShape( SdrObject* pObj ) const
+{
+	PARALLEL_GUARD();
+	if( pObj )
+	{
+		ListImpl::const_iterator aIter( std::find( maShapeList.begin(), maShapeList.end(), pObj ) );
+		if( (aIter != maShapeList.end()) && (aIter != maShapeList.begin()) )
+		{
+			aIter--;
+			return (*aIter);
+		}
+	}
+	else if( !maShapeList.empty() )
+	{
+		return (*--maShapeList.end());
+	}
+
+	return 0;
+}
+
+void ShapeListCritical::ObjectInDestruction(const SdrObject& rObject)
+{
+	PARALLEL_GUARD();
+	ListImpl::iterator aIter( std::find( maShapeList.begin(), maShapeList.end(), &rObject ) );
+	if( aIter != maShapeList.end() )
+	{
+		bool bIterErased = aIter == maIter;
+
+		aIter = maShapeList.erase( aIter );
+
+		if( bIterErased )
+			maIter = aIter;
+	}
+	else
+	{
+		DBG_ERROR("sd::ShapeListCritical::ObjectInDestruction(), got a call from an unknown friend!");
+	}
+}
+
+SdrObject* ShapeListCritical::getNextShape()
+{
+	PARALLEL_GUARD();
+	if( maIter != maShapeList.end() )
+	{
+		return (*maIter++);
+	}
+	else
+	{
+		return 0;
+	}
+}
+
+void ShapeListCritical::seekShape( sal_uInt32 nIndex )
+{
+	PARALLEL_GUARD();
+	maIter = maShapeList.begin();
+	while( nIndex-- && (maIter != maShapeList.end()) )
+		maIter++;
+}
+
+bool ShapeListCritical::hasMore() const
+{
+	PARALLEL_GUARD();
+	return maIter != maShapeList.end();
+}

File svl/source/items/style.cxx

 #define _SVSTDARR_STRINGSSORTDTOR
 #define _SVSTDARR_BYTESTRINGS
 #define _SVSTDARR_BYTESTRINGSSORTDTOR
-
+#include <osl/mutex_help.hxx>
 #include <rtl/uuid.h>
 #include <tools/tenccvt.hxx>
 #include <comphelper/processfactory.hxx>
 
 void SfxStyleSheetBasePool::Insert( SfxStyleSheetBase* p )
 {
+	STRUCT_GUARD();
 	DBG_ASSERT( p, "svl::SfxStyleSheetBasePool::Insert(), no stylesheet?" );
 
 	SfxStyleSheetIterator aIter(this, p->GetFamily(), p->GetMask());

File svl/source/notify/brdcst.cxx

 		for ( USHORT n = 0; n < aListeners.Count(); ++n )
 		{
 			SfxListener* pListener = aListeners[n];
+			/*
 			if ( pListener )
 				pListener->Notify( *this, rHint );
+				*/
 		}
 	}
 }

File tools/inc/tools/contnr_critical.hxx

  *
  ************************************************************************/
 
-#ifndef _CONTNR_CRITICAL_HXX
-#define _CONTNR_CRITICAL_HXX
+#ifndef _TOOLS_CONTNR_CRITICAL_HXX
+#define _TOOLS_CONTNR_CRITICAL_HXX
 
 #include "tools/toolsdllapi.h"
 #include <tools/solar.h>

File tools/inc/tools/list_critical.hxx

                 ContainerCritical( 1024, _nInitSize, _nReSize ) {}
             ListCritical( USHORT _nBlockSize, USHORT _nInitSize, USHORT _nReSize ) :
                 ContainerCritical( _nBlockSize, _nInitSize, _nReSize ) {}
-            ListCritical( const List& rList ) : ContainerCritical( rList ) {}
+            ListCritical( const ListCritical& rList ) : ContainerCritical( rList ) {}
 
     ListCritical&   operator =( const ListCritical& rList )
                 { ContainerCritical::operator =( rList ); return *this; }
                     { return ListCritical::operator !=( rList ); }              \
 };
 
-#endif // _LIST_HXX
+#endif // 

File tools/prj/d.lst

 ..\inc\tools\inetstrm.hxx %_DEST%\inc%_EXT%\tools\inetstrm.hxx
 ..\inc\tools\link.hxx %_DEST%\inc%_EXT%\tools\link.hxx
 ..\inc\tools\list.hxx %_DEST%\inc%_EXT%\tools\list.hxx
+..\inc\tools\list_critical.hxx %_DEST%\inc%_EXT%\tools\list_critical.hxx
 ..\inc\tools\mempool.hxx %_DEST%\inc%_EXT%\tools\mempool.hxx
 ..\inc\tools\multisel.hxx %_DEST%\inc%_EXT%\tools\multisel.hxx
 ..\inc\tools\ownlist.hxx %_DEST%\inc%_EXT%\tools\ownlist.hxx

File xmloff/inc/xmloff2/helper/xmloffreferenceobject.hxx

 #ifndef _XMLOFF_HELPER_XMLOFFREFERENCEOBJECT_HXX__
 #define _XMLOFF_HELPER_XMLOFFREFERENCEOBJECT_HXX__
 
+#include <rtl/alloc.h>
 #include <salhelper/simplereferenceobject.hxx>
 
 //------------------------------------------------------------
     class XMLOFF_DLLPUBLIC XmloffReferenceObject
     {
+        
+public:
+	// these are here to force memory de/allocation to sal lib.
+    /** @internal */
+	inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+		{ return ::rtl_allocateMemory( nSize ); }
+    /** @internal */
+	inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+		{ ::rtl_freeMemory( pMem ); }
+    /** @internal */
+	inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () )
+		{ return pMem; }
+    /** @internal */
+	inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () )
+		{}
+	
     public:
         inline XmloffReferenceObject()
         : m_nCount(0)

File xmloff/inc/xmloff2/helper/xmloffsimplereferenceobject.hxx

 #ifndef _XMLOFF_HELPER_XMLOFFSIMPLEREFERENCEOBJECT_HXX__
 #define _XMLOFF_HELPER_XMLOFFSIMPLEREFERENCEOBJECT_HXX__
 
+#include <rtl/alloc.h>
 #include <salhelper/simplereferenceobject.hxx>
 
   
     class XmloffSimpleReferenceObject
     {
+        
+public:
+	// these are here to force memory de/allocation to sal lib.
+    /** @internal */
+	inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+		{ return ::rtl_allocateMemory( nSize ); }
+    /** @internal */
+	inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+		{ ::rtl_freeMemory( pMem ); }
+    /** @internal */
+	inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () )
+		{ return pMem; }
+    /** @internal */
+	inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () )
+		{}
+	
     public:
         inline XmloffSimpleReferenceObject()
         : m_nCount(0)

File xmloff/inc/xmloff2/import/core/odfparallelcontext.inl

 	#pragma omp parallel for private(i)
 	for( i = 0 ; i < _size ; i++ )
 	{
-		try{
-			//vos::OParallel parallel(pRegister, _parentId);	
+		try{				
 			_processSubContext(m_rSubContexts[i]);
 		}catch( ... )
 		{

File xmloff/inc/xmloff2/import/draw/sdbodycontext.hxx

 {
     namespace draw
     {
-#ifdef PERFORMANCE_PARALLEL
-        typedef BodyContext<OdfParallelContext> SdBodyContext;
-#else
+//#ifdef PERFORMANCE_PARALLEL
+//        typedef BodyContext<OdfParallelContext> SdBodyContext;
+//#else
 		typedef BodyContext<OdfSimpleContext> SdBodyContext;
-#endif     
+//#endif     
     }
 }
 #endif

File xmloff/source2/helper/style/pagemasterpropertyhandlerfactory.cxx

  * for a copy of the LGPLv3 License.
  *
  ************************************************************************/
-
+#include <osl/mutex_help.hxx>
 #include "pagemasterpropertyhandlerfactory.hxx"
 #include <xmloff2/helper/style/handler/pagemasterpropertyhandler.hxx>
 #include <xmloff2/helper/style/handler/odfnamedboolpropertyhandler.hxx>
 ( sal_Int32 nType )
 {
     nType &= MID_FLAG_MASK;
-
+	PARALLEL_GUARD();
 	OdfPropertyHandler* pHdl = const_cast<OdfPropertyHandler*>
         (OdfPropertyHandlerFactory::getPropertyHandler( nType ) );
 	if( !pHdl )

File xmloff/source2/import/draw/odfshapeimporthelper.cxx

 sal_Bool OdfShapeImportHelper::pushGroupForSorting
     (const sal_Int16& id, const uno::Reference< drawing::XShapes >& xShapes)
 {
-	//#pragma omp critical 
+	PARALLEL_GUARD();
 	{
     	mpSortContextMap[id] = new ShapeSortContext(xShapes, mpSortContextMap[id] );
 	}