[Libreoffice-commits] .: writerperfect/source
Fridrich Strba
fridrich at kemper.freedesktop.org
Fri May 6 14:35:13 PDT 2011
writerperfect/source/filter/DocumentCollector.cxx | 1317 -------------
writerperfect/source/filter/DocumentCollector.hxx | 251 --
writerperfect/source/filter/DocumentElement.cxx | 55
writerperfect/source/filter/DocumentElement.hxx | 29
writerperfect/source/filter/DocumentHandler.hxx | 4
writerperfect/source/filter/DocumentHandlerInterface.hxx | 48
writerperfect/source/filter/FilterInternal.hxx | 14
writerperfect/source/filter/FontStyle.cxx | 8
writerperfect/source/filter/FontStyle.hxx | 8
writerperfect/source/filter/GraphicsStyle.cxx | 43
writerperfect/source/filter/GraphicsStyle.hxx | 43
writerperfect/source/filter/InternalHandler.cxx | 19
writerperfect/source/filter/InternalHandler.hxx | 9
writerperfect/source/filter/ListStyle.cxx | 31
writerperfect/source/filter/ListStyle.hxx | 16
writerperfect/source/filter/OdfDocumentHandler.hxx | 45
writerperfect/source/filter/OdgExporter.cxx | 650 ------
writerperfect/source/filter/OdgExporter.hxx | 93
writerperfect/source/filter/OdgGenerator.cxx | 767 +++++++
writerperfect/source/filter/OdgGenerator.hxx | 67
writerperfect/source/filter/OdtGenerator.cxx | 1487 +++++++++++++++
writerperfect/source/filter/OdtGenerator.hxx | 119 +
writerperfect/source/filter/PageSpan.cxx | 23
writerperfect/source/filter/PageSpan.hxx | 13
writerperfect/source/filter/SectionStyle.cxx | 13
writerperfect/source/filter/SectionStyle.hxx | 7
writerperfect/source/filter/Style.hxx | 9
writerperfect/source/filter/TableStyle.cxx | 33
writerperfect/source/filter/TableStyle.hxx | 19
writerperfect/source/filter/TextRunStyle.cxx | 68
writerperfect/source/filter/TextRunStyle.hxx | 10
writerperfect/source/filter/WriterProperties.hxx | 7
writerperfect/source/filter/makefile.mk | 17
writerperfect/source/stream/WPXSvStream.cxx | 2
writerperfect/source/wpdimp/WordPerfectCollector.cxx | 62
writerperfect/source/wpdimp/WordPerfectCollector.hxx | 48
writerperfect/source/wpdimp/WordPerfectImportFilter.cxx | 34
writerperfect/source/wpdimp/makefile.mk | 1
writerperfect/source/wpgimp/WPGImportFilter.cxx | 4
writerperfect/source/wpsimp/MSWorksCollector.cxx | 51
writerperfect/source/wpsimp/MSWorksCollector.hxx | 45
writerperfect/source/wpsimp/MSWorksImportFilter.cxx | 17
writerperfect/source/wpsimp/makefile.mk | 1
43 files changed, 2678 insertions(+), 2929 deletions(-)
New commits:
commit 871471fe640eff6ed1b2ef8e8f2bcd2d99eb621e
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Fri May 6 23:34:35 2011 +0200
Refactor writerperfect
diff --git a/writerperfect/source/filter/DocumentCollector.cxx b/writerperfect/source/filter/DocumentCollector.cxx
deleted file mode 100644
index cae7736..0000000
--- a/writerperfect/source/filter/DocumentCollector.cxx
+++ /dev/null
@@ -1,1317 +0,0 @@
-/* -*- 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
- * to a Writer target document
- *
- * Copyright (C) 2002-2004 William Lachance (william.lachance at sympatico.ca)
- * Copyright (C) 2003-2004 Net Integration Technologies (http://www.net-itech.com)
- * Copyright (C) 2004 Fridrich Strba (fridrich.strba at bluewin.ch)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * For further information visit http://libwpd.sourceforge.net
- *
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#if defined _MSC_VER
-#pragma warning( push, 1 )
-#endif
-#include <libwpd/libwpd.h>
-#if defined _MSC_VER
-#pragma warning( pop )
-#endif
-#include <string.h> // for strcmp
-
-#include "DocumentCollector.hxx"
-#include "DocumentElement.hxx"
-#include "DocumentHandler.hxx"
-#include "InternalHandler.hxx"
-#include "TextRunStyle.hxx"
-#include "FontStyle.hxx"
-#include "ListStyle.hxx"
-#include "PageSpan.hxx"
-#include "SectionStyle.hxx"
-#include "TableStyle.hxx"
-#include "FilterInternal.hxx"
-#include "WriterProperties.hxx"
-#include "OdgExporter.hxx"
-
-_WriterDocumentState::_WriterDocumentState() :
- mbFirstElement(true),
- mbFirstParagraphInPageSpan(true),
- mbInFakeSection(false),
- mbListElementOpenedAtCurrentLevel(false),
- mbTableCellOpened(false),
- mbHeaderRow(false),
- mbInNote(false),
- mbInTextBox(false),
- mbInFrame(false)
-{
-}
-
-_WriterListState::_WriterListState() :
- mpCurrentListStyle(NULL),
- miCurrentListLevel(0),
- miLastListLevel(0),
- miLastListNumber(0),
- mbListContinueNumbering(false),
- mbListElementParagraphOpened(false),
- mbListElementOpened()
-{
-}
-
-DocumentCollector::DocumentCollector(WPXInputStream *pInput, DocumentHandlerInterface *pHandler) :
- mpInput(pInput),
- mpHandler(pHandler),
- mbUsed(false),
- mWriterDocumentStates(),
- mWriterListStates(),
- mfSectionSpaceAfter(0.0),
- miNumListStyles(0),
- mpCurrentContentElements(&mBodyElements),
- mpCurrentPageSpan(NULL),
- miNumPageStyles(0),
- miObjectNumber(0),
- mbIsFlatXML(true),
- mpPassword(NULL)
-{
- mWriterDocumentStates.push(WriterDocumentState());
- mWriterListStates.push(WriterListState());
-}
-
-DocumentCollector::~DocumentCollector()
-{
-}
-
-bool DocumentCollector::filter()
-{
- // The contract for DocumentCollector is that it will only be used once after it is
- // instantiated
- if (mbUsed)
- return false;
-
- mbUsed = true;
-
- // parse & write
- // WLACH_REFACTORING: Remove these args..
- if (!parseSourceDocument(*mpInput))
- return false;
- if (!_writeTargetDocument(mpHandler))
- return false;
-
- // clean up the mess we made
- WRITER_DEBUG_MSG(("WriterWordPerfect: Cleaning up our mess..\n"));
-
- WRITER_DEBUG_MSG(("Destroying the body elements\n"));
- for (std::vector<DocumentElement *>::iterator iterBody = mBodyElements.begin(); iterBody != mBodyElements.end(); ++iterBody) {
- delete (*iterBody);
- (*iterBody) = NULL;
- }
-
- WRITER_DEBUG_MSG(("Destroying the styles elements\n"));
- for (std::vector<DocumentElement *>::iterator iterStyles = mStylesElements.begin(); iterStyles != mStylesElements.end(); ++iterStyles) {
- delete (*iterStyles);
- (*iterStyles) = NULL; // we may pass over the same element again (in the case of headers/footers spanning multiple pages)
- // so make sure we don't do a double del
- }
-
- 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);
- }
- for (std::map<WPXString, SpanStyle *, ltstr>::iterator iterSpanStyle = mSpanStyleHash.begin(); iterSpanStyle != mSpanStyleHash.end(); ++iterSpanStyle) {
- delete(iterSpanStyle->second);
- }
-
- for (std::map<WPXString, FontStyle *, ltstr>::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); ++iterFont) {
- delete(iterFont->second);
- }
-
- for (std::vector<ListStyle *>::iterator iterListStyles = mListStyles.begin(); iterListStyles != mListStyles.end(); ++iterListStyles) {
- delete (*iterListStyles);
- }
- for (std::vector<SectionStyle *>::iterator iterSectionStyles = mSectionStyles.begin(); iterSectionStyles != mSectionStyles.end(); ++iterSectionStyles) {
- delete (*iterSectionStyles);
- }
- for (std::vector<TableStyle *>::iterator iterTableStyles = mTableStyles.begin(); iterTableStyles != mTableStyles.end(); ++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);
- }
- for (std::vector<DocumentElement *>::iterator iterFrameAutomaticStyles = mFrameAutomaticStyles.begin();
- iterFrameAutomaticStyles != mFrameAutomaticStyles.end(); ++iterFrameAutomaticStyles) {
- delete(*iterFrameAutomaticStyles);
- }
- for (std::vector<DocumentElement *>::iterator iterMetaData = mMetaData.begin(); iterMetaData != mMetaData.end(); ++iterMetaData) {
- delete(*iterMetaData);
- }
-
- return true;
-}
-
-void DocumentCollector::_writeDefaultStyles(DocumentHandlerInterface *pHandler)
-{
- TagOpenElement("office:styles").write(pHandler);
-
- TagOpenElement defaultParagraphStyleOpenElement("style:default-style");
- defaultParagraphStyleOpenElement.addAttribute("style:family", "paragraph");
- defaultParagraphStyleOpenElement.write(pHandler);
-
- TagOpenElement defaultParagraphStylePropertiesOpenElement("style:paragraph-properties");
- defaultParagraphStylePropertiesOpenElement.addAttribute("style:tab-stop-distance", "0.5in");
- defaultParagraphStylePropertiesOpenElement.write(pHandler);
- TagCloseElement defaultParagraphStylePropertiesCloseElement("style:paragraph-properties");
- defaultParagraphStylePropertiesCloseElement.write(pHandler);
-
- pHandler->endElement("style:default-style");
-
- TagOpenElement defaultTableRowStyleOpenElement("style:default-style");
- defaultTableRowStyleOpenElement.addAttribute("style:family", "table-row");
- defaultTableRowStyleOpenElement.write(pHandler);
-
- TagOpenElement defaultTableRowPropertiesOpenElement("style:table-row-properties");
- defaultTableRowPropertiesOpenElement.addAttribute("fo:keep-together", "auto");
- defaultTableRowPropertiesOpenElement.write(pHandler);
-
- pHandler->endElement("style:table-row-properties");
- pHandler->endElement("style:default-style");
-
- TagOpenElement standardStyleOpenElement("style:style");
- standardStyleOpenElement.addAttribute("style:name", "Standard");
- standardStyleOpenElement.addAttribute("style:family", "paragraph");
- standardStyleOpenElement.addAttribute("style:class", "text");
- standardStyleOpenElement.write(pHandler);
-
- pHandler->endElement("style:style");
-
- TagOpenElement textBodyStyleOpenElement("style:style");
- textBodyStyleOpenElement.addAttribute("style:name", "Text_Body");
- textBodyStyleOpenElement.addAttribute("style:display-name", "Text Body");
- textBodyStyleOpenElement.addAttribute("style:family", "paragraph");
- textBodyStyleOpenElement.addAttribute("style:parent-style-name", "Standard");
- textBodyStyleOpenElement.addAttribute("style:class", "text");
- textBodyStyleOpenElement.write(pHandler);
-
- pHandler->endElement("style:style");
-
- TagOpenElement tableContentsStyleOpenElement("style:style");
- tableContentsStyleOpenElement.addAttribute("style:name", "Table_Contents");
- tableContentsStyleOpenElement.addAttribute("style:display-name", "Table Contents");
- tableContentsStyleOpenElement.addAttribute("style:family", "paragraph");
- tableContentsStyleOpenElement.addAttribute("style:parent-style-name", "Text_Body");
- tableContentsStyleOpenElement.addAttribute("style:class", "extra");
- tableContentsStyleOpenElement.write(pHandler);
-
- pHandler->endElement("style:style");
-
- TagOpenElement tableHeadingStyleOpenElement("style:style");
- tableHeadingStyleOpenElement.addAttribute("style:name", "Table_Heading");
- tableHeadingStyleOpenElement.addAttribute("style:display-name", "Table Heading");
- tableHeadingStyleOpenElement.addAttribute("style:family", "paragraph");
- tableHeadingStyleOpenElement.addAttribute("style:parent-style-name", "Table_Contents");
- tableHeadingStyleOpenElement.addAttribute("style:class", "extra");
- tableHeadingStyleOpenElement.write(pHandler);
-
- pHandler->endElement("style:style");
-
- for (std::vector<DocumentElement *>::const_iterator iter = mFrameStyles.begin();
- iter != mFrameStyles.end(); ++iter)
- (*iter)->write(pHandler);
-
- pHandler->endElement("office:styles");
-}
-
-void DocumentCollector::_writeMasterPages(DocumentHandlerInterface *pHandler)
-{
- TagOpenElement("office:master-styles").write(mpHandler);
- int pageNumber = 1;
- for (unsigned int i=0; i<mPageSpans.size(); i++)
- {
- bool bLastPage;
- (i == (mPageSpans.size() - 1)) ? bLastPage = true : bLastPage = false;
- mPageSpans[i]->writeMasterPages(pageNumber, i, bLastPage, pHandler);
- pageNumber += mPageSpans[i]->getSpan();
- }
- pHandler->endElement("office:master-styles");
-}
-
-void DocumentCollector::_writePageLayouts(DocumentHandlerInterface *pHandler)
-{
- for (unsigned int i=0; i<mPageSpans.size(); i++)
- {
- mPageSpans[i]->writePageLayout(i, pHandler);
- }
-}
-
-bool DocumentCollector::_writeTargetDocument(DocumentHandlerInterface *pHandler)
-{
- WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Printing out the header stuff..\n"));
-
- WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Start Document\n"));
- mpHandler->startDocument();
-
- WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: preamble\n"));
- WPXPropertyList docContentPropList;
- docContentPropList.insert("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
- docContentPropList.insert("xmlns:meta", "urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
- docContentPropList.insert("xmlns:dc", "http://purl.org/dc/elements/1.1/");
- docContentPropList.insert("xmlns:config", "urn:oasis:names:tc:opendocument:xmlns:config:1.0");
- docContentPropList.insert("xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
- docContentPropList.insert("xmlns:table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0");
- docContentPropList.insert("xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
- docContentPropList.insert("xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
- docContentPropList.insert("xmlns:xlink", "http://www.w3.org/1999/xlink");
- docContentPropList.insert("xmlns:number", "http://openoffice.org/2000/datastyle");
- docContentPropList.insert("xmlns:svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
- docContentPropList.insert("xmlns:chart", "urn:oasis:names:tc:opendocument:xmlns:chart:1.0");
- docContentPropList.insert("xmlns:dr3d", "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0");
- docContentPropList.insert("xmlns:math", "http://www.w3.org/1998/Math/MathML");
- docContentPropList.insert("xmlns:form", "urn:oasis:names:tc:opendocument:xmlns:form:1.0");
- docContentPropList.insert("xmlns:script", "urn:oasis:names:tc:opendocument:xmlns:script:1.0");
- docContentPropList.insert("xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
- docContentPropList.insert("office:version", "1.0");
- docContentPropList.insert("office:mimetype", "application/vnd.oasis.opendocument.text");
- mpHandler->startElement("office:document", docContentPropList);
-
- // write out the metadata
- TagOpenElement("office:meta").write(mpHandler);
- for (std::vector<DocumentElement *>::const_iterator iterMetaData = mMetaData.begin(); iterMetaData != mMetaData.end(); ++iterMetaData) {
- (*iterMetaData)->write(mpHandler);
- }
- mpHandler->endElement("office:meta");
-
- // write out the font styles
- TagOpenElement("office:font-face-decls").write(mpHandler);
- for (std::map<WPXString, FontStyle *, ltstr>::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); ++iterFont) {
- iterFont->second->write(mpHandler);
- }
- TagOpenElement symbolFontOpen("style:font-face");
- symbolFontOpen.addAttribute("style:name", "StarSymbol");
- symbolFontOpen.addAttribute("svg:font-family", "StarSymbol");
- symbolFontOpen.addAttribute("style:font-charset", "x-symbol");
- symbolFontOpen.write(mpHandler);
- mpHandler->endElement("style:font-face");
-
- mpHandler->endElement("office:font-face-decls");
-
- WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Writing out the styles..\n"));
-
- // write default styles
- _writeDefaultStyles(mpHandler);
-
- TagOpenElement("office:automatic-styles").write(mpHandler);
-
- for (std::vector<DocumentElement *>::const_iterator iterFrameAutomaticStyles = mFrameAutomaticStyles.begin();
- iterFrameAutomaticStyles != mFrameAutomaticStyles.end(); ++iterFrameAutomaticStyles)
- {
- (*iterFrameAutomaticStyles)->write(pHandler);
- }
-
- for (std::map<WPXString, ParagraphStyle *, ltstr>::const_iterator iterTextStyle = mTextStyleHash.begin();
- iterTextStyle != mTextStyleHash.end(); ++iterTextStyle)
- {
- // writing out the paragraph styles
- if (strcmp((iterTextStyle->second)->getName().cstr(), "Standard"))
- {
- // don't write standard paragraph "no styles" style
- (iterTextStyle->second)->write(pHandler);
- }
- }
-
- // span styles..
- for (std::map<WPXString, SpanStyle *, ltstr>::const_iterator iterSpanStyle = mSpanStyleHash.begin();
- iterSpanStyle != mSpanStyleHash.end(); ++iterSpanStyle)
- {
- (iterSpanStyle->second)->write(pHandler);
- }
-
- // writing out the sections styles
- for (std::vector<SectionStyle *>::const_iterator iterSectionStyles = mSectionStyles.begin(); iterSectionStyles != mSectionStyles.end(); ++iterSectionStyles) {
- (*iterSectionStyles)->write(pHandler);
- }
-
- // writing out the lists styles
- for (std::vector<ListStyle *>::const_iterator iterListStyles = mListStyles.begin(); iterListStyles != mListStyles.end(); ++iterListStyles) {
- (*iterListStyles)->write(pHandler);
- }
-
- // writing out the table styles
- for (std::vector<TableStyle *>::const_iterator iterTableStyles = mTableStyles.begin(); iterTableStyles != mTableStyles.end(); ++iterTableStyles) {
- (*iterTableStyles)->write(pHandler);
- }
-
- // writing out the page masters
- _writePageLayouts(pHandler);
-
-
- pHandler->endElement("office:automatic-styles");
-
- _writeMasterPages(pHandler);
-
- WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Writing out the document..\n"));
- // writing out the document
- TagOpenElement("office:body").write(mpHandler);
- TagOpenElement("office:text").write(mpHandler);
-
- for (std::vector<DocumentElement *>::const_iterator iterBodyElements = mBodyElements.begin(); iterBodyElements != mBodyElements.end(); ++iterBodyElements) {
- (*iterBodyElements)->write(pHandler);
- }
- WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Finished writing all doc els..\n"));
-
- pHandler->endElement("office:text");
- pHandler->endElement("office:body");
- pHandler->endElement("office:document");
-
- pHandler->endDocument();
-
- return true;
-}
-
-
-WPXString propListToStyleKey(const WPXPropertyList & xPropList)
-{
- WPXString sKey;
- WPXPropertyList::Iter i(xPropList);
- for (i.rewind(); i.next(); )
- {
- WPXString sProp;
- sProp.sprintf("[%s:%s]", i.key(), i()->getStr().cstr());
- sKey.append(sProp);
- }
-
- return sKey;
-}
-
-WPXString getParagraphStyleKey(const WPXPropertyList & xPropList, const WPXPropertyListVector & xTabStops)
-{
- WPXString sKey = propListToStyleKey(xPropList);
-
- WPXString sTabStops;
- sTabStops.sprintf("[num-tab-stops:%i]", xTabStops.count());
- WPXPropertyListVector::Iter i(xTabStops);
- for (i.rewind(); i.next();)
- {
- sTabStops.append(propListToStyleKey(i()));
- }
- sKey.append(sTabStops);
-
- return sKey;
-}
-
-// _allocateFontName: add a (potentially mapped) font style to the hash if it's not already there, do nothing otherwise
-void DocumentCollector::_allocateFontName(const WPXString & sFontName)
-{
- if (mFontHash.find(sFontName) == mFontHash.end())
- {
- FontStyle *pFontStyle = new FontStyle(sFontName.cstr(), sFontName.cstr());
- mFontHash[sFontName] = pFontStyle;
- }
-}
-
-void DocumentCollector::setDocumentMetaData(const WPXPropertyList &propList)
-{
- WPXPropertyList::Iter i(propList);
- for (i.rewind(); i.next(); )
- {
- // 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()));
- }
- }
-
-}
-
-void DocumentCollector::openPageSpan(const WPXPropertyList &propList)
-{
- PageSpan *pPageSpan = new PageSpan(propList);
- mPageSpans.push_back(pPageSpan);
- mpCurrentPageSpan = pPageSpan;
- miNumPageStyles++;
-
- mWriterDocumentStates.top().mbFirstParagraphInPageSpan = true;
-}
-
-static bool
-isOccurrenceEven (const WPXPropertyList &propList)
-{
- const WPXProperty *occurance = propList["libwpd:occurence"];
- return occurance && occurance->getStr() == "even";
-}
-
-void DocumentCollector::openHeader(const WPXPropertyList &propList)
-{
- std::vector<DocumentElement *> * pHeaderFooterContentElements = new std::vector<DocumentElement *>;
- if (isOccurrenceEven (propList))
- mpCurrentPageSpan->setHeaderLeftContent(pHeaderFooterContentElements);
- else
- mpCurrentPageSpan->setHeaderContent(pHeaderFooterContentElements);
-
- mpCurrentContentElements = pHeaderFooterContentElements;
-}
-
-void DocumentCollector::closeHeader()
-{
- mpCurrentContentElements = &mBodyElements;
-}
-
-void DocumentCollector::openFooter(const WPXPropertyList &propList)
-{
- std::vector<DocumentElement *> * pHeaderFooterContentElements = new std::vector<DocumentElement *>;
-
- if (isOccurrenceEven (propList))
- mpCurrentPageSpan->setFooterLeftContent(pHeaderFooterContentElements);
- else
- mpCurrentPageSpan->setFooterContent(pHeaderFooterContentElements);
-
- mpCurrentContentElements = pHeaderFooterContentElements;
-}
-
-void DocumentCollector::closeFooter()
-{
- mpCurrentContentElements = &mBodyElements;
-}
-
-void DocumentCollector::openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
-{
- int iNumColumns = columns.count();
- double fSectionMarginLeft = 0.0;
- double fSectionMarginRight = 0.0;
- if (propList["fo:margin-left"])
- fSectionMarginLeft = propList["fo:margin-left"]->getDouble();
- if (propList["fo:margin-right"])
- fSectionMarginRight = propList["fo:margin-right"]->getDouble();
-
- if (iNumColumns > 1 || fSectionMarginLeft != 0 || fSectionMarginRight != 0)
- {
- 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());
-
- SectionStyle *pSectionStyle = new SectionStyle(propList, columns, sSectionName.cstr());
- mSectionStyles.push_back(pSectionStyle);
-
- TagOpenElement *pSectionOpenElement = new TagOpenElement("text:section");
- pSectionOpenElement->addAttribute("text:style-name", pSectionStyle->getName());
- pSectionOpenElement->addAttribute("text:name", pSectionStyle->getName());
- mpCurrentContentElements->push_back(pSectionOpenElement);
- }
- else
- mWriterDocumentStates.top().mbInFakeSection = true;
-}
-
-void DocumentCollector::closeSection()
-{
- if (!mWriterDocumentStates.top().mbInFakeSection)
- mpCurrentContentElements->push_back(new TagCloseElement("text:section"));
- else
- mWriterDocumentStates.top().mbInFakeSection = false;
-
- mfSectionSpaceAfter = 0.0;
-}
-
-void DocumentCollector::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
-{
- // FIXMENOW: What happens if we open a footnote inside a table? do we then inherit the footnote's style
- // from "Table Contents"
-
- WPXPropertyList *pPersistPropList = new WPXPropertyList(propList);
- ParagraphStyle *pStyle = NULL;
-
- if (mWriterDocumentStates.top().mbFirstElement && mpCurrentContentElements == &mBodyElements)
- {
- // we don't have to go through the fuss of determining if the paragraph style is
- // unique in this case, because if we are the first document element, then we
- // are singular. Neither do we have to determine what our parent style is-- we can't
- // be inside a table in this case (the table would be the first document element
- //in that case)
- pPersistPropList->insert("style:parent-style-name", "Standard");
- WPXString sName;
- sName.sprintf("FS");
-
- WPXString sParagraphHashKey("P|FS");
- pPersistPropList->insert("style:master-page-name", "Page_Style_1");
- pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
- mTextStyleHash[sParagraphHashKey] = pStyle;
- mWriterDocumentStates.top().mbFirstElement = false;
- mWriterDocumentStates.top().mbFirstParagraphInPageSpan = false;
- }
- else
- {
- 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().mbHeaderRow)
- pPersistPropList->insert("style:parent-style-name", "Table_Heading");
- else
- pPersistPropList->insert("style:parent-style-name", "Table_Contents");
- }
- else
- pPersistPropList->insert("style:parent-style-name", "Standard");
-
- WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
-
- if (mTextStyleHash.find(sKey) == mTextStyleHash.end())
- {
- WPXString sName;
- sName.sprintf("S%i", mTextStyleHash.size());
-
- pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
-
- mTextStyleHash[sKey] = pStyle;
- }
- else
- {
- pStyle = mTextStyleHash[sKey];
- delete pPersistPropList;
- }
- }
- // create a document element corresponding to the paragraph, and append it to our list of document elements
- TagOpenElement *pParagraphOpenElement = new TagOpenElement("text:p");
- pParagraphOpenElement->addAttribute("text:style-name", pStyle->getName());
- mpCurrentContentElements->push_back(pParagraphOpenElement);
-}
-
-void DocumentCollector::closeParagraph()
-{
- mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
-}
-
-void DocumentCollector::openSpan(const WPXPropertyList &propList)
-{
- if (propList["style:font-name"])
- _allocateFontName(propList["style:font-name"]->getStr());
- WPXString sSpanHashKey = propListToStyleKey(propList);
- WRITER_DEBUG_MSG(("WriterWordPerfect: Span Hash Key: %s\n", sSpanHashKey.cstr()));
-
- // Get the style
- WPXString sName;
- if (mSpanStyleHash.find(sSpanHashKey) == mSpanStyleHash.end())
- {
- // allocate a new paragraph style
- sName.sprintf("Span%i", mSpanStyleHash.size());
- SpanStyle *pStyle = new SpanStyle(sName.cstr(), propList);
-
- mSpanStyleHash[sSpanHashKey] = pStyle;
- }
- else
- {
- sName.sprintf("%s", mSpanStyleHash.find(sSpanHashKey)->second->getName().cstr());
- }
-
- // create a document element corresponding to the paragraph, and append it to our list of document elements
- TagOpenElement *pSpanOpenElement = new TagOpenElement("text:span");
- pSpanOpenElement->addAttribute("text:style-name", sName.cstr());
- mpCurrentContentElements->push_back(pSpanOpenElement);
-}
-
-void DocumentCollector::closeSpan()
-{
- mpCurrentContentElements->push_back(new TagCloseElement("text:span"));
-}
-
-void DocumentCollector::defineOrderedListLevel(const WPXPropertyList &propList)
-{
- int id = 0;
- if (propList["libwpd:id"])
- id = propList["libwpd:id"]->getInt();
-
- OrderedListStyle *pOrderedListStyle = NULL;
- if (mWriterListStates.top().mpCurrentListStyle && mWriterListStates.top().mpCurrentListStyle->getListID() == id)
- pOrderedListStyle = static_cast<OrderedListStyle *>(mWriterListStates.top().mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
-
- // this rather appalling conditional makes sure we only start a new list (rather than continue an old
- // one) if: (1) we have no prior list OR (2) the prior list is actually definitively different
- // from the list that is just being defined (listIDs differ) OR (3) we can tell that the user actually
- // is starting a new list at level 1 (and only level 1)
- if (pOrderedListStyle == NULL || pOrderedListStyle->getListID() != id ||
- (propList["libwpd:level"] && propList["libwpd:level"]->getInt()==1 &&
- (propList["text:start-value"] && propList["text:start-value"]->getInt() != static_cast<int>(mWriterListStates.top().miLastListNumber+1))))
- {
- WRITER_DEBUG_MSG(("Attempting to create a new ordered list style (listid: %i)\n", id));
- WPXString sName;
- sName.sprintf("OL%i", miNumListStyles);
- miNumListStyles++;
- pOrderedListStyle = new OrderedListStyle(sName.cstr(), id);
- mListStyles.push_back(pOrderedListStyle);
- mWriterListStates.top().mpCurrentListStyle = pOrderedListStyle;
- mWriterListStates.top().mbListContinueNumbering = false;
- mWriterListStates.top().miLastListNumber = 0;
- }
- else
- mWriterListStates.top().mbListContinueNumbering = true;
-
- // Iterate through ALL list styles with the same WordPerfect list id and define a level if it is not already defined
- // This solves certain problems with lists that start and finish without reaching certain levels and then begin again
- // and reach those levels. See gradguide0405_PC.wpd in the regression suite
- for (std::vector<ListStyle *>::iterator iterOrderedListStyles = mListStyles.begin(); iterOrderedListStyles != mListStyles.end(); ++iterOrderedListStyles)
- {
- if ((* iterOrderedListStyles)->getListID() == id)
- (* iterOrderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList);
- }
-}
-
-void DocumentCollector::defineUnorderedListLevel(const WPXPropertyList &propList)
-{
- int id = 0;
- if (propList["libwpd:id"])
- id = propList["libwpd:id"]->getInt();
-
- UnorderedListStyle *pUnorderedListStyle = NULL;
- if (mWriterListStates.top().mpCurrentListStyle && mWriterListStates.top().mpCurrentListStyle->getListID() == id)
- pUnorderedListStyle = static_cast<UnorderedListStyle *>(mWriterListStates.top().mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?!
-
- if (pUnorderedListStyle == NULL) {
- WRITER_DEBUG_MSG(("Attempting to create a new unordered list style (listid: %i)\n", id));
- WPXString sName;
- sName.sprintf("UL%i", miNumListStyles);
- miNumListStyles++;
- pUnorderedListStyle = new UnorderedListStyle(sName.cstr(), id);
- mListStyles.push_back(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() == id)
- (* iterUnorderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList);
- }
-}
-
-void DocumentCollector::openOrderedListLevel(const WPXPropertyList & /* propList */)
-{
- if (mWriterListStates.top().mbListElementParagraphOpened)
- {
- mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
- mWriterListStates.top().mbListElementParagraphOpened = false;
- }
- TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:list");
- _openListLevel(pListLevelOpenElement);
-
- if (mWriterListStates.top().mbListContinueNumbering) {
- pListLevelOpenElement->addAttribute("text:continue-numbering", "true");
- }
-
- mpCurrentContentElements->push_back(pListLevelOpenElement);
-}
-
-void DocumentCollector::openUnorderedListLevel(const WPXPropertyList & /* propList */)
-{
- if (mWriterListStates.top().mbListElementParagraphOpened)
- {
- mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
- mWriterListStates.top().mbListElementParagraphOpened = false;
- }
- TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:list");
- _openListLevel(pListLevelOpenElement);
-
- mpCurrentContentElements->push_back(pListLevelOpenElement);
-}
-
-void DocumentCollector::_openListLevel(TagOpenElement *pListLevelOpenElement)
-{
- if (!mWriterListStates.top().mbListElementOpened.empty() &&
- !mWriterListStates.top().mbListElementOpened.top())
- {
- mpCurrentContentElements->push_back(new TagOpenElement("text:list-item"));
- mWriterListStates.top().mbListElementOpened.top() = true;
- }
-
- mWriterListStates.top().mbListElementOpened.push(false);
- if (mWriterListStates.top().mbListElementOpened.size() == 1) {
- pListLevelOpenElement->addAttribute("text:style-name", mWriterListStates.top().mpCurrentListStyle->getName());
- }
-}
-
-void DocumentCollector::closeOrderedListLevel()
-{
- _closeListLevel();
-}
-
-void DocumentCollector::closeUnorderedListLevel()
-{
- _closeListLevel();
-}
-
-void DocumentCollector::_closeListLevel()
-{
- 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"));
-
- if (!mWriterListStates.top().mbListElementOpened.empty())
- {
- mWriterListStates.top().mbListElementOpened.pop();
- }
-}
-
-void DocumentCollector::openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
-{
- mWriterListStates.top().miLastListLevel = mWriterListStates.top().miCurrentListLevel;
- if (mWriterListStates.top().miCurrentListLevel == 1)
- mWriterListStates.top().miLastListNumber++;
-
- if (mWriterListStates.top().mbListElementOpened.top())
- {
- mpCurrentContentElements->push_back(new TagCloseElement("text:list-item"));
- mWriterListStates.top().mbListElementOpened.top() = false;
- }
-
- ParagraphStyle *pStyle = NULL;
-
- WPXPropertyList *pPersistPropList = new WPXPropertyList(propList);
- pPersistPropList->insert("style:list-style-name", mWriterListStates.top().mpCurrentListStyle->getName());
- pPersistPropList->insert("style:parent-style-name", "Standard");
-
- WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
-
- if (mTextStyleHash.find(sKey) == mTextStyleHash.end())
- {
- WPXString sName;
- sName.sprintf("S%i", mTextStyleHash.size());
-
- pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
-
- mTextStyleHash[sKey] = pStyle;
- }
- else
- {
- pStyle = mTextStyleHash[sKey];
- delete pPersistPropList;
- }
-
- mpCurrentContentElements->push_back(new TagOpenElement("text:list-item"));
-
- TagOpenElement *pOpenListElementParagraph = new TagOpenElement("text:p");
- pOpenListElementParagraph->addAttribute("text:style-name", pStyle->getName());
- mpCurrentContentElements->push_back(pOpenListElementParagraph);
-
- if (mpCurrentContentElements == &mBodyElements)
- mWriterDocumentStates.top().mbFirstParagraphInPageSpan = false;
-
- mWriterListStates.top().mbListElementOpened.top() = true;
- mWriterListStates.top().mbListElementParagraphOpened = true;
- mWriterListStates.top().mbListContinueNumbering = false;
-}
-
-void DocumentCollector::closeListElement()
-{
- // this code is kind of tricky, because we don't actually close the list element (because this list element
- // could contain another list level in OOo's implementation of lists). that is done in the closeListLevel
- // code (or when we open another list element)
-
- if (mWriterListStates.top().mbListElementParagraphOpened)
- {
- mpCurrentContentElements->push_back(new TagCloseElement("text:p"));
- mWriterListStates.top().mbListElementParagraphOpened = false;
- }
-}
-
-void DocumentCollector::openFootnote(const WPXPropertyList &propList)
-{
- mWriterListStates.push(WriterListState());
- TagOpenElement *pOpenFootNote = new TagOpenElement("text:note");
- pOpenFootNote->addAttribute("text:note-class", "footnote");
- if (propList["libwpd:number"])
- {
- WPXString tmpString("ftn");
- tmpString.append(propList["libwpd:number"]->getStr());
- pOpenFootNote->addAttribute("text:id", tmpString);
- }
- mpCurrentContentElements->push_back(pOpenFootNote);
-
- mpCurrentContentElements->push_back(new TagOpenElement("text:note-citation"));
- if (propList["libwpd:number"])
- mpCurrentContentElements->push_back(new CharDataElement(propList["libwpd:number"]->getStr().cstr()));
- mpCurrentContentElements->push_back(new TagCloseElement("text:note-citation"));
-
- mpCurrentContentElements->push_back(new TagOpenElement("text:note-body"));
-
- mWriterDocumentStates.top().mbInNote = true;
-}
-
-void DocumentCollector::closeFootnote()
-{
- mWriterDocumentStates.top().mbInNote = false;
- if (mWriterListStates.size() > 1)
- mWriterListStates.pop();
-
- mpCurrentContentElements->push_back(new TagCloseElement("text:note-body"));
- mpCurrentContentElements->push_back(new TagCloseElement("text:note"));
-}
-
-void DocumentCollector::openEndnote(const WPXPropertyList &propList)
-{
- mWriterListStates.push(WriterListState());
- TagOpenElement *pOpenEndNote = new TagOpenElement("text:note");
- pOpenEndNote->addAttribute("text:note-class", "endnote");
- if (propList["libwpd:number"])
- {
- WPXString tmpString("edn");
- tmpString.append(propList["libwpd:number"]->getStr());
- pOpenEndNote->addAttribute("text:id", tmpString);
- }
- mpCurrentContentElements->push_back(pOpenEndNote);
-
- mpCurrentContentElements->push_back(new TagOpenElement("text:note-citation"));
- if (propList["libwpd:number"])
- mpCurrentContentElements->push_back(new CharDataElement(propList["libwpd:number"]->getStr().cstr()));
- mpCurrentContentElements->push_back(new TagCloseElement("text:note-citation"));
-
- mpCurrentContentElements->push_back(new TagOpenElement("text:note-body"));
-
- mWriterDocumentStates.top().mbInNote = true;
-}
-
-void DocumentCollector::closeEndnote()
-{
- mWriterDocumentStates.top().mbInNote = false;
- if (mWriterListStates.size() > 1)
- mWriterListStates.pop();
-
- mpCurrentContentElements->push_back(new TagCloseElement("text:note-body"));
- mpCurrentContentElements->push_back(new TagCloseElement("text:note"));
-}
-
-void DocumentCollector::openComment(const WPXPropertyList & /*propList*/)
-{
- mWriterListStates.push(WriterListState());
- mpCurrentContentElements->push_back(new TagOpenElement("office:annotation"));
-
- mWriterDocumentStates.top().mbInNote = true;
-}
-
-void DocumentCollector::closeComment()
-{
- mWriterDocumentStates.top().mbInNote = false;
- if (mWriterListStates.size() > 1)
- mWriterListStates.pop();
-
- mpCurrentContentElements->push_back(new TagCloseElement("office:annotation"));
-}
-
-void DocumentCollector::openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
-{
- if (!mWriterDocumentStates.top().mbInNote)
- {
- WPXString sTableName;
- sTableName.sprintf("Table%i", mTableStyles.size());
-
- // FIXME: we base the table style off of the page's margin left, ignoring (potential) wordperfect margin
- // state which is transmitted inside the page. could this lead to unacceptable behaviour?
- // WLACH_REFACTORING: characterize this behaviour, probably should nip it at the bud within libwpd
- TableStyle *pTableStyle = new TableStyle(propList, columns, sTableName.cstr());
-
- if (mWriterDocumentStates.top().mbFirstElement && mpCurrentContentElements == &mBodyElements)
- {
- WPXString sMasterPageName("Page_Style_1");
- pTableStyle->setMasterPageName(sMasterPageName);
- mWriterDocumentStates.top().mbFirstElement = false;
- }
-
- mTableStyles.push_back(pTableStyle);
-
- mpCurrentTableStyle = pTableStyle;
-
- TagOpenElement *pTableOpenElement = new TagOpenElement("table:table");
-
- pTableOpenElement->addAttribute("table:name", sTableName.cstr());
- pTableOpenElement->addAttribute("table:style-name", sTableName.cstr());
- mpCurrentContentElements->push_back(pTableOpenElement);
-
- for (int i=0; i<pTableStyle->getNumColumns(); i++)
- {
- TagOpenElement *pTableColumnOpenElement = new TagOpenElement("table:table-column");
- WPXString sColumnStyleName;
- sColumnStyleName.sprintf("%s.Column%i", sTableName.cstr(), (i+1));
- pTableColumnOpenElement->addAttribute("table:style-name", sColumnStyleName.cstr());
- mpCurrentContentElements->push_back(pTableColumnOpenElement);
-
- TagCloseElement *pTableColumnCloseElement = new TagCloseElement("table:table-column");
- mpCurrentContentElements->push_back(pTableColumnCloseElement);
- }
-}
-}
-
-void DocumentCollector::openTableRow(const WPXPropertyList &propList)
-{
- if (!mWriterDocumentStates.top().mbInNote)
- {
- if (propList["libwpd:is-header-row"] && (propList["libwpd:is-header-row"]->getInt()))
- {
- mpCurrentContentElements->push_back(new TagOpenElement("table:table-header-rows"));
- mWriterDocumentStates.top().mbHeaderRow = true;
- }
-
- WPXString sTableRowStyleName;
- sTableRowStyleName.sprintf("%s.Row%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableRowStyles());
- TableRowStyle *pTableRowStyle = new TableRowStyle(propList, sTableRowStyleName.cstr());
- mpCurrentTableStyle->addTableRowStyle(pTableRowStyle);
-
- TagOpenElement *pTableRowOpenElement = new TagOpenElement("table:table-row");
- pTableRowOpenElement->addAttribute("table:style-name", sTableRowStyleName);
- mpCurrentContentElements->push_back(pTableRowOpenElement);
- }
-}
-
-void DocumentCollector::closeTableRow()
-{
- if (!mWriterDocumentStates.top().mbInNote)
- {
- 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;
- }
- }
-}
-
-void DocumentCollector::openTableCell(const WPXPropertyList &propList)
-{
- if (!mWriterDocumentStates.top().mbInNote)
- {
- WPXString sTableCellStyleName;
- sTableCellStyleName.sprintf( "%s.Cell%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableCellStyles());
- TableCellStyle *pTableCellStyle = new TableCellStyle(propList, sTableCellStyleName.cstr());
- mpCurrentTableStyle->addTableCellStyle(pTableCellStyle);
-
- TagOpenElement *pTableCellOpenElement = new TagOpenElement("table:table-cell");
- pTableCellOpenElement->addAttribute("table:style-name", sTableCellStyleName);
- if (propList["table:number-columns-spanned"])
- pTableCellOpenElement->addAttribute("table:number-columns-spanned",
- propList["table:number-columns-spanned"]->getStr().cstr());
- if (propList["table:number-rows-spanned"])
- pTableCellOpenElement->addAttribute("table:number-rows-spanned",
- propList["table:number-rows-spanned"]->getStr().cstr());
- mpCurrentContentElements->push_back(pTableCellOpenElement);
-
- mWriterDocumentStates.top().mbTableCellOpened = true;
- }
-}
-
-void DocumentCollector::closeTableCell()
-{
- if (!mWriterDocumentStates.top().mbInNote)
- {
- mpCurrentContentElements->push_back(new TagCloseElement("table:table-cell"));
- mWriterDocumentStates.top().mbTableCellOpened = false;
- }
-}
-
-void DocumentCollector::insertCoveredTableCell(const WPXPropertyList & /* propList */)
-{
- if (!mWriterDocumentStates.top().mbInNote)
- {
- mpCurrentContentElements->push_back(new TagOpenElement("table:covered-table-cell"));
- mpCurrentContentElements->push_back(new TagCloseElement("table:covered-table-cell"));
- }
-}
-
-void DocumentCollector::closeTable()
-{
- if (!mWriterDocumentStates.top().mbInNote)
- {
- mpCurrentContentElements->push_back(new TagCloseElement("table:table"));
- }
-}
-
-
-void DocumentCollector::insertTab()
-{
- mpCurrentContentElements->push_back(new TagOpenElement("text:tab"));
- mpCurrentContentElements->push_back(new TagCloseElement("text:tab"));
-}
-
-void DocumentCollector::insertSpace()
-{
- mpCurrentContentElements->push_back(new TagOpenElement("text:s"));
- mpCurrentContentElements->push_back(new TagCloseElement("text:s"));
-}
-
-void DocumentCollector::insertLineBreak()
-{
- mpCurrentContentElements->push_back(new TagOpenElement("text:line-break"));
- mpCurrentContentElements->push_back(new TagCloseElement("text:line-break"));
-}
-
-void DocumentCollector::insertField(const WPXString &type, const WPXPropertyList &propList)
-{
- if (!type.len())
- return;
-
- TagOpenElement *openElement = new TagOpenElement(type.cstr());
- if (type == "text:page-number")
- openElement->addAttribute("text:select-page", "current");
-
- if (propList["style:num-format"])
- 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)
-{
- DocumentElement *pText = new TextElement(text);
- mpCurrentContentElements->push_back(pText);
-}
-
-void DocumentCollector::openFrame(const WPXPropertyList &propList)
-{
- mWriterListStates.push(WriterListState());
-
- // First, let's create a Frame Style for this box
- TagOpenElement *frameStyleOpenElement = new TagOpenElement("style:style");
- WPXString frameStyleName;
- frameStyleName.sprintf("GraphicFrame_%i", miObjectNumber);
- frameStyleOpenElement->addAttribute("style:name", frameStyleName);
- frameStyleOpenElement->addAttribute("style:family", "graphic");
-
- mFrameStyles.push_back(frameStyleOpenElement);
-
- TagOpenElement *frameStylePropertiesOpenElement = new TagOpenElement("style:graphic-properties");
-
- if (propList["text:anchor-type"])
- frameStylePropertiesOpenElement->addAttribute("text:anchor-type", propList["text:anchor-type"]->getStr());
- else
- frameStylePropertiesOpenElement->addAttribute("text:anchor-type","paragraph");
-
- if (propList["text:anchor-page-number"])
- frameStylePropertiesOpenElement->addAttribute("text:anchor-page-number", propList["text:anchor-page-number"]->getStr());
-
- if (propList["svg:x"])
- frameStylePropertiesOpenElement->addAttribute("svg:x", propList["svg:x"]->getStr());
-
- if (propList["svg:y"])
- frameStylePropertiesOpenElement->addAttribute("svg:y", propList["svg:y"]->getStr());
-
- if (propList["svg:width"])
- frameStylePropertiesOpenElement->addAttribute("svg:width", propList["svg:width"]->getStr());
-
- if (propList["svg:height"])
- frameStylePropertiesOpenElement->addAttribute("svg:height", propList["svg:height"]->getStr());
-
- if (propList["style:rel-width"])
- 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());
-
- if (propList["fo:max-width"])
- 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());
-
- if (propList["style:wrap"])
- frameStylePropertiesOpenElement->addAttribute("style:wrap", propList["style:wrap"]->getStr());
-
- mFrameStyles.push_back(frameStylePropertiesOpenElement);
-
- mFrameStyles.push_back(new TagCloseElement("style:graphic-properties"));
-
- mFrameStyles.push_back(new TagCloseElement("style:style"));
-
- // Now, let's create an automatic style for this frame
- TagOpenElement *frameAutomaticStyleElement = new TagOpenElement("style:style");
- WPXString frameAutomaticStyleName;
- frameAutomaticStyleName.sprintf("fr%i", miObjectNumber);
- frameAutomaticStyleElement->addAttribute("style:name", frameAutomaticStyleName);
- frameAutomaticStyleElement->addAttribute("style:family", "graphic");
- frameAutomaticStyleElement->addAttribute("style:parent-style-name", frameStyleName);
-
- mFrameAutomaticStyles.push_back(frameAutomaticStyleElement);
-
- TagOpenElement *frameAutomaticStylePropertiesElement = new TagOpenElement("style:graphic-properties");
- if (propList["style:horizontal-pos"])
- frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-pos", propList["style:horizontal-pos"]->getStr());
- else
- frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-pos", "left");
-
- if (propList["style:horizontal-rel"])
- frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-rel", propList["style:horizontal-rel"]->getStr());
- else
- frameAutomaticStylePropertiesElement->addAttribute("style:horizontal-rel", "paragraph");
-
- if (propList["style:vertical-pos"])
- frameAutomaticStylePropertiesElement->addAttribute("style:vertical-pos", propList["style:vertical-pos"]->getStr());
- else
- frameAutomaticStylePropertiesElement->addAttribute("style:vertical-pos", "top");
-
- if (propList["style:vertical-rel"])
- frameAutomaticStylePropertiesElement->addAttribute("style:vertical-rel", propList["style:vertical-rel"]->getStr());
- else
- frameAutomaticStylePropertiesElement->addAttribute("style:vertical-rel", "page-content");
-
- if (propList["fo:max-width"])
- 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("draw:ole-draw-aspect", "1");
-
- mFrameAutomaticStyles.push_back(frameAutomaticStylePropertiesElement);
-
- mFrameAutomaticStyles.push_back(new TagCloseElement("style:graphic-properties"));
-
- mFrameAutomaticStyles.push_back(new TagCloseElement("style:style"));
-
- // And write the frame itself
- TagOpenElement *drawFrameOpenElement = new TagOpenElement("draw:frame");
-
- drawFrameOpenElement->addAttribute("draw:style-name", frameAutomaticStyleName);
- WPXString objectName;
- 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());
- else
- drawFrameOpenElement->addAttribute("text:anchor-type","paragraph");
-
- if (propList["text:anchor-page-number"])
- drawFrameOpenElement->addAttribute("text:anchor-page-number", propList["text:anchor-page-number"]->getStr());
-
- if (propList["svg:x"])
- drawFrameOpenElement->addAttribute("svg:x", propList["svg:x"]->getStr());
-
- if (propList["svg:y"])
- drawFrameOpenElement->addAttribute("svg:y", propList["svg:y"]->getStr());
-
- if (propList["svg:width"])
- drawFrameOpenElement->addAttribute("svg:width", propList["svg:width"]->getStr());
-
- if (propList["svg:height"])
- drawFrameOpenElement->addAttribute("svg:height", propList["svg:height"]->getStr());
-
- if (propList["style:rel-width"])
- 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());
-
- mpCurrentContentElements->push_back(drawFrameOpenElement);
-
- mWriterDocumentStates.top().mbInFrame = true;
-}
-
-void DocumentCollector::closeFrame()
-{
- if (mWriterListStates.size() > 1)
- mWriterListStates.pop();
-
- mpCurrentContentElements->push_back(new TagCloseElement("draw:frame"));
-
- mWriterDocumentStates.top().mbInFrame = false;
-}
-
-void DocumentCollector::insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData &data)
-{
- if (!data.size())
- return;
- if (!mWriterDocumentStates.top().mbInFrame) // Embedded objects without a frame simply don't make sense for us
- return;
- if (!propList["libwpd:mimetype"])
- return;
-
- if (propList["libwpd:mimetype"]->getStr() == "image/x-wpg")
- {
- 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"));
- }
-}
-
-void DocumentCollector::openTextBox(const WPXPropertyList & /*propList*/)
-{
- if (!mWriterDocumentStates.top().mbInFrame) // Text box without a frame simply doesn't make sense for us
- return;
- mWriterListStates.push(WriterListState());
- mWriterDocumentStates.push(WriterDocumentState());
- mpCurrentContentElements->push_back(new TagOpenElement("draw:text-box"));
- mWriterDocumentStates.top().mbInTextBox = true;
- mWriterDocumentStates.top().mbFirstElement = false;
-}
-
-void DocumentCollector::closeTextBox()
-{
- if (!mWriterDocumentStates.top().mbInTextBox)
- return;
- if (mWriterListStates.size() > 1)
- mWriterListStates.pop();
- if (mWriterDocumentStates.size() > 1)
- mWriterDocumentStates.pop();
-
- mpCurrentContentElements->push_back(new TagCloseElement("draw:text-box"));
-}
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/DocumentCollector.hxx b/writerperfect/source/filter/DocumentCollector.hxx
deleted file mode 100644
index 6d0d353..0000000
--- a/writerperfect/source/filter/DocumentCollector.hxx
+++ /dev/null
@@ -1,251 +0,0 @@
-/* -*- 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
- * to a target file
- *
- * Copyright (C) 2002-2004 William Lachance (william.lachance at sympatico.ca)
- * Copyright (C) 2003-2004 Net Integration Technologies (http://www.net-itech.com)
- * Copyright (C) 2004 Fridrich Strba (fridrich.strba at bluewin.ch)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * For further information visit http://libwpd.sourceforge.net
- *
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef _DOCUMENTCOLLECTOR_HXX
-#define _DOCUMENTCOLLECTOR_HXX
-#include "SectionStyle.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>
-#include <stack>
-#include <string.h>
-
-#include "DocumentHandlerInterface.hxx"
-
-class DocumentElement;
-class TagOpenElement;
-class FontStyle;
-class ListStyle;
-
-class ParagraphStyle;
-class SpanStyle;
-class TableStyle;
-class PageSpan;
-
-// the state we use for writing the final document
-typedef struct _WriterDocumentState WriterDocumentState;
-struct _WriterDocumentState
-{
- _WriterDocumentState();
-
- bool mbFirstElement;
- bool mbFirstParagraphInPageSpan;
- bool mbInFakeSection;
- bool mbListElementOpenedAtCurrentLevel;
- bool mbTableCellOpened;
- bool mbHeaderRow;
- bool mbInNote;
- bool mbInTextBox;
- bool mbInFrame;
-};
-
-// list state
-typedef struct _WriterListState WriterListState;
-struct _WriterListState
-{
- _WriterListState();
-
- ListStyle *mpCurrentListStyle;
- unsigned int miCurrentListLevel;
- unsigned int miLastListLevel;
- unsigned int miLastListNumber;
- bool mbListContinueNumbering;
- bool mbListElementParagraphOpened;
- std::stack<bool> mbListElementOpened;
-};
-
-enum WriterListType { unordered, ordered };
-
-struct ltstr
-{
- bool operator()(const WPXString & s1, const WPXString & s2) const
- {
- return strcmp(s1.cstr(), s2.cstr()) < 0;
- }
-};
-
-class DocumentCollector : public WPXDocumentInterface
-{
-public:
- DocumentCollector(WPXInputStream *pInput, DocumentHandlerInterface *pHandler);
- virtual ~DocumentCollector();
- bool filter();
-
- // WPXDocumentInterface's callbacks
- virtual void setDocumentMetaData(const WPXPropertyList &propList);
- virtual void startDocument() {}
- virtual void endDocument() {}
-
- virtual void definePageStyle(const WPXPropertyList&) {}
- virtual void openPageSpan(const WPXPropertyList &propList);
- virtual void closePageSpan() {}
-
- virtual void defineSectionStyle(const WPXPropertyList&, const WPXPropertyListVector&) {}
- virtual void openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
- virtual void closeSection();
-
- virtual void openHeader(const WPXPropertyList &propList);
- virtual void closeHeader();
- virtual void openFooter(const WPXPropertyList &propList);
- virtual void closeFooter();
-
- virtual void defineParagraphStyle(const WPXPropertyList&, const WPXPropertyListVector&) {}
- virtual void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
- virtual void closeParagraph();
-
- virtual void defineCharacterStyle(const WPXPropertyList&) {}
- virtual void openSpan(const WPXPropertyList &propList);
- virtual void closeSpan();
-
- virtual void insertTab();
- virtual void insertSpace();
- virtual void insertText(const WPXString &text);
- virtual void insertLineBreak();
- virtual void insertField(const WPXString &type, const WPXPropertyList &propList);
-
- virtual void defineOrderedListLevel(const WPXPropertyList &propList);
- virtual void defineUnorderedListLevel(const WPXPropertyList &propList);
- virtual void openOrderedListLevel(const WPXPropertyList &propList);
- virtual void openUnorderedListLevel(const WPXPropertyList &propList);
- virtual void closeOrderedListLevel();
- virtual void closeUnorderedListLevel();
- virtual void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
- virtual void closeListElement();
-
- virtual void openFootnote(const WPXPropertyList &propList);
- virtual void closeFootnote();
- virtual void openEndnote(const WPXPropertyList &propList);
- virtual void closeEndnote();
- virtual void openComment(const WPXPropertyList &propList);
- virtual void closeComment();
- virtual void openTextBox(const WPXPropertyList &propList);
- virtual void closeTextBox();
-
- virtual void openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
- virtual void openTableRow(const WPXPropertyList &propList);
- virtual void closeTableRow();
- virtual void openTableCell(const WPXPropertyList &propList);
- virtual void closeTableCell();
- virtual void insertCoveredTableCell(const WPXPropertyList &propList);
- virtual void closeTable();
-
- virtual void openFrame(const WPXPropertyList & propList);
- virtual void closeFrame();
-
- 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();
- bool _writeTargetDocument(DocumentHandlerInterface *pHandler);
- void _writeDefaultStyles(DocumentHandlerInterface *pHandler);
- void _writeMasterPages(DocumentHandlerInterface *pHandler);
- void _writePageLayouts(DocumentHandlerInterface *pHandler);
- void _allocateFontName(const WPXString &);
-
-private:
- void _openListLevel(TagOpenElement *pListLevelOpenElement);
- void _closeListLevel();
-
- WPXInputStream *mpInput;
- DocumentHandlerInterface *mpHandler;
- bool mbUsed; // whether or not it has been before (you can only use me once!)
-
- std::stack<WriterDocumentState> mWriterDocumentStates;
-
- std::stack<WriterListState> mWriterListStates;
-
- // paragraph styles
- std::map<WPXString, ParagraphStyle *, ltstr> mTextStyleHash;
-
- // span styles
- std::map<WPXString, SpanStyle *, ltstr> mSpanStyleHash;
-
- // font styles
- std::map<WPXString, FontStyle *, ltstr> mFontHash;
-
- // section styles
- std::vector<SectionStyle *> mSectionStyles;
- double mfSectionSpaceAfter;
-
- // table styles
- std::vector<TableStyle *> mTableStyles;
-
- // frame styles
- std::vector<DocumentElement *> mFrameStyles;
-
- std::vector<DocumentElement *> mFrameAutomaticStyles;
-
- // metadata
- std::vector<DocumentElement *> mMetaData;
-
- // list styles
- unsigned int miNumListStyles;
-
- // style elements
- std::vector<DocumentElement *> mStylesElements;
- // content elements
- std::vector<DocumentElement *> mBodyElements;
- // the current set of elements that we're writing to
- std::vector<DocumentElement *> * mpCurrentContentElements;
-
- // page state
- std::vector<PageSpan *> mPageSpans;
- PageSpan *mpCurrentPageSpan;
- int miNumPageStyles;
-
- // list styles
- std::vector<ListStyle *> mListStyles;
-
- // object state
- unsigned miObjectNumber;
-
- // table state
- TableStyle *mpCurrentTableStyle;
-
- const bool mbIsFlatXML;
-
- const char * mpPassword;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/DocumentElement.cxx b/writerperfect/source/filter/DocumentElement.cxx
index 18380e1..578afb1 100644
--- a/writerperfect/source/filter/DocumentElement.cxx
+++ b/writerperfect/source/filter/DocumentElement.cxx
@@ -1,8 +1,7 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* DocumentElement: The items we are collecting to be put into the Writer
* document: paragraph and spans of text, as well as section breaks.
*
- * Copyright (C) 2002-2003 William Lachance (william.lachance at sympatico.ca)
+ * Copyright (C) 2002-2003 William Lachance (wrlach at gmail.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -27,7 +26,7 @@
*/
#include "DocumentElement.hxx"
-#include "DocumentHandler.hxx"
+#include "OdfDocumentHandler.hxx"
#include "FilterInternal.hxx"
#include <string.h>
@@ -38,71 +37,37 @@ void TagElement::print() const
WRITER_DEBUG_MSG(("%s\n", msTagName.cstr()));
}
-void TagOpenElement::write(DocumentHandlerInterface *pHandler) const
+void TagOpenElement::write(OdfDocumentHandler *pHandler) const
{
pHandler->startElement(getTagName().cstr(), maAttrList);
}
void TagOpenElement::print() const
{
- TagElement::print();
+ TagElement::print();
}
-void TagOpenElement::addAttribute(const char *szAttributeName, const WPXString &sAttributeValue)
+void TagOpenElement::addAttribute(const WPXString &szAttributeName, const WPXString &sAttributeValue)
{
- maAttrList.insert(szAttributeName, sAttributeValue);
+ maAttrList.insert(szAttributeName.cstr(), sAttributeValue);
}
-void TagCloseElement::write(DocumentHandlerInterface *pHandler) const
+void TagCloseElement::write(OdfDocumentHandler *pHandler) const
{
WRITER_DEBUG_MSG(("TagCloseElement: write (%s)\n", getTagName().cstr()));
pHandler->endElement(getTagName().cstr());
}
-void CharDataElement::write(DocumentHandlerInterface *pHandler) const
+void CharDataElement::write(OdfDocumentHandler *pHandler) const
{
WRITER_DEBUG_MSG(("TextElement: write\n"));
pHandler->characters(msData);
}
-TextElement::TextElement(const WPXString & sTextBuf) :
- msTextBuf(sTextBuf, false)
-{
-}
-
-// write: writes a text run, appropriately converting spaces to <text:s>
-// elements
-void TextElement::write(DocumentHandlerInterface *pHandler) const
+void TextElement::write(OdfDocumentHandler *pHandler) const
{
if (msTextBuf.len() <= 0)
return;
- WPXPropertyList xBlankAttrList;
-
- WPXString sTemp;
-
- int iNumConsecutiveSpaces = 0;
- WPXString::Iter i(msTextBuf);
- for (i.rewind(); i.next();)
- {
- if (*(i()) == ASCII_SPACE)
- iNumConsecutiveSpaces++;
- else
- iNumConsecutiveSpaces = 0;
-
- if (iNumConsecutiveSpaces > 1) {
- if (sTemp.len() > 0) {
- pHandler->characters(sTemp);
- sTemp.clear();
- }
- pHandler->startElement("text:s", xBlankAttrList);
- pHandler->endElement("text:s");
- }
- else {
- sTemp.append(i());
- }
- }
- pHandler->characters(sTemp);
+ pHandler->characters(msTextBuf);
}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/DocumentElement.hxx b/writerperfect/source/filter/DocumentElement.hxx
index cb84777..6de5db3 100644
--- a/writerperfect/source/filter/DocumentElement.hxx
+++ b/writerperfect/source/filter/DocumentElement.hxx
@@ -1,8 +1,7 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* DocumentElement: The items we are collecting to be put into the Writer
* document: paragraph and spans of text, as well as section breaks.
*
- * Copyright (C) 2002-2003 William Lachance (william.lachance at sympatico.ca)
+ * Copyright (C) 2002-2003 William Lachance (wrlach at gmail.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -33,13 +32,13 @@
#include <libwpd/WPXString.h>
#include <vector>
-#include "DocumentHandlerInterface.hxx"
+#include "OdfDocumentHandler.hxx"
class DocumentElement
{
public:
virtual ~DocumentElement() {}
- virtual void write(DocumentHandlerInterface *pHandler) const = 0;
+ virtual void write(OdfDocumentHandler *pHandler) const = 0;
virtual void print() const {}
};
@@ -47,7 +46,7 @@ class TagElement : public DocumentElement
{
public:
virtual ~TagElement() {}
- TagElement(const char *szTagName) : msTagName(szTagName) {}
+ TagElement(const WPXString &szTagName) : msTagName(szTagName) {}
const WPXString & getTagName() const { return msTagName; }
virtual void print() const;
private:
@@ -57,10 +56,10 @@ private:
class TagOpenElement : public TagElement
{
public:
- TagOpenElement(const char *szTagName) : TagElement(szTagName) {}
+ TagOpenElement(const WPXString &szTagName) : TagElement(szTagName) {}
virtual ~TagOpenElement() {}
- void addAttribute(const char *szAttributeName, const WPXString &sAttributeValue);
- virtual void write(DocumentHandlerInterface *pHandler) const;
+ void addAttribute(const WPXString &szAttributeName, const WPXString &sAttributeValue);
+ virtual void write(OdfDocumentHandler *pHandler) const;
virtual void print () const;
private:
WPXPropertyList maAttrList;
@@ -69,17 +68,17 @@ private:
class TagCloseElement : public TagElement
{
public:
- TagCloseElement(const char *szTagName) : TagElement(szTagName) {}
+ TagCloseElement(const WPXString &szTagName) : TagElement(szTagName) {}
virtual ~TagCloseElement() {}
- virtual void write(DocumentHandlerInterface *pHandler) const;
+ virtual void write(OdfDocumentHandler *pHandler) const;
};
class CharDataElement : public DocumentElement
{
public:
- CharDataElement(const char *sData) : DocumentElement(), msData(sData) {}
+ CharDataElement(const WPXString &sData) : DocumentElement(), msData(sData) {}
virtual ~CharDataElement() {}
- virtual void write(DocumentHandlerInterface *pHandler) const;
+ virtual void write(OdfDocumentHandler *pHandler) const;
private:
WPXString msData;
};
@@ -87,14 +86,12 @@ private:
class TextElement : public DocumentElement
{
public:
- TextElement(const WPXString & sTextBuf);
+ TextElement(const WPXString &sTextBuf) : DocumentElement(), msTextBuf(sTextBuf, false) {}
virtual ~TextElement() {}
- virtual void write(DocumentHandlerInterface *pHandler) const;
+ virtual void write(OdfDocumentHandler *pHandler) const;
private:
WPXString msTextBuf;
};
#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/DocumentHandler.hxx b/writerperfect/source/filter/DocumentHandler.hxx
index 249f64f..692c35e 100644
--- a/writerperfect/source/filter/DocumentHandler.hxx
+++ b/writerperfect/source/filter/DocumentHandler.hxx
@@ -12,12 +12,12 @@
#pragma warning( pop )
#endif
-#include "DocumentHandlerInterface.hxx"
+#include "OdfDocumentHandler.hxx"
using com::sun::star::uno::Reference;
using com::sun::star::xml::sax::XDocumentHandler;
-class DocumentHandler: public DocumentHandlerInterface
+class DocumentHandler: public OdfDocumentHandler
{
public:
DocumentHandler(Reference < XDocumentHandler > &xHandler);
diff --git a/writerperfect/source/filter/DocumentHandlerInterface.hxx b/writerperfect/source/filter/DocumentHandlerInterface.hxx
deleted file mode 100644
index 0e9ee56..0000000
--- a/writerperfect/source/filter/DocumentHandlerInterface.hxx
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Copyright (C) 2004 William Lachance (wlach at interlog.com)
- * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * Contributor(s): Martin Gallwey (gallwey at sun.com)
- *
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-#ifndef _DOCUMENTHANDLERINTERFACE_H
-#define _DOCUMENTHANDLERINTERFACE_H
-#include <libwpd/libwpd.h>
-#include <libwpd/WPXProperty.h>
-#include <libwpd/WPXString.h>
-
-class DocumentHandlerInterface
-{
-public:
- DocumentHandlerInterface() {};
- virtual ~DocumentHandlerInterface() {};
-
- virtual void startDocument() = 0;
- virtual void endDocument() = 0;
- virtual void startElement(const char *psName, const WPXPropertyList &xPropList) = 0;
- virtual void endElement(const char *psName) = 0;
- virtual void characters(const WPXString &sCharacters) = 0;
-};
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/FilterInternal.hxx b/writerperfect/source/filter/FilterInternal.hxx
index fcac328..1b80633 100644
--- a/writerperfect/source/filter/FilterInternal.hxx
+++ b/writerperfect/source/filter/FilterInternal.hxx
@@ -1,7 +1,6 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* FilterInternal: Debugging information
*
- * Copyright (C) 2002-2003 William Lachance (william.lachance at sympatico.ca)
+ * Copyright (C) 2002-2003 William Lachance (wrlach at gmail.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,21 +19,18 @@
* For further information visit http://libwpd.sourceforge.net
*
*/
+#ifndef __FILTERINTERNAL_HXX__
+#define __FILTERINTERNAL_HXX__
-#ifndef _FILTERINTERNAL_HXX
-#define _FILTERINTERNAL_HXX
-
-#include <stdio.h>
#ifdef DEBUG
+#include <stdio.h>
#define WRITER_DEBUG_MSG(M) printf M
#else
#define WRITER_DEBUG_MSG(M)
#endif
const double fDefaultSideMargin = 1.0; // inches
-const double fDefaultPageWidth = 8.5; // inches (OOo required default: we will handle this later)
+const double fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later)
const double fDefaultPageHeight = 11.0; // inches
#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/FontStyle.cxx b/writerperfect/source/filter/FontStyle.cxx
index c945407..59741aa 100644
--- a/writerperfect/source/filter/FontStyle.cxx
+++ b/writerperfect/source/filter/FontStyle.cxx
@@ -1,8 +1,7 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* FontStyle: Stores (and writes) font-based information that is needed at
* the head of an OO document.
*
- * Copyright (C) 2002-2003 William Lachance (william.lachance at sympatico.ca)
+ * Copyright (C) 2002-2003 William Lachance (wrlach at gmail.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -39,14 +38,13 @@ FontStyle::~FontStyle()
{
}
-void FontStyle::write(DocumentHandlerInterface *pHandler) const
+void FontStyle::write(OdfDocumentHandler *pHandler) const
{
TagOpenElement styleOpen("style:font-face");
styleOpen.addAttribute("style:name", getName());
styleOpen.addAttribute("svg:font-family", msFontFamily);
+// styleOpen.addAttribute("style:font-pitch", msFontPitch);
styleOpen.write(pHandler);
TagCloseElement styleClose("style:font-face");
styleClose.write(pHandler);
}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/FontStyle.hxx b/writerperfect/source/filter/FontStyle.hxx
index aec430d..7f1a44e 100644
--- a/writerperfect/source/filter/FontStyle.hxx
+++ b/writerperfect/source/filter/FontStyle.hxx
@@ -1,8 +1,7 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* FontStyle: Stores (and writes) font-based information that is needed at
* the head of an OO document.
*
- * Copyright (C) 2002-2003 William Lachance (william.lachance at sympatico.ca)
+ * Copyright (C) 2002-2003 William Lachance (wrlach at gmail.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -31,14 +30,13 @@
#include "Style.hxx"
#include "WriterProperties.hxx"
-#include "DocumentHandlerInterface.hxx"
class FontStyle : public Style
{
public:
FontStyle(const char *psName, const char *psFontFamily);
~FontStyle();
- virtual void write(DocumentHandlerInterface *pHandler) const;
+ virtual void write(OdfDocumentHandler *pHandler) const;
const WPXString &getFontFamily() const { return msFontFamily; }
private:
@@ -46,5 +44,3 @@ private:
WPXString msFontPitch;
};
#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/GraphicsStyle.cxx b/writerperfect/source/filter/GraphicsStyle.cxx
deleted file mode 100644
index abca6a8..0000000
--- a/writerperfect/source/filter/GraphicsStyle.cxx
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* GraphicsStyle:
- *
- * Copyright (C) 2007 Fridrich Strba .strba at bluewin.ch)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * For further information visit http://libwpd.sourceforge.net
- *
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-#include "GraphicsStyle.hxx"
-#include "WriterProperties.hxx"
-#include "DocumentElement.hxx"
-
-GraphicsStyle::GraphicsStyle(const char *psName) : Style(psName)
-{
-}
-
-GraphicsStyle::~GraphicsStyle()
-{
-}
-
-void GraphicsStyle::write(DocumentHandlerInterface * /* pHandler */) const
-{
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/GraphicsStyle.hxx b/writerperfect/source/filter/GraphicsStyle.hxx
deleted file mode 100644
index bef9b54..0000000
--- a/writerperfect/source/filter/GraphicsStyle.hxx
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* GraphicsStyle:
- *
- * Copyright (C) 2007 Fridrich Strba .strba at bluewin.ch)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * For further information visit http://libwpd.sourceforge.net
- *
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-#ifndef _GRAPHICSSTYLE_H
-#define _GRAPHICSSTYLE_H
-
-#include "Style.hxx"
-#include "WriterProperties.hxx"
-#include "DocumentHandlerInterface.hxx"
-
-class GraphicsStyle : public Style
-{
-public:
- GraphicsStyle(const char *psName);
- ~GraphicsStyle();
- virtual void write(DocumentHandlerInterface *pHandler) const;
-};
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/InternalHandler.cxx b/writerperfect/source/filter/InternalHandler.cxx
index a020827..8582047 100644
--- a/writerperfect/source/filter/InternalHandler.cxx
+++ b/writerperfect/source/filter/InternalHandler.cxx
@@ -1,6 +1,5 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
- * Copyright (C) 2007 Fridrich Strba .strba at bluewin.ch)
+ * Copyright (C) 2007 Fridrich Strba (fridrich.strba at bluewin.ch)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -34,13 +33,13 @@ InternalHandler::InternalHandler(std::vector<DocumentElement *> *elements):
void InternalHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
{
TagOpenElement *element = new TagOpenElement(psName);
- WPXPropertyList::Iter i(xPropList);
- for (i.rewind(); i.next(); )
- {
- // filter out libwpd elements
- if (strncmp(i.key(), "libwpd", 6) != 0)
- element->addAttribute(i.key(), i()->getStr());
- }
+ WPXPropertyList::Iter i(xPropList);
+ for (i.rewind(); i.next(); )
+ {
+ // filter out libwpd elements
+ if (strncmp(i.key(), "libwpd", 6) != 0)
+ element->addAttribute(i.key(), i()->getStr());
+ }
mpElements->push_back(element);
}
@@ -53,5 +52,3 @@ void InternalHandler::characters(const WPXString &sCharacters)
{
mpElements->push_back(new CharDataElement(sCharacters.cstr()));
}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/InternalHandler.hxx b/writerperfect/source/filter/InternalHandler.hxx
index 0869ad1..a0f1638 100644
--- a/writerperfect/source/filter/InternalHandler.hxx
+++ b/writerperfect/source/filter/InternalHandler.hxx
@@ -1,6 +1,5 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
- * Copyright (C) 2007 Fridrich Strba .strba at bluewin.ch)
+ * Copyright (C) 2007 Fridrich Strba (fridrich.strba at bluewin.ch)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -28,9 +27,9 @@
#include <libwpd/WPXProperty.h>
#include <libwpd/WPXString.h>
#include "DocumentElement.hxx"
-#include "DocumentHandlerInterface.hxx"
+#include "OdfDocumentHandler.hxx"
-class InternalHandler : public DocumentHandlerInterface
+class InternalHandler : public OdfDocumentHandler
{
public:
InternalHandler(std::vector<DocumentElement *> *elements);
@@ -45,5 +44,3 @@ private:
std::vector<DocumentElement *> *mpElements;
};
#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/ListStyle.cxx b/writerperfect/source/filter/ListStyle.cxx
index a5c1780..e59ad53 100644
--- a/writerperfect/source/filter/ListStyle.cxx
+++ b/writerperfect/source/filter/ListStyle.cxx
@@ -1,8 +1,7 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ListStyle: Stores (and writes) list-based information that is
* needed at the head of an OO document.
*
- * Copyright (C) 2002-2003 William Lachance (william.lachance at sympatico.ca)
+ * Copyright (C) 2002-2003 William Lachance (wrlach at gmail.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -30,7 +29,7 @@
#include "DocumentElement.hxx"
OrderedListLevelStyle::OrderedListLevelStyle(const WPXPropertyList &xPropList) :
- mPropList(xPropList)
+ mPropList(xPropList)
{
}
@@ -42,7 +41,7 @@ void OrderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList &
setListLevel(iLevel, new OrderedListLevelStyle(xPropList));
}
-void OrderedListLevelStyle::write(DocumentHandlerInterface *pHandler, int iLevel) const
+void OrderedListLevelStyle::write(OdfDocumentHandler *pHandler, int iLevel) const
{
WPXString sLevel;
sLevel.sprintf("%i", (iLevel+1));
@@ -50,23 +49,23 @@ void OrderedListLevelStyle::write(DocumentHandlerInterface *pHandler, int iLevel
TagOpenElement listLevelStyleOpen("text:list-level-style-number");
listLevelStyleOpen.addAttribute("text:level", sLevel);
listLevelStyleOpen.addAttribute("text:style-name", "Numbering_Symbols");
- if (mPropList["style:num-prefix"])
+ if (mPropList["style:num-prefix"])
{
WPXString sEscapedString(mPropList["style:num-prefix"]->getStr(), true);
listLevelStyleOpen.addAttribute("style:num-prefix", sEscapedString);
}
- if (mPropList["style:num-suffix"])
+ if (mPropList["style:num-suffix"])
{
WPXString sEscapedString(mPropList["style:num-suffix"]->getStr(), true);
listLevelStyleOpen.addAttribute("style:num-suffix", sEscapedString);
}
- if (mPropList["style:num-format"])
- listLevelStyleOpen.addAttribute("style:num-format", mPropList["style:num-format"]->getStr());
- if (mPropList["text:start-value"])
+ if (mPropList["style:num-format"])
+ listLevelStyleOpen.addAttribute("style:num-format", mPropList["style:num-format"]->getStr());
+ if (mPropList["text:start-value"])
{
// odf as to the version 1.1 does require the text:start-value to be a positive integer, means > 0
if (mPropList["text:start-value"]->getInt() > 0)
- listLevelStyleOpen.addAttribute("text:start-value", mPropList["text:start-value"]->getStr());
+ listLevelStyleOpen.addAttribute("text:start-value", mPropList["text:start-value"]->getStr());
else
listLevelStyleOpen.addAttribute("text:start-value", "1");
}
@@ -74,7 +73,7 @@ void OrderedListLevelStyle::write(DocumentHandlerInterface *pHandler, int iLevel
TagOpenElement stylePropertiesOpen("style:list-level-properties");
if (mPropList["text:space-before"] && mPropList["text:space-before"]->getDouble() > 0.0)
- stylePropertiesOpen.addAttribute("text:space-before", mPropList["text:space-before"]->getStr());
+ stylePropertiesOpen.addAttribute("text:space-before", mPropList["text:space-before"]->getStr());
if (mPropList["text:min-label-width"] && mPropList["text:min-label-width"]->getDouble() > 0.0)
stylePropertiesOpen.addAttribute("text:min-label-width", mPropList["text:min-label-width"]->getStr());
if (mPropList["text:min-label-distance"] && mPropList["text:min-label-distance"]->getDouble() > 0.0)
@@ -98,7 +97,7 @@ void UnorderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList
setListLevel(iLevel, new UnorderedListLevelStyle(xPropList));
}
-void UnorderedListLevelStyle::write(DocumentHandlerInterface *pHandler, int iLevel) const
+void UnorderedListLevelStyle::write(OdfDocumentHandler *pHandler, int iLevel) const
{
WPXString sLevel;
sLevel.sprintf("%i", (iLevel+1));
@@ -121,7 +120,7 @@ void UnorderedListLevelStyle::write(DocumentHandlerInterface *pHandler, int iLev
TagOpenElement stylePropertiesOpen("style:list-level-properties");
if (mPropList["text:space-before"] && mPropList["text:space-before"]->getDouble() > 0.0)
- stylePropertiesOpen.addAttribute("text:space-before", mPropList["text:space-before"]->getStr());
+ stylePropertiesOpen.addAttribute("text:space-before", mPropList["text:space-before"]->getStr());
if (mPropList["text:min-label-width"] && mPropList["text:min-label-width"]->getDouble() > 0.0)
stylePropertiesOpen.addAttribute("text:min-label-width", mPropList["text:min-label-width"]->getStr());
if (mPropList["text:min-label-distance"] && mPropList["text:min-label-distance"]->getDouble() > 0.0)
@@ -168,7 +167,7 @@ void ListStyle::setListLevel(int iLevel, ListLevelStyle *iListLevelStyle)
mppListLevels[iLevel] = iListLevelStyle;
}
-void ListStyle::write(DocumentHandlerInterface *pHandler) const
+void ListStyle::write(OdfDocumentHandler *pHandler) const
{
TagOpenElement listStyleOpenElement("text:list-style");
listStyleOpenElement.addAttribute("style:name", getName());
@@ -176,10 +175,8 @@ void ListStyle::write(DocumentHandlerInterface *pHandler) const
for (int i=0; i<WP6_NUM_LIST_LEVELS; i++) {
if (mppListLevels[i] != NULL)
- mppListLevels[i]->write(pHandler, i);
+ mppListLevels[i]->write(pHandler, i);
}
pHandler->endElement("text:list-style");
}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/ListStyle.hxx b/writerperfect/source/filter/ListStyle.hxx
index cbba20a..32f2d9c 100644
--- a/writerperfect/source/filter/ListStyle.hxx
+++ b/writerperfect/source/filter/ListStyle.hxx
@@ -1,8 +1,7 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ListStyle: Stores (and writes) list-based information that is
* needed at the head of an OO document.
*
- * Copyright (C) 2002-2003 William Lachance (william.lachance at sympatico.ca)
+ * Copyright (C) 2002-2003 William Lachance (wrlach at gmail.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -33,7 +32,6 @@
#include "Style.hxx"
#include "WriterProperties.hxx"
-#include "DocumentHandlerInterface.hxx"
class DocumentElement;
@@ -41,14 +39,14 @@ class ListLevelStyle
{
public:
virtual ~ListLevelStyle() {};
- virtual void write(DocumentHandlerInterface *pHandler, int iLevel) const = 0;
+ virtual void write(OdfDocumentHandler *pHandler, int iLevel) const = 0;
};
class OrderedListLevelStyle : public ListLevelStyle
{
public:
OrderedListLevelStyle(const WPXPropertyList &xPropList);
- void write(DocumentHandlerInterface *pHandler, int iLevel) const;
+ void write(OdfDocumentHandler *pHandler, int iLevel) const;
private:
WPXPropertyList mPropList;
};
@@ -57,7 +55,7 @@ class UnorderedListLevelStyle : public ListLevelStyle
{
public:
UnorderedListLevelStyle(const WPXPropertyList &xPropList);
- void write(DocumentHandlerInterface *pHandler, int iLevel) const;
+ void write(OdfDocumentHandler *pHandler, int iLevel) const;
private:
WPXPropertyList mPropList;
};
@@ -68,8 +66,8 @@ public:
ListStyle(const char *psName, const int iListID);
virtual ~ListStyle();
virtual void updateListLevel(const int iLevel, const WPXPropertyList &xPropList) = 0;
- virtual void write(DocumentHandlerInterface *pHandler) const;
- int getListID() const { return miListID; }
+ virtual void write(OdfDocumentHandler *pHandler) const;
+ int getListID() { return miListID; }
bool isListLevelDefined(int iLevel) const;
protected:
@@ -95,5 +93,3 @@ public:
void updateListLevel(const int iLevel, const WPXPropertyList &xPropList);
};
#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/filter/OdfDocumentHandler.hxx b/writerperfect/source/filter/OdfDocumentHandler.hxx
new file mode 100644
index 0000000..0b7288c
--- /dev/null
+++ b/writerperfect/source/filter/OdfDocumentHandler.hxx
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2004 William Lachance (wlach at interlog.com)
+ * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Contributor(s): Martin Gallwey (gallwey at sun.com)
+ *
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+#ifndef _DOCUMENTHANDLER_H
+#define _DOCUMENTHANDLER_H
+#include <libwpd/libwpd.h>
+
+enum OdfStreamType { ODF_FLAT_XML, ODF_CONTENT_XML, ODF_STYLES_XML, ODF_SETTINGS_XML, ODF_META_XML };
+
+class OdfDocumentHandler
+{
+public:
+ OdfDocumentHandler() {};
+ virtual ~OdfDocumentHandler() {};
+
+ virtual void startDocument() = 0;
+ virtual void endDocument() = 0;
+ virtual void startElement(const char *psName, const WPXPropertyList &xPropList) = 0;
+ virtual void endElement(const char *psName) = 0;
+ virtual void characters(const WPXString &sCharacters) = 0;
+};
+#endif
diff --git a/writerperfect/source/filter/OdgExporter.cxx b/writerperfect/source/filter/OdgExporter.cxx
deleted file mode 100644
index c111cdb..0000000
--- a/writerperfect/source/filter/OdgExporter.cxx
+++ /dev/null
@@ -1,650 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya at kde.org)
- * Copyright (C) 2006 Fridrich Strba (fridrich.strba at bluewin.ch)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02111-1301 USA
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "OdgExporter.hxx"
-#include "DocumentElement.hxx"
-#include "DocumentHandler.hxx"
-#include <locale.h>
-#include <math.h>
-#include <string>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-OdgExporter::OdgExporter(DocumentHandlerInterface *pHandler):
- mpHandler(pHandler),
- miGradientIndex(1),
- miDashIndex(1),
- miGraphicsStyleIndex(1),
- mfWidth(0.0),
- mfHeight(0.0)
-{
-}
-
-OdgExporter::~OdgExporter()
-{
-
- for (std::vector<DocumentElement *>::iterator iterBody = mBodyElements.begin(); iterBody != mBodyElements.end(); ++iterBody)
- {
- delete (*iterBody);
- (*iterBody) = NULL;
- }
-
- for (std::vector<DocumentElement *>::iterator iterGraphicsAutomaticStyles = mGraphicsAutomaticStyles.begin();
- iterGraphicsAutomaticStyles != mGraphicsAutomaticStyles.end(); ++iterGraphicsAutomaticStyles)
- {
- delete((*iterGraphicsAutomaticStyles));
- }
-
- for (std::vector<DocumentElement *>::iterator iterGraphicsStrokeDashStyles = mGraphicsStrokeDashStyles.begin();
- iterGraphicsStrokeDashStyles != mGraphicsStrokeDashStyles.end(); ++iterGraphicsStrokeDashStyles)
- {
- delete((*iterGraphicsStrokeDashStyles));
- }
-
- for (std::vector<DocumentElement *>::iterator iterGraphicsGradientStyles = mGraphicsGradientStyles.begin();
- iterGraphicsGradientStyles != mGraphicsGradientStyles.end(); ++iterGraphicsGradientStyles)
- {
- delete((*iterGraphicsGradientStyles));
- }
-}
-
-void OdgExporter::startGraphics(const ::WPXPropertyList &propList)
-{
- miGradientIndex = 1;
- miDashIndex = 1;
- miGraphicsStyleIndex = 1;
- mfWidth = 0.0;
- mfHeight = 0.0;
-
- if (propList["svg:width"])
- mfWidth = propList["svg:width"]->getDouble();
-
- if (propList["svg:height"])
- mfHeight = propList["svg:height"]->getDouble();
-
- mpHandler->startDocument();
- TagOpenElement tmpOfficeDocumentContent("office:document");
- tmpOfficeDocumentContent.addAttribute("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
- tmpOfficeDocumentContent.addAttribute("xmlns:svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
- 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.write(mpHandler);
-
- TagOpenElement("office:settings").write(mpHandler);
-
- TagOpenElement configItemSetOpenElement("config:config-item-set");
- configItemSetOpenElement.addAttribute("config:name", "ooo:view-settings");
- configItemSetOpenElement.write(mpHandler);
-
- TagOpenElement configItemOpenElement("config:config-item");
-
- configItemOpenElement.addAttribute("config:name", "VisibleAreaTop");
- configItemOpenElement.addAttribute("config:type", "int");
- 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");
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list