From 7380feb359560e71a41dcc30c23ac3a506e5bc30 Mon Sep 17 00:00:00 2001 From: Fridrich Štrba Date: Wed, 22 Oct 2014 12:17:37 +0200 Subject: Read XForm1D Change-Id: I1486f876df5dbfa3914440f612af48833317da09 --- src/lib/VDXParser.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++- src/lib/VDXParser.h | 1 + src/lib/VSDParser.cpp | 20 +++++++++++++++- src/lib/VSDParser.h | 1 + src/lib/VSDStencils.cpp | 11 +++++++-- src/lib/VSDStencils.h | 1 + src/lib/VSDTypes.h | 15 ++++++++++++ src/lib/VSDXParser.cpp | 28 +++++++++++++++++++++++ src/lib/tokens.txt | 5 ++++ 9 files changed, 139 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp index ca3f8ec..38b7a6c 100644 --- a/src/lib/VDXParser.cpp +++ b/src/lib/VDXParser.cpp @@ -258,6 +258,10 @@ void libvisio::VDXParser::processXmlNode(xmlTextReaderPtr reader) if (XML_READER_TYPE_ELEMENT == tokenType) readTxtXForm(reader); break; + case XML_XFORM1D: + if (XML_READER_TYPE_ELEMENT == tokenType) + readXForm1D(reader); + break; default: break; } @@ -538,7 +542,7 @@ void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader) tokenId = getElementToken(reader); if (XML_TOKEN_INVALID == tokenId) { - VSD_DEBUG_MSG(("VDXParser::readXFormData: unknown token %s\n", xmlTextReaderConstName(reader))); + VSD_DEBUG_MSG(("VDXParser::readTxtXForm: unknown token %s\n", xmlTextReaderConstName(reader))); } tokenType = xmlTextReaderNodeType(reader); switch (tokenId) @@ -606,6 +610,61 @@ void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader) while ((XML_TEXTXFORM != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret); } +void libvisio::VDXParser::readXForm1D(xmlTextReaderPtr reader) +{ + int ret = 1; + int tokenId = XML_TOKEN_INVALID; + int tokenType = -1; + do + { + ret = xmlTextReaderRead(reader); + tokenId = getElementToken(reader); + if (XML_TOKEN_INVALID == tokenId) + { + VSD_DEBUG_MSG(("VDXParser::readXForm1D: unknown token %s\n", xmlTextReaderConstName(reader))); + } + tokenType = xmlTextReaderNodeType(reader); + switch (tokenId) + { + case XML_BEGINX: + if (XML_READER_TYPE_ELEMENT == tokenType) + { + if (!m_shape.m_xform1d) + m_shape.m_xform1d = new XForm1D(); + ret = readDoubleData(m_shape.m_xform1d->beginX, reader); + } + break; + case XML_BEGINY: + if (XML_READER_TYPE_ELEMENT == tokenType) + { + if (!m_shape.m_xform1d) + m_shape.m_xform1d = new XForm1D(); + ret = readDoubleData(m_shape.m_xform1d->beginY, reader); + } + break; + case XML_ENDX: + if (XML_READER_TYPE_ELEMENT == tokenType) + { + if (!m_shape.m_xform1d) + m_shape.m_xform1d = new XForm1D(); + ret = readDoubleData(m_shape.m_xform1d->endX, reader); + } + break; + case XML_ENDY: + if (XML_READER_TYPE_ELEMENT == tokenType) + { + if (!m_shape.m_xform1d) + m_shape.m_xform1d = new XForm1D(); + ret = readDoubleData(m_shape.m_xform1d->endY, reader); + } + break; + default: + break; + } + } + while ((XML_XFORM1D != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret); +} + void libvisio::VDXParser::readPageProps(xmlTextReaderPtr reader) { double pageWidth = 0.0; diff --git a/src/lib/VDXParser.h b/src/lib/VDXParser.h index 3d64f79..5bca33d 100644 --- a/src/lib/VDXParser.h +++ b/src/lib/VDXParser.h @@ -55,6 +55,7 @@ private: void readXFormData(xmlTextReaderPtr reader); void readMisc(xmlTextReaderPtr reader); void readTxtXForm(xmlTextReaderPtr reader); + void readXForm1D(xmlTextReaderPtr reader); void readPageProps(xmlTextReaderPtr reader); void readFonts(xmlTextReaderPtr reader); void readTextBlock(xmlTextReaderPtr reader); diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp index 1b8133f..a30ba2a 100644 --- a/src/lib/VSDParser.cpp +++ b/src/lib/VSDParser.cpp @@ -415,6 +415,9 @@ void libvisio::VSDParser::handleChunk(librevenge::RVNGInputStream *input) case VSD_XFORM_DATA: readXFormData(input); break; + case VSD_XFORM_1D: + readXForm1D(input); + break; case VSD_TEXT_XFORM: readTxtXForm(input); break; @@ -965,10 +968,25 @@ void libvisio::VSDParser::readXFormData(librevenge::RVNGInputStream *input) m_shape.m_xform.flipY = !!readU8(input); } +void libvisio::VSDParser::readXForm1D(librevenge::RVNGInputStream *input) +{ + if (m_shape.m_xform1d) + delete m_shape.m_xform1d; + m_shape.m_xform1d = new XForm1D(); + input->seek(1, librevenge::RVNG_SEEK_CUR); + m_shape.m_xform1d->beginX = readDouble(input); + input->seek(1, librevenge::RVNG_SEEK_CUR); + m_shape.m_xform1d->beginY = readDouble(input); + input->seek(1, librevenge::RVNG_SEEK_CUR); + m_shape.m_xform1d->endX = readDouble(input); + input->seek(1, librevenge::RVNG_SEEK_CUR); + m_shape.m_xform1d->endY = readDouble(input); +} + void libvisio::VSDParser::readTxtXForm(librevenge::RVNGInputStream *input) { if (m_shape.m_txtxform) - delete(m_shape.m_txtxform); + delete m_shape.m_txtxform; m_shape.m_txtxform = new XForm(); input->seek(1, librevenge::RVNG_SEEK_CUR); m_shape.m_txtxform->pinX = readDouble(input); diff --git a/src/lib/VSDParser.h b/src/lib/VSDParser.h index aabb0db..5864b49 100644 --- a/src/lib/VSDParser.h +++ b/src/lib/VSDParser.h @@ -67,6 +67,7 @@ protected: void readInfiniteLine(librevenge::RVNGInputStream *input); void readShapeData(librevenge::RVNGInputStream *input); void readXFormData(librevenge::RVNGInputStream *input); + void readXForm1D(librevenge::RVNGInputStream *input); void readTxtXForm(librevenge::RVNGInputStream *input); void readShapeId(librevenge::RVNGInputStream *input); virtual void readShapeList(librevenge::RVNGInputStream *input); diff --git a/src/lib/VSDStencils.cpp b/src/lib/VSDStencils.cpp index 8477984..49a8300 100644 --- a/src/lib/VSDStencils.cpp +++ b/src/lib/VSDStencils.cpp @@ -16,7 +16,7 @@ libvisio::VSDShape::VSDShape() m_textStyleId(MINUS_ONE), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_charStyle(), m_themeRef(), m_charList(), m_paraStyle(), m_paraList(), m_text(), m_names(), m_textFormat(libvisio::VSD_TEXT_UTF16), m_nurbsData(), m_polylineData(), m_xform(), m_txtxform(0), - m_misc() + m_xform1d(0), m_misc() { } @@ -29,7 +29,8 @@ libvisio::VSDShape::VSDShape(const libvisio::VSDShape &shape) m_charStyle(shape.m_charStyle), m_themeRef(shape.m_themeRef), m_charList(shape.m_charList), m_paraStyle(shape.m_paraStyle), m_paraList(shape.m_paraList), m_text(shape.m_text), m_names(shape.m_names), m_textFormat(shape.m_textFormat), m_nurbsData(shape.m_nurbsData), m_polylineData(shape.m_polylineData), - m_xform(shape.m_xform), m_txtxform(shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : 0), m_misc(shape.m_misc) + m_xform(shape.m_xform), m_txtxform(shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : 0), + m_xform1d(shape.m_xform1d ? new XForm1D(*(shape.m_xform1d)) : 0), m_misc(shape.m_misc) { } @@ -72,6 +73,9 @@ libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shap if (m_txtxform) delete m_txtxform; m_txtxform = shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : 0; + if (m_xform1d) + delete m_xform1d; + m_xform1d = shape.m_xform1d ? new XForm1D(*(shape.m_xform1d)) : 0; m_misc = shape.m_misc; } return *this; @@ -85,6 +89,9 @@ void libvisio::VSDShape::clear() if (m_txtxform) delete m_txtxform; m_txtxform = 0; + if (m_xform1d) + delete m_xform1d; + m_xform1d = 0; m_geometries.clear(); m_shapeList.clear(); diff --git a/src/lib/VSDStencils.h b/src/lib/VSDStencils.h index 0e9b83d..3d9a14c 100644 --- a/src/lib/VSDStencils.h +++ b/src/lib/VSDStencils.h @@ -53,6 +53,7 @@ public: std::map m_polylineData; XForm m_xform; XForm *m_txtxform; + XForm1D *m_xform1d; VSDMisc m_misc; }; diff --git a/src/lib/VSDTypes.h b/src/lib/VSDTypes.h index 95f05ee..5ac4593 100644 --- a/src/lib/VSDTypes.h +++ b/src/lib/VSDTypes.h @@ -41,6 +41,21 @@ struct XForm }; +struct XForm1D +{ + double beginX; + double beginY; + unsigned beginId; + double endX; + double endY; + unsigned endId; + XForm1D() : beginX(0.0), beginY(0.0), beginId(MINUS_ONE), + endX(0.0), endY(0.0), endId(MINUS_ONE) {} + XForm1D(const XForm1D &xform1d) : beginX(xform1d.beginX), + beginY(xform1d.beginY), beginId(xform1d.beginId), + endX(xform1d.endX), endY(xform1d.endY), endId(xform1d.endId) {} +}; + // Utilities struct ChunkHeader { diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp index 21e2d2c..1160ff0 100644 --- a/src/lib/VSDXParser.cpp +++ b/src/lib/VSDXParser.cpp @@ -1005,6 +1005,34 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader) m_shape.m_txtxform = new XForm(); ret = readDoubleData(m_shape.m_txtxform->angle, reader); } + case XML_BEGINX: + if (XML_READER_TYPE_ELEMENT == tokenType) + { + if (!m_shape.m_xform1d) + m_shape.m_xform1d = new XForm1D(); + ret = readDoubleData(m_shape.m_xform1d->beginX, reader); + } + case XML_BEGINY: + if (XML_READER_TYPE_ELEMENT == tokenType) + { + if (!m_shape.m_xform1d) + m_shape.m_xform1d = new XForm1D(); + ret = readDoubleData(m_shape.m_xform1d->beginY, reader); + } + case XML_ENDX: + if (XML_READER_TYPE_ELEMENT == tokenType) + { + if (!m_shape.m_xform1d) + m_shape.m_xform1d = new XForm1D(); + ret = readDoubleData(m_shape.m_xform1d->endX, reader); + } + case XML_ENDY: + if (XML_READER_TYPE_ELEMENT == tokenType) + { + if (!m_shape.m_xform1d) + m_shape.m_xform1d = new XForm1D(); + ret = readDoubleData(m_shape.m_xform1d->endY, reader); + } break; case XML_IMGOFFSETX: if (XML_READER_TYPE_ELEMENT == tokenType) diff --git a/src/lib/tokens.txt b/src/lib/tokens.txt index 4421b59..3af92bd 100644 --- a/src/lib/tokens.txt +++ b/src/lib/tokens.txt @@ -52,6 +52,8 @@ a:themeElements a:tint B BeginArrow +BeginX +BeginY BottomMargin C Case @@ -71,6 +73,8 @@ E Ellipse EllipticalArcTo EndArrow +EndX +EndY FaceName FaceNames Fill @@ -220,4 +224,5 @@ vt:varStyle Width X XForm +XForm1D Y -- cgit v1.2.3