From: Fridrich S. <str...@us...> - 2010-06-09 16:32:57
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv22040/src/lib Modified Files: WPG1Parser.cpp WPG2Parser.cpp WPG2Parser.h WPGXParser.cpp WPGXParser.h Log Message: Starting to parse text embedded inside graphics as a fragment of WP document for wPG1 and WPG2 Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.108 retrieving revision 1.109 diff -u -d -r1.108 -r1.109 --- WPG2Parser.cpp 8 Jun 2010 13:47:08 -0000 1.108 +++ WPG2Parser.cpp 9 Jun 2010 16:32:48 -0000 1.109 @@ -288,7 +288,7 @@ { 0x0c, "Color Palette", &WPG2Parser::handleColorPalette }, { 0x0d, "DP Color Palette", &WPG2Parser::handleDPColorPalette }, { 0x0e, "Bitmap Data", &WPG2Parser::handleBitmapData }, - { 0x0f, "Text Data", 0 }, + { 0x0f, "Text Data", &WPG2Parser::handleTextData }, { 0x10, "Chart Style", 0 }, // ignored { 0x11, "Chart Data", 0 }, // ignored { 0x12, "Object Image", &WPG2Parser::handleObjectImage }, @@ -2019,6 +2019,17 @@ } +void WPG2Parser::handleTextData() +{ + if (!m_graphicsStarted) + return; + ::WPXBinaryData textData; + while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) + textData.append((char)readU8()); + WPGXSubDocumentHandler handler; + WPDocument::parseSubDocument(const_cast<WPXInputStream *>(textData.getDataStream()), &handler, WPD_FILE_FORMAT_WP6); +} + void WPG2Parser::handleObjectCapsule() { if (!m_graphicsStarted) Index: WPG2Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.h,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- WPG2Parser.h 7 Sep 2009 09:41:29 -0000 1.37 +++ WPG2Parser.h 9 Jun 2010 16:32:48 -0000 1.38 @@ -197,6 +197,8 @@ void handleBitmap(); void handleBitmapData(); + void handleTextData(); + void handleObjectCapsule(); void handleObjectImage(); Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- WPG1Parser.cpp 8 Jun 2010 13:47:08 -0000 1.63 +++ WPG1Parser.cpp 9 Jun 2010 16:32:48 -0000 1.64 @@ -922,7 +922,9 @@ #ifdef DEBUG int sizeEquivalentData = readU32(); short rotationAngle = readS16(); +#endif unsigned short textLength = readU16(); +#ifdef DEBUG int x1 = readS16(); int y1 = readS16(); int x2 = readS16(); @@ -930,6 +932,7 @@ int sx = readS16(); int sy = readS16(); unsigned char type = readU8(); +#endif WPXBinaryData textString; for (unsigned short i=0; i < textLength; i++) textString.append(readU8()); @@ -942,7 +945,9 @@ WPG_DEBUG_MSG((" End position: %d,%d\n", x2, y2)); WPG_DEBUG_MSG((" Scale factor: %d,%d\n", sx, sy)); WPG_DEBUG_MSG((" Type: %d\n", type)); -#endif + + WPGXSubDocumentHandler handler; + WPDocument::parseSubDocument(const_cast<WPXInputStream *>(textString.getDataStream()), &handler, WPD_FILE_FORMAT_WP5); } void WPG1Parser::resetPalette() Index: WPGXParser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- WPGXParser.cpp 4 Jun 2010 15:19:00 -0000 1.19 +++ WPGXParser.cpp 9 Jun 2010 16:32:48 -0000 1.20 @@ -26,6 +26,7 @@ */ #include "WPGXParser.h" +#include "libwpg_utils.h" double fixedPointToDouble(const unsigned int fixedPointNumber) { @@ -115,3 +116,248 @@ m_colorPalette = parser.m_colorPalette; return *this; } + +void WPGXSubDocumentHandler::setDocumentMetaData(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::setDocumentMetaData\n")); +} + +void WPGXSubDocumentHandler::startDocument() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::startDocument\n")); +} + +void WPGXSubDocumentHandler::endDocument() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::endDocument\n")); +} + +void WPGXSubDocumentHandler::definePageStyle(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::definePageStyle\n")); +} + +void WPGXSubDocumentHandler::openPageSpan(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openPageSpan\n")); +} + +void WPGXSubDocumentHandler::closePageSpan() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closePageSpan\n")); +} + +void WPGXSubDocumentHandler::openHeader(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openHeader\n")); +} + +void WPGXSubDocumentHandler::closeHeader() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeHeader\n")); +} + +void WPGXSubDocumentHandler::openFooter(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openFooter\n")); +} + +void WPGXSubDocumentHandler::closeFooter() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeFooter\n")); +} + +void WPGXSubDocumentHandler::defineParagraphStyle(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::defineParagraphStyle\n")); +} + +void WPGXSubDocumentHandler::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openParagraph\n")); +} + +void WPGXSubDocumentHandler::closeParagraph() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeParagraph\n")); +} + +void WPGXSubDocumentHandler::defineCharacterStyle(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::defineCharacterStyle\n")); +} + +void WPGXSubDocumentHandler::openSpan(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openSpan\n")); +} + +void WPGXSubDocumentHandler::closeSpan() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeSpan\n")); +} + +void WPGXSubDocumentHandler::defineSectionStyle(const WPXPropertyList &propList, const WPXPropertyListVector &columns) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::defineSectionStyle\n")); +} + +void WPGXSubDocumentHandler::openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openSection\n")); +} + +void WPGXSubDocumentHandler::closeSection() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeSection\n")); +} + +void WPGXSubDocumentHandler::insertTab() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::insertTab\n")); +} + +void WPGXSubDocumentHandler::insertText(const WPXString &text) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::insertText %s\n", text.cstr())); +} + +void WPGXSubDocumentHandler::insertLineBreak() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::insertLineBreak\n")); +} + +void WPGXSubDocumentHandler::defineOrderedListLevel(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::defineOrderedListLevel\n")); +} + +void WPGXSubDocumentHandler::defineUnorderedListLevel(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::defineUnorderedListLevel\n")); +} + +void WPGXSubDocumentHandler::openOrderedListLevel(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openOrderedListLevel\n")); +} + +void WPGXSubDocumentHandler::openUnorderedListLevel(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openUnorderedListLevel\n")); +} + +void WPGXSubDocumentHandler::closeOrderedListLevel() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeOrderedListLevel\n")); +} + +void WPGXSubDocumentHandler::closeUnorderedListLevel() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeUnorderedListLevel\n")); +} + +void WPGXSubDocumentHandler::openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openListElement\n")); +} + +void WPGXSubDocumentHandler::closeListElement() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeListElement\n")); +} + +void WPGXSubDocumentHandler::openFootnote(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openFootnote\n")); +} + +void WPGXSubDocumentHandler::closeFootnote() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeFootnote\n")); +} + +void WPGXSubDocumentHandler::openEndnote(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openEndnote\n")); +} + +void WPGXSubDocumentHandler::closeEndnote() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeEndnote\n")); +} + +void WPGXSubDocumentHandler::openComment(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openComment\n")); +} + +void WPGXSubDocumentHandler::closeComment() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeComment\n")); +} + +void WPGXSubDocumentHandler::openTextBox(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openTextBox\n")); +} + +void WPGXSubDocumentHandler::closeTextBox() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeTextBox\n")); +} + +void WPGXSubDocumentHandler::openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openTable\n")); +} + +void WPGXSubDocumentHandler::openTableRow(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openTableRow\n")); +} + +void WPGXSubDocumentHandler::closeTableRow() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeTableRow\n")); +} + +void WPGXSubDocumentHandler::openTableCell(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openTableCell\n")); +} + +void WPGXSubDocumentHandler::closeTableCell() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeTableCell\n")); +} + +void WPGXSubDocumentHandler::insertCoveredTableCell(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::insertCoveredTableCell\n")); +} + +void WPGXSubDocumentHandler::closeTable() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeTable\n")); +} + +void WPGXSubDocumentHandler::openFrame(const WPXPropertyList &propList) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::openFrame\n")); +} + +void WPGXSubDocumentHandler::closeFrame() +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::closeFrame\n")); +} + +void WPGXSubDocumentHandler::insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData &data) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::insertBinaryObject\n")); +} + +void WPGXSubDocumentHandler::insertEquation(const WPXPropertyList &propList, const WPXString &data) +{ + WPG_DEBUG_MSG(("WPGXSubDocumentHandler::insertEquation\n")); +} Index: WPGXParser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- WPGXParser.h 4 Jun 2010 15:19:00 -0000 1.17 +++ WPGXParser.h 9 Jun 2010 16:32:48 -0000 1.18 @@ -30,6 +30,7 @@ #include "WPGPaintInterface.h" #include <libwpd-stream/WPXStream.h> +#include <libwpd/libwpd.h> #include "WPGColor.h" #include <map> @@ -58,4 +59,72 @@ std::map<int,libwpg::WPGColor> m_colorPalette; }; +class WPGXSubDocumentHandler : public WPXDocumentInterface +{ +public: + WPGXSubDocumentHandler() {} + virtual ~WPGXSubDocumentHandler() {} + 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 insertText(const WPXString &text); + virtual void insertLineBreak(); + + virtual void defineOrderedListLevel(const WPXPropertyList &propList); + virtual void defineUnorderedListLevel(const WPXPropertyList &propList); + virtual void openOrderedListLevel(const WPXPropertyList &propList); + virtual void openUnorderedListLevel(const WPXPropertyList &propList); + virtual void closeOrderedListLevel(); + virtual void closeUnorderedListLevel(); + virtual void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops); + virtual void closeListElement(); + + virtual void openFootnote(const WPXPropertyList &propList); + virtual void closeFootnote(); + virtual void openEndnote(const WPXPropertyList &propList); + virtual void closeEndnote(); + virtual void 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); +}; + + #endif // __WPGXPARSER_H__ |