Commits

Anonymous committed 5a7573c

split to page

Comments (0)

Files changed (16)

xmloff/inc/xmloff2/helper/odfeventimporthelper.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 __HELPER_ODFEVENT_HELPER_HXX_
+#define __HELPER_ODFEVENT_HELPER_HXX_
+
+#include <map>
+#include <list>
+#include <xmloff2/dllapi.h>
+#include <xmloff2/helper/odfeventfactory.hxx>
+#include <xmloff2/helper/xmloffsimplereferenceobject.hxx>
+
+namespace helper
+{ 
+
+typedef std::map<rtl::OUString, OdfEventContextFactory* > FactoryMap;	 
+typedef std::map<OdfEventName, rtl::OUString > NameMap;
+typedef std::list< NameMap* > NameMapList;
+
+
+class OdfEventImportHelper
+:public XmloffSimpleReferenceObject
+{
+	NO_COPY_ABLE(OdfEventImportHelper);
+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( () )
+		{}
+	
+protected:		
+	FactoryMap maFactoryMap;
+	NameMap* mpEventNameMap;
+	NameMapList maEventNameMapList;
+public:
+	OdfEventImportHelper();
+
+	~OdfEventImportHelper();
+
+	/// register a handler for a particular language type
+	void registerFactory( const ::rtl::OUString& rLanguage,
+						  OdfEventContextFactory* pFactory );
+
+	/// add event name translation to the internal table
+	void addTranslationTable( const OdfEventNameTranslation* pTransTable );
+
+	/// save the old translation table on a stack and install an empty table
+	void pushTranslationTable();
+
+	/// recover the top-most previously saved translation table
+	void popTranslationTable();
+
+	/// create an appropriate import context for a particular event
+	
+	OdfContext* createEventContext
+	(const sal_uInt32& _local, OdfImport* p_odfImport,
+	 IOdfParentContext* p_parentContext,
+	 /// the context for the enclosing <script:events> element
+	 /// the event name (as understood by the API)
+	 const ::rtl::OUString& rApiEventName,
+	 /// the event type name (as registered)
+	 const ::rtl::OUString& rApiLanguage);
+
+};
+//=============================================================
+
+}
+#endif
+//=============================================================

xmloff/inc/xmloff2/helper/odfpagecharthelper.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: odfpagecharthelper.hxx,v $
+ * $Revision: 1.13.2.2 $
+ *
+ * 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 _XMLOFF_HELPER_ODFPAGECHARTHELPER_HXX_
+#define _XMLOFF_HELPER_ODFPAGECHARTHELPER_HXX_
+ 
+#include <xmloff2/dllapi.h>
+#include <com/sun/star/chart/XChartDocument.hpp>
+
+namespace import{
+	namespace core{
+		class OdfContext;
+	}
+	class OdfImport;
+}
+ 
+namespace helper
+{
+using import::OdfImport;	
+using import::core::OdfContext;
+using namespace com::sun::star;
+	 	
+class OdfPageChartHelper
+{	
+	NO_COPY_ABLE(OdfPageChartHelper);
+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( () )
+		{}
+	
+protected:
+	uno::Reference<chart::XChartDocument>	mxChartDocument;
+public:	
+	OdfPageChartHelper();
+	~OdfPageChartHelper();
+		
+	OdfContext* createChartContext(const sal_Int16& local, OdfImport* p_odfImport, const uno::Reference< frame::XModel >& model);
+    
+    const uno::Reference< chart::XChartDocument >& getChartDocument();
+	  
+};
+ 
+ 
+} 
+ 
+ #endif
+ 
+ 

xmloff/inc/xmloff2/helper/odfpageformhelper.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: odfpageformhelper.hxx,v $
+ * $Revision: 1.13.2.2 $
+ *
+ * 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 _XMLOFF_HELPER_ODF_PAGE_FORM_HELPER_HXX________
+#define _XMLOFF_HELPER_ODF_PAGE_FORM_HELPER_HXX________
+
+#include <xmloff2/dllapi.h>
+#include <xmloff2/compare.hxx>
+#include <com/sun/star/form/XFormsSupplier2.hpp>
+#include <xmloff2/helper/odfeventimporthelper.hxx>
+
+namespace helper
+{
+//=====================================================================
+  	
+class OdfPageFormControlHelper
+{	
+	friend class OdfFormImportHelper;
+	friend class OdfEventImportHelper;
+	NO_COPY_ABLE(OdfPageFormControlHelper);
+protected:
+	uno::Reference<form::XFormsSupplier2>	mxSupp;
+	MapDrawPage2Map                         maControlIds;// ids of the controls on all known page
+	MapDrawPage2MapIterator                 maCurrentPageIds;// ifs of the controls on the current page
+	std::vector<ModelStringPair>            maControlReferences;
+		
+	//// Current Form Context event name and factory ??
+    NameMap*		mpEventNameMap;
+	NameMapList		maEventNameMapList;
+	FactoryMap		maFactoryMap;
+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:
+	std::vector<ModelStringPair>          maCellValueBindings;
+    std::vector<ModelStringPair>          maCellRangeListSources;
+    std::vector<ModelStringPair>          maXFormsValueBindings;
+    std::vector<ModelStringPair>          maXFormsListBindings;
+    std::vector<ModelStringPair>          maXFormsSubmissions;
+
+public:
+	OdfPageFormControlHelper();
+	~OdfPageFormControlHelper();
+		
+    sal_Bool startPage
+    (const uno::Reference< drawing::XDrawPage >& xShapes);
+    sal_Bool endPage();
+
+    void enterEventContext();
+	void leaveEventContext();
+	
+	/// register a handler for a particular language type
+	void registerFactory( const ::rtl::OUString& rLanguage,
+						  OdfEventContextFactory* pFactory );
+	
+public:	
+	uno::Reference<form::XFormsSupplier2> getSupp();
+	uno::Reference< beans::XPropertySet > lookupControl(const ::rtl::OUString& _rControlId);
+	void registerControlId(const uno::Reference<beans::XPropertySet >& _rxControl, const ::rtl::OUString& _rId);
+	void registerControlReferences(const uno::Reference<beans::XPropertySet >& _rxControl, const rtl::OUString& _rReferringControls);
+
+public:
+    void registerCellValue(const uno::Reference<beans::XPropertySet >& xElement, const rtl::OUString& );
+    void registerCellRangeListSource(const uno::Reference<beans::XPropertySet >& xElement, const rtl::OUString& );
+    void registerXFormsValue(const uno::Reference<beans::XPropertySet >& xElement, const rtl::OUString& );
+    void registerXFormsList(const uno::Reference<beans::XPropertySet >& xElement, const rtl::OUString& );
+    void registerXFormsSubmission(const uno::Reference<beans::XPropertySet >& xElement, const rtl::OUString& );
+	
+};
+//=====================================================================
+}
+#endif

xmloff/inc/xmloff2/helper/odfpageshapehelper.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ,v $
+ * $Revision: 1.13.2.2 $
+ *
+ * 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 _XMLOFF_HELPER_ODF_PAGE_SHAPEHELPER_HXX_
+#define _XMLOFF_HELPER_ODF_PAGE_SHAPEHELPER_HXX_
+
+#include <map>
+#include <vector>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+
+#include <xmloff2/import/odfimport.hxx>
+
+namespace helper
+{
+	
+using namespace com::sun::star;
+using import::OdfImport;
+		
+struct ConnectionHint
+{
+	uno::Reference<drawing::XShape > mxConnector;
+	sal_Bool  mbStart;
+	rtl::OUString maDestShapeId;
+	sal_Int32 mnDestGlueId;
+};
+
+struct XShapeCompareHelper
+{
+  bool operator()(uno::Reference<drawing::XShape > x1,
+                  uno::Reference<drawing::XShape > x2 ) const
+  {
+    return x1.get() < x2.get();
+  }
+};
+
+/** this map store all glue point id mappings for shapes that had user defined glue points. This
+    is needed because on insertion the glue points will get a new and unique id */
+typedef std::map<sal_Int32,sal_Int32> GluePointIdMap;
+typedef std::map<uno::Reference <drawing::XShape >, 
+				 GluePointIdMap, 
+				 XShapeCompareHelper > ShapeGluePointsMap;
+
+/** this struct is created for each startPage() call and stores information that is needed during
+import of shapes for one page. Since pages could be nested ( notes pages inside impress ) there
+is a pointer so one can build up a stack of this structs */
+struct ShapePageContextImpl
+{
+    ShapeGluePointsMap		maShapeGluePointsMap;
+
+    uno::Reference < drawing::XShapes > mxShapes;
+
+    struct ShapePageContextImpl* mpNext;
+};
+
+class OdfPageShapeGlueHelper
+{	
+	NO_COPY_ABLE(OdfPageShapeGlueHelper);
+protected:
+    OdfImport* mp_odfImport;
+	std::vector<ConnectionHint> maConnections;
+	ShapePageContextImpl*	mpPageContext;
+	
+protected:	
+	sal_Bool    _restoreConnections();
+	    
+    sal_Int32   _getGluePointId(
+                 uno::Reference<drawing::XShape >& xShape,
+                 sal_Int32 nSourceId);
+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:
+	OdfPageShapeGlueHelper(OdfImport* p_odfImport);
+	
+	~OdfPageShapeGlueHelper();
+	
+	sal_Bool startPage(const uno::Reference< drawing::XShapes >& xShapes);
+    sal_Bool endPage();
+    
+    sal_Bool addShapeConnection
+    (uno::Reference< drawing::XShape >& rConnectorShape,
+	 sal_Bool bStart, const rtl::OUString& rDestShapeId, sal_Int32 nDestGlueId );
+
+	sal_Bool addGluePointMapping
+	(const uno::Reference< drawing::XShape >& xShape,
+	 sal_Int32 nSourceId, sal_Int32 nDestinnationId );
+
+	sal_Bool moveGluePointMapping(
+        const uno::Reference< drawing::XShape >& xShape, const sal_Int32 n );
+};
+//////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////
+// helper functions for z-order sorting
+struct ZOrderHint
+{
+    sal_Int32 nIs;
+    sal_Int32 nShould;
+
+    int operator<(const ZOrderHint& rComp) const
+    { return nShould < rComp.nShould; }
+};
+struct ShapeSortContext
+{
+public:
+    uno::Reference< drawing::XShapes > mxShapes;
+    std::list<ZOrderHint>			  maZOrderList;
+    std::list<ZOrderHint>			  maUnsortedList;
+
+    sal_Int32					  mnCurrentZ;
+    ShapeSortContext*			  mpParentContext;
+    const rtl::OUString				  msZOrder;
+
+    ShapeSortContext
+    (const uno::Reference< drawing::XShapes >& rShapes,
+     ShapeSortContext* pParentContext = NULL)
+    :mxShapes(rShapes)
+    ,mnCurrentZ( 0 )
+    ,mpParentContext(pParentContext)
+    ,msZOrder(RTL_CONSTASCII_USTRINGPARAM("ZOrder"))
+    {}
+
+    void moveShape(sal_Int32 nSourcePos, sal_Int32 nDestPos)
+    {
+        uno::Any aAny( mxShapes->getByIndex( nSourcePos ) );
+        uno::Reference< beans::XPropertySet > xPropSet;
+        aAny >>= xPropSet;
+
+        if( xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( msZOrder ) )
+        {
+            aAny <<= nDestPos;
+            xPropSet->setPropertyValue( msZOrder, aAny );
+
+            std::list<ZOrderHint>::iterator aIter = maZOrderList.begin();
+            std::list<ZOrderHint>::iterator aEnd = maZOrderList.end();
+
+            while( aIter != aEnd )
+            {
+                if( (*aIter).nIs < nSourcePos )
+                {
+                    DBG_ASSERT( (*aIter).nIs >= nDestPos, "Shape sorting failed" );
+                    (*aIter).nIs++;
+                }
+                aIter++;
+            }
+
+            aIter = maUnsortedList.begin();
+            aEnd = maUnsortedList.end();
+
+            while( aIter != aEnd )
+            {
+                if( (*aIter).nIs < nSourcePos )
+                {
+                    DBG_ASSERT( (*aIter).nIs >= nDestPos, "shape sorting failed" );
+                    (*aIter).nIs++;
+                }
+                aIter++;
+            }
+        }
+    }
+};
+
+class OdfPageShapeSortHelper
+{
+	NO_COPY_ABLE(OdfPageShapeSortHelper);
+protected:
+	ShapeSortContext*	mpSortContext;
+	
+public:
+	OdfPageShapeSortHelper();
+	~OdfPageShapeSortHelper();
+	
+    sal_Bool pushGroupForSorting(const uno::Reference< drawing::XShapes >& xShapes);
+    sal_Bool popGroupAndSort();	
+
+    sal_Bool shapeWithZIndexAdded
+        (const uno::Reference<drawing::XShape >& rShape, sal_Int32 nZIndex );
+
+};
+
+}
+#endif

xmloff/inc/xmloff2/helper/odfpagetexthelper.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: odfpagetexthelper.hxx,v $
+ * $Revision: 1.13.2.2 $
+ *
+ * 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 __ODF_PAGE_TEXT_HELPER_HXX____
+#define __ODF_PAGE_TEXT_HELPER_HXX____
+
+
+#include <comphelper/stl_types.hxx>
+
+#include <rtl/ref.hxx>
+#include <xmloff2/dllapi.h>
+
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/text/XFormField.hpp>
+#include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+namespace import
+{
+    namespace core
+    {
+        class OdfContext;
+    }
+}
+
+namespace helper
+{
+using namespace com::sun::star;
+using import::core::OdfContext;
+		
+class OdfTextImportHelper;
+
+class OdfTextCursorHelper
+{
+	NO_COPY_ABLE(OdfTextCursorHelper);
+protected:	
+	uno::Reference<text::XText>			mxText;
+	uno::Reference<text::XTextCursor>	mxCursor;
+	uno::Reference<text::XTextRange>	mxCursorAsRange;
+		
+	rtl::Reference<OdfContext> mxListBlock;
+    rtl::Reference<OdfContext> mxListItem;
+    	
+    sal_Bool			mbBodyContentStarted;	
+    sal_Bool			mbInsideDeleteContext;
+    rtl::OUString 		msOpenRedlineIdentifier;
+    				
+	OdfTextImportHelper* mpImportHelper;
+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:	
+	OdfTextCursorHelper(OdfTextImportHelper* pImportHelper);
+	~OdfTextCursorHelper();
+	
+	void setCursor(const uno::Reference < text::XTextCursor >& rCursor );
+	void resetCursor();
+	const uno::Reference< text::XText >& getText()const;
+	const uno::Reference< text::XTextCursor >& getCursor()const;
+	const uno::Reference< text::XTextRange >& getCursorAsRange()const;
+	void insertString(const rtl::OUString& rChars);
+	void insertString(const rtl::OUString& rChars, sal_Bool& rIgnoreLeadingSpace);
+	void insertControlCharacter(const sal_Int16& nControl);
+	void insertTextContent(const uno::Reference<text::XTextContent>& xContent);
+	void deleteParagraph();
+	sal_Bool isInFrame() const;
+	sal_Bool isInHeaderFooter() const;
+		
+	rtl::Reference<OdfContext> getListBlock();
+	rtl::Reference<OdfContext> getListItem();
+	void setListBlock(const rtl::Reference<OdfContext>& rContext);
+	void setListItem(const rtl::Reference<OdfContext>& rContext);
+	
+	void setOpenRedlineId(const rtl::OUString& rId);
+	rtl::OUString getOpenRedlineId();
+	void resetOpenRedlineId();
+	
+	void setInsideDeleteContext(sal_Bool bNew);
+	sal_Bool isInsideDeleteContext() const;
+
+	void setBodyContentStarted(sal_Bool);
+	sal_Bool isBodyContentStarted() const;
+	
+	void redlineAdd
+        (const rtl::OUString& rType,		/// redline type (insert, del,... )
+		 const rtl::OUString& rId,			/// use to identify this redline
+		 const rtl::OUString& rAuthor,		/// name of the author
+		 const rtl::OUString& rComment,	    /// redline comment
+		 const util::DateTime& rDateTime,	/// date+time
+         sal_Bool bMergeLastParagraph);
+         
+    uno::Reference<text::XTextCursor>
+    redlineCreateText
+        (uno::Reference<text::XTextCursor>& rOldCursor,/// needed to get the document
+		 const rtl::OUString& rId);
+		 	
+	void redlineSetCursor
+        (const rtl::OUString& rId,
+		 sal_Bool bStart,
+		 sal_Bool bIsOutsideOfParagraph);
+		 
+	void redlineAdjustStartNodeCursor(const sal_Bool&);
+	
+	void setShowChanges(sal_Bool bShowChanges );
+	void setRecordChanges(sal_Bool bRecordChanges );
+	void setChangesProtectionKey(const uno::Sequence<sal_Int8>& rProtectionKey );
+		
+	rtl::OUString setStyleAndAttrs
+		(sal_Int32 processId,
+		const uno::Reference<text::XTextCursor>& rCursor,
+		const rtl::OUString& rStyleName,
+		sal_Bool bPara,
+		sal_Bool bOutlineLevelAttrFound = sal_False,
+		sal_Int8 nOutlineLevel = -1,
+		sal_Bool bSetListAttrs = sal_True );
+};
+
+class OdfBookmarkHelper
+{	
+	NO_COPY_ABLE(OdfBookmarkHelper);
+protected:	
+	/// start ranges for open bookmarks
+    typedef std::map<rtl::OUString,
+                // start range, xml:id
+             std::pair<uno::Reference<text::XTextRange>, rtl::OUString>,
+             comphelper::UStringLess> BookmarkStartRangesMap;
+    typedef std::vector<rtl::OUString> BookmarkVector;
+
+    BookmarkStartRangesMap maBookmarkStartRanges;
+    BookmarkVector maBookmarkVector;
+public:
+	OdfBookmarkHelper();
+	~OdfBookmarkHelper();	
+	
+	void insertBookmarkStartRange
+		(const rtl::OUString& sName,
+		const uno::Reference<text::XTextRange> & rRange,
+		const rtl::OUString& sXmlId);
+ 	
+ 	sal_Bool findAndRemoveBookmarkStartRange
+        (const rtl::OUString sName,
+        uno::Reference<text::XTextRange>& rRange, rtl::OUString& rXmlId);
+   
+   rtl::OUString findActiveBookmarkName();
+	
+};
+class OdfFieldHelper
+{
+	NO_COPY_ABLE(OdfFieldHelper);
+protected:	
+	typedef std::pair<rtl::OUString, rtl::OUString> FieldName;
+	typedef std::pair<rtl::OUString, rtl::OUString> FieldParam;
+	typedef std::vector<FieldParam> FieldParams;
+	typedef std::pair<FieldName, FieldParams> FieldStackItem;
+	typedef std::stack<FieldStackItem> FieldStack;
+	FieldStack maFieldStack;
+public:	
+	OdfFieldHelper();
+	~OdfFieldHelper();
+	
+	void setCurrentFieldParamsTo(uno::Reference<text::XFormField> &xFormField);
+	rtl::OUString getCurrentFieldName();
+	rtl::OUString getCurrentFieldType();
+	sal_Bool hasCurrentFieldCtx();
+	void pushFieldCtx(const rtl::OUString& name, const rtl::OUString& type);
+	void popFieldCtx();
+	
+	void addFieldParam(const rtl::OUString& name, const rtl::OUString& value);
+		
+};
+
+class OdfFrameHelper
+{
+	NO_COPY_ABLE(OdfFrameHelper);
+public:
+	OdfFrameHelper();
+	~OdfFrameHelper();
+	
+	virtual uno::Reference<beans::XPropertySet>
+		createAndInsertOLEObject
+    (const rtl::OUString& /*rHRef*/, const rtl::OUString& /*rStyleName*/,
+     const rtl::OUString& /*rTblName*/, sal_Int32 /*nWidth*/,
+     sal_Int32 /*nHeight*/ );
+	
+	virtual uno::Reference<beans::XPropertySet>
+    createAndInsertOOoLink
+    (const rtl::OUString& /*rHRef*/, const rtl::OUString& /*rStyleName*/,
+     const rtl::OUString& /*rTblName*/, sal_Int32 /*nWidth*/,
+     sal_Int32 /*nHeight*/ );
+     
+	virtual uno::Reference<beans::XPropertySet>
+    createAndInsertApplet
+    (const rtl::OUString& /*rCode*/, const rtl::OUString& /*rName*/,
+     sal_Bool /*bMayScript*/, const rtl::OUString& /*rHRef*/,
+     sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ );
+     
+	virtual uno::Reference<beans::XPropertySet>
+    createAndInsertPlugin
+    (const rtl::OUString& /*rMimeType*/, const rtl::OUString& /*rHRef*/,
+     sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ );
+
+	virtual uno::Reference<beans::XPropertySet>
+    createAndInsertFloatingFrame
+     (const rtl::OUString& /*rName*/, const rtl::OUString& /*rHRef*/,
+      const rtl::OUString& /*rStyleName*/, sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ );
+	
+	virtual void endAppletOrPlugin
+    (const uno::Reference<beans::XPropertySet> &rPropSet,
+     std::map<const rtl::OUString, rtl::OUString, comphelper::UStringLess > &rParamMap );
+	
+};
+
+class OdfTextListsHelper
+{
+	NO_COPY_ABLE(OdfTextListsHelper);
+public:
+	OdfTextListsHelper();
+	~OdfTextListsHelper();
+	
+        sal_Bool isListProcessed(const rtl::OUString& sListId );
+        rtl::OUString generateNewListId();
+        // keeping track of processed lists for import and export
+        // --> OD 2008-08-15 #i92811#
+        // - add optional parameter <sListStyleDefaultListId>
+        const ::rtl::OUString& getLastProcessedListId();
+        const ::rtl::OUString& getListStyleOfLastProcessedList();
+        rtl::OUString getContinueListIdOfProcessedList
+        (const rtl::OUString& sListId );
+
+        rtl::OUString getListIdForListBlock(OdfContext* rListBlock);
+        void keepListAsProcessed
+        (const rtl::OUString& sListId, const rtl::OUString& sListStyleName,
+         const rtl::OUString& sContinueListId, const rtl::OUString& sListStyleDefaultListId = rtl::OUString() );
+        // <--
+
+protected:
+        rtl::OUString _getListStyleOfProcessedList
+            (const rtl::OUString& sListId);
+
+        // container type for processed lists:
+        // map with <ListId> as key and pair( <ListStyleName, ContinueListId> )
+        // as value
+        typedef std::map<rtl::OUString,
+                         std::pair<rtl::OUString, rtl::OUString>,
+                         comphelper::UStringLess > MapForLists;
+                         	
+        MapForLists		mProcessedLists;
+
+        rtl::OUString	msLastProcessedListId;
+        rtl::OUString	msListStyleOfLastProcessedList;
+
+        MapForLists		mProcessedListsStyle;
+        
+
+};
+//=============================================================
+}
+#endif

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

         // 3
         _begin += (*mp_odfImport)[_begin]->getCount() +1;
     }
+
 	static int _cupcount = DetectNumberOfWorkers();
 	//static int _cupcount = 1;
 	static sal_Bool _bInit = sal_False;

xmloff/inc/xmloff2/import/draw/sdbodycontext.h

 
 }
 //------------------------------------------------------------
+#ifdef PERFORMANCE_PARALLEL	
+template< class ParentContext >
+sal_Bool BodyContext< ParentContext >::processSubContexts()
+{
+	sal_uInt32 _begin = m_odfElementInfoRef->getLocal() + 1;
+    sal_uInt32 _end = _begin + m_odfElementInfoRef->getCount();
+    int i = 0;
+    while( _begin < _end )
+    {
+        // 1
+        OdfContext* p_currentContext = _createChildContext(_begin);
+        // 2
+        /// Sometimes the result will be NULL
+        if( NULL != p_currentContext )
+        {
+        	p_currentContext->initProcessContext(i ++ );
+            m_rSubContexts.push_back(p_currentContext);
+        }
+        // 3
+        _begin += (*mp_odfImport)[_begin]->getCount() +1;
+    }
+    /***/
+    sal_Int32 pageCount = _getSdImport()->getLocalDrawPages()->getCount();
+    /****/
+    
+	static int _cupcount = DetectNumberOfWorkers();
+	//static int _cupcount = 1;
+	static sal_Bool _bInit = sal_False;
+	if( !_bInit )
+	{		
+		omp_set_num_threads(_cupcount);
+		_bInit = sal_True;
+	}
+	int _size = m_rSubContexts.size();	
+	//vos::IParallelRegister* pRegister = dynamic_cast<vos::IParallelRegister*>(&Application::GetSolarMutex() );
+	//sal_Int32 _parentId = osl::Thread::getCurrentIdentifier();
+
+	i = 0;
+	#pragma omp parallel for private(i)
+	for( i = 0 ; i < _size ; i++ )
+	{
+		try{				
+			_processSubContext(m_rSubContexts[i]);
+		}catch( ... )
+		{
+			DBG_ASSERT( sal_False, "Error ..." );
+			std::cout << "you are wang" << std::endl;
+		}
+	}
+
+    for( int i = 0 ; i< m_rSubContexts.size() ; i++ )
+    {
+        _collectSubContext(m_rSubContexts[i]);
+    }
+    //m_rSubContexts.clear();
+    return true;
+
+}	
+#endif
+
 template< class ParentContext >
 OdfContext* BodyContext< ParentContext >::_createChildContext(const sal_uInt32& _local)
 {

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

 	 IOdfParentContext* p_parentContext);
 
 	virtual ~BodyContext();
+	
+#ifdef PERFORMANCE_PARALLEL	
+	virtual sal_Bool processSubContexts();
+#endif
 
 public:
 

xmloff/inc/xmloff2/import/draw/style/sdstylecontext.hxx

 	virtual ~SdMasterStylesContext();
 	
     //const SdMasterPageList& getMasterPageList() const { return mMasterPageList; }
+#ifdef PERFORMANCE_PARALLEL	
+	virtual sal_Bool processSubContexts();
+#endif
 
 protected:
 	virtual OdfContext *_createChildContext(const sal_uInt32&);

xmloff/source2/import/chart/odfpagecharthelper.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: odfpagecharthelper.cxx,v $
+ * $Revision: 1.13.2.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <xmloff2/helper/odfpagecharthelper.hxx>
+#include <xmloff2/import/chart/schchartcontext.hxx>
+
+namespace helper
+{
+using import::_chart::SchChartContext;	
+//------------------------------------------------------------
+OdfPageChartHelper::OdfPageChartHelper()
+{
+	
+}
+//------------------------------------------------------------
+OdfPageChartHelper::~OdfPageChartHelper()
+{
+}
+//------------------------------------------------------------
+OdfContext* OdfPageChartHelper::createChartContext
+(const sal_Int16& local, OdfImport* p_odfImport, const uno::Reference< frame::XModel >& model)
+{
+	OdfContext* pContext = 0;
+
+	uno::Reference< chart::XChartDocument > xDoc( model, uno::UNO_QUERY );
+	if( xDoc.is())
+	{
+		mxChartDocument = xDoc;
+		pContext = new SchChartContext(local, p_odfImport);
+	}
+	else
+	{
+		DBG_ERROR( "No valid XChartDocument given as XModel" );
+		pContext = new OdfContext(local, p_odfImport);
+	}
+	return pContext;
+	
+}
+//------------------------------------------------------------
+const uno::Reference< chart::XChartDocument >& 
+	OdfPageChartHelper::getChartDocument()
+{
+	return mxChartDocument;
+	
+}
+//------------------------------------------------------------
+}

xmloff/source2/import/draw/odfpageshapehelper.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: odfshapeimporthelper.cxx,v $
+ * $Revision: 1.13.2.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <xmloff2/helper/odfpageshapehelper.hxx>
+#include <xmloff2/helper/unointerfacetouniqueidentifiermapper.hxx>
+namespace helper
+{
+//=====================================================================
+OdfPageShapeGlueHelper::OdfPageShapeGlueHelper(OdfImport* p_odfImport)
+:mp_odfImport(p_odfImport)
+,mpPageContext(NULL)
+{
+	
+}
+//=====================================================================
+OdfPageShapeGlueHelper::~OdfPageShapeGlueHelper()
+{
+	OSL_ENSURE( mpPageContext == NULL, "OdfPageShapeGlueHelper::~OdfPageShapeGlueHelper()");
+	while(mpPageContext!=NULL)
+	{
+		ShapePageContextImpl* pNextContext = mpPageContext->mpNext;
+		delete mpPageContext;
+		mpPageContext = pNextContext;
+	}
+}	
+//=====================================================================
+sal_Bool OdfPageShapeGlueHelper::startPage
+	(const uno::Reference< drawing::XShapes >& xShapes)
+{
+	ShapePageContextImpl* pNextContext = new ShapePageContextImpl();	
+	pNextContext->mpNext = mpPageContext;
+	mpPageContext = pNextContext;
+	mpPageContext->mxShapes = xShapes;
+	return sal_True;
+}
+//=====================================================================
+sal_Bool OdfPageShapeGlueHelper::endPage()
+{
+    _restoreConnections();
+    
+	ShapePageContextImpl* pNextContext = mpPageContext->mpNext;
+	delete mpPageContext;
+	mpPageContext = pNextContext;
+	return sal_True;
+}
+
+//=====================================================================
+sal_Bool OdfPageShapeGlueHelper::_restoreConnections()
+{
+    if( !maConnections.empty() )
+	{
+		uno::Any aAny;
+			
+		const std::vector<ConnectionHint>::size_type nCount = maConnections.size();
+		for(std::vector<ConnectionHint>::size_type i = 0; i < nCount; i++ )
+		{
+			ConnectionHint& rHint = maConnections[i];
+			uno::Reference< beans::XPropertySet > xConnector( rHint.mxConnector, uno::UNO_QUERY );
+			if( xConnector.is() )
+			{
+				// #86637# remember line deltas
+				uno::Any aLine1Delta;
+				uno::Any aLine2Delta;
+				uno::Any aLine3Delta;
+				rtl::OUString aStr1(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta"));
+				rtl::OUString aStr2(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta"));
+				rtl::OUString aStr3(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta"));
+				aLine1Delta = xConnector->getPropertyValue(aStr1);
+				aLine2Delta = xConnector->getPropertyValue(aStr2);
+				aLine3Delta = xConnector->getPropertyValue(aStr3);
+
+
+                rtl::OUString aStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape"));
+                rtl::OUString aEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape"));
+                rtl::OUString aStartGluePointIndex(RTL_CONSTASCII_USTRINGPARAM("StartGluePointIndex"));
+                rtl::OUString aEndGluePointIndex(RTL_CONSTASCII_USTRINGPARAM("EndGluePointIndex"));
+
+				// #86637# simply setting these values WILL force the connector to do
+				// an new layout promptly. So the line delta values have to be rescued
+				// and restored around connector changes.
+				uno::Reference< drawing::XShape > xShape
+					(mp_odfImport->getInterfaceToIdentifierMapper().getReference( rHint.maDestShapeId ), uno::UNO_QUERY );
+				if( xShape.is() )
+				{
+					aAny <<= xShape;
+					xConnector->setPropertyValue( rHint.mbStart ? aStartShape : aEndShape, aAny );
+
+					sal_Int32 nGlueId = rHint.mnDestGlueId < 4 ? rHint.mnDestGlueId : _getGluePointId(xShape, rHint.mnDestGlueId );
+					aAny <<= nGlueId;
+					xConnector->setPropertyValue( rHint.mbStart ? aStartGluePointIndex : aEndGluePointIndex, aAny );
+				}
+
+				// #86637# restore line deltas
+				xConnector->setPropertyValue(aStr1, aLine1Delta );
+				xConnector->setPropertyValue(aStr2, aLine2Delta );
+				xConnector->setPropertyValue(aStr3, aLine3Delta );
+			}
+		}
+		maConnections.clear();
+	}
+	return sal_True;
+}
+//=====================================================================
+sal_Int32 OdfPageShapeGlueHelper::_getGluePointId
+(uno::Reference<drawing::XShape >& xShape, sal_Int32 nSourceId)
+{	
+    if( mpPageContext )
+	{
+		ShapeGluePointsMap::iterator
+            aShapeIter( mpPageContext->maShapeGluePointsMap.find( xShape ) );
+		if( aShapeIter != mpPageContext->maShapeGluePointsMap.end() )
+		{
+			GluePointIdMap::iterator aIdIter = (*aShapeIter).second.find(nSourceId);
+			if( aIdIter != (*aShapeIter).second.end() )
+				return (*aIdIter).second;
+		}
+	}	
+	return -1;
+}
+//=====================================================================
+sal_Bool OdfPageShapeGlueHelper::addGluePointMapping
+	(const uno::Reference< drawing::XShape >& xShape,
+	 sal_Int32 nSourceId, sal_Int32 nDestinnationId )
+{
+	
+    if( mpPageContext )
+		mpPageContext->maShapeGluePointsMap[xShape][nSourceId] = nDestinnationId;
+    return sal_True;    
+}
+//=====================================================================
+sal_Bool OdfPageShapeGlueHelper::moveGluePointMapping(
+        const uno::Reference< drawing::XShape >& xShape, const sal_Int32 n )
+{
+	
+    if( mpPageContext )
+	{
+		ShapeGluePointsMap::iterator aShapeIter( mpPageContext->maShapeGluePointsMap.find( xShape ) );
+		if( aShapeIter != mpPageContext->maShapeGluePointsMap.end() )
+		{
+			GluePointIdMap::iterator aShapeIdIter = (*aShapeIter).second.begin();
+			GluePointIdMap::iterator aShapeIdEnd  = (*aShapeIter).second.end();
+			while ( aShapeIdIter != aShapeIdEnd )
+			{
+				if ( (*aShapeIdIter).second != -1 )
+					(*aShapeIdIter).second += n;
+				aShapeIdIter++;
+			}
+		}
+	}
+	return sal_True;
+}
+//=====================================================================
+sal_Bool OdfPageShapeGlueHelper::addShapeConnection
+    (uno::Reference< drawing::XShape >& rConnectorShape,
+	 sal_Bool bStart, const rtl::OUString& rDestShapeId, sal_Int32 nDestGlueId )
+{
+    ConnectionHint aHint;
+	aHint.mxConnector = rConnectorShape;
+	aHint.mbStart = bStart;
+	aHint.maDestShapeId = rDestShapeId;
+	aHint.mnDestGlueId = nDestGlueId;
+
+	maConnections.push_back( aHint );
+	return sal_True;
+}
+//=====================================================================
+//=====================================================================
+//=====================================================================
+OdfPageShapeSortHelper::OdfPageShapeSortHelper()
+:mpSortContext(NULL)	
+{
+	
+}
+//=====================================================================
+OdfPageShapeSortHelper::~OdfPageShapeSortHelper()
+{
+	OSL_ENSURE( NULL == mpSortContext , 
+		"OdfPageShapeSortHelper::~OdfPageShapeSortHelper ");
+	while( NULL != mpSortContext )
+	{
+		ShapeSortContext* pContext = mpSortContext;
+		//#pragma omp critical 
+		{
+			mpSortContext = pContext->mpParentContext;
+		}
+		delete pContext;
+	}
+}
+//=====================================================================
+sal_Bool OdfPageShapeSortHelper::pushGroupForSorting
+    (const uno::Reference< drawing::XShapes >& xShapes)
+{
+	mpSortContext = new ShapeSortContext(xShapes, mpSortContext);	
+    return sal_True;
+}
+//=====================================================================
+sal_Bool OdfPageShapeSortHelper::popGroupAndSort()
+{
+    DBG_ASSERT( mpSortContext, "No context to sort!" );
+	if( mpSortContext == NULL )
+		return sal_False;
+
+	try
+	{
+		std::list<ZOrderHint>& rZList = mpSortContext->maZOrderList;
+		std::list<ZOrderHint>& rUnsortedList = mpSortContext->maUnsortedList;
+
+		// sort shapes
+		if( !rZList.empty() )
+		{
+			// only do something if we have shapes to sort
+
+			// check if there are more shapes than inserted with ::shapeWithZIndexAdded()
+			// This can happen if there where already shapes on the page before import
+			// Since the writer may delete some of this shapes during import, we need
+			// to do this here and not in our c'tor anymore
+
+			// check if we have more shapes than we know of
+			sal_Int32 nCount = mpSortContext->mxShapes->getCount();
+
+			nCount -= rZList.size();
+			nCount -= rUnsortedList.size();
+			
+			if( nCount > 0 )
+			{
+				// first update offsets of added shapes
+				std::list<ZOrderHint>::iterator aIter( rZList.begin() );
+				while( aIter != rZList.end() )
+					(*aIter++).nIs += nCount;
+
+				aIter = rUnsortedList.begin();
+				while( aIter != rUnsortedList.end() )
+					(*aIter++).nIs += nCount;
+
+				// second add the already existing shapes in the unsorted list
+				ZOrderHint aNewHint;
+				do
+				{
+					nCount--;
+
+					aNewHint.nIs = nCount;
+					aNewHint.nShould = -1;
+					rUnsortedList.insert(rUnsortedList.begin(), aNewHint);
+				}
+				while( nCount );
+			}
+
+			// sort z ordered shapes
+			rZList.sort();
+
+			// this is the current index, all shapes before that
+			// index are finished
+			sal_Int32 nIndex = 0;
+			while( !rZList.empty() )
+			{
+				std::list<ZOrderHint>::iterator aIter( rZList.begin() );
+
+				while( nIndex < (*aIter).nShould && !rUnsortedList.empty() )
+				{
+					ZOrderHint aGapHint( *rUnsortedList.begin() );
+					rUnsortedList.pop_front();
+
+					mpSortContext->moveShape( aGapHint.nIs, nIndex++ );
+				}
+
+				if( (*aIter).nIs != nIndex )
+					mpSortContext->moveShape( (*aIter).nIs, nIndex );
+
+				rZList.pop_front();
+				nIndex++;
+			}
+		}
+	}
+	catch( uno::Exception& )
+	{
+		DBG_ERROR("exception while sorting shapes, sorting failed!");
+	}
+
+	// put parent on top and delete current context, were done
+	ShapeSortContext* pContext = mpSortContext;
+	//#pragma omp critical 
+	{
+		mpSortContext = pContext->mpParentContext;
+	}
+	delete pContext;
+	return sal_True;
+}
+//=====================================================================
+sal_Bool OdfPageShapeSortHelper::shapeWithZIndexAdded
+        (const uno::Reference<drawing::XShape >& rShape,
+         sal_Int32 nZIndex )
+{
+    if(mpSortContext)
+	{
+		ZOrderHint aNewHint;
+		aNewHint.nIs = mpSortContext->mnCurrentZ++;
+		aNewHint.nShould = nZIndex;
+
+		if( nZIndex == -1 )
+		{
+			// don't care, so add to unsorted list
+			mpSortContext->maUnsortedList.push_back(aNewHint);
+		}
+		else
+		{
+			// insert into sort list
+			mpSortContext->maZOrderList.push_back(aNewHint);
+		}
+	}
+	return sal_True;
+}
+//=====================================================================
+
+}

xmloff/source2/import/draw/style/sdstylescontext2.cxx

 
 }
 //=============================================================
+#ifdef PERFORMANCE_PARALLEL	
+sal_Bool SdMasterStylesContext::processSubContexts()
+{
+	sal_uInt32 _begin = m_odfElementInfoRef->getLocal() + 1;
+    sal_uInt32 _end = _begin + m_odfElementInfoRef->getCount();
+    int i = 0;
+    while( _begin < _end )
+    {
+        // 1
+        OdfContext* p_currentContext = _createChildContext(_begin);
+        // 2
+        /// Sometimes the result will be NULL
+        if( NULL != p_currentContext )
+        {
+        	p_currentContext->initProcessContext(i ++ );
+            m_rSubContexts.push_back(p_currentContext);
+        }
+        // 3
+        _begin += (*mp_odfImport)[_begin]->getCount() +1;
+    }
+
+	sal_Int32 pageCount = _getSdImport().getMasterPages()->getCount();
+
+	static int _cupcount = /*DetectNumberOfWorkers()*/ 1;
+	//static int _cupcount = 1;
+	static sal_Bool _bInit = sal_False;
+	if( !_bInit )
+	{		
+		omp_set_num_threads(_cupcount);
+		_bInit = sal_True;
+	}
+	int _size = m_rSubContexts.size();	
+	//vos::IParallelRegister* pRegister = dynamic_cast<vos::IParallelRegister*>(&Application::GetSolarMutex() );
+	//sal_Int32 _parentId = osl::Thread::getCurrentIdentifier();
+
+	i = 0;
+	//#pragma omp parallel for private(i)
+	for( i = 0 ; i < _size ; i++ )
+	{
+		try{				
+			_processSubContext(m_rSubContexts[i]);
+		}catch( ... )
+		{
+			DBG_ASSERT( sal_False, "Error ..." );
+			std::cout << "you are wang" << std::endl;
+		}
+	}
+
+    for( int i = 0 ; i< m_rSubContexts.size() ; i++ )
+    {
+        _collectSubContext(m_rSubContexts[i]);
+    }
+    //m_rSubContexts.clear();
+    return true;	
+}
+#endif
+//=============================================================
 OdfContext* SdMasterStylesContext::_createChildContext
 (const sal_uInt32& _local)
 {

xmloff/source2/import/forms/odfpageformhelper.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: odfpageformhelper.cxx,v $
+ * $Revision: 1.13.2.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "strings.hxx"
+#include <tools/debug.hxx>
+#include <xmloff2/helper/odfpageformhelper.hxx>
+
+
+namespace helper
+{
+using namespace import::_forms;
+//=====================================================================
+OdfPageFormControlHelper::OdfPageFormControlHelper()
+:mpEventNameMap(NULL)
+{
+	
+}
+//=====================================================================
+OdfPageFormControlHelper::~OdfPageFormControlHelper()
+{
+	FactoryMap::iterator aEnd = maFactoryMap.end();
+	for(FactoryMap::iterator aIter = maFactoryMap.begin(); 
+		aIter != aEnd; 
+		aIter++ )
+	{
+		delete aIter->second;
+	}
+	maFactoryMap.clear();
+
+	if(mpEventNameMap)
+	{
+		delete mpEventNameMap;
+	}
+	/*
+	aEventNameMapList
+	
+	*/
+}
+//=====================================================================
+sal_Bool OdfPageFormControlHelper::startPage
+    (const uno::Reference< drawing::XDrawPage >& xShapes)
+{	
+    OSL_ENSURE(xShapes.is(), "OdfPageFormControlHelper::startPage: NULL page!");
+    mxSupp = uno::Reference<form::XFormsSupplier2 >::query(xShapes);
+    OSL_ENSURE( mxSupp.is(), "OdfPageFormControlHelper::startPage: invalid draw page (no XFormsSupplier)!" );
+    if ( !mxSupp.is() )
+        return sal_False;
+
+    // add a new entry to our page map
+    std::pair<MapDrawPage2MapIterator, bool > aPagePosition;
+    aPagePosition =
+        maControlIds.insert(MapDrawPage2Map::value_type(xShapes, MapString2PropertySet()));
+    OSL_ENSURE(aPagePosition.second, "OdfPageFormControlHelper::startPage: already imported this page!");
+    maCurrentPageIds = aPagePosition.first;
+
+    return sal_True;
+}
+//=====================================================================
+sal_Bool OdfPageFormControlHelper::endPage()
+{	
+    OSL_ENSURE(mxSupp.is(), "OdfPageFormControlHelper::endPage: sure you called startPage before?" );
+    // do some knittings for the controls which are referring to each other
+    try
+    {
+        static const sal_Unicode s_nSeparator = ',';
+        rtl::OUString sReferring;
+        rtl::OUString sCurrentReferring;
+        rtl::OUString sSeparator(&s_nSeparator, 1);
+        uno::Reference<beans::XPropertySet > xCurrentReferring;
+        sal_Int32 nSeparator, nPrevSep;
+        for(std::vector< ModelStringPair >::const_iterator aReferences = maControlReferences.begin();
+                aReferences != maControlReferences.end();
+                ++aReferences
+            )
+        {
+            // the list of control ids is comma separated
+
+            // in a list of n ids there are only n-1 separators ... have to catch this last id
+            // -> normalize the list
+            sReferring = aReferences->second;
+            sReferring += sSeparator;
+
+            nPrevSep = -1;
+            while(-1 != (nSeparator = sReferring.indexOf(s_nSeparator, nPrevSep + 1)))
+            {
+                sCurrentReferring = sReferring.copy(nPrevSep + 1, nSeparator - nPrevSep - 1);
+                xCurrentReferring = lookupControl(sCurrentReferring);
+                if (xCurrentReferring.is())
+                    // if this condition fails, this is an error, but lookupControlId should have asserted this ...
+                    xCurrentReferring->setPropertyValue
+                        (PROPERTY_CONTROLLABEL, uno::makeAny( aReferences->first ) );
+
+                nPrevSep = nSeparator;
+            }
+        }
+    }
+    catch(uno::Exception& )
+    {
+        OSL_ENSURE(sal_False, "OdfPageFormControlHelper::endPage: unable to knit the control references (caught an exception)!");
+    }
+
+    // now that we have all children of the forms collection, attach the events
+    uno::Reference<container::XIndexAccess > xIndexContainer;
+    if ( mxSupp.is() && mxSupp->hasForms() )
+        xIndexContainer = xIndexContainer.query( mxSupp->getForms() );
+    // TODO
+    /*
+    if ( xIndexContainer.is() )
+        IEventAttacherManager::_setEvents( xIndexContainer );
+	*/
+    // clear the structures for the control references.
+    maControlReferences.clear();
+    // and no we have no current page anymore
+    maCurrentPageIds = maControlIds.end();
+    return sal_True;
+}
+//=====================================================================
+void OdfPageFormControlHelper::registerControlId
+(const uno::Reference<beans::XPropertySet >& _rxControl,
+ const ::rtl::OUString& _rId)
+{
+    OSL_ENSURE(maCurrentPageIds != maControlIds.end(),
+              "OdfPageFormControlHelper::registerControlId: no current page!");
+    OSL_ENSURE(_rId.getLength(), "OdfPageFormControlHelper::registerControlId: invalid (empty) control id!");
+
+    OSL_ENSURE(maCurrentPageIds->second.end() == maCurrentPageIds->second.find(_rId), "OFormLayerXMLImport_Impl::registerControlId: control id already used!");
+    maCurrentPageIds->second[_rId] = _rxControl;
+}
+//=====================================================================
+uno::Reference< beans::XPropertySet > OdfPageFormControlHelper::lookupControl
+(const ::rtl::OUString& _rControlId)
+{
+    OSL_ENSURE(maCurrentPageIds != maControlIds.end(),
+        "OdfPageFormControlHelper::lookupControl: no current page!");
+    uno::Reference< beans::XPropertySet > xReturn;
+    if(maCurrentPageIds != maControlIds.end())
+    {
+        ConstMapString2PropertySetIterator aPos = maCurrentPageIds->second.find(_rControlId);
+        if(maCurrentPageIds->second.end() != aPos)
+            xReturn = aPos->second;
+        else
+            OSL_ENSURE(sal_False, "OdfPageFormControlHelper::lookupControl: invalid control id (did not find it)!");
+    }
+    return xReturn;
+}
+//=====================================================================
+void OdfPageFormControlHelper::registerControlReferences
+(const uno::Reference<beans::XPropertySet >& _rxControl,
+ const rtl::OUString& _rReferringControls)
+{    
+    OSL_ENSURE(_rxControl.is(), "OdfPageFormControlHelper::registerControlReferences: invalid (NULL) control!");
+    maControlReferences.push_back( ModelStringPair( _rxControl, _rReferringControls ) );
+}
+//=====================================================================
+void OdfPageFormControlHelper::enterEventContext()
+{
+    // first
+    if( NULL == mpEventNameMap )
+    {
+        mpEventNameMap = new NameMap();
+    }
+    maEventNameMapList.push_back(mpEventNameMap);
+    mpEventNameMap = new NameMap();
+    //
+    for(const OdfEventNameTranslation* pTrans = aStandardEventTable;
+		pTrans->sAPIName != NULL;
+		pTrans++)
+	{
+	    OdfEventName aName(pTrans->nPrefix, pTrans->sXMLName);
+	    // check for conflicting entries
+		DBG_ASSERT(mpEventNameMap->find(aName) == mpEventNameMap->end(),
+					   "conflicting event translations");
+        // assign new translation
+		(*(mpEventNameMap))[aName] = rtl::OUString::createFromAscii(pTrans->sAPIName);
+	}
+}
+//=====================================================================
+void OdfPageFormControlHelper::leaveEventContext()
+{
+    DBG_ASSERT(maEventNameMapList.size() > 0,
+			   "no translation tables left to pop");
+	if (maEventNameMapList.size() > 0)
+	{
+		// delete current and install old map
+		delete mpEventNameMap;
+		mpEventNameMap = maEventNameMapList.back();
+		maEventNameMapList.pop_back();
+	}
+}
+
+//=====================================================================
+void OdfPageFormControlHelper::registerCellValue
+(const uno::Reference<beans::XPropertySet >& _rxControlModel,
+ const rtl::OUString& _rCellAddress)
+{
+     OSL_ENSURE( _rxControlModel.is() && _rCellAddress.getLength(),
+            "OdfPageFormControlHelper::registerCellValue: invalid arguments!" );
+     maCellValueBindings.push_back( ModelStringPair( _rxControlModel, _rCellAddress ) );
+}
+//=====================================================================
+void OdfPageFormControlHelper::registerCellRangeListSource
+(const uno::Reference<beans::XPropertySet >& _rxControlModel,
+ const rtl::OUString& _rCellRangeAddress)
+{
+    OSL_ENSURE( _rxControlModel.is() && _rCellRangeAddress.getLength(),
+            "OdfPageFormControlHelper::registerCellRangeListSource: invalid arguments!" );
+    maCellRangeListSources.push_back( ModelStringPair( _rxControlModel, _rCellRangeAddress ) );
+}
+//=====================================================================
+void OdfPageFormControlHelper::registerXFormsValue
+(const uno::Reference<beans::XPropertySet >& _rxControlModel,
+ const rtl::OUString& _rBindingID)
+{
+    // TODO: is an empty binding name allowed?
+    OSL_ENSURE( _rxControlModel.is()&& _rBindingID.getLength(), "need  model" );
+
+    maXFormsValueBindings.push_back( ModelStringPair( _rxControlModel, _rBindingID ) );
+}
+//=====================================================================
+void OdfPageFormControlHelper::registerXFormsList
+(const uno::Reference<beans::XPropertySet >& _rxControlModel,
+ const rtl::OUString& _rBindingID)
+{
+    // TODO: is an empty binding name allowed?
+    OSL_ENSURE( _rxControlModel.is(), "need  model" );
+
+    maXFormsListBindings.push_back(
+        ModelStringPair( _rxControlModel, _rBindingID ) );
+}
+//=====================================================================
+void OdfPageFormControlHelper::registerXFormsSubmission
+(const uno::Reference<beans::XPropertySet >& _rxControlModel,
+ const rtl::OUString& _rSubmissionID)
+{
+    // TODO: is an empty binding name allowed?
+    OSL_ENSURE( _rxControlModel.is(), "need  model" );
+
+    maXFormsSubmissions.push_back(
+        ModelStringPair( _rxControlModel, _rSubmissionID ) );
+}
+//=====================================================================
+
+}//namespace helper
+

xmloff/source2/import/script/odfeventimporthelper.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.
+ *
+ ************************************************************************/
+#include <tools/debug.hxx>
+#include <xmloff2/import/odfimport.hxx>
+#include <xmloff2/import/core/odfcontext.hxx>
+#include <xmloff2/helper/odfpageformhelper.hxx>
+#include <xmloff2/helper/odfformimporthelper.hxx>
+#include <xmloff2/helper/odfeventimporthelper.hxx>
+
+namespace helper
+{ 
+//=============================================================
+OdfEventImportHelper::OdfEventImportHelper()
+:mpEventNameMap(new NameMap())
+{
+	
+}
+//=============================================================
+OdfEventImportHelper::~OdfEventImportHelper()
+{
+	FactoryMap::iterator aEnd = maFactoryMap.end();
+	for(FactoryMap::iterator aIter = maFactoryMap.begin(); 
+		aIter != aEnd; 
+		aIter++ )
+	{
+		delete aIter->second;
+	}
+	maFactoryMap.clear();
+
+	if(mpEventNameMap)
+	{
+		delete mpEventNameMap;
+	}
+	/*
+	aEventNameMapList
+	
+	*/
+}
+//=============================================================
+void OdfEventImportHelper::registerFactory
+	( const ::rtl::OUString& rLanguage,
+	 OdfEventContextFactory* pFactory )
+{
+	DBG_ASSERT(pFactory != NULL, "I need a factory.");
+	if (NULL != pFactory)
+	{
+		maFactoryMap[rLanguage] = pFactory;
+	}
+}
+//=============================================================
+void OdfEventImportHelper::addTranslationTable
+	( const OdfEventNameTranslation* pTransTable )
+{
+	if (NULL != pTransTable)
+	{
+		// put translation table into map
+		for(const OdfEventNameTranslation* pTrans = pTransTable;
+			pTrans->sAPIName != NULL;
+			pTrans++)
+		{
+			OdfEventName aName( pTrans->nPrefix, pTrans->sXMLName );
+
+			// check for conflicting entries
+			DBG_ASSERT(mpEventNameMap->find(aName) == mpEventNameMap->end(),
+					   "conflicting event translations");
+
+			// assign new translation
+			(*mpEventNameMap)[aName] = 
+				rtl::OUString::createFromAscii(pTrans->sAPIName);
+		}
+	}	
+}	
+//=============================================================
+void OdfEventImportHelper::pushTranslationTable()
+{
+	maEventNameMapList.push_back(mpEventNameMap);
+	mpEventNameMap = new NameMap();
+}
+//=============================================================
+void OdfEventImportHelper::popTranslationTable()
+{
+	DBG_ASSERT(maEventNameMapList.size() > 0, 
+			   "no translation tables left to pop");
+	if ( !maEventNameMapList.empty() )
+	{
+		// delete current and install old map
+		delete mpEventNameMap;
+		mpEventNameMap = maEventNameMapList.back();
+		maEventNameMapList.pop_back();
+	}
+}
+//=====================================================================
+OdfContext* OdfEventImportHelper::createEventContext
+(const sal_uInt32& _local, OdfImport* p_odfImport,
+	 IOdfParentContext* p_parentContext,
+	 /// the context for the enclosing <script:events> element
+	 /// the event name (as understood by the API)
+	 const ::rtl::OUString& rApiEventName,
+	 /// the event type name (as registered)
+	 const ::rtl::OUString& rApiLanguage)
+{
+	OdfContext* pContext = NULL;
+
+	// translate event name form xml to api
+	OdfEventName aEventName( (*p_odfImport)[_local]->getPrefix(),
+                             (*p_odfImport)[_local]->getLocalName() );
+    
+    OdfPageFormControlHelper* pControlHelper = p_odfImport->getFormHelper()->getControlHelper
+    	(dynamic_cast<OdfContext*>(p_parentContext)->getProcessId());
+    NameMap* pNameMap = NULL;
+    if( pControlHelper && pControlHelper ->mpEventNameMap )
+    {
+    	pNameMap = pControlHelper ->mpEventNameMap;
+    }else
+    {
+    	pNameMap = mpEventNameMap;
+    }
+    
+    if( pNameMap != NULL )
+    {
+        NameMap::iterator aNameIter = pNameMap ->find(aEventName);
+        if (aNameIter != pNameMap ->end())
+        {
+            rtl::OUString aScriptLanguage;
+            sal_uInt16 nScriptPrefix = (*p_odfImport)[_local]->getOdfNamespaceMapRef()->_getKeyByAttrName( rApiLanguage, &aScriptLanguage );
+
+            if( ODF_NAMESPACE_OOO != nScriptPrefix )
+                aScriptLanguage = rApiLanguage;
+
+            // check for factory
+            FactoryMap::const_iterator aFactoryIterator;
+            sal_Bool bFound = sal_False;
+            if( pControlHelper )
+            {	
+            	aFactoryIterator = pControlHelper->maFactoryMap.find(aScriptLanguage);
+            	bFound = ( aFactoryIterator != pControlHelper->maFactoryMap.end() );
+            }
+            if( !bFound )
+            {
+            	aFactoryIterator = maFactoryMap.find(aScriptLanguage);
+            	bFound = ( aFactoryIterator != maFactoryMap.end() );
+            }
+            if (bFound)
+            {
+                // delegate to factory
+                pContext = aFactoryIterator->second->createContext(
+                    _local, p_odfImport, p_parentContext,
+                    aNameIter->second, aScriptLanguage);
+            }
+        }
+    }
+	// default context (if no context was created above)
+	if( NULL == pContext )
+	{
+		pContext = p_odfImport->createContext(_local, p_parentContext);
+        /*
+        Sequence<OUString> aMsgParams(2);
+
+        aMsgParams[0] = rXmlEventName;
+        aMsgParams[1] = rLanguage;
+
+        rImport.SetError(XMLERROR_FLAG_ERROR | XMLERROR_ILLEGAL_EVENT,
+                         aMsgParams);
+        */
+	}
+	return pContext;
+}
+
+
+}

xmloff/source2/import/text/odfpagetexthelper.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: odfpagetexthelper.cxx,v $
+ * $Revision: 1.13.2.2 $
+ *
+ * This file is part of OpenOffice.org.