[Libreoffice-commits] .: patches/dev300

Fridrich Strba fridrich at kemper.freedesktop.org
Sat Nov 6 19:39:39 PDT 2010


 patches/dev300/writerperfect-testing.diff | 1412 ++++++++++++++++--------------
 1 file changed, 766 insertions(+), 646 deletions(-)

New commits:
commit fbe0ca83ab7760529718259264fb4724981156a7
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Sun Nov 7 03:39:14 2010 +0100

    Fix the writerperfect module

diff --git a/patches/dev300/writerperfect-testing.diff b/patches/dev300/writerperfect-testing.diff
index 4c5d289..0710a30 100644
--- a/patches/dev300/writerperfect-testing.diff
+++ b/patches/dev300/writerperfect-testing.diff
@@ -7,47 +7,21 @@
  wp	writerperfect\source\stream	nmake	-	all	wp_stream NULL
  wp	writerperfect\source\filter	nmake	-	all	wp_filter NULL
 --- 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>
++++ writerperfect/source/filter/DocumentCollector.cxx	2010-11-06 23:13:35.000000000 +0100
+@@ -40,6 +40,8 @@
  
  #include "DocumentCollector.hxx"
  #include "DocumentElement.hxx"
-@@ -48,34 +47,52 @@
++#include "DocumentHandler.hxx"
++#include "InternalHandler.hxx"
+ #include "TextRunStyle.hxx"
+ #include "FontStyle.hxx"
+ #include "ListStyle.hxx"
+@@ -48,34 +50,49 @@
  #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),
@@ -60,9 +34,10 @@
 +    mbInNote(false),
 +    mbInTextBox(false),
 +    mbInFrame(false)
-+{
-+}
-+
+ {
+ }
+ 
+-DocumentCollector::DocumentCollector(WPSInputStream *pInput, DocumentHandler *pHandler) :
 +_WriterListState::_WriterListState() :
 +    mpCurrentListStyle(NULL),
 +    miCurrentListLevel(0),
@@ -71,18 +46,16 @@
 +    mbListContinueNumbering(false),
 +    mbListElementParagraphOpened(false),
 +    mbListElementOpened()
- {
- }
- 
--DocumentCollector::DocumentCollector(WPSInputStream *pInput, DocumentHandler *pHandler) :
-+DocumentCollector::DocumentCollector(WPXInputStream *pInput, const char * password, DocumentHandlerInterface *pHandler) :
++{
++}
++
++DocumentCollector::DocumentCollector(WPXInputStream *pInput, DocumentHandlerInterface *pHandler) :
          mpInput(pInput),
          mpHandler(pHandler),
      mbUsed(false),
--    mfSectionSpaceAfter(0.0f),
 +    mWriterDocumentStates(),
 +    mWriterListStates(),
-+    mfSectionSpaceAfter(0.0),
+     mfSectionSpaceAfter(0.0f),
      miNumListStyles(0),
      mpCurrentContentElements(&mBodyElements),
      mpCurrentPageSpan(NULL),
@@ -95,28 +68,20 @@
 -    mbListElementOpened(false),
 -    mbListElementParagraphOpened(false)
 +    miObjectNumber(0),
-+    mpPassword(password)
++    mbIsFlatXML(true),
++    mpPassword(NULL)
  {
 +    mWriterDocumentStates.push(WriterDocumentState());
 +    mWriterListStates.push(WriterListState());
  }
  
  DocumentCollector::~DocumentCollector()
-@@ -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);
++        delete (*iterBody);
          (*iterBody) = NULL;
      }
  
@@ -125,49 +90,40 @@
      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);
++        delete (iterTextStyle->second);
      }
      for (std::map<WPXString, SpanStyle *, ltstr>::iterator iterSpanStyle = mSpanStyleHash.begin(); iterSpanStyle != mSpanStyleHash.end(); iterSpanStyle++) {
 -        delete iterSpanStyle->second;
-+    	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);
++        delete(iterFont->second);
      }
  
      for (std::vector<ListStyle *>::iterator iterListStyles = mListStyles.begin(); iterListStyles != mListStyles.end(); iterListStyles++) {
-@@ -133,80 +150,115 @@
+@@ -133,80 +150,101 @@
          delete (*iterSectionStyles);
      }
      for (std::vector<TableStyle *>::iterator iterTableStyles = mTableStyles.begin(); iterTableStyles != mTableStyles.end(); iterTableStyles++) {
 -        delete (*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;
  }
@@ -262,27 +218,23 @@
 +    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)
-+// writes everything up to the automatic styles declarations..
-+void DocumentCollector::_writeBegin()
++void DocumentCollector::_writeMasterPages(DocumentHandlerInterface *pHandler)
  {
 -        WPXPropertyList 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++)
      {
-@@ -218,65 +270,79 @@
+@@ -218,65 +256,79 @@
      pHandler->endElement("office:master-styles");
  }
  
@@ -292,7 +244,7 @@
      for (unsigned int i=0; i<mPageSpans.size(); i++)
      {
 -        mPageSpans[i]->writePageMaster(i, pHandler);
-+    	mPageSpans[i]->writePageLayout(i, pHandler);
++        mPageSpans[i]->writePageLayout(i, pHandler);
      }
  }
  
@@ -344,7 +296,7 @@
 +    // 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");
  
@@ -375,19 +327,19 @@
  
 -    mpHandler->startElement("office:automatic-styles", xBlankAttrList);
 +    TagOpenElement("office:automatic-styles").write(mpHandler);
- 
--    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>::iterator iterTextStyle = mTextStyleHash.begin(); 
 +    for (std::map<WPXString, ParagraphStyle *, ltstr>::const_iterator iterTextStyle = mTextStyleHash.begin(); 
               iterTextStyle != mTextStyleHash.end(); iterTextStyle++) 
          {
          // writing out the paragraph styles
-@@ -288,29 +354,29 @@
+@@ -288,29 +340,29 @@
      }
  
          // span styles..
@@ -422,7 +374,7 @@
  
  
      pHandler->endElement("office:automatic-styles");
-@@ -319,15 +385,17 @@
+@@ -319,15 +371,17 @@
  
       WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Writing out the document..\n"));
       // writing out the document
@@ -443,7 +395,7 @@
  
      pHandler->endDocument();
  
-@@ -375,11 +443,31 @@
+@@ -375,11 +429,31 @@
      }
  }
  
@@ -454,12 +406,12 @@
 +        {
 +                // 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()));
++        }
 +        }
 +
 +}
@@ -475,7 +427,7 @@
  }
  
  void DocumentCollector::openHeader(const WPXPropertyList &propList)
-@@ -419,16 +507,20 @@
+@@ -419,16 +493,20 @@
  void DocumentCollector::openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
  {
          int iNumColumns = columns.count();
@@ -485,32 +437,32 @@
 +    double fSectionMarginRight = 0.0;
      if (propList["fo:margin-left"])
 -        fSectionMarginLeft = propList["fo:margin-left"]->getFloat();
-+    	fSectionMarginLeft = propList["fo:margin-left"]->getDouble();
++        fSectionMarginLeft = propList["fo:margin-left"]->getDouble();
      if (propList["fo:margin-right"])
 -        fSectionMarginRight = propList["fo:margin-right"]->getFloat();
-+    	fSectionMarginRight = propList["fo:margin-right"]->getDouble();
++        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();
++        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 @@
+@@ -438,29 +516,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);
++        mpCurrentContentElements->push_back(pSectionOpenElement);
      }
      else
 -        mWriterDocumentState.mbInFakeSection = true;
-+    	mWriterDocumentStates.top().mbInFakeSection = true;
++        mWriterDocumentStates.top().mbInFakeSection = true;
  }
  
  void DocumentCollector::closeSection()
@@ -518,10 +470,10 @@
 -    if (!mWriterDocumentState.mbInFakeSection)
 -        mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:section")));
 +    if (!mWriterDocumentStates.top().mbInFakeSection)
-+    	mpCurrentContentElements->push_back(new TagCloseElement("text:section"));
++        mpCurrentContentElements->push_back(new TagCloseElement("text:section"));
      else
 -        mWriterDocumentState.mbInFakeSection = false;
-+    	mWriterDocumentStates.top().mbInFakeSection = false;
++        mWriterDocumentStates.top().mbInFakeSection = false;
  
 -    // open as many paragraphs as needed to simulate section space after
 -    // WLACH_REFACTORING: disable this for now..
@@ -537,7 +489,7 @@
  }
  
  void DocumentCollector::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
-@@ -471,7 +554,7 @@
+@@ -471,7 +540,7 @@
      WPXPropertyList *pPersistPropList = new WPXPropertyList(propList);
      ParagraphStyle *pStyle = NULL;
  
@@ -546,38 +498,38 @@
      {
          // 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 @@
+@@ -483,26 +552,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");
++        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;
++        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 (mWriterDocumentStates.top().mbFirstParagraphInPageSpan && mpCurrentContentElements == &mBodyElements)
          {
 -            if (mWriterDocumentState.mbHeaderRow)
 -                pPersistPropList->insert("style:parent-style-name", "Table Heading");
-+    		if (mWriterDocumentStates.top().mbHeaderRow)
-+    			pPersistPropList->insert("style:parent-style-name", "Table_Heading");
++            WPXString sPageStyleName;
++            sPageStyleName.sprintf("Page_Style_%i", miNumPageStyles);
++            pPersistPropList->insert("style:master-page-name", sPageStyleName);
++            mWriterDocumentStates.top().mbFirstParagraphInPageSpan = false;    
++        }
++
++        if (mWriterDocumentStates.top().mbTableCellOpened)
++        {
++            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");
++                pPersistPropList->insert("style:parent-style-name", "Table_Contents");
          }
          else
              pPersistPropList->insert("style:parent-style-name", "Standard");
@@ -585,12 +537,12 @@
                  WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
  
 -        if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) {
-+    	if (mTextStyleHash.find(sKey) == mTextStyleHash.end())
-+    	{
++        if (mTextStyleHash.find(sKey) == mTextStyleHash.end())
++        {
              WPXString sName;
              sName.sprintf("S%i", mTextStyleHash.size()); 
              
-@@ -519,12 +612,12 @@
+@@ -519,12 +598,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());
@@ -605,7 +557,7 @@
  }
  
  void DocumentCollector::openSpan(const WPXPropertyList &propList)
-@@ -552,12 +645,12 @@
+@@ -552,12 +631,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());
@@ -620,18 +572,18 @@
  }
  
  void DocumentCollector::defineOrderedListLevel(const WPXPropertyList &propList)
-@@ -567,8 +660,8 @@
+@@ -567,8 +646,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?!
++        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 @@
+@@ -576,27 +655,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 && 
@@ -647,15 +599,15 @@
 -        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;
++        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;
++        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
@@ -663,36 +615,36 @@
      for (std::vector<ListStyle *>::iterator iterOrderedListStyles = mListStyles.begin(); iterOrderedListStyles != mListStyles.end(); iterOrderedListStyles++)
      {
 -        if ((* iterOrderedListStyles)->getListID() == propList["libwpd:id"]->getInt())
-+    	if ((* iterOrderedListStyles)->getListID() == id)
++        if ((* iterOrderedListStyles)->getListID() == id)
              (* iterOrderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList);
      }
  }
-@@ -608,106 +701,114 @@
+@@ -608,106 +687,114 @@
                  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?!
 +    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?!
++        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++;
++        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;
++        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)
++        if ((* iterUnorderedListStyles)->getListID() == id)
              (* iterUnorderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList);
      }
  }
@@ -703,8 +655,8 @@
 -    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);
@@ -724,8 +676,8 @@
 -    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);
@@ -742,19 +694,19 @@
 -      }
 -    else if (mbListElementParagraphOpened)
 +    if (!mWriterListStates.top().mbListElementOpened.empty() &&
-+    	!mWriterListStates.top().mbListElementOpened.top())
++        !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;
++        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;
@@ -781,8 +733,8 @@
 -    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;
@@ -795,7 +747,7 @@
 -    mbListElementOpened = false;
 +    if (!mWriterListStates.top().mbListElementOpened.empty())
 +    {
-+    	mWriterListStates.top().mbListElementOpened.pop();
++        mWriterListStates.top().mbListElementOpened.pop();
 +    }
  }
  
@@ -806,14 +758,14 @@
 -        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 (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;
@@ -824,7 +776,7 @@
      pPersistPropList->insert("style:parent-style-name", "Standard");
  
          WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
-@@ -727,17 +828,18 @@
+@@ -727,17 +814,18 @@
                  delete pPersistPropList;
          }
  
@@ -839,7 +791,7 @@
 -    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenListElement));
 -    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pOpenListElementParagraph));
 +    if (mpCurrentContentElements == &mBodyElements)
-+    	mWriterDocumentStates.top().mbFirstParagraphInPageSpan = false;
++        mWriterDocumentStates.top().mbFirstParagraphInPageSpan = false;
          
 -    mbListElementOpened = true;
 -    mbListElementParagraphOpened = true;
@@ -850,7 +802,7 @@
  }
  
  void DocumentCollector::closeListElement()
-@@ -746,69 +848,100 @@
+@@ -746,69 +834,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)
  
@@ -859,8 +811,8 @@
      {
 -        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(new TagCloseElement("text:p"));
++        mWriterListStates.top().mbListElementParagraphOpened = false;
      }
  }
  
@@ -884,7 +836,7 @@
          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 CharDataElement(propList["libwpd:number"]->getStr().cstr()));
 +    mpCurrentContentElements->push_back(new TagCloseElement("text:note-citation"));
  
 -    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:footnote-body")));
@@ -899,7 +851,7 @@
 -    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")));
@@ -927,7 +879,7 @@
          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 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")));
@@ -942,7 +894,7 @@
 -    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"));
@@ -960,7 +912,7 @@
 +{
 +    mWriterDocumentStates.top().mbInNote = false;
 +    if (mWriterListStates.size() > 1)
-+    	mWriterListStates.pop();
++        mWriterListStates.pop();
 +
 +    mpCurrentContentElements->push_back(new TagCloseElement("office:annotation"));
  }
@@ -972,31 +924,31 @@
      WPXString sTableName;
      sTableName.sprintf("Table%i", mTableStyles.size());
  
-@@ -817,11 +950,11 @@
+@@ -817,11 +936,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)
++    if (mWriterDocumentStates.top().mbFirstElement && mpCurrentContentElements == &mBodyElements)
      {
 -        WPXString sMasterPageName("Page Style 1");
-+    		WPXString sMasterPageName("Page_Style_1");
++        WPXString sMasterPageName("Page_Style_1");
          pTableStyle->setMasterPageName(sMasterPageName);
 -        mWriterDocumentState.mbFirstElement = false;
-+    		mWriterDocumentStates.top().mbFirstElement = false;
++        mWriterDocumentStates.top().mbFirstElement = false;
      }
  
      mTableStyles.push_back(pTableStyle);
-@@ -832,7 +965,7 @@
+@@ -832,7 +951,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);
++    mpCurrentContentElements->push_back(pTableOpenElement);
  
      for (int i=0; i<pTableStyle->getNumColumns(); i++) 
          {
-@@ -846,13 +979,16 @@
+@@ -846,13 +965,16 @@
          mpCurrentContentElements->push_back(pTableColumnCloseElement);
      }
  }
@@ -1010,17 +962,17 @@
      {
 -        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;
++        mpCurrentContentElements->push_back(new TagOpenElement("table:table-header-rows"));
++        mWriterDocumentStates.top().mbHeaderRow = true;
      }
  
      WPXString sTableRowStyleName;
-@@ -862,21 +998,27 @@
+@@ -862,21 +984,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);
++    mpCurrentContentElements->push_back(pTableRowOpenElement);
 +    }
  }
  
@@ -1029,15 +981,15 @@
 -    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("table:table-row")));
 -    if (mWriterDocumentState.mbHeaderRow)
 +    if (!mWriterDocumentStates.top().mbInNote)
-+    {
-+    	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;
-+    	}
++        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;
++        }
      }
  }
  
@@ -1048,17 +1000,17 @@
      WPXString sTableCellStyleName;
      sTableCellStyleName.sprintf( "%s.Cell%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableCellStyles());
      TableCellStyle *pTableCellStyle = new TableCellStyle(propList, sTableCellStyleName.cstr());
-@@ -890,39 +1032,72 @@
+@@ -890,39 +1018,72 @@
          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));
-+    	// pTableCellOpenElement->addAttribute("table:value-type", "string");
-+    	mpCurrentContentElements->push_back(pTableCellOpenElement);
++        // pTableCellOpenElement->addAttribute("table:value-type", "string");
++        mpCurrentContentElements->push_back(pTableCellOpenElement);
  
 -    mWriterDocumentState.mbTableCellOpened = true;
-+    	mWriterDocumentStates.top().mbTableCellOpened = true;
++        mWriterDocumentStates.top().mbTableCellOpened = true;
 +    }
  }
  
@@ -1068,8 +1020,8 @@
 -    mWriterDocumentState.mbTableCellOpened = false;
 +    if (!mWriterDocumentStates.top().mbInNote)
 +    {
-+    	mpCurrentContentElements->push_back(new TagCloseElement("table:table-cell"));
-+    	mWriterDocumentStates.top().mbTableCellOpened = false;
++        mpCurrentContentElements->push_back(new TagCloseElement("table:table-cell"));
++        mWriterDocumentStates.top().mbTableCellOpened = false;
 +    }
  }
  
@@ -1079,8 +1031,8 @@
 -    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("table:covered-table-cell")));
 +    if (!mWriterDocumentStates.top().mbInNote)
 +    {
-+    	mpCurrentContentElements->push_back(new TagOpenElement("table:covered-table-cell"));
-+    	mpCurrentContentElements->push_back(new TagCloseElement("table:covered-table-cell"));
++        mpCurrentContentElements->push_back(new TagOpenElement("table:covered-table-cell"));
++        mpCurrentContentElements->push_back(new TagCloseElement("table:covered-table-cell"));
 +    }
  }
  
@@ -1089,11 +1041,11 @@
 -    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("table:table")));
 +    if (!mWriterDocumentStates.top().mbInNote)
 +    {
-+    	mpCurrentContentElements->push_back(new TagCloseElement("table:table"));
++        mpCurrentContentElements->push_back(new TagCloseElement("table:table"));
 +    }
  }
- 
 +
+ 
  void DocumentCollector::insertTab()
  {
 -    mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagOpenElement("text:tab-stop")));
@@ -1119,21 +1071,21 @@
 +void DocumentCollector::insertField(const WPXString &type, const WPXPropertyList &propList)
 +{
 +    if (!type.len())
-+    	return;
++        return;
 +
 +    TagOpenElement *openElement = new TagOpenElement(type.cstr());
 +    if (type == "text:page-number")
-+    	openElement->addAttribute("text:select-page", "current"); 
++        openElement->addAttribute("text:select-page", "current"); 
 +
 +    if (propList["style:num-format"])
-+    	openElement->addAttribute("style:num-format", propList["style:num-format"]->getStr());
++        openElement->addAttribute("style:num-format", propList["style:num-format"]->getStr());
 +
 +    mpCurrentContentElements->push_back(openElement);
 +    mpCurrentContentElements->push_back(new TagCloseElement(type.cstr()));
  }
  
  void DocumentCollector::insertText(const WPXString &text)
-@@ -931,4 +1106,222 @@
+@@ -931,4 +1092,221 @@
      mpCurrentContentElements->push_back(pText);
  }
  
@@ -1153,39 +1105,39 @@
 +    TagOpenElement *frameStylePropertiesOpenElement = new TagOpenElement("style:graphic-properties");
 +
 +    if (propList["text:anchor-type"])
-+    	frameStylePropertiesOpenElement->addAttribute("text:anchor-type", propList["text:anchor-type"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("text:anchor-type", propList["text:anchor-type"]->getStr());
 +    else
-+    	frameStylePropertiesOpenElement->addAttribute("text:anchor-type","paragraph");
++        frameStylePropertiesOpenElement->addAttribute("text:anchor-type","paragraph");
 +
 +    if (propList["text:anchor-page-number"])
-+    	frameStylePropertiesOpenElement->addAttribute("text:anchor-page-number", propList["text:anchor-page-number"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("text:anchor-page-number", propList["text:anchor-page-number"]->getStr());
 +
 +    if (propList["svg:x"])
-+    	frameStylePropertiesOpenElement->addAttribute("svg:x", propList["svg:x"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("svg:x", propList["svg:x"]->getStr());
 +
 +    if (propList["svg:y"])
-+    	frameStylePropertiesOpenElement->addAttribute("svg:y", propList["svg:y"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("svg:y", propList["svg:y"]->getStr());
 +
 +    if (propList["svg:width"])
-+    	frameStylePropertiesOpenElement->addAttribute("svg:width", propList["svg:width"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("svg:width", propList["svg:width"]->getStr());
 +
 +    if (propList["svg:height"])
-+    	frameStylePropertiesOpenElement->addAttribute("svg:height", propList["svg:height"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("svg:height", propList["svg:height"]->getStr());
 +
 +    if (propList["style:rel-width"])
-+    	frameStylePropertiesOpenElement->addAttribute("style:rel-width", propList["style:rel-width"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("style:rel-width", propList["style:rel-width"]->getStr());
 +
 +    if (propList["style:rel-height"])
-+    	frameStylePropertiesOpenElement->addAttribute("style:rel-height", propList["style:rel-height"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("style:rel-height", propList["style:rel-height"]->getStr());
 +
 +    if (propList["fo:max-width"])
-+    	frameStylePropertiesOpenElement->addAttribute("fo:max-width", propList["fo:max-width"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("fo:max-width", propList["fo:max-width"]->getStr());
 +
 +    if (propList["fo:max-height"])
-+    	frameStylePropertiesOpenElement->addAttribute("fo:max-height", propList["fo:max-height"]->getStr());
-+    	
++        frameStylePropertiesOpenElement->addAttribute("fo:max-height", propList["fo:max-height"]->getStr());
++        
 +    if (propList["style:wrap"])
-+    	frameStylePropertiesOpenElement->addAttribute("style:wrap", propList["style:wrap"]->getStr());
++        frameStylePropertiesOpenElement->addAttribute("style:wrap", propList["style:wrap"]->getStr());
 +
 +    mFrameStyles.push_back(frameStylePropertiesOpenElement);
 +
@@ -1205,30 +1157,30 @@
 +
 +    TagOpenElement *frameAutomaticStylePropertiesElement = new TagOpenElement("style:graphic-properties");
 +    if (propList["style:horizontal-pos"])
-+    	frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-pos", propList["style:horizontal-pos"]->getStr());
++        frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-pos", propList["style:horizontal-pos"]->getStr());
 +    else
-+    	frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-pos", "left");
++        frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-pos", "left");
 +
 +    if (propList["style:horizontal-rel"])
-+    	frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-rel", propList["style:horizontal-rel"]->getStr());
++        frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-rel", propList["style:horizontal-rel"]->getStr());
 +    else
-+    	frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-rel", "paragraph");
++        frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-rel", "paragraph");
 +
 +    if (propList["style:vertical-pos"])
-+    	frameAutomaticStylePropertiesElement->addAttribute("style:vertical-pos", propList["style:vertical-pos"]->getStr());
++        frameAutomaticStylePropertiesElement->addAttribute("style:vertical-pos", propList["style:vertical-pos"]->getStr());
 +    else
-+    	frameAutomaticStylePropertiesElement->addAttribute("style:vertical-pos", "top");
++        frameAutomaticStylePropertiesElement->addAttribute("style:vertical-pos", "top");
 +
 +    if (propList["style:vertical-rel"])
-+    	frameAutomaticStylePropertiesElement->addAttribute("style:vertical-rel", propList["style:vertical-rel"]->getStr());
++        frameAutomaticStylePropertiesElement->addAttribute("style:vertical-rel", propList["style:vertical-rel"]->getStr());
 +    else
-+    	frameAutomaticStylePropertiesElement->addAttribute("style:vertical-rel", "page-content");
++        frameAutomaticStylePropertiesElement->addAttribute("style:vertical-rel", "page-content");
 +
 +    if (propList["fo:max-width"])
-+    	frameAutomaticStylePropertiesElement->addAttribute("fo:max-width", propList["fo:max-width"]->getStr());
++        frameAutomaticStylePropertiesElement->addAttribute("fo:max-width", propList["fo:max-width"]->getStr());
 +
 +    if (propList["fo:max-height"])
-+    	frameAutomaticStylePropertiesElement->addAttribute("fo:max-height", propList["fo:max-height"]->getStr());
++        frameAutomaticStylePropertiesElement->addAttribute("fo:max-height", propList["fo:max-height"]->getStr());
 +
 +    frameAutomaticStylePropertiesElement->addAttribute("draw:ole-draw-aspect", "1");
 +
@@ -1246,30 +1198,30 @@
 +    objectName.sprintf("Object%i", miObjectNumber++);
 +    drawFrameOpenElement->addAttribute("draw:name", objectName);
 +    if (propList["text:anchor-type"])
-+    	drawFrameOpenElement->addAttribute("text:anchor-type", propList["text:anchor-type"]->getStr());
++        drawFrameOpenElement->addAttribute("text:anchor-type", propList["text:anchor-type"]->getStr());
 +    else
-+    	drawFrameOpenElement->addAttribute("text:anchor-type","paragraph");
++        drawFrameOpenElement->addAttribute("text:anchor-type","paragraph");
 +
 +    if (propList["text:anchor-page-number"])
-+    	drawFrameOpenElement->addAttribute("text:anchor-page-number", propList["text:anchor-page-number"]->getStr());
++        drawFrameOpenElement->addAttribute("text:anchor-page-number", propList["text:anchor-page-number"]->getStr());
 +
 +    if (propList["svg:x"])
-+    	drawFrameOpenElement->addAttribute("svg:x", propList["svg:x"]->getStr());
++        drawFrameOpenElement->addAttribute("svg:x", propList["svg:x"]->getStr());
 +
 +    if (propList["svg:y"])
-+    	drawFrameOpenElement->addAttribute("svg:y", propList["svg:y"]->getStr());
++        drawFrameOpenElement->addAttribute("svg:y", propList["svg:y"]->getStr());
 +
 +    if (propList["svg:width"])
-+    	drawFrameOpenElement->addAttribute("svg:width", propList["svg:width"]->getStr());
++        drawFrameOpenElement->addAttribute("svg:width", propList["svg:width"]->getStr());
 +
 +    if (propList["svg:height"])
-+    	drawFrameOpenElement->addAttribute("svg:height", propList["svg:height"]->getStr());
++        drawFrameOpenElement->addAttribute("svg:height", propList["svg:height"]->getStr());
 +
 +    if (propList["style:rel-width"])
-+    	drawFrameOpenElement->addAttribute("style:rel-width", propList["style:rel-width"]->getStr());
++        drawFrameOpenElement->addAttribute("style:rel-width", propList["style:rel-width"]->getStr());
 +
 +    if (propList["style:rel-height"])
-+    	drawFrameOpenElement->addAttribute("style:rel-height", propList["style:rel-height"]->getStr());
++        drawFrameOpenElement->addAttribute("style:rel-height", propList["style:rel-height"]->getStr());
 +
 +    mpCurrentContentElements->push_back(drawFrameOpenElement);
 +
@@ -1279,7 +1231,7 @@
 +void DocumentCollector::closeFrame()
 +{
 +    if (mWriterListStates.size() > 1)
-+    	mWriterListStates.pop();
++        mWriterListStates.pop();
 +
 +    mpCurrentContentElements->push_back(new TagCloseElement("draw:frame"));
 +
@@ -1289,53 +1241,51 @@
 +void DocumentCollector::insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData &data)
 +{
 +    if (!data.size())
-+    	return;
++        return;
 +    if (!mWriterDocumentStates.top().mbInFrame) // Embedded objects without a frame simply don't make sense for us
-+    	return;
++        return;
 +    if (!propList["libwpd:mimetype"])
-+    	return;
++        return;
 +
 +    if (propList["libwpd:mimetype"]->getStr() == "image/x-wpg")
 +    {
-+#ifdef USE_LIBWPG
-+    	std::vector<DocumentElement *> tmpContentElements;
-+    	InternalHandler tmpHandler(&tmpContentElements);
-+    	OdgExporter exporter(&tmpHandler, ODF_FLAT_XML);
-+    	
-+    	libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT;
-+    	
-+    	if (!libwpg::WPGraphics::isSupported(const_cast<WPXInputStream *>(data.getDataStream())))
-+    		fileFormat = libwpg::WPG_WPG1;
-+
-+    	if (libwpg::WPGraphics::parse(const_cast<WPXInputStream *>(data.getDataStream()), &exporter, fileFormat) && !tmpContentElements.empty())
-+    	{
-+    		mpCurrentContentElements->push_back(new TagOpenElement("draw:object"));
-+    		for (std::vector<DocumentElement *>::const_iterator iter = tmpContentElements.begin(); iter != tmpContentElements.end(); iter++)
-+    			mpCurrentContentElements->push_back(*iter);
-+    		mpCurrentContentElements->push_back(new TagCloseElement("draw:object"));
-+    	}
-+#endif
++        std::vector<DocumentElement *> tmpContentElements;
++        InternalHandler tmpHandler(&tmpContentElements);
++        OdgExporter exporter(&tmpHandler);
++        
++        libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT;
++        
++        if (!libwpg::WPGraphics::isSupported(const_cast<WPXInputStream *>(data.getDataStream())))
++            fileFormat = libwpg::WPG_WPG1;
++
++        if (libwpg::WPGraphics::parse(const_cast<WPXInputStream *>(data.getDataStream()), &exporter, fileFormat) && !tmpContentElements.empty())
++        {
++            mpCurrentContentElements->push_back(new TagOpenElement("draw:object"));
++            for (std::vector<DocumentElement *>::const_iterator iter = tmpContentElements.begin(); iter != tmpContentElements.end(); iter++)
++                mpCurrentContentElements->push_back(*iter);
++            mpCurrentContentElements->push_back(new TagCloseElement("draw:object"));
++        }
 +    }
 +    else
 +    {
-+    	mpCurrentContentElements->push_back(new TagOpenElement("draw:image"));
-+    	
-+    	mpCurrentContentElements->push_back(new TagOpenElement("office:binary-data"));
-+    	
-+    	WPXString binaryBase64Data = data.getBase64Data();
-+    	
-+    	mpCurrentContentElements->push_back(new CharDataElement(binaryBase64Data.cstr()));
-+    	
-+    	mpCurrentContentElements->push_back(new TagCloseElement("office:binary-data"));
-+    	
-+    	mpCurrentContentElements->push_back(new TagCloseElement("draw:image"));
++        mpCurrentContentElements->push_back(new TagOpenElement("draw:image"));
++        
++        mpCurrentContentElements->push_back(new TagOpenElement("office:binary-data"));
++        
++        WPXString binaryBase64Data = data.getBase64Data();
++        
++        mpCurrentContentElements->push_back(new CharDataElement(binaryBase64Data.cstr()));
++        
++        mpCurrentContentElements->push_back(new TagCloseElement("office:binary-data"));
++        
++        mpCurrentContentElements->push_back(new TagCloseElement("draw:image"));
 +    }
 +}
 +
 +void DocumentCollector::openTextBox(const WPXPropertyList & /*propList*/)
 +{
 +    if (!mWriterDocumentStates.top().mbInFrame) // Text box without a frame simply doesn't make sense for us
-+    	return;
++        return;
 +    mWriterListStates.push(WriterListState());
 +    mWriterDocumentStates.push(WriterDocumentState());
 +    mpCurrentContentElements->push_back(new TagOpenElement("draw:text-box"));
@@ -1346,59 +1296,31 @@
 +void DocumentCollector::closeTextBox()
 +{
 +    if (!mWriterDocumentStates.top().mbInTextBox)
-+    	return;
++        return;
 +    if (mWriterListStates.size() > 1)
-+    	mWriterListStates.pop();
++        mWriterListStates.pop();
 +    if (mWriterDocumentStates.size() > 1)
-+    	mWriterDocumentStates.pop();
++        mWriterDocumentStates.pop();
 +
 +    mpCurrentContentElements->push_back(new TagCloseElement("draw:text-box"));
 +}
 +
++
  /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 --- writerperfect/source/filter/DocumentCollector.hxx	2010-11-04 13:37:48.000000000 +0100
-+++ writerperfect/source/filter/DocumentCollector.hxx	2010-11-06 14:50:10.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 target file
-  *
-- * 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)
-  *
-@@ -32,24 +32,18 @@
- #ifndef _DOCUMENTCOLLECTOR_HXX
- #define _DOCUMENTCOLLECTOR_HXX
- #include "SectionStyle.hxx"
-+#include "FilterInternal.hxx"
- 
--#if defined _MSC_VER
--#pragma warning( push, 1 )
--#endif
--#include <libwps/libwps.h>
- #include <libwpd/libwpd.h>
--#if defined _MSC_VER
--#pragma warning( pop )
--#endif
- #include <vector>
- #include <map>
++++ writerperfect/source/filter/DocumentCollector.hxx	2010-11-06 23:09:43.000000000 +0100
+@@ -46,8 +46,9 @@
  #include <stack>
--#include <string.h>
+ #include <string.h>
  
++#include "DocumentHandlerInterface.hxx"
++
  class DocumentElement;
 -class DocumentHandler;
-+class DocumentHandlerInterface;
  class TagOpenElement;
  class FontStyle;
-+class GraphicsStyle;
  class ListStyle;
- 
- class ParagraphStyle;
-@@ -64,11 +58,29 @@
+@@ -64,11 +65,29 @@
      _WriterDocumentState();
  
      bool mbFirstElement;
@@ -1428,7 +1350,7 @@
  };
  
  enum WriterListType { unordered, ordered };
-@@ -81,20 +93,23 @@
+@@ -81,20 +100,23 @@
    }
  };
  
@@ -1437,13 +1359,13 @@
  {
  public:
 -    DocumentCollector(WPSInputStream *pInput, DocumentHandler *pHandler);
-+    DocumentCollector(WPXInputStream *pInput, const char * password, DocumentHandlerInterface *pHandler);
++    DocumentCollector(WPXInputStream *pInput, DocumentHandlerInterface *pHandler);
      virtual ~DocumentCollector();
      bool filter();
  
 -     virtual void setDocumentMetaData(const WPXPropertyList & /* propList */) {}
 +    // WPXDocumentInterface's callbacks 
-+ 	virtual void setDocumentMetaData(const WPXPropertyList &propList);
++    virtual void setDocumentMetaData(const WPXPropertyList &propList);
      virtual void startDocument() {}
      virtual void endDocument() {}
  
@@ -1455,7 +1377,7 @@
      virtual void openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
      virtual void closeSection();
  
-@@ -103,9 +118,11 @@
+@@ -103,9 +125,11 @@
      virtual void openFooter(const WPXPropertyList &propList);
      virtual void closeFooter();
  
@@ -1467,7 +1389,7 @@
      virtual void openSpan(const WPXPropertyList &propList);
      virtual void closeSpan();
  
-@@ -109,10 +126,11 @@
+@@ -109,10 +133,11 @@
      virtual void openSpan(const WPXPropertyList &propList);
      virtual void closeSpan();
  
@@ -1480,7 +1402,7 @@
  
      virtual void defineOrderedListLevel(const WPXPropertyList &propList);
      virtual void defineUnorderedListLevel(const WPXPropertyList &propList);
-@@ -127,6 +145,10 @@
+@@ -127,6 +152,10 @@
      virtual void closeFootnote();
      virtual void openEndnote(const WPXPropertyList &propList);
      virtual void closeEndnote();
@@ -1491,7 +1413,7 @@
  
       virtual void openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
       virtual void openTableRow(const WPXPropertyList &propList);
-@@ -135,25 +157,34 @@
+@@ -135,25 +164,34 @@
      virtual void closeTableCell();
      virtual void insertCoveredTableCell(const WPXPropertyList &propList);
       virtual void closeTable();
@@ -1502,6 +1424,8 @@
 +    
 +    virtual void insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData &data);
 +    virtual void insertEquation(const WPXPropertyList & /* propList */, const WPXString & /* data */) {}
++
++    virtual bool parseSourceDocument(WPXInputStream &input) = 0;
  
  protected:
      void _resetDocumentState();
@@ -1509,9 +1433,7 @@
 -    void _writeDefaultStyles(DocumentHandler *pHandler);
 -    void _writeMasterPages(DocumentHandler *pHandler);
 -    void _writePageMasters(DocumentHandler *pHandler);
-+    bool _parseSourceDocument(WPXInputStream &input, const char *password);
 +    bool _writeTargetDocument(DocumentHandlerInterface *pHandler);
-+    void _writeBegin();
 +    void _writeDefaultStyles(DocumentHandlerInterface *pHandler);
 +    void _writeMasterPages(DocumentHandlerInterface *pHandler);
 +    void _writePageLayouts(DocumentHandlerInterface *pHandler);
@@ -1535,13 +1457,7 @@
  
      // paragraph styles
      std::map<WPXString, ParagraphStyle *, ltstr> mTextStyleHash;
-@@ -166,11 +197,19 @@
- 
-     // section styles
-     std::vector<SectionStyle *> mSectionStyles;
--    float mfSectionSpaceAfter;
-+    double mfSectionSpaceAfter;
- 
+@@ -171,6 +209,14 @@
      // table styles
      std::vector<TableStyle *> mTableStyles;
  
@@ -1556,7 +1472,7 @@
      // list styles
      unsigned int miNumListStyles;
  
-@@ -186,20 +225,17 @@
+@@ -186,18 +232,18 @@
      PageSpan *mpCurrentPageSpan;
      int miNumPageStyles;
  
@@ -1576,15 +1492,15 @@
  
      // table state
      TableStyle *mpCurrentTableStyle;
--};
- 
++
++    const bool mbIsFlatXML;
++    
 +    const char * mpPassword;
-+};
- #endif
+ };
  
- /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+ #endif
 --- writerperfect/source/filter/DocumentElement.cxx	2010-10-17 15:38:36.000000000 +0200
-+++ writerperfect/source/filter/DocumentElement.cxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/DocumentElement.cxx	2010-11-06 23:09:43.000000000 +0100
 @@ -27,6 +27,7 @@
   */
  
@@ -1632,7 +1548,7 @@
          
      WPXString sTemp;
 --- writerperfect/source/filter/DocumentElement.hxx	2010-11-04 13:37:48.000000000 +0100
-+++ writerperfect/source/filter/DocumentElement.hxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/DocumentElement.hxx	2010-11-06 23:09:43.000000000 +0100
 @@ -28,30 +28,25 @@
  
  #ifndef _DOCUMENTELEMENT_H
@@ -1708,8 +1624,81 @@
  
  private:
      WPXString msTextBuf;
+--- writerperfect/source/filter/DocumentHandler.cxx	2010-10-17 15:38:36.000000000 +0200
++++ writerperfect/source/filter/DocumentHandler.cxx	2010-11-06 23:09:43.000000000 +0100
+@@ -29,6 +29,8 @@
+ 
+ #include <xmloff/attrlist.hxx>
+ 
++// #define DEBUG_XML 1
++
+ using namespace ::rtl;
+ using rtl::OUString;
+ 
+@@ -41,19 +43,19 @@
+ 
+ void DocumentHandler::startDocument() 
+ {
+-    WRITER_DEBUG_MSG(("DocumentHandler::startDocument\n"));
+     mxHandler->startDocument();
+ }
+ 
+ void DocumentHandler::endDocument()
+ {
+-    WRITER_DEBUG_MSG(("DocumentHandler::endDocument\n"));
+     mxHandler->endDocument();
+ }
+ 
+ void DocumentHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
+ {
+-    WRITER_DEBUG_MSG(("DocumentHandler::startElement\n"));
++#ifdef DEBUG_XML
++    printf("<%s", psName);
++#endif
+         SvXMLAttributeList *pAttrList = new SvXMLAttributeList();
+     Reference < XAttributeList > xAttrList(pAttrList);
+     WPXPropertyList::Iter i(xPropList);
+@@ -61,23 +63,36 @@
+     {
+                 // filter out libwpd elements
+                 if (strncmp(i.key(), "libwpd", 6) != 0)
++        {
+                         pAttrList->AddAttribute(OUString::createFromAscii(i.key()),
+                                                 OUString::createFromAscii(i()->getStr().cstr()));
++#ifdef DEBUG_XML
++            printf(" %s=\"%s\"", i.key(), i()->getStr().cstr());
++#endif
++        }
+         }
++#ifdef DEBUG_XML
++    printf(">");
++#endif
+ 
+         mxHandler->startElement(OUString::createFromAscii(psName), xAttrList);
+ }
+ 
+ void DocumentHandler::endElement(const char *psName)
+ {
+-    WRITER_DEBUG_MSG(("DocumentHandler::endElement\n"));
++#ifdef DEBUG_XML
++    printf("</%s>", psName);
++#endif
+         mxHandler->endElement(OUString::createFromAscii(psName));
+ }
+ 
+ void DocumentHandler::characters(const WPXString &sCharacters)
+ {
+-    WRITER_DEBUG_MSG(("DocumentHandler::characters\n"));
+         OUString sCharU16(sCharacters.cstr(), strlen(sCharacters.cstr()), RTL_TEXTENCODING_UTF8);
++#ifdef DEBUG_XML
++    WPXString sEscapedCharacters(sCharacters, true);
++    printf("%s", sEscapedCharacters.cstr());
++#endif
+         mxHandler->characters(sCharU16);
+ }
+ 
 --- writerperfect/source/filter/DocumentHandler.hxx	2010-11-04 13:37:48.000000000 +0100
-+++ writerperfect/source/filter/DocumentHandler.hxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/DocumentHandler.hxx	2010-11-06 23:09:43.000000000 +0100
 @@ -12,10 +12,12 @@
  #pragma warning( pop )
  #endif
@@ -1725,7 +1714,7 @@
  public:
          DocumentHandler(Reference < XDocumentHandler > &xHandler);
 --- writerperfect/source/filter/DocumentHandlerInterface.hxx	1970-01-01 01:00:00.000000000 +0100
-+++ writerperfect/source/filter/DocumentHandlerInterface.hxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/DocumentHandlerInterface.hxx	2010-11-06 23:09:43.000000000 +0100
 @@ -0,0 +1,45 @@
 +/*
 + * Copyright (C) 2004 William Lachance (wlach at interlog.com)
@@ -1773,7 +1762,7 @@
 +};
 +#endif
 --- writerperfect/source/filter/FilterInternal.hxx	2010-11-04 13:37:48.000000000 +0100
-+++ writerperfect/source/filter/FilterInternal.hxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/FilterInternal.hxx	2010-11-06 23:09:43.000000000 +0100
 @@ -20,6 +20,10 @@
   * For further information visit http://libwpd.sourceforge.net
   *
@@ -1793,7 +1782,7 @@
 +
  /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 --- writerperfect/source/filter/FontStyle.cxx	2010-10-17 15:38:36.000000000 +0200
-+++ writerperfect/source/filter/FontStyle.cxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/FontStyle.cxx	2010-11-06 23:09:43.000000000 +0100
 @@ -30,7 +30,7 @@
  #include "DocumentElement.hxx"
  
@@ -1816,7 +1805,7 @@
 -    styleOpen.addAttribute("fo:font-family", msFontFamily);
 -    styleOpen.addAttribute("style:font-pitch", msFontPitch);
 +    styleOpen.addAttribute("svg:font-family", msFontFamily);
-+//	styleOpen.addAttribute("style:font-pitch", msFontPitch);
++//    styleOpen.addAttribute("style:font-pitch", msFontPitch);
      styleOpen.write(pHandler);
 -    TagCloseElement styleClose("style:font-decl");
 +    TagCloseElement styleClose("style:font-face");
@@ -1824,7 +1813,7 @@
  }
  
 --- writerperfect/source/filter/FontStyle.hxx	2010-11-04 13:37:48.000000000 +0100
-+++ writerperfect/source/filter/FontStyle.hxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/FontStyle.hxx	2010-11-06 23:09:43.000000000 +0100
 @@ -27,23 +27,18 @@
   */
  #ifndef _FONTSTYLE_H
@@ -1852,7 +1841,7 @@
  
  private:
 --- writerperfect/source/filter/GraphicsStyle.cxx	1970-01-01 01:00:00.000000000 +0100
-+++ writerperfect/source/filter/GraphicsStyle.cxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/GraphicsStyle.cxx	2010-11-06 23:09:43.000000000 +0100
 @@ -0,0 +1,40 @@
 +/* GraphicsStyle:
 + *
@@ -1895,7 +1884,7 @@
 +{        
 +}
 --- writerperfect/source/filter/GraphicsStyle.hxx	1970-01-01 01:00:00.000000000 +0100
-+++ writerperfect/source/filter/GraphicsStyle.hxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/GraphicsStyle.hxx	2010-11-06 23:09:43.000000000 +0100
 @@ -0,0 +1,40 @@
 +/* GraphicsStyle:
 + *
@@ -1938,7 +1927,7 @@
 +};
 +#endif
 --- writerperfect/source/filter/InternalHandler.cxx	1970-01-01 01:00:00.000000000 +0100
-+++ writerperfect/source/filter/InternalHandler.cxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/InternalHandler.cxx	2010-11-06 23:09:43.000000000 +0100
 @@ -0,0 +1,54 @@
 +/*
 + * Copyright (C) 2007 Fridrich Strba .strba at bluewin.ch)
@@ -1974,7 +1963,7 @@
 +
 +void InternalHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
 +{
-+    TagOpenElement	*element = new TagOpenElement(psName);
++    TagOpenElement    *element = new TagOpenElement(psName);
 +    WPXPropertyList::Iter i(xPropList);
 +    for (i.rewind(); i.next(); )
 +    {
@@ -1995,7 +1984,7 @@
 +    mpElements->push_back(new CharDataElement(sCharacters.cstr()));
 +}
 --- writerperfect/source/filter/InternalHandler.hxx	1970-01-01 01:00:00.000000000 +0100
-+++ writerperfect/source/filter/InternalHandler.hxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/InternalHandler.hxx	2010-11-06 23:09:43.000000000 +0100
 @@ -0,0 +1,46 @@
 +/*
 + * Copyright (C) 2007 Fridrich Strba .strba at bluewin.ch)
@@ -2044,7 +2033,7 @@
 +};
 +#endif
 --- writerperfect/source/filter/ListStyle.cxx	2010-10-17 15:38:36.000000000 +0200
-+++ writerperfect/source/filter/ListStyle.cxx	2010-11-06 16:38:36.000000000 +0100
++++ writerperfect/source/filter/ListStyle.cxx	2010-11-06 23:09:43.000000000 +0100
 @@ -42,34 +42,46 @@
          setListLevel(iLevel, new OrderedListLevelStyle(xPropList));
  }
@@ -2160,7 +2149,7 @@
      TagOpenElement listStyleOpenElement("text:list-style");
      listStyleOpenElement.addAttribute("style:name", getName());
 --- writerperfect/source/filter/ListStyle.hxx	2010-11-04 13:37:48.000000000 +0100
-+++ writerperfect/source/filter/ListStyle.hxx	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/ListStyle.hxx	2010-11-06 23:09:43.000000000 +0100
 @@ -27,18 +27,13 @@
   */
  #ifndef _LISTSTYLE_H
@@ -2217,7 +2206,7 @@
      bool isListLevelDefined(int iLevel) const;
  
 --- writerperfect/source/filter/makefile.mk	2010-10-10 13:15:28.000000000 +0200
-+++ writerperfect/source/filter/makefile.mk	2010-11-06 14:50:10.000000000 +0100
++++ writerperfect/source/filter/makefile.mk	2010-11-06 23:09:43.000000000 +0100
 @@ -10,6 +10,10 @@
  INCPRE+=$(LIBWPD_CFLAGS)
  .ENDIF
@@ -2251,7 +2240,7 @@
  
  .INCLUDE :  target.mk
 --- writerperfect/source/filter/OdgExporter.cxx	1970-01-01 01:00:00.000000000 +0100
-+++ writerperfect/source/filter/OdgExporter.cxx	2010-11-06 16:29:31.000000000 +0100
++++ writerperfect/source/filter/OdgExporter.cxx	2010-11-06 23:14:23.000000000 +0100
 @@ -0,0 +1,648 @@
 +/* libwpg
 + * Copyright (C) 2006 Ariya Hidayat (ariya at kde.org)
@@ -2290,7 +2279,7 @@
 +#define M_PI 3.14159265358979323846
 +#endif
 +
-+OdgExporter::OdgExporter(DocumentHandler *pHandler):
++OdgExporter::OdgExporter(DocumentHandlerInterface *pHandler):
 +    mpHandler(pHandler),
 +    miGradientIndex(1),
 +    miDashIndex(1), 
@@ -2305,26 +2294,26 @@
 +
 +    for (std::vector<DocumentElement *>::iterator iterBody = mBodyElements.begin(); iterBody != mBodyElements.end(); iterBody++)
 +    {
-+    	delete (*iterBody);
-+    	(*iterBody) = NULL;
++        delete (*iterBody);
++        (*iterBody) = NULL;
 +    }
 +
 +    for (std::vector<DocumentElement *>::iterator iterGraphicsAutomaticStyles = mGraphicsAutomaticStyles.begin();
-+    	iterGraphicsAutomaticStyles != mGraphicsAutomaticStyles.end(); iterGraphicsAutomaticStyles++)
++        iterGraphicsAutomaticStyles != mGraphicsAutomaticStyles.end(); iterGraphicsAutomaticStyles++)
 +    {
-+    	delete((*iterGraphicsAutomaticStyles));
++        delete((*iterGraphicsAutomaticStyles));
 +    }
 +
 +    for (std::vector<DocumentElement *>::iterator iterGraphicsStrokeDashStyles = mGraphicsStrokeDashStyles.begin();
-+    	iterGraphicsStrokeDashStyles != mGraphicsStrokeDashStyles.end(); iterGraphicsStrokeDashStyles++)
++        iterGraphicsStrokeDashStyles != mGraphicsStrokeDashStyles.end(); iterGraphicsStrokeDashStyles++)
 +    {
-+    	delete((*iterGraphicsStrokeDashStyles));
++        delete((*iterGraphicsStrokeDashStyles));
 +    }
 +
 +    for (std::vector<DocumentElement *>::iterator iterGraphicsGradientStyles = mGraphicsGradientStyles.begin();
-+    	iterGraphicsGradientStyles != mGraphicsGradientStyles.end(); iterGraphicsGradientStyles++)
++        iterGraphicsGradientStyles != mGraphicsGradientStyles.end(); iterGraphicsGradientStyles++)
 +    {
-+    	delete((*iterGraphicsGradientStyles));
++        delete((*iterGraphicsGradientStyles));
 +    }
 +}
 +
@@ -2337,10 +2326,10 @@
 +    mfHeight = 0.0;
 +
 +    if (propList["svg:width"])
-+    	mfWidth = propList["svg:width"]->getDouble();
++        mfWidth = propList["svg:width"]->getDouble();
 +
 +    if (propList["svg:height"])
-+    	mfHeight = propList["svg:height"]->getDouble();
++        mfHeight = propList["svg:height"]->getDouble();
 +
 +    mpHandler->startDocument();
 +    TagOpenElement tmpOfficeDocumentContent("office:document");
@@ -2354,9 +2343,9 @@
 +    tmpOfficeDocumentContent.addAttribute("xmlns:config", "urn:oasis:names:tc:opendocument:xmlns:config:1.0");
 +    tmpOfficeDocumentContent.addAttribute("xmlns:ooo", "http://openoffice.org/2004/office");
 +    tmpOfficeDocumentContent.addAttribute("office:version", "1.0");
-+    tmpOfficeDocumentContent.addAttribute("office:mimetype", "application/vnd.oasis.opendocument.graphics");
++    tmpOfficeDocumentContent.addAttribute("office:mimetype", "application/vnd.oasis.opendocument.graphics");    
 +    tmpOfficeDocumentContent.write(mpHandler);
-+
++    
 +    TagOpenElement("office:settings").write(mpHandler);
 +
 +    TagOpenElement configItemSetOpenElement("config:config-item-set");
@@ -2370,29 +2359,29 @@
 +    configItemOpenElement.write(mpHandler);
 +    mpHandler->characters("0");
 +    mpHandler->endElement("config:config-item");
-+
++    
 +    configItemOpenElement.addAttribute("config:name", "VisibleAreaLeft");
 +    configItemOpenElement.addAttribute("config:type", "int");
 +    configItemOpenElement.write(mpHandler);
 +    mpHandler->characters("0");
 +    mpHandler->endElement("config:config-item");
-+
++    
 +    configItemOpenElement.addAttribute("config:name", "VisibleAreaWidth");
 +    configItemOpenElement.addAttribute("config:type", "int");
 +    configItemOpenElement.write(mpHandler);
 +    WPXString sWidth; sWidth.sprintf("%li", (unsigned long)(2540 * mfWidth));
 +    mpHandler->characters(sWidth);
 +    mpHandler->endElement("config:config-item");
-+
++    
 +    configItemOpenElement.addAttribute("config:name", "VisibleAreaHeight");
 +    configItemOpenElement.addAttribute("config:type", "int");
 +    configItemOpenElement.write(mpHandler);
 +    WPXString sHeight; sHeight.sprintf("%li", (unsigned long)(2540 * mfHeight));
 +    mpHandler->characters(sHeight);
 +    mpHandler->endElement("config:config-item");
-+
++    
 +    mpHandler->endElement("config:config-item-set");
-+
++    
 +    mpHandler->endElement("office:settings");
 +}
 +
@@ -2401,15 +2390,15 @@
 +    TagOpenElement("office:styles").write(mpHandler);
 +
 +    for (std::vector<DocumentElement *>::const_iterator iterGraphicsStrokeDashStyles = mGraphicsStrokeDashStyles.begin();
-+    	iterGraphicsStrokeDashStyles != mGraphicsStrokeDashStyles.end(); iterGraphicsStrokeDashStyles++)
++        iterGraphicsStrokeDashStyles != mGraphicsStrokeDashStyles.end(); iterGraphicsStrokeDashStyles++)
 +    {
-+    	(*iterGraphicsStrokeDashStyles)->write(mpHandler);
++        (*iterGraphicsStrokeDashStyles)->write(mpHandler);
 +    }
 +
 +    for (std::vector<DocumentElement *>::const_iterator iterGraphicsGradientStyles = mGraphicsGradientStyles.begin();
-+    	iterGraphicsGradientStyles != mGraphicsGradientStyles.end(); iterGraphicsGradientStyles++)
++        iterGraphicsGradientStyles != mGraphicsGradientStyles.end(); iterGraphicsGradientStyles++)
 +    {
-+    	(*iterGraphicsGradientStyles)->write(mpHandler);
++        (*iterGraphicsGradientStyles)->write(mpHandler);
 +    }
 +
 +    mpHandler->endElement("office:styles");
@@ -2418,9 +2407,9 @@
 +
 +    // writing out the graphics automatic styles
 +    for (std::vector<DocumentElement *>::iterator iterGraphicsAutomaticStyles = mGraphicsAutomaticStyles.begin();
-+    	iterGraphicsAutomaticStyles != mGraphicsAutomaticStyles.end(); iterGraphicsAutomaticStyles++)
++        iterGraphicsAutomaticStyles != mGraphicsAutomaticStyles.end(); iterGraphicsAutomaticStyles++)
 +    {
-+    	(*iterGraphicsAutomaticStyles)->write(mpHandler);
++        (*iterGraphicsAutomaticStyles)->write(mpHandler);
 +    }
 +
 +    TagOpenElement tmpStylePageLayoutOpenElement("style:page-layout");
@@ -2483,10 +2472,10 @@
 +    tmpDrawPageOpenElement.write(mpHandler);
 +
 +    for (std::vector<DocumentElement *>::const_iterator bodyIter = mBodyElements.begin();
-+    	bodyIter != mBodyElements.end(); bodyIter++)
++        bodyIter != mBodyElements.end(); bodyIter++)
 +    {
-+    	(*bodyIter)->write(mpHandler);
-+    }
++        (*bodyIter)->write(mpHandler);
++    }    
 +
 +    mpHandler->endElement("draw:page");
 +    mpHandler->endElement("office:drawing");
@@ -2524,11 +2513,11 @@
 +    pDrawRectElement->addAttribute("svg:height", propList["svg:height"]->getStr());
 +    // FIXME: what to do when rx != ry ?
 +    if (propList["svg:rx"])
-+    	pDrawRectElement->addAttribute("draw:corner-radius", propList["svg:rx"]->getStr());
++        pDrawRectElement->addAttribute("draw:corner-radius", propList["svg:rx"]->getStr());
 +    else
-+    	pDrawRectElement->addAttribute("draw:corner-radius", "0.0000in");
++        pDrawRectElement->addAttribute("draw:corner-radius", "0.0000in");
 +    mBodyElements.push_back(pDrawRectElement);
-+    mBodyElements.push_back(new TagCloseElement("draw:rect"));
++    mBodyElements.push_back(new TagCloseElement("draw:rect"));    
 +}
 +
 +void OdgExporter::drawEllipse(const ::WPXPropertyList &propList)
@@ -2544,30 +2533,30 @@
 +    pDrawEllipseElement->addAttribute("svg:height", sValue);
 +    if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0)
 +    {
-+    	double rotation = propList["libwpg:rotate"]->getDouble();
-+    	while(rotation < -180)
-+    		rotation += 360;
-+    	while(rotation > 180)
-+    		rotation -= 360;
-+    	double radrotation = rotation*M_PI/180.0;
-+    	double deltax = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0)
-+    		+ pow(propList["svg:ry"]->getDouble(), 2.0))*cos(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble())
-+    		- radrotation ) - propList["svg:rx"]->getDouble();
-+    	double deltay = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0)
-+    		+ pow(propList["svg:ry"]->getDouble(), 2.0))*sin(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble())
-+    		- radrotation ) - propList["svg:ry"]->getDouble();
-+    	sValue = "rotate("; sValue.append(doubleToString(radrotation)); sValue.append(") ");
-+    	sValue.append("translate("); sValue.append(doubleToString(propList["svg:cx"]->getDouble() - propList["svg:rx"]->getDouble() - deltax));
-+    	sValue.append("in, ");
-+    	sValue.append(doubleToString(propList["svg:cy"]->getDouble() - propList["svg:ry"]->getDouble() - deltay)); sValue.append("in)");
-+    	pDrawEllipseElement->addAttribute("draw:transform", sValue);
++        double rotation = propList["libwpg:rotate"]->getDouble();
++        while(rotation < -180)
++            rotation += 360;
++        while(rotation > 180)
++            rotation -= 360;
++        double radrotation = rotation*M_PI/180.0;
++        double deltax = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0)
++            + pow(propList["svg:ry"]->getDouble(), 2.0))*cos(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble())
++            - radrotation ) - propList["svg:rx"]->getDouble();
++        double deltay = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0)
++            + pow(propList["svg:ry"]->getDouble(), 2.0))*sin(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble())
++            - radrotation ) - propList["svg:ry"]->getDouble();
++        sValue = "rotate("; sValue.append(doubleToString(radrotation)); sValue.append(") ");
++        sValue.append("translate("); sValue.append(doubleToString(propList["svg:cx"]->getDouble() - propList["svg:rx"]->getDouble() - deltax));
++        sValue.append("in, ");
++        sValue.append(doubleToString(propList["svg:cy"]->getDouble() - propList["svg:ry"]->getDouble() - deltay)); sValue.append("in)");
++        pDrawEllipseElement->addAttribute("draw:transform", sValue);
 +    }
 +    else
 +    {
-+    	sValue = doubleToString(propList["svg:cx"]->getDouble()-propList["svg:rx"]->getDouble()); sValue.append("in");
-+    	pDrawEllipseElement->addAttribute("svg:x", sValue);
-+    	sValue = doubleToString(propList["svg:cy"]->getDouble()-propList["svg:ry"]->getDouble()); sValue.append("in");
-+    	pDrawEllipseElement->addAttribute("svg:y", sValue);
++        sValue = doubleToString(propList["svg:cx"]->getDouble()-propList["svg:rx"]->getDouble()); sValue.append("in");
++        pDrawEllipseElement->addAttribute("svg:x", sValue);
++        sValue = doubleToString(propList["svg:cy"]->getDouble()-propList["svg:ry"]->getDouble()); sValue.append("in");
++        pDrawEllipseElement->addAttribute("svg:y", sValue);
 +    }
 +    mBodyElements.push_back(pDrawEllipseElement);
 +    mBodyElements.push_back(new TagCloseElement("draw:ellipse"));
@@ -2586,52 +2575,52 @@
 +void OdgExporter::drawPolySomething(const ::WPXPropertyListVector& vertices, bool isClosed)
 +{
 +    if(vertices.count() < 2)
-+    	return;
++        return;
 +
 +    if(vertices.count() == 2)
 +    {
-+    	writeGraphicsStyle();
-+    	TagOpenElement *pDrawLineElement = new TagOpenElement("draw:line");
-+    	WPXString sValue;
-+    	sValue.sprintf("gr%i", miGraphicsStyleIndex-1);
-+    	pDrawLineElement->addAttribute("draw:style-name", sValue);
-+    	pDrawLineElement->addAttribute("draw:text-style-name", "P1");
-+    	pDrawLineElement->addAttribute("draw:layer", "layout");
-+    	pDrawLineElement->addAttribute("svg:x1", vertices[0]["svg:x"]->getStr());
-+    	pDrawLineElement->addAttribute("svg:y1", vertices[0]["svg:y"]->getStr());
-+    	pDrawLineElement->addAttribute("svg:x2", vertices[1]["svg:x"]->getStr());
-+    	pDrawLineElement->addAttribute("svg:y2", vertices[1]["svg:y"]->getStr());
-+    	mBodyElements.push_back(pDrawLineElement);
-+    	mBodyElements.push_back(new TagCloseElement("draw:line"));
++        writeGraphicsStyle();
++        TagOpenElement *pDrawLineElement = new TagOpenElement("draw:line");
++        WPXString sValue;
++        sValue.sprintf("gr%i", miGraphicsStyleIndex-1);
++        pDrawLineElement->addAttribute("draw:style-name", sValue);
++        pDrawLineElement->addAttribute("draw:text-style-name", "P1");
++        pDrawLineElement->addAttribute("draw:layer", "layout");
++        pDrawLineElement->addAttribute("svg:x1", vertices[0]["svg:x"]->getStr());
++        pDrawLineElement->addAttribute("svg:y1", vertices[0]["svg:y"]->getStr());
++        pDrawLineElement->addAttribute("svg:x2", vertices[1]["svg:x"]->getStr());
++        pDrawLineElement->addAttribute("svg:y2", vertices[1]["svg:y"]->getStr());
++        mBodyElements.push_back(pDrawLineElement);
++        mBodyElements.push_back(new TagCloseElement("draw:line"));
 +    }
 +    else
 +    {
-+    	::WPXPropertyListVector path;
-+    	::WPXPropertyList element;
-+
-+    	for (unsigned long ii = 0; ii < vertices.count(); ii++)
-+    	{
-+    		element = vertices[ii];
-+    		if (ii == 0)
-+    			element.insert("libwpg:path-action", "M");
-+    		else
-+    			element.insert("libwpg:path-action", "L");
-+    		path.append(element);
-+    		element.clear();
-+    	}
-+    	if (isClosed)
-+    	{
-+    		element.insert("libwpg:path-action", "Z");
-+    		path.append(element);
-+    	}
-+    	drawPath(path);
++        ::WPXPropertyListVector path;
++        ::WPXPropertyList element;
++
++        for (unsigned long ii = 0; ii < vertices.count(); ii++)
++        {
++            element = vertices[ii];
++            if (ii == 0)
++                element.insert("libwpg:path-action", "M");
++            else
++                element.insert("libwpg:path-action", "L");
++            path.append(element);
++            element.clear();
++        }
++        if (isClosed)
++        {
++            element.insert("libwpg:path-action", "Z");
++            path.append(element);
++        }
++        drawPath(path);
 +    }
 +}
 +
 +void OdgExporter::drawPath(const WPXPropertyListVector& path)
 +{
 +    if(path.count() == 0)
-+    	return;
++        return;
 +
 +    // try to find the bounding box
 +    // this is simple convex hull technique, the bounding box might not be
@@ -2642,34 +2631,34 @@
 +    double qy = path[0]["svg:y"]->getDouble();
 +    for(unsigned k = 0; k < path.count(); k++)
 +    {
-+    	if (!path[k]["svg:x"] || !path[k]["svg:y"])
-+    		continue;
-+    	px = (px > path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : px; 
-+    	py = (py > path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : py; 
-+    	qx = (qx < path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : qx; 
-+    	qy = (qy < path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : qy; 
-+    	if(path[k]["libwpg:path-action"]->getStr() == "C")
-+    	{
-+    		px = (px > path[k]["svg:x1"]->getDouble()) ? path[k]["svg:x1"]->getDouble() : px; 
-+    		py = (py > path[k]["svg:y1"]->getDouble()) ? path[k]["svg:y1"]->getDouble() : py; 
-+    		qx = (qx < path[k]["svg:x1"]->getDouble()) ? path[k]["svg:x1"]->getDouble() : qx; 
-+    		qy = (qy < path[k]["svg:y1"]->getDouble()) ? path[k]["svg:y1"]->getDouble() : qy; 
-+    		px = (px > path[k]["svg:x2"]->getDouble()) ? path[k]["svg:x2"]->getDouble() : px; 
-+    		py = (py > path[k]["svg:y2"]->getDouble()) ? path[k]["svg:y2"]->getDouble() : py; 
-+    		qx = (qx < path[k]["svg:x2"]->getDouble()) ? path[k]["svg:x2"]->getDouble() : qx; 
-+    		qy = (qy < path[k]["svg:y2"]->getDouble()) ? path[k]["svg:y2"]->getDouble() : qy; 
-+    	}
-+    	if(path[k]["libwpg:path-action"]->getStr() == "A")
-+    	{
-+    		px = (px > path[k]["svg:x"]->getDouble()-2*path[k]["svg:rx"]->getDouble()) ? path[k]["svg:x"]->getDouble()-2*path[k]["svg:rx"]->getDouble() : px;
-+    		py = (py > path[k]["svg:y"]->getDouble()-2*path[k]["svg:ry"]->getDouble()) ? path[k]["svg:y"]->getDouble()-2*path[k]["svg:ry"]->getDouble() : py;
-+    		qx = (qx < path[k]["svg:x"]->getDouble()+2*path[k]["svg:rx"]->getDouble()) ? path[k]["svg:x"]->getDouble()+2*path[k]["svg:rx"]->getDouble() : qx;
-+    		qy = (qy < path[k]["svg:y"]->getDouble()+2*path[k]["svg:ry"]->getDouble()) ? path[k]["svg:y"]->getDouble()+2*path[k]["svg:ry"]->getDouble() : qy;
-+    	}
++        if (!path[k]["svg:x"] || !path[k]["svg:y"])
++            continue;
++        px = (px > path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : px; 
++        py = (py > path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : py; 
++        qx = (qx < path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : qx; 
++        qy = (qy < path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : qy; 
++        if(path[k]["libwpg:path-action"]->getStr() == "C")
++        {
++            px = (px > path[k]["svg:x1"]->getDouble()) ? path[k]["svg:x1"]->getDouble() : px; 
++            py = (py > path[k]["svg:y1"]->getDouble()) ? path[k]["svg:y1"]->getDouble() : py; 
++            qx = (qx < path[k]["svg:x1"]->getDouble()) ? path[k]["svg:x1"]->getDouble() : qx; 
++            qy = (qy < path[k]["svg:y1"]->getDouble()) ? path[k]["svg:y1"]->getDouble() : qy; 
++            px = (px > path[k]["svg:x2"]->getDouble()) ? path[k]["svg:x2"]->getDouble() : px; 
++            py = (py > path[k]["svg:y2"]->getDouble()) ? path[k]["svg:y2"]->getDouble() : py; 
++            qx = (qx < path[k]["svg:x2"]->getDouble()) ? path[k]["svg:x2"]->getDouble() : qx; 
++            qy = (qy < path[k]["svg:y2"]->getDouble()) ? path[k]["svg:y2"]->getDouble() : qy; 
++        }
++        if(path[k]["libwpg:path-action"]->getStr() == "A")
++        {
++            px = (px > path[k]["svg:x"]->getDouble()-2*path[k]["svg:rx"]->getDouble()) ? path[k]["svg:x"]->getDouble()-2*path[k]["svg:rx"]->getDouble() : px;
++            py = (py > path[k]["svg:y"]->getDouble()-2*path[k]["svg:ry"]->getDouble()) ? path[k]["svg:y"]->getDouble()-2*path[k]["svg:ry"]->getDouble() : py;
++            qx = (qx < path[k]["svg:x"]->getDouble()+2*path[k]["svg:rx"]->getDouble()) ? path[k]["svg:x"]->getDouble()+2*path[k]["svg:rx"]->getDouble() : qx;
++            qy = (qy < path[k]["svg:y"]->getDouble()+2*path[k]["svg:ry"]->getDouble()) ? path[k]["svg:y"]->getDouble()+2*path[k]["svg:ry"]->getDouble() : qy;
++        }
 +    }
 +    double vw = qx - px;
 +    double vh = qy - py;
-+
++        
 +    writeGraphicsStyle();
 +
 +    TagOpenElement *pDrawPathElement = new TagOpenElement("draw:path");
@@ -2693,36 +2682,36 @@
 +    for(unsigned i = 0; i < path.count(); i++)
 +    {
 +        WPXString sElement;
-+    	if (path[i]["libwpg:path-action"]->getStr() == "M")
-+    	{
-+    		// 2540 is 2.54*1000, 2.54 in = 1 inch
-+    	    sElement.sprintf("M%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
-+    			(unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
-+    		sValue.append(sElement);
-+    	}
-+    	else if (path[i]["libwpg:path-action"]->getStr() == "L")
-+    	{
-+    	    sElement.sprintf("L%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
-+    			(unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
-+    		sValue.append(sElement);
-+    	}
-+    	else if (path[i]["libwpg:path-action"]->getStr() == "C")
-+    	{
-+    		sElement.sprintf("C%i %i %i %i %i %i", (unsigned)((path[i]["svg:x1"]->getDouble()-px)*2540),
-+    			(int)((path[i]["svg:y1"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x2"]->getDouble()-px)*2540),
-+    			(int)((path[i]["svg:y2"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
-+    			(unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
-+    		sValue.append(sElement);
-+    	}
-+    	else if (path[i]["libwpg:path-action"]->getStr() == "A")
-+    	{
-+    		sElement.sprintf("A%i %i %i %i %i %i %i", (unsigned)((path[i]["svg:rx"]->getDouble())*2540),
-+    			(int)((path[i]["svg:ry"]->getDouble())*2540), (path[i]["libwpg:rotate"] ? path[i]["libwpg:rotate"]->getInt() : 0), 
-+    			0, 0, (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540), (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
-+    		sValue.append(sElement);
-+    	}
-+    	else if (path[i]["libwpg:path-action"]->getStr() == "Z" && i >= (path.count() - 1))
-+    		sValue.append(" Z");
++        if (path[i]["libwpg:path-action"]->getStr() == "M")
++        {
++            // 2540 is 2.54*1000, 2.54 in = 1 inch
++            sElement.sprintf("M%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
++                (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
++            sValue.append(sElement);
++        }
++        else if (path[i]["libwpg:path-action"]->getStr() == "L")
++        {
++            sElement.sprintf("L%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
++                (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
++            sValue.append(sElement);
++        }
++        else if (path[i]["libwpg:path-action"]->getStr() == "C")
++        {            
++            sElement.sprintf("C%i %i %i %i %i %i", (unsigned)((path[i]["svg:x1"]->getDouble()-px)*2540),
++                (int)((path[i]["svg:y1"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x2"]->getDouble()-px)*2540),
++                (int)((path[i]["svg:y2"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
++                (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
++            sValue.append(sElement);
++        }
++        else if (path[i]["libwpg:path-action"]->getStr() == "A")
++        {            
++            sElement.sprintf("A%i %i %i %i %i %i %i", (unsigned)((path[i]["svg:rx"]->getDouble())*2540),
++                (int)((path[i]["svg:ry"]->getDouble())*2540), (path[i]["libwpg:rotate"] ? path[i]["libwpg:rotate"]->getInt() : 0), 
++                0, 0, (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540), (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
++            sValue.append(sElement);
++        }
++        else if (path[i]["libwpg:path-action"]->getStr() == "Z" && i >= (path.count() - 1))
++            sValue.append(" Z");
 +    }
 +    pDrawPathElement->addAttribute("svg:d", sValue);
 +    mBodyElements.push_back(pDrawPathElement);
@@ -2732,32 +2721,32 @@
 +void OdgExporter::drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData)
 +{
 +    if (!propList["libwpg:mime-type"] && propList["libwpg:mime-type"]->getStr().len() <= 0)
-+    	return;
++        return;
 +    TagOpenElement *pDrawFrameElement = new TagOpenElement("draw:frame");
-+
-+
++    
++    
 +    WPXString sValue;
 +    if (propList["svg:x"])
-+    	pDrawFrameElement->addAttribute("svg:x", propList["svg:x"]->getStr());
++        pDrawFrameElement->addAttribute("svg:x", propList["svg:x"]->getStr());
 +    if (propList["svg:y"])
-+    	pDrawFrameElement->addAttribute("svg:y", propList["svg:y"]->getStr());
++        pDrawFrameElement->addAttribute("svg:y", propList["svg:y"]->getStr());
 +    if (propList["svg:height"])
-+    	pDrawFrameElement->addAttribute("svg:height", propList["svg:height"]->getStr());
++        pDrawFrameElement->addAttribute("svg:height", propList["svg:height"]->getStr());
 +    if (propList["svg:width"])
-+    	pDrawFrameElement->addAttribute("svg:width", propList["svg:width"]->getStr());
++        pDrawFrameElement->addAttribute("svg:width", propList["svg:width"]->getStr());
 +    mBodyElements.push_back(pDrawFrameElement);
-+
++    
 +    mBodyElements.push_back(new TagOpenElement("draw:image"));
-+
++    
 +    mBodyElements.push_back(new TagOpenElement("office:binary-data"));
-+
++    
 +    ::WPXString base64Binary = binaryData.getBase64Data();
 +    mBodyElements.push_back(new CharDataElement(base64Binary.cstr()));
-+
++    
 +    mBodyElements.push_back(new TagCloseElement("office:binary-data"));
-+
++    
 +    mBodyElements.push_back(new TagCloseElement("draw:image"));
-+
++    
 +    mBodyElements.push_back(new TagCloseElement("draw:frame"));
 +}
 +
@@ -2766,57 +2755,57 @@
 +#if 0
 +    if(mxStyle["libwpg:stroke-solid"] && !mxStyle["libwpg:stroke-solid"]->getInt() && (mxDashArray.count() >=2 ) )
 +    {
-+    	// ODG only supports dashes with the same length of spaces inbetween
-+    	// here we take the first space and assume everything else the same
-+    	// note that dash length is written in percentage ?????????????????
-+    	double distance = mxDashArray.at(1);
-+    	TagOpenElement *pDrawStrokeDashElement = new TagOpenElement("draw:stroke-dash");
-+    	pDrawStrokeDashElement->addAttribute("draw:style", "rect");
-+    	WPXString sValue;
-+    	sValue.sprintf("Dash_%i", miDashIndex++);
-+    	pDrawStrokeDashElement->addAttribute("draw:name", sValue);
-+    	sValue = doubleToString(distance); sValue.append("in");
-+    	pDrawStrokeDashElement->addAttribute("draw:distance", sValue);
-+    	WPXString sName;
-+    	// We have to find out how to do this intelligently, since the ODF is allowing only
-+    	// two pairs draw:dots1 draw:dots1-length and draw:dots2 draw:dots2-length
-+    	for(unsigned i = 0; i < mxDashArray.count()/2 && i < 2; i++)
-+    	{
-+    		sName.sprintf("draw:dots%i", i+1);
-+    		pDrawStrokeDashElement->addAttribute(sName.cstr(), "1");
-+    		sName.sprintf("draw:dots%i-length", i+1);
-+    		sValue = doubleToString(mxDashArray.at(i*2)); sValue.append("in");
-+    		pDrawStrokeDashElement->addAttribute(sName.cstr(), sValue);
-+    	}
-+    	mGraphicsStrokeDashStyles.push_back(pDrawStrokeDashElement);
-+    	mGraphicsStrokeDashStyles.push_back(new TagCloseElement("draw:stroke-dash"));
++        // ODG only supports dashes with the same length of spaces inbetween
++        // here we take the first space and assume everything else the same
++        // note that dash length is written in percentage ?????????????????
++        double distance = mxDashArray.at(1);
++        TagOpenElement *pDrawStrokeDashElement = new TagOpenElement("draw:stroke-dash");
++        pDrawStrokeDashElement->addAttribute("draw:style", "rect");
++        WPXString sValue;
++        sValue.sprintf("Dash_%i", miDashIndex++);
++        pDrawStrokeDashElement->addAttribute("draw:name", sValue);
++        sValue = doubleToString(distance); sValue.append("in");
++        pDrawStrokeDashElement->addAttribute("draw:distance", sValue);
++        WPXString sName;
++        // We have to find out how to do this intelligently, since the ODF is allowing only
++        // two pairs draw:dots1 draw:dots1-length and draw:dots2 draw:dots2-length
++        for(unsigned i = 0; i < mxDashArray.count()/2 && i < 2; i++)
++        {
++            sName.sprintf("draw:dots%i", i+1);
++            pDrawStrokeDashElement->addAttribute(sName.cstr(), "1");
++            sName.sprintf("draw:dots%i-length", i+1);
++            sValue = doubleToString(mxDashArray.at(i*2)); sValue.append("in");
++            pDrawStrokeDashElement->addAttribute(sName.cstr(), sValue);
++        }
++        mGraphicsStrokeDashStyles.push_back(pDrawStrokeDashElement);
++        mGraphicsStrokeDashStyles.push_back(new TagCloseElement("draw:stroke-dash"));
 +    }
 +#endif
 +    if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "gradient" && mxGradient.count() >= 2)
 +    {
-+    	TagOpenElement *pDrawGradientElement = new TagOpenElement("draw:gradient");
-+    	pDrawGradientElement->addAttribute("draw:style", "linear");
-+    	WPXString sValue;
-+    	sValue.sprintf("Gradient_%i", miGradientIndex++);
-+    	pDrawGradientElement->addAttribute("draw:name", sValue);
-+
-+    	// ODG angle unit is 0.1 degree
-+    	double angle = mxStyle["draw:angle"] ? -mxStyle["draw:angle"]->getDouble() : 0.0;
-+    	while(angle < 0)
-+    		angle += 360;
-+    	while(angle > 360)
-+    		angle -= 360;
-+
-+    	sValue.sprintf("%i", (unsigned)(angle*10));
-+    	pDrawGradientElement->addAttribute("draw:angle", sValue);
-+
-+    	pDrawGradientElement->addAttribute("draw:start-color", mxGradient[0]["svg:stop-color"]->getStr().cstr());
-+    	pDrawGradientElement->addAttribute("draw:end-color", mxGradient[1]["svg:stop-color"]->getStr().cstr());
-+    	pDrawGradientElement->addAttribute("draw:start-intensity", "100%");
-+    	pDrawGradientElement->addAttribute("draw:end-intensity", "100%");
-+    	pDrawGradientElement->addAttribute("draw:border", "0%");
-+    	mGraphicsGradientStyles.push_back(pDrawGradientElement);
-+    	mGraphicsGradientStyles.push_back(new TagCloseElement("draw:gradient"));
++        TagOpenElement *pDrawGradientElement = new TagOpenElement("draw:gradient");
++        pDrawGradientElement->addAttribute("draw:style", "linear");
++        WPXString sValue;
++        sValue.sprintf("Gradient_%i", miGradientIndex++);
++        pDrawGradientElement->addAttribute("draw:name", sValue);
++
++        // ODG angle unit is 0.1 degree
++        double angle = mxStyle["draw:angle"] ? -mxStyle["draw:angle"]->getDouble() : 0.0;
++        while(angle < 0)
++            angle += 360;
++        while(angle > 360)
++            angle -= 360;
++
++        sValue.sprintf("%i", (unsigned)(angle*10));
++        pDrawGradientElement->addAttribute("draw:angle", sValue);
++
++        pDrawGradientElement->addAttribute("draw:start-color", mxGradient[0]["svg:stop-color"]->getStr().cstr());
++        pDrawGradientElement->addAttribute("draw:end-color", mxGradient[1]["svg:stop-color"]->getStr().cstr());
++        pDrawGradientElement->addAttribute("draw:start-intensity", "100%");
++        pDrawGradientElement->addAttribute("draw:end-intensity", "100%");
++        pDrawGradientElement->addAttribute("draw:border", "0%");
++        mGraphicsGradientStyles.push_back(pDrawGradientElement);
++        mGraphicsGradientStyles.push_back(new TagCloseElement("draw:gradient"));
 +    }
 +
 +    TagOpenElement *pStyleStyleElement = new TagOpenElement("style:style");
@@ -2831,51 +2820,51 @@
 +
 +    if(!(mxStyle["draw:stroke"] && mxStyle["draw:stroke"]->getStr() == "none") && mxStyle["svg:stroke-width"] && mxStyle["svg:stroke-width"]->getDouble() > 0.0)
 +    {
-+    	if (mxStyle["svg:stroke-width"])
-+    		pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-width", mxStyle["svg:stroke-width"]->getStr());
-+
-+    	if (mxStyle["svg:stroke-color"])
-+    		pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-color", mxStyle["svg:stroke-color"]->getStr());
-+    	if (mxStyle["svg:stroke-opacity"] && mxStyle["svg:stroke-opacity"]->getDouble() != 1.0)
-+    		pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-opacity", mxStyle["svg:stroke-opacity"]->getStr());
++        if (mxStyle["svg:stroke-width"])
++            pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-width", mxStyle["svg:stroke-width"]->getStr());
 +
++        if (mxStyle["svg:stroke-color"])
++            pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-color", mxStyle["svg:stroke-color"]->getStr());
++        if (mxStyle["svg:stroke-opacity"] && mxStyle["svg:stroke-opacity"]->getDouble() != 1.0)
++            pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-opacity", mxStyle["svg:stroke-opacity"]->getStr());
++            
 +
-+    	if(mxStyle["libwpg:stroke-solid"] && mxStyle["libwpg:stroke-solid"]->getInt())
-+    		pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "solid");
++        if(mxStyle["libwpg:stroke-solid"] && mxStyle["libwpg:stroke-solid"]->getInt())
++            pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "solid");
 +#if 0
-+    	else
-+    	{
-+    		pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "dash");
-+    		sValue.sprintf("Dash_%i", miDashIndex-1);
-+    		pStyleGraphicsPropertiesElement->addAttribute("draw:stroke-dash", sValue);
-+    	}
++        else
++        {
++            pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "dash");
++            sValue.sprintf("Dash_%i", miDashIndex-1);
++            pStyleGraphicsPropertiesElement->addAttribute("draw:stroke-dash", sValue);
++        }
 +#endif
 +    }
 +    else
-+    	pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "none");
++        pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "none");
 +
 +    if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "none")
-+    	pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "none");
++        pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "none");
 +
 +    if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "solid")
 +    {
-+    	pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "solid");
-+    	if (mxStyle["draw:fill-color"])
-+    		pStyleGraphicsPropertiesElement->addAttribute("draw:fill-color", mxStyle["draw:fill-color"]->getStr());
-+    	if (mxStyle["draw:opacity"] && mxStyle["draw:opacity"]->getDouble() != 1.0)

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list