From ebea843b5c693eaef2f601d3739242ed6b8db02c Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 25 Aug 2014 10:14:52 +0900 Subject: Added support for libwpd-0.10. This resolves FTBFS in Debian/Testing. Thanks to Slavek for testing in all Debian/Ubuntu distros and fixing a couple of problems with libwpd-0.8. --- config.h.in | 3 + filters/kword/wordperfect/configure.in.in | 25 +++ .../kword/wordperfect/import/DocumentElement.cxx | 14 +- .../kword/wordperfect/import/DocumentElement.hxx | 20 +- .../kword/wordperfect/import/DocumentHandler.hxx | 9 +- filters/kword/wordperfect/import/FontStyle.hxx | 9 +- filters/kword/wordperfect/import/ListStyle.cxx | 12 +- filters/kword/wordperfect/import/ListStyle.hxx | 16 +- filters/kword/wordperfect/import/PageSpan.cxx | 38 ++-- filters/kword/wordperfect/import/PageSpan.hxx | 5 +- filters/kword/wordperfect/import/SectionStyle.cxx | 8 +- filters/kword/wordperfect/import/SectionStyle.hxx | 8 +- filters/kword/wordperfect/import/Style.hxx | 12 +- filters/kword/wordperfect/import/TableStyle.cxx | 14 +- filters/kword/wordperfect/import/TableStyle.hxx | 16 +- filters/kword/wordperfect/import/TextRunStyle.cxx | 16 +- filters/kword/wordperfect/import/TextRunStyle.hxx | 17 +- .../wordperfect/import/WordPerfectCollector.cxx | 138 +++++++------- .../wordperfect/import/WordPerfectCollector.hxx | 175 ++++++++--------- filters/kword/wordperfect/import/shared_headers.h | 75 ++++++++ filters/kword/wordperfect/import/wpimport.cc | 206 +++++++-------------- 21 files changed, 425 insertions(+), 411 deletions(-) create mode 100644 filters/kword/wordperfect/import/shared_headers.h diff --git a/config.h.in b/config.h.in index 78d8bb0d..e07c90c9 100644 --- a/config.h.in +++ b/config.h.in @@ -92,6 +92,9 @@ /* Defines if your system has libpwd greater than or equal to v0.9.0 */ #undef HAVE_LIBWPD_090 +/* Defines if your system has libpwd greater than or equal to v0.10.0 */ +#undef HAVE_LIBWPD_0100 + /* Define if you have libz */ #undef HAVE_LIBZ diff --git a/filters/kword/wordperfect/configure.in.in b/filters/kword/wordperfect/configure.in.in index d3b83532..de1902e0 100644 --- a/filters/kword/wordperfect/configure.in.in +++ b/filters/kword/wordperfect/configure.in.in @@ -45,6 +45,31 @@ if test -z "$LIBWPD_LIBS"; then fi fi +if test -z "$LIBWPD_LIBS"; then + if test -n "$PKGCONFIG"; then + vers=`$PKGCONFIG libwpd-0.10 --modversion 2>/dev/null` + if test -n "$vers" + then + LIBWPD_LIBS="`$PKGCONFIG libwpd-0.10 --libs`" + LIBWPD_RPATH= + for args in $LIBWPD_LIBS; do + case $args in + -L*) + LIBWPD_RPATH="$LIBWPD_RPATH $args" + ;; + esac + done + LIBWPD_RPATH=`echo $LIBWPD_RPATH | $SED -e "s/-L/-R/g"` + LIBWPD_CFLAGS="`$PKGCONFIG libwpd-0.10 --cflags`" + LIBWPD_VERSION="0.10" + + AC_DEFINE_UNQUOTED(HAVE_WPD, 1, [Defines if your system has the libwpd library]) + AC_DEFINE_UNQUOTED(HAVE_LIBWPD_0100, 1, [Defines if your system has libwpd greater than or equal to v0.10.0]) + AC_SUBST(LIBWPD_VERSION) + fi + fi +fi + AC_SUBST(LIBWPD_LIBS) AC_SUBST(LIBWPD_CFLAGS) AC_SUBST(LIBWPD_RPATH) diff --git a/filters/kword/wordperfect/import/DocumentElement.cxx b/filters/kword/wordperfect/import/DocumentElement.cxx index 4f0428ab..a1a92892 100644 --- a/filters/kword/wordperfect/import/DocumentElement.cxx +++ b/filters/kword/wordperfect/import/DocumentElement.cxx @@ -48,7 +48,7 @@ void TagOpenElement::print() const TagElement::print(); } -void TagOpenElement::addAttribute(const char *szAttributeName, const WPXString &sAttributeValue) +void TagOpenElement::addAttribute(const char *szAttributeName, const _SH_String &sAttributeValue) { maAttrList.insert(szAttributeName, sAttributeValue); } @@ -66,8 +66,12 @@ void CharDataElement::write(DocumentHandler &xHandler) const xHandler.characters(msData); } -TextElement::TextElement(const WPXString & sTextBuf) : +TextElement::TextElement(const _SH_String & sTextBuf) : +#ifdef HAVE_LIBWPD_0100 + msTextBuf(sTextBuf) +#else msTextBuf(sTextBuf, false) +#endif { } @@ -75,12 +79,12 @@ TextElement::TextElement(const WPXString & sTextBuf) : // elements void TextElement::write(DocumentHandler &xHandler) const { - WPXPropertyList xBlankAttrList; + _SH_PropertyList xBlankAttrList; - WPXString sTemp; + _SH_String sTemp; int iNumConsecutiveSpaces = 0; - WPXString::Iter i(msTextBuf); + _SH_String::Iter i(msTextBuf); for (i.rewind(); i.next();) { if (*(i()) == ASCII_SPACE) diff --git a/filters/kword/wordperfect/import/DocumentElement.hxx b/filters/kword/wordperfect/import/DocumentElement.hxx index 5bdb03c1..764758e8 100644 --- a/filters/kword/wordperfect/import/DocumentElement.hxx +++ b/filters/kword/wordperfect/import/DocumentElement.hxx @@ -28,14 +28,12 @@ #ifndef _DOCUMENTELEMENT_H #define _DOCUMENTELEMENT_H + #include -#include -#include #include - +#include "shared_headers.h" #include "DocumentHandler.hxx" - 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 @@ -52,10 +50,10 @@ class TagElement : public DocumentElement { public: TagElement(const char *szTagName) : msTagName(szTagName) {} - const WPXString & getTagName() const { return msTagName; } + const _SH_String & getTagName() const { return msTagName; } virtual void print() const; private: - WPXString msTagName; + _SH_String msTagName; }; class TagOpenElement : public TagElement @@ -63,11 +61,11 @@ class TagOpenElement : public TagElement public: TagOpenElement(const char *szTagName) : TagElement(szTagName) {} ~TagOpenElement() {} - void addAttribute(const char *szAttributeName, const WPXString &sAttributeValue); + void addAttribute(const char *szAttributeName, const _SH_String &sAttributeValue); virtual void write(DocumentHandler &xHandler) const; virtual void print () const; private: - WPXPropertyList maAttrList; + _SH_PropertyList maAttrList; }; class TagCloseElement : public TagElement @@ -83,17 +81,17 @@ public: CharDataElement(const char *sData) : DocumentElement(), msData(sData) {} virtual void write(DocumentHandler &xHandler) const; private: - WPXString msData; + _SH_String msData; }; class TextElement : public DocumentElement { public: - TextElement(const WPXString & sTextBuf); + TextElement(const _SH_String & sTextBuf); virtual void write(DocumentHandler &xHandler) const; private: - WPXString msTextBuf; + _SH_String msTextBuf; }; #endif diff --git a/filters/kword/wordperfect/import/DocumentHandler.hxx b/filters/kword/wordperfect/import/DocumentHandler.hxx index a2fe2fa7..ff8e39f0 100644 --- a/filters/kword/wordperfect/import/DocumentHandler.hxx +++ b/filters/kword/wordperfect/import/DocumentHandler.hxx @@ -27,17 +27,18 @@ */ #ifndef _DOCUMENTHANDLER_H #define _DOCUMENTHANDLER_H + #include -#include -#include +#include "shared_headers.h" class DocumentHandler { public: virtual void startDocument() = 0; virtual void endDocument() = 0; - virtual void startElement(const char *psName, const WPXPropertyList &xPropList) = 0; + virtual void startElement(const char *psName, const _SH_PropertyList &xPropList) = 0; virtual void endElement(const char *psName) = 0; - virtual void characters(const WPXString &sCharacters) = 0; + virtual void characters(const _SH_String &sCharacters) = 0; }; + #endif diff --git a/filters/kword/wordperfect/import/FontStyle.hxx b/filters/kword/wordperfect/import/FontStyle.hxx index 04ecfd13..6d09de5c 100644 --- a/filters/kword/wordperfect/import/FontStyle.hxx +++ b/filters/kword/wordperfect/import/FontStyle.hxx @@ -27,10 +27,11 @@ */ #ifndef _FONTSTYLE_H #define _FONTSTYLE_H -#include +#include #include "Style.hxx" #include "WriterProperties.hxx" +#include "shared_headers.h" class FontStyle : public Style { @@ -38,10 +39,10 @@ public: FontStyle(const char *psName, const char *psFontFamily); ~FontStyle(); virtual void write(DocumentHandler &xHandler) const; - const WPXString &getFontFamily() const { return msFontFamily; } + const _SH_String &getFontFamily() const { return msFontFamily; } private: - WPXString msFontFamily; - WPXString msFontPitch; + _SH_String msFontFamily; + _SH_String msFontPitch; }; #endif diff --git a/filters/kword/wordperfect/import/ListStyle.cxx b/filters/kword/wordperfect/import/ListStyle.cxx index 17d150ee..66373a10 100644 --- a/filters/kword/wordperfect/import/ListStyle.cxx +++ b/filters/kword/wordperfect/import/ListStyle.cxx @@ -29,12 +29,12 @@ #include "ListStyle.hxx" #include "DocumentElement.hxx" -OrderedListLevelStyle::OrderedListLevelStyle(const WPXPropertyList &xPropList) : +OrderedListLevelStyle::OrderedListLevelStyle(const _SH_PropertyList &xPropList) : mPropList(xPropList) { } -void OrderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList &xPropList) +void OrderedListStyle::updateListLevel(const int iLevel, const _SH_PropertyList &xPropList) { if (iLevel < 0) return; @@ -44,7 +44,7 @@ void OrderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList & void OrderedListLevelStyle::write(DocumentHandler &xHandler, int iLevel) const { - WPXString sLevel; + _SH_String sLevel; sLevel.sprintf("%i", (iLevel+1)); TagOpenElement listLevelStyleOpen("text:list-level-style-number"); @@ -73,12 +73,12 @@ void OrderedListLevelStyle::write(DocumentHandler &xHandler, int iLevel) const xHandler.endElement("text:list-level-style-number"); } -UnorderedListLevelStyle::UnorderedListLevelStyle(const WPXPropertyList &xPropList) +UnorderedListLevelStyle::UnorderedListLevelStyle(const _SH_PropertyList &xPropList) : mPropList(xPropList) { } -void UnorderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList &xPropList) +void UnorderedListStyle::updateListLevel(const int iLevel, const _SH_PropertyList &xPropList) { if (iLevel < 0) return; @@ -88,7 +88,7 @@ void UnorderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList void UnorderedListLevelStyle::write(DocumentHandler &xHandler, int iLevel) const { - WPXString sLevel; + _SH_String sLevel; sLevel.sprintf("%i", (iLevel+1)); TagOpenElement listLevelStyleOpen("text:list-level-style-bullet"); listLevelStyleOpen.addAttribute("text:level", sLevel); diff --git a/filters/kword/wordperfect/import/ListStyle.hxx b/filters/kword/wordperfect/import/ListStyle.hxx index c0c4ffb0..d8e6a25f 100644 --- a/filters/kword/wordperfect/import/ListStyle.hxx +++ b/filters/kword/wordperfect/import/ListStyle.hxx @@ -28,6 +28,7 @@ #ifndef _LISTSTYLE_H #define _LISTSTYLE_H #include +#include "shared_headers.h" #define WP6_NUM_LIST_LEVELS 8 // see WP6FileStructure.h (we shouldn't need to reference this) @@ -40,24 +41,25 @@ class ListLevelStyle { public: virtual void write(DocumentHandler &xHandler, int iLevel) const = 0; + virtual ~ListLevelStyle() {} }; class OrderedListLevelStyle : public ListLevelStyle { public: - OrderedListLevelStyle(const WPXPropertyList &xPropList); + OrderedListLevelStyle(const _SH_PropertyList &xPropList); virtual void write(DocumentHandler &xHandler, int iLevel) const; private: - WPXPropertyList mPropList; + _SH_PropertyList mPropList; }; class UnorderedListLevelStyle : public ListLevelStyle { public: - UnorderedListLevelStyle(const WPXPropertyList &xPropList); + UnorderedListLevelStyle(const _SH_PropertyList &xPropList); virtual void write(DocumentHandler &xHandler, int iLevel) const; private: - WPXPropertyList mPropList; + _SH_PropertyList mPropList; }; class ListStyle : public Style @@ -65,7 +67,7 @@ class ListStyle : public Style public: ListStyle(const char *psName, const int iListID); virtual ~ListStyle(); - virtual void updateListLevel(const int iLevel, const WPXPropertyList &xPropList) = 0; + virtual void updateListLevel(const int iLevel, const _SH_PropertyList &xPropList) = 0; virtual void write(DocumentHandler &xHandler) const; const int getListID() { return miListID; } const bool isListLevelDefined(int iLevel) const; @@ -83,13 +85,13 @@ class OrderedListStyle : public ListStyle { public: OrderedListStyle(const char *psName, const int iListID) : ListStyle(psName, iListID) {} - void updateListLevel(const int iLevel, const WPXPropertyList &xPropList); + void updateListLevel(const int iLevel, const _SH_PropertyList &xPropList); }; class UnorderedListStyle : public ListStyle { public: UnorderedListStyle(const char *psName, const int iListID) : ListStyle(psName, iListID) {} - void updateListLevel(const int iLevel, const WPXPropertyList &xPropList); + void updateListLevel(const int iLevel, const _SH_PropertyList &xPropList); }; #endif diff --git a/filters/kword/wordperfect/import/PageSpan.cxx b/filters/kword/wordperfect/import/PageSpan.cxx index b2596690..1113004d 100644 --- a/filters/kword/wordperfect/import/PageSpan.cxx +++ b/filters/kword/wordperfect/import/PageSpan.cxx @@ -33,7 +33,7 @@ #include "DocumentElement.hxx" -PageSpan::PageSpan(const WPXPropertyList &xPropList) : +PageSpan::PageSpan(const _SH_PropertyList &xPropList) : #if 0 const int iSpan, const float fFormLength, const float fFormWidth, const WPXFormQt::Orientation fFormQt::Orientation, const float fLeftMargin, const float fRightMargin, const float fTopMargin, const float fBottomMargin): @@ -73,7 +73,7 @@ int PageSpan::getSpan() const float PageSpan::getMarginLeft() const { if (mxPropList["fo:margin-left"]) -#ifdef HAVE_LIBWPD_090 +#if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100) return mxPropList["fo:margin-left"]->getDouble(); #else return mxPropList["fo:margin-left"]->getFloat(); @@ -85,7 +85,7 @@ float PageSpan::getMarginLeft() const float PageSpan::getMarginRight() const { if (mxPropList["fo:margin-right"]) -#ifdef HAVE_LIBWPD_090 +#if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100) return mxPropList["fo:margin-right"]->getDouble(); #else return mxPropList["fo:margin-right"]->getFloat(); @@ -96,27 +96,27 @@ float PageSpan::getMarginRight() const void PageSpan::writePageMaster(const int iNum, DocumentHandler &xHandler) const { - WPXPropertyList propList; + _SH_PropertyList propList; - WPXString sPageMasterName; + _SH_String sPageMasterName; sPageMasterName.sprintf("PM%i", iNum+2); propList.insert("style:name", sPageMasterName); xHandler.startElement("style:page-master", propList); - WPXPropertyList tempPropList = mxPropList; + _SH_PropertyList tempPropList = mxPropList; if (!tempPropList["style:writing-mode"]) - tempPropList.insert("style:writing-mode", WPXString("lr-tb")); + tempPropList.insert("style:writing-mode", _SH_String("lr-tb")); if (!tempPropList["style:footnote-max-height"]) - tempPropList.insert("style:footnote-max-height", WPXString("0inch")); + tempPropList.insert("style:footnote-max-height", _SH_String("0inch")); xHandler.startElement("style:properties", tempPropList); - WPXPropertyList footnoteSepPropList; - footnoteSepPropList.insert("style:width", WPXString("0.0071inch")); - footnoteSepPropList.insert("style:distance-before-sep", WPXString("0.0398inch")); - footnoteSepPropList.insert("style:distance-after-sep", WPXString("0.0398inch")); - footnoteSepPropList.insert("style:adjustment", WPXString("left")); - footnoteSepPropList.insert("style:rel-width", WPXString("25\%")); - footnoteSepPropList.insert("style:color", WPXString("#000000")); + _SH_PropertyList footnoteSepPropList; + footnoteSepPropList.insert("style:width", _SH_String("0.0071inch")); + footnoteSepPropList.insert("style:distance-before-sep", _SH_String("0.0398inch")); + footnoteSepPropList.insert("style:distance-after-sep", _SH_String("0.0398inch")); + footnoteSepPropList.insert("style:adjustment", _SH_String("left")); + footnoteSepPropList.insert("style:rel-width", _SH_String("25\%")); + footnoteSepPropList.insert("style:color", _SH_String("#000000")); xHandler.startElement("style:footnote-sep", footnoteSepPropList); xHandler.endElement("style:footnote-sep"); @@ -127,7 +127,7 @@ void PageSpan::writePageMaster(const int iNum, DocumentHandler &xHandler) const void PageSpan::writeMasterPages(const int iStartingNum, const int iPageMasterNum, const bool bLastPageSpan, DocumentHandler &xHandler) const { - WPXPropertyList propList; // scratch space + _SH_PropertyList propList; // scratch space int iSpan = 0; (bLastPageSpan) ? iSpan = 1 : iSpan = getSpan(); @@ -135,15 +135,15 @@ void PageSpan::writeMasterPages(const int iStartingNum, const int iPageMasterNum for (int i=iStartingNum; i<(iStartingNum+iSpan); i++) { TagOpenElement masterPageOpen("style:master-page"); - WPXString sMasterPageName; + _SH_String sMasterPageName; sMasterPageName.sprintf("Page Style %i", i); - WPXString sPageMasterName; + _SH_String sPageMasterName; sPageMasterName.sprintf("PM%i", iPageMasterNum+2); propList.insert("style:name", sMasterPageName); propList.insert("style:page-master-name", sPageMasterName); if (!bLastPageSpan) { - WPXString sNextMasterPageName; + _SH_String sNextMasterPageName; sNextMasterPageName.sprintf("Page Style %i", (i+1)); propList.insert("style:next-style-name", sNextMasterPageName); } diff --git a/filters/kword/wordperfect/import/PageSpan.hxx b/filters/kword/wordperfect/import/PageSpan.hxx index 61ac0193..58c5ad81 100644 --- a/filters/kword/wordperfect/import/PageSpan.hxx +++ b/filters/kword/wordperfect/import/PageSpan.hxx @@ -29,6 +29,7 @@ #define _PAGESPAN_H #include #include +#include "shared_headers.h" class DocumentElement; class DocumentHandler; @@ -36,7 +37,7 @@ class DocumentHandler; class PageSpan { public: - PageSpan(const WPXPropertyList &xPropList); + PageSpan(const _SH_PropertyList &xPropList); virtual ~PageSpan(); void writePageMaster(const int iNum, DocumentHandler &xHandler) const; void writeMasterPages(const int iStartingNum, const int iPageMasterNum, const bool bLastPageSpan, DocumentHandler &xHandler) const; @@ -58,7 +59,7 @@ protected: void _writeHeaderFooter(const char *headerFooterTagName, const std::vector & headerFooterContent, DocumentHandler &xHandler) const; private: - WPXPropertyList mxPropList; + _SH_PropertyList mxPropList; std::vector * mpHeaderContent; std::vector * mpFooterContent; std::vector * mpHeaderLeftContent; diff --git a/filters/kword/wordperfect/import/SectionStyle.cxx b/filters/kword/wordperfect/import/SectionStyle.cxx index beda648d..153ee45d 100644 --- a/filters/kword/wordperfect/import/SectionStyle.cxx +++ b/filters/kword/wordperfect/import/SectionStyle.cxx @@ -37,8 +37,8 @@ double rint(double x); #endif /* _WIN32 */ -SectionStyle::SectionStyle(const WPXPropertyList &xPropList, - const WPXPropertyListVector &xColumns, +SectionStyle::SectionStyle(const _SH_PropertyList &xPropList, + const _SH_PropertyListVector &xColumns, const char *psName) : Style(psName), mPropList(xPropList), @@ -60,11 +60,11 @@ void SectionStyle::write(DocumentHandler &xHandler) const xHandler.startElement("style:properties", mPropList); // column properties - WPXPropertyList columnProps; + _SH_PropertyList columnProps; columnProps.insert("fo:column-count", (int)mColumns.count()); xHandler.startElement("style:columns", columnProps); - WPXPropertyListVector::Iter i(mColumns); + _SH_PropertyListVector::Iter i(mColumns); for (i.rewind(); i.next();) { xHandler.startElement("style:column", i()); diff --git a/filters/kword/wordperfect/import/SectionStyle.hxx b/filters/kword/wordperfect/import/SectionStyle.hxx index 9508a887..2f01d752 100644 --- a/filters/kword/wordperfect/import/SectionStyle.hxx +++ b/filters/kword/wordperfect/import/SectionStyle.hxx @@ -28,7 +28,7 @@ #ifndef _SECTIONSTYLE_H #define _SECTIONSTYLE_H #include -#include +#include "shared_headers.h" #include "Style.hxx" #include "WriterProperties.hxx" @@ -37,11 +37,11 @@ class SectionStyle : public Style { public: - SectionStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &xColumns, const char *psName); + SectionStyle(const _SH_PropertyList &xPropList, const _SH_PropertyListVector &xColumns, const char *psName); virtual void write(DocumentHandler &xHandler) const; private: - WPXPropertyList mPropList; - WPXPropertyListVector mColumns; + _SH_PropertyList mPropList; + _SH_PropertyListVector mColumns; }; #endif diff --git a/filters/kword/wordperfect/import/Style.hxx b/filters/kword/wordperfect/import/Style.hxx index 80828865..49f5e28e 100644 --- a/filters/kword/wordperfect/import/Style.hxx +++ b/filters/kword/wordperfect/import/Style.hxx @@ -38,23 +38,23 @@ class TopLevelElementStyle public: TopLevelElementStyle() : mpsMasterPageName(NULL) { } virtual ~TopLevelElementStyle() { if (mpsMasterPageName) delete mpsMasterPageName; } - void setMasterPageName(WPXString &sMasterPageName) { mpsMasterPageName = new WPXString(sMasterPageName); } - const WPXString * getMasterPageName() const { return mpsMasterPageName; } + void setMasterPageName(_SH_String &sMasterPageName) { mpsMasterPageName = new _SH_String(sMasterPageName); } + const _SH_String * getMasterPageName() const { return mpsMasterPageName; } private: - WPXString *mpsMasterPageName; + _SH_String *mpsMasterPageName; }; class Style { public: - Style(const WPXString &psName) : msName(psName) {} + Style(const _SH_String &psName) : msName(psName) {} virtual ~Style() {} virtual void write(DocumentHandler &xHandler) const {}; - const WPXString &getName() const { return msName; } + const _SH_String &getName() const { return msName; } private: - WPXString msName; + _SH_String msName; }; #endif diff --git a/filters/kword/wordperfect/import/TableStyle.cxx b/filters/kword/wordperfect/import/TableStyle.cxx index a4fb63ba..2913fea1 100644 --- a/filters/kword/wordperfect/import/TableStyle.cxx +++ b/filters/kword/wordperfect/import/TableStyle.cxx @@ -37,7 +37,7 @@ #include #endif -TableCellStyle::TableCellStyle(const WPXPropertyList &xPropList, const char *psName) : +TableCellStyle::TableCellStyle(const _SH_PropertyList &xPropList, const char *psName) : Style(psName), mPropList(xPropList) { @@ -52,8 +52,8 @@ void TableCellStyle::write(DocumentHandler &xHandler) const // WLACH_REFACTORING: Only temporary.. a much better solution is to // generalize this sort of thing into the "Style" superclass - WPXPropertyList stylePropList; - WPXPropertyList::Iter i(mPropList); + _SH_PropertyList stylePropList; + _SH_PropertyList::Iter i(mPropList); for (i.rewind(); i.next();) { if (strlen(i.key()) > 2 && strncmp(i.key(), "fo", 2) == 0) @@ -66,7 +66,7 @@ void TableCellStyle::write(DocumentHandler &xHandler) const xHandler.endElement("style:style"); } -TableRowStyle::TableRowStyle(const WPXPropertyList &propList, const char *psName) : +TableRowStyle::TableRowStyle(const _SH_PropertyList &propList, const char *psName) : Style(psName), mPropList(propList) { @@ -91,7 +91,7 @@ void TableRowStyle::write(DocumentHandler &xHandler) const } -TableStyle::TableStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &columns, const char *psName) : +TableStyle::TableStyle(const _SH_PropertyList &xPropList, const _SH_PropertyListVector &columns, const char *psName) : Style(psName), mPropList(xPropList), mColumns(columns) @@ -133,11 +133,11 @@ void TableStyle::write(DocumentHandler &xHandler) const xHandler.endElement("style:style"); int i=1; - WPXPropertyListVector::Iter j(mColumns); + _SH_PropertyListVector::Iter j(mColumns); for (j.rewind(); j.next();) { TagOpenElement styleOpen("style:style"); - WPXString sColumnName; + _SH_String sColumnName; sColumnName.sprintf("%s.Column%i", getName().cstr(), i); styleOpen.addAttribute("style:name", sColumnName); styleOpen.addAttribute("style:family", "table-column"); diff --git a/filters/kword/wordperfect/import/TableStyle.hxx b/filters/kword/wordperfect/import/TableStyle.hxx index e5321182..3730da4b 100644 --- a/filters/kword/wordperfect/import/TableStyle.hxx +++ b/filters/kword/wordperfect/import/TableStyle.hxx @@ -30,7 +30,7 @@ #define _TABLESTYLE_H #include #include - +#include "shared_headers.h" #include "Style.hxx" #include "WriterProperties.hxx" @@ -40,25 +40,25 @@ class DocumentHandler; class TableCellStyle : public Style { public: - TableCellStyle(const WPXPropertyList &xPropList, const char *psName); + TableCellStyle(const _SH_PropertyList &xPropList, const char *psName); virtual void write(DocumentHandler &xHandler) const; private: - WPXPropertyList mPropList; + _SH_PropertyList mPropList; }; class TableRowStyle : public Style { public: - TableRowStyle(const WPXPropertyList &propList, const char *psName); + TableRowStyle(const _SH_PropertyList &propList, const char *psName); virtual void write(DocumentHandler &xHandler) const; private: - WPXPropertyList mPropList; + _SH_PropertyList mPropList; }; class TableStyle : public Style, public TopLevelElementStyle { public: - TableStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &columns, const char *psName); + TableStyle(const _SH_PropertyList &xPropList, const _SH_PropertyListVector &columns, const char *psName); ~TableStyle(); virtual void write(DocumentHandler &xHandler) const; const int getNumColumns() const { return mColumns.count(); } @@ -67,8 +67,8 @@ public: void addTableRowStyle(TableRowStyle *pTableRowStyle) { mTableRowStyles.push_back(pTableRowStyle); } int getNumTableRowStyles() { return mTableRowStyles.size(); } private: - WPXPropertyList mPropList; - WPXPropertyListVector mColumns; + _SH_PropertyList mPropList; + _SH_PropertyListVector mColumns; std::vector mTableCellStyles; std::vector mTableRowStyles; }; diff --git a/filters/kword/wordperfect/import/TextRunStyle.cxx b/filters/kword/wordperfect/import/TextRunStyle.cxx index 702dddb5..b188632c 100644 --- a/filters/kword/wordperfect/import/TextRunStyle.cxx +++ b/filters/kword/wordperfect/import/TextRunStyle.cxx @@ -39,7 +39,7 @@ #include #endif -ParagraphStyle::ParagraphStyle(WPXPropertyList *pPropList, const WPXPropertyListVector &xTabStops, const WPXString &sName) : +ParagraphStyle::ParagraphStyle(_SH_PropertyList *pPropList, const _SH_PropertyListVector &xTabStops, const _SH_String &sName) : mpPropList(pPropList), mxTabStops(xTabStops), msName(sName) @@ -55,7 +55,7 @@ void ParagraphStyle::write(DocumentHandler &xHandler) const { WRITER_DEBUG_MSG(("Writing a paragraph style..\n")); - WPXPropertyList propList; + _SH_PropertyList propList; propList.insert("style:name", msName.cstr()); propList.insert("style:family", "paragraph"); propList.insert("style:parent-style-name", (*mpPropList)["style:parent-style-name"]->getStr()); @@ -64,7 +64,7 @@ void ParagraphStyle::write(DocumentHandler &xHandler) const xHandler.startElement("style:style", propList); propList.clear(); - WPXPropertyList::Iter i((*mpPropList)); + _SH_PropertyList::Iter i((*mpPropList)); for (i.rewind(); i.next(); ) { if (strcmp(i.key(), "style:list-style-name") == 0) @@ -96,12 +96,12 @@ void ParagraphStyle::write(DocumentHandler &xHandler) const { TagOpenElement tabListOpen("style:tab-stops"); tabListOpen.write(xHandler); - WPXPropertyListVector::Iter i(mxTabStops); + _SH_PropertyListVector::Iter i(mxTabStops); for (i.rewind(); i.next();) { TagOpenElement tabStopOpen("style:tab-stop"); - WPXPropertyList::Iter j(i()); + _SH_PropertyList::Iter j(i()); for (j.rewind(); j.next(); ) { tabStopOpen.addAttribute(j.key(), j()->getStr().cstr()); @@ -116,7 +116,7 @@ void ParagraphStyle::write(DocumentHandler &xHandler) const xHandler.endElement("style:style"); } -SpanStyle::SpanStyle(const char *psName, const WPXPropertyList &xPropList) : +SpanStyle::SpanStyle(const char *psName, const _SH_PropertyList &xPropList) : Style(psName), mPropList(xPropList) { @@ -125,12 +125,12 @@ SpanStyle::SpanStyle(const char *psName, const WPXPropertyList &xPropList) : void SpanStyle::write(DocumentHandler &xHandler) const { WRITER_DEBUG_MSG(("Writing a span style..\n")); - WPXPropertyList styleOpenList; + _SH_PropertyList styleOpenList; styleOpenList.insert("style:name", getName()); styleOpenList.insert("style:family", "text"); xHandler.startElement("style:style", styleOpenList); - WPXPropertyList propList(mPropList); + _SH_PropertyList propList(mPropList); if (mPropList["style:font-name"]) { diff --git a/filters/kword/wordperfect/import/TextRunStyle.hxx b/filters/kword/wordperfect/import/TextRunStyle.hxx index 2b2eb631..e0847e2f 100644 --- a/filters/kword/wordperfect/import/TextRunStyle.hxx +++ b/filters/kword/wordperfect/import/TextRunStyle.hxx @@ -30,9 +30,10 @@ #ifndef _TEXTRUNSTYLE_H #define _TEXTRUNSTYLE_H -#include +#include #include "Style.hxx" +#include "shared_headers.h" class TagOpenElement; class DocumentElement; @@ -41,24 +42,24 @@ class DocumentHandler; class ParagraphStyle { public: - ParagraphStyle(WPXPropertyList *propList, const WPXPropertyListVector &tabStops, const WPXString &sName); + ParagraphStyle(_SH_PropertyList *propList, const _SH_PropertyListVector &tabStops, const _SH_String &sName); virtual ~ParagraphStyle(); virtual void write(DocumentHandler &xHandler) const; - WPXString getName() const { return msName; } + _SH_String getName() const { return msName; } private: - WPXPropertyList *mpPropList; - WPXPropertyListVector mxTabStops; - WPXString msName; + _SH_PropertyList *mpPropList; + _SH_PropertyListVector mxTabStops; + _SH_String msName; }; class SpanStyle : public Style { public: - SpanStyle(const char *psName, const WPXPropertyList &xPropList); + SpanStyle(const char *psName, const _SH_PropertyList &xPropList); virtual void write(DocumentHandler &xHandler) const; private: - WPXPropertyList mPropList; + _SH_PropertyList mPropList; }; #endif diff --git a/filters/kword/wordperfect/import/WordPerfectCollector.cxx b/filters/kword/wordperfect/import/WordPerfectCollector.cxx index 33fb4816..eb59a70f 100644 --- a/filters/kword/wordperfect/import/WordPerfectCollector.cxx +++ b/filters/kword/wordperfect/import/WordPerfectCollector.cxx @@ -55,7 +55,7 @@ _WriterDocumentState::_WriterDocumentState() : { } -WordPerfectCollector::WordPerfectCollector(WPXInputStream *pInput, DocumentHandler *pHandler) : +WordPerfectCollector::WordPerfectCollector(_SH_InputStream *pInput, DocumentHandler *pHandler) : mpInput(pInput), mpHandler(pHandler), mbUsed(false), @@ -69,8 +69,8 @@ WordPerfectCollector::WordPerfectCollector(WPXInputStream *pInput, DocumentHandl miLastListLevel(0), miLastListNumber(0), mbListContinueNumbering(false), - mbListElementParagraphOpened(false), - mbListElementOpened(false) + mbListElementOpened(false), + mbListElementParagraphOpened(false) { } @@ -111,10 +111,10 @@ bool WordPerfectCollector::filter() } WRITER_DEBUG_MSG(("Destroying the rest of the styles elements\n")); - for (std::map::iterator iterTextStyle = mTextStyleHash.begin(); iterTextStyle != mTextStyleHash.end(); iterTextStyle++) { + for (std::map<_SH_String, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin(); iterTextStyle != mTextStyleHash.end(); iterTextStyle++) { delete(iterTextStyle->second); } - for (std::map::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); iterFont++) { + for (std::map<_SH_String, FontStyle *, ltstr>::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); iterFont++) { delete(iterFont->second); } @@ -135,15 +135,21 @@ bool WordPerfectCollector::filter() return true; } -bool WordPerfectCollector::_parseSourceDocument(WPXInputStream &input) +bool WordPerfectCollector::_parseSourceDocument(_SH_InputStream &input) { -#ifdef HAVE_LIBWPD_090 - WPDResult result = WPDocument::parse(&input, static_cast(this), NULL); +#if defined(HAVE_LIBWPD_0100) + libwpd::WPDResult result = libwpd::WPDocument::parse(&input, static_cast<_SH_DocumentInterface*>(this), NULL); +#elif defined(HAVE_LIBWPD_090) + WPDResult result = WPDocument::parse(&input, static_cast<_SH_DocumentInterface*>(this), NULL); +#else + WPDResult result = WPDocument::parse(&input, static_cast<_SH_DocumentInterface*>(this)); +#endif +#if defined(HAVE_LIBWPD_0100) + if (result != libwpd::WPD_OK) #else - WPDResult result = WPDocument::parse(&input, static_cast(this)); + if (result != WPD_OK) #endif - if (result != WPD_OK) - return false; + return false; return true; } @@ -214,7 +220,7 @@ void WordPerfectCollector::_writeBegin() void WordPerfectCollector::_writeMasterPages(DocumentHandler &xHandler) { - WPXPropertyList xBlankAttrList; + _SH_PropertyList xBlankAttrList; xHandler.startElement("office:master-styles", xBlankAttrList); int pageNumber = 1; @@ -240,13 +246,13 @@ void WordPerfectCollector::_writePageMasters(DocumentHandler &xHandler) bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler) { WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Printing out the header stuff..\n")); - WPXPropertyList xBlankAttrList; + _SH_PropertyList xBlankAttrList; WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Start Document\n")); mpHandler->startDocument(); WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: preamble\n")); - WPXPropertyList docContentPropList; + _SH_PropertyList docContentPropList; docContentPropList.insert("xmlns:office", "http://openoffice.org/2000/office"); docContentPropList.insert("xmlns:style", "http://openoffice.org/2000/style"); docContentPropList.insert("xmlns:text", "http://openoffice.org/2000/text"); @@ -267,7 +273,7 @@ bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler) // write out the font styles mpHandler->startElement("office:font-decls", xBlankAttrList); - for (std::map::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); iterFont++) { + for (std::map<_SH_String, FontStyle *, ltstr>::iterator iterFont = mFontHash.begin(); iterFont != mFontHash.end(); iterFont++) { iterFont->second->write(*mpHandler); } TagOpenElement symbolFontOpen("style:font-decl"); @@ -287,7 +293,7 @@ bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler) mpHandler->startElement("office:automatic-styles", xBlankAttrList); - for (std::map::iterator iterTextStyle = mTextStyleHash.begin(); + for (std::map<_SH_String, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin(); iterTextStyle != mTextStyleHash.end(); iterTextStyle++) { // writing out the paragraph styles @@ -299,7 +305,7 @@ bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler) } // span styles.. - for (std::map::iterator iterSpanStyle = mSpanStyleHash.begin(); + for (std::map<_SH_String, SpanStyle *, ltstr>::iterator iterSpanStyle = mSpanStyleHash.begin(); iterSpanStyle != mSpanStyleHash.end(); iterSpanStyle++) { (iterSpanStyle->second)->write(xHandler); @@ -346,13 +352,13 @@ bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler) } -WPXString propListToStyleKey(const WPXPropertyList & xPropList) +_SH_String propListToStyleKey(const _SH_PropertyList & xPropList) { - WPXString sKey; - WPXPropertyList::Iter i(xPropList); + _SH_String sKey; + _SH_PropertyList::Iter i(xPropList); for (i.rewind(); i.next(); ) { - WPXString sProp; + _SH_String sProp; sProp.sprintf("[%s:%s]", i.key(), i()->getStr().cstr()); sKey.append(sProp); } @@ -360,13 +366,13 @@ WPXString propListToStyleKey(const WPXPropertyList & xPropList) return sKey; } -WPXString getParagraphStyleKey(const WPXPropertyList & xPropList, const WPXPropertyListVector & xTabStops) +_SH_String getParagraphStyleKey(const _SH_PropertyList & xPropList, const _SH_PropertyListVector & xTabStops) { - WPXString sKey = propListToStyleKey(xPropList); + _SH_String sKey = propListToStyleKey(xPropList); - WPXString sTabStops; + _SH_String sTabStops; sTabStops.sprintf("[num-tab-stops:%i]", xTabStops.count()); - WPXPropertyListVector::Iter i(xTabStops); + _SH_PropertyListVector::Iter i(xTabStops); for (i.rewind(); i.next();) { sTabStops.append(propListToStyleKey(i())); @@ -377,7 +383,7 @@ WPXString getParagraphStyleKey(const WPXPropertyList & xPropList, const WPXPrope } // _allocateFontName: add a (potentially mapped) font style to the hash if it's not already there, do nothing otherwise -void WordPerfectCollector::_allocateFontName(const WPXString & sFontName) +void WordPerfectCollector::_allocateFontName(const _SH_String & sFontName) { if (mFontHash.find(sFontName) == mFontHash.end()) { @@ -386,14 +392,14 @@ void WordPerfectCollector::_allocateFontName(const WPXString & sFontName) } } -void WordPerfectCollector::openPageSpan(const WPXPropertyList &propList) +void WordPerfectCollector::openPageSpan(const _SH_PropertyList &propList) { PageSpan *pPageSpan = new PageSpan(propList); mPageSpans.push_back(pPageSpan); mpCurrentPageSpan = pPageSpan; } -void WordPerfectCollector::openHeader(const WPXPropertyList &propList) +void WordPerfectCollector::openHeader(const _SH_PropertyList &propList) { std::vector * pHeaderFooterContentElements = new std::vector; @@ -410,7 +416,7 @@ void WordPerfectCollector::closeHeader() mpCurrentContentElements = &mBodyElements; } -void WordPerfectCollector::openFooter(const WPXPropertyList &propList) +void WordPerfectCollector::openFooter(const _SH_PropertyList &propList) { std::vector * pHeaderFooterContentElements = new std::vector; @@ -427,18 +433,18 @@ void WordPerfectCollector::closeFooter() mpCurrentContentElements = &mBodyElements; } -void WordPerfectCollector::openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns) +void WordPerfectCollector::openSection(const _SH_PropertyList &propList, const _SH_PropertyListVector &columns) { int iNumColumns = columns.count(); if (iNumColumns > 1) { -#ifdef HAVE_LIBWPD_090 +#if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100) mfSectionSpaceAfter = propList["fo:margin-bottom"]->getDouble(); #else mfSectionSpaceAfter = propList["fo:margin-bottom"]->getFloat(); #endif - WPXString sSectionName; + _SH_String sSectionName; sSectionName.sprintf("Section%i", mSectionStyles.size()); SectionStyle *pSectionStyle = new SectionStyle(propList, columns, sSectionName.cstr()); @@ -472,12 +478,12 @@ void WordPerfectCollector::closeSection() mfSectionSpaceAfter = 0.0f; } -void WordPerfectCollector::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) +void WordPerfectCollector::openParagraph(const _SH_PropertyList &propList, const _SH_PropertyListVector &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); + _SH_PropertyList *pPersistPropList = new _SH_PropertyList(propList); ParagraphStyle *pStyle = NULL; if (mWriterDocumentState.mbFirstElement && mpCurrentContentElements == &mBodyElements) @@ -488,10 +494,10 @@ void WordPerfectCollector::openParagraph(const WPXPropertyList &propList, const // 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; + _SH_String sName; sName.sprintf("FS"); - WPXString sParagraphHashKey("P|FS"); + _SH_String sParagraphHashKey("P|FS"); pPersistPropList->insert("style:master-page-name", "Page Style 1"); pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName); mTextStyleHash[sParagraphHashKey] = pStyle; @@ -509,10 +515,10 @@ void WordPerfectCollector::openParagraph(const WPXPropertyList &propList, const else pPersistPropList->insert("style:parent-style-name", "Standard"); - WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops); + _SH_String sKey = getParagraphStyleKey(*pPersistPropList, tabStops); if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) { - WPXString sName; + _SH_String sName; sName.sprintf("S%i", mTextStyleHash.size()); pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName); @@ -536,15 +542,15 @@ void WordPerfectCollector::closeParagraph() mpCurrentContentElements->push_back(static_cast(new TagCloseElement("text:p"))); } -void WordPerfectCollector::openSpan(const WPXPropertyList &propList) +void WordPerfectCollector::openSpan(const _SH_PropertyList &propList) { if (propList["style:font-name"]) _allocateFontName(propList["style:font-name"]->getStr()); - WPXString sSpanHashKey = propListToStyleKey(propList); + _SH_String sSpanHashKey = propListToStyleKey(propList); WRITER_DEBUG_MSG(("WriterWordPerfect: Span Hash Key: %s\n", sSpanHashKey.cstr())); // Get the style - WPXString sName; + _SH_String sName; if (mSpanStyleHash.find(sSpanHashKey) == mSpanStyleHash.end()) { // allocate a new paragraph style @@ -569,7 +575,7 @@ void WordPerfectCollector::closeSpan() mpCurrentContentElements->push_back(static_cast(new TagCloseElement("text:span"))); } -void WordPerfectCollector::defineOrderedListLevel(const WPXPropertyList &propList) +void WordPerfectCollector::defineOrderedListLevel(const _SH_PropertyList &propList) { int id = 0; if (propList["libwpd:id"]) @@ -588,7 +594,7 @@ void WordPerfectCollector::defineOrderedListLevel(const WPXPropertyList &propLis (propList["text:start-value"] && propList["text:start-value"]->getInt() != (miLastListNumber+1)))) { WRITER_DEBUG_MSG(("Attempting to create a new ordered list style (listid: %i)\n", id)); - WPXString sName; + _SH_String sName; sName.sprintf("OL%i", miNumListStyles); miNumListStyles++; pOrderedListStyle = new OrderedListStyle(sName.cstr(), propList["libwpd:id"]->getInt()); @@ -610,7 +616,7 @@ void WordPerfectCollector::defineOrderedListLevel(const WPXPropertyList &propLis } } -void WordPerfectCollector::defineUnorderedListLevel(const WPXPropertyList &propList) +void WordPerfectCollector::defineUnorderedListLevel(const _SH_PropertyList &propList) { int id = 0; if (propList["libwpd:id"]) @@ -622,7 +628,7 @@ void WordPerfectCollector::defineUnorderedListLevel(const WPXPropertyList &propL if (pUnorderedListStyle == NULL) { WRITER_DEBUG_MSG(("Attempting to create a new unordered list style (listid: %i)\n", id)); - WPXString sName; + _SH_String sName; sName.sprintf("UL%i", miNumListStyles); pUnorderedListStyle = new UnorderedListStyle(sName.cstr(), id); mListStyles.push_back(static_cast(pUnorderedListStyle)); @@ -637,7 +643,7 @@ void WordPerfectCollector::defineUnorderedListLevel(const WPXPropertyList &propL } } -void WordPerfectCollector::openOrderedListLevel(const WPXPropertyList &propList) +void WordPerfectCollector::openOrderedListLevel(const _SH_PropertyList &propList) { miCurrentListLevel++; TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:ordered-list"); @@ -650,7 +656,7 @@ void WordPerfectCollector::openOrderedListLevel(const WPXPropertyList &propList) mpCurrentContentElements->push_back(static_cast(pListLevelOpenElement)); } -void WordPerfectCollector::openUnorderedListLevel(const WPXPropertyList &propList) +void WordPerfectCollector::openUnorderedListLevel(const _SH_PropertyList &propList) { miCurrentListLevel++; TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:unordered-list"); @@ -695,7 +701,7 @@ void WordPerfectCollector::_closeListLevel(const char *szListType) miCurrentListLevel--; - WPXString sCloseElement; + _SH_String sCloseElement; sCloseElement.sprintf("text:%s", szListType); mpCurrentContentElements->push_back(static_cast(new TagCloseElement(sCloseElement.cstr()))); @@ -704,7 +710,7 @@ void WordPerfectCollector::_closeListLevel(const char *szListType) mbListElementOpened = false; } -void WordPerfectCollector::openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) +void WordPerfectCollector::openListElement(const _SH_PropertyList &propList, const _SH_PropertyListVector &tabStops) { miLastListLevel = miCurrentListLevel; if (miCurrentListLevel == 1) @@ -715,15 +721,15 @@ void WordPerfectCollector::openListElement(const WPXPropertyList &propList, cons ParagraphStyle *pStyle = NULL; - WPXPropertyList *pPersistPropList = new WPXPropertyList(propList); + _SH_PropertyList *pPersistPropList = new _SH_PropertyList(propList); pPersistPropList->insert("style:list-style-name", mpCurrentListStyle->getName()); pPersistPropList->insert("style:parent-style-name", "Standard"); - WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops); + _SH_String sKey = getParagraphStyleKey(*pPersistPropList, tabStops); if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) { - WPXString sName; + _SH_String sName; sName.sprintf("S%i", mTextStyleHash.size()); pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName); @@ -762,12 +768,12 @@ void WordPerfectCollector::closeListElement() } } -void WordPerfectCollector::openFootnote(const WPXPropertyList &propList) +void WordPerfectCollector::openFootnote(const _SH_PropertyList &propList) { TagOpenElement *pOpenFootNote = new TagOpenElement("text:footnote"); if (propList["libwpd:number"]) { - WPXString tmpString("ftn"); + _SH_String tmpString("ftn"); tmpString.append(propList["libwpd:number"]->getStr()); pOpenFootNote->addAttribute("text:id", tmpString); } @@ -791,12 +797,12 @@ void WordPerfectCollector::closeFootnote() mpCurrentContentElements->push_back(static_cast(new TagCloseElement("text:footnote"))); } -void WordPerfectCollector::openEndnote(const WPXPropertyList &propList) +void WordPerfectCollector::openEndnote(const _SH_PropertyList &propList) { TagOpenElement *pOpenEndNote = new TagOpenElement("text:endnote"); if (propList["libwpd:number"]) { - WPXString tmpString("edn"); + _SH_String tmpString("edn"); tmpString.append(propList["libwpd:number"]->getStr()); pOpenEndNote->addAttribute("text:id", tmpString); } @@ -820,11 +826,11 @@ void WordPerfectCollector::closeEndnote() mpCurrentContentElements->push_back(static_cast(new TagCloseElement("text:endnote"))); } -void WordPerfectCollector::openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns) +void WordPerfectCollector::openTable(const _SH_PropertyList &propList, const _SH_PropertyListVector &columns) { if (!mWriterDocumentState.mbInNote) { - WPXString sTableName; + _SH_String sTableName; sTableName.sprintf("Table%i", mTableStyles.size()); // FIXME: we base the table style off of the page's margin left, ignoring (potential) wordperfect margin @@ -834,7 +840,7 @@ void WordPerfectCollector::openTable(const WPXPropertyList &propList, const WPXP if (mWriterDocumentState.mbFirstElement && mpCurrentContentElements == &mBodyElements) { - WPXString sMasterPageName("Page Style 1"); + _SH_String sMasterPageName("Page Style 1"); pTableStyle->setMasterPageName(sMasterPageName); mWriterDocumentState.mbFirstElement = false; } @@ -852,7 +858,7 @@ void WordPerfectCollector::openTable(const WPXPropertyList &propList, const WPXP for (int i=0; igetNumColumns(); i++) { TagOpenElement *pTableColumnOpenElement = new TagOpenElement("table:table-column"); - WPXString sColumnStyleName; + _SH_String sColumnStyleName; sColumnStyleName.sprintf("%s.Column%i", sTableName.cstr(), (i+1)); pTableColumnOpenElement->addAttribute("table:style-name", sColumnStyleName.cstr()); mpCurrentContentElements->push_back(pTableColumnOpenElement); @@ -863,7 +869,7 @@ void WordPerfectCollector::openTable(const WPXPropertyList &propList, const WPXP } } -void WordPerfectCollector::openTableRow(const WPXPropertyList &propList) +void WordPerfectCollector::openTableRow(const _SH_PropertyList &propList) { if (!mWriterDocumentState.mbInNote) { @@ -873,7 +879,7 @@ void WordPerfectCollector::openTableRow(const WPXPropertyList &propList) mWriterDocumentState.mbHeaderRow = true; } - WPXString sTableRowStyleName; + _SH_String sTableRowStyleName; sTableRowStyleName.sprintf("%s.Row%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableRowStyles()); TableRowStyle *pTableRowStyle = new TableRowStyle(propList, sTableRowStyleName.cstr()); mpCurrentTableStyle->addTableRowStyle(pTableRowStyle); @@ -897,11 +903,11 @@ void WordPerfectCollector::closeTableRow() } } -void WordPerfectCollector::openTableCell(const WPXPropertyList &propList) +void WordPerfectCollector::openTableCell(const _SH_PropertyList &propList) { if (!mWriterDocumentState.mbInNote) { - WPXString sTableCellStyleName; + _SH_String sTableCellStyleName; sTableCellStyleName.sprintf( "%s.Cell%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableCellStyles()); TableCellStyle *pTableCellStyle = new TableCellStyle(propList, sTableCellStyleName.cstr()); mpCurrentTableStyle->addTableCellStyle(pTableCellStyle); @@ -930,7 +936,7 @@ void WordPerfectCollector::closeTableCell() } } -void WordPerfectCollector::insertCoveredTableCell(const WPXPropertyList &propList) +void WordPerfectCollector::insertCoveredTableCell(const _SH_PropertyList &propList) { if (!mWriterDocumentState.mbInNote) { @@ -960,7 +966,7 @@ void WordPerfectCollector::insertLineBreak() mpCurrentContentElements->push_back(static_cast(new TagCloseElement("text:line-break"))); } -void WordPerfectCollector::insertText(const WPXString &text) +void WordPerfectCollector::insertText(const _SH_String &text) { DocumentElement *pText = new TextElement(text); mpCurrentContentElements->push_back(pText); diff --git a/filters/kword/wordperfect/import/WordPerfectCollector.hxx b/filters/kword/wordperfect/import/WordPerfectCollector.hxx index 7cdb51ea..7c5e8286 100644 --- a/filters/kword/wordperfect/import/WordPerfectCollector.hxx +++ b/filters/kword/wordperfect/import/WordPerfectCollector.hxx @@ -31,13 +31,12 @@ #ifndef _WORDPERFECTCOLLECTOR_H #define _WORDPERFECTCOLLECTOR_H + #include "SectionStyle.hxx" #include #include -#ifdef HAVE_LIBWPD_090 -#define WPXHLListenerImpl WPXDocumentInterface -#endif +#include "shared_headers.h" #include #include #include @@ -71,156 +70,128 @@ enum WriterListType { unordered, ordered }; struct ltstr { - bool operator()(const WPXString & s1, const WPXString & s2) const + bool operator()(const _SH_String & s1, const _SH_String & s2) const { return strcmp(s1.cstr(), s2.cstr()) < 0; } }; -#ifdef HAVE_LIBWPD_090 -class WordPerfectCollector : public WPXDocumentInterface -#else // HAVE_LIBWPD_090 -class WordPerfectCollector : public WPXHLListenerImpl -#endif // HAVE_LIBWPD_090 +class WordPerfectCollector : public _SH_DocumentInterface { public: - WordPerfectCollector(WPXInputStream *pInput, DocumentHandler *pHandler); + WordPerfectCollector(_SH_InputStream *pInput, DocumentHandler *pHandler); virtual ~WordPerfectCollector(); bool filter(); -#ifdef HAVE_LIBWPD_090 - virtual void setDocumentMetaData(const WPXPropertyList &propList) {}; + virtual void setDocumentMetaData(const _SH_PropertyList &propList) {}; virtual void startDocument(); virtual void endDocument(); - virtual void definePageStyle(const WPXPropertyList &propList) {}; - virtual void openPageSpan(const WPXPropertyList &propList); + + virtual void openPageSpan(const _SH_PropertyList &propList); virtual void closePageSpan(); - virtual void openHeader(const WPXPropertyList &propList); + virtual void openHeader(const _SH_PropertyList &propList); virtual void closeHeader(); - virtual void openFooter(const WPXPropertyList &propList); + virtual void openFooter(const _SH_PropertyList &propList); virtual void closeFooter(); - virtual void defineParagraphStyle(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) {}; - virtual void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops); + virtual void openParagraph(const _SH_PropertyList &propList, const _SH_PropertyListVector &tabStops); virtual void closeParagraph(); - virtual void defineCharacterStyle(const WPXPropertyList &propList) {}; - virtual void openSpan(const WPXPropertyList &propList); + virtual void openSpan(const _SH_PropertyList &propList); virtual void closeSpan(); - virtual void defineSectionStyle(const WPXPropertyList &propList, const WPXPropertyListVector &columns) {}; - virtual void openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns); + virtual void openSection(const _SH_PropertyList &propList, const _SH_PropertyListVector &columns); virtual void closeSection(); virtual void insertTab(); - virtual void insertSpace() {}; - virtual void insertText(const WPXString &text); + virtual void insertText(const _SH_String &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 defineOrderedListLevel(const _SH_PropertyList &propList); + virtual void defineUnorderedListLevel(const _SH_PropertyList &propList); + virtual void openOrderedListLevel(const _SH_PropertyList &propList); + virtual void openUnorderedListLevel(const _SH_PropertyList &propList); virtual void closeOrderedListLevel(); virtual void closeUnorderedListLevel(); - virtual void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops); + virtual void openListElement(const _SH_PropertyList &propList, const _SH_PropertyListVector &tabStops); virtual void closeListElement(); - virtual void openFootnote(const WPXPropertyList &propList); + virtual void openFootnote(const _SH_PropertyList &propList); virtual void closeFootnote(); - virtual void openEndnote(const WPXPropertyList &propList); + virtual void openEndnote(const _SH_PropertyList &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 openTable(const _SH_PropertyList &propList, const _SH_PropertyListVector &columns); + virtual void openTableRow(const _SH_PropertyList &propList); virtual void closeTableRow(); - virtual void openTableCell(const WPXPropertyList &propList); + virtual void openTableCell(const _SH_PropertyList &propList); virtual void closeTableCell(); - virtual void insertCoveredTableCell(const WPXPropertyList &propList); + virtual void insertCoveredTableCell(const _SH_PropertyList &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) {}; - -#else // HAVE_LIBWPD_090 - - virtual void setDocumentMetaData(const WPXPropertyList &propList) {} - virtual void startDocument() {} - virtual void endDocument() {} - - virtual void openPageSpan(const WPXPropertyList &propList); - virtual void closePageSpan() {} - - 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 openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops); - virtual void closeParagraph(); - - virtual void openSpan(const WPXPropertyList &propList); - virtual void closeSpan(); +#if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100) + virtual void definePageStyle(const _SH_PropertyList &propList) {} + virtual void defineParagraphStyle(const _SH_PropertyList &propList, const _SH_PropertyListVector &tabStops) {} + virtual void defineCharacterStyle(const _SH_PropertyList &propList) {} + virtual void defineSectionStyle(const _SH_PropertyList &propList, const _SH_PropertyListVector &columns) {} + virtual void insertSpace() {} + virtual void insertField(const _SH_String &type, const _SH_PropertyList &propList) {} + virtual void openComment(const _SH_PropertyList &propList) {} + virtual void closeComment() {} + virtual void openTextBox(const _SH_PropertyList &propList) {} + virtual void closeTextBox() {} + virtual void openFrame(const _SH_PropertyList &propList) {} + virtual void closeFrame() {} + virtual void insertBinaryObject(const _SH_PropertyList &propList, const _SH_BinaryData &data) {} + virtual void insertEquation(const _SH_PropertyList &propList, const _SH_String &data) {} +#endif - virtual void insertTab(); - virtual void insertText(const WPXString &text); - virtual void insertLineBreak(); - - 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 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(); - -#endif // HAVE_LIBWPD_090 +#if defined(HAVE_LIBWPD_0100) + virtual void startDocument(const _SH_PropertyList &propList) {} + virtual void defineEmbeddedFont(const _SH_PropertyList &propList) {} + virtual void defineParagraphStyle(const _SH_PropertyList &propList) {} + virtual void openParagraph(const _SH_PropertyList &propList) {} + virtual void openLink(const _SH_PropertyList &propList) {} + virtual void closeLink() {} + virtual void defineSectionStyle(const _SH_PropertyList &propList) {} + virtual void openSection(const _SH_PropertyList &propList) {} + virtual void insertField(const _SH_PropertyList &propList) {} + virtual void openListElement(const _SH_PropertyList &propList) {} + virtual void openTable(const _SH_PropertyList &propList) {} + virtual void insertBinaryObject(const _SH_PropertyList &propList) {} + virtual void insertEquation(const _SH_PropertyList &propList) {} + virtual void openGroup(const _SH_PropertyList &propList) {} + virtual void closeGroup() {} + virtual void defineGraphicStyle(const _SH_PropertyList &propList) {} + virtual void drawRectangle(const _SH_PropertyList &propList) {} + virtual void drawEllipse(const _SH_PropertyList &propList) {} + virtual void drawPolygon(const _SH_PropertyList &propList) {} + virtual void drawPolyline(const _SH_PropertyList &propList) {} + virtual void drawPath(const _SH_PropertyList &propList) {} + virtual void drawConnector(const _SH_PropertyList &propList) {} +#endif protected: void _resetDocumentState(); - bool _parseSourceDocument(WPXInputStream &input); + bool _parseSourceDocument(_SH_InputStream &input); bool _writeTargetDocument(DocumentHandler &xHandler); void _writeBegin(); void _writeDefaultStyles(DocumentHandler &xHandler); void _writeMasterPages(DocumentHandler &xHandler); void _writePageMasters(DocumentHandler &xHandler); - void _allocateFontName(const WPXString &); + void _allocateFontName(const _SH_String &); private: void _openListLevel(TagOpenElement *pListLevelOpenElement); void _closeListLevel(const char *szListType); - WPXInputStream *mpInput; - DocumentHandler *mpHandler; + _SH_InputStream *mpInput; + DocumentHandler *mpHandler; bool mbUsed; // whether or not it has been before (you can only use me once!) WriterDocumentState mWriterDocumentState; // paragraph styles - std::map mTextStyleHash; + std::map<_SH_String, ParagraphStyle *, ltstr> mTextStyleHash; - // span styles - std::map mSpanStyleHash; + // span styles + std::map<_SH_String, SpanStyle *, ltstr> mSpanStyleHash; // font styles - std::map mFontHash; + std::map<_SH_String, FontStyle *, ltstr> mFontHash; // section styles std::vector mSectionStyles; diff --git a/filters/kword/wordperfect/import/shared_headers.h b/filters/kword/wordperfect/import/shared_headers.h new file mode 100644 index 00000000..0fc50c43 --- /dev/null +++ b/filters/kword/wordperfect/import/shared_headers.h @@ -0,0 +1,75 @@ +/* This file is part of the TDE project + + 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; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +/* + This file handles the different version of include files required + when using libwpd-0.8, libwpd-0.9 or libwpd-0.10 +*/ + +#ifndef __SHARED_HEADERS_H__ +#define __SHARED_HEADERS_H__ + +#include + +#ifdef HAVE_LIBWPD_0100 + //libwpd-0.10 + #include + #include + #include + #include + #include + + #define _SH_BinaryData librevenge::RVNGBinaryData + #define _SH_DocumentInterface librevenge::RVNGTextInterface + #define _SH_InputStream librevenge::RVNGInputStream + #define _SH_PropertyList librevenge::RVNGPropertyList + #define _SH_PropertyListVector librevenge::RVNGPropertyListVector + #define _SH_SEEK_CUR librevenge::RVNG_SEEK_CUR + #define _SH_SEEK_SET librevenge::RVNG_SEEK_SET + #define _SH_SEEK_TYPE librevenge::RVNG_SEEK_TYPE + #define _SH_String librevenge::RVNGString + +#else + //libwpd-0.9 and libwpd-0.8 + #include + #include + #include + +#ifdef HAVE_LIBWPD_090 + #include + #include +#else + #include +#endif + + #define _SH_BinaryData WPXBinaryData +#ifdef HAVE_LIBWPD_090 + #define _SH_DocumentInterface WPXDocumentInterface +#else + #define _SH_DocumentInterface WPXHLListenerImpl +#endif + #define _SH_InputStream WPXInputStream + #define _SH_PropertyList WPXPropertyList + #define _SH_PropertyListVector WPXPropertyListVector + #define _SH_SEEK_CUR WPX_SEEK_CUR + #define _SH_SEEK_SET WPX_SEEK_SET + #define _SH_SEEK_TYPE WPX_SEEK_TYPE + #define _SH_String WPXString +#endif + +#endif diff --git a/filters/kword/wordperfect/import/wpimport.cc b/filters/kword/wordperfect/import/wpimport.cc index 5ff786c1..e8537b76 100644 --- a/filters/kword/wordperfect/import/wpimport.cc +++ b/filters/kword/wordperfect/import/wpimport.cc @@ -35,53 +35,67 @@ typedef KGenericFactory WPImportFactory; K_EXPORT_COMPONENT_FACTORY( libwpimport, WPImportFactory( "kofficefilters" ) ) #include -#ifdef HAVE_LIBWPD_090 -#include -#define uint8_t uchar -#else -#include -#endif #include "DocumentHandler.hxx" #include "WordPerfectCollector.hxx" -#ifdef HAVE_LIBWPD_090 -class WPXMemoryInputStream : public WPXInputStream +class _SH_MemoryInputStream : public _SH_InputStream { public: - WPXMemoryInputStream(unsigned char *data, unsigned long size); - virtual ~WPXMemoryInputStream(); - - virtual bool isOLEStream() { - return false; - } - virtual WPXInputStream * getDocumentOLEStream(const char *name) { - return NULL; - } + _SH_MemoryInputStream(unsigned char *data, unsigned long size); + virtual ~_SH_MemoryInputStream(); + virtual bool isOLEStream() { return false; } +#if defined(HAVE_LIBWPD_0100) || defined(HAVE_LIBWPD_090) + virtual _SH_InputStream * getDocumentOLEStream(const char *name = NULL) { return NULL; } const virtual unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead); - virtual int seek(long offset, WPX_SEEK_TYPE seekType); +#else + virtual _SH_InputStream * getDocumentOLEStream() { return NULL; } + const virtual uint8_t *read(size_t numBytes, size_t &numBytesRead); +#endif + + virtual int seek(long offset, _SH_SEEK_TYPE seekType); virtual long tell(); virtual bool atEOS(); +#ifdef HAVE_LIBWPD_0100 + virtual bool isStructured() { return false; } + virtual unsigned subStreamCount() { return 0U; } + virtual const char *subStreamName(unsigned id) { return NULL; } + virtual bool existsSubStream(const char *name) { return false; } + virtual RVNGInputStream *getSubStreamByName(const char *name) { return NULL; } + virtual RVNGInputStream *getSubStreamById(unsigned id) { return NULL; } + virtual bool isEnd() { return false; } +#endif + private: long m_offset; size_t m_size; unsigned char *m_data; }; -WPXMemoryInputStream::WPXMemoryInputStream(unsigned char *data, unsigned long size) : - WPXInputStream(), +_SH_MemoryInputStream::_SH_MemoryInputStream(unsigned char *data, unsigned long size) : +#if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100) + _SH_InputStream(), +#else + _SH_InputStream(false), +#endif m_offset(0), m_size(size), m_data(data) { } -WPXMemoryInputStream::~WPXMemoryInputStream() +_SH_MemoryInputStream::~_SH_MemoryInputStream() { + if (m_data) + delete [] m_data; } -const unsigned char * WPXMemoryInputStream::read(unsigned long numBytes, unsigned long &numBytesRead) +#if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100) +const unsigned char * _SH_MemoryInputStream::read(unsigned long numBytes, unsigned long &numBytesRead) +#else +const uint8_t * _SH_MemoryInputStream::read(size_t numBytes, size_t &numBytesRead) +#endif { numBytesRead = 0; @@ -106,11 +120,11 @@ const unsigned char * WPXMemoryInputStream::read(unsigned long numBytes, unsigne return &m_data[oldOffset]; } -int WPXMemoryInputStream::seek(long offset, WPX_SEEK_TYPE seekType) +int _SH_MemoryInputStream::seek(long offset, _SH_SEEK_TYPE seekType) { - if (seekType == WPX_SEEK_CUR) + if (seekType == _SH_SEEK_CUR) m_offset += offset; - else if (seekType == WPX_SEEK_SET) + else if (seekType == _SH_SEEK_SET) m_offset = offset; if (m_offset < 0) @@ -127,12 +141,12 @@ int WPXMemoryInputStream::seek(long offset, WPX_SEEK_TYPE seekType) return 0; } -long WPXMemoryInputStream::tell() +long _SH_MemoryInputStream::tell() { return m_offset; } -bool WPXMemoryInputStream::atEOS() +bool _SH_MemoryInputStream::atEOS() { if ((long)m_offset == (long)m_size) return true; @@ -140,104 +154,6 @@ bool WPXMemoryInputStream::atEOS() return false; } -#else // HAVE_LIBWPD_090 - -class WPXMemoryInputStream : public WPXInputStream -{ -public: - WPXMemoryInputStream(uint8_t *data, size_t size); - virtual ~WPXMemoryInputStream(); - - virtual bool isOLEStream() { return false; } - virtual WPXInputStream * getDocumentOLEStream() { return NULL; } - - const virtual uint8_t *read(size_t numBytes, size_t &numBytesRead); - virtual int seek(long offset, WPX_SEEK_TYPE seekType); - virtual long tell(); - virtual bool atEOS(); - -private: - long m_offset; - size_t m_size; - uint8_t *m_data; - uint8_t *m_tmpBuf; -}; - - -WPXMemoryInputStream::WPXMemoryInputStream(uint8_t *data, size_t size) : -#ifdef HAVE_LIBWPD_090 - WPXInputStream(), -#else - WPXInputStream(false), -#endif - m_offset(0), - m_data(data), - m_size(size), - m_tmpBuf(NULL) -{ -} - -WPXMemoryInputStream::~WPXMemoryInputStream() -{ - delete [] m_tmpBuf; - delete [] m_data; -} - -const uint8_t * WPXMemoryInputStream::read(size_t numBytes, size_t &numBytesRead) -{ - delete [] m_tmpBuf; - int numBytesToRead; - - if ((m_offset+numBytes) < m_size) - numBytesToRead = numBytes; - else - numBytesToRead = m_size - m_offset; - - numBytesRead = numBytesToRead; // about as paranoid as we can be.. - - if (numBytesToRead == 0) - return NULL; - - m_tmpBuf = new uint8_t[numBytesToRead]; - for (size_t i=0; i= m_size) - m_offset = m_size; - - return 0; -} - -long WPXMemoryInputStream::tell() -{ - return m_offset; -} - -bool WPXMemoryInputStream::atEOS() -{ - if (m_offset >= m_size ) - return true; - - return false; -} - -#endif // HAVE_LIBWPD_090 - class KWordHandler : public DocumentHandler { public: @@ -245,13 +161,13 @@ public: virtual ~KWordHandler() {}; void startDocument(); void endDocument(); - void startElement(const char *psName, const WPXPropertyList &xPropList); + void startElement(const char *psName, const _SH_PropertyList &xPropList); void endElement(const char *psName); - void characters(const WPXString &sCharacters); - WPXString documentstring; + void characters(const _SH_String &sCharacters); + _SH_String documentstring; private: bool isTagOpened; - WPXString openedTagName; + _SH_String openedTagName; }; KWordHandler::KWordHandler() : @@ -264,17 +180,17 @@ void KWordHandler::startDocument() documentstring.clear(); } -void KWordHandler::startElement(const char *psName, const WPXPropertyList &xPropList) +void KWordHandler::startElement(const char *psName, const _SH_PropertyList &xPropList) { if (isTagOpened) { documentstring.append( ">" ); isTagOpened = false; } - WPXString tempString; + _SH_String tempString; tempString.sprintf("<%s", psName); documentstring.append( tempString ); - WPXPropertyList::Iter i(xPropList); + _SH_PropertyList::Iter i(xPropList); for (i.rewind(); i.next(); ) { // filter out libwpd elements @@ -294,21 +210,25 @@ void KWordHandler::endElement(const char *psName) documentstring.append( " />" ); else { - WPXString tempString; + _SH_String tempString; tempString.sprintf("", psName); documentstring.append( tempString ); } isTagOpened = false; } -void KWordHandler::characters(const WPXString &sCharacters) +void KWordHandler::characters(const _SH_String &sCharacters) { if (isTagOpened) { documentstring.append( ">" ); isTagOpened = false; } - documentstring.append( WPXString(sCharacters, true) ); +#ifdef HAVE_LIBWPD_0100 + documentstring.append( _SH_String::escapeXML(sCharacters) ); +#else + documentstring.append( _SH_String(sCharacters, true) ); +#endif } @@ -348,19 +268,25 @@ KoFilter::ConversionStatus WPImport::convert( const TQCString& from, const TQCSt fclose( f ); // instream now owns buf, no need to delete buf later - WPXMemoryInputStream instream = WPXMemoryInputStream( buf, fsize ); + _SH_MemoryInputStream instream = _SH_MemoryInputStream( buf, fsize ); -#ifdef HAVE_LIBWPD_090 +#if defined(HAVE_LIBWPD_0100) + libwpd::WPDConfidence confidence = libwpd::WPDocument::isFileFormatSupported(&instream); +#elif defined(HAVE_LIBWPD_090) WPDConfidence confidence = WPDocument::isFileFormatSupported(&instream); -#else // HAVE_LIBWPD_090 +#else WPDConfidence confidence = WPDocument::isFileFormatSupported(&instream, false); -#endif // HAVE_LIBWPD_090 +#endif +#if defined(HAVE_LIBWPD_0100) + if( confidence == libwpd::WPD_CONFIDENCE_NONE ) +#else if( confidence == WPD_CONFIDENCE_NONE ) +#endif { fprintf(stderr, "ERROR: We have no confidence that you are giving us a valid WordPerfect document.\n"); return KoFilter::StupidError; } - instream.seek(0, WPX_SEEK_SET); + instream.seek(0, _SH_SEEK_SET); // open and parse the file KWordHandler handler; -- cgit v1.2.1