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.
pull/1/head
Michele Calgaro 11 years ago
parent d3cd90948f
commit ebea843b5c

@ -92,6 +92,9 @@
/* Defines if your system has libpwd greater than or equal to v0.9.0 */ /* Defines if your system has libpwd greater than or equal to v0.9.0 */
#undef HAVE_LIBWPD_090 #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 */ /* Define if you have libz */
#undef HAVE_LIBZ #undef HAVE_LIBZ

@ -45,6 +45,31 @@ if test -z "$LIBWPD_LIBS"; then
fi fi
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_LIBS)
AC_SUBST(LIBWPD_CFLAGS) AC_SUBST(LIBWPD_CFLAGS)
AC_SUBST(LIBWPD_RPATH) AC_SUBST(LIBWPD_RPATH)

@ -48,7 +48,7 @@ void TagOpenElement::print() const
TagElement::print(); 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); maAttrList.insert(szAttributeName, sAttributeValue);
} }
@ -66,8 +66,12 @@ void CharDataElement::write(DocumentHandler &xHandler) const
xHandler.characters(msData); xHandler.characters(msData);
} }
TextElement::TextElement(const WPXString & sTextBuf) : TextElement::TextElement(const _SH_String & sTextBuf) :
#ifdef HAVE_LIBWPD_0100
msTextBuf(sTextBuf)
#else
msTextBuf(sTextBuf, false) msTextBuf(sTextBuf, false)
#endif
{ {
} }
@ -75,12 +79,12 @@ TextElement::TextElement(const WPXString & sTextBuf) :
// elements // elements
void TextElement::write(DocumentHandler &xHandler) const void TextElement::write(DocumentHandler &xHandler) const
{ {
WPXPropertyList xBlankAttrList; _SH_PropertyList xBlankAttrList;
WPXString sTemp; _SH_String sTemp;
int iNumConsecutiveSpaces = 0; int iNumConsecutiveSpaces = 0;
WPXString::Iter i(msTextBuf); _SH_String::Iter i(msTextBuf);
for (i.rewind(); i.next();) for (i.rewind(); i.next();)
{ {
if (*(i()) == ASCII_SPACE) if (*(i()) == ASCII_SPACE)

@ -28,14 +28,12 @@
#ifndef _DOCUMENTELEMENT_H #ifndef _DOCUMENTELEMENT_H
#define _DOCUMENTELEMENT_H #define _DOCUMENTELEMENT_H
#include <libwpd/libwpd.h> #include <libwpd/libwpd.h>
#include <libwpd/WPXProperty.h>
#include <libwpd/WPXString.h>
#include <vector> #include <vector>
#include "shared_headers.h"
#include "DocumentHandler.hxx" #include "DocumentHandler.hxx"
const float fDefaultSideMargin = 1.0f; // inches const float fDefaultSideMargin = 1.0f; // inches
const float fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later) const float fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later)
const float fDefaultPageHeight = 11.0f; // inches const float fDefaultPageHeight = 11.0f; // inches
@ -52,10 +50,10 @@ class TagElement : public DocumentElement
{ {
public: public:
TagElement(const char *szTagName) : msTagName(szTagName) {} TagElement(const char *szTagName) : msTagName(szTagName) {}
const WPXString & getTagName() const { return msTagName; } const _SH_String & getTagName() const { return msTagName; }
virtual void print() const; virtual void print() const;
private: private:
WPXString msTagName; _SH_String msTagName;
}; };
class TagOpenElement : public TagElement class TagOpenElement : public TagElement
@ -63,11 +61,11 @@ class TagOpenElement : public TagElement
public: public:
TagOpenElement(const char *szTagName) : TagElement(szTagName) {} TagOpenElement(const char *szTagName) : TagElement(szTagName) {}
~TagOpenElement() {} ~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 write(DocumentHandler &xHandler) const;
virtual void print () const; virtual void print () const;
private: private:
WPXPropertyList maAttrList; _SH_PropertyList maAttrList;
}; };
class TagCloseElement : public TagElement class TagCloseElement : public TagElement
@ -83,17 +81,17 @@ public:
CharDataElement(const char *sData) : DocumentElement(), msData(sData) {} CharDataElement(const char *sData) : DocumentElement(), msData(sData) {}
virtual void write(DocumentHandler &xHandler) const; virtual void write(DocumentHandler &xHandler) const;
private: private:
WPXString msData; _SH_String msData;
}; };
class TextElement : public DocumentElement class TextElement : public DocumentElement
{ {
public: public:
TextElement(const WPXString & sTextBuf); TextElement(const _SH_String & sTextBuf);
virtual void write(DocumentHandler &xHandler) const; virtual void write(DocumentHandler &xHandler) const;
private: private:
WPXString msTextBuf; _SH_String msTextBuf;
}; };
#endif #endif

@ -27,17 +27,18 @@
*/ */
#ifndef _DOCUMENTHANDLER_H #ifndef _DOCUMENTHANDLER_H
#define _DOCUMENTHANDLER_H #define _DOCUMENTHANDLER_H
#include <libwpd/libwpd.h> #include <libwpd/libwpd.h>
#include <libwpd/WPXProperty.h> #include "shared_headers.h"
#include <libwpd/WPXString.h>
class DocumentHandler class DocumentHandler
{ {
public: public:
virtual void startDocument() = 0; virtual void startDocument() = 0;
virtual void endDocument() = 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 endElement(const char *psName) = 0;
virtual void characters(const WPXString &sCharacters) = 0; virtual void characters(const _SH_String &sCharacters) = 0;
}; };
#endif #endif

@ -27,10 +27,11 @@
*/ */
#ifndef _FONTSTYLE_H #ifndef _FONTSTYLE_H
#define _FONTSTYLE_H #define _FONTSTYLE_H
#include <libwpd/libwpd.h>
#include <libwpd/libwpd.h>
#include "Style.hxx" #include "Style.hxx"
#include "WriterProperties.hxx" #include "WriterProperties.hxx"
#include "shared_headers.h"
class FontStyle : public Style class FontStyle : public Style
{ {
@ -38,10 +39,10 @@ public:
FontStyle(const char *psName, const char *psFontFamily); FontStyle(const char *psName, const char *psFontFamily);
~FontStyle(); ~FontStyle();
virtual void write(DocumentHandler &xHandler) const; virtual void write(DocumentHandler &xHandler) const;
const WPXString &getFontFamily() const { return msFontFamily; } const _SH_String &getFontFamily() const { return msFontFamily; }
private: private:
WPXString msFontFamily; _SH_String msFontFamily;
WPXString msFontPitch; _SH_String msFontPitch;
}; };
#endif #endif

@ -29,12 +29,12 @@
#include "ListStyle.hxx" #include "ListStyle.hxx"
#include "DocumentElement.hxx" #include "DocumentElement.hxx"
OrderedListLevelStyle::OrderedListLevelStyle(const WPXPropertyList &xPropList) : OrderedListLevelStyle::OrderedListLevelStyle(const _SH_PropertyList &xPropList) :
mPropList(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) if (iLevel < 0)
return; return;
@ -44,7 +44,7 @@ void OrderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList &
void OrderedListLevelStyle::write(DocumentHandler &xHandler, int iLevel) const void OrderedListLevelStyle::write(DocumentHandler &xHandler, int iLevel) const
{ {
WPXString sLevel; _SH_String sLevel;
sLevel.sprintf("%i", (iLevel+1)); sLevel.sprintf("%i", (iLevel+1));
TagOpenElement listLevelStyleOpen("text:list-level-style-number"); 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"); xHandler.endElement("text:list-level-style-number");
} }
UnorderedListLevelStyle::UnorderedListLevelStyle(const WPXPropertyList &xPropList) UnorderedListLevelStyle::UnorderedListLevelStyle(const _SH_PropertyList &xPropList)
: mPropList(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) if (iLevel < 0)
return; return;
@ -88,7 +88,7 @@ void UnorderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList
void UnorderedListLevelStyle::write(DocumentHandler &xHandler, int iLevel) const void UnorderedListLevelStyle::write(DocumentHandler &xHandler, int iLevel) const
{ {
WPXString sLevel; _SH_String sLevel;
sLevel.sprintf("%i", (iLevel+1)); sLevel.sprintf("%i", (iLevel+1));
TagOpenElement listLevelStyleOpen("text:list-level-style-bullet"); TagOpenElement listLevelStyleOpen("text:list-level-style-bullet");
listLevelStyleOpen.addAttribute("text:level", sLevel); listLevelStyleOpen.addAttribute("text:level", sLevel);

@ -28,6 +28,7 @@
#ifndef _LISTSTYLE_H #ifndef _LISTSTYLE_H
#define _LISTSTYLE_H #define _LISTSTYLE_H
#include <libwpd/libwpd.h> #include <libwpd/libwpd.h>
#include "shared_headers.h"
#define WP6_NUM_LIST_LEVELS 8 // see WP6FileStructure.h (we shouldn't need to reference this) #define WP6_NUM_LIST_LEVELS 8 // see WP6FileStructure.h (we shouldn't need to reference this)
@ -40,24 +41,25 @@ class ListLevelStyle
{ {
public: public:
virtual void write(DocumentHandler &xHandler, int iLevel) const = 0; virtual void write(DocumentHandler &xHandler, int iLevel) const = 0;
virtual ~ListLevelStyle() {}
}; };
class OrderedListLevelStyle : public ListLevelStyle class OrderedListLevelStyle : public ListLevelStyle
{ {
public: public:
OrderedListLevelStyle(const WPXPropertyList &xPropList); OrderedListLevelStyle(const _SH_PropertyList &xPropList);
virtual void write(DocumentHandler &xHandler, int iLevel) const; virtual void write(DocumentHandler &xHandler, int iLevel) const;
private: private:
WPXPropertyList mPropList; _SH_PropertyList mPropList;
}; };
class UnorderedListLevelStyle : public ListLevelStyle class UnorderedListLevelStyle : public ListLevelStyle
{ {
public: public:
UnorderedListLevelStyle(const WPXPropertyList &xPropList); UnorderedListLevelStyle(const _SH_PropertyList &xPropList);
virtual void write(DocumentHandler &xHandler, int iLevel) const; virtual void write(DocumentHandler &xHandler, int iLevel) const;
private: private:
WPXPropertyList mPropList; _SH_PropertyList mPropList;
}; };
class ListStyle : public Style class ListStyle : public Style
@ -65,7 +67,7 @@ class ListStyle : public Style
public: public:
ListStyle(const char *psName, const int iListID); ListStyle(const char *psName, const int iListID);
virtual ~ListStyle(); 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; virtual void write(DocumentHandler &xHandler) const;
const int getListID() { return miListID; } const int getListID() { return miListID; }
const bool isListLevelDefined(int iLevel) const; const bool isListLevelDefined(int iLevel) const;
@ -83,13 +85,13 @@ class OrderedListStyle : public ListStyle
{ {
public: public:
OrderedListStyle(const char *psName, const int iListID) : ListStyle(psName, iListID) {} 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 class UnorderedListStyle : public ListStyle
{ {
public: public:
UnorderedListStyle(const char *psName, const int iListID) : ListStyle(psName, iListID) {} 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 #endif

@ -33,7 +33,7 @@
#include "DocumentElement.hxx" #include "DocumentElement.hxx"
PageSpan::PageSpan(const WPXPropertyList &xPropList) : PageSpan::PageSpan(const _SH_PropertyList &xPropList) :
#if 0 #if 0
const int iSpan, const float fFormLength, const float fFormWidth, const WPXFormQt::Orientation fFormQt::Orientation, 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): const float fLeftMargin, const float fRightMargin, const float fTopMargin, const float fBottomMargin):
@ -73,7 +73,7 @@ int PageSpan::getSpan() const
float PageSpan::getMarginLeft() const float PageSpan::getMarginLeft() const
{ {
if (mxPropList["fo:margin-left"]) if (mxPropList["fo:margin-left"])
#ifdef HAVE_LIBWPD_090 #if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100)
return mxPropList["fo:margin-left"]->getDouble(); return mxPropList["fo:margin-left"]->getDouble();
#else #else
return mxPropList["fo:margin-left"]->getFloat(); return mxPropList["fo:margin-left"]->getFloat();
@ -85,7 +85,7 @@ float PageSpan::getMarginLeft() const
float PageSpan::getMarginRight() const float PageSpan::getMarginRight() const
{ {
if (mxPropList["fo:margin-right"]) if (mxPropList["fo:margin-right"])
#ifdef HAVE_LIBWPD_090 #if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100)
return mxPropList["fo:margin-right"]->getDouble(); return mxPropList["fo:margin-right"]->getDouble();
#else #else
return mxPropList["fo:margin-right"]->getFloat(); return mxPropList["fo:margin-right"]->getFloat();
@ -96,27 +96,27 @@ float PageSpan::getMarginRight() const
void PageSpan::writePageMaster(const int iNum, DocumentHandler &xHandler) 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); sPageMasterName.sprintf("PM%i", iNum+2);
propList.insert("style:name", sPageMasterName); propList.insert("style:name", sPageMasterName);
xHandler.startElement("style:page-master", propList); xHandler.startElement("style:page-master", propList);
WPXPropertyList tempPropList = mxPropList; _SH_PropertyList tempPropList = mxPropList;
if (!tempPropList["style:writing-mode"]) 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"]) 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); xHandler.startElement("style:properties", tempPropList);
WPXPropertyList footnoteSepPropList; _SH_PropertyList footnoteSepPropList;
footnoteSepPropList.insert("style:width", WPXString("0.0071inch")); footnoteSepPropList.insert("style:width", _SH_String("0.0071inch"));
footnoteSepPropList.insert("style:distance-before-sep", WPXString("0.0398inch")); footnoteSepPropList.insert("style:distance-before-sep", _SH_String("0.0398inch"));
footnoteSepPropList.insert("style:distance-after-sep", WPXString("0.0398inch")); footnoteSepPropList.insert("style:distance-after-sep", _SH_String("0.0398inch"));
footnoteSepPropList.insert("style:adjustment", WPXString("left")); footnoteSepPropList.insert("style:adjustment", _SH_String("left"));
footnoteSepPropList.insert("style:rel-width", WPXString("25\%")); footnoteSepPropList.insert("style:rel-width", _SH_String("25\%"));
footnoteSepPropList.insert("style:color", WPXString("#000000")); footnoteSepPropList.insert("style:color", _SH_String("#000000"));
xHandler.startElement("style:footnote-sep", footnoteSepPropList); xHandler.startElement("style:footnote-sep", footnoteSepPropList);
xHandler.endElement("style:footnote-sep"); 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, void PageSpan::writeMasterPages(const int iStartingNum, const int iPageMasterNum, const bool bLastPageSpan,
DocumentHandler &xHandler) const DocumentHandler &xHandler) const
{ {
WPXPropertyList propList; // scratch space _SH_PropertyList propList; // scratch space
int iSpan = 0; int iSpan = 0;
(bLastPageSpan) ? iSpan = 1 : iSpan = getSpan(); (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++) for (int i=iStartingNum; i<(iStartingNum+iSpan); i++)
{ {
TagOpenElement masterPageOpen("style:master-page"); TagOpenElement masterPageOpen("style:master-page");
WPXString sMasterPageName; _SH_String sMasterPageName;
sMasterPageName.sprintf("Page Style %i", i); sMasterPageName.sprintf("Page Style %i", i);
WPXString sPageMasterName; _SH_String sPageMasterName;
sPageMasterName.sprintf("PM%i", iPageMasterNum+2); sPageMasterName.sprintf("PM%i", iPageMasterNum+2);
propList.insert("style:name", sMasterPageName); propList.insert("style:name", sMasterPageName);
propList.insert("style:page-master-name", sPageMasterName); propList.insert("style:page-master-name", sPageMasterName);
if (!bLastPageSpan) if (!bLastPageSpan)
{ {
WPXString sNextMasterPageName; _SH_String sNextMasterPageName;
sNextMasterPageName.sprintf("Page Style %i", (i+1)); sNextMasterPageName.sprintf("Page Style %i", (i+1));
propList.insert("style:next-style-name", sNextMasterPageName); propList.insert("style:next-style-name", sNextMasterPageName);
} }

@ -29,6 +29,7 @@
#define _PAGESPAN_H #define _PAGESPAN_H
#include <libwpd/libwpd.h> #include <libwpd/libwpd.h>
#include <vector> #include <vector>
#include "shared_headers.h"
class DocumentElement; class DocumentElement;
class DocumentHandler; class DocumentHandler;
@ -36,7 +37,7 @@ class DocumentHandler;
class PageSpan class PageSpan
{ {
public: public:
PageSpan(const WPXPropertyList &xPropList); PageSpan(const _SH_PropertyList &xPropList);
virtual ~PageSpan(); virtual ~PageSpan();
void writePageMaster(const int iNum, DocumentHandler &xHandler) const; void writePageMaster(const int iNum, DocumentHandler &xHandler) const;
void writeMasterPages(const int iStartingNum, const int iPageMasterNum, const bool bLastPageSpan, 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<DocumentElement *> & headerFooterContent, void _writeHeaderFooter(const char *headerFooterTagName, const std::vector<DocumentElement *> & headerFooterContent,
DocumentHandler &xHandler) const; DocumentHandler &xHandler) const;
private: private:
WPXPropertyList mxPropList; _SH_PropertyList mxPropList;
std::vector<DocumentElement *> * mpHeaderContent; std::vector<DocumentElement *> * mpHeaderContent;
std::vector<DocumentElement *> * mpFooterContent; std::vector<DocumentElement *> * mpFooterContent;
std::vector<DocumentElement *> * mpHeaderLeftContent; std::vector<DocumentElement *> * mpHeaderLeftContent;

@ -37,8 +37,8 @@ double rint(double x);
#endif /* _WIN32 */ #endif /* _WIN32 */
SectionStyle::SectionStyle(const WPXPropertyList &xPropList, SectionStyle::SectionStyle(const _SH_PropertyList &xPropList,
const WPXPropertyListVector &xColumns, const _SH_PropertyListVector &xColumns,
const char *psName) : const char *psName) :
Style(psName), Style(psName),
mPropList(xPropList), mPropList(xPropList),
@ -60,11 +60,11 @@ void SectionStyle::write(DocumentHandler &xHandler) const
xHandler.startElement("style:properties", mPropList); xHandler.startElement("style:properties", mPropList);
// column properties // column properties
WPXPropertyList columnProps; _SH_PropertyList columnProps;
columnProps.insert("fo:column-count", (int)mColumns.count()); columnProps.insert("fo:column-count", (int)mColumns.count());
xHandler.startElement("style:columns", columnProps); xHandler.startElement("style:columns", columnProps);
WPXPropertyListVector::Iter i(mColumns); _SH_PropertyListVector::Iter i(mColumns);
for (i.rewind(); i.next();) for (i.rewind(); i.next();)
{ {
xHandler.startElement("style:column", i()); xHandler.startElement("style:column", i());

@ -28,7 +28,7 @@
#ifndef _SECTIONSTYLE_H #ifndef _SECTIONSTYLE_H
#define _SECTIONSTYLE_H #define _SECTIONSTYLE_H
#include <libwpd/libwpd.h> #include <libwpd/libwpd.h>
#include <libwpd/WPXPropertyListVector.h> #include "shared_headers.h"
#include "Style.hxx" #include "Style.hxx"
#include "WriterProperties.hxx" #include "WriterProperties.hxx"
@ -37,11 +37,11 @@
class SectionStyle : public Style class SectionStyle : public Style
{ {
public: 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; virtual void write(DocumentHandler &xHandler) const;
private: private:
WPXPropertyList mPropList; _SH_PropertyList mPropList;
WPXPropertyListVector mColumns; _SH_PropertyListVector mColumns;
}; };
#endif #endif

@ -38,23 +38,23 @@ class TopLevelElementStyle
public: public:
TopLevelElementStyle() : mpsMasterPageName(NULL) { } TopLevelElementStyle() : mpsMasterPageName(NULL) { }
virtual ~TopLevelElementStyle() { if (mpsMasterPageName) delete mpsMasterPageName; } virtual ~TopLevelElementStyle() { if (mpsMasterPageName) delete mpsMasterPageName; }
void setMasterPageName(WPXString &sMasterPageName) { mpsMasterPageName = new WPXString(sMasterPageName); } void setMasterPageName(_SH_String &sMasterPageName) { mpsMasterPageName = new _SH_String(sMasterPageName); }
const WPXString * getMasterPageName() const { return mpsMasterPageName; } const _SH_String * getMasterPageName() const { return mpsMasterPageName; }
private: private:
WPXString *mpsMasterPageName; _SH_String *mpsMasterPageName;
}; };
class Style class Style
{ {
public: public:
Style(const WPXString &psName) : msName(psName) {} Style(const _SH_String &psName) : msName(psName) {}
virtual ~Style() {} virtual ~Style() {}
virtual void write(DocumentHandler &xHandler) const {}; virtual void write(DocumentHandler &xHandler) const {};
const WPXString &getName() const { return msName; } const _SH_String &getName() const { return msName; }
private: private:
WPXString msName; _SH_String msName;
}; };
#endif #endif

@ -37,7 +37,7 @@
#include <minmax.h> #include <minmax.h>
#endif #endif
TableCellStyle::TableCellStyle(const WPXPropertyList &xPropList, const char *psName) : TableCellStyle::TableCellStyle(const _SH_PropertyList &xPropList, const char *psName) :
Style(psName), Style(psName),
mPropList(xPropList) mPropList(xPropList)
{ {
@ -52,8 +52,8 @@ void TableCellStyle::write(DocumentHandler &xHandler) const
// WLACH_REFACTORING: Only temporary.. a much better solution is to // WLACH_REFACTORING: Only temporary.. a much better solution is to
// generalize this sort of thing into the "Style" superclass // generalize this sort of thing into the "Style" superclass
WPXPropertyList stylePropList; _SH_PropertyList stylePropList;
WPXPropertyList::Iter i(mPropList); _SH_PropertyList::Iter i(mPropList);
for (i.rewind(); i.next();) for (i.rewind(); i.next();)
{ {
if (strlen(i.key()) > 2 && strncmp(i.key(), "fo", 2) == 0) 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"); xHandler.endElement("style:style");
} }
TableRowStyle::TableRowStyle(const WPXPropertyList &propList, const char *psName) : TableRowStyle::TableRowStyle(const _SH_PropertyList &propList, const char *psName) :
Style(psName), Style(psName),
mPropList(propList) 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), Style(psName),
mPropList(xPropList), mPropList(xPropList),
mColumns(columns) mColumns(columns)
@ -133,11 +133,11 @@ void TableStyle::write(DocumentHandler &xHandler) const
xHandler.endElement("style:style"); xHandler.endElement("style:style");
int i=1; int i=1;
WPXPropertyListVector::Iter j(mColumns); _SH_PropertyListVector::Iter j(mColumns);
for (j.rewind(); j.next();) for (j.rewind(); j.next();)
{ {
TagOpenElement styleOpen("style:style"); TagOpenElement styleOpen("style:style");
WPXString sColumnName; _SH_String sColumnName;
sColumnName.sprintf("%s.Column%i", getName().cstr(), i); sColumnName.sprintf("%s.Column%i", getName().cstr(), i);
styleOpen.addAttribute("style:name", sColumnName); styleOpen.addAttribute("style:name", sColumnName);
styleOpen.addAttribute("style:family", "table-column"); styleOpen.addAttribute("style:family", "table-column");

@ -30,7 +30,7 @@
#define _TABLESTYLE_H #define _TABLESTYLE_H
#include <libwpd/libwpd.h> #include <libwpd/libwpd.h>
#include <vector> #include <vector>
#include "shared_headers.h"
#include "Style.hxx" #include "Style.hxx"
#include "WriterProperties.hxx" #include "WriterProperties.hxx"
@ -40,25 +40,25 @@ class DocumentHandler;
class TableCellStyle : public Style class TableCellStyle : public Style
{ {
public: public:
TableCellStyle(const WPXPropertyList &xPropList, const char *psName); TableCellStyle(const _SH_PropertyList &xPropList, const char *psName);
virtual void write(DocumentHandler &xHandler) const; virtual void write(DocumentHandler &xHandler) const;
private: private:
WPXPropertyList mPropList; _SH_PropertyList mPropList;
}; };
class TableRowStyle : public Style class TableRowStyle : public Style
{ {
public: public:
TableRowStyle(const WPXPropertyList &propList, const char *psName); TableRowStyle(const _SH_PropertyList &propList, const char *psName);
virtual void write(DocumentHandler &xHandler) const; virtual void write(DocumentHandler &xHandler) const;
private: private:
WPXPropertyList mPropList; _SH_PropertyList mPropList;
}; };
class TableStyle : public Style, public TopLevelElementStyle class TableStyle : public Style, public TopLevelElementStyle
{ {
public: public:
TableStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &columns, const char *psName); TableStyle(const _SH_PropertyList &xPropList, const _SH_PropertyListVector &columns, const char *psName);
~TableStyle(); ~TableStyle();
virtual void write(DocumentHandler &xHandler) const; virtual void write(DocumentHandler &xHandler) const;
const int getNumColumns() const { return mColumns.count(); } const int getNumColumns() const { return mColumns.count(); }
@ -67,8 +67,8 @@ public:
void addTableRowStyle(TableRowStyle *pTableRowStyle) { mTableRowStyles.push_back(pTableRowStyle); } void addTableRowStyle(TableRowStyle *pTableRowStyle) { mTableRowStyles.push_back(pTableRowStyle); }
int getNumTableRowStyles() { return mTableRowStyles.size(); } int getNumTableRowStyles() { return mTableRowStyles.size(); }
private: private:
WPXPropertyList mPropList; _SH_PropertyList mPropList;
WPXPropertyListVector mColumns; _SH_PropertyListVector mColumns;
std::vector<TableCellStyle *> mTableCellStyles; std::vector<TableCellStyle *> mTableCellStyles;
std::vector<TableRowStyle *> mTableRowStyles; std::vector<TableRowStyle *> mTableRowStyles;
}; };

@ -39,7 +39,7 @@
#include <minmax.h> #include <minmax.h>
#endif #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), mpPropList(pPropList),
mxTabStops(xTabStops), mxTabStops(xTabStops),
msName(sName) msName(sName)
@ -55,7 +55,7 @@ void ParagraphStyle::write(DocumentHandler &xHandler) const
{ {
WRITER_DEBUG_MSG(("Writing a paragraph style..\n")); WRITER_DEBUG_MSG(("Writing a paragraph style..\n"));
WPXPropertyList propList; _SH_PropertyList propList;
propList.insert("style:name", msName.cstr()); propList.insert("style:name", msName.cstr());
propList.insert("style:family", "paragraph"); propList.insert("style:family", "paragraph");
propList.insert("style:parent-style-name", (*mpPropList)["style:parent-style-name"]->getStr()); 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); xHandler.startElement("style:style", propList);
propList.clear(); propList.clear();
WPXPropertyList::Iter i((*mpPropList)); _SH_PropertyList::Iter i((*mpPropList));
for (i.rewind(); i.next(); ) for (i.rewind(); i.next(); )
{ {
if (strcmp(i.key(), "style:list-style-name") == 0) if (strcmp(i.key(), "style:list-style-name") == 0)
@ -96,12 +96,12 @@ void ParagraphStyle::write(DocumentHandler &xHandler) const
{ {
TagOpenElement tabListOpen("style:tab-stops"); TagOpenElement tabListOpen("style:tab-stops");
tabListOpen.write(xHandler); tabListOpen.write(xHandler);
WPXPropertyListVector::Iter i(mxTabStops); _SH_PropertyListVector::Iter i(mxTabStops);
for (i.rewind(); i.next();) for (i.rewind(); i.next();)
{ {
TagOpenElement tabStopOpen("style:tab-stop"); TagOpenElement tabStopOpen("style:tab-stop");
WPXPropertyList::Iter j(i()); _SH_PropertyList::Iter j(i());
for (j.rewind(); j.next(); ) for (j.rewind(); j.next(); )
{ {
tabStopOpen.addAttribute(j.key(), j()->getStr().cstr()); tabStopOpen.addAttribute(j.key(), j()->getStr().cstr());
@ -116,7 +116,7 @@ void ParagraphStyle::write(DocumentHandler &xHandler) const
xHandler.endElement("style:style"); xHandler.endElement("style:style");
} }
SpanStyle::SpanStyle(const char *psName, const WPXPropertyList &xPropList) : SpanStyle::SpanStyle(const char *psName, const _SH_PropertyList &xPropList) :
Style(psName), Style(psName),
mPropList(xPropList) mPropList(xPropList)
{ {
@ -125,12 +125,12 @@ SpanStyle::SpanStyle(const char *psName, const WPXPropertyList &xPropList) :
void SpanStyle::write(DocumentHandler &xHandler) const void SpanStyle::write(DocumentHandler &xHandler) const
{ {
WRITER_DEBUG_MSG(("Writing a span style..\n")); WRITER_DEBUG_MSG(("Writing a span style..\n"));
WPXPropertyList styleOpenList; _SH_PropertyList styleOpenList;
styleOpenList.insert("style:name", getName()); styleOpenList.insert("style:name", getName());
styleOpenList.insert("style:family", "text"); styleOpenList.insert("style:family", "text");
xHandler.startElement("style:style", styleOpenList); xHandler.startElement("style:style", styleOpenList);
WPXPropertyList propList(mPropList); _SH_PropertyList propList(mPropList);
if (mPropList["style:font-name"]) if (mPropList["style:font-name"])
{ {

@ -30,9 +30,10 @@
#ifndef _TEXTRUNSTYLE_H #ifndef _TEXTRUNSTYLE_H
#define _TEXTRUNSTYLE_H #define _TEXTRUNSTYLE_H
#include <libwpd/libwpd.h>
#include <libwpd/libwpd.h>
#include "Style.hxx" #include "Style.hxx"
#include "shared_headers.h"
class TagOpenElement; class TagOpenElement;
class DocumentElement; class DocumentElement;
@ -41,24 +42,24 @@ class DocumentHandler;
class ParagraphStyle class ParagraphStyle
{ {
public: 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 ~ParagraphStyle();
virtual void write(DocumentHandler &xHandler) const; virtual void write(DocumentHandler &xHandler) const;
WPXString getName() const { return msName; } _SH_String getName() const { return msName; }
private: private:
WPXPropertyList *mpPropList; _SH_PropertyList *mpPropList;
WPXPropertyListVector mxTabStops; _SH_PropertyListVector mxTabStops;
WPXString msName; _SH_String msName;
}; };
class SpanStyle : public Style class SpanStyle : public Style
{ {
public: public:
SpanStyle(const char *psName, const WPXPropertyList &xPropList); SpanStyle(const char *psName, const _SH_PropertyList &xPropList);
virtual void write(DocumentHandler &xHandler) const; virtual void write(DocumentHandler &xHandler) const;
private: private:
WPXPropertyList mPropList; _SH_PropertyList mPropList;
}; };
#endif #endif

@ -55,7 +55,7 @@ _WriterDocumentState::_WriterDocumentState() :
{ {
} }
WordPerfectCollector::WordPerfectCollector(WPXInputStream *pInput, DocumentHandler *pHandler) : WordPerfectCollector::WordPerfectCollector(_SH_InputStream *pInput, DocumentHandler *pHandler) :
mpInput(pInput), mpInput(pInput),
mpHandler(pHandler), mpHandler(pHandler),
mbUsed(false), mbUsed(false),
@ -69,8 +69,8 @@ WordPerfectCollector::WordPerfectCollector(WPXInputStream *pInput, DocumentHandl
miLastListLevel(0), miLastListLevel(0),
miLastListNumber(0), miLastListNumber(0),
mbListContinueNumbering(false), 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")); WRITER_DEBUG_MSG(("Destroying the rest of the styles elements\n"));
for (std::map<WPXString, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin(); iterTextStyle != mTextStyleHash.end(); iterTextStyle++) { for (std::map<_SH_String, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin(); iterTextStyle != mTextStyleHash.end(); iterTextStyle++) {
delete(iterTextStyle->second); delete(iterTextStyle->second);
} }
for (std::map<WPXString, FontStyle *, ltstr>::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); delete(iterFont->second);
} }
@ -135,15 +135,21 @@ bool WordPerfectCollector::filter()
return true; return true;
} }
bool WordPerfectCollector::_parseSourceDocument(WPXInputStream &input) bool WordPerfectCollector::_parseSourceDocument(_SH_InputStream &input)
{ {
#ifdef HAVE_LIBWPD_090 #if defined(HAVE_LIBWPD_0100)
WPDResult result = WPDocument::parse(&input, static_cast<WPXHLListenerImpl *>(this), NULL); 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 #else
WPDResult result = WPDocument::parse(&input, static_cast<WPXHLListenerImpl *>(this)); if (result != WPD_OK)
#endif #endif
if (result != WPD_OK) return false;
return false;
return true; return true;
} }
@ -214,7 +220,7 @@ void WordPerfectCollector::_writeBegin()
void WordPerfectCollector::_writeMasterPages(DocumentHandler &xHandler) void WordPerfectCollector::_writeMasterPages(DocumentHandler &xHandler)
{ {
WPXPropertyList xBlankAttrList; _SH_PropertyList xBlankAttrList;
xHandler.startElement("office:master-styles", xBlankAttrList); xHandler.startElement("office:master-styles", xBlankAttrList);
int pageNumber = 1; int pageNumber = 1;
@ -240,13 +246,13 @@ void WordPerfectCollector::_writePageMasters(DocumentHandler &xHandler)
bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler) bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler)
{ {
WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Printing out the header stuff..\n")); 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")); WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: Start Document\n"));
mpHandler->startDocument(); mpHandler->startDocument();
WRITER_DEBUG_MSG(("WriterWordPerfect: Document Body: preamble\n")); 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:office", "http://openoffice.org/2000/office");
docContentPropList.insert("xmlns:style", "http://openoffice.org/2000/style"); docContentPropList.insert("xmlns:style", "http://openoffice.org/2000/style");
docContentPropList.insert("xmlns:text", "http://openoffice.org/2000/text"); docContentPropList.insert("xmlns:text", "http://openoffice.org/2000/text");
@ -267,7 +273,7 @@ bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler)
// write out the font styles // write out the font styles
mpHandler->startElement("office:font-decls", xBlankAttrList); mpHandler->startElement("office:font-decls", xBlankAttrList);
for (std::map<WPXString, FontStyle *, ltstr>::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); iterFont->second->write(*mpHandler);
} }
TagOpenElement symbolFontOpen("style:font-decl"); TagOpenElement symbolFontOpen("style:font-decl");
@ -287,7 +293,7 @@ bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler)
mpHandler->startElement("office:automatic-styles", xBlankAttrList); mpHandler->startElement("office:automatic-styles", xBlankAttrList);
for (std::map<WPXString, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin(); for (std::map<_SH_String, ParagraphStyle *, ltstr>::iterator iterTextStyle = mTextStyleHash.begin();
iterTextStyle != mTextStyleHash.end(); iterTextStyle++) iterTextStyle != mTextStyleHash.end(); iterTextStyle++)
{ {
// writing out the paragraph styles // writing out the paragraph styles
@ -299,7 +305,7 @@ bool WordPerfectCollector::_writeTargetDocument(DocumentHandler &xHandler)
} }
// span styles.. // span styles..
for (std::map<WPXString, SpanStyle *, ltstr>::iterator iterSpanStyle = mSpanStyleHash.begin(); for (std::map<_SH_String, SpanStyle *, ltstr>::iterator iterSpanStyle = mSpanStyleHash.begin();
iterSpanStyle != mSpanStyleHash.end(); iterSpanStyle++) iterSpanStyle != mSpanStyleHash.end(); iterSpanStyle++)
{ {
(iterSpanStyle->second)->write(xHandler); (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; _SH_String sKey;
WPXPropertyList::Iter i(xPropList); _SH_PropertyList::Iter i(xPropList);
for (i.rewind(); i.next(); ) for (i.rewind(); i.next(); )
{ {
WPXString sProp; _SH_String sProp;
sProp.sprintf("[%s:%s]", i.key(), i()->getStr().cstr()); sProp.sprintf("[%s:%s]", i.key(), i()->getStr().cstr());
sKey.append(sProp); sKey.append(sProp);
} }
@ -360,13 +366,13 @@ WPXString propListToStyleKey(const WPXPropertyList & xPropList)
return sKey; 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()); sTabStops.sprintf("[num-tab-stops:%i]", xTabStops.count());
WPXPropertyListVector::Iter i(xTabStops); _SH_PropertyListVector::Iter i(xTabStops);
for (i.rewind(); i.next();) for (i.rewind(); i.next();)
{ {
sTabStops.append(propListToStyleKey(i())); 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 // _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()) 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); PageSpan *pPageSpan = new PageSpan(propList);
mPageSpans.push_back(pPageSpan); mPageSpans.push_back(pPageSpan);
mpCurrentPageSpan = pPageSpan; mpCurrentPageSpan = pPageSpan;
} }
void WordPerfectCollector::openHeader(const WPXPropertyList &propList) void WordPerfectCollector::openHeader(const _SH_PropertyList &propList)
{ {
std::vector<DocumentElement *> * pHeaderFooterContentElements = new std::vector<DocumentElement *>; std::vector<DocumentElement *> * pHeaderFooterContentElements = new std::vector<DocumentElement *>;
@ -410,7 +416,7 @@ void WordPerfectCollector::closeHeader()
mpCurrentContentElements = &mBodyElements; mpCurrentContentElements = &mBodyElements;
} }
void WordPerfectCollector::openFooter(const WPXPropertyList &propList) void WordPerfectCollector::openFooter(const _SH_PropertyList &propList)
{ {
std::vector<DocumentElement *> * pHeaderFooterContentElements = new std::vector<DocumentElement *>; std::vector<DocumentElement *> * pHeaderFooterContentElements = new std::vector<DocumentElement *>;
@ -427,18 +433,18 @@ void WordPerfectCollector::closeFooter()
mpCurrentContentElements = &mBodyElements; 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(); int iNumColumns = columns.count();
if (iNumColumns > 1) if (iNumColumns > 1)
{ {
#ifdef HAVE_LIBWPD_090 #if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100)
mfSectionSpaceAfter = propList["fo:margin-bottom"]->getDouble(); mfSectionSpaceAfter = propList["fo:margin-bottom"]->getDouble();
#else #else
mfSectionSpaceAfter = propList["fo:margin-bottom"]->getFloat(); mfSectionSpaceAfter = propList["fo:margin-bottom"]->getFloat();
#endif #endif
WPXString sSectionName; _SH_String sSectionName;
sSectionName.sprintf("Section%i", mSectionStyles.size()); sSectionName.sprintf("Section%i", mSectionStyles.size());
SectionStyle *pSectionStyle = new SectionStyle(propList, columns, sSectionName.cstr()); SectionStyle *pSectionStyle = new SectionStyle(propList, columns, sSectionName.cstr());
@ -472,12 +478,12 @@ void WordPerfectCollector::closeSection()
mfSectionSpaceAfter = 0.0f; 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 // FIXMENOW: What happens if we open a footnote inside a table? do we then inherit the footnote's style
// from "Table Contents" // from "Table Contents"
WPXPropertyList *pPersistPropList = new WPXPropertyList(propList); _SH_PropertyList *pPersistPropList = new _SH_PropertyList(propList);
ParagraphStyle *pStyle = NULL; ParagraphStyle *pStyle = NULL;
if (mWriterDocumentState.mbFirstElement && mpCurrentContentElements == &mBodyElements) 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 // be inside a table in this case (the table would be the first document element
//in that case) //in that case)
pPersistPropList->insert("style:parent-style-name", "Standard"); pPersistPropList->insert("style:parent-style-name", "Standard");
WPXString sName; _SH_String sName;
sName.sprintf("FS"); sName.sprintf("FS");
WPXString sParagraphHashKey("P|FS"); _SH_String sParagraphHashKey("P|FS");
pPersistPropList->insert("style:master-page-name", "Page Style 1"); pPersistPropList->insert("style:master-page-name", "Page Style 1");
pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName); pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
mTextStyleHash[sParagraphHashKey] = pStyle; mTextStyleHash[sParagraphHashKey] = pStyle;
@ -509,10 +515,10 @@ void WordPerfectCollector::openParagraph(const WPXPropertyList &propList, const
else else
pPersistPropList->insert("style:parent-style-name", "Standard"); pPersistPropList->insert("style:parent-style-name", "Standard");
WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops); _SH_String sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) { if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) {
WPXString sName; _SH_String sName;
sName.sprintf("S%i", mTextStyleHash.size()); sName.sprintf("S%i", mTextStyleHash.size());
pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName); pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName);
@ -536,15 +542,15 @@ void WordPerfectCollector::closeParagraph()
mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:p"))); mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:p")));
} }
void WordPerfectCollector::openSpan(const WPXPropertyList &propList) void WordPerfectCollector::openSpan(const _SH_PropertyList &propList)
{ {
if (propList["style:font-name"]) if (propList["style:font-name"])
_allocateFontName(propList["style:font-name"]->getStr()); _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())); WRITER_DEBUG_MSG(("WriterWordPerfect: Span Hash Key: %s\n", sSpanHashKey.cstr()));
// Get the style // Get the style
WPXString sName; _SH_String sName;
if (mSpanStyleHash.find(sSpanHashKey) == mSpanStyleHash.end()) if (mSpanStyleHash.find(sSpanHashKey) == mSpanStyleHash.end())
{ {
// allocate a new paragraph style // allocate a new paragraph style
@ -569,7 +575,7 @@ void WordPerfectCollector::closeSpan()
mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:span"))); mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:span")));
} }
void WordPerfectCollector::defineOrderedListLevel(const WPXPropertyList &propList) void WordPerfectCollector::defineOrderedListLevel(const _SH_PropertyList &propList)
{ {
int id = 0; int id = 0;
if (propList["libwpd:id"]) 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)))) (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)); 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); sName.sprintf("OL%i", miNumListStyles);
miNumListStyles++; miNumListStyles++;
pOrderedListStyle = new OrderedListStyle(sName.cstr(), propList["libwpd:id"]->getInt()); 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; int id = 0;
if (propList["libwpd:id"]) if (propList["libwpd:id"])
@ -622,7 +628,7 @@ void WordPerfectCollector::defineUnorderedListLevel(const WPXPropertyList &propL
if (pUnorderedListStyle == NULL) { if (pUnorderedListStyle == NULL) {
WRITER_DEBUG_MSG(("Attempting to create a new unordered list style (listid: %i)\n", id)); 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); sName.sprintf("UL%i", miNumListStyles);
pUnorderedListStyle = new UnorderedListStyle(sName.cstr(), id); pUnorderedListStyle = new UnorderedListStyle(sName.cstr(), id);
mListStyles.push_back(static_cast<ListStyle *>(pUnorderedListStyle)); mListStyles.push_back(static_cast<ListStyle *>(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++; miCurrentListLevel++;
TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:ordered-list"); TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:ordered-list");
@ -650,7 +656,7 @@ void WordPerfectCollector::openOrderedListLevel(const WPXPropertyList &propList)
mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pListLevelOpenElement)); mpCurrentContentElements->push_back(static_cast<DocumentElement *>(pListLevelOpenElement));
} }
void WordPerfectCollector::openUnorderedListLevel(const WPXPropertyList &propList) void WordPerfectCollector::openUnorderedListLevel(const _SH_PropertyList &propList)
{ {
miCurrentListLevel++; miCurrentListLevel++;
TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:unordered-list"); TagOpenElement *pListLevelOpenElement = new TagOpenElement("text:unordered-list");
@ -695,7 +701,7 @@ void WordPerfectCollector::_closeListLevel(const char *szListType)
miCurrentListLevel--; miCurrentListLevel--;
WPXString sCloseElement; _SH_String sCloseElement;
sCloseElement.sprintf("text:%s", szListType); sCloseElement.sprintf("text:%s", szListType);
mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement(sCloseElement.cstr()))); mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement(sCloseElement.cstr())));
@ -704,7 +710,7 @@ void WordPerfectCollector::_closeListLevel(const char *szListType)
mbListElementOpened = false; mbListElementOpened = false;
} }
void WordPerfectCollector::openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) void WordPerfectCollector::openListElement(const _SH_PropertyList &propList, const _SH_PropertyListVector &tabStops)
{ {
miLastListLevel = miCurrentListLevel; miLastListLevel = miCurrentListLevel;
if (miCurrentListLevel == 1) if (miCurrentListLevel == 1)
@ -715,15 +721,15 @@ void WordPerfectCollector::openListElement(const WPXPropertyList &propList, cons
ParagraphStyle *pStyle = NULL; 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:list-style-name", mpCurrentListStyle->getName());
pPersistPropList->insert("style:parent-style-name", "Standard"); pPersistPropList->insert("style:parent-style-name", "Standard");
WPXString sKey = getParagraphStyleKey(*pPersistPropList, tabStops); _SH_String sKey = getParagraphStyleKey(*pPersistPropList, tabStops);
if (mTextStyleHash.find(sKey) == mTextStyleHash.end()) if (mTextStyleHash.find(sKey) == mTextStyleHash.end())
{ {
WPXString sName; _SH_String sName;
sName.sprintf("S%i", mTextStyleHash.size()); sName.sprintf("S%i", mTextStyleHash.size());
pStyle = new ParagraphStyle(pPersistPropList, tabStops, sName); 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"); TagOpenElement *pOpenFootNote = new TagOpenElement("text:footnote");
if (propList["libwpd:number"]) if (propList["libwpd:number"])
{ {
WPXString tmpString("ftn"); _SH_String tmpString("ftn");
tmpString.append(propList["libwpd:number"]->getStr()); tmpString.append(propList["libwpd:number"]->getStr());
pOpenFootNote->addAttribute("text:id", tmpString); pOpenFootNote->addAttribute("text:id", tmpString);
} }
@ -791,12 +797,12 @@ void WordPerfectCollector::closeFootnote()
mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:footnote"))); mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:footnote")));
} }
void WordPerfectCollector::openEndnote(const WPXPropertyList &propList) void WordPerfectCollector::openEndnote(const _SH_PropertyList &propList)
{ {
TagOpenElement *pOpenEndNote = new TagOpenElement("text:endnote"); TagOpenElement *pOpenEndNote = new TagOpenElement("text:endnote");
if (propList["libwpd:number"]) if (propList["libwpd:number"])
{ {
WPXString tmpString("edn"); _SH_String tmpString("edn");
tmpString.append(propList["libwpd:number"]->getStr()); tmpString.append(propList["libwpd:number"]->getStr());
pOpenEndNote->addAttribute("text:id", tmpString); pOpenEndNote->addAttribute("text:id", tmpString);
} }
@ -820,11 +826,11 @@ void WordPerfectCollector::closeEndnote()
mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:endnote"))); mpCurrentContentElements->push_back(static_cast<DocumentElement *>(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) if (!mWriterDocumentState.mbInNote)
{ {
WPXString sTableName; _SH_String sTableName;
sTableName.sprintf("Table%i", mTableStyles.size()); sTableName.sprintf("Table%i", mTableStyles.size());
// FIXME: we base the table style off of the page's margin left, ignoring (potential) wordperfect margin // 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) if (mWriterDocumentState.mbFirstElement && mpCurrentContentElements == &mBodyElements)
{ {
WPXString sMasterPageName("Page Style 1"); _SH_String sMasterPageName("Page Style 1");
pTableStyle->setMasterPageName(sMasterPageName); pTableStyle->setMasterPageName(sMasterPageName);
mWriterDocumentState.mbFirstElement = false; mWriterDocumentState.mbFirstElement = false;
} }
@ -852,7 +858,7 @@ void WordPerfectCollector::openTable(const WPXPropertyList &propList, const WPXP
for (int i=0; i<pTableStyle->getNumColumns(); i++) for (int i=0; i<pTableStyle->getNumColumns(); i++)
{ {
TagOpenElement *pTableColumnOpenElement = new TagOpenElement("table:table-column"); TagOpenElement *pTableColumnOpenElement = new TagOpenElement("table:table-column");
WPXString sColumnStyleName; _SH_String sColumnStyleName;
sColumnStyleName.sprintf("%s.Column%i", sTableName.cstr(), (i+1)); sColumnStyleName.sprintf("%s.Column%i", sTableName.cstr(), (i+1));
pTableColumnOpenElement->addAttribute("table:style-name", sColumnStyleName.cstr()); pTableColumnOpenElement->addAttribute("table:style-name", sColumnStyleName.cstr());
mpCurrentContentElements->push_back(pTableColumnOpenElement); 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) if (!mWriterDocumentState.mbInNote)
{ {
@ -873,7 +879,7 @@ void WordPerfectCollector::openTableRow(const WPXPropertyList &propList)
mWriterDocumentState.mbHeaderRow = true; mWriterDocumentState.mbHeaderRow = true;
} }
WPXString sTableRowStyleName; _SH_String sTableRowStyleName;
sTableRowStyleName.sprintf("%s.Row%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableRowStyles()); sTableRowStyleName.sprintf("%s.Row%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableRowStyles());
TableRowStyle *pTableRowStyle = new TableRowStyle(propList, sTableRowStyleName.cstr()); TableRowStyle *pTableRowStyle = new TableRowStyle(propList, sTableRowStyleName.cstr());
mpCurrentTableStyle->addTableRowStyle(pTableRowStyle); 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) if (!mWriterDocumentState.mbInNote)
{ {
WPXString sTableCellStyleName; _SH_String sTableCellStyleName;
sTableCellStyleName.sprintf( "%s.Cell%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableCellStyles()); sTableCellStyleName.sprintf( "%s.Cell%i", mpCurrentTableStyle->getName().cstr(), mpCurrentTableStyle->getNumTableCellStyles());
TableCellStyle *pTableCellStyle = new TableCellStyle(propList, sTableCellStyleName.cstr()); TableCellStyle *pTableCellStyle = new TableCellStyle(propList, sTableCellStyleName.cstr());
mpCurrentTableStyle->addTableCellStyle(pTableCellStyle); 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) if (!mWriterDocumentState.mbInNote)
{ {
@ -960,7 +966,7 @@ void WordPerfectCollector::insertLineBreak()
mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:line-break"))); mpCurrentContentElements->push_back(static_cast<DocumentElement *>(new TagCloseElement("text:line-break")));
} }
void WordPerfectCollector::insertText(const WPXString &text) void WordPerfectCollector::insertText(const _SH_String &text)
{ {
DocumentElement *pText = new TextElement(text); DocumentElement *pText = new TextElement(text);
mpCurrentContentElements->push_back(pText); mpCurrentContentElements->push_back(pText);

@ -31,13 +31,12 @@
#ifndef _WORDPERFECTCOLLECTOR_H #ifndef _WORDPERFECTCOLLECTOR_H
#define _WORDPERFECTCOLLECTOR_H #define _WORDPERFECTCOLLECTOR_H
#include "SectionStyle.hxx" #include "SectionStyle.hxx"
#include <config.h> #include <config.h>
#include <libwpd/libwpd.h> #include <libwpd/libwpd.h>
#ifdef HAVE_LIBWPD_090 #include "shared_headers.h"
#define WPXHLListenerImpl WPXDocumentInterface
#endif
#include <vector> #include <vector>
#include <map> #include <map>
#include <stack> #include <stack>
@ -71,156 +70,128 @@ enum WriterListType { unordered, ordered };
struct ltstr 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; return strcmp(s1.cstr(), s2.cstr()) < 0;
} }
}; };
#ifdef HAVE_LIBWPD_090 class WordPerfectCollector : public _SH_DocumentInterface
class WordPerfectCollector : public WPXDocumentInterface
#else // HAVE_LIBWPD_090
class WordPerfectCollector : public WPXHLListenerImpl
#endif // HAVE_LIBWPD_090
{ {
public: public:
WordPerfectCollector(WPXInputStream *pInput, DocumentHandler *pHandler); WordPerfectCollector(_SH_InputStream *pInput, DocumentHandler *pHandler);
virtual ~WordPerfectCollector(); virtual ~WordPerfectCollector();
bool filter(); bool filter();
#ifdef HAVE_LIBWPD_090 virtual void setDocumentMetaData(const _SH_PropertyList &propList) {};
virtual void setDocumentMetaData(const WPXPropertyList &propList) {};
virtual void startDocument(); virtual void startDocument();
virtual void endDocument(); 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 closePageSpan();
virtual void openHeader(const WPXPropertyList &propList); virtual void openHeader(const _SH_PropertyList &propList);
virtual void closeHeader(); virtual void closeHeader();
virtual void openFooter(const WPXPropertyList &propList); virtual void openFooter(const _SH_PropertyList &propList);
virtual void closeFooter(); virtual void closeFooter();
virtual void defineParagraphStyle(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) {}; virtual void openParagraph(const _SH_PropertyList &propList, const _SH_PropertyListVector &tabStops);
virtual void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
virtual void closeParagraph(); virtual void closeParagraph();
virtual void defineCharacterStyle(const WPXPropertyList &propList) {}; virtual void openSpan(const _SH_PropertyList &propList);
virtual void openSpan(const WPXPropertyList &propList);
virtual void closeSpan(); virtual void closeSpan();
virtual void defineSectionStyle(const WPXPropertyList &propList, const WPXPropertyListVector &columns) {}; virtual void openSection(const _SH_PropertyList &propList, const _SH_PropertyListVector &columns);
virtual void openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
virtual void closeSection(); virtual void closeSection();
virtual void insertTab(); virtual void insertTab();
virtual void insertSpace() {}; virtual void insertText(const _SH_String &text);
virtual void insertText(const WPXString &text);
virtual void insertLineBreak(); virtual void insertLineBreak();
virtual void insertField(const WPXString &type, const WPXPropertyList &propList) {}; virtual void defineOrderedListLevel(const _SH_PropertyList &propList);
virtual void defineOrderedListLevel(const WPXPropertyList &propList); virtual void defineUnorderedListLevel(const _SH_PropertyList &propList);
virtual void defineUnorderedListLevel(const WPXPropertyList &propList); virtual void openOrderedListLevel(const _SH_PropertyList &propList);
virtual void openOrderedListLevel(const WPXPropertyList &propList); virtual void openUnorderedListLevel(const _SH_PropertyList &propList);
virtual void openUnorderedListLevel(const WPXPropertyList &propList);
virtual void closeOrderedListLevel(); virtual void closeOrderedListLevel();
virtual void closeUnorderedListLevel(); 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 closeListElement();
virtual void openFootnote(const WPXPropertyList &propList); virtual void openFootnote(const _SH_PropertyList &propList);
virtual void closeFootnote(); virtual void closeFootnote();
virtual void openEndnote(const WPXPropertyList &propList); virtual void openEndnote(const _SH_PropertyList &propList);
virtual void closeEndnote(); virtual void closeEndnote();
virtual void openComment(const WPXPropertyList &propList) {}; virtual void openTable(const _SH_PropertyList &propList, const _SH_PropertyListVector &columns);
virtual void closeComment() {}; virtual void openTableRow(const _SH_PropertyList &propList);
virtual void openTextBox(const WPXPropertyList &propList) {};
virtual void closeTextBox() {};
virtual void openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
virtual void openTableRow(const WPXPropertyList &propList);
virtual void closeTableRow(); virtual void closeTableRow();
virtual void openTableCell(const WPXPropertyList &propList); virtual void openTableCell(const _SH_PropertyList &propList);
virtual void closeTableCell(); virtual void closeTableCell();
virtual void insertCoveredTableCell(const WPXPropertyList &propList); virtual void insertCoveredTableCell(const _SH_PropertyList &propList);
virtual void closeTable(); 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(); #if defined(HAVE_LIBWPD_0100)
virtual void insertText(const WPXString &text); virtual void startDocument(const _SH_PropertyList &propList) {}
virtual void insertLineBreak(); virtual void defineEmbeddedFont(const _SH_PropertyList &propList) {}
virtual void defineParagraphStyle(const _SH_PropertyList &propList) {}
virtual void defineOrderedListLevel(const WPXPropertyList &propList); virtual void openParagraph(const _SH_PropertyList &propList) {}
virtual void defineUnorderedListLevel(const WPXPropertyList &propList); virtual void openLink(const _SH_PropertyList &propList) {}
virtual void openOrderedListLevel(const WPXPropertyList &propList); virtual void closeLink() {}
virtual void openUnorderedListLevel(const WPXPropertyList &propList); virtual void defineSectionStyle(const _SH_PropertyList &propList) {}
virtual void closeOrderedListLevel(); virtual void openSection(const _SH_PropertyList &propList) {}
virtual void closeUnorderedListLevel(); virtual void insertField(const _SH_PropertyList &propList) {}
virtual void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops); virtual void openListElement(const _SH_PropertyList &propList) {}
virtual void closeListElement(); virtual void openTable(const _SH_PropertyList &propList) {}
virtual void insertBinaryObject(const _SH_PropertyList &propList) {}
virtual void openFootnote(const WPXPropertyList &propList); virtual void insertEquation(const _SH_PropertyList &propList) {}
virtual void closeFootnote(); virtual void openGroup(const _SH_PropertyList &propList) {}
virtual void openEndnote(const WPXPropertyList &propList); virtual void closeGroup() {}
virtual void closeEndnote(); virtual void defineGraphicStyle(const _SH_PropertyList &propList) {}
virtual void drawRectangle(const _SH_PropertyList &propList) {}
virtual void openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns); virtual void drawEllipse(const _SH_PropertyList &propList) {}
virtual void openTableRow(const WPXPropertyList &propList); virtual void drawPolygon(const _SH_PropertyList &propList) {}
virtual void closeTableRow(); virtual void drawPolyline(const _SH_PropertyList &propList) {}
virtual void openTableCell(const WPXPropertyList &propList); virtual void drawPath(const _SH_PropertyList &propList) {}
virtual void closeTableCell(); virtual void drawConnector(const _SH_PropertyList &propList) {}
virtual void insertCoveredTableCell(const WPXPropertyList &propList); #endif
virtual void closeTable();
#endif // HAVE_LIBWPD_090
protected: protected:
void _resetDocumentState(); void _resetDocumentState();
bool _parseSourceDocument(WPXInputStream &input); bool _parseSourceDocument(_SH_InputStream &input);
bool _writeTargetDocument(DocumentHandler &xHandler); bool _writeTargetDocument(DocumentHandler &xHandler);
void _writeBegin(); void _writeBegin();
void _writeDefaultStyles(DocumentHandler &xHandler); void _writeDefaultStyles(DocumentHandler &xHandler);
void _writeMasterPages(DocumentHandler &xHandler); void _writeMasterPages(DocumentHandler &xHandler);
void _writePageMasters(DocumentHandler &xHandler); void _writePageMasters(DocumentHandler &xHandler);
void _allocateFontName(const WPXString &); void _allocateFontName(const _SH_String &);
private: private:
void _openListLevel(TagOpenElement *pListLevelOpenElement); void _openListLevel(TagOpenElement *pListLevelOpenElement);
void _closeListLevel(const char *szListType); void _closeListLevel(const char *szListType);
WPXInputStream *mpInput; _SH_InputStream *mpInput;
DocumentHandler *mpHandler; DocumentHandler *mpHandler;
bool mbUsed; // whether or not it has been before (you can only use me once!) bool mbUsed; // whether or not it has been before (you can only use me once!)
WriterDocumentState mWriterDocumentState; WriterDocumentState mWriterDocumentState;
// paragraph styles // paragraph styles
std::map<WPXString, ParagraphStyle *, ltstr> mTextStyleHash; std::map<_SH_String, ParagraphStyle *, ltstr> mTextStyleHash;
// span styles // span styles
std::map<WPXString, SpanStyle *, ltstr> mSpanStyleHash; std::map<_SH_String, SpanStyle *, ltstr> mSpanStyleHash;
// font styles // font styles
std::map<WPXString, FontStyle *, ltstr> mFontHash; std::map<_SH_String, FontStyle *, ltstr> mFontHash;
// section styles // section styles
std::vector<SectionStyle *> mSectionStyles; std::vector<SectionStyle *> mSectionStyles;

@ -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 <config.h>
#ifdef HAVE_LIBWPD_0100
//libwpd-0.10
#include <librevenge/RVNGBinaryData.h>
#include <librevenge-stream/librevenge-stream.h>
#include <librevenge/RVNGPropertyList.h>
#include <librevenge/RVNGPropertyListVector.h>
#include <librevenge/RVNGString.h>
#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 <libwpd/WPXPropertyList.h>
#include <libwpd/WPXPropertyListVector.h>
#include <libwpd/WPXString.h>
#ifdef HAVE_LIBWPD_090
#include <libwpd/WPXBinaryData.h>
#include <libwpd-stream/libwpd-stream.h>
#else
#include <libwpd/WPXStream.h>
#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

@ -35,53 +35,67 @@ typedef KGenericFactory<WPImport, KoFilter> WPImportFactory;
K_EXPORT_COMPONENT_FACTORY( libwpimport, WPImportFactory( "kofficefilters" ) ) K_EXPORT_COMPONENT_FACTORY( libwpimport, WPImportFactory( "kofficefilters" ) )
#include <libwpd/libwpd.h> #include <libwpd/libwpd.h>
#ifdef HAVE_LIBWPD_090
#include <libwpd-stream/libwpd-stream.h>
#define uint8_t uchar
#else
#include <libwpd/WPXStream.h>
#endif
#include "DocumentHandler.hxx" #include "DocumentHandler.hxx"
#include "WordPerfectCollector.hxx" #include "WordPerfectCollector.hxx"
#ifdef HAVE_LIBWPD_090 class _SH_MemoryInputStream : public _SH_InputStream
class WPXMemoryInputStream : public WPXInputStream
{ {
public: public:
WPXMemoryInputStream(unsigned char *data, unsigned long size); _SH_MemoryInputStream(unsigned char *data, unsigned long size);
virtual ~WPXMemoryInputStream(); virtual ~_SH_MemoryInputStream();
virtual bool isOLEStream() {
return false;
}
virtual WPXInputStream * getDocumentOLEStream(const char *name) {
return NULL;
}
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); 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 long tell();
virtual bool atEOS(); 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: private:
long m_offset; long m_offset;
size_t m_size; size_t m_size;
unsigned char *m_data; unsigned char *m_data;
}; };
WPXMemoryInputStream::WPXMemoryInputStream(unsigned char *data, unsigned long size) : _SH_MemoryInputStream::_SH_MemoryInputStream(unsigned char *data, unsigned long size) :
WPXInputStream(), #if defined(HAVE_LIBWPD_090) || defined(HAVE_LIBWPD_0100)
_SH_InputStream(),
#else
_SH_InputStream(false),
#endif
m_offset(0), m_offset(0),
m_size(size), m_size(size),
m_data(data) 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; numBytesRead = 0;
@ -106,11 +120,11 @@ const unsigned char * WPXMemoryInputStream::read(unsigned long numBytes, unsigne
return &m_data[oldOffset]; 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; m_offset += offset;
else if (seekType == WPX_SEEK_SET) else if (seekType == _SH_SEEK_SET)
m_offset = offset; m_offset = offset;
if (m_offset < 0) if (m_offset < 0)
@ -127,12 +141,12 @@ int WPXMemoryInputStream::seek(long offset, WPX_SEEK_TYPE seekType)
return 0; return 0;
} }
long WPXMemoryInputStream::tell() long _SH_MemoryInputStream::tell()
{ {
return m_offset; return m_offset;
} }
bool WPXMemoryInputStream::atEOS() bool _SH_MemoryInputStream::atEOS()
{ {
if ((long)m_offset == (long)m_size) if ((long)m_offset == (long)m_size)
return true; return true;
@ -140,104 +154,6 @@ bool WPXMemoryInputStream::atEOS()
return false; 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<numBytesToRead; i++)
{
m_tmpBuf[i] = m_data[m_offset];
m_offset++;
}
return m_tmpBuf;
}
int WPXMemoryInputStream::seek(long offset, WPX_SEEK_TYPE seekType)
{
if (seekType == WPX_SEEK_CUR)
m_offset += offset;
else if (seekType == WPX_SEEK_SET)
m_offset = offset;
if (m_offset < 0)
m_offset = 0;
else if (m_offset >= 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 class KWordHandler : public DocumentHandler
{ {
public: public:
@ -245,13 +161,13 @@ public:
virtual ~KWordHandler() {}; virtual ~KWordHandler() {};
void startDocument(); void startDocument();
void endDocument(); 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 endElement(const char *psName);
void characters(const WPXString &sCharacters); void characters(const _SH_String &sCharacters);
WPXString documentstring; _SH_String documentstring;
private: private:
bool isTagOpened; bool isTagOpened;
WPXString openedTagName; _SH_String openedTagName;
}; };
KWordHandler::KWordHandler() : KWordHandler::KWordHandler() :
@ -264,17 +180,17 @@ void KWordHandler::startDocument()
documentstring.clear(); documentstring.clear();
} }
void KWordHandler::startElement(const char *psName, const WPXPropertyList &xPropList) void KWordHandler::startElement(const char *psName, const _SH_PropertyList &xPropList)
{ {
if (isTagOpened) if (isTagOpened)
{ {
documentstring.append( ">" ); documentstring.append( ">" );
isTagOpened = false; isTagOpened = false;
} }
WPXString tempString; _SH_String tempString;
tempString.sprintf("<%s", psName); tempString.sprintf("<%s", psName);
documentstring.append( tempString ); documentstring.append( tempString );
WPXPropertyList::Iter i(xPropList); _SH_PropertyList::Iter i(xPropList);
for (i.rewind(); i.next(); ) for (i.rewind(); i.next(); )
{ {
// filter out libwpd elements // filter out libwpd elements
@ -294,21 +210,25 @@ void KWordHandler::endElement(const char *psName)
documentstring.append( " />" ); documentstring.append( " />" );
else else
{ {
WPXString tempString; _SH_String tempString;
tempString.sprintf("</%s>", psName); tempString.sprintf("</%s>", psName);
documentstring.append( tempString ); documentstring.append( tempString );
} }
isTagOpened = false; isTagOpened = false;
} }
void KWordHandler::characters(const WPXString &sCharacters) void KWordHandler::characters(const _SH_String &sCharacters)
{ {
if (isTagOpened) if (isTagOpened)
{ {
documentstring.append( ">" ); documentstring.append( ">" );
isTagOpened = false; 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 ); fclose( f );
// instream now owns buf, no need to delete buf later // 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); WPDConfidence confidence = WPDocument::isFileFormatSupported(&instream);
#else // HAVE_LIBWPD_090 #else
WPDConfidence confidence = WPDocument::isFileFormatSupported(&instream, false); 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 ) if( confidence == WPD_CONFIDENCE_NONE )
#endif
{ {
fprintf(stderr, "ERROR: We have no confidence that you are giving us a valid WordPerfect document.\n"); fprintf(stderr, "ERROR: We have no confidence that you are giving us a valid WordPerfect document.\n");
return KoFilter::StupidError; return KoFilter::StupidError;
} }
instream.seek(0, WPX_SEEK_SET); instream.seek(0, _SH_SEEK_SET);
// open and parse the file // open and parse the file
KWordHandler handler; KWordHandler handler;

Loading…
Cancel
Save