summaryrefslogtreecommitdiffstats
path: root/writerperfect/source
diff options
context:
space:
mode:
Diffstat (limited to 'writerperfect/source')
-rw-r--r--writerperfect/source/filter/DocumentElement.cxx122
-rw-r--r--writerperfect/source/filter/DocumentElement.hxx103
-rw-r--r--writerperfect/source/filter/FilterInternal.hxx34
-rw-r--r--writerperfect/source/filter/FontStyle.cxx52
-rw-r--r--writerperfect/source/filter/FontStyle.hxx53
-rw-r--r--writerperfect/source/filter/ListStyle.cxx186
-rw-r--r--writerperfect/source/filter/ListStyle.hxx109
-rw-r--r--writerperfect/source/filter/PageSpan.cxx154
-rw-r--r--writerperfect/source/filter/PageSpan.hxx72
-rw-r--r--writerperfect/source/filter/SectionStyle.cxx85
-rw-r--r--writerperfect/source/filter/SectionStyle.hxx46
-rw-r--r--writerperfect/source/filter/Style.hxx65
-rw-r--r--writerperfect/source/filter/TableStyle.cxx234
-rw-r--r--writerperfect/source/filter/TableStyle.hxx79
-rw-r--r--writerperfect/source/filter/TextRunStyle.cxx248
-rw-r--r--writerperfect/source/filter/TextRunStyle.hxx87
-rw-r--r--writerperfect/source/filter/WriterProperties.hxx36
-rw-r--r--writerperfect/source/filter/makefile.mk25
-rw-r--r--writerperfect/source/stream/WPXSvStream.cxx103
-rw-r--r--writerperfect/source/stream/WPXSvStream.h33
-rw-r--r--writerperfect/source/stream/makefile.mk14
21 files changed, 1940 insertions, 0 deletions
diff --git a/writerperfect/source/filter/DocumentElement.cxx b/writerperfect/source/filter/DocumentElement.cxx
new file mode 100644
index 000000000000..75a678612733
--- /dev/null
+++ b/writerperfect/source/filter/DocumentElement.cxx
@@ -0,0 +1,122 @@
+/* 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@sympatico.ca)
+ *
+ * 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 "DocumentElement.hxx"
+#include "FilterInternal.hxx"
+#include <string.h>
+
+#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HPP_
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#endif
+
+using rtl::OUString;
+using namespace ::rtl;
+
+using com::sun::star::xml::sax::XAttributeList;
+
+#define UCS_SPACE 0x0020
+
+void TagElement::print() const
+{
+ WRITER_DEBUG_MSG(("%s\n", msTagName.getUTF8()));
+}
+
+void TagOpenElement::write(Reference < XDocumentHandler > &xHandler) const
+{
+ WRITER_DEBUG_MSG(("Writing startElement (%s)\n", getTagName().getUTF8()));
+
+ SvXMLAttributeList * paAttrList = new SvXMLAttributeList(maAttrList);
+ Reference < XAttributeList > xAttrList ( paAttrList );
+
+ xHandler->startElement(OUString::createFromAscii(getTagName().getUTF8()), xAttrList);
+ WRITER_DEBUG_MSG(("Done\n"));
+}
+
+void TagOpenElement::print() const
+{
+ TagElement::print();
+}
+
+void TagOpenElement::addAttribute(const char *szAttributeName, const char *szAttributeValue)
+{
+ maAttrList.AddAttribute(OUString::createFromAscii(szAttributeName),
+ OUString::createFromAscii(szAttributeValue));
+}
+
+void TagCloseElement::write(Reference < XDocumentHandler > &xHandler) const
+{
+ WRITER_DEBUG_MSG(("TagCloseElement: write (%s)\n", getTagName().getUTF8()));
+
+ xHandler->endElement(OUString::createFromAscii(getTagName().getUTF8()));
+}
+
+void CharDataElement::write(Reference < XDocumentHandler > &xHandler) const
+{
+ WRITER_DEBUG_MSG(("TextElement: write\n"));
+ xHandler->characters(OUString::createFromAscii(msData.getUTF8()) );
+}
+
+TextElement::TextElement(const UCSString & sTextBuf) :
+ msTextBuf(sTextBuf)
+{
+}
+
+// write: writes a text run, appropriately converting spaces to <text:s>
+// elements
+// FIXME: this function is appalling because OUString isn't rich enough.
+// probably should allocate some resizable buffer of UCS2 instead
+void TextElement::write(Reference < XDocumentHandler > &xHandler) const
+{
+ WRITER_DEBUG_MSG(("TextElement: write\n"));
+ SvXMLAttributeList * pAttrList = new SvXMLAttributeList;
+ Reference < XAttributeList > xBlankAttrList ( pAttrList );
+
+ OUString sTempUCS2;
+ int iNumConsecutiveSpaces = 0;
+ for (int i=0; i<msTextBuf.getLen(); i++) {
+ if (msTextBuf.getUCS4()[i] == UCS_SPACE)
+ iNumConsecutiveSpaces++;
+ else
+ iNumConsecutiveSpaces = 0;
+
+ if (iNumConsecutiveSpaces > 1) {
+ if (sTempUCS2.getLength() > 0) {
+ xHandler->characters(sTempUCS2);
+ sTempUCS2 = OUString::createFromAscii("");
+ }
+ xHandler->startElement(OUString::createFromAscii("text:s"), xBlankAttrList);
+ xHandler->endElement(OUString::createFromAscii("text:s"));
+ }
+ else {
+ const uint32_t * ucs4 = msTextBuf.getUCS4();
+ sal_Unicode su = static_cast<sal_Unicode>(msTextBuf.getUCS4()[i]);
+ OUString aStringPart(&su,1);
+ sTempUCS2 += aStringPart;
+ }
+ }
+ xHandler->characters(sTempUCS2);
+}
diff --git a/writerperfect/source/filter/DocumentElement.hxx b/writerperfect/source/filter/DocumentElement.hxx
new file mode 100644
index 000000000000..a50275d3948f
--- /dev/null
+++ b/writerperfect/source/filter/DocumentElement.hxx
@@ -0,0 +1,103 @@
+/* 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@sympatico.ca)
+ *
+ * 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 _DOCUMENTELEMENT_H
+#define _DOCUMENTELEMENT_H
+#include <libwpd/libwpd.h>
+#include <libwpd/libwpd_support.h>
+#include <vector>
+
+using namespace std;
+
+#include "WordPerfectCollector.hxx"
+#include "TextRunStyle.hxx"
+#include "SectionStyle.hxx"
+#include "TableStyle.hxx"
+
+#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#endif
+
+#include "ooo/attrlist.hxx"
+
+class DocumentElement
+{
+public:
+ virtual ~DocumentElement() {}
+ virtual void write(Reference < XDocumentHandler > &xHandler) const = 0;
+ virtual void print() const {}
+};
+
+class TagElement : public DocumentElement
+{
+public:
+ TagElement(const char *szTagName) : msTagName(szTagName) {}
+ const UTF8String & getTagName() const { return msTagName; }
+ virtual void print() const;
+private:
+ UTF8String msTagName;
+};
+
+class TagOpenElement : public TagElement
+{
+public:
+ TagOpenElement(const char *szTagName) : TagElement(szTagName) {}
+ ~TagOpenElement() {}
+ void addAttribute(const char *szAttributeName, const char *szAttributeValue);
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+ virtual void print () const;
+private:
+ SvXMLAttributeList maAttrList;
+};
+
+class TagCloseElement : public TagElement
+{
+public:
+ TagCloseElement(const char *szTagName) : TagElement(szTagName) {}
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+};
+
+class CharDataElement : public DocumentElement
+{
+public:
+ CharDataElement(const char *sData) : DocumentElement(), msData(sData) {}
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+private:
+ UTF8String msData;
+};
+
+class TextElement : public DocumentElement
+{
+public:
+ TextElement(const UCSString & sTextBuf);
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+
+private:
+ UCSString msTextBuf;
+};
+
+#endif
diff --git a/writerperfect/source/filter/FilterInternal.hxx b/writerperfect/source/filter/FilterInternal.hxx
new file mode 100644
index 000000000000..12d4b8641013
--- /dev/null
+++ b/writerperfect/source/filter/FilterInternal.hxx
@@ -0,0 +1,34 @@
+/* FilterInternal: Debugging information
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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
+ *
+ */
+#include <stdio.h>
+#ifdef DEBUG
+#define WRITER_DEBUG_MSG(M) printf M
+#else
+#define WRITER_DEBUG_MSG(M)
+#endif
+
+#include <rtl/string.hxx>
+
+inline rtl::OString utf8_itoa(int i)
+{
+ return rtl::OString::valueOf( (sal_Int32) i );
+}
diff --git a/writerperfect/source/filter/FontStyle.cxx b/writerperfect/source/filter/FontStyle.cxx
new file mode 100644
index 000000000000..1aaa56e2bc8a
--- /dev/null
+++ b/writerperfect/source/filter/FontStyle.cxx
@@ -0,0 +1,52 @@
+/* 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@sympatico.ca)
+ *
+ * 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 "FontStyle.hxx"
+#include "FontMap.hxx"
+#include "WriterProperties.hxx"
+#include "DocumentElement.hxx"
+
+FontStyle::FontStyle(const char *psName, const char *psFontFamily) : Style(psName),
+ msFontFamily(psFontFamily),
+ msFontPitch(IMP_DEFAULT_FONT_PITCH)
+
+{
+}
+
+FontStyle::~FontStyle()
+{
+}
+
+void FontStyle::write(Reference < XDocumentHandler > &xHandler) const
+{
+ TagOpenElement styleOpen("style:font-decl");
+ styleOpen.addAttribute("style:name", mapFont(getName()));
+ styleOpen.addAttribute("fo:font-family", mapFont(msFontFamily));
+ styleOpen.addAttribute("style:font-pitch", msFontPitch);
+ styleOpen.write(xHandler);
+ TagCloseElement styleClose("style:font-decl");
+ styleClose.write(xHandler);
+}
diff --git a/writerperfect/source/filter/FontStyle.hxx b/writerperfect/source/filter/FontStyle.hxx
new file mode 100644
index 000000000000..e275aa1ce531
--- /dev/null
+++ b/writerperfect/source/filter/FontStyle.hxx
@@ -0,0 +1,53 @@
+/* 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@sympatico.ca)
+ *
+ * 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 _FONTSTYLE_H
+#define _FONTSTYLE_H
+#include <libwpd/libwpd.h>
+
+#include "Style.hxx"
+#include "WriterProperties.hxx"
+
+#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#endif
+
+using com::sun::star::uno::Reference;
+using com::sun::star::xml::sax::XDocumentHandler;
+
+class FontStyle : public Style
+{
+public:
+ FontStyle(const char *psName, const char *psFontFamily);
+ ~FontStyle();
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+ const UTF8String &getFontFamily() const { return msFontFamily; }
+
+private:
+ UTF8String msFontFamily;
+ UTF8String msFontPitch;
+};
+#endif
diff --git a/writerperfect/source/filter/ListStyle.cxx b/writerperfect/source/filter/ListStyle.cxx
new file mode 100644
index 000000000000..96959bb8126d
--- /dev/null
+++ b/writerperfect/source/filter/ListStyle.cxx
@@ -0,0 +1,186 @@
+/* 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@sympatico.ca)
+ *
+ * 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 "FilterInternal.hxx"
+#include "ListStyle.hxx"
+#include "DocumentElement.hxx"
+
+using namespace ::rtl;
+using rtl::OUString;
+
+OrderedListLevelStyle::OrderedListLevelStyle(const WPXNumberingType listType, const UCSString &sTextBeforeNumber,
+ const UCSString &sTextAfterNumber, const float fSpaceBefore, const int iStartingNumber) :
+ mlistType(listType),
+ msTextBeforeNumber(sTextBeforeNumber),
+ msTextAfterNumber(sTextAfterNumber),
+ mfSpaceBefore(fSpaceBefore),
+ miStartingNumber(iStartingNumber)
+{
+}
+
+void OrderedListStyle::updateListLevel(const int iLevel, const WPXNumberingType listType, const UCSString &sTextBeforeNumber, const UCSString &sTextAfterNumber, const int iStartingNumber)
+{
+ if (!isListLevelDefined(iLevel))
+ setListLevel(iLevel, new OrderedListLevelStyle(listType, sTextBeforeNumber, sTextAfterNumber, iLevel*0.5f, iStartingNumber));
+}
+
+void OrderedListLevelStyle::write(Reference < XDocumentHandler > &xHandler, int iLevel) const
+{
+ // then convert from ucs4 to utf8 and write it
+ //char *sBulletUTF8 = ucs2ArrayToUTF8String(msBullet);
+
+ //if (mfSpaceBefore != 0.0f)
+ UTF8String sListTypeSymbol("1");
+ switch (mlistType)
+ {
+ case ARABIC:
+ sListTypeSymbol.sprintf("1");
+ break;
+ case LOWERCASE:
+ sListTypeSymbol.sprintf("a");
+ break;
+ case UPPERCASE:
+ sListTypeSymbol.sprintf("A");
+ break;
+ case LOWERCASE_ROMAN:
+ sListTypeSymbol.sprintf("i");
+ break;
+ case UPPERCASE_ROMAN:
+ sListTypeSymbol.sprintf("I");
+ break;
+ }
+
+ UTF8String sTextBeforeNumber(msTextBeforeNumber, true);
+ UTF8String sTextAfterNumber(msTextAfterNumber, true);
+ UTF8String sLevel;
+ sLevel.sprintf("%i", (iLevel+1));
+ UTF8String sStartValue;
+ sStartValue.sprintf("%i", miStartingNumber);
+
+ TagOpenElement listLevelStyleOpen("text:list-level-style-number");
+ listLevelStyleOpen.addAttribute("text:level", sLevel.getUTF8());
+ listLevelStyleOpen.addAttribute("text:style-name", "Numbering Symbols");
+ listLevelStyleOpen.addAttribute("style:num-prefix", sTextBeforeNumber.getUTF8());
+ listLevelStyleOpen.addAttribute("style:num-suffix", sTextAfterNumber.getUTF8());
+ listLevelStyleOpen.addAttribute("style:num-format", sListTypeSymbol.getUTF8());
+ listLevelStyleOpen.addAttribute("text:start-value", sStartValue.getUTF8());
+ listLevelStyleOpen.write(xHandler);
+
+ UTF8String sSpaceBefore;
+ sSpaceBefore.sprintf("%fcm", mfSpaceBefore);
+ TagOpenElement stylePropertiesOpen("style:properties");
+ stylePropertiesOpen.addAttribute("text:space-before", sSpaceBefore.getUTF8());
+ stylePropertiesOpen.addAttribute("text:min-label-width", "0.499cm");
+ stylePropertiesOpen.write(xHandler);
+
+ xHandler->endElement(OUString::createFromAscii("style:properties"));
+ xHandler->endElement(OUString::createFromAscii("text:list-level-style-number"));
+}
+
+UnorderedListLevelStyle::UnorderedListLevelStyle(const UCSString &sBullet, const float fSpaceBefore)
+ : msBullet(sBullet),
+ mfSpaceBefore(fSpaceBefore)
+{
+}
+
+void UnorderedListStyle::updateListLevel(const int iLevel, const UCSString &sBullet)
+{
+ if (!isListLevelDefined(iLevel))
+ setListLevel(iLevel, new UnorderedListLevelStyle(sBullet, iLevel*0.5f));
+}
+
+void UnorderedListLevelStyle::write(Reference < XDocumentHandler > &xHandler, int iLevel) const
+{
+ UTF8String sBulletUTF8(msBullet, true);
+ UTF8String sLevel;
+ sLevel.sprintf("%i", (iLevel+1));
+ TagOpenElement listLevelStyleOpen("text:list-level-style-bullet");
+ listLevelStyleOpen.addAttribute("text:level", sLevel.getUTF8());
+ listLevelStyleOpen.addAttribute("text:style-name", "Bullet Symbols");
+ listLevelStyleOpen.addAttribute("style:num-suffice", ".");
+ listLevelStyleOpen.addAttribute("text:bullet-char", sBulletUTF8.getUTF8());
+ listLevelStyleOpen.write(xHandler);
+
+ UTF8String sSpaceBefore;
+ sSpaceBefore.sprintf("%fcm", mfSpaceBefore);
+ TagOpenElement stylePropertiesOpen("style:properties");
+ stylePropertiesOpen.addAttribute("text:space-before", sSpaceBefore.getUTF8());
+ stylePropertiesOpen.addAttribute("text:min-label-width", "0.499cm");
+ stylePropertiesOpen.addAttribute("style:font-name", "StarSymbol");
+ stylePropertiesOpen.write(xHandler);
+
+ xHandler->endElement(OUString::createFromAscii("style:properties"));
+ xHandler->endElement(OUString::createFromAscii("text:list-level-style-bullet"));
+}
+
+ListStyle::ListStyle(const char *psName, const int iListID) :
+ Style(psName),
+ miListID(iListID)
+{
+ for (int i=0; i<WP6_NUM_LIST_LEVELS; i++)
+ mppListLevels[i] = NULL;
+
+}
+
+ListStyle::~ListStyle()
+{
+ for (int i=0; i<WP6_NUM_LIST_LEVELS; i++) {
+ if (mppListLevels[i])
+ delete(mppListLevels[i]);
+ }
+
+}
+
+const bool ListStyle::isListLevelDefined(int iLevel) const
+{
+ if (mppListLevels[iLevel] == NULL)
+ return false;
+
+ return true;
+}
+
+void ListStyle::setListLevel(int iLevel, ListLevelStyle *iListLevelStyle)
+{
+ // can't uncomment this next line without adding some extra logic.
+ // figure out which is best: use the initial message, or constantly
+ // update?
+ if (mppListLevels[iLevel] == NULL)
+ mppListLevels[iLevel] = iListLevelStyle;
+}
+
+void ListStyle::write(Reference < XDocumentHandler > &xHandler) const
+{
+ TagOpenElement listStyleOpenElement("text:list-style");
+ listStyleOpenElement.addAttribute("style:name", getName());
+ listStyleOpenElement.write(xHandler);
+
+ for (int i=0; i<WP6_NUM_LIST_LEVELS; i++) {
+ if (mppListLevels[i] != NULL)
+ mppListLevels[i]->write(xHandler, i);
+ }
+
+ xHandler->endElement(OUString::createFromAscii("text:list-style"));
+}
diff --git a/writerperfect/source/filter/ListStyle.hxx b/writerperfect/source/filter/ListStyle.hxx
new file mode 100644
index 000000000000..51017b9e6133
--- /dev/null
+++ b/writerperfect/source/filter/ListStyle.hxx
@@ -0,0 +1,109 @@
+/* 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@sympatico.ca)
+ *
+ * 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 _LISTSTYLE_H
+#define _LISTSTYLE_H
+#include <libwpd/libwpd.h>
+
+#define WP6_NUM_LIST_LEVELS 8 // see WP6FileStructure.h (we shouldn't need to reference this)
+
+#include "Style.hxx"
+#include "WriterProperties.hxx"
+
+#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#endif
+
+using com::sun::star::uno::Reference;
+using com::sun::star::xml::sax::XDocumentHandler;
+
+class DocumentElement;
+
+class ListLevelStyle
+{
+public:
+ virtual void write(Reference < XDocumentHandler > &xHandler, int level) const = 0;
+};
+
+class OrderedListLevelStyle : public ListLevelStyle
+{
+public:
+ OrderedListLevelStyle(const WPXNumberingType listType,
+ const UCSString &sTextBeforeNumber, const UCSString &sTextAfterNumber,
+ const float fSpaceBefore, const int iStartingNumber);
+ virtual void write(Reference < XDocumentHandler > &xHandler, int level) const;
+private:
+ UCSString msTextBeforeNumber;
+ UCSString msTextAfterNumber;
+ float mfSpaceBefore;
+ int miStartingNumber;
+ WPXNumberingType mlistType;
+};
+
+class UnorderedListLevelStyle : public ListLevelStyle
+{
+public:
+ UnorderedListLevelStyle(const UCSString &sBullet, const float fSpaceBefore);
+ virtual void write(Reference < XDocumentHandler > &xHandler, int iLevel) const;
+private:
+ UCSString msBullet;
+ float mfSpaceBefore;
+};
+
+class ListStyle : public Style
+{
+public:
+ ListStyle(const char *psName, const int iListID);
+ virtual ~ListStyle();
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+ const int getListID() { return miListID; }
+ const bool isListLevelDefined(int iLevel) const;
+
+protected:
+ void setListLevel(int iLevel, ListLevelStyle *iListLevelStyle);
+
+private:
+ ListLevelStyle *mppListLevels[WP6_NUM_LIST_LEVELS];
+ int miNumListLevels;
+ const int miListID;
+};
+
+class OrderedListStyle : public ListStyle
+{
+public:
+ OrderedListStyle(const char *psName, const int iListID) : ListStyle(psName, iListID) {}
+ void updateListLevel(const int iLevel, const WPXNumberingType listType,
+ const UCSString &sTextBeforeNumber, const UCSString &sTextAfterNumber,
+ const int iStartingNumber);
+};
+
+class UnorderedListStyle : public ListStyle
+{
+public:
+ UnorderedListStyle(const char *psName, const int iListID) : ListStyle(psName, iListID) {}
+ void updateListLevel(const int iLevel, const UCSString &sBullet);
+};
+#endif
diff --git a/writerperfect/source/filter/PageSpan.cxx b/writerperfect/source/filter/PageSpan.cxx
new file mode 100644
index 000000000000..d3d12e60b1c0
--- /dev/null
+++ b/writerperfect/source/filter/PageSpan.cxx
@@ -0,0 +1,154 @@
+/* SectionStyle: Stores (and writes) section-based information (e.g.: a column
+ * break needs a new section) that is needed at the head of an OO document and
+ * is referenced throughout the entire document
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 "FilterInternal.hxx"
+#include "PageSpan.hxx"
+#include "DocumentElement.hxx"
+
+const float fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later)
+const float fDefaultPageHeight = 11.0f; // inches
+
+PageSpan::PageSpan(const int iSpan, const float fFormLength, const float fFormWidth, const WPXFormOrientation fFormOrientation,
+ const float fLeftMargin, const float fRightMargin, const float fTopMargin, const float fBottomMargin):
+ miSpan(iSpan),
+ mfFormLength(fFormLength),
+ mfFormWidth(fFormWidth),
+ mfFormOrientation(fFormOrientation),
+ mfMarginLeft(fLeftMargin),
+ mfMarginRight(fRightMargin),
+ mfMarginTop(fTopMargin),
+ mfMarginBottom(fBottomMargin),
+ mpHeaderContent(NULL),
+ mpFooterContent(NULL),
+ mpHeaderLeftContent(NULL),
+ mpFooterLeftContent(NULL)
+{
+}
+
+PageSpan::~PageSpan()
+{
+ delete mpHeaderContent;
+ delete mpHeaderLeftContent;
+ delete mpFooterContent;
+ delete mpFooterLeftContent;
+}
+
+void PageSpan::writePageMaster(const int iNum, Reference < XDocumentHandler > &xHandler) const
+{
+ TagOpenElement pageMasterOpen("style:page-master");
+ UTF8String sPageMasterName;
+ sPageMasterName.sprintf("PM%i", iNum);
+ pageMasterOpen.addAttribute("style:name", sPageMasterName.getUTF8());
+ pageMasterOpen.write(xHandler);
+
+ TagOpenElement pageMasterPropertiesOpen("style:properties");
+ UTF8String sMarginTop;
+ sMarginTop.sprintf("%.4finch", mfMarginTop);
+ UTF8String sMarginBottom;
+ sMarginBottom.sprintf("%.4finch", mfMarginBottom);
+ UTF8String sMarginLeft;
+ sMarginLeft.sprintf("%.4finch", mfMarginLeft);
+ UTF8String sMarginRight;
+ sMarginRight.sprintf("%.4finch", mfMarginRight);
+ UTF8String sPageWidth;
+ sPageWidth.sprintf("%.4finch", mfFormWidth);
+ UTF8String sPageHeight;
+ sPageHeight.sprintf("%.4finch", mfFormLength);
+ if (mfFormOrientation == LANDSCAPE)
+ {
+ pageMasterPropertiesOpen.addAttribute("style:print-orientation", "landscape");
+ }
+ else
+ {
+ pageMasterPropertiesOpen.addAttribute("style:print-orientation", "portrait");
+ }
+ pageMasterPropertiesOpen.addAttribute("fo:page-width", sPageWidth.getUTF8());
+ pageMasterPropertiesOpen.addAttribute("fo:page-height", sPageHeight.getUTF8());
+ pageMasterPropertiesOpen.addAttribute("fo:margin-top", sMarginTop.getUTF8());
+ pageMasterPropertiesOpen.addAttribute("fo:margin-bottom", sMarginBottom.getUTF8());
+ pageMasterPropertiesOpen.addAttribute("fo:margin-left", sMarginLeft.getUTF8());
+ pageMasterPropertiesOpen.addAttribute("fo:margin-right", sMarginRight.getUTF8());
+ pageMasterPropertiesOpen.write(xHandler);
+ TagCloseElement pageMasterPropertiesClose("style:properties");
+ pageMasterPropertiesClose.write(xHandler);
+
+ TagCloseElement pageMasterClose("style:page-master");
+ pageMasterClose.write(xHandler);
+}
+
+void PageSpan::writeMasterPages(const int iStartingNum, const int iPageMasterNum, const bool bLastPageSpan, Reference < XDocumentHandler > &xHandler) const
+{
+ int iSpan = 0;
+ (bLastPageSpan) ? iSpan = 1 : iSpan = miSpan;
+
+ for (int i=iStartingNum; i<(iStartingNum+iSpan); i++)
+ {
+ TagOpenElement masterPageOpen("style:master-page");
+ UTF8String sMasterPageName;
+ sMasterPageName.sprintf("Page Style %i", i);
+ UTF8String sPageMasterName;
+ sPageMasterName.sprintf("PM%i", iPageMasterNum);
+ masterPageOpen.addAttribute("style:name", sMasterPageName.getUTF8());
+ masterPageOpen.addAttribute("style:page-master-name", sPageMasterName.getUTF8());
+ if (!bLastPageSpan)
+ {
+ UTF8String sNextMasterPageName;
+ sNextMasterPageName.sprintf("Page Style %i", (i+1));
+ masterPageOpen.addAttribute("style:next-style-name", sNextMasterPageName.getUTF8());
+ }
+ masterPageOpen.write(xHandler);
+
+ if (mpHeaderContent)
+ _writeHeaderFooter("style:header", *mpHeaderContent, xHandler);
+ if (mpHeaderLeftContent)
+ _writeHeaderFooter("style:header-left", *mpHeaderLeftContent, xHandler);
+ if (mpFooterContent)
+ _writeHeaderFooter("style:footer", *mpFooterContent, xHandler);
+ if (mpFooterLeftContent)
+ _writeHeaderFooter("style:footer-left", *mpFooterLeftContent, xHandler);
+
+ TagCloseElement masterPageClose("style:master-page");
+ masterPageClose.write(xHandler);
+ }
+
+}
+
+void PageSpan::_writeHeaderFooter(const char *headerFooterTagName,
+ const vector<DocumentElement *> & headerFooterContent,
+ Reference < XDocumentHandler > &xHandler) const
+{
+ TagOpenElement headerFooterOpen(headerFooterTagName);
+ headerFooterOpen.write(xHandler);
+ for (vector<DocumentElement *>::const_iterator iter = headerFooterContent.begin();
+ iter != headerFooterContent.end();
+ iter++) {
+ (*iter)->write(xHandler);
+ }
+ TagCloseElement headerFooterClose(headerFooterTagName);
+ headerFooterClose.write(xHandler);
+}
+
diff --git a/writerperfect/source/filter/PageSpan.hxx b/writerperfect/source/filter/PageSpan.hxx
new file mode 100644
index 000000000000..ea4b4c606464
--- /dev/null
+++ b/writerperfect/source/filter/PageSpan.hxx
@@ -0,0 +1,72 @@
+/* PageSpan: Stores (and writes) page-based information (e.g.: margins,
+ * headers/footers)
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 _PAGESPAN_H
+#define _PAGESPAN_H
+#include <libwpd/libwpd.h>
+
+#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#endif
+
+using com::sun::star::uno::Reference;
+using com::sun::star::xml::sax::XDocumentHandler;
+
+class DocumentElement;
+
+class PageSpan
+{
+public:
+ PageSpan(const int iSpan, const float fFormLength, const float fFormWidth, const WPXFormOrientation fFormOrientation,
+ const float fLeftMargin, const float fRightMargin, const float fTopMargin, const float fBottomMargin);
+ virtual ~PageSpan();
+ void writePageMaster(const int iNum, Reference < XDocumentHandler > &xHandler) const;
+ void writeMasterPages(const int iStartingNum, const int iPageMasterNum, const bool bLastPageSpan, Reference < XDocumentHandler > &xHandler) const;
+ const int getSpan() const { return miSpan; }
+ float getFormLength() { return mfFormLength; }
+ float getFormWidth() { return mfFormWidth; }
+ WPXFormOrientation getFormOrientation() { return mfFormOrientation; }
+ float getMarginLeft() { return mfMarginLeft; }
+ float getMarginRight() { return mfMarginRight; }
+
+ const vector<DocumentElement *> * getHeaderContent() const { return mpHeaderContent; }
+ void setHeaderContent(vector<DocumentElement *> * pHeaderContent) { mpHeaderContent = pHeaderContent; }
+ void setFooterContent(vector<DocumentElement *> * pFooterContent) { mpFooterContent = pFooterContent; }
+ void setHeaderLeftContent(vector<DocumentElement *> * pHeaderContent) { mpHeaderLeftContent = pHeaderContent; }
+ void setFooterLeftContent(vector<DocumentElement *> * pFooterContent) { mpFooterLeftContent = pFooterContent; }
+protected:
+ void _writeHeaderFooter(const char *headerFooterTagName, const vector<DocumentElement *> & headerFooterContent,
+ Reference < XDocumentHandler > &xHandler) const;
+private:
+ int miSpan;
+ float mfFormLength, mfFormWidth, mfMarginLeft, mfMarginRight, mfMarginTop, mfMarginBottom;
+ WPXFormOrientation mfFormOrientation;
+ vector<DocumentElement *> * mpHeaderContent;
+ vector<DocumentElement *> * mpFooterContent;
+ vector<DocumentElement *> * mpHeaderLeftContent;
+ vector<DocumentElement *> * mpFooterLeftContent;
+};
+#endif
diff --git a/writerperfect/source/filter/SectionStyle.cxx b/writerperfect/source/filter/SectionStyle.cxx
new file mode 100644
index 000000000000..dbe3dc1a4f11
--- /dev/null
+++ b/writerperfect/source/filter/SectionStyle.cxx
@@ -0,0 +1,85 @@
+/* SectionStyle: Stores (and writes) section-based information (e.g.: a column
+ * break needs a new section) that is needed at the head of an OO document and
+ * is referenced throughout the entire document
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 "FilterInternal.hxx"
+#include "SectionStyle.hxx"
+#include "DocumentElement.hxx"
+
+using namespace ::rtl;
+using rtl::OUString;
+
+const float fDefaultSideMargin = 1.0f; // inches
+const float fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later)
+const float fDefaultPageHeight = 11.0f; // inches
+
+SectionStyle::SectionStyle(const int iNumColumns, const char *psName) : Style(psName),
+ miNumColumns(iNumColumns)
+{
+
+ WRITER_DEBUG_MSG(("WriterWordPerfect: Created a new set of section props with this no. of columns: %i and this name: %s\n",
+ (int)miNumColumns, (const char *)getName()));
+}
+
+void SectionStyle::write(Reference < XDocumentHandler > &xHandler) const
+{
+ TagOpenElement styleOpen("style:style");
+ styleOpen.addAttribute("style:name", getName());
+ styleOpen.addAttribute("style:family", "section");
+ styleOpen.write(xHandler);
+
+ // style properties
+ TagOpenElement stylePropertiesOpen("style:properties");
+ stylePropertiesOpen.addAttribute("text:dont-balance-text-columns", "false");
+ stylePropertiesOpen.write(xHandler);
+
+ // column properties
+ TagOpenElement columnsOpen("style:columns");
+ UTF8String sColumnCount;
+ sColumnCount.sprintf("%i", miNumColumns);
+ columnsOpen.addAttribute("fo:column-count", sColumnCount.getUTF8());
+ columnsOpen.addAttribute("fo:column-gap", "0inch");
+ columnsOpen.write(xHandler);
+
+ if (miNumColumns > 1) {
+ for (int i=0; i<miNumColumns; i++) {
+ // theoretically, we would put column widths in here, but that's currently unsupported..
+ // so we just allocate a size of "1" for each
+ TagOpenElement columnOpen("style:column");
+ columnOpen.addAttribute("style:rel-width", "1");
+ columnOpen.addAttribute("fo:margin-left", "0inch");
+ columnOpen.addAttribute("fo:margin-right", "0inch");
+ columnOpen.write(xHandler);
+
+ TagCloseElement columnClose("style:column");
+ columnClose.write(xHandler);
+ }
+ }
+
+ xHandler->endElement(OUString::createFromAscii("style:columns"));
+ xHandler->endElement(OUString::createFromAscii("style:properties"));
+ xHandler->endElement(OUString::createFromAscii("style:style"));
+}
diff --git a/writerperfect/source/filter/SectionStyle.hxx b/writerperfect/source/filter/SectionStyle.hxx
new file mode 100644
index 000000000000..8b7f5f42a6a5
--- /dev/null
+++ b/writerperfect/source/filter/SectionStyle.hxx
@@ -0,0 +1,46 @@
+/* SectionStyle: Stores (and writes) section-based information (e.g.: a column
+ * change needs a new section) that is needed at the head of an OO document.
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 _SECTIONSTYLE_H
+#define _SECTIONSTYLE_H
+#include <libwpd/libwpd.h>
+
+#include "Style.hxx"
+#include "WriterProperties.hxx"
+
+using com::sun::star::uno::Reference;
+using com::sun::star::xml::sax::XDocumentHandler;
+
+class SectionStyle : public Style
+{
+public:
+ SectionStyle(const int iNumColumns, const char *psName);
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+
+private:
+ int miNumColumns;
+};
+#endif
diff --git a/writerperfect/source/filter/Style.hxx b/writerperfect/source/filter/Style.hxx
new file mode 100644
index 000000000000..a43e5da038c7
--- /dev/null
+++ b/writerperfect/source/filter/Style.hxx
@@ -0,0 +1,65 @@
+/* Style: A base class from which all other styles are inherited, includes
+ * a name.
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 _STYLE_H
+#define _STYLE_H
+#include <libwpd/libwpd.h>
+
+class DocumentElement;
+
+#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#endif
+
+using com::sun::star::uno::Reference;
+using com::sun::star::xml::sax::XDocumentHandler;
+
+class TopLevelElementStyle
+{
+public:
+ TopLevelElementStyle() : mpsMasterPageName(NULL) { }
+ virtual ~TopLevelElementStyle() { if (mpsMasterPageName) delete mpsMasterPageName; }
+ void setMasterPageName(UTF8String &sMasterPageName) { mpsMasterPageName = new UTF8String(sMasterPageName); }
+ const UTF8String * getMasterPageName() const { return mpsMasterPageName; }
+
+private:
+ UTF8String *mpsMasterPageName;
+};
+
+class Style
+{
+ public:
+ Style(const UTF8String &psName) : msName(psName) {}
+ virtual ~Style() {}
+
+ virtual void write(Reference < XDocumentHandler > &xHandler) const {};
+ const UTF8String &getName() const { return msName; }
+
+ private:
+ UTF8String msName;
+};
+#endif
diff --git a/writerperfect/source/filter/TableStyle.cxx b/writerperfect/source/filter/TableStyle.cxx
new file mode 100644
index 000000000000..b7905c3a8079
--- /dev/null
+++ b/writerperfect/source/filter/TableStyle.cxx
@@ -0,0 +1,234 @@
+/* TableStyle: Stores (and writes) table-based information that is
+ * needed at the head of an OO document.
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 <math.h>
+#include "FilterInternal.hxx"
+#include "TableStyle.hxx"
+#include "DocumentElement.hxx"
+
+#ifdef _MSC_VER
+#include <minmax.h>
+#endif
+
+using namespace ::rtl;
+using rtl::OUString;
+
+TableCellStyle::TableCellStyle(const float fLeftBorderThickness, const float fRightBorderThickness,
+ const float fTopBorderThickness, const float fBottomBorderThickness,
+ const RGBSColor *pFgColor, const RGBSColor *pBgColor, const char *psName) :
+ Style(psName),
+ mfLeftBorderThickness(fLeftBorderThickness),
+ mfRightBorderThickness(fRightBorderThickness),
+ mfTopBorderThickness(fTopBorderThickness),
+ mfBottomBorderThickness(fBottomBorderThickness)
+{
+ if (pFgColor != NULL) {
+ m_fgColor.m_r = pFgColor->m_r;
+ m_fgColor.m_g = pFgColor->m_g;
+ m_fgColor.m_b = pFgColor->m_b;
+ m_fgColor.m_s = pFgColor->m_s;
+ }
+ else {
+ m_fgColor.m_r = m_fgColor.m_g = m_fgColor.m_b = 0xFF;
+ m_fgColor.m_s = 0x64; // 100%
+ }
+ if (pBgColor != NULL) {
+ m_bgColor.m_r = pBgColor->m_r;
+ m_bgColor.m_g = pBgColor->m_g;
+ m_bgColor.m_b = pBgColor->m_b;
+ m_bgColor.m_s = pBgColor->m_s;
+ }
+ else {
+ m_bgColor.m_r = m_bgColor.m_g = m_bgColor.m_b = 0xFF;
+ m_bgColor.m_s = 0x64; // 100%
+ }
+}
+
+void TableCellStyle::write(Reference < XDocumentHandler > &xHandler) const
+{
+ TagOpenElement styleOpen("style:style");
+ styleOpen.addAttribute("style:name", getName());
+ styleOpen.addAttribute("style:family", "table-cell");
+ styleOpen.write(xHandler);
+
+ TagOpenElement stylePropertiesOpen("style:properties");
+ UTF8String sBackgroundColor;
+ float fgAmount = (float)m_fgColor.m_s/100.0f;
+ float bgAmount = max(((float)m_bgColor.m_s-(float)m_fgColor.m_s)/100.0f, 0.0f);
+
+ int bgRed = min((int)(((float)m_fgColor.m_r*fgAmount)+((float)m_bgColor.m_r*bgAmount)), 255);
+ int bgGreen = min((int)(((float)m_fgColor.m_g*fgAmount)+((float)m_bgColor.m_g*bgAmount)), 255);
+ int bgBlue = min((int)(((float)m_fgColor.m_b*fgAmount)+((float)m_bgColor.m_b*bgAmount)), 255);
+ sBackgroundColor.sprintf("#%.2x%.2x%.2x", bgRed, bgGreen, bgBlue);
+ stylePropertiesOpen.addAttribute("fo:background-color", sBackgroundColor.getUTF8());
+ stylePropertiesOpen.addAttribute("fo:padding", "0.0382inch");
+ UTF8String sBorderLeft;
+ sBorderLeft.sprintf("%finch solid #000000", mfLeftBorderThickness);
+ stylePropertiesOpen.addAttribute("fo:border-left", sBorderLeft.getUTF8());
+ UTF8String sBorderRight;
+ sBorderRight.sprintf("%finch solid #000000", mfRightBorderThickness);
+ stylePropertiesOpen.addAttribute("fo:border-right", sBorderRight.getUTF8());
+ UTF8String sBorderTop;
+ sBorderTop.sprintf("%finch solid #000000", mfTopBorderThickness);
+ stylePropertiesOpen.addAttribute("fo:border-top", sBorderTop.getUTF8());
+ UTF8String sBorderBottom;
+ sBorderBottom.sprintf("%finch solid #000000", mfBottomBorderThickness);
+ stylePropertiesOpen.addAttribute("fo:border-bottom", sBorderBottom.getUTF8());
+ stylePropertiesOpen.write(xHandler);
+ xHandler->endElement(OUString::createFromAscii("style:properties"));
+
+ xHandler->endElement(OUString::createFromAscii("style:style"));
+
+// xHandler->endElement(OUString::createFromAscii("<style:style style:name=\"%s\" style:family=\"%s\"><style:properties fo:background-color=\"#%.2x%.2x%.2x\" fo:padding=\"0.0382inch\" fo:border-left=\"%finch solid #000000\" fo:border-right=\"%finch solid #000000\" fo:border-top=\"%finch solid #000000\" fo:border-bottom=\"%finch solid #000000\"/></style:style>\n", getName(), "table-cell",
+// m_fgColor.m_r, m_fgColor.m_g, m_fgColor.m_b,
+// mfLeftBorderThickness, mfRightBorderThickness,
+// mfTopBorderThickness, mfBottomBorderThickness);
+}
+
+
+TableStyle::TableStyle(const float fDocumentMarginLeft, const float fDocumentMarginRight,
+ const float fMarginLeftOffset, const float fMarginRightOffset,
+ const uint8_t iTablePositionBits, const float fLeftOffset,
+ const vector < WPXColumnDefinition > &columns, const char *psName) :
+ Style(psName),
+ mfDocumentMarginLeft(fDocumentMarginLeft),
+ mfDocumentMarginRight(fDocumentMarginRight),
+ mfMarginLeftOffset(fMarginLeftOffset),
+ mfMarginRightOffset(fMarginRightOffset),
+ miTablePositionBits(iTablePositionBits),
+ mfLeftOffset(fLeftOffset),
+ miNumColumns(columns.size())
+
+{
+ WRITER_DEBUG_MSG(("WriterWordPerfect: Created a new set of table props with this no. of columns repeated: %i and this name: %s\n",
+ (int)miNumColumns, (const char *)getName()));
+
+ typedef vector<WPXColumnDefinition>::const_iterator CDVIter;
+ for (CDVIter iterColumns = columns.begin() ; iterColumns != columns.end(); iterColumns++)
+ {
+ mColumns.push_back((*iterColumns));
+ }
+}
+
+TableStyle::~TableStyle()
+{
+ typedef vector<TableCellStyle *>::iterator TCSVIter;
+ for (TCSVIter iterTableCellStyles = mTableCellStyles.begin() ; iterTableCellStyles != mTableCellStyles.end(); iterTableCellStyles++)
+ delete(*iterTableCellStyles);
+
+}
+
+void TableStyle::write(Reference < XDocumentHandler > &xHandler) const
+{
+ TagOpenElement styleOpen("style:style");
+ styleOpen.addAttribute("style:name", getName());
+ styleOpen.addAttribute("style:family", "table");
+ if (getMasterPageName())
+ styleOpen.addAttribute("style:master-page-name", getMasterPageName()->getUTF8());
+ styleOpen.write(xHandler);
+
+ TagOpenElement stylePropertiesOpen("style:properties");
+
+ UTF8String sTableMarginLeft;
+ UTF8String sTableMarginRight;
+ UTF8String sTableAlignment;
+ char *pTableAlignment = NULL;
+ if (miTablePositionBits == WPX_TABLE_POSITION_ALIGN_WITH_LEFT_MARGIN) {
+ sTableAlignment.sprintf("left");
+ sTableMarginLeft.sprintf("0inch");
+ }
+ else if (miTablePositionBits == WPX_TABLE_POSITION_ALIGN_WITH_RIGHT_MARGIN) {
+ sTableAlignment.sprintf("right");
+ }
+ else if (miTablePositionBits == WPX_TABLE_POSITION_CENTER_BETWEEN_MARGINS) {
+ sTableAlignment.sprintf("center");
+ }
+ else if (miTablePositionBits == WPX_TABLE_POSITION_ABSOLUTE_FROM_LEFT_MARGIN) {
+ sTableAlignment.sprintf("left");
+ sTableMarginLeft.sprintf("%finch", (mfLeftOffset-mfDocumentMarginLeft+mfMarginLeftOffset));
+ }
+ else if (miTablePositionBits == WPX_TABLE_POSITION_FULL) {
+ sTableAlignment.sprintf("margins");
+ sTableMarginLeft.sprintf("%finch", mfMarginLeftOffset);
+ sTableMarginRight.sprintf("%finch", mfMarginRightOffset);
+ }
+ stylePropertiesOpen.addAttribute("table:align", sTableAlignment.getUTF8());
+ if (sTableMarginLeft.getUTF8())
+ stylePropertiesOpen.addAttribute("fo:margin-left", sTableMarginLeft.getUTF8());
+ if (sTableMarginRight.getUTF8())
+ stylePropertiesOpen.addAttribute("fo:margin-right", sTableMarginRight.getUTF8());
+
+ float fTableWidth = 0;
+ typedef vector<WPXColumnDefinition>::const_iterator CDVIter;
+ for (CDVIter iterColumns2 = mColumns.begin() ; iterColumns2 != mColumns.end(); iterColumns2++)
+ {
+ fTableWidth += (*iterColumns2).m_width;
+ }
+ UTF8String sTableWidth;
+ sTableWidth.sprintf("%finch", fTableWidth);
+ stylePropertiesOpen.addAttribute("style:width", sTableWidth.getUTF8());
+ stylePropertiesOpen.write(xHandler);
+
+ xHandler->endElement(OUString::createFromAscii("style:properties"));
+
+ xHandler->endElement(OUString::createFromAscii("style:style"));
+
+
+// if (getMasterPageName()) {
+// xHandler->endElement(OUString::createFromAscii("<style:style style:name=\"%s\" style:family=\"%s\" style:master-page-name=\"%s\"><style:properties table:align=\"%s\" %s %s style:width=\"%finch\"/></style:style>\n", getName(), "table", getMasterPageName()->getUTF8(), pTableAlignment, psTableMarginLeft, psTableMarginRight, fTableWidth);
+// }
+// else {
+// xHandler->endElement(OUString::createFromAscii("<style:style style:name=\"%s\" style:family=\"%s\"><style:properties table:align=\"%s\" %s %s style:width=\"%finch\"/></style:style>\n", getName(), "table", pTableAlignment, psTableMarginLeft, psTableMarginRight, fTableWidth);
+// }
+
+ int i=1;
+ typedef vector<WPXColumnDefinition>::const_iterator CDVIter;
+ for (CDVIter iterColumns = mColumns.begin() ; iterColumns != mColumns.end(); iterColumns++)
+ {
+ TagOpenElement styleOpen("style:style");
+ UTF8String sColumnName;
+ sColumnName.sprintf("%s.Column%i", (const char *)getName(), i);
+ styleOpen.addAttribute("style:name", sColumnName.getUTF8());
+ styleOpen.addAttribute("style:family", "table-column");
+ styleOpen.write(xHandler);
+
+ TagOpenElement stylePropertiesOpen("style:properties");
+ UTF8String sColumnWidth;
+ sColumnWidth.sprintf("%finch", (*iterColumns).m_width);
+ stylePropertiesOpen.addAttribute("style:column-width", sColumnWidth.getUTF8());
+ stylePropertiesOpen.write(xHandler);
+ xHandler->endElement(OUString::createFromAscii("style:properties"));
+
+ xHandler->endElement(OUString::createFromAscii("style:style"));
+
+//xHandler->endElement(OUString::createFromAscii("<style:style style:name=\"%s.Column%i\" style:family=\"%s\"><style:properties style:column-width=\"%finch\"/></style:style>\n", getName(), i, "table-column", (*iter).m_width);
+ i++;
+ }
+
+ typedef vector<TableCellStyle *>::const_iterator TCSVIter;
+ for (TCSVIter iterTableCell = mTableCellStyles.begin() ; iterTableCell != mTableCellStyles.end(); iterTableCell++)
+ (*iterTableCell)->write(xHandler);
+}
diff --git a/writerperfect/source/filter/TableStyle.hxx b/writerperfect/source/filter/TableStyle.hxx
new file mode 100644
index 000000000000..ecf5cfe85858
--- /dev/null
+++ b/writerperfect/source/filter/TableStyle.hxx
@@ -0,0 +1,79 @@
+/* TableStyle: Stores (and writes) table-based information that is
+ * needed at the head of an OO document.
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 _TABLESTYLE_H
+#define _TABLESTYLE_H
+#include <libwpd/libwpd.h>
+#include <vector>
+
+#include "Style.hxx"
+#include "WriterProperties.hxx"
+
+using com::sun::star::uno::Reference;
+using com::sun::star::xml::sax::XDocumentHandler;
+
+class DocumentElement;
+
+class TableCellStyle : public Style
+{
+public:
+ TableCellStyle(const float fLeftBorderThickness, const float fRightBorderThickness,
+ const float fTopBorderThickness, const float fBottomBorderThickness,
+ const RGBSColor *pFgColor, const RGBSColor *pBgColor, const char *psName);
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+private:
+ float mfLeftBorderThickness;
+ float mfRightBorderThickness;
+ float mfTopBorderThickness;
+ float mfBottomBorderThickness;
+ RGBSColor m_fgColor;
+ RGBSColor m_bgColor;
+};
+
+class TableStyle : public Style, public TopLevelElementStyle
+{
+ public:
+ TableStyle(const float fDocumentMarginLeft, const float fDocumentMarginRight,
+ const float fMarginLeftOffset, const float fMarginRightOffset,
+ const uint8_t iTablePositionBits, const float fLeftOffset,
+ const vector < WPXColumnDefinition > &columns,
+ const char *psName);
+ ~TableStyle();
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+ const int getNumColumns() const { return miNumColumns; }
+ void addTableCellStyle(TableCellStyle *pTableCellStyle) { mTableCellStyles.push_back(pTableCellStyle); }
+ int getNumTableCellStyles() { return mTableCellStyles.size(); }
+private:
+ float mfDocumentMarginLeft, mfDocumentMarginRight;
+ float mfMarginLeftOffset, mfMarginRightOffset;
+ vector< WPXColumnDefinition > mColumns;
+ unsigned int miTablePositionBits;
+ float mfLeftOffset;
+ vector<TableCellStyle *> mTableCellStyles;
+ int miNumColumns;
+};
+
+#endif
diff --git a/writerperfect/source/filter/TextRunStyle.cxx b/writerperfect/source/filter/TextRunStyle.cxx
new file mode 100644
index 000000000000..1e118a66d385
--- /dev/null
+++ b/writerperfect/source/filter/TextRunStyle.cxx
@@ -0,0 +1,248 @@
+/* TextRunStyle: Stores (and writes) paragraph/span-style-based information
+ * (e.g.: a paragraph might be bold) that is needed at the head of an OO
+ * document.
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 "FilterInternal.hxx"
+#include "TextRunStyle.hxx"
+#include "WriterProperties.hxx"
+#include "DocumentElement.hxx"
+#ifdef _MSC_VER
+#include <minmax.h>
+#endif
+
+using namespace ::rtl;
+using rtl::OUString;
+
+ParagraphStyle::ParagraphStyle(const uint8_t iParagraphJustification,
+ const float fMarginLeft, const float fMarginRight, const float fTextIndent,
+ const float fLineSpacing, const float fSpacingAfterParagraph,
+ const bool bColumnBreak, const bool bPageBreak,
+ const char *psName, const char *psParentName) :
+ Style(psName),
+ msParentName(psParentName),
+ mpsListStyleName(NULL),
+ mfMarginLeft(fMarginLeft),
+ mfMarginRight(fMarginRight),
+ mfTextIndent(fTextIndent),
+ mfLineSpacing(fLineSpacing),
+ mfSpacingAfterParagraph(fSpacingAfterParagraph),
+ miParagraphJustification(iParagraphJustification),
+ mbColumnBreak(bColumnBreak),
+ mbPageBreak(bPageBreak)
+{
+}
+
+ParagraphStyle::~ParagraphStyle()
+{
+ if (mpsListStyleName)
+ delete mpsListStyleName;
+}
+
+void ParagraphStyle::write(Reference < XDocumentHandler > &xHandler) const
+{
+ WRITER_DEBUG_MSG(("Writing a paragraph style..\n"));
+ TagOpenElement styleOpen("style:style");
+ styleOpen.addAttribute("style:name", getName());
+ styleOpen.addAttribute("style:family", "paragraph");
+ styleOpen.addAttribute("style:parent-style-name", msParentName);
+ if (getMasterPageName())
+ styleOpen.addAttribute("style:master-page-name", getMasterPageName()->getUTF8());
+ if (mpsListStyleName)
+ styleOpen.addAttribute("style:list-style-name", mpsListStyleName->getUTF8());
+ styleOpen.write(xHandler);
+
+ TagOpenElement stylePropertiesOpen("style:properties");
+ // margin properties
+ if (mfMarginLeft != 0.0f || mfMarginRight != 0.0f || mfTextIndent != 0.0f)
+ {
+ UTF8String sMarginLeft;
+ sMarginLeft.sprintf("%finch", mfMarginLeft);
+ UTF8String sMarginRight;
+ sMarginRight.sprintf("%finch", mfMarginRight);
+ UTF8String sTextIndent;
+ sTextIndent.sprintf("%finch", mfTextIndent);
+ stylePropertiesOpen.addAttribute("fo:margin-left", sMarginLeft.getUTF8());
+ stylePropertiesOpen.addAttribute("fo:margin-right", sMarginRight.getUTF8());
+ stylePropertiesOpen.addAttribute("fo:text-indent", sTextIndent.getUTF8());
+ }
+ // line spacing
+ if (mfLineSpacing != 1.0f) {
+ UTF8String sLineSpacing;
+ sLineSpacing.sprintf("%.2f%%", mfLineSpacing*100.0f);
+ stylePropertiesOpen.addAttribute("fo:line-height", sLineSpacing.getUTF8());
+ }
+ if (mfSpacingAfterParagraph != 0.0f) {
+ UTF8String sSpacingAfterParagraph;
+ sSpacingAfterParagraph.sprintf("%finch", mfSpacingAfterParagraph);
+ UTF8String sSpacingBeforeParagraph;
+ sSpacingBeforeParagraph.sprintf("%finch", 0.0f);
+ stylePropertiesOpen.addAttribute("fo:margin-top", sSpacingBeforeParagraph.getUTF8());
+ stylePropertiesOpen.addAttribute("fo:margin-bottom", sSpacingAfterParagraph.getUTF8());
+ }
+
+ // column break
+ if (mbColumnBreak) {
+ stylePropertiesOpen.addAttribute("fo:break-before", "column");
+ }
+
+ if (mbPageBreak) {
+ stylePropertiesOpen.addAttribute("fo:break-before", "page");
+ }
+
+ WRITER_DEBUG_MSG(("WriterWordPerfect: Adding justification style props: %i\n", miParagraphJustification));
+ switch (miParagraphJustification)
+ {
+ case WPX_PARAGRAPH_JUSTIFICATION_LEFT:
+ // doesn't require a paragraph prop - it is the default, but, like, whatever
+ stylePropertiesOpen.addAttribute("fo:text-align", "left");
+ break;
+ case WPX_PARAGRAPH_JUSTIFICATION_CENTER:
+ stylePropertiesOpen.addAttribute("fo:text-align", "center");
+ break;
+ case WPX_PARAGRAPH_JUSTIFICATION_RIGHT:
+ stylePropertiesOpen.addAttribute("fo:text-align", "end");
+ break;
+ case WPX_PARAGRAPH_JUSTIFICATION_FULL:
+ stylePropertiesOpen.addAttribute("fo:text-align", "justify");
+ break;
+ case WPX_PARAGRAPH_JUSTIFICATION_FULL_ALL_LINES:
+ stylePropertiesOpen.addAttribute("fo:text-align", "justify");
+ stylePropertiesOpen.addAttribute("fo:text-align-last", "justify");
+ break;
+ }
+ stylePropertiesOpen.addAttribute("style:justify-single-word", "false");
+ stylePropertiesOpen.write(xHandler);
+
+ xHandler->endElement(OUString::createFromAscii("style:properties"));
+ xHandler->endElement(OUString::createFromAscii("style:style"));
+}
+
+SpanStyle::SpanStyle(const uint32_t iTextAttributeBits, const char *pFontName, const float fFontSize,
+ const RGBSColor *pFontColor, const RGBSColor *pHighlightColor, const char *psName) :
+ Style(psName),
+ miTextAttributeBits(iTextAttributeBits),
+ msFontName(pFontName),
+ mfFontSize(fFontSize),
+ m_fontColor(pFontColor->m_r,pFontColor->m_g,pFontColor->m_b,pFontColor->m_s),
+ m_highlightColor((pHighlightColor?pHighlightColor->m_r:0xff), (pHighlightColor?pHighlightColor->m_g:0xff),
+ (pHighlightColor?pHighlightColor->m_b:0xff), (pHighlightColor?pHighlightColor->m_s:0xff))
+{
+}
+
+void SpanStyle::write(Reference < XDocumentHandler > &xHandler) const
+{
+ WRITER_DEBUG_MSG(("Writing a span style..\n"));
+ TagOpenElement styleOpen("style:style");
+ styleOpen.addAttribute("style:name", getName());
+ styleOpen.addAttribute("style:family", "text");
+ styleOpen.write(xHandler);
+
+ TagOpenElement stylePropertiesOpen("style:properties");
+ _addTextProperties(&stylePropertiesOpen);
+ stylePropertiesOpen.write(xHandler);
+
+ xHandler->endElement(OUString::createFromAscii("style:properties"));
+ xHandler->endElement(OUString::createFromAscii("style:style"));
+}
+
+void SpanStyle::_addTextProperties(TagOpenElement *pStylePropertiesOpenElement) const
+{
+ if (miTextAttributeBits & WPX_SUPERSCRIPT_BIT) {
+ UTF8String sSuperScript;
+ sSuperScript.sprintf("super %s", IMP_DEFAULT_SUPER_SUB_SCRIPT);
+ pStylePropertiesOpenElement->addAttribute("style:text-position", sSuperScript.getUTF8());
+ }
+ if (miTextAttributeBits & WPX_SUBSCRIPT_BIT) {
+ UTF8String sSubScript;
+ sSubScript.sprintf("sub %s", IMP_DEFAULT_SUPER_SUB_SCRIPT);
+ pStylePropertiesOpenElement->addAttribute("style:text-position", sSubScript.getUTF8());
+ }
+ if (miTextAttributeBits & WPX_ITALICS_BIT) {
+ pStylePropertiesOpenElement->addAttribute("fo:font-style", "italic");
+ }
+ if (miTextAttributeBits & WPX_BOLD_BIT) {
+ pStylePropertiesOpenElement->addAttribute("fo:font-weight", "bold");
+ }
+ if (miTextAttributeBits & WPX_STRIKEOUT_BIT) {
+ pStylePropertiesOpenElement->addAttribute("style:text-crossing-out", "single-line");
+ }
+ if (miTextAttributeBits & WPX_UNDERLINE_BIT) {
+ pStylePropertiesOpenElement->addAttribute("style:text-underline", "single");
+ }
+ if (miTextAttributeBits & WPX_DOUBLE_UNDERLINE_BIT) {
+ pStylePropertiesOpenElement->addAttribute("style:text-underline", "double");
+ }
+ if (miTextAttributeBits & WPX_OUTLINE_BIT) {
+ pStylePropertiesOpenElement->addAttribute("style:text-outline", "true");
+ }
+ if (miTextAttributeBits & WPX_SMALL_CAPS_BIT) {
+ pStylePropertiesOpenElement->addAttribute("fo:font-variant", "small-caps");
+ }
+ if (miTextAttributeBits & WPX_BLINK_BIT) {
+ pStylePropertiesOpenElement->addAttribute("style:text-blinking", "true");
+ }
+ if (miTextAttributeBits & WPX_SHADOW_BIT) {
+ pStylePropertiesOpenElement->addAttribute("fo:text-shadow", "1pt 1pt");
+ }
+
+ pStylePropertiesOpenElement->addAttribute("style:font-name", msFontName.getUTF8());
+ UTF8String sFontSize;
+ sFontSize.sprintf("%ipt", (int)mfFontSize);
+ pStylePropertiesOpenElement->addAttribute("fo:font-size", sFontSize.getUTF8());
+
+ if (!(miTextAttributeBits & WPX_REDLINE_BIT))
+ // Here we give the priority to the redline bit over the font color. This is how WordPerfect behaves:
+ // redline overrides font color even if the color is changed when redline was already defined.
+ // When redline finishes, the color is back.
+ {
+ UTF8String sFontColor;
+ float fontShading = (float)((float)m_fontColor.m_s/100.0f); //convert the percents to float between 0 and 1
+ // Mix fontShading amount of given color with (1-fontShading) of White (#ffffff)
+ int fontRed = (int)0xFF + (int)((float)m_fontColor.m_r*fontShading) - (int)((float)0xFF*fontShading);
+ int fontGreen = (int)0xFF + (int)((float)m_fontColor.m_g*fontShading) - (int)((float)0xFF*fontShading);
+ int fontBlue = (int)0xFF + (int)((float)m_fontColor.m_b*fontShading) - (int)((float)0xFF*fontShading);
+ sFontColor.sprintf("#%.2x%.2x%.2x", fontRed, fontGreen, fontBlue);
+ pStylePropertiesOpenElement->addAttribute("fo:color", sFontColor.getUTF8());
+ }
+ else // redlining applies
+ {
+ pStylePropertiesOpenElement->addAttribute("fo:color", "#ff3333"); // #ff3333 = a nice bright red
+ }
+
+ if (m_highlightColor.m_s != 0xff)
+ {
+ UTF8String sHighlightColor;
+ float highlightShading = (float)((float)m_highlightColor.m_s/100.0f);
+ int highlightRed = (int)0xFF + (int)((float)m_highlightColor.m_r*highlightShading) - (int)((float)0xFF*highlightShading);
+ int highlightGreen = (int)0xFF + (int)((float)m_highlightColor.m_g*highlightShading) - (int)((float)0xFF*highlightShading);
+ int highlightBlue = (int)0xFF + (int)((float)m_highlightColor.m_b*highlightShading) - (int)((float)0xFF*highlightShading);
+ sHighlightColor.sprintf("#%.2x%.2x%.2x", highlightRed, highlightGreen, highlightBlue);
+ pStylePropertiesOpenElement->addAttribute("style:text-background-color", sHighlightColor.getUTF8());
+ }
+ else
+ pStylePropertiesOpenElement->addAttribute("style:text-background-color", "transparent");
+
+}
diff --git a/writerperfect/source/filter/TextRunStyle.hxx b/writerperfect/source/filter/TextRunStyle.hxx
new file mode 100644
index 000000000000..0ce6d3e7ad7d
--- /dev/null
+++ b/writerperfect/source/filter/TextRunStyle.hxx
@@ -0,0 +1,87 @@
+/* TextRunStyle: Stores (and writes) paragraph/span-style-based information
+ * (e.g.: a paragraph might be bold) that is needed at the head of an OO
+ * document.
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 _TEXTRUNSTYLE_H
+#define _TEXTRUNSTYLE_H
+#include <libwpd/libwpd.h>
+
+#include "Style.hxx"
+
+using com::sun::star::uno::Reference;
+using com::sun::star::xml::sax::XDocumentHandler;
+
+class TagOpenElement;
+class DocumentElement;
+
+class SpanStyle : public Style
+{
+public:
+ SpanStyle(const uint32_t iTextAttributeBits, const char *pFontName, const float fFontSize, const RGBSColor *pFontColor,
+ const RGBSColor *pHighlightColor, const char *psName);
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+ const int getTextAttributeBits() const { return miTextAttributeBits; }
+ const UTF8String & getFontName() const { return msFontName; }
+ const float getFontSize() const { return mfFontSize; }
+
+ void _addTextProperties(TagOpenElement *pStylePropertiesOpenElement) const;
+
+private:
+ int miTextAttributeBits;
+ UTF8String msFontName;
+ float mfFontSize;
+ RGBSColor m_fontColor;
+ RGBSColor m_highlightColor;
+};
+
+class ParagraphStyle : public Style, public TopLevelElementStyle
+{
+public:
+ ParagraphStyle(const uint8_t iParagraphJustification,
+ const float fMarginLeft, const float fMarginRight, const float fTextIndent,
+ const float fLineSpacing, const float fSpacingAfterParagraph,
+ const bool bColumnBreak, const bool bPageBreak, const char *psName, const char *psParentName);
+
+ virtual ~ParagraphStyle();
+
+ void setListStyleName(UTF8String &sListStyleName) { delete mpsListStyleName ; mpsListStyleName = new UTF8String(sListStyleName); }
+ virtual void write(Reference < XDocumentHandler > &xHandler) const;
+ const virtual bool isParagraphStyle() const { return true; }
+
+private:
+ UTF8String msParentName;
+ UTF8String *mpsListStyleName;
+ float mfMarginLeft;
+ float mfMarginRight;
+ float mfTextIndent;
+ float mfLineSpacing;
+ float mfSpacingAfterParagraph;
+ uint8_t miParagraphJustification;
+ bool mbColumnBreak;
+ bool mbPageBreak;
+};
+#endif
diff --git a/writerperfect/source/filter/WriterProperties.hxx b/writerperfect/source/filter/WriterProperties.hxx
new file mode 100644
index 000000000000..8b6466ac406c
--- /dev/null
+++ b/writerperfect/source/filter/WriterProperties.hxx
@@ -0,0 +1,36 @@
+/* WriterProperties: A grab bag of writer-specific properties which we use
+ * define here for later use.
+ *
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ *
+ * 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 _WRITER_PROPERTIES_H
+#define _WRITER_PROPERTIES_H
+
+#define IMP_DEFAULT_SUPER_SUB_SCRIPT "58%"
+#define IMP_NUM_CENTIMETERES_PER_INCH 2.54f
+#define IMP_DEFAULT_FONT_NAME "Times New Roman"
+#define IMP_DEFAULT_FONT_SIZE 12.0f
+#define IMP_DEFAULT_FONT_PITCH "variable"
+#define IMP_DEFAULT_FONT_COLOR (new RGBSColor(0x00,0x00,0x00,0x64))
+#endif
diff --git a/writerperfect/source/filter/makefile.mk b/writerperfect/source/filter/makefile.mk
new file mode 100644
index 000000000000..9cd1bbac79bc
--- /dev/null
+++ b/writerperfect/source/filter/makefile.mk
@@ -0,0 +1,25 @@
+PRJ=..$/..
+
+PRJNAME=filter
+TARGET=filter
+ENABLE_EXCEPTIONS=true
+
+.INCLUDE : settings.mk
+
+# broken but ... necessary, internal include shafted ...
+INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwpd -I..
+
+SLOFILES= \
+ $(SLO)$/DocumentElement.obj \
+ $(SLO)$/FontMap.obj \
+ $(SLO)$/FontStyle.obj \
+ $(SLO)$/ListStyle.obj \
+ $(SLO)$/PageSpan.obj \
+ $(SLO)$/SectionStyle.obj \
+ $(SLO)$/TableStyle.obj \
+ $(SLO)$/TextRunStyle.obj \
+ $(SLO)$/WordPerfectCollector.obj \
+ $(SLO)$/WordPerfectImportFilter.obj \
+ $(SLO)$/genericfilter.obj
+
+.INCLUDE : target.mk
diff --git a/writerperfect/source/stream/WPXSvStream.cxx b/writerperfect/source/stream/WPXSvStream.cxx
new file mode 100644
index 000000000000..f6f14e85d3c8
--- /dev/null
+++ b/writerperfect/source/stream/WPXSvStream.cxx
@@ -0,0 +1,103 @@
+#include "WPXSvStream.h"
+#include "libwpd_internal.h"
+
+#include <sot/storage.hxx>
+#include <tools/stream.hxx>
+#include <unotools/streamwrap.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_H_
+#include <com/sun/star/io/XSeekable.hpp>
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+
+WPXSvInputStream::WPXSvInputStream( Reference< XInputStream > xStream ) :
+ WPXInputStream(true),
+ mxStream(xStream),
+ mnOffset(0)
+{
+ Reference < XSeekable> xSeekable = Reference < XSeekable > (xStream, UNO_QUERY);
+ if (!xSeekable.is())
+ mnLength = 0;
+ else
+ mnLength = xSeekable->getLength(); // exception
+}
+
+WPXSvInputStream::~WPXSvInputStream()
+{
+}
+
+const uint8_t * WPXSvInputStream::read(size_t numBytes)
+{
+ // FIXME: assume no short reads (?)
+ mnOffset += mxStream->readBytes (maData, numBytes);
+ return (const uint8_t *)maData.getConstArray();
+}
+
+int WPXSvInputStream::seek(long offset, WPX_SEEK_TYPE seekType)
+{
+ if (seekType == WPX_SEEK_CUR && offset >= 0)
+ {
+ mxStream->skipBytes (offset); // exception ?
+ mnOffset += offset;
+ return FALSE;
+ }
+
+ Reference < XSeekable> xSeekable = Reference < XSeekable >(mxStream, UNO_QUERY);
+
+ if (!xSeekable.is())
+ return TRUE;
+
+ if (seekType == WPX_SEEK_CUR)
+ mnOffset += offset;
+ else
+ mnOffset = offset;
+
+ xSeekable->seek(mnOffset); // FIXME: catch exception!
+
+ return FALSE;
+}
+
+long WPXSvInputStream::tell()
+{
+ return mnOffset;
+}
+
+bool WPXSvInputStream::atEOS()
+{
+ return mnOffset < mnLength;
+}
+
+bool WPXSvInputStream::isOLEStream()
+{
+ bool bAns;
+
+ SvStream *pStream = utl::UcbStreamHelper::CreateStream( mxStream );
+ bAns = pStream && SotStorage::IsOLEStorage( pStream );
+ delete pStream;
+
+ return bAns;
+}
+
+WPXInputStream * WPXSvInputStream::getDocumentOLEStream()
+{
+ SvStream *pStream = utl::UcbStreamHelper::CreateStream( mxStream );
+
+ SotStorage *pStorage = new SotStorage( pStream, TRUE );
+
+ fprintf (stderr, "Dodgy\n");
+ SvStream *pContents = pStorage->OpenSotStream(
+ rtl::OUString::createFromAscii( "PerfectOffice_MAIN" ),
+ STREAM_STD_READ );
+
+ Reference < XInputStream > xContents = new utl::OInputStreamWrapper( pStream );
+ if (xContents.is())
+ return new WPXSvInputStream( xContents );
+ else {
+ fprintf( stderr, "Badly wrong\n" );
+ return NULL;
+ }
+ // FIXME: we leak pStorage - investigate protected destructor there.
+}
diff --git a/writerperfect/source/stream/WPXSvStream.h b/writerperfect/source/stream/WPXSvStream.h
new file mode 100644
index 000000000000..cf12b286a904
--- /dev/null
+++ b/writerperfect/source/stream/WPXSvStream.h
@@ -0,0 +1,33 @@
+#ifndef WPXSVSTREAM_H
+#define WPXSVSTREAM_H
+
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_H_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+
+#include <libwpd/WPXStream.h>
+
+class WPXSvInputStream : public WPXInputStream
+{
+public:
+ WPXSvInputStream( ::com::sun::star::uno::Reference<
+ ::com::sun::star::io::XInputStream > xStream );
+ virtual ~WPXSvInputStream();
+
+ virtual bool isOLEStream();
+ virtual WPXInputStream * getDocumentOLEStream();
+
+ virtual const uint8_t *read(size_t numBytes);
+ virtual int seek(long offset, WPX_SEEK_TYPE seekType);
+ virtual long tell();
+ virtual bool atEOS();
+
+private:
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::io::XInputStream > mxStream;
+ ::com::sun::star::uno::Sequence< sal_Int8 > maData;
+ sal_Int64 mnOffset;
+ sal_Int64 mnLength;
+};
+
+#endif
diff --git a/writerperfect/source/stream/makefile.mk b/writerperfect/source/stream/makefile.mk
new file mode 100644
index 000000000000..14d5fe2911c8
--- /dev/null
+++ b/writerperfect/source/stream/makefile.mk
@@ -0,0 +1,14 @@
+PRJ=..$/..
+
+PRJNAME=stream
+TARGET=stream
+ENABLE_EXCEPTIONS=true
+
+.INCLUDE : settings.mk
+
+# broken but ... necessary, internal include shafted ...
+INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwpd
+
+SLOFILES= $(SLO)$/WPXSvStream.obj
+
+.INCLUDE : target.mk