summaryrefslogtreecommitdiffstats
path: root/filters/kword
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-04-05 15:17:32 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-04-05 15:18:32 -0500
commitefca1544fd2475b9f1198e793dde8da1a39de4e2 (patch)
tree366f9b3169fac415f67d699a6e6a6ca0672ea45c /filters/kword
parent64ee8a777ccaee333996bd6f8f70ac094edb4e7b (diff)
downloadkoffice-efca1544fd2475b9f1198e793dde8da1a39de4e2.tar.gz
koffice-efca1544fd2475b9f1198e793dde8da1a39de4e2.zip
Fix FTBFS with libwpd 0.9 and above
This resolves Bug 1169 Remove spurious build files
Diffstat (limited to 'filters/kword')
-rw-r--r--filters/kword/wordperfect/configure.in.in2
-rw-r--r--filters/kword/wordperfect/import/WordPerfectCollector.hxx61
-rw-r--r--filters/kword/wordperfect/import/wpimport.cc104
3 files changed, 165 insertions, 2 deletions
diff --git a/filters/kword/wordperfect/configure.in.in b/filters/kword/wordperfect/configure.in.in
index a4919660..d3b83532 100644
--- a/filters/kword/wordperfect/configure.in.in
+++ b/filters/kword/wordperfect/configure.in.in
@@ -41,8 +41,6 @@ if test -z "$LIBWPD_LIBS"; then
AC_DEFINE_UNQUOTED(HAVE_WPD, 1, [Defines if your system has the libwpd library])
AC_DEFINE_UNQUOTED(HAVE_LIBWPD_090, 1, [Defines if your system has libpwd greater than or equal to v0.9.0])
-
- AC_MSG_ERROR([[libwpd >= 0.9.0 is not yet supported!]])
fi
fi
fi
diff --git a/filters/kword/wordperfect/import/WordPerfectCollector.hxx b/filters/kword/wordperfect/import/WordPerfectCollector.hxx
index d593224a..fa3ec722 100644
--- a/filters/kword/wordperfect/import/WordPerfectCollector.hxx
+++ b/filters/kword/wordperfect/import/WordPerfectCollector.hxx
@@ -77,13 +77,72 @@ struct ltstr
}
};
+#ifdef HAVE_LIBWPD_090
+class WordPerfectCollector : public WPXDocumentInterface
+#else // HAVE_LIBWPD_090
class WordPerfectCollector : public WPXHLListenerImpl
+#endif HAVE_LIBWPD_090
{
public:
WordPerfectCollector(WPXInputStream *pInput, DocumentHandler *pHandler);
virtual ~WordPerfectCollector();
bool filter();
+#ifdef HAVE_LIBWPD_090
+ virtual void setDocumentMetaData(const WPXPropertyList &propList) {};
+ virtual void startDocument();
+ virtual void endDocument();
+ virtual void definePageStyle(const WPXPropertyList &propList) {};
+ virtual void openPageSpan(const WPXPropertyList &propList) {};
+ virtual void closePageSpan() {};
+ virtual void openHeader(const WPXPropertyList &propList) {};
+ virtual void closeHeader() {};
+ virtual void openFooter(const WPXPropertyList &propList) {};
+ virtual void closeFooter() {};
+ virtual void defineParagraphStyle(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) {};
+ virtual void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
+ virtual void closeParagraph();
+ virtual void defineCharacterStyle(const WPXPropertyList &propList) {};
+ virtual void openSpan(const WPXPropertyList &propList);
+ virtual void closeSpan();
+ virtual void defineSectionStyle(const WPXPropertyList &propList, const WPXPropertyListVector &columns) {};
+ virtual void openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns) {};
+ virtual void closeSection() {};
+ virtual void insertTab();
+ virtual void insertSpace() {};
+ virtual void insertText(const WPXString &text);
+ virtual void insertLineBreak();
+ virtual void insertField(const WPXString &type, const WPXPropertyList &propList) {};
+ virtual void defineOrderedListLevel(const WPXPropertyList &propList) {};
+ virtual void defineUnorderedListLevel(const WPXPropertyList &propList) {};
+ virtual void openOrderedListLevel(const WPXPropertyList &propList) {};
+ virtual void openUnorderedListLevel(const WPXPropertyList &propList) {};
+ virtual void closeOrderedListLevel() {};
+ virtual void closeUnorderedListLevel() {};
+ virtual void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) {};
+ virtual void closeListElement() {};
+ virtual void openFootnote(const WPXPropertyList &propList) {};
+ virtual void closeFootnote() {};
+ virtual void openEndnote(const WPXPropertyList &propList) {};
+ virtual void closeEndnote() {};
+ virtual void openComment(const WPXPropertyList &propList) {};
+ virtual void closeComment() {};
+ virtual void openTextBox(const WPXPropertyList &propList) {};
+ virtual void closeTextBox() {};
+ virtual void openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns) {};
+ virtual void openTableRow(const WPXPropertyList &propList) {};
+ virtual void closeTableRow() {};
+ virtual void openTableCell(const WPXPropertyList &propList) {};
+ virtual void closeTableCell() {};
+ virtual void insertCoveredTableCell(const WPXPropertyList &propList) {};
+ virtual void closeTable() {};
+ virtual void openFrame(const WPXPropertyList &propList) {};
+ virtual void closeFrame() {};
+ virtual void insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData &data) {};
+ virtual void insertEquation(const WPXPropertyList &propList, const WPXString &data) {};
+
+#else // HAVE_LIBWPD_090
+
virtual void setDocumentMetaData(const WPXPropertyList &propList) {}
virtual void startDocument() {}
virtual void endDocument() {}
@@ -132,6 +191,8 @@ public:
virtual void insertCoveredTableCell(const WPXPropertyList &propList);
virtual void closeTable();
+#endif // HAVE_LIBWPD_090
+
protected:
void _resetDocumentState();
bool _parseSourceDocument(WPXInputStream &input);
diff --git a/filters/kword/wordperfect/import/wpimport.cc b/filters/kword/wordperfect/import/wpimport.cc
index 09fc4d5c..5ff786c1 100644
--- a/filters/kword/wordperfect/import/wpimport.cc
+++ b/filters/kword/wordperfect/import/wpimport.cc
@@ -44,6 +44,104 @@ K_EXPORT_COMPONENT_FACTORY( libwpimport, WPImportFactory( "kofficefilters" ) )
#include "DocumentHandler.hxx"
#include "WordPerfectCollector.hxx"
+#ifdef HAVE_LIBWPD_090
+class WPXMemoryInputStream : public WPXInputStream
+{
+public:
+ WPXMemoryInputStream(unsigned char *data, unsigned long size);
+ virtual ~WPXMemoryInputStream();
+
+ virtual bool isOLEStream() {
+ return false;
+ }
+ virtual WPXInputStream * getDocumentOLEStream(const char *name) {
+ return NULL;
+ }
+
+ const virtual unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead);
+ virtual int seek(long offset, WPX_SEEK_TYPE seekType);
+ virtual long tell();
+ virtual bool atEOS();
+
+private:
+ long m_offset;
+ size_t m_size;
+ unsigned char *m_data;
+};
+
+WPXMemoryInputStream::WPXMemoryInputStream(unsigned char *data, unsigned long size) :
+ WPXInputStream(),
+ m_offset(0),
+ m_size(size),
+ m_data(data)
+{
+}
+
+WPXMemoryInputStream::~WPXMemoryInputStream()
+{
+}
+
+const unsigned char * WPXMemoryInputStream::read(unsigned long numBytes, unsigned long &numBytesRead)
+{
+ numBytesRead = 0;
+
+ if (numBytes == 0)
+ return 0;
+
+ 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 0;
+
+ long oldOffset = m_offset;
+ m_offset += numBytesToRead;
+
+ return &m_data[oldOffset];
+}
+
+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;
+ return 1;
+ }
+ if ((long)m_offset > (long)m_size)
+ {
+ m_offset = m_size;
+ return 1;
+ }
+
+ return 0;
+}
+
+long WPXMemoryInputStream::tell()
+{
+ return m_offset;
+}
+
+bool WPXMemoryInputStream::atEOS()
+{
+ if ((long)m_offset == (long)m_size)
+ return true;
+
+ return false;
+}
+
+#else // HAVE_LIBWPD_090
+
class WPXMemoryInputStream : public WPXInputStream
{
public:
@@ -138,6 +236,8 @@ bool WPXMemoryInputStream::atEOS()
return false;
}
+#endif // HAVE_LIBWPD_090
+
class KWordHandler : public DocumentHandler
{
public:
@@ -250,7 +350,11 @@ KoFilter::ConversionStatus WPImport::convert( const TQCString& from, const TQCSt
// instream now owns buf, no need to delete buf later
WPXMemoryInputStream instream = WPXMemoryInputStream( buf, fsize );
+#ifdef HAVE_LIBWPD_090
+ WPDConfidence confidence = WPDocument::isFileFormatSupported(&instream);
+#else // HAVE_LIBWPD_090
WPDConfidence confidence = WPDocument::isFileFormatSupported(&instream, false);
+#endif // HAVE_LIBWPD_090
if( confidence == WPD_CONFIDENCE_NONE )
{
fprintf(stderr, "ERROR: We have no confidence that you are giving us a valid WordPerfect document.\n");