diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2011-07-18 16:20:03 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2011-07-18 16:20:03 +0200 |
commit | bd612a8746e8d8293465bac9c5478e82b5e4579e (patch) | |
tree | 6743820078993e57a85cbf4a2bbfcbdc66b5168d | |
parent | d653b23e2a631c8e13ef29f10f48e49494bc194d (diff) |
put text after geometries in the shape
-rw-r--r-- | src/lib/Makefile.am | 2 | ||||
-rw-r--r-- | src/lib/VSDXCharacterList.cpp | 100 | ||||
-rw-r--r-- | src/lib/VSDXCharacterList.h | 49 | ||||
-rw-r--r-- | src/lib/VSDXCollector.h | 3 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.cpp | 23 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.h | 5 | ||||
-rw-r--r-- | src/lib/VSDXDocumentStructure.h | 2 | ||||
-rw-r--r-- | src/lib/VSDXGeometryList.cpp | 22 | ||||
-rw-r--r-- | src/lib/VSDXGeometryList.h | 2 | ||||
-rw-r--r-- | src/lib/VSDXOutputElementList.cpp | 76 | ||||
-rw-r--r-- | src/lib/VSDXOutputElementList.h | 3 | ||||
-rw-r--r-- | src/lib/VSDXParser.cpp | 40 | ||||
-rw-r--r-- | src/lib/VSDXParser.h | 4 | ||||
-rw-r--r-- | src/lib/VSDXStylesCollector.cpp | 7 | ||||
-rw-r--r-- | src/lib/VSDXStylesCollector.h | 3 |
15 files changed, 299 insertions, 42 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index e383c3f..aeaeca2 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -36,6 +36,7 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \ VSD6Parser.cpp \ VSDInternalStream.cpp \ VSDSVGGenerator.cpp \ + VSDXCharacterList.cpp \ VSDXCollector.cpp \ VSDXContentCollector.cpp \ VSDXGeometryList.cpp \ @@ -48,6 +49,7 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \ VSD6Parser.h \ VSDInternalStream.h \ VSDSVGGenerator.h \ + VSDXCharacterList.h \ VSDXCollector.h \ VSDXContentCollector.h \ VSDXDocumentStructure.h \ diff --git a/src/lib/VSDXCharacterList.cpp b/src/lib/VSDXCharacterList.cpp new file mode 100644 index 0000000..aacc054 --- /dev/null +++ b/src/lib/VSDXCharacterList.cpp @@ -0,0 +1,100 @@ +/* libvisio + * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111-1301 USA + */ + +#include "VSDXCollector.h" +#include "VSDXCharacterList.h" + +namespace libvisio { + +class VSDXCharacterListElement +{ +public: + VSDXCharacterListElement() {} + virtual ~VSDXCharacterListElement() {} + virtual void handle(VSDXCollector *collector) = 0; +}; + +class VSDXText : public VSDXCharacterListElement +{ +public: + VSDXText(unsigned id , unsigned level, const WPXString &text) : + m_id(id), m_level(level), m_text(text) {} + ~VSDXText() {} + void handle(VSDXCollector *collector); +private: + unsigned m_id, m_level; + const WPXString m_text; +}; +} // namespace libvisio + + +void libvisio::VSDXText::handle(VSDXCollector *collector) +{ + collector->collectText(m_id, m_level, m_text); +} + +libvisio::VSDXCharacterList::VSDXCharacterList() +{ +} + +libvisio::VSDXCharacterList::~VSDXCharacterList() +{ + clear(); +} + +void libvisio::VSDXCharacterList::addText(unsigned id, unsigned level, const WPXString &text) +{ + m_elements[id] = new VSDXText(id, level, text); +} + +void libvisio::VSDXCharacterList::setElementsOrder(const std::vector<unsigned> &elementsOrder) +{ + m_elementsOrder.clear(); + for (unsigned i = 0; i<elementsOrder.size(); i++) + m_elementsOrder.push_back(elementsOrder[i]); +} + +void libvisio::VSDXCharacterList::handle(VSDXCollector *collector) +{ + if (empty()) + return; + std::map<unsigned, VSDXCharacterListElement *>::iterator iter; + if (m_elementsOrder.size()) + { + for (unsigned i = 0; i < m_elementsOrder.size(); i++) + { + iter = m_elements.find(m_elementsOrder[i]); + if (iter != m_elements.end()) + iter->second->handle(collector); + } + } + else + { + for (iter = m_elements.begin(); iter != m_elements.end(); iter++) + iter->second->handle(collector); + } +} + +void libvisio::VSDXCharacterList::clear() +{ + for (std::map<unsigned, VSDXCharacterListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); iter++) + delete iter->second; + m_elements.clear(); + m_elementsOrder.clear(); +} diff --git a/src/lib/VSDXCharacterList.h b/src/lib/VSDXCharacterList.h new file mode 100644 index 0000000..d1e4593 --- /dev/null +++ b/src/lib/VSDXCharacterList.h @@ -0,0 +1,49 @@ +/* libvisio + * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> + * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111-1301 USA + */ + +#ifndef __VSDXCHARACTERLIST_H__ +#define __VSDXCHARACTERLIST_H__ + +#include <vector> +#include <map> + +namespace libvisio { + +class VSDXCharacterListElement; +class VSDXCollector; + +class VSDXCharacterList +{ +public: + VSDXCharacterList(); + ~VSDXCharacterList(); + void addText(unsigned id, unsigned level, const WPXString &text); + void setElementsOrder(const std::vector<unsigned> &m_elementsOrder); + void handle(VSDXCollector *collector); + void clear(); + bool empty() const { return (!m_elements.size()); } +private: + std::map<unsigned, VSDXCharacterListElement *> m_elements; + std::vector<unsigned> m_elementsOrder; +}; + +} // namespace libvisio + +#endif // __VSDXCHARACTERLIST_H__ diff --git a/src/lib/VSDXCollector.h b/src/lib/VSDXCollector.h index 534acc5..98e9f48 100644 --- a/src/lib/VSDXCollector.h +++ b/src/lib/VSDXCollector.h @@ -59,7 +59,8 @@ public: virtual void collectColours(const std::vector<Colour> &colours) = 0; - virtual void collectText(unsigned id, unsigned level, const std::string &text) = 0; + virtual void collectCharList(unsigned id, unsigned level) = 0; + virtual void collectText(unsigned id, unsigned level, const WPXString &text) = 0; // Temporary hack virtual void startPage() = 0; diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDXContentCollector.cpp index 3f27953..7dcce68 100644 --- a/src/lib/VSDXContentCollector.cpp +++ b/src/lib/VSDXContentCollector.cpp @@ -489,6 +489,11 @@ void libvisio::VSDXContentCollector::collectGeomList(unsigned /* id */, unsigned _handleLevelChange(level); } +void libvisio::VSDXContentCollector::collectCharList(unsigned /* id */, unsigned level) +{ + _handleLevelChange(level); +} + void libvisio::VSDXContentCollector::collectGeometry(unsigned /* id */, unsigned level, unsigned geomFlags) { _handleLevelChange(level); @@ -623,7 +628,7 @@ void libvisio::VSDXContentCollector::collectNURBSTo(unsigned /* id */, unsigned for (unsigned p = 0; p < controlPoints.size() && p < weights.size(); p++) { - double basis = _NURBSBasis(p, degree, i * step, controlPoints.size(), knotVector); + double basis = _NURBSBasis(p, degree, i * step, knotVector); nextX += basis * controlPoints[p].first * weights[p]; nextY += basis * controlPoints[p].second * weights[p]; denominator += weights[p] * basis; @@ -642,7 +647,7 @@ void libvisio::VSDXContentCollector::collectNURBSTo(unsigned /* id */, unsigned transformPoint(m_x, m_y); } -double libvisio::VSDXContentCollector::_NURBSBasis(unsigned knot, unsigned degree, double point, unsigned controlCount, const std::vector<double> &knotVector) +double libvisio::VSDXContentCollector::_NURBSBasis(unsigned knot, unsigned degree, double point, const std::vector<double> &knotVector) { double basis = 0; if (!knotVector.size()) @@ -655,10 +660,10 @@ double libvisio::VSDXContentCollector::_NURBSBasis(unsigned knot, unsigned degre return 0; } if (knotVector.size() > knot+degree && knotVector[knot+degree]-knotVector[knot] > 0) - basis = (point-knotVector[knot])/(knotVector[knot+degree]-knotVector[knot]) * _NURBSBasis(knot, degree-1, point, controlCount, knotVector); + basis = (point-knotVector[knot])/(knotVector[knot+degree]-knotVector[knot]) * _NURBSBasis(knot, degree-1, point, knotVector); - if (knotVector.size() > knot+degree+1 && knot <= controlCount && knotVector[knot+degree+1] - knotVector[knot+1] > 0) - basis += (knotVector[knot+degree+1]-point)/(knotVector[knot+degree+1]-knotVector[knot+1]) * _NURBSBasis(knot+1, degree-1, point, controlCount, knotVector); + if (knotVector.size() > knot+degree+1 && knotVector[knot+degree+1] - knotVector[knot+1] > 0) + basis += (knotVector[knot+degree+1]-point)/(knotVector[knot+degree+1]-knotVector[knot+1]) * _NURBSBasis(knot+1, degree-1, point, knotVector); return basis; } @@ -900,7 +905,7 @@ void libvisio::VSDXContentCollector::collectColours(const std::vector<Colour> &c m_colours.push_back(colours[i]); } -void libvisio::VSDXContentCollector::collectText(unsigned /*id*/, unsigned level, const std::string &text) +void libvisio::VSDXContentCollector::collectText(unsigned /*id*/, unsigned level, const WPXString &text) { _handleLevelChange(level); VSD_DEBUG_MSG(("Text: %s\n", text.c_str())); @@ -908,9 +913,9 @@ void libvisio::VSDXContentCollector::collectText(unsigned /*id*/, unsigned level WPXPropertyList textCoords; textCoords.insert("svg:x", m_scale * m_x); textCoords.insert("svg:y", m_scale * m_y); - m_painter->startTextObject(textCoords, WPXPropertyListVector()); - m_painter->insertText(WPXString(text.c_str())); - m_painter->endTextObject(); + m_shapeOutput->addStartTextObject(textCoords, WPXPropertyListVector()); + m_shapeOutput->addInsertText(text); + m_shapeOutput->addEndTextObject(); } void libvisio::VSDXContentCollector::_handleLevelChange(unsigned level) diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDXContentCollector.h index cc672e6..19d3639 100644 --- a/src/lib/VSDXContentCollector.h +++ b/src/lib/VSDXContentCollector.h @@ -74,7 +74,8 @@ public: void collectColours(const std::vector<Colour> &colours); - void collectText(unsigned id, unsigned level, const std::string &text); + void collectCharList(unsigned id, unsigned level); + void collectText(unsigned id, unsigned level, const WPXString &text); void startPage(); void endPage(); @@ -88,7 +89,7 @@ private: void transformPoint(double &x, double &y); void transformAngle(double &angle); - double _NURBSBasis(unsigned knot, unsigned degree, double point, unsigned controlCount, const std::vector<double> &knotVector); + double _NURBSBasis(unsigned knot, unsigned degree, double point, const std::vector<double> &knotVector); void _flushCurrentPath(); void _flushCurrentForeignData(); diff --git a/src/lib/VSDXDocumentStructure.h b/src/lib/VSDXDocumentStructure.h index 86a190b..db266ad 100644 --- a/src/lib/VSDXDocumentStructure.h +++ b/src/lib/VSDXDocumentStructure.h @@ -42,6 +42,8 @@ #define VSD_SHAPE_LIST 0x65 #define VSD_FONT_IX 0x69 +#define VSD_CHAR_LIST 0x69 + #define VSD_GEOM_LIST 0x6c #define VSD_SHAPE_ID 0x83 diff --git a/src/lib/VSDXGeometryList.cpp b/src/lib/VSDXGeometryList.cpp index eb4bebe..7f33faf 100644 --- a/src/lib/VSDXGeometryList.cpp +++ b/src/lib/VSDXGeometryList.cpp @@ -160,18 +160,6 @@ private: double m_x, m_y; unsigned m_dataID; }; - -class VSDXText : public VSDXGeometryListElement -{ -public: - VSDXText(unsigned id , unsigned level, const std::string &text) : - m_id(id), m_level(level), m_text(text) {} - ~VSDXText() {} - void handle(VSDXCollector *collector); -private: - unsigned m_id, m_level; - const std::string m_text; -}; } // namespace libvisio @@ -225,11 +213,6 @@ void libvisio::VSDXPolylineTo2::handle(VSDXCollector *collector) collector->collectPolylineTo(m_id, m_level, m_x, m_y, m_dataID); } -void libvisio::VSDXText::handle(VSDXCollector *collector) -{ - collector->collectText(m_id, m_level, m_text); -} - libvisio::VSDXGeometryList::VSDXGeometryList() { } @@ -289,11 +272,6 @@ void libvisio::VSDXGeometryList::addEllipticalArcTo(unsigned id, unsigned level, m_elements[id] = new VSDXEllipticalArcTo(id, level, x3, y3, x2, y2, angle, ecc); } -void libvisio::VSDXGeometryList::addText(unsigned id, unsigned level, const std::string &text) -{ - m_elements[id] = new VSDXText(id, level, text); -} - void libvisio::VSDXGeometryList::setElementsOrder(const std::vector<unsigned> &elementsOrder) { m_elementsOrder.clear(); diff --git a/src/lib/VSDXGeometryList.h b/src/lib/VSDXGeometryList.h index 4abfe87..de70beb 100644 --- a/src/lib/VSDXGeometryList.h +++ b/src/lib/VSDXGeometryList.h @@ -34,7 +34,6 @@ class VSDXGeometryList public: VSDXGeometryList(); ~VSDXGeometryList(); - void addGeomList(unsigned id, unsigned level, const std::vector<unsigned> &geometryOrder); void addGeometry(unsigned id, unsigned level, unsigned geomFlags); void addMoveTo(unsigned id, unsigned level, double x, double y); void addLineTo(unsigned id, unsigned level, double x, double y); @@ -45,7 +44,6 @@ public: void addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned dataID); void addEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop); void addEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc); - void addText(unsigned id, unsigned level, const std::string &text); void setElementsOrder(const std::vector<unsigned> &m_elementsOrder); void handle(VSDXCollector *collector); void clear(); diff --git a/src/lib/VSDXOutputElementList.cpp b/src/lib/VSDXOutputElementList.cpp index 713a222..f9b370e 100644 --- a/src/lib/VSDXOutputElementList.cpp +++ b/src/lib/VSDXOutputElementList.cpp @@ -95,6 +95,38 @@ public: virtual void draw(libwpg::WPGPaintInterface *painter); }; + +class VSDXStartTextObjectOutputElement : public VSDXOutputElement +{ +public: + VSDXStartTextObjectOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec); + virtual ~VSDXStartTextObjectOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); +private: + WPXPropertyList m_propList; + WPXPropertyListVector m_propListVec; +}; + + +class VSDXInsertTextOutputElement : public VSDXOutputElement +{ +public: + VSDXInsertTextOutputElement(const WPXString &text); + virtual ~VSDXInsertTextOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); +private: + WPXString m_text; +}; + + +class VSDXEndTextObjectOutputElement : public VSDXOutputElement +{ +public: + VSDXEndTextObjectOutputElement(); + virtual ~VSDXEndTextObjectOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); +}; + } // namespace libvisio libvisio::VSDXStyleOutputElement::VSDXStyleOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) : @@ -156,6 +188,35 @@ void libvisio::VSDXEndLayerOutputElement::draw(libwpg::WPGPaintInterface *painte } +libvisio::VSDXStartTextObjectOutputElement::VSDXStartTextObjectOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) : + m_propList(propList), m_propListVec(propListVec) {} + +void libvisio::VSDXStartTextObjectOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->startTextObject(m_propList, m_propListVec); +} + + +libvisio::VSDXInsertTextOutputElement::VSDXInsertTextOutputElement(const WPXString &text) : + m_text(text) {} + +void libvisio::VSDXInsertTextOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->insertText(m_text); +} + + +libvisio::VSDXEndTextObjectOutputElement::VSDXEndTextObjectOutputElement() {} + +void libvisio::VSDXEndTextObjectOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->endTextObject(); +} + + libvisio::VSDXOutputElementList::~VSDXOutputElementList() { for (std::vector<VSDXOutputElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); iter++) @@ -199,6 +260,21 @@ void libvisio::VSDXOutputElementList::addEndLayer() m_elements.push_back(new VSDXEndLayerOutputElement()); } +void libvisio::VSDXOutputElementList::addStartTextObject(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) +{ + m_elements.push_back(new VSDXStartTextObjectOutputElement(propList, propListVec)); +} + +void libvisio::VSDXOutputElementList::addInsertText(const WPXString &text) +{ + m_elements.push_back(new VSDXInsertTextOutputElement(text)); +} + +void libvisio::VSDXOutputElementList::addEndTextObject() +{ + m_elements.push_back(new VSDXEndTextObjectOutputElement()); +} + void libvisio::VSDXOutputElementList::clear() { for (std::vector<VSDXOutputElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); iter++) diff --git a/src/lib/VSDXOutputElementList.h b/src/lib/VSDXOutputElementList.h index 9d40dc8..eae0010 100644 --- a/src/lib/VSDXOutputElementList.h +++ b/src/lib/VSDXOutputElementList.h @@ -43,6 +43,9 @@ public: void addGraphicObject(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData); void addStartLayer(const WPXPropertyList &propList); void addEndLayer(); + void addStartTextObject(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec); + void addInsertText(const WPXString &text); + void addEndTextObject(); bool empty() const { return !m_elements.size(); } void clear(); private: diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp index 2739597..f335bce 100644 --- a/src/lib/VSDXParser.cpp +++ b/src/lib/VSDXParser.cpp @@ -32,7 +32,7 @@ libvisio::VSDXParser::VSDXParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter) : m_input(input), m_painter(painter), m_header(), m_collector(0), m_geomList(new VSDXGeometryList()), m_geomListVector(), - m_shapeList(), m_currentLevel(0) + m_charList(new VSDXCharacterList()), m_charListVector(), m_shapeList(), m_currentLevel(0) {} libvisio::VSDXParser::~VSDXParser() @@ -42,6 +42,11 @@ libvisio::VSDXParser::~VSDXParser() m_geomList->clear(); delete m_geomList; } + if (m_charList) + { + m_charList->clear(); + delete m_charList; + } } /** Parses Visio input stream content, making callbacks to functions provided @@ -187,8 +192,10 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level) if (level < 3) { m_geomListVector.push_back(m_geomList); + m_charListVector.push_back(m_charList); // reinitialize, but don't clear, because we want those pointers to be valid until we handle the whole vector m_geomList = new VSDXGeometryList(); + m_charList = new VSDXCharacterList(); m_shapeList.handle(m_collector); m_shapeList.clear(); } @@ -201,6 +208,13 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level) delete *iter; } m_geomListVector.clear(); + for (std::vector<VSDXCharacterList *>::iterator iter = m_charListVector.begin(); iter != m_charListVector.end(); iter++) + { + (*iter)->handle(m_collector); + (*iter)->clear(); + delete *iter; + } + m_charListVector.clear(); } m_currentLevel = level; } @@ -282,6 +296,9 @@ void libvisio::VSDXParser::handlePage(WPXInputStream *input) case VSD_PAGE_PROPS: readPageProps(input); break; + case VSD_CHAR_LIST: + readCharList(input); + break; case VSD_TEXT: readText(input); break; @@ -393,6 +410,21 @@ void libvisio::VSDXParser::readGeomList(WPXInputStream *input) m_collector->collectGeomList(m_header.id, m_header.level); } +void libvisio::VSDXParser::readCharList(WPXInputStream *input) +{ + uint32_t subHeaderLength = readU32(input); + uint32_t childrenListLength = readU32(input); + input->seek(subHeaderLength, WPX_SEEK_CUR); + std::vector<unsigned> characterOrder; + characterOrder.reserve(childrenListLength / sizeof(uint32_t)); + for (unsigned i = 0; i < (childrenListLength / sizeof(uint32_t)); i++) + characterOrder.push_back(readU32(input)); + + m_charList->setElementsOrder(characterOrder); + // We want the collectors to still get the level information + m_collector->collectCharList(m_header.id, m_header.level); +} + void libvisio::VSDXParser::readGeometry(WPXInputStream *input) { unsigned geomFlags = readU8(input); @@ -833,7 +865,7 @@ void libvisio::VSDXParser::readColours(WPXInputStream *input) void libvisio::VSDXParser::readText(WPXInputStream *input) { input->seek(8, WPX_SEEK_CUR); - std::string text; + WPXString text; unsigned bytesRead = 8; // Read up to end of chunk in byte pairs (except from last 2 bytes) @@ -842,9 +874,9 @@ void libvisio::VSDXParser::readText(WPXInputStream *input) bytesRead += 2; char c = readU8(input); input->seek(1, WPX_SEEK_CUR); - text.push_back(c); + text.append(c); } - m_geomList->addText(m_header.id, m_header.level, text); + m_charList->addText(m_header.id, m_header.level, text); } diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h index 761a43a..9fa9b26 100644 --- a/src/lib/VSDXParser.h +++ b/src/lib/VSDXParser.h @@ -30,6 +30,7 @@ #include <libwpg/libwpg.h> #include "VSDXTypes.h" #include "VSDXGeometryList.h" +#include "VSDXCharacterList.h" #include "VSDXShapeList.h" namespace libvisio @@ -66,6 +67,7 @@ protected: void readPageProps(WPXInputStream *input); void readShape(WPXInputStream *input); void readColours(WPXInputStream *input); + void readCharList(WPXInputStream *input); void readText(WPXInputStream *input); // parser of one pass @@ -84,6 +86,8 @@ protected: VSDXCollector *m_collector; VSDXGeometryList *m_geomList; std::vector<VSDXGeometryList *> m_geomListVector; + VSDXCharacterList *m_charList; + std::vector<VSDXCharacterList *> m_charListVector; VSDXShapeList m_shapeList; unsigned m_currentLevel; diff --git a/src/lib/VSDXStylesCollector.cpp b/src/lib/VSDXStylesCollector.cpp index 14a2245..7f69b18 100644 --- a/src/lib/VSDXStylesCollector.cpp +++ b/src/lib/VSDXStylesCollector.cpp @@ -69,6 +69,11 @@ void libvisio::VSDXStylesCollector::collectGeomList(unsigned /* id */, unsigned _handleLevelChange(level); } +void libvisio::VSDXStylesCollector::collectCharList(unsigned /* id */, unsigned level) +{ + _handleLevelChange(level); +} + void libvisio::VSDXStylesCollector::collectGeometry(unsigned /* id */, unsigned level, unsigned /* geomFlags */) { _handleLevelChange(level); @@ -165,7 +170,7 @@ void libvisio::VSDXStylesCollector::collectColours(const std::vector<Colour> & / { } -void libvisio::VSDXStylesCollector::collectText(unsigned /*id*/, unsigned level, const std::string & /*text*/) +void libvisio::VSDXStylesCollector::collectText(unsigned /*id*/, unsigned level, const WPXString & /*text*/) { _handleLevelChange(level); } diff --git a/src/lib/VSDXStylesCollector.h b/src/lib/VSDXStylesCollector.h index 19478ee..031fdfe 100644 --- a/src/lib/VSDXStylesCollector.h +++ b/src/lib/VSDXStylesCollector.h @@ -65,7 +65,8 @@ public: void collectColours(const std::vector<Colour> &colours); - void collectText(unsigned id, unsigned level, const std::string &text); + void collectCharList(unsigned id, unsigned level); + void collectText(unsigned id, unsigned level, const WPXString &text); // Temporary hack void startPage(); |