[Libreoffice-commits] .: patches/dev300

Fridrich Strba fridrich at kemper.freedesktop.org
Sat Nov 6 09:01:07 PDT 2010


 patches/dev300/libwpd-testing.diff        |   14 
 patches/dev300/libwpg-testing.diff        |   29 
 patches/dev300/libwps-testing.diff        |   14 
 patches/dev300/writerperfect-testing.diff | 4133 +++++++++++++-----------------
 4 files changed, 1935 insertions(+), 2255 deletions(-)

New commits:
commit 4f9de255d0dccf33b74452c3345f07f28597a23d
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Sat Nov 6 17:00:25 2010 +0100

    Adapt the unstable libwp* patches to the current libwp* APIs

diff --git a/patches/dev300/libwpd-testing.diff b/patches/dev300/libwpd-testing.diff
index 6becd23..40abb54 100644
--- a/patches/dev300/libwpd-testing.diff
+++ b/patches/dev300/libwpd-testing.diff
@@ -1,18 +1,18 @@
---- libwpd/makefile.mk	2008-04-07 14:04:18.000000000 +0200
-+++ libwpd/makefile.mk	2008-04-07 14:05:05.000000000 +0200
-@@ -45,8 +45,8 @@
+--- libwpd/makefile.mk	2010-10-10 13:27:50.000000000 +0200
++++ libwpd/makefile.mk	2010-11-06 16:04:03.000000000 +0100
+@@ -41,8 +41,8 @@
      @echo "Using system libwpd..."
  .ENDIF
  
 -TARFILE_NAME=libwpd-0.8.14
 -TARFILE_MD5=64d66018897d759358f454010b6e75d2
-+TARFILE_NAME=libwpd-0.9.0~CVS20081118
-+TARFILE_MD5=32c8599f6f4cbb420e485288f74b398a
++TARFILE_NAME=libwpd-0.9.0
++TARFILE_MD5=b0b0e72cb18878461cb6530f070253cb
  BUILD_ACTION=dmake $(MFLAGS) $(CALLMACROS)
  BUILD_DIR=src$/lib
  
---- libwpd/prj/d.lst	2008-04-07 14:04:18.000000000 +0200
-+++ libwpd/prj/d.lst	2008-04-07 14:19:27.000000000 +0200
+--- libwpd/prj/d.lst	2010-10-10 13:27:50.000000000 +0200
++++ libwpd/prj/d.lst	2010-11-06 16:25:53.000000000 +0100
 @@ -1,12 +1,15 @@
  mkdir: %_DEST%\inc%_EXT%\libwpd
 +mkdir: %_DEST%\inc%_EXT%\libwpd-stream
diff --git a/patches/dev300/libwpg-testing.diff b/patches/dev300/libwpg-testing.diff
index 063485f..1327425 100644
--- a/patches/dev300/libwpg-testing.diff
+++ b/patches/dev300/libwpg-testing.diff
@@ -1,6 +1,6 @@
---- libwpg/makefile.mk	2008-04-07 14:04:33.000000000 +0200
-+++ libwpg/makefile.mk	2008-04-07 14:21:35.000000000 +0200
-@@ -54,10 +54,11 @@
+--- libwpg/makefile.mk	2010-10-10 13:27:50.000000000 +0200
++++ libwpg/makefile.mk	2010-11-06 16:22:22.000000000 +0100
+@@ -46,10 +46,11 @@
  INCPRE+=$(LIBWPD_CFLAGS)
  .ELSE
  INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwpd
@@ -9,8 +9,27 @@
  
 -TARFILE_NAME=libwpg-0.1.3
 -TARFILE_MD5=db556b750bf3eac8481a4cc5e29e5af1
-+TARFILE_NAME=libwpg-0.2.0~CVS20081118
-+TARFILE_MD5=6f0defec3c4342c0f3e1a1fe50f3f5f9
++TARFILE_NAME=libwpg-0.2.0
++TARFILE_MD5=e7df3a54ca033d744c465356d32bf6ad
  BUILD_ACTION=dmake $(MFLAGS) $(CALLMACROS)
  BUILD_DIR=src/lib
  
+--- libwpg/prj/d.lst	2010-10-10 13:27:50.000000000 +0200
++++ libwpg/prj/d.lst	2010-11-06 16:14:35.000000000 +0100
+@@ -1,16 +1,6 @@
+ mkdir: %_DEST%\inc%_EXT%\libwpg
+ ..\%__SRC%\misc\build\libwpg*\src\lib\libwpg.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGBitmap.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGBinaryData.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGBrush.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGColor.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGGradient.h %_DEST%\inc%_EXT%\libwpg\
+ ..\%__SRC%\misc\build\libwpg*\src\lib\WPGPaintInterface.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGPath.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGPen.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGPoint.h %_DEST%\inc%_EXT%\libwpg\
+ ..\%__SRC%\misc\build\libwpg*\src\lib\WPGraphics.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGRect.h %_DEST%\inc%_EXT%\libwpg\
+-..\%__SRC%\misc\build\libwpg*\src\lib\WPGString.h %_DEST%\inc%_EXT%\libwpg\
+ ..\%__SRC%\lib\*.a %_DEST%\lib%_EXT%\*.a
+ ..\%__SRC%\slb\*.lib %_DEST%\lib%_EXT%\*.lib
diff --git a/patches/dev300/libwps-testing.diff b/patches/dev300/libwps-testing.diff
index 34ad457..96efae2 100644
--- a/patches/dev300/libwps-testing.diff
+++ b/patches/dev300/libwps-testing.diff
@@ -1,6 +1,6 @@
---- libwps/makefile.mk	2008-04-07 14:04:25.000000000 +0200
-+++ libwps/makefile.mk	2008-04-07 14:18:31.000000000 +0200
-@@ -54,10 +54,11 @@
+--- libwps/makefile.mk	2010-10-10 13:27:50.000000000 +0200
++++ libwps/makefile.mk	2010-11-06 12:03:50.000000000 +0100
+@@ -46,10 +46,11 @@
  INCPRE+=$(LIBWPD_CFLAGS)
  .ELSE
  INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwpd
@@ -9,13 +9,13 @@
  
 -TARFILE_NAME=libwps-0.1.2
 -TARFILE_MD5=799fc3b835a79adce8c88a3fee0150c1
-+TARFILE_NAME=libwps-0.2.0~CVS20081118
-+TARFILE_MD5=3c77ef8cb348ab6f98ebf53961cc59ea
++TARFILE_NAME=libwps-0.2.0
++TARFILE_MD5=6e637742d12b15d44b81736276885329
  BUILD_ACTION=dmake $(MFLAGS) $(CALLMACROS)
  BUILD_DIR=src/lib
  
---- libwps/prj/d.lst	2008-04-07 14:04:25.000000000 +0200
-+++ libwps/prj/d.lst	2008-04-07 14:23:26.000000000 +0200
+--- libwps/prj/d.lst	2010-10-10 13:27:50.000000000 +0200
++++ libwps/prj/d.lst	2010-11-06 11:55:59.000000000 +0100
 @@ -1,6 +1,5 @@
  mkdir: %_DEST%\inc%_EXT%\libwps
  ..\%__SRC%\misc\build\libwps*\src\lib\libwps.h %_DEST%\inc%_EXT%\libwps\
diff --git a/patches/dev300/writerperfect-testing.diff b/patches/dev300/writerperfect-testing.diff
index 37c7146..4c5d289 100644
--- a/patches/dev300/writerperfect-testing.diff
+++ b/patches/dev300/writerperfect-testing.diff
@@ -1,46 +1,68 @@
-diff -u -r -N writerperfect/prj/build.lst writerperfect/prj/build.lst
---- writerperfect/prj/build.lst	2008-11-17 22:06:28.000000000 +0100
-+++ writerperfect/prj/build.lst	2008-11-17 23:37:06.000000000 +0100
+--- writerperfect/prj/build.lst	2010-10-10 13:15:28.000000000 +0200
++++ writerperfect/prj/build.lst	2010-11-06 13:52:55.000000000 +0100
 @@ -1,4 +1,4 @@
 -wp      writerperfect : LIBWPG:libwpg LIBWPS:libwps LIBWPD:libwpd sot comphelper xmloff svtools NULL
 +wp      writerperfect : LIBWPG:libwpg LIBWPS:libwps LIBWPD:libwpd sot comphelper xmloff svtools sfx2 NULL
  wp	writerperfect			usr1	-	all	wp_mkout NULL
  wp	writerperfect\source\stream	nmake	-	all	wp_stream NULL
  wp	writerperfect\source\filter	nmake	-	all	wp_filter NULL
-diff -u -r -N writerperfect/source/filter/DocumentCollector.cxx writerperfect/source/filter/DocumentCollector.cxx
---- writerperfect/source/filter/DocumentCollector.cxx	2008-11-17 22:06:28.000000000 +0100
-+++ writerperfect/source/filter/DocumentCollector.cxx	2008-11-17 23:30:51.000000000 +0100
-@@ -39,6 +39,8 @@
+--- writerperfect/source/filter/DocumentCollector.cxx	2010-10-17 15:38:36.000000000 +0200
++++ writerperfect/source/filter/DocumentCollector.cxx	2010-11-06 16:36:55.000000000 +0100
+@@ -1,9 +1,9 @@
+ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /* DocumentCollector: Collects sections and runs of text from a
+- * file (and styles to go along with them) and writes them
++ * wordperfect file (and styles to go along with them) and writes them
+  * to a Writer target document
+  *
+- * Copyright (C) 2002-2004 William Lachance (william.lachance at sympatico.ca)
++ * Copyright (C) 2002-2004 William Lachance (wrlach at gmail.com)
+  * Copyright (C) 2003-2004 Net Integration Technologies (http://www.net-itech.com)
+  * Copyright (C) 2004 Fridrich Strba (fridrich.strba at bluewin.ch)
+  *
+@@ -29,14 +29,13 @@
+  * Corel Corporation or Corel Corporation Limited."
+  */
+ 
+-#if defined _MSC_VER
+-#pragma warning( push, 1 )
++#ifdef HAVE_CONFIG_H
++#include <config.h>
+ #endif
++
+ #include <libwpd/libwpd.h>
+-#if defined _MSC_VER
+-#pragma warning( pop )
+-#endif
+ #include <string.h> // for strcmp
++#include <string>
  
  #include "DocumentCollector.hxx"
  #include "DocumentElement.hxx"
-+#include "DocumentHandler.hxx"
-+#include "InternalHandler.hxx"
- #include "TextRunStyle.hxx"
- #include "FontStyle.hxx"
- #include "ListStyle.hxx"
-@@ -47,6 +49,7 @@
+@@ -48,34 +47,52 @@
  #include "TableStyle.hxx"
  #include "FilterInternal.hxx"
  #include "WriterProperties.hxx"
++#ifdef USE_LIBWPG
++#include "GraphicsStyle.hxx"
 +#include "OdgExporter.hxx"
++#endif
++#include "InternalHandler.hxx"
  
  _WriterDocumentState::_WriterDocumentState() :
- 	mbFirstElement(true),
-@@ -54,27 +57,40 @@
- 	mbListElementOpenedAtCurrentLevel(false),
- 	mbTableCellOpened(false),
- 	mbHeaderRow(false),
--	mbInNote(false)
+     mbFirstElement(true),
++    mbFirstParagraphInPageSpan(true),
+     mbInFakeSection(false),
+     mbListElementOpenedAtCurrentLevel(false),
+     mbTableCellOpened(false),
+     mbHeaderRow(false),
+-    mbInNote(false)
 +    mbInNote(false),
 +    mbInTextBox(false),
 +    mbInFrame(false)
- {
- }
- 
--DocumentCollector::DocumentCollector(WPSInputStream *pInput, DocumentHandler *pHandler) :
--        mpInput(pInput),
--        mpHandler(pHandler),
++{
++}
++
 +_WriterListState::_WriterListState() :
 +    mpCurrentListStyle(NULL),
 +    miCurrentListLevel(0),
@@ -49,128 +71,130 @@ diff -u -r -N writerperfect/source/filter/DocumentCollector.cxx writerperfect/so
 +    mbListContinueNumbering(false),
 +    mbListElementParagraphOpened(false),
 +    mbListElementOpened()
-+{
-+}
-+
-+DocumentCollector::DocumentCollector(WPXInputStream *pInput, DocumentHandlerInterface *pHandler) :
-+    mpInput(pInput),
-+    mpHandler(pHandler),
- 	mbUsed(false),
+ {
+ }
+ 
+-DocumentCollector::DocumentCollector(WPSInputStream *pInput, DocumentHandler *pHandler) :
++DocumentCollector::DocumentCollector(WPXInputStream *pInput, const char * password, DocumentHandlerInterface *pHandler) :
+         mpInput(pInput),
+         mpHandler(pHandler),
+     mbUsed(false),
+-    mfSectionSpaceAfter(0.0f),
 +    mWriterDocumentStates(),
 +    mWriterListStates(),
- 	mfSectionSpaceAfter(0.0f),
- 	miNumListStyles(0),
- 	mpCurrentContentElements(&mBodyElements),
- 	mpCurrentPageSpan(NULL),
- 	miNumPageStyles(0),
--	mpCurrentListStyle(NULL),
--	miCurrentListLevel(0),
--	miLastListLevel(0),
--	miLastListNumber(0),
--	mbListContinueNumbering(false),
--	mbListElementOpened(false),
--	mbListElementParagraphOpened(false)
++    mfSectionSpaceAfter(0.0),
+     miNumListStyles(0),
+     mpCurrentContentElements(&mBodyElements),
+     mpCurrentPageSpan(NULL),
+     miNumPageStyles(0),
+-    mpCurrentListStyle(NULL),
+-    miCurrentListLevel(0),
+-    miLastListLevel(0),
+-    miLastListNumber(0),
+-    mbListContinueNumbering(false),
+-    mbListElementOpened(false),
+-    mbListElementParagraphOpened(false)
 +    miObjectNumber(0),
-+    mbIsFlatXML(true),
-+    mpPassword(NULL)
++    mpPassword(password)
  {
 +    mWriterDocumentStates.push(WriterDocumentState());
 +    mWriterListStates.push(WriterListState());
  }
  
  DocumentCollector::~DocumentCollector()
-@@ -91,18 +107,18 @@
- 	mbUsed = true;
- 
- 	// parse & write
--        // WLACH_REFACTORING: Remove these args..
-  	if (!parseSourceDocument(*mpInput))
- 		return false;
- 	if (!_writeTargetDocument(mpHandler))
- 		return false;
- 
-+
-  	// clean up the mess we made
-  	WRITER_DEBUG_MSG(("WriterWordPerfect: Cleaning up our mess..\n"));
- 
- 	WRITER_DEBUG_MSG(("Destroying the body elements\n"));
- 	for (std::vector<DocumentElement *>::iterator iterBody = mBodyElements.begin(); iterBody != mBodyElements.end(); iterBody++) {
--		delete((*iterBody));
-+        delete (*iterBody);
- 		(*iterBody) = NULL;
- 	}
- 
-@@ -115,97 +131,118 @@
- 
- 	WRITER_DEBUG_MSG(("Destroying the rest of the styles elements\n"));
- 	for (std::map<WPXString, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin(); iterTextStyle != mTextStyleHash.end(); iterTextStyle++) {
--		delete iterTextStyle->second;
-+        delete (iterTextStyle->second);
- 	}
- 	for (std::map<WPXString, SpanStyle *, ltstr>::iterator iterSpanStyle = mSpanStyleHash.begin(); iterSpanStyle != mSpanStyleHash.end(); iterSpanStyle++) {
--		delete iterSpanStyle->second;
-+        delete(iterSpanStyle->second);
- 	}
- 
- 	for (std::map<WPXString, FontStyle *, ltstr>::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); iterFont++) {
--		delete iterFont->second;
-+        delete(iterFont->second);
- 	}
- 
- 	for (std::vector<ListStyle *>::iterator iterListStyles = mListStyles.begin(); iterListStyles != mListStyles.end(); iterListStyles++) {
--		delete (*iterListStyles);
-+        delete(*iterListStyles);
- 	}
- 	for (std::vector<SectionStyle *>::iterator iterSectionStyles = mSectionStyles.begin(); iterSectionStyles != mSectionStyles.end(); iterSectionStyles++) {
--		delete (*iterSectionStyles);
-+        delete(*iterSectionStyles);
- 	}
- 	for (std::vector<TableStyle *>::iterator iterTableStyles = mTableStyles.begin(); iterTableStyles != mTableStyles.end(); iterTableStyles++) {
--		delete (*iterTableStyles);
-+        delete((*iterTableStyles));
- 	}
- 
- 	for (std::vector<PageSpan *>::iterator iterPageSpans = mPageSpans.begin(); iterPageSpans != mPageSpans.end(); iterPageSpans++) {
--		delete (*iterPageSpans);
-+        delete(*iterPageSpans);
-+    }
+@@ -93,7 +110,7 @@
+ 
+     // parse & write
+         // WLACH_REFACTORING: Remove these args..
+-     if (!parseSourceDocument(*mpInput))
++ 	if (!_parseSourceDocument(*mpInput, mpPassword))
+         return false;
+     if (!_writeTargetDocument(mpHandler))
+         return false;
+@@ -103,7 +120,7 @@
+ 
+     WRITER_DEBUG_MSG(("Destroying the body elements\n"));
+     for (std::vector<DocumentElement *>::iterator iterBody = mBodyElements.begin(); iterBody != mBodyElements.end(); iterBody++) {
+-        delete((*iterBody));
++    	delete (*iterBody);
+         (*iterBody) = NULL;
+     }
+ 
+@@ -116,14 +133,14 @@
+ 
+     WRITER_DEBUG_MSG(("Destroying the rest of the styles elements\n"));
+     for (std::map<WPXString, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin(); iterTextStyle != mTextStyleHash.end(); iterTextStyle++) {
+-        delete iterTextStyle->second;
++    	delete (iterTextStyle->second);
+     }
+     for (std::map<WPXString, SpanStyle *, ltstr>::iterator iterSpanStyle = mSpanStyleHash.begin(); iterSpanStyle != mSpanStyleHash.end(); iterSpanStyle++) {
+-        delete iterSpanStyle->second;
++    	delete(iterSpanStyle->second);
+     }
+ 
+     for (std::map<WPXString, FontStyle *, ltstr>::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); iterFont++) {
+-        delete iterFont->second;
++    	delete(iterFont->second);
+     }
+ 
+     for (std::vector<ListStyle *>::iterator iterListStyles = mListStyles.begin(); iterListStyles != mListStyles.end(); iterListStyles++) {
+@@ -133,80 +150,115 @@
+         delete (*iterSectionStyles);
+     }
+     for (std::vector<TableStyle *>::iterator iterTableStyles = mTableStyles.begin(); iterTableStyles != mTableStyles.end(); iterTableStyles++) {
+-        delete (*iterTableStyles);
++    	delete((*iterTableStyles));
+     }
+ 
+     for (std::vector<PageSpan *>::iterator iterPageSpans = mPageSpans.begin(); iterPageSpans != mPageSpans.end(); iterPageSpans++) {
+         delete (*iterPageSpans);
+     }
 +    for (std::vector<DocumentElement *>::iterator iterFrameStyles = mFrameStyles.begin(); iterFrameStyles != mFrameStyles.end(); iterFrameStyles++) {
-+        delete(*iterFrameStyles);
++    	delete(*iterFrameStyles);
 +    }
 +    for (std::vector<DocumentElement *>::iterator iterFrameAutomaticStyles = mFrameAutomaticStyles.begin();
-+        iterFrameAutomaticStyles != mFrameAutomaticStyles.end(); iterFrameAutomaticStyles++) {
-+        delete(*iterFrameAutomaticStyles);
++    	iterFrameAutomaticStyles != mFrameAutomaticStyles.end(); iterFrameAutomaticStyles++) {
++    	delete(*iterFrameAutomaticStyles);
 +    }
 +    for (std::vector<DocumentElement *>::iterator iterMetaData = mMetaData.begin(); iterMetaData != mMetaData.end(); iterMetaData++) {
-+        delete(*iterMetaData);
- 	}
++    	delete(*iterMetaData);
++    }
++
++ 	return true;
++}
++
++bool DocumentCollector::_parseSourceDocument(WPXInputStream &input, const char * password)
++{
++    WPDResult result = WPDocument::parse(&input, this, password);
++    if (result != WPD_OK)
++    	return false;
  
-  	return true;
+      return true;
  }
  
 -void DocumentCollector::_writeDefaultStyles(DocumentHandler *pHandler)
 +void DocumentCollector::_writeDefaultStyles(DocumentHandlerInterface *pHandler)
  {
--	TagOpenElement stylesOpenElement("office:styles");
--	stylesOpenElement.write(pHandler);
+-    TagOpenElement stylesOpenElement("office:styles");
+-    stylesOpenElement.write(pHandler);
 +    TagOpenElement("office:styles").write(pHandler);
  
- 	TagOpenElement defaultParagraphStyleOpenElement("style:default-style");
- 	defaultParagraphStyleOpenElement.addAttribute("style:family", "paragraph");
- 	defaultParagraphStyleOpenElement.write(pHandler);
+     TagOpenElement defaultParagraphStyleOpenElement("style:default-style");
+     defaultParagraphStyleOpenElement.addAttribute("style:family", "paragraph");
+     defaultParagraphStyleOpenElement.write(pHandler);
  
--	TagOpenElement defaultParagraphStylePropertiesOpenElement("style:properties");
--	defaultParagraphStylePropertiesOpenElement.addAttribute("style:family", "paragraph");
--	defaultParagraphStylePropertiesOpenElement.addAttribute("style:tab-stop-distance", "0.5inch");
+-    TagOpenElement defaultParagraphStylePropertiesOpenElement("style:properties");
+-    defaultParagraphStylePropertiesOpenElement.addAttribute("style:family", "paragraph");
+-    defaultParagraphStylePropertiesOpenElement.addAttribute("style:tab-stop-distance", "0.5inch");
 +    TagOpenElement defaultParagraphStylePropertiesOpenElement("style:paragraph-properties");
 +    defaultParagraphStylePropertiesOpenElement.addAttribute("style:tab-stop-distance", "0.5in");
- 	defaultParagraphStylePropertiesOpenElement.write(pHandler);
--	TagCloseElement defaultParagraphStylePropertiesCloseElement("style:properties");
+     defaultParagraphStylePropertiesOpenElement.write(pHandler);
+-    TagCloseElement defaultParagraphStylePropertiesCloseElement("style:properties");
 +    TagCloseElement defaultParagraphStylePropertiesCloseElement("style:paragraph-properties");
- 	defaultParagraphStylePropertiesCloseElement.write(pHandler);
+     defaultParagraphStylePropertiesCloseElement.write(pHandler);
  
--	TagCloseElement defaultParagraphStyleCloseElement("style:default-style");
--	defaultParagraphStyleCloseElement.write(pHandler);
+-    TagCloseElement defaultParagraphStyleCloseElement("style:default-style");
+-    defaultParagraphStyleCloseElement.write(pHandler);
 +    pHandler->endElement("style:default-style");
 +
 +    TagOpenElement defaultTableRowStyleOpenElement("style:default-style");
@@ -184,130 +208,111 @@ diff -u -r -N writerperfect/source/filter/DocumentCollector.cxx writerperfect/so
 +    pHandler->endElement("style:table-row-properties");
 +    pHandler->endElement("style:default-style");
  
- 	TagOpenElement standardStyleOpenElement("style:style");
--        standardStyleOpenElement.addAttribute("style:name", "Standard");
--        standardStyleOpenElement.addAttribute("style:family", "paragraph");
--        standardStyleOpenElement.addAttribute("style:class", "text");
--        standardStyleOpenElement.write(pHandler);
+     TagOpenElement standardStyleOpenElement("style:style");
+         standardStyleOpenElement.addAttribute("style:name", "Standard");
+         standardStyleOpenElement.addAttribute("style:family", "paragraph");
+         standardStyleOpenElement.addAttribute("style:class", "text");
+         standardStyleOpenElement.write(pHandler);
 -        TagCloseElement standardStyleCloseElement("style:style");
 -        standardStyleCloseElement.write(pHandler);
--
--        TagOpenElement textBodyStyleOpenElement("style:style");
--        textBodyStyleOpenElement.addAttribute("style:name", "Text Body");
--        textBodyStyleOpenElement.addAttribute("style:family", "paragraph");
--        textBodyStyleOpenElement.addAttribute("style:parent-style-name", "Standard");
--        textBodyStyleOpenElement.addAttribute("style:class", "text");
--        textBodyStyleOpenElement.write(pHandler);
--        TagCloseElement textBodyStyleCloseElement("style:style");
--        textBodyStyleCloseElement.write(pHandler);
--
--        TagOpenElement tableContentsStyleOpenElement("style:style");
--        tableContentsStyleOpenElement.addAttribute("style:name", "Table Contents");
--        tableContentsStyleOpenElement.addAttribute("style:family", "paragraph");
--        tableContentsStyleOpenElement.addAttribute("style:parent-style-name", "Text Body");
--        tableContentsStyleOpenElement.addAttribute("style:class", "extra");
--        tableContentsStyleOpenElement.write(pHandler);
--        TagCloseElement tableContentsStyleCloseElement("style:style");
--        tableContentsStyleCloseElement.write(pHandler);
--
--        TagOpenElement tableHeadingStyleOpenElement("style:style");
--        tableHeadingStyleOpenElement.addAttribute("style:name", "Table Heading");
--        tableHeadingStyleOpenElement.addAttribute("style:family", "paragraph");
--        tableHeadingStyleOpenElement.addAttribute("style:parent-style-name", "Table Contents");
--        tableHeadingStyleOpenElement.addAttribute("style:class", "extra");
--        tableHeadingStyleOpenElement.write(pHandler);
--        TagCloseElement tableHeadingStyleCloseElement("style:style");
--        tableHeadingStyleCloseElement.write(pHandler);
--
--	TagCloseElement stylesCloseElement("office:styles");
--	stylesCloseElement.write(pHandler);
-+    standardStyleOpenElement.addAttribute("style:name", "Standard");
-+    standardStyleOpenElement.addAttribute("style:family", "paragraph");
-+    standardStyleOpenElement.addAttribute("style:class", "text");
-+    standardStyleOpenElement.write(pHandler);
 +
 +    pHandler->endElement("style:style");
-+
-+    TagOpenElement textBodyStyleOpenElement("style:style");
+ 
+         TagOpenElement textBodyStyleOpenElement("style:style");
+-        textBodyStyleOpenElement.addAttribute("style:name", "Text Body");
 +    textBodyStyleOpenElement.addAttribute("style:name", "Text_Body");
 +    textBodyStyleOpenElement.addAttribute("style:display-name", "Text Body");
-+    textBodyStyleOpenElement.addAttribute("style:family", "paragraph");
-+    textBodyStyleOpenElement.addAttribute("style:parent-style-name", "Standard");
-+    textBodyStyleOpenElement.addAttribute("style:class", "text");
-+    textBodyStyleOpenElement.write(pHandler);
+         textBodyStyleOpenElement.addAttribute("style:family", "paragraph");
+         textBodyStyleOpenElement.addAttribute("style:parent-style-name", "Standard");
+         textBodyStyleOpenElement.addAttribute("style:class", "text");
+         textBodyStyleOpenElement.write(pHandler);
+-        TagCloseElement textBodyStyleCloseElement("style:style");
+-        textBodyStyleCloseElement.write(pHandler);
 +
 +    pHandler->endElement("style:style");
  
-+    TagOpenElement tableContentsStyleOpenElement("style:style");
+         TagOpenElement tableContentsStyleOpenElement("style:style");
+-        tableContentsStyleOpenElement.addAttribute("style:name", "Table Contents");
 +    tableContentsStyleOpenElement.addAttribute("style:name", "Table_Contents");
 +    tableContentsStyleOpenElement.addAttribute("style:display-name", "Table Contents");
-+    tableContentsStyleOpenElement.addAttribute("style:family", "paragraph");
+         tableContentsStyleOpenElement.addAttribute("style:family", "paragraph");
+-        tableContentsStyleOpenElement.addAttribute("style:parent-style-name", "Text Body");
 +    tableContentsStyleOpenElement.addAttribute("style:parent-style-name", "Text_Body");
-+    tableContentsStyleOpenElement.addAttribute("style:class", "extra");
-+    tableContentsStyleOpenElement.write(pHandler);
+         tableContentsStyleOpenElement.addAttribute("style:class", "extra");
+         tableContentsStyleOpenElement.write(pHandler);
+-        TagCloseElement tableContentsStyleCloseElement("style:style");
+-        tableContentsStyleCloseElement.write(pHandler);
 +
 +    pHandler->endElement("style:style");
-+
-+    TagOpenElement tableHeadingStyleOpenElement("style:style");
+ 
+         TagOpenElement tableHeadingStyleOpenElement("style:style");
+-        tableHeadingStyleOpenElement.addAttribute("style:name", "Table Heading");
 +    tableHeadingStyleOpenElement.addAttribute("style:name", "Table_Heading");
 +    tableHeadingStyleOpenElement.addAttribute("style:display-name", "Table Heading");
-+    tableHeadingStyleOpenElement.addAttribute("style:family", "paragraph");
+         tableHeadingStyleOpenElement.addAttribute("style:family", "paragraph");
+-        tableHeadingStyleOpenElement.addAttribute("style:parent-style-name", "Table Contents");
 +    tableHeadingStyleOpenElement.addAttribute("style:parent-style-name", "Table_Contents");
-+    tableHeadingStyleOpenElement.addAttribute("style:class", "extra");
-+    tableHeadingStyleOpenElement.write(pHandler);
-+
+         tableHeadingStyleOpenElement.addAttribute("style:class", "extra");
+         tableHeadingStyleOpenElement.write(pHandler);
+-        TagCloseElement tableHeadingStyleCloseElement("style:style");
+-        tableHeadingStyleCloseElement.write(pHandler);
+ 
+-    TagCloseElement stylesCloseElement("office:styles");
+-    stylesCloseElement.write(pHandler);
 +    pHandler->endElement("style:style");
-+
+ 
 +    for (std::vector<DocumentElement *>::const_iterator iter = mFrameStyles.begin();
-+        iter != mFrameStyles.end(); iter++)
-+        (*iter)->write(pHandler);
++    	iter != mFrameStyles.end(); iter++)
++    	(*iter)->write(pHandler);
 +
 +    pHandler->endElement("office:styles");
  }
  
 -void DocumentCollector::_writeMasterPages(DocumentHandler *pHandler)
-+void DocumentCollector::_writeMasterPages(DocumentHandlerInterface *pHandler)
++// writes everything up to the automatic styles declarations..
++void DocumentCollector::_writeBegin()
  {
 -        WPXPropertyList xBlankAttrList;
--
--	pHandler->startElement("office:master-styles", xBlankAttrList);
++}
+ 
+-    pHandler->startElement("office:master-styles", xBlankAttrList);
++void DocumentCollector::_writeMasterPages(DocumentHandlerInterface *pHandler)
++{
 +    TagOpenElement("office:master-styles").write(mpHandler);
- 	int pageNumber = 1;
- 	for (unsigned int i=0; i<mPageSpans.size(); i++)
- 	{
-@@ -217,99 +254,118 @@
- 	pHandler->endElement("office:master-styles");
+     int pageNumber = 1;
+     for (unsigned int i=0; i<mPageSpans.size(); i++)
+     {
+@@ -218,65 +270,79 @@
+     pHandler->endElement("office:master-styles");
  }
  
 -void DocumentCollector::_writePageMasters(DocumentHandler *pHandler)
 +void DocumentCollector::_writePageLayouts(DocumentHandlerInterface *pHandler)
  {
- 	for (unsigned int i=0; i<mPageSpans.size(); i++)
- 	{
--		mPageSpans[i]->writePageMaster(i, pHandler);
-+        mPageSpans[i]->writePageLayout(i, pHandler);
- 	}
+     for (unsigned int i=0; i<mPageSpans.size(); i++)
+     {
+-        mPageSpans[i]->writePageMaster(i, pHandler);
++    	mPageSpans[i]->writePageLayout(i, pHandler);
+     }
  }
  
 -bool DocumentCollector::_writeTargetDocument(DocumentHandler *pHandler)
--{        
 +bool DocumentCollector::_writeTargetDocument(DocumentHandlerInterface *pHandler)
-+{
- 	WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Printing out the header stuff..\n"));
--	WPXPropertyList xBlankAttrList;
- 
- 	WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Start Document\n"));
- 	mpHandler->startDocument();
- 
- 	WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: preamble\n"));
--        WPXPropertyList docContentPropList;
--	docContentPropList.insert("xmlns:office", "http://openoffice.org/2000/office");
--	docContentPropList.insert("xmlns:style", "http://openoffice.org/2000/style");
--	docContentPropList.insert("xmlns:text", "http://openoffice.org/2000/text");
--	docContentPropList.insert("xmlns:table", "http://openoffice.org/2000/table");
--	docContentPropList.insert("xmlns:draw", "http://openoffice.org/2000/draw");
--	docContentPropList.insert("xmlns:fo", "http://www.w3.org/1999/XSL/Format");
-+    WPXPropertyList docContentPropList;
+ {        
+     WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Printing out the header stuff..\n"));
+-    WPXPropertyList xBlankAttrList;
+ 
+     WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Start Document\n"));
+     mpHandler->startDocument();
+ 
+     WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: preamble\n"));
+         WPXPropertyList docContentPropList;
+-    docContentPropList.insert("xmlns:office", "http://openoffice.org/2000/office");
+-    docContentPropList.insert("xmlns:style", "http://openoffice.org/2000/style");
+-    docContentPropList.insert("xmlns:text", "http://openoffice.org/2000/text");
+-    docContentPropList.insert("xmlns:table", "http://openoffice.org/2000/table");
+-    docContentPropList.insert("xmlns:draw", "http://openoffice.org/2000/draw");
+-    docContentPropList.insert("xmlns:fo", "http://www.w3.org/1999/XSL/Format");
 +    docContentPropList.insert("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
 +    docContentPropList.insert("xmlns:meta", "urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
 +    docContentPropList.insert("xmlns:dc", "http://purl.org/dc/elements/1.1/");
@@ -316,202 +321,130 @@ diff -u -r -N writerperfect/source/filter/DocumentCollector.cxx writerperfect/so
 +    docContentPropList.insert("xmlns:table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0");
 +    docContentPropList.insert("xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
 +    docContentPropList.insert("xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
- 	docContentPropList.insert("xmlns:xlink", "http://www.w3.org/1999/xlink");
- 	docContentPropList.insert("xmlns:number", "http://openoffice.org/2000/datastyle");
--	docContentPropList.insert("xmlns:svg", "http://www.w3.org/2000/svg");
--	docContentPropList.insert("xmlns:chart", "http://openoffice.org/2000/chart");
--	docContentPropList.insert("xmlns:dr3d", "http://openoffice.org/2000/dr3d");
+     docContentPropList.insert("xmlns:xlink", "http://www.w3.org/1999/xlink");
+     docContentPropList.insert("xmlns:number", "http://openoffice.org/2000/datastyle");
+-    docContentPropList.insert("xmlns:svg", "http://www.w3.org/2000/svg");
+-    docContentPropList.insert("xmlns:chart", "http://openoffice.org/2000/chart");
+-    docContentPropList.insert("xmlns:dr3d", "http://openoffice.org/2000/dr3d");
 +    docContentPropList.insert("xmlns:svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
 +    docContentPropList.insert("xmlns:chart", "urn:oasis:names:tc:opendocument:xmlns:chart:1.0");
 +    docContentPropList.insert("xmlns:dr3d", "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0");
- 	docContentPropList.insert("xmlns:math", "http://www.w3.org/1998/Math/MathML");
--	docContentPropList.insert("xmlns:form", "http://openoffice.org/2000/form");
--	docContentPropList.insert("xmlns:script", "http://openoffice.org/2000/script");
--	docContentPropList.insert("office:class", "text");
+     docContentPropList.insert("xmlns:math", "http://www.w3.org/1998/Math/MathML");
+-    docContentPropList.insert("xmlns:form", "http://openoffice.org/2000/form");
+-    docContentPropList.insert("xmlns:script", "http://openoffice.org/2000/script");
+-    docContentPropList.insert("office:class", "text");
 +    docContentPropList.insert("xmlns:form", "urn:oasis:names:tc:opendocument:xmlns:form:1.0");
 +    docContentPropList.insert("xmlns:script", "urn:oasis:names:tc:opendocument:xmlns:script:1.0");
 +    docContentPropList.insert("xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
- 	docContentPropList.insert("office:version", "1.0");
+     docContentPropList.insert("office:version", "1.0");
 -        mpHandler->startElement("office:document-content", docContentPropList);
-+    if (mbIsFlatXML)
-+    {
-+        docContentPropList.insert("office:mimetype", "application/vnd.oasis.opendocument.text");
-+        mpHandler->startElement("office:document", docContentPropList);
-+    }
-+    else
-+        mpHandler->startElement("office:document-content", docContentPropList);
++    docContentPropList.insert("office:mimetype", "application/vnd.oasis.opendocument.text");
++    mpHandler->startElement("office:document", docContentPropList);
 +
 +    // write out the metadata
 +    TagOpenElement("office:meta").write(mpHandler);
 +    for (std::vector<DocumentElement *>::const_iterator iterMetaData = mMetaData.begin(); iterMetaData != mMetaData.end(); iterMetaData++) {
-+        (*iterMetaData)->write(mpHandler);
++    	(*iterMetaData)->write(mpHandler);
 +    }
 +    mpHandler->endElement("office:meta");
  
- 	// write out the font styles
--	mpHandler->startElement("office:font-decls", xBlankAttrList);
+     // write out the font styles
+-    mpHandler->startElement("office:font-decls", xBlankAttrList);
 +    TagOpenElement("office:font-face-decls").write(mpHandler);
- 	for (std::map<WPXString, FontStyle *, ltstr>::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); iterFont++) {
- 		iterFont->second->write(mpHandler);
- 	}
--	TagOpenElement symbolFontOpen("style:font-decl");
+     for (std::map<WPXString, FontStyle *, ltstr>::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); iterFont++) {
+         iterFont->second->write(mpHandler);
+     }
+-    TagOpenElement symbolFontOpen("style:font-decl");
 +    TagOpenElement symbolFontOpen("style:font-face");
- 	symbolFontOpen.addAttribute("style:name", "StarSymbol");
--	symbolFontOpen.addAttribute("fo:font-family", "StarSymbol");
+     symbolFontOpen.addAttribute("style:name", "StarSymbol");
+-    symbolFontOpen.addAttribute("fo:font-family", "StarSymbol");
 +    symbolFontOpen.addAttribute("svg:font-family", "StarSymbol");
- 	symbolFontOpen.addAttribute("style:font-charset", "x-symbol");
- 	symbolFontOpen.write(mpHandler);
+     symbolFontOpen.addAttribute("style:font-charset", "x-symbol");
+     symbolFontOpen.write(mpHandler);
 -        mpHandler->endElement("style:font-decl");
 -
--	mpHandler->endElement("office:font-decls");
+-    mpHandler->endElement("office:font-decls");
 +    mpHandler->endElement("style:font-face");
  
 +    mpHandler->endElement("office:font-face-decls");
  
-  	WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Writing out the styles..\n"));
+      WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Writing out the styles..\n"));
  
- 	// write default styles
- 	_writeDefaultStyles(mpHandler);
+     // write default styles
+     _writeDefaultStyles(mpHandler);
  
--	mpHandler->startElement("office:automatic-styles", xBlankAttrList);
+-    mpHandler->startElement("office:automatic-styles", xBlankAttrList);
 +    TagOpenElement("office:automatic-styles").write(mpHandler);
  
--	for (std::map<WPXString, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin(); 
--             iterTextStyle != mTextStyleHash.end(); iterTextStyle++) 
--        {
+-    for (std::map<WPXString, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin(); 
 +    for (std::vector<DocumentElement *>::const_iterator iterFrameAutomaticStyles = mFrameAutomaticStyles.begin();
-+        iterFrameAutomaticStyles != mFrameAutomaticStyles.end(); iterFrameAutomaticStyles++)
++    	iterFrameAutomaticStyles != mFrameAutomaticStyles.end(); iterFrameAutomaticStyles++)
 +    {
-+        (*iterFrameAutomaticStyles)->write(pHandler);
++    	(*iterFrameAutomaticStyles)->write(pHandler);
 +    }
 +
 +    for (std::map<WPXString, ParagraphStyle *, ltstr>::const_iterator iterTextStyle = mTextStyleHash.begin(); 
-+         iterTextStyle != mTextStyleHash.end(); iterTextStyle++) 
-+    {
- 		// writing out the paragraph styles
- 		if (strcmp((iterTextStyle->second)->getName().cstr(), "Standard")) 
--                {
-+        {
- 			// don't write standard paragraph "no styles" style
- 			(iterTextStyle->second)->write(pHandler);
- 		}
- 	}
- 
--        // span styles..
--	for (std::map<WPXString, SpanStyle *, ltstr>::iterator iterSpanStyle = mSpanStyleHash.begin(); 
--             iterSpanStyle != mSpanStyleHash.end(); iterSpanStyle++) 
--        {
--                (iterSpanStyle->second)->write(pHandler);
-+    // span styles..
+              iterTextStyle != mTextStyleHash.end(); iterTextStyle++) 
+         {
+         // writing out the paragraph styles
+@@ -288,29 +354,29 @@
+     }
+ 
+         // span styles..
+-    for (std::map<WPXString, SpanStyle *, ltstr>::iterator iterSpanStyle = mSpanStyleHash.begin(); 
 +    for (std::map<WPXString, SpanStyle *, ltstr>::const_iterator iterSpanStyle = mSpanStyleHash.begin(); 
-+         iterSpanStyle != mSpanStyleHash.end(); iterSpanStyle++) 
-+    {
-+        (iterSpanStyle->second)->write(pHandler);
- 	}
+              iterSpanStyle != mSpanStyleHash.end(); iterSpanStyle++) 
+         {
+                 (iterSpanStyle->second)->write(pHandler);
+     }
  
-  	// writing out the sections styles
--	for (std::vector<SectionStyle *>::iterator iterSectionStyles = mSectionStyles.begin(); iterSectionStyles != mSectionStyles.end(); iterSectionStyles++) {
+      // writing out the sections styles
+-    for (std::vector<SectionStyle *>::iterator iterSectionStyles = mSectionStyles.begin(); iterSectionStyles != mSectionStyles.end(); iterSectionStyles++) {
 +    for (std::vector<SectionStyle *>::const_iterator iterSectionStyles = mSectionStyles.begin(); iterSectionStyles != mSectionStyles.end(); iterSectionStyles++) {
- 		(*iterSectionStyles)->write(pHandler);
- 	}
+         (*iterSectionStyles)->write(pHandler);
+     }
  
- 	// writing out the lists styles
--	for (std::vector<ListStyle *>::iterator iterListStyles = mListStyles.begin(); iterListStyles != mListStyles.end(); iterListStyles++) {
+     // writing out the lists styles
+-    for (std::vector<ListStyle *>::iterator iterListStyles = mListStyles.begin(); iterListStyles != mListStyles.end(); iterListStyles++) {
 +    for (std::vector<ListStyle *>::const_iterator iterListStyles = mListStyles.begin(); iterListStyles != mListStyles.end(); iterListStyles++) {
- 		(*iterListStyles)->write(pHandler);
- 	}
+         (*iterListStyles)->write(pHandler);
+     }
  
-  	// writing out the table styles
--	for (std::vector<TableStyle *>::iterator iterTableStyles = mTableStyles.begin(); iterTableStyles != mTableStyles.end(); iterTableStyles++) {
+      // writing out the table styles
+-    for (std::vector<TableStyle *>::iterator iterTableStyles = mTableStyles.begin(); iterTableStyles != mTableStyles.end(); iterTableStyles++) {
 +    for (std::vector<TableStyle *>::const_iterator iterTableStyles = mTableStyles.begin(); iterTableStyles != mTableStyles.end(); iterTableStyles++) {
- 		(*iterTableStyles)->write(pHandler);
- 	}
+         (*iterTableStyles)->write(pHandler);
+     }
  
- 	// writing out the page masters
--	_writePageMasters(pHandler);
+     // writing out the page masters
+-    _writePageMasters(pHandler);
 +    _writePageLayouts(pHandler);
  
  
- 	pHandler->endElement("office:automatic-styles");
-@@ -318,15 +374,20 @@
+     pHandler->endElement("office:automatic-styles");
+@@ -319,15 +385,17 @@
  
-  	WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Writing out the document..\n"));
-  	// writing out the document
--	pHandler->startElement("office:body", xBlankAttrList);
+      WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Writing out the document..\n"));
+      // writing out the document
+-    pHandler->startElement("office:body", xBlankAttrList);
 +    TagOpenElement("office:body").write(mpHandler);
 +    TagOpenElement("office:text").write(mpHandler);
  
--	for (std::vector<DocumentElement *>::iterator iterBodyElements = mBodyElements.begin(); iterBodyElements != mBodyElements.end(); iterBodyElements++) {
+-    for (std::vector<DocumentElement *>::iterator iterBodyElements = mBodyElements.begin(); iterBodyElements != mBodyElements.end(); iterBodyElements++) {
 +    for (std::vector<DocumentElement *>::const_iterator iterBodyElements = mBodyElements.begin(); iterBodyElements != mBodyElements.end(); iterBodyElements++) {
- 		(*iterBodyElements)->write(pHandler);
- 	}
-  	WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Finished writing all doc els..\n"));
+         (*iterBodyElements)->write(pHandler);
+     }
+      WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Finished writing all doc els..\n"));
  
 +    pHandler->endElement("office:text");
- 	pHandler->endElement("office:body");
--	pHandler->endElement("office:document-content");
-+    if (mbIsFlatXML)
-+        pHandler->endElement("office:document");
-+    else
-+        pHandler->endElement("office:document-content");
+     pHandler->endElement("office:body");
+-    pHandler->endElement("office:document-content");
++    pHandler->endElement("office:document");
  
- 	pHandler->endDocument();
+     pHandler->endDocument();
  
-@@ -336,32 +397,32 @@
- 
- WPXString propListToStyleKey(const WPXPropertyList & xPropList)
- {
--        WPXString sKey;
--        WPXPropertyList::Iter i(xPropList);
--        for (i.rewind(); i.next(); )
--        {
--                WPXString sProp;
--                sProp.sprintf("[%s:%s]", i.key(), i()->getStr().cstr());
--                sKey.append(sProp);
--        }
-+    WPXString sKey;
-+    WPXPropertyList::Iter i(xPropList);
-+    for (i.rewind(); i.next(); )
-+    {
-+        WPXString sProp;
-+        sProp.sprintf("[%s:%s]", i.key(), i()->getStr().cstr());
-+        sKey.append(sProp);
-+    }
- 
--        return sKey;
-+    return sKey;
- }
- 
- WPXString getParagraphStyleKey(const WPXPropertyList & xPropList, const WPXPropertyListVector & xTabStops)
- {
--        WPXString sKey = propListToStyleKey(xPropList);
--        
--        WPXString sTabStops;
--        sTabStops.sprintf("[num-tab-stops:%i]", xTabStops.count());
--        WPXPropertyListVector::Iter i(xTabStops);
--        for (i.rewind(); i.next();)
--        {
--                sTabStops.append(propListToStyleKey(i()));
--        }
--        sKey.append(sTabStops);
-+    WPXString sKey = propListToStyleKey(xPropList);
-+
-+    WPXString sTabStops;
-+    sTabStops.sprintf("[num-tab-stops:%i]", xTabStops.count());
-+    WPXPropertyListVector::Iter i(xTabStops);
-+    for (i.rewind(); i.next();)
-+    {
-+        sTabStops.append(propListToStyleKey(i()));
-+    }
-+    sKey.append(sTabStops);
- 
--        return sKey;
-+    return sKey;
- }
- 
- // _allocateFontName: add a (potentially mapped) font style to the hash if it's not already there, do nothing otherwise
-@@ -374,11 +435,29 @@
- 	}
+@@ -375,11 +443,31 @@
+     }
  }
  
 +void DocumentCollector::setDocumentMetaData(const WPXPropertyList &propList)
@@ -521,580 +454,483 @@ diff -u -r -N writerperfect/source/filter/DocumentCollector.cxx writerperfect/so
 +        {
 +                // filter out libwpd elements
 +                if (strncmp(i.key(), "libwpd", 6) != 0 && strncmp(i.key(), "dcterms", 7) != 0)
-+        {
-+            mMetaData.push_back(new TagOpenElement(i.key()));
-+            WPXString sStringValue(i()->getStr(), true);
-+            mMetaData.push_back(new CharDataElement(sStringValue.cstr()));
-+            mMetaData.push_back(new TagCloseElement(i.key()));
-+        }
++    	{
++    		mMetaData.push_back(new TagOpenElement(i.key()));
++    		WPXString sStringValue(i()->getStr(), true);
++    		mMetaData.push_back(new CharDataElement(sStringValue.cstr()));
++    		mMetaData.push_back(new TagCloseElement(i.key()));
++    	}
 +        }
 +
 +}
 +
  void DocumentCollector::openPageSpan(const WPXPropertyList &propList)
  {
- 	PageSpan *pPageSpan = new PageSpan(propList);
- 	mPageSpans.push_back(pPageSpan);
- 	mpCurrentPageSpan = pPageSpan;
+     PageSpan *pPageSpan = new PageSpan(propList);
+     mPageSpans.push_back(pPageSpan);
+     mpCurrentPageSpan = pPageSpan;
 +    miNumPageStyles++;
++
++    mWriterDocumentStates.top().mbFirstParagraphInPageSpan = true;
  }
  
  void DocumentCollector::openHeader(const WPXPropertyList &propList)
-@@ -386,9 +465,9 @@
- 	std::vector<DocumentElement *> * pHeaderFooterContentElements = new std::vector<DocumentElement *>;
- 
- 	if (propList["libwpd:occurence"]->getStr() == "even")
--                mpCurrentPageSpan->setHeaderLeftContent(pHeaderFooterContentElements);
--        else
--                mpCurrentPageSpan->setHeaderContent(pHeaderFooterContentElements);
-+        mpCurrentPageSpan->setHeaderLeftContent(pHeaderFooterContentElements);
-+    else
-+        mpCurrentPageSpan->setHeaderContent(pHeaderFooterContentElements);
- 
- 	mpCurrentContentElements = pHeaderFooterContentElements;
- }
-@@ -403,9 +482,9 @@
- 	std::vector<DocumentElement *> * pHeaderFooterContentElements = new std::vector<DocumentElement *>;
- 
- 	if (propList["libwpd:occurence"]->getStr() == "even")
--                mpCurrentPageSpan->setFooterLeftContent(pHeaderFooterContentElements);
--        else
--                mpCurrentPageSpan->setFooterContent(pHeaderFooterContentElements);
-+        mpCurrentPageSpan->setFooterLeftContent(pHeaderFooterContentElements);
-+    else
-+        mpCurrentPageSpan->setFooterContent(pHeaderFooterContentElements);
- 
- 	mpCurrentContentElements = pHeaderFooterContentElements;
- }
-@@ -417,7 +496,7 @@
- 
+@@ -419,16 +507,20 @@
  void DocumentCollector::openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
  {
--        int iNumColumns = columns.count();
-+    int iNumColumns = columns.count();
- 	float fSectionMarginLeft = 0.0f;
- 	float fSectionMarginRight = 0.0f;
- 	if (propList["fo:margin-left"])
-@@ -427,38 +506,33 @@
- 
- 	if (iNumColumns > 1 || fSectionMarginLeft != 0 || fSectionMarginRight != 0)
- 	{
--		mfSectionSpaceAfter = propList["fo:margin-bottom"]->getFloat();
-+        if (propList["fo:margin-bottom"])
-+            mfSectionSpaceAfter = propList["fo:margin-bottom"]->getFloat();
-+        else if (propList["libwpd:margin-bottom"])
-+            mfSectionSpaceAfter =  propList["libwpd:margin-bottom"]->getFloat();
-+
- 		WPXString sSectionName;
- 		sSectionName.sprintf("Section%i", mSectionStyles.size());
--		
-+
- 		SectionStyle *pSectionStyle = new SectionStyle(propList, columns, sSectionName.cstr());
- 		mSectionStyles.push_back(pSectionStyle);
--		
-+
- 		TagOpenElement *pSectionOpenElement = new TagOpenElement("text:section");
- 		pSectionOpenElement->addAttribute("text:style-name", pSectionStyle->getName());
- 		pSectionOpenElement->addAttribute("text:name", pSectionStyle->getName());
--		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pSectionOpenElement));
-+        mpCurrentContentElements->push_back(pSectionOpenElement);
- 	}
- 	else
--		mWriterDocumentState.mbInFakeSection = true;
-+        mWriterDocumentStates.top().mbInFakeSection = true;
+         int iNumColumns = columns.count();
+-    float fSectionMarginLeft = 0.0f;
+-    float fSectionMarginRight = 0.0f;
++    double fSectionMarginLeft = 0.0;
++    double fSectionMarginRight = 0.0;
+     if (propList["fo:margin-left"])
+-        fSectionMarginLeft = propList["fo:margin-left"]->getFloat();
++    	fSectionMarginLeft = propList["fo:margin-left"]->getDouble();
+     if (propList["fo:margin-right"])
+-        fSectionMarginRight = propList["fo:margin-right"]->getFloat();
++    	fSectionMarginRight = propList["fo:margin-right"]->getDouble();
+ 
+     if (iNumColumns > 1 || fSectionMarginLeft != 0 || fSectionMarginRight != 0)
+     {
+-        mfSectionSpaceAfter = propList["fo:margin-bottom"]->getFloat();
++    	if (propList["fo:margin-bottom"])
++    		mfSectionSpaceAfter = propList["fo:margin-bottom"]->getDouble();
++    	else if (propList["libwpd:margin-bottom"])
++    		mfSectionSpaceAfter =  propList["libwpd:margin-bottom"]->getDouble();
++
+         WPXString sSectionName;
+         sSectionName.sprintf("Section%i", mSectionStyles.size());
+         
+@@ -438,29 +530,20 @@
+         TagOpenElement *pSectionOpenElement = new TagOpenElement("text:section");
+         pSectionOpenElement->addAttribute("text:style-name", pSectionStyle->getName());
+         pSectionOpenElement->addAttribute("text:name", pSectionStyle->getName());
+-        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pSectionOpenElement));
++    	mpCurrentContentElements->push_back(pSectionOpenElement);
+     }
+     else
+-        mWriterDocumentState.mbInFakeSection = true;
++    	mWriterDocumentStates.top().mbInFakeSection = true;
  }
  
  void DocumentCollector::closeSection()
  {
--	if (!mWriterDocumentState.mbInFakeSection)
--		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:section")));
+-    if (!mWriterDocumentState.mbInFakeSection)
+-        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:section")));
 +    if (!mWriterDocumentStates.top().mbInFakeSection)
-+        mpCurrentContentElements->push_back(new TagCloseElement("text:section"));
- 	else
--		mWriterDocumentState.mbInFakeSection = false;
-+        mWriterDocumentStates.top().mbInFakeSection = false;
- 
--	// open as many paragraphs as needed to simulate section space after
--	// WLACH_REFACTORING: disable this for now..
--	#if 0
--	for (float f=0.0f; f<mfSectionSpaceAfter; f+=1.0f) {
--		vector<WPXTabStop> dummyTabStops;
--		openParagraph(WPX_PARAGRAPH_JUSTIFICATION_LEFT, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, dummyTabStops, false, false);
--		closeParagraph();
--	}
--	#endif
- 	mfSectionSpaceAfter = 0.0f;
++    	mpCurrentContentElements->push_back(new TagCloseElement("text:section"));
+     else
+-        mWriterDocumentState.mbInFakeSection = false;
++    	mWriterDocumentStates.top().mbInFakeSection = false;
+ 
+-    // open as many paragraphs as needed to simulate section space after
+-    // WLACH_REFACTORING: disable this for now..
+-    #if 0
+-    for (float f=0.0f; f<mfSectionSpaceAfter; f+=1.0f) {
+-        vector<WPXTabStop> dummyTabStops;
+-        openParagraph(WPX_PARAGRAPH_JUSTIFICATION_LEFT, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, dummyTabStops, false, false);
+-        closeParagraph();
+-    }
+-    #endif
+-    mfSectionSpaceAfter = 0.0f;
++    mfSectionSpaceAfter = 0.0;
  }
  
-@@ -466,11 +540,11 @@
- {
- 	// FIXMENOW: What happens if we open a footnote inside a table? do we then inherit the footnote's style
- 	// from "Table Contents"
--	
-+
- 	WPXPropertyList *pPersistPropList = new WPXPropertyList(propList);
- 	ParagraphStyle *pStyle = NULL;
+ void DocumentCollector::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
+@@ -471,7 +554,7 @@
+     WPXPropertyList *pPersistPropList = new WPXPropertyList(propList);
+     ParagraphStyle *pStyle = NULL;
  
--	if (mWriterDocumentState.mbFirstElement && mpCurrentContentElements == &mBodyElements)
+-    if (mWriterDocumentState.mbFirstElement && mpCurrentContentElements == &mBodyElements)
 +    if (mWriterDocumentStates.top().mbFirstElement && mpCurrentContentElements == &mBodyElements)
- 	{
- 		// we don't have to go through the fuss of determining if the paragraph style is 
- 		// unique in this case, because if we are the first document element, then we
-@@ -482,31 +556,35 @@
- 		sName.sprintf("FS");
- 
- 		WPXString sParagraphHashKey("P|FS");
--		pPersistPropList->insert("style:master-page-name", "Page Style 1");
--                pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
-+        pPersistPropList->insert("style:master-page-name", "Page_Style_1");
-+        pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
- 		mTextStyleHash[sParagraphHashKey] = pStyle;
--		mWriterDocumentState.mbFirstElement = false;
-+        mWriterDocumentStates.top().mbFirstElement = false;
-  	}
- 	else
- 	{
--		if (mWriterDocumentState.mbTableCellOpened)
-+//		WPXString sPageStyleName;
-+//		sPageStyleName.sprintf("Page_Style_%i", miNumPageStyles);
-+//		pPersistPropList->insert("style:master-page-name", sPageStyleName);
-+        if (mWriterDocumentStates.top().mbTableCellOpened)
- 		{
--			if (mWriterDocumentState.mbHeaderRow)
--				pPersistPropList->insert("style:parent-style-name", "Table Heading");
-+            if (mWriterDocumentStates.top().mbHeaderRow)
-+                pPersistPropList->insert("style:parent-style-name", "Table_Heading");
- 			else
--				pPersistPropList->insert("style:parent-style-name", "Table Contents");
-+                pPersistPropList->insert("style:parent-style-name", "Table_Contents");
- 		}
- 		else
- 			pPersistPropList->insert("style:parent-style-name", "Standard");
- 
--                WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
-+        WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
- 
--		if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) {
-+        if (mTextStyleHash.find(sKey) == mTextStyleHash.end())
-+        {
- 			WPXString sName;
- 			sName.sprintf("S%i", mTextStyleHash.size()); 
--			
-+
- 			pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
--	
-+
- 			mTextStyleHash[sKey] = pStyle;
- 		}
- 		else
-@@ -518,56 +596,56 @@
- 	// create a document element corresponding to the paragraph, and append it to our list of document elements
- 	TagOpenElement *pParagraphOpenElement = new TagOpenElement("text:p");
- 	pParagraphOpenElement->addAttribute("text:style-name", pStyle->getName());
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pParagraphOpenElement));
+     {
+         // we don't have to go through the fuss of determining if the paragraph style is 
+         // unique in this case, because if we are the first document element, then we
+@@ -483,26 +566,36 @@
+         sName.sprintf("FS");
+ 
+         WPXString sParagraphHashKey("P|FS");
+-        pPersistPropList->insert("style:master-page-name", "Page Style 1");
++    	pPersistPropList->insert("style:master-page-name", "Page_Style_1");
+                 pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
+         mTextStyleHash[sParagraphHashKey] = pStyle;
+-        mWriterDocumentState.mbFirstElement = false;
++    	mWriterDocumentStates.top().mbFirstElement = false;
++    	mWriterDocumentStates.top().mbFirstParagraphInPageSpan = false;
+      }
+     else
+     {
+-        if (mWriterDocumentState.mbTableCellOpened)
++    	if (mWriterDocumentStates.top().mbFirstParagraphInPageSpan && mpCurrentContentElements == &mBodyElements)
++    	{
++    		WPXString sPageStyleName;
++    		sPageStyleName.sprintf("Page_Style_%i", miNumPageStyles);
++    		pPersistPropList->insert("style:master-page-name", sPageStyleName);
++    		mWriterDocumentStates.top().mbFirstParagraphInPageSpan = false;	
++    	}
++
++    	if (mWriterDocumentStates.top().mbTableCellOpened)
+         {
+-            if (mWriterDocumentState.mbHeaderRow)
+-                pPersistPropList->insert("style:parent-style-name", "Table Heading");
++    		if (mWriterDocumentStates.top().mbHeaderRow)
++    			pPersistPropList->insert("style:parent-style-name", "Table_Heading");
+             else
+-                pPersistPropList->insert("style:parent-style-name", "Table Contents");
++    			pPersistPropList->insert("style:parent-style-name", "Table_Contents");
+         }
+         else
+             pPersistPropList->insert("style:parent-style-name", "Standard");
+ 
+                 WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
+ 
+-        if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) {
++    	if (mTextStyleHash.find(sKey) == mTextStyleHash.end())
++    	{
+             WPXString sName;
+             sName.sprintf("S%i", mTextStyleHash.size()); 
+             
+@@ -519,12 +612,12 @@
+     // create a document element corresponding to the paragraph, and append it to our list of document elements
+     TagOpenElement *pParagraphOpenElement = new TagOpenElement("text:p");
+     pParagraphOpenElement->addAttribute("text:style-name", pStyle->getName());
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pParagraphOpenElement));
 +    mpCurrentContentElements->push_back(pParagraphOpenElement);
  }
  
  void DocumentCollector::closeParagraph()
  {
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:p")));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:p")));
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
  }
  
  void DocumentCollector::openSpan(const WPXPropertyList &propList)
- {
--        if (propList["style:font-name"])
--                _allocateFontName(propList["style:font-name"]->getStr());
-+    if (propList["style:font-name"])
-+        _allocateFontName(propList["style:font-name"]->getStr());
- 	WPXString sSpanHashKey = propListToStyleKey(propList);
- 	WRITER_DEBUG_MSG(("WriterWordPerfect: Span Hash Key: %s\n", sSpanHashKey.cstr()));
- 
- 	// Get the style
--        WPXString sName;
-+    WPXString sName;
- 	if (mSpanStyleHash.find(sSpanHashKey) == mSpanStyleHash.end())
--        {
-+    {
- 		// allocate a new paragraph style
- 		sName.sprintf("Span%i", mSpanStyleHash.size());
--		SpanStyle *pStyle = new SpanStyle(sName.cstr(), propList);                
-+        SpanStyle *pStyle = new SpanStyle(sName.cstr(), propList);
- 
- 		mSpanStyleHash[sSpanHashKey] = pStyle;
- 	}
- 	else 
--        {
-+    {
- 		sName.sprintf("%s", mSpanStyleHash.find(sSpanHashKey)->second->getName().cstr());
- 	}
- 
- 	// create a document element corresponding to the paragraph, and append it to our list of document elements
- 	TagOpenElement *pSpanOpenElement = new TagOpenElement("text:span");
- 	pSpanOpenElement->addAttribute("text:style-name", sName.cstr());
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pSpanOpenElement));
+@@ -552,12 +645,12 @@
+     // create a document element corresponding to the paragraph, and append it to our list of document elements
+     TagOpenElement *pSpanOpenElement = new TagOpenElement("text:span");
+     pSpanOpenElement->addAttribute("text:style-name", sName.cstr());
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pSpanOpenElement));
 +    mpCurrentContentElements->push_back(pSpanOpenElement);
  }
  
  void DocumentCollector::closeSpan()
  {
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:span")));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:span")));
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:span"));
  }
  
  void DocumentCollector::defineOrderedListLevel(const WPXPropertyList &propList)
- {
--        int id = 0;
--        if (propList["libwpd:id"])
--                id = propList["libwpd:id"]->getInt();
-+    int id = 0;
-+    if (propList["libwpd:id"])
-+        id = propList["libwpd:id"]->getInt();
- 
-  	OrderedListStyle *pOrderedListStyle = NULL;
--	if (mpCurrentListStyle && mpCurrentListStyle->getListID() == id)
--		pOrderedListStyle = static_cast<OrderedListStyle *>(mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
+@@ -567,8 +660,8 @@
+                 id = propList["libwpd:id"]->getInt();
+ 
+      OrderedListStyle *pOrderedListStyle = NULL;
+-    if (mpCurrentListStyle && mpCurrentListStyle->getListID() == id)
+-        pOrderedListStyle = static_cast<OrderedListStyle *>(mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
 +    if (mWriterListStates.top().mpCurrentListStyle && mWriterListStates.top().mpCurrentListStyle->getListID() == id)
-+        pOrderedListStyle = static_cast<OrderedListStyle *>(mWriterListStates.top().mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
- 
- 	// this rather appalling conditional makes sure we only start a new list (rather than continue an old
- 	// one) if: (1) we have no prior list OR (2) the prior list is actually definitively different
-@@ -575,168 +653,174 @@
- 	// is starting a new list at level 1 (and only level 1)
- 	if (pOrderedListStyle == NULL || pOrderedListStyle->getListID() != id  ||
- 	    (propList["libwpd:level"] && propList["libwpd:level"]->getInt()==1 && 
++    	pOrderedListStyle = static_cast<OrderedListStyle *>(mWriterListStates.top().mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
+ 
+     // this rather appalling conditional makes sure we only start a new list (rather than continue an old
+     // one) if: (1) we have no prior list OR (2) the prior list is actually definitively different
+@@ -576,27 +669,27 @@
+     // is starting a new list at level 1 (and only level 1)
+     if (pOrderedListStyle == NULL || pOrderedListStyle->getListID() != id  ||
+         (propList["libwpd:level"] && propList["libwpd:level"]->getInt()==1 && 
 -             (propList["text:start-value"] && (unsigned int)(propList["text:start-value"]->getInt()) != (miLastListNumber+1))))
-+         (propList["text:start-value"] && (unsigned)propList["text:start-value"]->getInt() != (mWriterListStates.top().miLastListNumber+1))))
- 	{
- 		WRITER_DEBUG_MSG(("Attempting to create a new ordered list style (listid: %i)\n", id));
- 		WPXString sName;
- 		sName.sprintf("OL%i", miNumListStyles);
- 		miNumListStyles++;
--		pOrderedListStyle = new OrderedListStyle(sName.cstr(), propList["libwpd:id"]->getInt());
--		mListStyles.push_back(static_cast<ListStyle *>(pOrderedListStyle));
--		mpCurrentListStyle = static_cast<ListStyle *>(pOrderedListStyle);
--		mbListContinueNumbering = false;
--		miLastListNumber = 0;
-+        pOrderedListStyle = new OrderedListStyle(sName.cstr(), id);
-+        mListStyles.push_back(pOrderedListStyle);
-+        mWriterListStates.top().mpCurrentListStyle = pOrderedListStyle;
-+        mWriterListStates.top().mbListContinueNumbering = false;
-+        mWriterListStates.top().miLastListNumber = 0;
- 	}
- 	else
--		mbListContinueNumbering = true;
-+        mWriterListStates.top().mbListContinueNumbering = true;
- 
- 	// Iterate through ALL list styles with the same WordPerfect list id and define a level if it is not already defined
- 	// This solves certain problems with lists that start and finish without reaching certain levels and then begin again
- 	// and reach those levels. See gradguide0405_PC.wpd in the regression suite
- 	for (std::vector<ListStyle *>::iterator iterOrderedListStyles = mListStyles.begin(); iterOrderedListStyles != mListStyles.end(); iterOrderedListStyles++)
- 	{
--		if ((* iterOrderedListStyles)->getListID() == propList["libwpd:id"]->getInt())
-+        if ((* iterOrderedListStyles)->getListID() == id)
- 			(* iterOrderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList);
- 	}
++         (propList["text:start-value"] && propList["text:start-value"]->getInt() != (mWriterListStates.top().miLastListNumber+1))))
+     {
+         WRITER_DEBUG_MSG(("Attempting to create a new ordered list style (listid: %i)\n", id));
+         WPXString sName;
+         sName.sprintf("OL%i", miNumListStyles);
+         miNumListStyles++;
+-        pOrderedListStyle = new OrderedListStyle(sName.cstr(), propList["libwpd:id"]->getInt());
+-        mListStyles.push_back(static_cast<ListStyle *>(pOrderedListStyle));
+-        mpCurrentListStyle = static_cast<ListStyle *>(pOrderedListStyle);
+-        mbListContinueNumbering = false;
+-        miLastListNumber = 0;
++    	pOrderedListStyle = new OrderedListStyle(sName.cstr(), id);
++    	mListStyles.push_back(pOrderedListStyle);
++    	mWriterListStates.top().mpCurrentListStyle = pOrderedListStyle;
++    	mWriterListStates.top().mbListContinueNumbering = false;
++    	mWriterListStates.top().miLastListNumber = 0;
+     }
+     else
+-        mbListContinueNumbering = true;
++    	mWriterListStates.top().mbListContinueNumbering = true;
+ 
+     // Iterate through ALL list styles with the same WordPerfect list id and define a level if it is not already defined
+     // This solves certain problems with lists that start and finish without reaching certain levels and then begin again
+     // and reach those levels. See gradguide0405_PC.wpd in the regression suite
+     for (std::vector<ListStyle *>::iterator iterOrderedListStyles = mListStyles.begin(); iterOrderedListStyles != mListStyles.end(); iterOrderedListStyles++)
+     {
+-        if ((* iterOrderedListStyles)->getListID() == propList["libwpd:id"]->getInt())
++    	if ((* iterOrderedListStyles)->getListID() == id)
+             (* iterOrderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList);
+     }
  }
+@@ -608,106 +701,114 @@
+                 id = propList["libwpd:id"]->getInt();
  
- void DocumentCollector::defineUnorderedListLevel(const WPXPropertyList &propList)
- {
--        int id = 0;
--        if (propList["libwpd:id"])
--                id = propList["libwpd:id"]->getInt();
-+    int id = 0;
-+    if (propList["libwpd:id"])
-+        id = propList["libwpd:id"]->getInt();
- 
-  	UnorderedListStyle *pUnorderedListStyle = NULL;
--	if (mpCurrentListStyle && mpCurrentListStyle->getListID() == id)
--		pUnorderedListStyle = static_cast<UnorderedListStyle *>(mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
+      UnorderedListStyle *pUnorderedListStyle = NULL;
+-    if (mpCurrentListStyle && mpCurrentListStyle->getListID() == id)
+-        pUnorderedListStyle = static_cast<UnorderedListStyle *>(mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
 +    if (mWriterListStates.top().mpCurrentListStyle && mWriterListStates.top().mpCurrentListStyle->getListID() == id)
-+        pUnorderedListStyle = static_cast<UnorderedListStyle *>(mWriterListStates.top().mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
- 
- 	if (pUnorderedListStyle == NULL) {
- 		WRITER_DEBUG_MSG(("Attempting to create a new unordered list style (listid: %i)\n", id));
- 		WPXString sName;
- 		sName.sprintf("UL%i", miNumListStyles);
-+        miNumListStyles++;
- 		pUnorderedListStyle = new UnorderedListStyle(sName.cstr(), id);
--		mListStyles.push_back(static_cast<ListStyle *>(pUnorderedListStyle));
--		mpCurrentListStyle = static_cast<ListStyle *>(pUnorderedListStyle);
-+        mListStyles.push_back(pUnorderedListStyle);
-+        mWriterListStates.top().mpCurrentListStyle = pUnorderedListStyle;
- 	}
- 
- 	// See comment in DocumentCollector::defineOrderedListLevel
- 	for (std::vector<ListStyle *>::iterator iterUnorderedListStyles = mListStyles.begin(); iterUnorderedListStyles != mListStyles.end(); iterUnorderedListStyles++)
- 	{
--		if ((* iterUnorderedListStyles)->getListID() == propList["libwpd:id"]->getInt())
-+        if ((* iterUnorderedListStyles)->getListID() == id)
- 			(* iterUnorderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList);
- 	}
++    	pUnorderedListStyle = static_cast<UnorderedListStyle *>(mWriterListStates.top().mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
+ 
+     if (pUnorderedListStyle == NULL) {
+         WRITER_DEBUG_MSG(("Attempting to create a new unordered list style (listid: %i)\n", id));
+         WPXString sName;
+         sName.sprintf("UL%i", miNumListStyles);
++    	miNumListStyles++;
+         pUnorderedListStyle = new UnorderedListStyle(sName.cstr(), id);
+-        mListStyles.push_back(static_cast<ListStyle *>(pUnorderedListStyle));
+-        mpCurrentListStyle = static_cast<ListStyle *>(pUnorderedListStyle);
++    	mListStyles.push_back(pUnorderedListStyle);
++    	mWriterListStates.top().mpCurrentListStyle = pUnorderedListStyle;
+     }
+ 
+     // See comment in DocumentCollector::defineOrderedListLevel
+     for (std::vector<ListStyle *>::iterator iterUnorderedListStyles = mListStyles.begin(); iterUnorderedListStyles != mListStyles.end(); iterUnorderedListStyles++)
+     {
+-        if ((* iterUnorderedListStyles)->getListID() == propList["libwpd:id"]->getInt())
++    	if ((* iterUnorderedListStyles)->getListID() == id)
+             (* iterUnorderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList);
+     }
  }
  
  void DocumentCollector::openOrderedListLevel(const WPXPropertyList & /* propList */)
  {
--	miCurrentListLevel++;
--	TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:ordered-list");
+-    miCurrentListLevel++;
+-    TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:ordered-list");
 +    if (mWriterListStates.top().mbListElementParagraphOpened)
 +    {
-+        mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
-+        mWriterListStates.top().mbListElementParagraphOpened = false;
++    	mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
++    	mWriterListStates.top().mbListElementParagraphOpened = false;
 +    }
 +    TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:list");
- 	_openListLevel(pListLevelOpenElement);
+     _openListLevel(pListLevelOpenElement);
  
--	if (mbListContinueNumbering) {
+-    if (mbListContinueNumbering) {
 +    if (mWriterListStates.top().mbListContinueNumbering) {
- 		pListLevelOpenElement->addAttribute("text:continue-numbering", "true");
- 	}
+         pListLevelOpenElement->addAttribute("text:continue-numbering", "true");
+     }
  
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pListLevelOpenElement));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pListLevelOpenElement));
 +    mpCurrentContentElements->push_back(pListLevelOpenElement);
  }
  
  void DocumentCollector::openUnorderedListLevel(const WPXPropertyList & /* propList */)
  {
--	miCurrentListLevel++;
--	TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:unordered-list");
+-    miCurrentListLevel++;
+-    TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:unordered-list");
 +    if (mWriterListStates.top().mbListElementParagraphOpened)
 +    {
-+        mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
-+        mWriterListStates.top().mbListElementParagraphOpened = false;
++    	mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
++    	mWriterListStates.top().mbListElementParagraphOpened = false;
 +    }
 +    TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:list");
- 	_openListLevel(pListLevelOpenElement);
+     _openListLevel(pListLevelOpenElement);
  
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pListLevelOpenElement));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pListLevelOpenElement));
 +    mpCurrentContentElements->push_back(pListLevelOpenElement);
  }
  
  void DocumentCollector::_openListLevel(TagOpenElement *pListLevelOpenElement)
  {
--  	if (!mbListElementOpened && miCurrentListLevel > 1)
--  	{
--  		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:list-item")));
--  	}
--	else if (mbListElementParagraphOpened)
+-      if (!mbListElementOpened && miCurrentListLevel > 1)
+-      {
+-          mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:list-item")));
+-      }
+-    else if (mbListElementParagraphOpened)
 +    if (!mWriterListStates.top().mbListElementOpened.empty() &&
-+        !mWriterListStates.top().mbListElementOpened.top())
- 	{
--		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:p")));
--		mbListElementParagraphOpened = false;
-+        mpCurrentContentElements->push_back(new TagOpenElement("text:list-item"));
-+        mWriterListStates.top().mbListElementOpened.top() = true;
- 	}
- 
--	if (miCurrentListLevel==1) {
--		pListLevelOpenElement->addAttribute("text:style-name", mpCurrentListStyle->getName());
++    	!mWriterListStates.top().mbListElementOpened.top())
+     {
+-        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:p")));
+-        mbListElementParagraphOpened = false;
++    	mpCurrentContentElements->push_back(new TagOpenElement("text:list-item"));
++    	mWriterListStates.top().mbListElementOpened.top() = true;
+     }
+ 
+-    if (miCurrentListLevel==1) {
+-        pListLevelOpenElement->addAttribute("text:style-name", mpCurrentListStyle->getName());
 +    mWriterListStates.top().mbListElementOpened.push(false);
 +    if (mWriterListStates.top().mbListElementOpened.size() == 1) {
-+        pListLevelOpenElement->addAttribute("text:style-name", mWriterListStates.top().mpCurrentListStyle->getName());
- 	}
++    	pListLevelOpenElement->addAttribute("text:style-name", mWriterListStates.top().mpCurrentListStyle->getName());
+     }
 -
--	mbListElementOpened = false;
+-    mbListElementOpened = false;
  }
  
  void DocumentCollector::closeOrderedListLevel()
  {
--	_closeListLevel("ordered-list");
+-    _closeListLevel("ordered-list");
 +    _closeListLevel();
  }
  
  void DocumentCollector::closeUnorderedListLevel()
  {
--	_closeListLevel("unordered-list");
+-    _closeListLevel("unordered-list");
 +    _closeListLevel();
  }
  
 -void DocumentCollector::_closeListLevel(const char *szListType)
 +void DocumentCollector::_closeListLevel()
  {
--	if (mbListElementOpened)
--		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:list-item")));
+-    if (mbListElementOpened)
+-        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:list-item")));
 -
--	miCurrentListLevel--;
+-    miCurrentListLevel--;
 +    if (mWriterListStates.top().mbListElementOpened.top())
 +    {
-+        mpCurrentContentElements->push_back(new TagCloseElement("text:list-item"));
-+        mWriterListStates.top().mbListElementOpened.top() = false;
++    	mpCurrentContentElements->push_back(new TagCloseElement("text:list-item"));
++    	mWriterListStates.top().mbListElementOpened.top() = false;
 +    }
  
--	WPXString sCloseElement;
--	sCloseElement.sprintf("text:%s", szListType);
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement(sCloseElement.cstr())));
+-    WPXString sCloseElement;
+-    sCloseElement.sprintf("text:%s", szListType);
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement(sCloseElement.cstr())));
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:list"));
  
--	if (miCurrentListLevel > 0)
--		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:list-item")));
--	mbListElementOpened = false;
+-    if (miCurrentListLevel > 0)
+-        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:list-item")));
+-    mbListElementOpened = false;
 +    if (!mWriterListStates.top().mbListElementOpened.empty())
 +    {
-+        mWriterListStates.top().mbListElementOpened.pop();
++    	mWriterListStates.top().mbListElementOpened.pop();
 +    }
  }
  
  void DocumentCollector::openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
  {
--	miLastListLevel = miCurrentListLevel;
--	if (miCurrentListLevel == 1)
--		miLastListNumber++;
+-    miLastListLevel = miCurrentListLevel;
+-    if (miCurrentListLevel == 1)
+-        miLastListNumber++;
 +    mWriterListStates.top().miLastListLevel = mWriterListStates.top().miCurrentListLevel;
 +    if (mWriterListStates.top().miCurrentListLevel == 1)
-+        mWriterListStates.top().miLastListNumber++;
++    	mWriterListStates.top().miLastListNumber++;
  
--	if (mbListElementOpened)
--		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:list-item")));
+-    if (mbListElementOpened)
+-        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:list-item")));
 +    if (mWriterListStates.top().mbListElementOpened.top())
 +    {
-+        mpCurrentContentElements->push_back(new TagCloseElement("text:list-item"));
-+        mWriterListStates.top().mbListElementOpened.top() = false;
++    	mpCurrentContentElements->push_back(new TagCloseElement("text:list-item"));
++    	mWriterListStates.top().mbListElementOpened.top() = false;
 +    }
  
- 	ParagraphStyle *pStyle = NULL;
+     ParagraphStyle *pStyle = NULL;
  
- 	WPXPropertyList *pPersistPropList = new WPXPropertyList(propList);
--	pPersistPropList->insert("style:list-style-name", mpCurrentListStyle->getName());
+     WPXPropertyList *pPersistPropList = new WPXPropertyList(propList);
+-    pPersistPropList->insert("style:list-style-name", mpCurrentListStyle->getName());
 +    pPersistPropList->insert("style:list-style-name", mWriterListStates.top().mpCurrentListStyle->getName());
- 	pPersistPropList->insert("style:parent-style-name", "Standard");
- 
--        WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
-+    WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
+     pPersistPropList->insert("style:parent-style-name", "Standard");
  
--        if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) 
--        {
--                WPXString sName;
--                sName.sprintf("S%i", mTextStyleHash.size()); 
--		
--                pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
--                
--                mTextStyleHash[sKey] = pStyle;
--        }
--        else
--        {
--                pStyle = mTextStyleHash[sKey];
--                delete pPersistPropList;
--        }
-+    if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) 
-+    {
-+        WPXString sName;
-+        sName.sprintf("S%i", mTextStyleHash.size()); 
+         WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
+@@ -727,17 +828,18 @@
+                 delete pPersistPropList;
+         }
  
--	TagOpenElement *pOpenListElement = new TagOpenElement("text:list-item");
--	TagOpenElement *pOpenListElementParagraph = new TagOpenElement("text:p");
-+        pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
-+
-+        mTextStyleHash[sKey] = pStyle;
-+    }
-+    else
-+    {
-+        pStyle = mTextStyleHash[sKey];
-+        delete pPersistPropList;
-+    }
-+
+-    TagOpenElement *pOpenListElement = new TagOpenElement("text:list-item");
+-    TagOpenElement *pOpenListElementParagraph = new TagOpenElement("text:p");
 +    mpCurrentContentElements->push_back(new TagOpenElement("text:list-item"));
  
 +    TagOpenElement *pOpenListElementParagraph = new TagOpenElement("text:p");
- 	pOpenListElementParagraph->addAttribute("text:style-name", pStyle->getName());
+     pOpenListElementParagraph->addAttribute("text:style-name", pStyle->getName());
 +    mpCurrentContentElements->push_back(pOpenListElementParagraph);
  
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenListElement));
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenListElementParagraph));
--		
--	mbListElementOpened = true;
--	mbListElementParagraphOpened = true;
--	mbListContinueNumbering = false;
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenListElement));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenListElementParagraph));
++    if (mpCurrentContentElements == &mBodyElements)
++    	mWriterDocumentStates.top().mbFirstParagraphInPageSpan = false;
+         
+-    mbListElementOpened = true;
+-    mbListElementParagraphOpened = true;
+-    mbListContinueNumbering = false;
 +    mWriterListStates.top().mbListElementOpened.top() = true;
 +    mWriterListStates.top().mbListElementParagraphOpened = true;
 +    mWriterListStates.top().mbListContinueNumbering = false;
  }
  
  void DocumentCollector::closeListElement()
-@@ -745,183 +829,234 @@
- 	// could contain another list level in OOo's implementation of lists). that is done in the closeListLevel
- 	// code (or when we open another list element)
+@@ -746,69 +848,100 @@
+     // could contain another list level in OOo's implementation of lists). that is done in the closeListLevel
+     // code (or when we open another list element)
  
--	if (mbListElementParagraphOpened)
+-    if (mbListElementParagraphOpened)
 +    if (mWriterListStates.top().mbListElementParagraphOpened)
- 	{
--		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:p")));
--		mbListElementParagraphOpened = false;
-+        mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
-+        mWriterListStates.top().mbListElementParagraphOpened = false;
- 	}
+     {
+-        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:p")));
+-        mbListElementParagraphOpened = false;
++    	mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
++    	mWriterListStates.top().mbListElementParagraphOpened = false;
+     }
  }
  
  void DocumentCollector::openFootnote(const WPXPropertyList &propList)
  {
--	TagOpenElement *pOpenFootNote = new TagOpenElement("text:footnote");
+-    TagOpenElement *pOpenFootNote = new TagOpenElement("text:footnote");
 +    mWriterListStates.push(WriterListState());
 +    TagOpenElement *pOpenFootNote = new TagOpenElement("text:note");
 +    pOpenFootNote->addAttribute("text:note-class", "footnote");
- 	if (propList["libwpd:number"])
- 	{
- 		WPXString tmpString("ftn");
- 		tmpString.append(propList["libwpd:number"]->getStr());
- 		pOpenFootNote->addAttribute("text:id", tmpString);
- 	}
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenFootNote));
+     if (propList["libwpd:number"])
+     {
+         WPXString tmpString("ftn");
+         tmpString.append(propList["libwpd:number"]->getStr());
+         pOpenFootNote->addAttribute("text:id", tmpString);
+     }
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenFootNote));
 +    mpCurrentContentElements->push_back(pOpenFootNote);
-+
+ 
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:footnote-citation")));
 +    mpCurrentContentElements->push_back(new TagOpenElement("text:note-citation"));
-+    if (propList["libwpd:number"])
-+        mpCurrentContentElements->push_back(new CharDataElement(propList["libwpd:number"]->getStr().cstr()));
+         if (propList["libwpd:number"])
+-                mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new CharDataElement(propList["libwpd:number"]->getStr().cstr())));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:footnote-citation")));
++    	mpCurrentContentElements->push_back(new CharDataElement(propList["libwpd:number"]->getStr().cstr()));
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:note-citation"));
-+
-+    mpCurrentContentElements->push_back(new TagOpenElement("text:note-body"));
  
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:footnote-citation")));
--        if (propList["libwpd:number"])
--                mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new CharDataElement(propList["libwpd:number"]->getStr().cstr())));
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:footnote-citation")));
--
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:footnote-body")));
--	
--	mWriterDocumentState.mbInNote = true;
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:footnote-body")));
++    mpCurrentContentElements->push_back(new TagOpenElement("text:note-body"));
+     
+-    mWriterDocumentState.mbInNote = true;
 +    mWriterDocumentStates.top().mbInNote = true;
  }
  
  void DocumentCollector::closeFootnote()
  {
--	mWriterDocumentState.mbInNote = false;
+-    mWriterDocumentState.mbInNote = false;
 +    mWriterDocumentStates.top().mbInNote = false;
 +    if (mWriterListStates.size() > 1)
-+        mWriterListStates.pop();
++    	mWriterListStates.pop();
  
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:footnote-body")));
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:footnote")));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:footnote-body")));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:footnote")));
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:note-body"));
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:note"));
  }
  
  void DocumentCollector::openEndnote(const WPXPropertyList &propList)
  {
--	TagOpenElement *pOpenEndNote = new TagOpenElement("text:endnote");
+-    TagOpenElement *pOpenEndNote = new TagOpenElement("text:endnote");
 +    mWriterListStates.push(WriterListState());
 +    TagOpenElement *pOpenEndNote = new TagOpenElement("text:note");
 +    pOpenEndNote->addAttribute("text:note-class", "endnote");
- 	if (propList["libwpd:number"])
- 	{
- 		WPXString tmpString("edn");
- 		tmpString.append(propList["libwpd:number"]->getStr());
- 		pOpenEndNote->addAttribute("text:id", tmpString);
- 	}
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenEndNote));
+     if (propList["libwpd:number"])
+     {
+         WPXString tmpString("edn");
+         tmpString.append(propList["libwpd:number"]->getStr());
+         pOpenEndNote->addAttribute("text:id", tmpString);
+     }
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenEndNote));
 +    mpCurrentContentElements->push_back(pOpenEndNote);
  
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:endnote-citation")));
--        if (propList["libwpd:number"])
--                mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new CharDataElement(propList["libwpd:number"]->getStr().cstr())));
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:endnote-citation")));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:endnote-citation")));
 +    mpCurrentContentElements->push_back(new TagOpenElement("text:note-citation"));
-+    if (propList["libwpd:number"])
-+        mpCurrentContentElements->push_back(new CharDataElement(propList["libwpd:number"]->getStr().cstr()));
+         if (propList["libwpd:number"])
+-                mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new CharDataElement(propList["libwpd:number"]->getStr().cstr())));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:endnote-citation")));
++    	mpCurrentContentElements->push_back(new CharDataElement(propList["libwpd:number"]->getStr().cstr()));
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:note-citation"));
  
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:endnote-body")));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:endnote-body")));
 +    mpCurrentContentElements->push_back(new TagOpenElement("text:note-body"));
  
 +    mWriterDocumentStates.top().mbInNote = true;
@@ -1102,28 +938,21 @@ diff -u -r -N writerperfect/source/filter/DocumentCollector.cxx writerperfect/so
 +
  void DocumentCollector::closeEndnote()
  {
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:endnote-body")));
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:endnote")));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:endnote-body")));
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:endnote")));
 +    mWriterDocumentStates.top().mbInNote = false;
 +    if (mWriterListStates.size() > 1)
-+        mWriterListStates.pop();
++    	mWriterListStates.pop();
 +
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:note-body"));
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:note"));
- }
- 
--void DocumentCollector::openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
-+void DocumentCollector::openComment(const WPXPropertyList & /* propList */)
- {
--	WPXString sTableName;
--	sTableName.sprintf("Table%i", mTableStyles.size());
++}
++
++void DocumentCollector::openComment(const WPXPropertyList & /*propList*/)
++{
 +    mWriterListStates.push(WriterListState());
 +    mpCurrentContentElements->push_back(new TagOpenElement("office:annotation"));
- 
--	// FIXME: we base the table style off of the page's margin left, ignoring (potential) wordperfect margin
--	// state which is transmitted inside the page. could this lead to unacceptable behaviour?
--        // WLACH_REFACTORING: characterize this behaviour, probably should nip it at the bud within libwpd
--	TableStyle *pTableStyle = new TableStyle(propList, columns, sTableName.cstr());
++
 +    mWriterDocumentStates.top().mbInNote = true;
 +}
 +
@@ -1131,218 +960,183 @@ diff -u -r -N writerperfect/source/filter/DocumentCollector.cxx writerperfect/so
 +{
 +    mWriterDocumentStates.top().mbInNote = false;
 +    if (mWriterListStates.size() > 1)
-+        mWriterListStates.pop();
- 
--	if (mWriterDocumentState.mbFirstElement && mpCurrentContentElements == &mBodyElements)
-+    mpCurrentContentElements->push_back(new TagCloseElement("office:annotation"));
-+}
++    	mWriterListStates.pop();
 +
-+void DocumentCollector::openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
-+{
-+    if (!mWriterDocumentStates.top().mbInNote)
- 	{
--		WPXString sMasterPageName("Page Style 1");
--		pTableStyle->setMasterPageName(sMasterPageName);
--		mWriterDocumentState.mbFirstElement = false;
--	}
-+        WPXString sTableName;
-+        sTableName.sprintf("Table%i", mTableStyles.size());
- 
--	mTableStyles.push_back(pTableStyle);
-+        // FIXME: we base the table style off of the page's margin left, ignoring (potential) wordperfect margin
-+        // state which is transmitted inside the page. could this lead to unacceptable behaviour?
-+        // WLACH_REFACTORING: characterize this behaviour, probably should nip it at the bud within libwpd
-+        TableStyle *pTableStyle = new TableStyle(propList, columns, sTableName.cstr());
- 
--	mpCurrentTableStyle = pTableStyle;
-+        if (mWriterDocumentStates.top().mbFirstElement && mpCurrentContentElements == &mBodyElements)
-+        {
-+            WPXString sMasterPageName("Page_Style_1");
-+            pTableStyle->setMasterPageName(sMasterPageName);
-+            mWriterDocumentStates.top().mbFirstElement = false;
-+        }
- 
--	TagOpenElement *pTableOpenElement = new TagOpenElement("table:table");
-+        mTableStyles.push_back(pTableStyle);
- 
--	pTableOpenElement->addAttribute("table:name", sTableName.cstr());
--	pTableOpenElement->addAttribute("table:style-name", sTableName.cstr());
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pTableOpenElement));
-+        mpCurrentTableStyle = pTableStyle;
++    mpCurrentContentElements->push_back(new TagCloseElement("office:annotation"));
+ }
  
--	for (int i=0; i<pTableStyle->getNumColumns(); i++) 
--        {
--		TagOpenElement *pTableColumnOpenElement = new TagOpenElement("table:table-column");
--		WPXString sColumnStyleName;
--		sColumnStyleName.sprintf("%s.Column%i", sTableName.cstr(), (i+1));
--		pTableColumnOpenElement->addAttribute("table:style-name", sColumnStyleName.cstr());
--		mpCurrentContentElements->push_back(pTableColumnOpenElement);
-+        TagOpenElement *pTableOpenElement = new TagOpenElement("table:table");
- 
--		TagCloseElement *pTableColumnCloseElement = new TagCloseElement("table:table-column");
--		mpCurrentContentElements->push_back(pTableColumnCloseElement);
-+        pTableOpenElement->addAttribute("table:name", sTableName.cstr());
-+        pTableOpenElement->addAttribute("table:style-name", sTableName.cstr());
-+        mpCurrentContentElements->push_back(pTableOpenElement);
-+
-+        for (int i=0; i<pTableStyle->getNumColumns(); i++) 
-+        {
-+            TagOpenElement *pTableColumnOpenElement = new TagOpenElement("table:table-column");
-+            WPXString sColumnStyleName;
-+            sColumnStyleName.sprintf("%s.Column%i", sTableName.cstr(), (i+1));
-+            pTableColumnOpenElement->addAttribute("table:style-name", sColumnStyleName.cstr());
-+            mpCurrentContentElements->push_back(pTableColumnOpenElement);
-+
-+            TagCloseElement *pTableColumnCloseElement = new TagCloseElement("table:table-column");
-+            mpCurrentContentElements->push_back(pTableColumnCloseElement);
-+        }
- 	}
+ void DocumentCollector::openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
+ {
++    if (!mWriterDocumentStates.top().mbInNote)
++    {
+     WPXString sTableName;
+     sTableName.sprintf("Table%i", mTableStyles.size());
+ 
+@@ -817,11 +950,11 @@
+         // WLACH_REFACTORING: characterize this behaviour, probably should nip it at the bud within libwpd
+     TableStyle *pTableStyle = new TableStyle(propList, columns, sTableName.cstr());
+ 
+-    if (mWriterDocumentState.mbFirstElement && mpCurrentContentElements == &mBodyElements)
++    	if (mWriterDocumentStates.top().mbFirstElement && mpCurrentContentElements == &mBodyElements)
+     {
+-        WPXString sMasterPageName("Page Style 1");
++    		WPXString sMasterPageName("Page_Style_1");
+         pTableStyle->setMasterPageName(sMasterPageName);
+-        mWriterDocumentState.mbFirstElement = false;
++    		mWriterDocumentStates.top().mbFirstElement = false;
+     }
+ 
+     mTableStyles.push_back(pTableStyle);
+@@ -832,7 +965,7 @@
+ 
+     pTableOpenElement->addAttribute("table:name", sTableName.cstr());
+     pTableOpenElement->addAttribute("table:style-name", sTableName.cstr());
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pTableOpenElement));
++    	mpCurrentContentElements->push_back(pTableOpenElement);
+ 
+     for (int i=0; i<pTableStyle->getNumColumns(); i++) 
+         {
+@@ -846,13 +979,16 @@
+         mpCurrentContentElements->push_back(pTableColumnCloseElement);
+     }
  }
++}
  
  void DocumentCollector::openTableRow(const WPXPropertyList &propList)
  {
--	if (propList["libwpd:is-header-row"] && (propList["libwpd:is-header-row"]->getInt()))
 +    if (!mWriterDocumentStates.top().mbInNote)
- 	{
--		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("table:table-header-rows")));
--		mWriterDocumentState.mbHeaderRow = true;
--	}
-+        if (propList["libwpd:is-header-row"] && (propList["libwpd:is-header-row"]->getInt()))
-+        {
-+            mpCurrentContentElements->push_back(new TagOpenElement("table:table-header-rows"));
-+            mWriterDocumentStates.top().mbHeaderRow = true;
-+        }
- 
--	WPXString sTableRowStyleName;
--	sTableRowStyleName.sprintf("%s.Row%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableRowStyles());
--	TableRowStyle *pTableRowStyle = new TableRowStyle(propList, sTableRowStyleName.cstr());
--	mpCurrentTableStyle->addTableRowStyle(pTableRowStyle);
--	
--	TagOpenElement *pTableRowOpenElement = new TagOpenElement("table:table-row");
--	pTableRowOpenElement->addAttribute("table:style-name", sTableRowStyleName);
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pTableRowOpenElement));
-+        WPXString sTableRowStyleName;
-+        sTableRowStyleName.sprintf("%s.Row%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableRowStyles());
-+        TableRowStyle *pTableRowStyle = new TableRowStyle(propList, sTableRowStyleName.cstr());
-+        mpCurrentTableStyle->addTableRowStyle(pTableRowStyle);
-+
-+        TagOpenElement *pTableRowOpenElement = new TagOpenElement("table:table-row");
-+        pTableRowOpenElement->addAttribute("table:style-name", sTableRowStyleName);
-+        mpCurrentContentElements->push_back(pTableRowOpenElement);
++    {
+     if (propList["libwpd:is-header-row"] && (propList["libwpd:is-header-row"]->getInt()))
+     {
+-        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("table:table-header-rows")));
+-        mWriterDocumentState.mbHeaderRow = true;
++    		mpCurrentContentElements->push_back(new TagOpenElement("table:table-header-rows"));
++    		mWriterDocumentStates.top().mbHeaderRow = true;
+     }
+ 
+     WPXString sTableRowStyleName;
+@@ -862,21 +998,27 @@
+     
+     TagOpenElement *pTableRowOpenElement = new TagOpenElement("table:table-row");
+     pTableRowOpenElement->addAttribute("table:style-name", sTableRowStyleName);
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pTableRowOpenElement));
++    	mpCurrentContentElements->push_back(pTableRowOpenElement);
 +    }
  }
  
  void DocumentCollector::closeTableRow()
  {
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("table:table-row")));
--	if (mWriterDocumentState.mbHeaderRow)
+-    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("table:table-row")));
+-    if (mWriterDocumentState.mbHeaderRow)
 +    if (!mWriterDocumentStates.top().mbInNote)
- 	{
--		mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("table:table-header-rows")));
--		mWriterDocumentState.mbHeaderRow = false;
-+        mpCurrentContentElements->push_back(new TagCloseElement("table:table-row"));
-+        if (mWriterDocumentStates.top().mbHeaderRow)
-+        {
-+            mpCurrentContentElements->push_back(new TagCloseElement("table:table-header-rows"));
-+            mWriterDocumentStates.top().mbHeaderRow = false;
-+        }
- 	}
++    {
++    	mpCurrentContentElements->push_back(new TagCloseElement("table:table-row"));
++    	if (mWriterDocumentStates.top().mbHeaderRow)
+     {
+-        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("table:table-header-rows")));
+-        mWriterDocumentState.mbHeaderRow = false;
++    		mpCurrentContentElements->push_back(new TagCloseElement("table:table-header-rows"));
++    		mWriterDocumentStates.top().mbHeaderRow = false;
++    	}
+     }
  }
  
  void DocumentCollector::openTableCell(const WPXPropertyList &propList)
  {
--	WPXString sTableCellStyleName;
--	sTableCellStyleName.sprintf( "%s.Cell%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableCellStyles());
--	TableCellStyle *pTableCellStyle = new TableCellStyle(propList, sTableCellStyleName.cstr());
--	mpCurrentTableStyle->addTableCellStyle(pTableCellStyle);
--
--	TagOpenElement *pTableCellOpenElement = new TagOpenElement("table:table-cell");
--	pTableCellOpenElement->addAttribute("table:style-name", sTableCellStyleName);
--	if (propList["table:number-columns-spanned"])
--                pTableCellOpenElement->addAttribute("table:number-columns-spanned", 
--                                                    propList["table:number-columns-spanned"]->getStr().cstr());
--        if (propList["table:number-rows-spanned"])
--                pTableCellOpenElement->addAttribute("table:number-rows-spanned",
--                                                    propList["table:number-rows-spanned"]->getStr().cstr());
--	pTableCellOpenElement->addAttribute("table:value-type", "string");
--	mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pTableCellOpenElement));
 +    if (!mWriterDocumentStates.top().mbInNote)
 +    {
-+        WPXString sTableCellStyleName;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list