summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2013-06-23 22:59:48 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2013-06-23 22:59:48 +0200
commit79ed95777a2e407e172788366cd886f9fba60a32 (patch)
tree95a536936eab9828a65cce8d326ebf7a5adf725b /src
Intial skeleton of libsdw
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/conv/Makefile.am1
-rw-r--r--src/conv/html/HtmlDocumentGenerator.cpp462
-rw-r--r--src/conv/html/HtmlDocumentGenerator.h109
-rw-r--r--src/conv/html/Makefile.am40
-rw-r--r--src/conv/html/sdw2html.cpp117
-rw-r--r--src/conv/html/sdw2html.rc.in31
-rw-r--r--src/conv/raw/Makefile.am41
-rw-r--r--src/conv/raw/RawDocumentGenerator.cpp428
-rw-r--r--src/conv/raw/RawDocumentGenerator.h145
-rw-r--r--src/conv/raw/sdw2raw.cpp120
-rw-r--r--src/conv/raw/sdw2raw.rc.in31
-rw-r--r--src/conv/text/Makefile.am41
-rw-r--r--src/conv/text/TextDocumentGenerator.cpp82
-rw-r--r--src/conv/text/TextDocumentGenerator.h101
-rw-r--r--src/conv/text/sdw2text.cpp120
-rw-r--r--src/conv/text/sdw2text.rc.in31
-rw-r--r--src/lib/Makefile.am40
-rw-r--r--src/lib/SDWDocument.cpp103
-rw-r--r--src/lib/SDWHeader.cpp50
-rw-r--r--src/lib/SDWHeader.h85
-rw-r--r--src/lib/SDWParser.cpp38
-rw-r--r--src/lib/SDWParser.h68
-rw-r--r--src/lib/libsdw.rc.in31
-rw-r--r--src/lib/libsdw_internal.cpp88
-rw-r--r--src/lib/libsdw_internal.h119
26 files changed, 2523 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..4796627
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = lib conv
diff --git a/src/conv/Makefile.am b/src/conv/Makefile.am
new file mode 100644
index 0000000..6f3276d
--- /dev/null
+++ b/src/conv/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = raw html text
diff --git a/src/conv/html/HtmlDocumentGenerator.cpp b/src/conv/html/HtmlDocumentGenerator.cpp
new file mode 100644
index 0000000..6f07ce4
--- /dev/null
+++ b/src/conv/html/HtmlDocumentGenerator.cpp
@@ -0,0 +1,462 @@
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002-2004 William Lachance (wrlach@gmail.com)
+ * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
+ * Copyright (C) 2004 Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#include <stdio.h>
+#include <iostream>
+#include "HtmlDocumentGenerator.h"
+
+// use the BELL code to represent a TAB for now
+#define UCS_TAB 0x0009
+
+HtmlDocumentGenerator::HtmlDocumentGenerator() :
+ m_ignore(false),
+ m_pOutputStream(&std::cout),
+ m_footNotesStream(),
+ m_endNotesStream(),
+ m_commentsStream(),
+ m_textBoxesStream(),
+ m_dummyStream(),
+ m_footNotesCount(0),
+ m_endNotesCount(0),
+ m_commentsCount(0),
+ m_textBoxesCount(0),
+ m_commentNumber(1),
+ m_textBoxNumber(1)
+{
+}
+
+HtmlDocumentGenerator::~HtmlDocumentGenerator()
+{
+}
+
+void HtmlDocumentGenerator::setDocumentMetaData(const WPXPropertyList &propList)
+{
+ if (propList["author"])
+ *m_pOutputStream << "<meta name=\"author\" content=\"" << propList["author"]->getStr().cstr() << "\">" << std::endl;
+ if (propList["subject"])
+ *m_pOutputStream << "<meta name=\"subject\" content=\"" << propList["subject"]->getStr().cstr() << "\">" << std::endl;
+ if (propList["publisher"])
+ *m_pOutputStream << "<meta name=\"publisher\" content=\"" << propList["publisher"]->getStr().cstr() << "\">" << std::endl;
+ if (propList["keywords"])
+ *m_pOutputStream << "<meta name=\"keywords\" content=\"" << propList["keywords"]->getStr().cstr() << "\">" << std::endl;
+ if (propList["language"])
+ *m_pOutputStream << "<meta name=\"language\" content=\"" << propList["language"]->getStr().cstr() << "\">" << std::endl;
+ if (propList["abstract"])
+ *m_pOutputStream << "<meta name=\"abstract\" content=\"" << propList["abstract"]->getStr().cstr() << "\">" << std::endl;
+ if (propList["descriptive-name"])
+ *m_pOutputStream << "<meta name=\"descriptive-name\" content=\"" << propList["descriptive-name"]->getStr().cstr() << "\">" << std::endl;
+ if (propList["descriptive-type"])
+ *m_pOutputStream << "<meta name=\"descriptive-type\" content=\"" << propList["descriptive-type"]->getStr().cstr() << "\">" << std::endl;
+}
+
+void HtmlDocumentGenerator::startDocument()
+{
+ *m_pOutputStream << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">" << std::endl;
+ *m_pOutputStream << "<html>" << std::endl;
+ *m_pOutputStream << "<head>" << std::endl;
+ *m_pOutputStream << "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" >" << std::endl;
+ *m_pOutputStream << "</head>" << std::endl;
+ *m_pOutputStream << "<body>" << std::endl;
+}
+
+void HtmlDocumentGenerator::endDocument()
+{
+ if (m_footNotesStream.str().length())
+ {
+ *m_pOutputStream << "<p><b>FOOTNOTES</b></p>" << std::endl;
+ *m_pOutputStream << m_footNotesStream.str() << std::endl;
+ }
+ if (m_endNotesStream.str().length())
+ {
+ *m_pOutputStream << "<p><b>ENDNOTES</b></p>" << std::endl;
+ *m_pOutputStream << m_endNotesStream.str() << std::endl;
+ }
+ if (m_commentsStream.str().length())
+ {
+ *m_pOutputStream << "<p><b>COMMENTS AND ANNOTATIONS</b></p>" << std::endl;
+ *m_pOutputStream << m_commentsStream.str() << std::endl;
+ }
+ if (m_textBoxesStream.str().length())
+ {
+ *m_pOutputStream << "<p><b>TEXT BOXES</b></p>" << std::endl;
+ *m_pOutputStream << m_textBoxesStream.str() << std::endl;
+ }
+ *m_pOutputStream << "</body>" << std::endl;
+ *m_pOutputStream << "</html>" << std::endl;
+}
+
+void HtmlDocumentGenerator::openHeader(const WPXPropertyList & /* propList */)
+{
+ m_ignore = true;
+}
+
+void HtmlDocumentGenerator::closeHeader()
+{
+ m_ignore = false;
+}
+
+
+void HtmlDocumentGenerator::openFooter(const WPXPropertyList & /* propList */)
+{
+ m_ignore = true;
+}
+
+void HtmlDocumentGenerator::closeFooter()
+{
+ m_ignore = false;
+}
+
+void HtmlDocumentGenerator::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector & /* tabStops */)
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "<p style=\"";
+
+ if (propList["fo:text-align"])
+ {
+
+ if (propList["fo:text-align"]->getStr() == WPXString("end")) // stupid OOo convention..
+ *m_pOutputStream << "text-align:right;";
+ else
+ *m_pOutputStream << "text-align:" << propList["fo:text-align"]->getStr().cstr() << ";";
+ }
+ if (propList["fo:text-indent"])
+ *m_pOutputStream << "text-indent:" << propList["fo:text-indent"]->getStr().cstr() << ";";
+
+ if (propList["fo:line-height"] &&
+ (propList["fo:line-height"]->getDouble() < 1.0 || propList["fo:line-height"]->getDouble() > 1.0))
+ *m_pOutputStream << "line-height:" << propList["fo:line-height"]->getStr().cstr() << ";";
+ *m_pOutputStream << "\">";
+ }
+}
+
+void HtmlDocumentGenerator::closeParagraph()
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "</p>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::openSpan(const WPXPropertyList &propList)
+{
+ if (!m_ignore)
+ {
+
+ *m_pOutputStream << "<span style=\"";
+ if (propList["style:font-name"])
+ *m_pOutputStream << "font-family: \'" << propList["style:font-name"]->getStr().cstr() << "\';";
+ if (propList["fo:font-size"])
+ *m_pOutputStream << "font-size: " << propList["fo:font-size"]->getStr().cstr() << ";";
+ if (propList["fo:font-weight"])
+ *m_pOutputStream << "font-weight: " << propList["fo:font-weight"]->getStr().cstr() << ";";
+ if (propList["fo:font-style"])
+ *m_pOutputStream << "font-style: " << propList["fo:font-style"]->getStr().cstr() << ";";
+ if (propList["style:text-crossing-out"] && propList["style:text-crossing-out"]->getStr() == WPXString("single-line"))
+ *m_pOutputStream << "text-decoration:line-through;";
+ if (propList["style:text-underline"]) // don't know if double underline is possible
+ *m_pOutputStream << "text-decoration:underline;";
+ if (propList["style:text-blinking"])
+ *m_pOutputStream << "text-decoration:blink;";
+ if (propList["fo:color"])
+ *m_pOutputStream << "color:" << propList["fo:color"]->getStr().cstr() << ";";
+ if (propList["style:text-background-color"])
+ *m_pOutputStream << "background-color:" << propList["style:text-background-color"]->getStr().cstr() << ";";
+
+ *m_pOutputStream << "\">";
+ }
+}
+
+void HtmlDocumentGenerator::closeSpan()
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "</span>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::insertTab()
+{
+ if (!m_ignore)
+ {
+ // Does not have a lot of effect since tabs in html are ignorable white-space
+ *m_pOutputStream << "\t";
+ }
+}
+
+void HtmlDocumentGenerator::insertLineBreak()
+{
+ if (!m_ignore)
+ {
+
+ *m_pOutputStream << "<br>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::insertText(const WPXString &text)
+{
+ if (!m_ignore)
+ {
+
+ WPXString tempUTF8(text, true);
+ *m_pOutputStream << tempUTF8.cstr();
+ }
+}
+
+void HtmlDocumentGenerator::insertSpace()
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "&nbsp;";
+ }
+}
+
+void HtmlDocumentGenerator::openOrderedListLevel(const WPXPropertyList & /* propList */)
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "<ol>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::closeOrderedListLevel()
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "</ol>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::openUnorderedListLevel(const WPXPropertyList & /* propList */)
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "<ul>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::closeUnorderedListLevel()
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "</ul>" << std::endl;
+ }
+}
+
+
+void HtmlDocumentGenerator::openListElement(const WPXPropertyList & /* propList */, const WPXPropertyListVector &/* tabStops */)
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "<li>";
+ }
+}
+
+void HtmlDocumentGenerator::closeListElement()
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "</li>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::openFootnote(const WPXPropertyList &propList)
+{
+ if (!m_ignore)
+ {
+ if (!m_footNotesCount++)
+ {
+ if (propList["libwpd:number"])
+ *m_pOutputStream << "<sup>(footnote: " << propList["libwpd:number"]->getStr().cstr() << ")</sup>";
+ m_pOutputStream = &m_footNotesStream;
+ // Cheesey hack..
+ if (propList["libwpd:number"])
+ *m_pOutputStream << "<p>" << propList["libwpd:number"]->getStr().cstr() << ":</p>";
+ else
+ *m_pOutputStream << "<p/>";
+ }
+ else
+ m_pOutputStream = &m_dummyStream;
+ }
+}
+
+void HtmlDocumentGenerator::closeFootnote()
+{
+ if (!m_ignore)
+ {
+ if (!(--m_footNotesCount))
+ {
+ *m_pOutputStream << "<p/>" << std::endl;
+ m_pOutputStream = &std::cout;
+ }
+ }
+}
+
+void HtmlDocumentGenerator::openEndnote(const WPXPropertyList &propList)
+{
+ if (!m_ignore)
+ {
+ if (!m_endNotesCount++)
+ {
+ if (propList["libwpd:number"])
+ *m_pOutputStream << "<sup>(endnote: " << propList["libwpd:number"]->getStr().cstr() << ")</sup>";
+ m_pOutputStream = &m_footNotesStream;
+ // Cheesey hack..
+ if (propList["libwpd:number"])
+ *m_pOutputStream << "<p>" << propList["libwpd:number"]->getStr().cstr() << ":</p>";
+ else
+ *m_pOutputStream << "<p/>";
+ }
+ else
+ m_pOutputStream = &m_dummyStream;
+ }
+}
+
+void HtmlDocumentGenerator::closeEndnote()
+{
+ if (!m_ignore)
+ {
+ if (!(--m_endNotesCount))
+ {
+ *m_pOutputStream << "<p/>" << std::endl;
+ m_pOutputStream = &std::cout;
+ }
+ }
+}
+
+void HtmlDocumentGenerator::openComment(const WPXPropertyList & /*propList*/)
+{
+ if (!m_ignore)
+ {
+ if (!m_commentsCount++)
+ {
+ *m_pOutputStream << "<sup>(comment: " << m_commentNumber << ")</sup>";
+ m_pOutputStream = &m_commentsStream;
+ *m_pOutputStream << "<p>Comment " << m_commentNumber++ << ":</p>" << std::endl;
+ *m_pOutputStream << "<p/>";
+ }
+ else
+ m_pOutputStream = &m_dummyStream;
+ }
+}
+
+void HtmlDocumentGenerator::closeComment()
+{
+ if (!m_ignore)
+ {
+ if (!(--m_commentsCount))
+ {
+ *m_pOutputStream << "<p/>" << std::endl;
+ m_pOutputStream = &std::cout;
+ }
+ }
+}
+
+void HtmlDocumentGenerator::openTextBox(const WPXPropertyList & /*propList*/)
+{
+ if (!m_ignore)
+ {
+ if (!(m_textBoxesCount++)) // Osnola: fixes increments textBoxesCount
+ {
+ *m_pOutputStream << "<sup>(text box: " << m_textBoxNumber << ")</sup>";
+ m_pOutputStream = &m_commentsStream;
+ *m_pOutputStream << "<p>Text Box " << m_textBoxNumber++ << ":</p>" << std::endl;
+ m_pOutputStream = &m_textBoxesStream;
+ *m_pOutputStream << "<p/>";
+ }
+ else
+ m_pOutputStream = &m_dummyStream;
+ }
+}
+
+void HtmlDocumentGenerator::closeTextBox()
+{
+ if (!m_ignore)
+ {
+ if (!(--m_textBoxesCount))
+ {
+ *m_pOutputStream << "<p/>" << std::endl;
+ m_pOutputStream = &std::cout;
+ }
+ }
+}
+
+void HtmlDocumentGenerator::openTable(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* columns */)
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "<table border=\"1\">" << std::endl;
+ *m_pOutputStream << "<tbody>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::openTableRow(const WPXPropertyList & /* propList */)
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "<tr>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::closeTableRow()
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "</tr>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::openTableCell(const WPXPropertyList &propList)
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "<td style=\"";
+ if (propList["fo:background-color"])
+ *m_pOutputStream << "background-color:" << propList["fo:background-color"]->getStr().cstr() << ";";
+
+ *m_pOutputStream << "\" ";
+
+ if (propList["table:number-columns-spanned"])
+ *m_pOutputStream << "colspan=\"" << propList["table:number-columns-spanned"]->getInt() << "\" ";
+ if (propList["table:number-rows-spanned"])
+ *m_pOutputStream << "rowspan=\"" << propList["table:number-rows-spanned"]->getInt() << "\" ";
+
+ *m_pOutputStream << ">" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::closeTableCell()
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "</td>" << std::endl;
+ }
+}
+
+void HtmlDocumentGenerator::closeTable()
+{
+ if (!m_ignore)
+ {
+ *m_pOutputStream << "</tbody>" << std::endl;
+ *m_pOutputStream << "</table>" << std::endl;
+ }
+}
diff --git a/src/conv/html/HtmlDocumentGenerator.h b/src/conv/html/HtmlDocumentGenerator.h
new file mode 100644
index 0000000..0fa2b5c
--- /dev/null
+++ b/src/conv/html/HtmlDocumentGenerator.h
@@ -0,0 +1,109 @@
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002-2005 William Lachance (wrlach@gmail.com)
+ * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#ifndef HTMLLISTENERIMPL_H
+#define HTMLLISTENERIMPL_H
+
+#include <ostream>
+#include <sstream>
+#include <libwpd/libwpd.h>
+
+class HtmlDocumentGenerator : public WPXDocumentInterface
+{
+public:
+ HtmlDocumentGenerator();
+ virtual ~HtmlDocumentGenerator();
+
+ virtual void setDocumentMetaData(const WPXPropertyList &propList);
+
+ virtual void startDocument();
+ virtual void endDocument();
+
+ virtual void definePageStyle(const WPXPropertyList &) {}
+ virtual void openPageSpan(const WPXPropertyList & /* propList */) {}
+ virtual void closePageSpan() {}
+ virtual void openHeader(const WPXPropertyList &propList);
+ virtual void closeHeader();
+ virtual void openFooter(const WPXPropertyList &propList);
+ virtual void closeFooter();
+
+ virtual void defineSectionStyle(const WPXPropertyList &, const WPXPropertyListVector &) {}
+ virtual void openSection(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* columns */) {}
+ virtual void closeSection() {}
+
+ virtual void defineParagraphStyle(const WPXPropertyList &, const WPXPropertyListVector &) {}
+ virtual void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
+ virtual void closeParagraph();
+
+ virtual void defineCharacterStyle(const WPXPropertyList &) {}
+ virtual void openSpan(const WPXPropertyList &propList);
+ virtual void closeSpan();
+
+ virtual void insertTab();
+ virtual void insertText(const WPXString &text);
+ virtual void insertSpace();
+ 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 */) {}
+
+private:
+ bool m_ignore;
+ std::ostream *m_pOutputStream;
+ std::ostringstream m_footNotesStream, m_endNotesStream, m_commentsStream, m_textBoxesStream, m_dummyStream;
+ unsigned m_footNotesCount, m_endNotesCount, m_commentsCount, m_textBoxesCount;
+ unsigned m_commentNumber, m_textBoxNumber;
+ // Unimplemented to prevent compiler from creating crasher ones
+ HtmlDocumentGenerator(const HtmlDocumentGenerator &);
+ HtmlDocumentGenerator &operator=(const HtmlDocumentGenerator &);
+};
+
+#endif /* HTMLLISTENERIMPL_H */
diff --git a/src/conv/html/Makefile.am b/src/conv/html/Makefile.am
new file mode 100644
index 0000000..7d1926b
--- /dev/null
+++ b/src/conv/html/Makefile.am
@@ -0,0 +1,40 @@
+bin_PROGRAMS = sdw2html
+
+AM_CXXFLAGS = -I$(top_srcdir)/inc $(WPD_CFLAGS) $(DEBUG_CXXFLAGS)
+
+sdw2html_DEPENDENCIES = @SDW2HTML_WIN32_RESOURCE@
+
+if STATIC_TOOLS
+
+sdw2html_LDADD = \
+ ../../lib/@SDW_OBJDIR@/libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.a \
+ $(WPD_LIBS) @SDW2HTML_WIN32_RESOURCE@
+sdw2html_LDFLAGS = -all-static
+
+else
+
+sdw2html_LDADD = \
+ ../../lib/libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.la \
+ $(WPD_LIBS) @SDW2HTML_WIN32_RESOURCE@
+
+endif
+
+sdw2html_SOURCES = \
+ HtmlDocumentGenerator.cpp \
+ HtmlDocumentGenerator.h \
+ sdw2html.cpp
+
+if OS_WIN32
+
+@SDW2HTML_WIN32_RESOURCE@ : sdw2html.rc $(sdw2html_OBJECTS)
+ chmod +x $(top_srcdir)/build/win32/*compile-resource
+ WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource sdw2html.rc @SDW2HTML_WIN32_RESOURCE@
+endif
+
+EXTRA_DIST = \
+ sdw2html.rc.in
+
+# These may be in the builddir too
+BUILD_EXTRA_DIST = \
+ sdw2html.rc
+
diff --git a/src/conv/html/sdw2html.cpp b/src/conv/html/sdw2html.cpp
new file mode 100644
index 0000000..9c81e5b
--- /dev/null
+++ b/src/conv/html/sdw2html.cpp
@@ -0,0 +1,117 @@
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ * Copyright (C) 2002-2004 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#include <stdio.h>
+#include "HtmlDocumentGenerator.h"
+#include <libwpd/libwpd.h>
+#include <libwpd-stream/libwpd-stream.h>
+#include <libsdw/libsdw.h>
+#include <string.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef VERSION
+#define VERSION "UNKNOWN VERSION"
+#endif
+
+namespace
+{
+
+int printUsage()
+{
+ printf("Usage: sdw2html [OPTION] <WordPerfect Document>\n");
+ printf("\n");
+ printf("Options:\n");
+ printf("--help Shows this help message\n");
+ printf("--password <password> Try to decrypt password protected document\n");
+ printf("--version Output sdw2html version \n");
+ return -1;
+}
+
+int printVersion()
+{
+ printf("sdw2html %s\n", VERSION);
+ return 0;
+}
+
+} // anonymous namespace
+
+using namespace libsdw;
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2)
+ return printUsage();
+
+ char *file = 0;
+ char *password = 0;
+
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "--password"))
+ {
+ if (i < argc - 1)
+ password = argv[++i];
+ }
+ else if (!strncmp(argv[i], "--password=", 11))
+ password = &argv[i][11];
+ else if (!strcmp(argv[i], "--version"))
+ return printVersion();
+ else if (!file && strncmp(argv[i], "--", 2))
+ file = argv[i];
+ else
+ return printUsage();
+ }
+
+ if (!file)
+ return printUsage();
+
+ WPXFileStream input(file);
+
+ SDWConfidence confidence = SDWDocument::isFileFormatSupported(&input);
+ if (confidence != SDW_CONFIDENCE_EXCELLENT && confidence != SDW_CONFIDENCE_ENCRYPTION)
+ {
+ fprintf(stderr, "ERROR: Unsupported file format!\n");
+ return 1;
+ }
+
+ if (confidence == SDW_CONFIDENCE_ENCRYPTION && !password)
+ {
+ fprintf(stderr, "ERROR: File is password protected! Use \"--password\" option!\n");
+ return 1;
+ }
+
+ if (confidence == SDW_CONFIDENCE_ENCRYPTION && password && (!SDWDocument::verifyPassword(&input, password)))
+ {
+ fprintf(stderr, "ERROR: The password does not match, or document is not encrypted!\n");
+ return 1;
+ }
+
+ HtmlDocumentGenerator documentGenerator;
+ if (!SDWDocument::parse(&input, &documentGenerator, password))
+ return 1;
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/conv/html/sdw2html.rc.in b/src/conv/html/sdw2html.rc.in
new file mode 100644
index 0000000..362eda3
--- /dev/null
+++ b/src/conv/html/sdw2html.rc.in
@@ -0,0 +1,31 @@
+#include <winver.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @SDW_MAJOR_VERSION@,@SDW_MINOR_VERSION@,@SDW_MICRO_VERSION@,BUILDNUMBER
+ PRODUCTVERSION @SDW_MAJOR_VERSION@,@SDW_MINOR_VERSION@,@SDW_MICRO_VERSION@,0
+ FILEFLAGSMASK 0
+ FILEFLAGS 0
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_APP
+ FILESUBTYPE VFT2_UNKNOWN
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "The libsdw developer community"
+ VALUE "FileDescription", "sdw2html"
+ VALUE "FileVersion", "@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.@SDW_MICRO_VERSION@.BUILDNUMBER"
+ VALUE "InternalName", "sdw2html"
+ VALUE "LegalCopyright", "Copyright (C) 2002-2006 William Lachance, Marc Maurer, Fridrich Strba, other contributers"
+ VALUE "OriginalFilename", "sdw2html.exe"
+ VALUE "ProductName", "libsdw"
+ VALUE "ProductVersion", "@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.@SDW_MICRO_VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
+
diff --git a/src/conv/raw/Makefile.am b/src/conv/raw/Makefile.am
new file mode 100644
index 0000000..a5ab93b
--- /dev/null
+++ b/src/conv/raw/Makefile.am
@@ -0,0 +1,41 @@
+bin_PROGRAMS = sdw2raw
+
+AM_CXXFLAGS = -I$(top_srcdir)/inc $(WPD_CFLAGS) $(DEBUG_CXXFLAGS)
+
+sdw2raw_DEPENDENCIES = @SDW2RAW_WIN32_RESOURCE@
+
+if STATIC_TOOLS
+
+sdw2raw_LDADD = \
+ ../../lib/@SDW_OBJDIR@/libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.a \
+ $(WPD_LIBS) @SDW2RAW_WIN32_RESOURCE@
+sdw2raw_LDFLAGS = -all-static
+
+else
+
+sdw2raw_LDADD = \
+ ../../lib/libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.la \
+ $(WPD_LIBS) @SDW2RAW_WIN32_RESOURCE@
+
+endif
+
+sdw2raw_SOURCES = \
+ RawDocumentGenerator.cpp \
+ RawDocumentGenerator.h \
+ sdw2raw.cpp
+
+if OS_WIN32
+
+@SDW2RAW_WIN32_RESOURCE@ : sdw2raw.rc $(sdw2raw_OBJECTS)
+ chmod +x $(top_srcdir)/build/win32/*compile-resource
+ WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource sdw2raw.rc @SDW2RAW_WIN32_RESOURCE@
+endif
+
+EXTRA_DIST = \
+ $(sdw2raw_SOURCES) \
+ sdw2raw.rc.in
+
+# These may be in the builddir too
+BUILD_EXTRA_DIST = \
+ sdw2raw.rc
+
diff --git a/src/conv/raw/RawDocumentGenerator.cpp b/src/conv/raw/RawDocumentGenerator.cpp
new file mode 100644
index 0000000..4fe934b
--- /dev/null
+++ b/src/conv/raw/RawDocumentGenerator.cpp
@@ -0,0 +1,428 @@
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
+ * Copyright (C) 2002-2004 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include "RawDocumentGenerator.h"
+
+#ifdef _U
+#undef _U
+#endif
+
+#define _U(M, L) \
+ m_atLeastOneCallback = true; \
+ if (!m_printCallgraphScore) \
+ __iuprintf M; \
+ else \
+ m_callStack.push(L);
+
+#ifdef _D
+#undef _D
+#endif
+
+#define _D(M, L) \
+ m_atLeastOneCallback = true; \
+ if (!m_printCallgraphScore) \
+ __idprintf M; \
+ else \
+ { \
+ ListenerCallback lc = m_callStack.top(); \
+ if (lc != L) \
+ m_callbackMisses++; \
+ m_callStack.pop(); \
+ }
+
+RawDocumentGenerator::RawDocumentGenerator(bool printCallgraphScore) :
+ m_indent(0),
+ m_callbackMisses(0),
+ m_atLeastOneCallback(false),
+ m_printCallgraphScore(printCallgraphScore),
+ m_callStack()
+{
+}
+
+RawDocumentGenerator::~RawDocumentGenerator()
+{
+ if (m_printCallgraphScore)
+ printf("%d\n", m_atLeastOneCallback ? (int)(m_callStack.size()) + m_callbackMisses : -1);
+}
+
+void RawDocumentGenerator::__iprintf(const char *format, ...)
+{
+ m_atLeastOneCallback = true;
+ if (m_printCallgraphScore) return;
+
+ va_list args;
+ va_start(args, format);
+ for (int i=0; i<m_indent; i++)
+ printf(" ");
+ vprintf(format, args);
+ va_end(args);
+}
+
+void RawDocumentGenerator::__iuprintf(const char *format, ...)
+{
+ m_atLeastOneCallback = true;
+ va_list args;
+ va_start(args, format);
+ for (int i=0; i<m_indent; i++)
+ printf(" ");
+ vprintf(format, args);
+ __indentUp();
+ va_end(args);
+}
+
+void RawDocumentGenerator::__idprintf(const char *format, ...)
+{
+ m_atLeastOneCallback = true;
+ va_list args;
+ va_start(args, format);
+ __indentDown();
+ for (int i=0; i<m_indent; i++)
+ printf(" ");
+ vprintf(format, args);
+ va_end(args);
+}
+
+WPXString getPropString(const WPXPropertyList &propList)
+{
+ WPXString propString;
+ WPXPropertyList::Iter i(propList);
+ if (!i.last())
+ {
+ propString.append(i.key());
+ propString.append(": ");
+ propString.append(i()->getStr().cstr());
+ for (; i.next(); )
+ {
+ propString.append(", ");
+ propString.append(i.key());
+ propString.append(": ");
+ propString.append(i()->getStr().cstr());
+ }
+ }
+
+ return propString;
+}
+
+WPXString getPropString(const WPXPropertyListVector &itemList)
+{
+ WPXString propString;
+
+ propString.append("(");
+ WPXPropertyListVector::Iter i(itemList);
+
+ if (!i.last())
+ {
+ propString.append("(");
+ propString.append(getPropString(i()));
+ propString.append(")");
+
+ for (; i.next();)
+ {
+ propString.append(", (");
+ propString.append(getPropString(i()));
+ propString.append(")");
+ }
+
+ }
+ propString.append(")");
+
+ return propString;
+}
+
+void RawDocumentGenerator::setDocumentMetaData(const WPXPropertyList &propList)
+{
+ if (m_printCallgraphScore)
+ return;
+
+ __iprintf("setDocumentMetaData(%s)\n", getPropString(propList).cstr());
+}
+
+void RawDocumentGenerator::startDocument()
+{
+ _U(("startDocument()\n"), LC_START_DOCUMENT);
+}
+
+void RawDocumentGenerator::endDocument()
+{
+ _D(("endDocument()\n"), LC_START_DOCUMENT);
+}
+
+void RawDocumentGenerator::definePageStyle(const WPXPropertyList &propList)
+{
+ __iprintf("definePageStyle(%s)\n", getPropString(propList).cstr());
+}
+
+void RawDocumentGenerator::openPageSpan(const WPXPropertyList &propList)
+{
+ _U(("openPageSpan(%s)\n", getPropString(propList).cstr()),
+ LC_OPEN_PAGE_SPAN);
+}
+
+void RawDocumentGenerator::closePageSpan()
+{
+ _D(("closePageSpan()\n"),
+ LC_OPEN_PAGE_SPAN);
+}
+
+void RawDocumentGenerator::openHeader(const WPXPropertyList &propList)
+{
+ _U(("openHeader(%s)\n",
+ getPropString(propList).cstr()),
+ LC_OPEN_HEADER_FOOTER);
+}
+
+void RawDocumentGenerator::closeHeader()
+{
+ _D(("closeHeader()\n"),
+ LC_OPEN_HEADER_FOOTER);
+}
+
+void RawDocumentGenerator::openFooter(const WPXPropertyList &propList)
+{
+ _U(("openFooter(%s)\n",
+ getPropString(propList).cstr()),
+ LC_OPEN_HEADER_FOOTER);
+}
+
+void RawDocumentGenerator::closeFooter()
+{
+ _D(("closeFooter()\n"),
+ LC_OPEN_HEADER_FOOTER);
+}
+
+void RawDocumentGenerator::defineParagraphStyle(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
+{
+ __iprintf("defineParagraphStyle(%s, tab-stops: %s)\n", getPropString(propList).cstr(), getPropString(tabStops).cstr());
+}
+
+void RawDocumentGenerator::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
+{
+ _U(("openParagraph(%s, tab-stops: %s)\n", getPropString(propList).cstr(), getPropString(tabStops).cstr()),
+ LC_OPEN_PARAGRAPH);
+}
+
+void RawDocumentGenerator::closeParagraph()
+{
+ _D(("closeParagraph()\n"), LC_OPEN_PARAGRAPH);
+}
+
+void RawDocumentGenerator::defineCharacterStyle(const WPXPropertyList &propList)
+{
+ __iprintf("defineCharacterStyle(%s)\n", getPropString(propList).cstr());
+}
+
+void RawDocumentGenerator::openSpan(const WPXPropertyList &propList)
+{
+ _U(("openSpan(%s)\n", getPropString(propList).cstr()), LC_OPEN_SPAN);
+}
+
+void RawDocumentGenerator::closeSpan()
+{
+ _D(("closeSpan()\n"), LC_OPEN_SPAN);
+}
+
+void RawDocumentGenerator::defineSectionStyle(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
+{
+ __iprintf("defineSectionStyle(%s, columns: %s)\n", getPropString(propList).cstr(), getPropString(columns).cstr());
+}
+
+void RawDocumentGenerator::openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
+{
+ _U(("openSection(%s, columns: %s)\n", getPropString(propList).cstr(), getPropString(columns).cstr()), LC_OPEN_SECTION);
+}
+
+void RawDocumentGenerator::closeSection()
+{
+ _D(("closeSection()\n"), LC_OPEN_SECTION);
+}
+
+void RawDocumentGenerator::insertTab()
+{
+ __iprintf("insertTab()\n");
+}
+
+void RawDocumentGenerator::insertSpace()
+{
+ __iprintf("insertSpace()\n");
+}
+
+void RawDocumentGenerator::insertText(const WPXString &text)
+{
+ __iprintf("insertText(text: %s)\n", text.cstr());
+}
+
+void RawDocumentGenerator::insertLineBreak()
+{
+ __iprintf("insertLineBreak()\n");
+}
+
+void RawDocumentGenerator::insertField(const WPXString &type, const WPXPropertyList &propList)
+{
+ __iprintf("insertField(type: %s, %s)\n", type.cstr(), getPropString(propList).cstr());
+}
+
+void RawDocumentGenerator::defineOrderedListLevel(const WPXPropertyList &propList)
+{
+ __iprintf("defineOrderedListLevel(%s)\n", getPropString(propList).cstr());
+}
+
+void RawDocumentGenerator::defineUnorderedListLevel(const WPXPropertyList &propList)
+{
+ __iprintf("defineUnorderedListLevel(%s)\n", getPropString(propList).cstr());
+}
+
+void RawDocumentGenerator::openOrderedListLevel(const WPXPropertyList &propList)
+{
+ _U(("openOrderedListLevel(%s)\n", getPropString(propList).cstr()),
+ LC_OPEN_ORDERED_LIST_LEVEL);
+}
+
+void RawDocumentGenerator::openUnorderedListLevel(const WPXPropertyList &propList)
+{
+ _U(("openUnorderedListLevel(%s)\n", getPropString(propList).cstr()),
+ LC_OPEN_UNORDERED_LIST_LEVEL);
+}
+
+void RawDocumentGenerator::closeOrderedListLevel()
+{
+ _D(("closeOrderedListLevel()\n"),
+ LC_OPEN_ORDERED_LIST_LEVEL);
+}
+
+void RawDocumentGenerator::closeUnorderedListLevel()
+{
+ _D(("closeUnorderedListLevel()\n"), LC_OPEN_UNORDERED_LIST_LEVEL);
+}
+
+void RawDocumentGenerator::openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
+{
+ _U(("openListElement(%s, tab-stops: %s)\n", getPropString(propList).cstr(), getPropString(tabStops).cstr()),
+ LC_OPEN_LIST_ELEMENT);
+}
+
+void RawDocumentGenerator::closeListElement()
+{
+ _D(("closeListElement()\n"), LC_OPEN_LIST_ELEMENT);
+}
+
+void RawDocumentGenerator::openFootnote(const WPXPropertyList &propList)
+{
+ _U(("openFootnote(%s)\n", getPropString(propList).cstr()),
+ LC_OPEN_FOOTNOTE);
+}
+
+void RawDocumentGenerator::closeFootnote()
+{
+ _D(("closeFootnote()\n"), LC_OPEN_FOOTNOTE);
+}
+
+void RawDocumentGenerator::openEndnote(const WPXPropertyList &propList)
+{
+ _U(("openEndnote(number: %s)\n", getPropString(propList).cstr()),
+ LC_OPEN_ENDNOTE);
+}
+
+void RawDocumentGenerator::closeEndnote()
+{
+ _D(("closeEndnote()\n"), LC_OPEN_ENDNOTE);
+}
+
+void RawDocumentGenerator::openComment(const WPXPropertyList &propList)
+{
+ _U(("openComment(%s)\n", getPropString(propList).cstr()),
+ LC_OPEN_COMMENT);
+}
+
+void RawDocumentGenerator::closeComment()
+{
+ _D(("closeComment()\n"), LC_OPEN_COMMENT);
+}
+
+void RawDocumentGenerator::openTextBox(const WPXPropertyList &propList)
+{
+ _U(("openTextBox(%s)\n", getPropString(propList).cstr()),
+ LC_OPEN_TEXT_BOX);
+}
+
+void RawDocumentGenerator::closeTextBox()
+{
+ _D(("closeTextBox()\n"), LC_OPEN_TEXT_BOX);
+}
+
+void RawDocumentGenerator::openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
+{
+ _U(("openTable(%s, columns: %s)\n", getPropString(propList).cstr(), getPropString(columns).cstr()), LC_OPEN_TABLE);
+}
+
+void RawDocumentGenerator::openTableRow(const WPXPropertyList &propList)
+{
+ _U(("openTableRow(%s)\n", getPropString(propList).cstr()),
+ LC_OPEN_TABLE_ROW);
+}
+
+void RawDocumentGenerator::closeTableRow()
+{
+ _D(("closeTableRow()\n"), LC_OPEN_TABLE_ROW);
+}
+
+void RawDocumentGenerator::openTableCell(const WPXPropertyList &propList)
+{
+ _U(("openTableCell(%s)\n", getPropString(propList).cstr()),
+ LC_OPEN_TABLE_CELL);
+}
+
+void RawDocumentGenerator::closeTableCell()
+{
+ _D(("closeTableCell()\n"), LC_OPEN_TABLE_CELL);
+}
+
+void RawDocumentGenerator::insertCoveredTableCell(const WPXPropertyList &propList)
+{
+ __iprintf("insertCoveredTableCell(%s)\n", getPropString(propList).cstr());
+}
+
+void RawDocumentGenerator::closeTable()
+{
+ _D(("closeTable()\n"), LC_OPEN_TABLE);
+}
+
+void RawDocumentGenerator::openFrame(const WPXPropertyList &propList)
+{
+ _U(("openFrame(%s)\n", getPropString(propList).cstr()),
+ LC_OPEN_FRAME);
+}
+
+void RawDocumentGenerator::closeFrame()
+{
+ _D(("closeFrame()\n"), LC_OPEN_FRAME);
+}
+
+void RawDocumentGenerator::insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData & /* data */)
+{
+ __iprintf("insertBinaryObject(%s)\n", getPropString(propList).cstr());
+}
+
+void RawDocumentGenerator::insertEquation(const WPXPropertyList &propList, const WPXString &data)
+{
+ __iprintf("insertEquation(%s, text: %s)\n", getPropString(propList).cstr(), data.cstr());
+}
diff --git a/src/conv/raw/RawDocumentGenerator.h b/src/conv/raw/RawDocumentGenerator.h
new file mode 100644
index 0000000..4e2c259
--- /dev/null
+++ b/src/conv/raw/RawDocumentGenerator.h
@@ -0,0 +1,145 @@
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
+ * Copyright (C) 2002-2004 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#ifndef RAWLISTENERIMPL_H
+#define RAWLISTENERIMPL_H
+#include <libwpd/libwpd.h>
+#include <stack>
+
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
+
+using namespace std;
+
+enum ListenerCallback
+{
+ LC_START_DOCUMENT = 0,
+ LC_OPEN_PAGE_SPAN,
+ LC_OPEN_HEADER_FOOTER,
+ LC_OPEN_PARAGRAPH,
+ LC_OPEN_SPAN,
+ LC_OPEN_SECTION,
+ LC_OPEN_ORDERED_LIST_LEVEL,
+ LC_OPEN_UNORDERED_LIST_LEVEL,
+ LC_OPEN_LIST_ELEMENT,
+ LC_OPEN_FOOTNOTE,
+ LC_OPEN_ENDNOTE,
+ LC_OPEN_TABLE,
+ LC_OPEN_TABLE_ROW,
+ LC_OPEN_TABLE_CELL,
+ LC_OPEN_COMMENT,
+ LC_OPEN_TEXT_BOX,
+ LC_OPEN_FRAME
+};
+
+class RawDocumentGenerator : public WPXDocumentInterface
+{
+public:
+ RawDocumentGenerator(bool printCallgraphScore);
+ virtual ~RawDocumentGenerator();
+
+ 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);
+
+private:
+ int m_indent;
+ int m_callbackMisses;
+ bool m_atLeastOneCallback;
+ bool m_printCallgraphScore;
+ stack<ListenerCallback> m_callStack;
+
+ void __indentUp()
+ {
+ m_indent++;
+ }
+ void __indentDown()
+ {
+ if (m_indent > 0) m_indent--;
+ }
+
+ void __iprintf(const char *format, ...) __attribute__((format(printf,2,3)));
+ void __iuprintf(const char *format, ...) __attribute__((format(printf,2,3)));
+ void __idprintf(const char *format, ...) __attribute__((format(printf,2,3)));
+
+};
+
+#endif /* RAWLISTENERIMPL_H */
diff --git a/src/conv/raw/sdw2raw.cpp b/src/conv/raw/sdw2raw.cpp
new file mode 100644
index 0000000..8b97ba9
--- /dev/null
+++ b/src/conv/raw/sdw2raw.cpp
@@ -0,0 +1,120 @@
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
+ * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#include <stdio.h>
+#include <libwpd/libwpd.h>
+#include <libwpd-stream/libwpd-stream.h>
+#include <libsdw/libsdw.h>
+#include "RawDocumentGenerator.h"
+#include <string.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef VERSION
+#define VERSION "UNKNOWN VERSION"
+#endif
+
+namespace
+{
+
+int printUsage()
+{
+ printf("Usage: sdw2raw [OPTION] <WordPerfect Document>\n");
+ printf("\n");
+ printf("Options:\n");
+ printf("--callgraph Display the call graph nesting level\n");
+ printf("--help Shows this help message\n");
+ printf("--password <password> Try to decrypt password protected document\n");
+ printf("--version Output wpd2raw version \n");
+ return -1;
+}
+
+int printVersion()
+{
+ printf("sdw2raw %s\n", VERSION);
+ return 0;
+}
+
+} // anonymous namespace
+
+using namespace libsdw;
+
+int main(int argc, char *argv[])
+{
+ bool printIndentLevel = false;
+ char *file = 0;
+ char *password = 0;
+
+ if (argc < 2)
+ return printUsage();
+
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "--password"))
+ {
+ if (i < argc - 1)
+ password = argv[++i];
+ }
+ else if (!strncmp(argv[i], "--password=", 11))
+ password = &argv[i][11];
+ else if (!strcmp(argv[i], "--callgraph"))
+ printIndentLevel = true;
+ else if (!strcmp(argv[i], "--version"))
+ return printVersion();
+ else if (!file && strncmp(argv[i], "--", 2))
+ file = argv[i];
+ else
+ return printUsage();
+ }
+
+ if (!file)
+ return printUsage();
+
+ WPXFileStream input(file);
+
+ SDWConfidence confidence = SDWDocument::isFileFormatSupported(&input);
+ if (confidence != SDW_CONFIDENCE_EXCELLENT && confidence != SDW_CONFIDENCE_ENCRYPTION)
+ {
+ fprintf(stderr, "ERROR: Unsupported file format!\n");
+ return 1;
+ }
+
+ if (confidence == SDW_CONFIDENCE_ENCRYPTION && !password)
+ {
+ fprintf(stderr, "ERROR: File is password protected! Use \"--password\" option!\n");
+ return 1;
+ }
+
+ if (confidence == SDW_CONFIDENCE_ENCRYPTION && password && (!SDWDocument::verifyPassword(&input, password)))
+ {
+ fprintf(stderr, "ERROR: The password does not match, or document is not encrypted!\n");
+ return 1;
+ }
+
+ RawDocumentGenerator documentGenerator(printIndentLevel);
+ if (!SDWDocument::parse(&input, &documentGenerator, password))
+ return 1;
+
+ return 0;
+}
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/conv/raw/sdw2raw.rc.in b/src/conv/raw/sdw2raw.rc.in
new file mode 100644
index 0000000..3619646
--- /dev/null
+++ b/src/conv/raw/sdw2raw.rc.in
@@ -0,0 +1,31 @@
+#include <winver.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @SDW_MAJOR_VERSION@,@SDW_MINOR_VERSION@,@SDW_MICRO_VERSION@,BUILDNUMBER
+ PRODUCTVERSION @SDW_MAJOR_VERSION@,@SDW_MINOR_VERSION@,@SDW_MICRO_VERSION@,0
+ FILEFLAGSMASK 0
+ FILEFLAGS 0
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_APP
+ FILESUBTYPE VFT2_UNKNOWN
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "The libsdw developer community"
+ VALUE "FileDescription", "sdw2raw"
+ VALUE "FileVersion", "@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.@SDW_MICRO_VERSION@.BUILDNUMBER"
+ VALUE "InternalName", "sdw2raw"
+ VALUE "LegalCopyright", "Copyright (C) 2002-2006 William Lachance, Marc Maurer, Fridrich Strba, other contributers"
+ VALUE "OriginalFilename", "sdw2raw.exe"
+ VALUE "ProductName", "libsdw"
+ VALUE "ProductVersion", "@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.@SDW_MICRO_VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
+
diff --git a/src/conv/text/Makefile.am b/src/conv/text/Makefile.am
new file mode 100644
index 0000000..abf582d
--- /dev/null
+++ b/src/conv/text/Makefile.am
@@ -0,0 +1,41 @@
+bin_PROGRAMS = sdw2text
+
+AM_CXXFLAGS = -I$(top_srcdir)/inc $(WPD_CFLAGS) $(DEBUG_CXXFLAGS)
+
+sdw2text_DEPENDENCIES = @SDW2TEXT_WIN32_RESOURCE@
+
+if STATIC_TOOLS
+
+sdw2text_LDADD = \
+ ../../lib/@SDW_OBJDIR@/libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.a \
+ $(WPD_LIBS) @SDW2TEXT_WIN32_RESOURCE@
+sdw2text_LDFLAGS = -all-static
+
+else
+
+sdw2text_LDADD = \
+ ../../lib/libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.la \
+ $(WPD_LIBS) @SDW2TEXT_WIN32_RESOURCE@
+
+endif
+
+sdw2text_SOURCES = \
+ TextDocumentGenerator.cpp \
+ TextDocumentGenerator.h \
+ sdw2text.cpp
+
+if OS_WIN32
+
+@SDW2TEXT_WIN32_RESOURCE@ : sdw2text.rc $(sdw2text_OBJECTS)
+ chmod +x $(top_srcdir)/build/win32/*compile-resource
+ WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource sdw2text.rc @SDW2TEXT_WIN32_RESOURCE@
+endif
+
+EXTRA_DIST = \
+ $(sdw2text_SOURCES) \
+ sdw2text.rc.in
+
+# These may be in the builddir too
+BUILD_EXTRA_DIST = \
+ sdw2text.rc
+
diff --git a/src/conv/text/TextDocumentGenerator.cpp b/src/conv/text/TextDocumentGenerator.cpp
new file mode 100644
index 0000000..35f9db9
--- /dev/null
+++ b/src/conv/text/TextDocumentGenerator.cpp
@@ -0,0 +1,82 @@
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
+ * Copyright (C) 2002-2003 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#include <stdio.h>
+#include "TextDocumentGenerator.h"
+
+// use the BELL code to represent a TAB for now
+#define UCS_TAB 0x0009
+
+TextDocumentGenerator::TextDocumentGenerator(const bool isInfo) :
+ m_currentListLevel(0),
+ m_isInfo(isInfo)
+{
+}
+
+TextDocumentGenerator::~TextDocumentGenerator()
+{
+}
+
+void TextDocumentGenerator::setDocumentMetaData(const WPXPropertyList &propList)
+{
+ if (!m_isInfo)
+ return;
+ WPXPropertyList::Iter propIter(propList);
+ for (propIter.rewind(); propIter.next(); )
+ {
+ printf("%s %s\n", propIter.key(), propIter()->getStr().cstr());
+ }
+}
+
+void TextDocumentGenerator::closeParagraph()
+{
+ if (m_isInfo)
+ return;
+ printf("\n");
+}
+
+void TextDocumentGenerator::insertTab()
+{
+ if (m_isInfo)
+ return;
+ printf("%c", UCS_TAB);
+}
+
+void TextDocumentGenerator::insertText(const WPXString &text)
+{
+ if (m_isInfo)
+ return;
+ printf("%s", text.cstr());
+}
+
+void TextDocumentGenerator::insertSpace()
+{
+ if (m_isInfo)
+ return;
+ printf(" ");
+}
+
+void TextDocumentGenerator::insertLineBreak()
+{
+ if (m_isInfo)
+ return;
+ printf("\n");
+}
diff --git a/src/conv/text/TextDocumentGenerator.h b/src/conv/text/TextDocumentGenerator.h
new file mode 100644
index 0000000..929db79
--- /dev/null
+++ b/src/conv/text/TextDocumentGenerator.h
@@ -0,0 +1,101 @@
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
+ * Copyright (C) 2002-2003 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#ifndef TEXTLISTENERIMPL_H
+#define TEXTLISTENERIMPL_H
+
+#include <libwpd/libwpd.h>
+
+class TextDocumentGenerator : public WPXDocumentInterface
+{
+public:
+ TextDocumentGenerator(const bool isInfo=false);
+ virtual ~TextDocumentGenerator();
+
+ virtual void setDocumentMetaData(const WPXPropertyList &propList);
+
+ virtual void startDocument() {}
+ virtual void endDocument() {}
+
+ virtual void definePageStyle(const WPXPropertyList &) {}
+ virtual void openPageSpan(const WPXPropertyList & /* propList */) {}
+ virtual void closePageSpan() {}
+ virtual void openHeader(const WPXPropertyList & /* propList */) {}
+ virtual void closeHeader() {}
+ virtual void openFooter(const WPXPropertyList & /* propList */) {}
+ virtual void closeFooter() {}
+
+ virtual void defineSectionStyle(const WPXPropertyList &, const WPXPropertyListVector &) {}
+ virtual void openSection(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* columns */) {}
+ virtual void closeSection() {}
+
+ virtual void defineParagraphStyle(const WPXPropertyList &, const WPXPropertyListVector &) {}
+ virtual void openParagraph(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* tabStops */) {}
+ virtual void closeParagraph();
+
+ virtual void defineCharacterStyle(const WPXPropertyList &) {}
+ virtual void openSpan(const WPXPropertyList & /* propList */) {}
+ virtual void closeSpan() {}
+
+ virtual void insertTab();
+ virtual void insertText(const WPXString &text);
+ virtual void insertSpace();
+ 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 & /* object */) {}
+ virtual void insertEquation(const WPXPropertyList & /* propList */, const WPXString & /* data */) {}
+
+private:
+ unsigned int m_currentListLevel;
+ bool m_isInfo;
+};
+
+#endif /* TEXTLISTENERIMPL_H */
diff --git a/src/conv/text/sdw2text.cpp b/src/conv/text/sdw2text.cpp
new file mode 100644
index 0000000..dbdd189
--- /dev/null
+++ b/src/conv/text/sdw2text.cpp
@@ -0,0 +1,120 @@
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
+ * Copyright (C) 2002-2004 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <libwpd/libwpd.h>
+#include <libwpd-stream/libwpd-stream.h>
+#include <libsdw/libsdw.h>
+#include "TextDocumentGenerator.h"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef VERSION
+#define VERSION "UNKNOWN VERSION"
+#endif
+
+namespace
+{
+
+int printUsage()
+{
+ printf("Usage: sdw2text [OPTION] <WordPerfect Document>\n");
+ printf("\n");
+ printf("Options:\n");
+ printf("--info Display document metadata instead of the text\n");
+ printf("--help Shows this help message\n");
+ printf("--password <password> Try to decrypt password protected document\n");
+ printf("--version Output sdw2text version\n");
+ return -1;
+}
+
+int printVersion()
+{
+ printf("sdw2text %s\n", VERSION);
+ return 0;
+}
+
+} // anonymous namespace
+
+using namespace libsdw;
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2)
+ return printUsage();
+
+ char *szInputFile = 0;
+ bool isInfo = false;
+ char *password = 0;
+
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "--password"))
+ {
+ if (i < argc - 1)
+ password = argv[++i];
+ }
+ else if (!strncmp(argv[i], "--password=", 11))
+ password = &argv[i][11];
+ else if (!strcmp(argv[i], "--info"))
+ isInfo = true;
+ else if (!strcmp(argv[i], "--version"))
+ return printVersion();
+ else if (!szInputFile && strncmp(argv[i], "--", 2))
+ szInputFile = argv[i];
+ else
+ return printUsage();
+ }
+
+ if (!szInputFile)
+ return printUsage();
+
+ WPXFileStream input(szInputFile);
+
+ SDWConfidence confidence = SDWDocument::isFileFormatSupported(&input);
+ if (confidence != SDW_CONFIDENCE_EXCELLENT && confidence != SDW_CONFIDENCE_ENCRYPTION)
+ {
+ fprintf(stderr, "ERROR: Unsupported file format!\n");
+ return 1;
+ }
+
+ if (confidence == SDW_CONFIDENCE_ENCRYPTION && !password)
+ {
+ fprintf(stderr, "ERROR: File is password protected! Use \"--password\" option!\n");
+ return 1;
+ }
+
+ if (confidence == SDW_CONFIDENCE_ENCRYPTION && password && (!SDWDocument::verifyPassword(&input, password)))
+ {
+ fprintf(stderr, "ERROR: The password does not match, or document is not encrypted!\n");
+ return 1;
+ }
+
+ TextDocumentGenerator documentGenerator(isInfo);
+ if (!SDWDocument::parse(&input, &documentGenerator, password))
+ return 1;
+
+ return 0;
+}
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/conv/text/sdw2text.rc.in b/src/conv/text/sdw2text.rc.in
new file mode 100644
index 0000000..6f80b9b
--- /dev/null
+++ b/src/conv/text/sdw2text.rc.in
@@ -0,0 +1,31 @@
+#include <winver.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @SDW_MAJOR_VERSION@,@SDW_MINOR_VERSION@,@SDW_MICRO_VERSION@,BUILDNUMBER
+ PRODUCTVERSION @SDW_MAJOR_VERSION@,@SDW_MINOR_VERSION@,@SDW_MICRO_VERSION@,0
+ FILEFLAGSMASK 0
+ FILEFLAGS 0
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_APP
+ FILESUBTYPE VFT2_UNKNOWN
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "The libsdw developer community"
+ VALUE "FileDescription", "sdw2text"
+ VALUE "FileVersion", "@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.@SDW_MICRO_VERSION@.BUILDNUMBER"
+ VALUE "InternalName", "sdw2text"
+ VALUE "LegalCopyright", "Copyright (C) 2002-2006 William Lachance, Marc Maurer, Fridrich Strba, other contributers"
+ VALUE "OriginalFilename", "sdw2text.exe"
+ VALUE "ProductName", "libsdw"
+ VALUE "ProductVersion", "@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.@SDW_MICRO_VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
+
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
new file mode 100644
index 0000000..5d2e8fd
--- /dev/null
+++ b/src/lib/Makefile.am
@@ -0,0 +1,40 @@
+if OS_WIN32
+version_info = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -avoid-version
+else
+version_info = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+endif
+
+lib_LTLIBRARIES = libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.la $(target_libsdw_stream)
+libsdw_@SDW_MAJOR_VERSION@_@SDW_MINOR_VERSION@_includedir = $(includedir)/libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@/libsdw
+libsdw_@SDW_MAJOR_VERSION@_@SDW_MINOR_VERSION@_include_HEADERS = \
+ $(top_srcdir)/inc/libsdw/libsdw.h \
+ $(top_srcdir)/inc/libsdw/SDWDocument.h
+
+AM_CXXFLAGS = -I$(top_srcdir)/inc $(WPD_CFLAGS) $(DEBUG_CXXFLAGS)
+
+libsdw_@SDW_MAJOR_VERSION@_@SDW_MINOR_VERSION@_la_LIBADD = $(WPD_LIBS) @LIBSDW_WIN32_RESOURCE@
+libsdw_@SDW_MAJOR_VERSION@_@SDW_MINOR_VERSION@_la_DEPENDENCIES = @LIBSDW_WIN32_RESOURCE@
+libsdw_@SDW_MAJOR_VERSION@_@SDW_MINOR_VERSION@_la_LDFLAGS = $(version_info) -export-dynamic -no-undefined
+libsdw_@SDW_MAJOR_VERSION@_@SDW_MINOR_VERSION@_la_SOURCES = \
+ libsdw_internal.cpp \
+ SDWDocument.cpp \
+ SDWHeader.cpp \
+ SDWParser.cpp \
+ libsdw_internal.h \
+ SDWHeader.h \
+ SDWParser.h
+
+if OS_WIN32
+
+@LIBSDW_WIN32_RESOURCE@ : libsdw.rc $(libsdw_@SDW_MAJOR_VERSION@_@SDW_MINOR_VERSION@_la_OBJECTS)
+ chmod +x $(top_srcdir)/build/win32/*compile-resource
+ WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource libsdw.rc @LIBSDW_WIN32_RESOURCE@
+
+endif
+
+EXTRA_DIST = \
+ libsdw.rc.in
+
+# These may be in the builddir too
+BUILD_EXTRA_DIST = \
+ libsdw.rc
diff --git a/src/lib/SDWDocument.cpp b/src/lib/SDWDocument.cpp
new file mode 100644
index 0000000..757d5da
--- /dev/null
+++ b/src/lib/SDWDocument.cpp
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2003 William Lachance (william.lachance@sympatico.ca)
+ * Copyright (C) 2003-2004 Marc Maurer (uwog@uwog.net)
+ * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
+ * Copyright (C) 2006, 2007 Andrew Ziem (andrewziem users sourceforge net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#include <libsdw/libsdw.h>
+#include "SDWHeader.h"
+#include "SDWParser.h"
+#include "libsdw_internal.h"
+
+/**
+\mainpage libsdw documentation
+This document contains both the libsdw API specification and the normal libsdw
+documentation.
+\section api_docs libsdw API documentation
+The external libsdw API is provided by the SDWDocument class. This class, combined
+with the libwpd's WPXDocumentInterface class, are the only two classes that will be
+of interest for the application programmer using libsdw.
+\section lib_docs libsdw documentation
+If you are interrested in the structure of libsdw itself, this whole document
+would be a good starting point for exploring the interals of libsdw. Mind that
+this document is a work-in-progress, and will most likely not cover libsdw for
+the full 100%.
+
+ \warning When compiled with -DDEBUG_WITH__FILES, code is added to store the results of the parsing in different files: one file by Ole parts and some files to store the read pictures. These files are created in the current repository, therefore it is recommended to launch the tests in an empty repository...*/
+
+/**
+Analyzes the content of an input stream to see if it can be parsed
+\param ip The input stream
+\return A confidence value which represents the likelyhood that the content from
+the input stream can be parsed
+*/
+libsdw::SDWConfidence libsdw::SDWDocument::isFileFormatSupported(WPXInputStream *input)
+{
+ SDW_DEBUG_MSG(("SDWDocument::isFileFormatSupported()\n"));
+ if (!input->isOLEStream())
+ return SDW_CONFIDENCE_NONE;
+ WPXInputStream *starWriterDocument = input->getDocumentOLEStream("StarWriterDocument");
+ if (!starWriterDocument)
+ return SDW_CONFIDENCE_NONE;
+
+ delete starWriterDocument;
+ return SDW_CONFIDENCE_NONE;
+}
+
+/**
+Checks whether the given password was used to encrypt the document
+\param input The input stream
+\param password The password used to protect the document or NULL if the document is not protected
+\return A value which indicates between the given password and the password that was used to protect the document
+*/
+bool libsdw::SDWDocument::verifyPassword(WPXInputStream *input, const char *password)
+{
+ if (!password)
+ return false;
+ if (!input)
+ return false;
+
+ return false;
+}
+
+/**
+Parses the input stream content. It will make callbacks to the functions provided by a
+WPXDocumentInterface class implementation when needed. This is often commonly called the
+'main parsing routine'.
+\param ip The input stream
+\param documentInterface A SDWListener implementation
+*/
+bool libsdw::SDWDocument::parse(WPXInputStream *input, WPXDocumentInterface * /* documentInterface */, const char *password)
+{
+ SDW_DEBUG_MSG(("SDWDocument::isFileFormatSupported()\n"));
+ if (!input->isOLEStream())
+ return false;
+ WPXInputStream *starWriterDocument = input->getDocumentOLEStream("StarWriterDocument");
+ if (!starWriterDocument)
+ return false;
+ if (password && !verifyPassword(input, password))
+ return false;
+
+ delete starWriterDocument;
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/lib/SDWHeader.cpp b/src/lib/SDWHeader.cpp
new file mode 100644
index 0000000..7f5509c
--- /dev/null
+++ b/src/lib/SDWHeader.cpp
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* libwpd
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
+ * Copyright (C) 2002-2004 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libwpd.sourceforge.net
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+
+#include "SDWHeader.h"
+
+#include <string.h>
+
+libsdw::SDWHeader::SDWHeader(WPXInputStream * /* input */, SDWEncryption * /* encryption */, uint32_t documentOffset, uint8_t productType,
+ uint8_t fileType, uint8_t majorVersion, uint8_t minorVersion, uint16_t documentEncryption) :
+ m_documentOffset(documentOffset),
+ m_productType(productType),
+ m_fileType(fileType),
+ m_majorVersion(majorVersion),
+ m_minorVersion(minorVersion),
+ m_documentEncryption(documentEncryption)
+{
+}
+
+libsdw::SDWHeader::~SDWHeader()
+{
+}
+
+libsdw::SDWHeader *libsdw::SDWHeader::constructHeader(WPXInputStream * /* input */, SDWEncryption * /* encryption */)
+{
+ return 0;
+}
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/lib/SDWHeader.h b/src/lib/SDWHeader.h
new file mode 100644
index 0000000..c1e7c62
--- /dev/null
+++ b/src/lib/SDWHeader.h
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* libwpd
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
+ * Copyright (C) 2002-2003 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libwpd.sourceforge.net
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+
+#ifndef WPXHEADER_H
+#define WPXHEADER_H
+
+#include <libwpd/libwpd.h>
+#include <libwpd-stream/libwpd-stream.h>
+#include "libsdw_internal.h"
+
+namespace libsdw
+{
+
+class SDWEncryption;
+
+class SDWHeader
+{
+public:
+ SDWHeader(WPXInputStream *input, SDWEncryption *encryption, uint32_t documentOffset, uint8_t productType,
+ uint8_t fileType, uint8_t majorVersion, uint8_t minorVersion, uint16_t documentEncryption);
+ virtual ~SDWHeader();
+
+ static SDWHeader *constructHeader(WPXInputStream *input, SDWEncryption *encryption);
+
+ uint32_t getDocumentOffset() const
+ {
+ return m_documentOffset;
+ }
+ uint8_t getProductType() const
+ {
+ return m_productType;
+ }
+ uint8_t getFileType() const
+ {
+ return m_fileType;
+ }
+ uint8_t getMajorVersion() const
+ {
+ return m_majorVersion;
+ }
+ uint8_t getMinorVersion() const
+ {
+ return m_minorVersion;
+ }
+ uint16_t getDocumentEncryption() const
+ {
+ return m_documentEncryption;
+ }
+
+private:
+ uint32_t m_documentOffset;
+ uint8_t m_productType;
+ uint8_t m_fileType;
+ uint8_t m_majorVersion;
+ uint8_t m_minorVersion;
+ uint16_t m_documentEncryption;
+};
+
+} // namespace libsdw
+
+#endif /* WPXHEADER_H */
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/lib/SDWParser.cpp b/src/lib/SDWParser.cpp
new file mode 100644
index 0000000..6d9fa32
--- /dev/null
+++ b/src/lib/SDWParser.cpp
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
+ * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#include "libsdw_internal.h"
+
+#include "SDWHeader.h"
+#include "SDWParser.h"
+
+libsdw::SDWParser::SDWParser(WPXInputStream *input, SDWHeader *header, SDWEncryption *encryption) :
+ m_input(input),
+ m_header(header),
+ m_encryption(encryption)
+{
+}
+
+libsdw::SDWParser::~SDWParser()
+{
+}
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/lib/SDWParser.h b/src/lib/SDWParser.h
new file mode 100644
index 0000000..f46b3e1
--- /dev/null
+++ b/src/lib/SDWParser.h
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
+ * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#ifndef SDWPARSER_H
+#define SDWPARSER_H
+
+#include <libwpd/libwpd.h>
+#include <libwpd-stream/libwpd-stream.h>
+
+namespace libsdw
+{
+
+class SDWHeader;
+class SDWEncryption;
+
+class SDWParser
+{
+public:
+ SDWParser(WPXInputStream *input, SDWHeader *header, SDWEncryption *encryption);
+ virtual ~SDWParser();
+
+ virtual void parse(WPXDocumentInterface *documentInterface) = 0;
+
+protected:
+ SDWHeader *getHeader()
+ {
+ return m_header;
+ }
+ WPXInputStream *getInput()
+ {
+ return m_input;
+ }
+ SDWEncryption *getEncryption()
+ {
+ return m_encryption;
+ }
+
+private:
+ SDWParser(const SDWParser &);
+ SDWParser &operator=(const SDWParser &);
+ WPXInputStream *m_input;
+ SDWHeader *m_header;
+ SDWEncryption *m_encryption;
+};
+
+} // namespace libsdw
+
+#endif /* SDWPARSER_H */
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/lib/libsdw.rc.in b/src/lib/libsdw.rc.in
new file mode 100644
index 0000000..81b5761
--- /dev/null
+++ b/src/lib/libsdw.rc.in
@@ -0,0 +1,31 @@
+#include <winver.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @SDW_MAJOR_VERSION@,@SDW_MINOR_VERSION@,@SDW_MICRO_VERSION@,BUILDNUMBER
+ PRODUCTVERSION @SDW_MAJOR_VERSION@,@SDW_MINOR_VERSION@,@SDW_MICRO_VERSION@,0
+ FILEFLAGSMASK 0
+ FILEFLAGS 0
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_UNKNOWN
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "The libsdw developer community"
+ VALUE "FileDescription", "libsdw"
+ VALUE "FileVersion", "@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.@SDW_MICRO_VERSION@.BUILDNUMBER"
+ VALUE "InternalName", "libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@"
+ VALUE "LegalCopyright", "Copyright (C) 2006, 2007 Andrew Ziem, Fridrich Strba, other contributers"
+ VALUE "OriginalFilename", "libsdw-@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.dll"
+ VALUE "ProductName", "libsdw"
+ VALUE "ProductVersion", "@SDW_MAJOR_VERSION@.@SDW_MINOR_VERSION@.@SDW_MICRO_VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
+
diff --git a/src/lib/libsdw_internal.cpp b/src/lib/libsdw_internal.cpp
new file mode 100644
index 0000000..fde7b7d
--- /dev/null
+++ b/src/lib/libsdw_internal.cpp
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002, 2005 William Lachance (william.lachance@sympatico.ca)
+ * Copyright (C) 2002, 2004 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#include "libsdw_internal.h"
+
+uint8_t libsdw::readU8(WPXInputStream *input)
+{
+ if (!input || input->atEOS())
+ {
+ SDW_DEBUG_MSG(("Throwing EndOfStreamException\n"));
+ throw EndOfStreamException();
+ }
+ unsigned long numBytesRead;
+ uint8_t const *p = input->read(sizeof(uint8_t), numBytesRead);
+
+ if (p && numBytesRead == sizeof(uint8_t))
+ return *(uint8_t const *)(p);
+ SDW_DEBUG_MSG(("Throwing EndOfStreamException\n"));
+ throw EndOfStreamException();
+}
+
+int8_t libsdw::readS8(WPXInputStream *input)
+{
+ return (int8_t)readU8(input);
+}
+
+uint16_t libsdw::readU16(WPXInputStream *input)
+{
+ if (!input || input->atEOS())
+ {
+ SDW_DEBUG_MSG(("Throwing EndOfStreamException\n"));
+ throw EndOfStreamException();
+ }
+ unsigned long numBytesRead;
+ uint8_t const *p = input->read(sizeof(uint16_t), numBytesRead);
+
+ if (p && numBytesRead == sizeof(uint16_t))
+ return (uint16_t)p[0]|((uint16_t)p[1]<<8);
+ SDW_DEBUG_MSG(("Throwing EndOfStreamException\n"));
+ throw EndOfStreamException();
+}
+
+int16_t libsdw::readS16(WPXInputStream *input)
+{
+ return (int16_t)readU16(input);
+}
+
+uint32_t libsdw::readU32(WPXInputStream *input)
+{
+ if (!input || input->atEOS())
+ {
+ SDW_DEBUG_MSG(("Throwing EndOfStreamException\n"));
+ throw EndOfStreamException();
+ }
+ unsigned long numBytesRead;
+ uint8_t const *p = input->read(sizeof(uint32_t), numBytesRead);
+
+ if (p && numBytesRead == sizeof(uint32_t))
+ return (uint32_t)p[0]|((uint32_t)p[1]<<8)|((uint32_t)p[2]<<16)|((uint32_t)p[3]<<24);
+ SDW_DEBUG_MSG(("Throwing EndOfStreamException\n"));
+ throw EndOfStreamException();
+}
+
+int32_t libsdw::readS32(WPXInputStream *input)
+{
+ return (int32_t)readU32(input);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/lib/libsdw_internal.h b/src/lib/libsdw_internal.h
new file mode 100644
index 0000000..4a2af91
--- /dev/null
+++ b/src/lib/libsdw_internal.h
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* libsdw
+ * Version: MPL 2.0 / LGPLv2.1+
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
+ * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU Lesser General Public License Version 2.1 or later
+ * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
+ * applicable instead of those above.
+ *
+ * For further information visit http://libsdw.sourceforge.net
+ */
+
+#ifndef LIBSDW_INTERNAL_H
+#define LIBSDW_INTERNAL_H
+
+#include <assert.h>
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#include <iostream>
+#include <map>
+#include <string>
+
+#include <libwpd-stream/libwpd-stream.h>
+#include <libwpd/libwpd.h>
+
+class WPXBinaryData;
+
+#if defined(_MSC_VER) || defined(__DJGPP__)
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+typedef unsigned short uint16_t;
+typedef signed short int16_t;
+typedef unsigned uint32_t;
+typedef signed int int32_t;
+
+#else /* !defined _MSC_VER */
+
+#ifdef HAVE_CONFIG_H
+
+#include <config.h>
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+#else /* !defined HAVE_CONFIG_H */
+
+#include <stdint.h>
+#include <inttypes.h>
+
+#endif /* HAVE_CONFIG_H */
+
+#endif /* _MSC_VER */
+
+#include <libwpd/libwpd.h>
+#include <libwpd-stream/libwpd-stream.h>
+
+/* ---------- debug --------------- */
+#ifdef DEBUG
+#define SDW_DEBUG_MSG(M) printf M
+#else
+#define SDW_DEBUG_MSG(M)
+#endif
+
+/* ---------- exception ------------ */
+namespace libsdw
+{
+// Various exceptions
+class EndOfStreamException
+{
+ // needless to say, we could flesh this class out a bit
+};
+
+class FileException
+{
+ // needless to say, we could flesh this class out a bit
+};
+
+class ParseException
+{
+ // needless to say, we could flesh this class out a bit
+};
+
+class GenericException
+{
+ // needless to say, we could flesh this class out a bit
+};
+} // namespace libsdw
+
+/* ---------- input ----------------- */
+namespace libsdw
+{
+uint8_t readU8(WPXInputStream *input);
+uint16_t readU16(WPXInputStream *input);
+uint32_t readU32(WPXInputStream *input);
+
+int8_t readS8(WPXInputStream *input);
+int16_t readS16(WPXInputStream *input);
+int32_t readS32(WPXInputStream *input);
+} // namespace libsdw
+
+#endif /* LIBSDW_INTERNAL_H */
+/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */