Update of /cvsroot/libwpg/libwpg/src/lib In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv29065/src/lib Modified Files: WPG1Parser.cpp WPG2Parser.cpp WPGPaintInterface.h WPGSVGGenerator.cpp WPGSVGGenerator.h WPGXParser.cpp WPGXParser.h Log Message: Some more steps towards parsing of embedded text Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- WPG1Parser.cpp 10 Jun 2010 14:35:51 -0000 1.65 +++ WPG1Parser.cpp 10 Jun 2010 18:48:07 -0000 1.66 @@ -912,7 +912,11 @@ propList.insert("svg:x", (double)x/1200.0); propList.insert("svg:y", (double)(y)/1200.0); - m_painter->drawTextLine(propList, textString); + m_painter->startTextObject(propList, ::WPXPropertyListVector()); + + m_painter->insertText(textString); + + m_painter->endTextObject(); } void WPG1Parser::handleGraphicsTextTypeTwo() Index: WPGXParser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- WPGXParser.cpp 10 Jun 2010 14:35:52 -0000 1.21 +++ WPGXParser.cpp 10 Jun 2010 18:48:07 -0000 1.22 @@ -117,109 +117,29 @@ return *this; } -void WPGTextDataHandler::setDocumentMetaData(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::setDocumentMetaData\n")); -} - -void WPGTextDataHandler::startDocument() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::startDocument\n")); -} - -void WPGTextDataHandler::endDocument() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::endDocument\n")); -} - -void WPGTextDataHandler::startSubDocument() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::startSubDocument\n")); -} - void WPGTextDataHandler::endSubDocument() { WPG_DEBUG_MSG(("WPGTextDataHandler::endSubDocument\n")); } -void WPGTextDataHandler::definePageStyle(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::definePageStyle\n")); -} - -void WPGTextDataHandler::openPageSpan(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openPageSpan\n")); -} - -void WPGTextDataHandler::closePageSpan() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closePageSpan\n")); -} - -void WPGTextDataHandler::openHeader(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openHeader\n")); -} - -void WPGTextDataHandler::closeHeader() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeHeader\n")); -} - -void WPGTextDataHandler::openFooter(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openFooter\n")); -} - -void WPGTextDataHandler::closeFooter() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeFooter\n")); -} - -void WPGTextDataHandler::defineParagraphStyle(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::defineParagraphStyle\n")); -} - void WPGTextDataHandler::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) { - WPG_DEBUG_MSG(("WPGTextDataHandler::openParagraph\n")); + m_painter->startTextLine(propList); } void WPGTextDataHandler::closeParagraph() { - WPG_DEBUG_MSG(("WPGTextDataHandler::closeParagraph\n")); -} - -void WPGTextDataHandler::defineCharacterStyle(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::defineCharacterStyle\n")); + m_painter->endTextLine(); } void WPGTextDataHandler::openSpan(const WPXPropertyList &propList) { - WPG_DEBUG_MSG(("WPGTextDataHandler::openSpan\n")); + m_painter->startTextSpan(propList); } void WPGTextDataHandler::closeSpan() { - WPG_DEBUG_MSG(("WPGTextDataHandler::closeSpan\n")); -} - -void WPGTextDataHandler::defineSectionStyle(const WPXPropertyList &propList, const WPXPropertyListVector &columns) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::defineSectionStyle\n")); -} - -void WPGTextDataHandler::openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openSection\n")); -} - -void WPGTextDataHandler::closeSection() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeSection\n")); + m_painter->endTextSpan(); } void WPGTextDataHandler::insertTab() @@ -229,7 +149,7 @@ void WPGTextDataHandler::insertText(const WPXString &text) { - WPG_DEBUG_MSG(("WPGTextDataHandler::insertText %s\n", text.cstr())); + m_painter->insertText(text); } void WPGTextDataHandler::insertLineBreak() @@ -237,36 +157,6 @@ WPG_DEBUG_MSG(("WPGTextDataHandler::insertLineBreak\n")); } -void WPGTextDataHandler::defineOrderedListLevel(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::defineOrderedListLevel\n")); -} - -void WPGTextDataHandler::defineUnorderedListLevel(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::defineUnorderedListLevel\n")); -} - -void WPGTextDataHandler::openOrderedListLevel(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openOrderedListLevel\n")); -} - -void WPGTextDataHandler::openUnorderedListLevel(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openUnorderedListLevel\n")); -} - -void WPGTextDataHandler::closeOrderedListLevel() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeOrderedListLevel\n")); -} - -void WPGTextDataHandler::closeUnorderedListLevel() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeUnorderedListLevel\n")); -} - void WPGTextDataHandler::openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) { WPG_DEBUG_MSG(("WPGTextDataHandler::openListElement\n")); @@ -276,104 +166,3 @@ { WPG_DEBUG_MSG(("WPGTextDataHandler::closeListElement\n")); } - -void WPGTextDataHandler::openFootnote(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openFootnote\n")); -} - -void WPGTextDataHandler::closeFootnote() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeFootnote\n")); -} - -void WPGTextDataHandler::openEndnote(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openEndnote\n")); -} - -void WPGTextDataHandler::closeEndnote() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeEndnote\n")); -} - -void WPGTextDataHandler::openComment(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openComment\n")); -} - -void WPGTextDataHandler::closeComment() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeComment\n")); -} - -void WPGTextDataHandler::openTextBox(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openTextBox\n")); -} - -void WPGTextDataHandler::closeTextBox() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeTextBox\n")); -} - -void WPGTextDataHandler::openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openTable\n")); -} - -void WPGTextDataHandler::openTableRow(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openTableRow\n")); -} - -void WPGTextDataHandler::closeTableRow() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeTableRow\n")); -} - -void WPGTextDataHandler::openTableCell(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openTableCell\n")); -} - -void WPGTextDataHandler::closeTableCell() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeTableCell\n")); -} - -void WPGTextDataHandler::insertCoveredTableCell(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::insertCoveredTableCell\n")); -} - -void WPGTextDataHandler::closeTable() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeTable\n")); -} - -void WPGTextDataHandler::openFrame(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::openFrame\n")); -} - -void WPGTextDataHandler::closeFrame() -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::closeFrame\n")); -} - -void WPGTextDataHandler::insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData &data) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::insertBinaryObject\n")); -} - -void WPGTextDataHandler::insertEquation(const WPXPropertyList &propList, const WPXString &data) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::insertEquation\n")); -} - -void WPGTextDataHandler::setTextDataProperties(const WPXPropertyList &propList) -{ - WPG_DEBUG_MSG(("WPGTextDataHandler::setTextDataProperties\n")); - -} Index: WPGSVGGenerator.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- WPGSVGGenerator.h 8 Jun 2010 13:47:08 -0000 1.23 +++ WPGSVGGenerator.h 10 Jun 2010 18:48:07 -0000 1.24 @@ -55,7 +55,13 @@ void drawPolygon(const ::WPXPropertyListVector &vertices); void drawPath(const ::WPXPropertyListVector &path); void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData); - void drawTextLine(const ::WPXPropertyList &propList, const ::WPXString &str); + void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path); + void endTextObject(); + void startTextLine(const ::WPXPropertyList &propList) {} + void endTextLine() {} + void startTextSpan(const ::WPXPropertyList &propList) {} + void endTextSpan() {} + void insertText(const ::WPXString &str); private: ::WPXPropertyListVector m_gradient; Index: WPGSVGGenerator.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- WPGSVGGenerator.cpp 8 Jun 2010 13:47:08 -0000 1.38 +++ WPGSVGGenerator.cpp 10 Jun 2010 18:48:07 -0000 1.39 @@ -255,12 +255,20 @@ m_outputSink << "\" />\n"; } -void libwpg::WPGSVGGenerator::drawTextLine(const ::WPXPropertyList &propList, const ::WPXString &str) +void libwpg::WPGSVGGenerator::startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path) { m_outputSink << "<text "; if (propList["svg:x"] && propList["svg:y"]) m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\" >\n"; +} + +void libwpg::WPGSVGGenerator::insertText(const ::WPXString &str) +{ m_outputSink << str.cstr() << "\n"; +} + +void libwpg::WPGSVGGenerator::endTextObject() +{ m_outputSink << "</text >\n"; } Index: WPGPaintInterface.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGPaintInterface.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- WPGPaintInterface.h 8 Jun 2010 13:47:08 -0000 1.21 +++ WPGPaintInterface.h 10 Jun 2010 18:48:07 -0000 1.22 @@ -40,6 +40,9 @@ // none of the other callback functions will be called before this function is called virtual void startGraphics(const ::WPXPropertyList &propList) = 0; + // none of the other callback functions will be called after this function is called + virtual void endGraphics() = 0; + virtual void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient) = 0; virtual void startLayer(const ::WPXPropertyList &propList) = 0; @@ -50,6 +53,7 @@ virtual void endEmbeddedGraphics() = 0; + // Different primitive shapes virtual void drawRectangle(const ::WPXPropertyList& propList) = 0; virtual void drawEllipse(const ::WPXPropertyList& propList) = 0; @@ -60,12 +64,20 @@ virtual void drawPath(const ::WPXPropertyListVector &path) = 0; + // Embedded binary/raster data virtual void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData) = 0; - virtual void drawTextLine(const ::WPXPropertyList &propList, const ::WPXString &str) = 0; - - // none of the other callback functions will be called after this function is called - virtual void endGraphics() = 0; + // Embedded text object + virtual void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path) = 0; + virtual void endTextObject() = 0; + + virtual void startTextLine(const ::WPXPropertyList &propList) = 0; + virtual void endTextLine() = 0; + + virtual void startTextSpan(const ::WPXPropertyList &propList) = 0; + virtual void endTextSpan() = 0; + + virtual void insertText(const ::WPXString &str) = 0; }; } // namespace libwpg Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.110 retrieving revision 1.111 diff -u -d -r1.110 -r1.111 --- WPG2Parser.cpp 10 Jun 2010 14:35:52 -0000 1.110 +++ WPG2Parser.cpp 10 Jun 2010 18:48:07 -0000 1.111 @@ -2211,10 +2211,10 @@ long ys1 = (y1 <= y2) ? y1 : y2; long ys2 = (y1 <= y2) ? y2 : y1; - WPG_DEBUG_MSG((" x1 : %li\n", x1)); - WPG_DEBUG_MSG((" y1 : %li\n", y1)); - WPG_DEBUG_MSG((" x2 : %li\n", x2)); - WPG_DEBUG_MSG((" y2 : %li\n", y2)); + WPG_DEBUG_MSG((" x1 : %li\n", xs1)); + WPG_DEBUG_MSG((" y1 : %li\n", ys1)); + WPG_DEBUG_MSG((" x2 : %li\n", xs2)); + WPG_DEBUG_MSG((" y2 : %li\n", ys2)); m_textData.x1 = TO_DOUBLE(xs1)/m_xres; m_textData.y1 = TO_DOUBLE(ys1)/m_yres; @@ -2240,11 +2240,28 @@ { if (!m_graphicsStarted) return; +// if (!m_drawTextData) +// return; + ::WPXBinaryData textData; while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) textData.append((char)readU8()); WPGTextDataHandler handler(m_painter); + ::WPXPropertyList propList; + + propList.insert("svg:x", (double)m_textData.x1); + propList.insert("svg:y", (double)m_textData.y1); + if (m_textData.x1 != m_textData.x2 && m_textData.y1 != m_textData.y2) + { + propList.insert("svg:width", (m_textData.x2 - m_textData.x1)); + propList.insert("svg:height", (m_textData.y2 - m_textData.y1)); + } + + m_painter->startTextObject(propList, ::WPXPropertyListVector()); + WPDocument::parseSubDocument(const_cast<WPXInputStream *>(textData.getDataStream()), &handler, WPD_FILE_FORMAT_WP6); + + m_painter->endTextObject(); m_drawTextData = false; } Index: WPGXParser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- WPGXParser.h 10 Jun 2010 14:35:52 -0000 1.19 +++ WPGXParser.h 10 Jun 2010 18:48:07 -0000 1.20 @@ -59,79 +59,91 @@ std::map<int,libwpg::WPGColor> m_colorPalette; }; -class WPGTextDataHandler : public WPXDocumentInterface +class WPGTextDataHandler : public ::WPXDocumentInterface { public: WPGTextDataHandler(libwpg::WPGPaintInterface* painter) : - m_painter(painter) {} - virtual ~WPGTextDataHandler() {} - void setDocumentMetaData(const WPXPropertyList &propList); + m_painter(painter), + m_x(0.0), + m_y(0.0), + m_width(0.0), + m_height(0.0), + m_fontName("Times New Roman"), + m_fontSize(12.0), + m_paragraphStyle(), + m_textStyle() {} + + ~WPGTextDataHandler() {} + void setDocumentMetaData(const WPXPropertyList &propList) {} - void startDocument(); - void endDocument(); + void startDocument() {} + void endDocument() {} - void startSubDocument(); + void startSubDocument() {} void endSubDocument(); - void definePageStyle(const WPXPropertyList &propList); - void openPageSpan(const WPXPropertyList &propList); - void closePageSpan(); - void openHeader(const WPXPropertyList &propList); - void closeHeader(); - void openFooter(const WPXPropertyList &propList); - void closeFooter(); + void definePageStyle(const WPXPropertyList &propList) {} + void openPageSpan(const WPXPropertyList &propList) {} + void closePageSpan() {} + void openHeader(const WPXPropertyList &propList) {} + void closeHeader() {} + void openFooter(const WPXPropertyList &propList) {} + void closeFooter() {} - void defineParagraphStyle(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops); + void defineParagraphStyle(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops) {} void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops); void closeParagraph(); - void defineCharacterStyle(const WPXPropertyList &propList); + void defineCharacterStyle(const WPXPropertyList &propList) {} void openSpan(const WPXPropertyList &propList); void closeSpan(); - void defineSectionStyle(const WPXPropertyList &propList, const WPXPropertyListVector &columns); - void openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns); - void closeSection(); + void defineSectionStyle(const WPXPropertyList &propList, const WPXPropertyListVector &columns) {} + void openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns) {} + void closeSection() {} void insertTab(); void insertText(const WPXString &text); void insertLineBreak(); - void defineOrderedListLevel(const WPXPropertyList &propList); - void defineUnorderedListLevel(const WPXPropertyList &propList); - void openOrderedListLevel(const WPXPropertyList &propList); - void openUnorderedListLevel(const WPXPropertyList &propList); - void closeOrderedListLevel(); - void closeUnorderedListLevel(); + void defineOrderedListLevel(const WPXPropertyList &propList) {} + void defineUnorderedListLevel(const WPXPropertyList &propList) {} + void openOrderedListLevel(const WPXPropertyList &propList) {} + void openUnorderedListLevel(const WPXPropertyList &propList) {} + void closeOrderedListLevel() {} + void closeUnorderedListLevel() {} void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops); void closeListElement(); - void openFootnote(const WPXPropertyList &propList); - void closeFootnote(); - void openEndnote(const WPXPropertyList &propList); - void closeEndnote(); - void openComment(const WPXPropertyList &propList); - void closeComment(); - void openTextBox(const WPXPropertyList &propList); - void closeTextBox(); + void openFootnote(const WPXPropertyList &propList) {} + void closeFootnote() {} + void openEndnote(const WPXPropertyList &propList) {} + void closeEndnote() {} + void openComment(const WPXPropertyList &propList) {} + void closeComment() {} + void openTextBox(const WPXPropertyList &propList) {} + void closeTextBox() {} - void openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns); - void openTableRow(const WPXPropertyList &propList); - void closeTableRow(); - void openTableCell(const WPXPropertyList &propList); - void closeTableCell(); - void insertCoveredTableCell(const WPXPropertyList &propList); - void closeTable(); + void openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns) {} + void openTableRow(const WPXPropertyList &propList) {} + void closeTableRow() {} + void openTableCell(const WPXPropertyList &propList) {} + void closeTableCell() {} + void insertCoveredTableCell(const WPXPropertyList &propList) {} + void closeTable() {} - void openFrame(const WPXPropertyList &propList); - void closeFrame(); + void openFrame(const WPXPropertyList &propList) {} + void closeFrame() {} - void insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData &data); - void insertEquation(const WPXPropertyList &propList, const WPXString &data); + void insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData &data) {} + void insertEquation(const WPXPropertyList &propList, const WPXString &data) {} - void setTextDataProperties(const WPXPropertyList &propList); private: libwpg::WPGPaintInterface *m_painter; + double m_x, m_y, m_width, m_height; + ::WPXString m_fontName; + double m_fontSize; + ::WPXPropertyList m_paragraphStyle, m_textStyle; }; |