src/lib/VSD5Parser.cpp | 33 ++++++++++++++++++--------------- src/lib/VSD5Parser.h | 3 +++ src/lib/VSD6Parser.cpp | 11 +++++++++++ src/lib/VSD6Parser.h | 1 + src/lib/VSDCollector.h | 2 +- src/lib/VSDContentCollector.cpp | 3 ++- src/lib/VSDContentCollector.h | 2 +- src/lib/VSDDocumentStructure.h | 3 +++ src/lib/VSDPages.cpp | 5 +++-- src/lib/VSDPages.h | 1 + src/lib/VSDParser.cpp | 37 +++++++++++++++++++++++++++++++++++-- src/lib/VSDParser.h | 4 ++++ src/lib/VSDStylesCollector.cpp | 2 +- src/lib/VSDStylesCollector.h | 2 +- src/lib/VSDXMLParserBase.cpp | 5 ++++- 15 files changed, 89 insertions(+), 25 deletions(-)
New commits: commit 9a4a8eb8e76755bd2aaa287f86a931f7f4030ccc Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Thu Feb 21 15:39:47 2013 +0100 Some initial work on the support of page names diff --git a/src/lib/VSD5Parser.cpp b/src/lib/VSD5Parser.cpp index 55351b1..9d7c164 100644 --- a/src/lib/VSD5Parser.cpp +++ b/src/lib/VSD5Parser.cpp @@ -162,44 +162,47 @@ void libvisio::VSD5Parser::readGeomList(WPXInputStream *input) handleChunkRecords(input); } -void libvisio::VSD5Parser::readCharList(WPXInputStream *input) +void libvisio::VSD5Parser::readList(WPXInputStream *input) { - VSD_DEBUG_MSG(("VSD5Parser::readCharList\n")); if (!m_isStencilStarted) m_collector->collectUnhandledChunk(m_header.id, m_header.level); handleChunkRecords(input); } +void libvisio::VSD5Parser::readCharList(WPXInputStream *input) +{ + VSD_DEBUG_MSG(("VSD5Parser::readCharList\n")); + readList(input); +} + void libvisio::VSD5Parser::readParaList(WPXInputStream *input) { VSD_DEBUG_MSG(("VSD5Parser::readParaList\n")); - if (!m_isStencilStarted) - m_collector->collectUnhandledChunk(m_header.id, m_header.level); - handleChunkRecords(input); + readList(input); } void libvisio::VSD5Parser::readShapeList(WPXInputStream *input) { VSD_DEBUG_MSG(("VSD5Parser::readShapeList\n")); - if (!m_isStencilStarted) - m_collector->collectUnhandledChunk(m_header.id, m_header.level); - handleChunkRecords(input); + readList(input); } void libvisio::VSD5Parser::readPropList(WPXInputStream *input) { VSD_DEBUG_MSG(("VSD5Parser::readPropList\n")); - if (!m_isStencilStarted) - m_collector->collectUnhandledChunk(m_header.id, m_header.level); - handleChunkRecords(input); + readList(input); } void libvisio::VSD5Parser::readFieldList(WPXInputStream *input) { VSD_DEBUG_MSG(("VSD5Parser::readFieldList\n")); - if (!m_isStencilStarted) - m_collector->collectUnhandledChunk(m_header.id, m_header.level); - handleChunkRecords(input); + readList(input); +} + +void libvisio::VSD5Parser::readNameList2(WPXInputStream *input) +{ + VSD_DEBUG_MSG(("VSD5Parser::readNameList2\n")); + readList(input); } void libvisio::VSD5Parser::readLine(WPXInputStream *input) @@ -378,7 +381,7 @@ void libvisio::VSD5Parser::readShape(WPXInputStream *input) void libvisio::VSD5Parser::readPage(WPXInputStream *input) { unsigned backgroundPageID = getUInt(input); - m_collector->collectPage(m_header.id, m_header.level, backgroundPageID, m_isBackgroundPage); + m_collector->collectPage(m_header.id, m_header.level, backgroundPageID, m_isBackgroundPage, WPXString()); } void libvisio::VSD5Parser::readTextBlock(WPXInputStream *input) diff --git a/src/lib/VSD5Parser.h b/src/lib/VSD5Parser.h index ceb73d6..4430e1c 100644 --- a/src/lib/VSD5Parser.h +++ b/src/lib/VSD5Parser.h @@ -58,6 +58,7 @@ protected: virtual void readShapeList(WPXInputStream *input); virtual void readPropList(WPXInputStream *input); virtual void readFieldList(WPXInputStream *input); + virtual void readNameList2(WPXInputStream *input); virtual void readLine(WPXInputStream *input); virtual void readFillAndShadow(WPXInputStream *input); @@ -79,6 +80,8 @@ private: VSD5Parser(); VSD5Parser(const VSDParser &); VSD5Parser &operator=(const VSDParser &); + + void readList(WPXInputStream *input); }; } // namespace libvisio diff --git a/src/lib/VSD6Parser.cpp b/src/lib/VSD6Parser.cpp index 645d569..a34862b 100644 --- a/src/lib/VSD6Parser.cpp +++ b/src/lib/VSD6Parser.cpp @@ -282,6 +282,17 @@ void libvisio::VSD6Parser::readName(WPXInputStream *input) } } +void libvisio::VSD6Parser::readName2(WPXInputStream *input) +{ + unsigned char character = 0; + ::WPXBinaryData name; + getInt(input); // skip a dword that seems to be always 1 + while ((character = readU8(input))) + name.append(character); + name.append(character); + m_names[m_header.id] = VSDName(name, libvisio::VSD_TEXT_ANSI); +} + void libvisio::VSD6Parser::readTextField(WPXInputStream *input) { unsigned long initialPosition = input->tell(); diff --git a/src/lib/VSD6Parser.h b/src/lib/VSD6Parser.h index 6550324..dd7663b 100644 --- a/src/lib/VSD6Parser.h +++ b/src/lib/VSD6Parser.h @@ -54,6 +54,7 @@ private: virtual void readParaIX(WPXInputStream *input); virtual void readFillAndShadow(WPXInputStream *input); virtual void readName(WPXInputStream *input); + virtual void readName2(WPXInputStream *input); virtual void readTextField(WPXInputStream *input); VSD6Parser(); diff --git a/src/lib/VSDCollector.h b/src/lib/VSDCollector.h index 1c88eaa..1633726 100644 --- a/src/lib/VSDCollector.h +++ b/src/lib/VSDCollector.h @@ -79,7 +79,7 @@ public: virtual void collectShapesOrder(unsigned id, unsigned level, const std::vector<unsigned> &shapeIds) = 0; virtual void collectForeignDataType(unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height) = 0; virtual void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale) = 0; - virtual void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, bool isBackgroundPage) = 0; + virtual void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, bool isBackgroundPage, const WPXString &pageName) = 0; virtual void collectShape(unsigned id, unsigned level, unsigned parent, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle) = 0; virtual void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) = 0; virtual void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot) = 0; diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp index cbe2bcb..09b268b 100644 --- a/src/lib/VSDContentCollector.cpp +++ b/src/lib/VSDContentCollector.cpp @@ -1699,10 +1699,11 @@ void libvisio::VSDContentCollector::collectPageProps(unsigned /* id */, unsigned m_currentPage.m_pageHeight = m_scale*m_pageHeight; } -void libvisio::VSDContentCollector::collectPage(unsigned /* id */, unsigned level, unsigned backgroundPageID, bool isBackgroundPage) +void libvisio::VSDContentCollector::collectPage(unsigned /* id */, unsigned level, unsigned backgroundPageID, bool isBackgroundPage, const WPXString &pageName) { _handleLevelChange(level); m_currentPage.m_backgroundPageID = backgroundPageID; + m_currentPage.m_pageName = pageName; m_isBackgroundPage = isBackgroundPage; } diff --git a/src/lib/VSDContentCollector.h b/src/lib/VSDContentCollector.h index bf8e728..0c273c2 100644 --- a/src/lib/VSDContentCollector.h +++ b/src/lib/VSDContentCollector.h @@ -100,7 +100,7 @@ public: void collectShapesOrder(unsigned id, unsigned level, const std::vector<unsigned> &shapeIds); void collectForeignDataType(unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height); void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale); - void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, bool isBackgroundPage); + void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, bool isBackgroundPage, const WPXString &pageName); void collectShape(unsigned id, unsigned level, unsigned parent, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle); void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree); void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot); diff --git a/src/lib/VSDDocumentStructure.h b/src/lib/VSDDocumentStructure.h index ee9296f..ae0fd62 100644 --- a/src/lib/VSDDocumentStructure.h +++ b/src/lib/VSDDocumentStructure.h @@ -50,6 +50,9 @@ #define VSD_NAME_LIST 0x2c #define VSD_NAME 0x2d +#define VSD_NAME_LIST2 0x32 +#define VSD_NAME2 0x33 + #define VSD_PAGE_SHEET 0x46 #define VSD_SHAPE_GROUP 0x47 #define VSD_SHAPE_SHAPE 0x48 diff --git a/src/lib/VSDPages.cpp b/src/lib/VSDPages.cpp index 0e741dc..81d2b84 100644 --- a/src/lib/VSDPages.cpp +++ b/src/lib/VSDPages.cpp @@ -32,14 +32,14 @@ #include "libvisio_utils.h" libvisio::VSDPage::VSDPage() - : m_pageWidth(0.0), m_pageHeight(0.0), + : m_pageWidth(0.0), m_pageHeight(0.0), m_pageName(), m_currentPageID(0), m_backgroundPageID(MINUS_ONE), m_pageElements() { } libvisio::VSDPage::VSDPage(const libvisio::VSDPage &page) - : m_pageWidth(page.m_pageWidth), m_pageHeight(page.m_pageHeight), + : m_pageWidth(page.m_pageWidth), m_pageHeight(page.m_pageHeight), m_pageName(page.m_pageName), m_currentPageID(page.m_currentPageID), m_backgroundPageID(page.m_backgroundPageID), m_pageElements(page.m_pageElements) { @@ -55,6 +55,7 @@ libvisio::VSDPage &libvisio::VSDPage::operator=(const libvisio::VSDPage &page) { m_pageWidth = page.m_pageWidth; m_pageHeight = page.m_pageHeight; + m_pageName = page.m_pageName; m_currentPageID = page.m_currentPageID; m_backgroundPageID = page.m_backgroundPageID; m_pageElements = page.m_pageElements; diff --git a/src/lib/VSDPages.h b/src/lib/VSDPages.h index 49497ac..98c0b5e 100644 --- a/src/lib/VSDPages.h +++ b/src/lib/VSDPages.h @@ -46,6 +46,7 @@ public: void append(const VSDOutputElementList &outputElements); void draw(libwpg::WPGPaintInterface *painter) const; double m_pageWidth, m_pageHeight; + WPXString m_pageName; unsigned m_currentPageID, m_backgroundPageID; VSDOutputElementList m_pageElements; }; diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp index bab29b6..e5aca03 100644 --- a/src/lib/VSDParser.cpp +++ b/src/lib/VSDParser.cpp @@ -46,7 +46,7 @@ libvisio::VSDParser::VSDParser(WPXInputStream *input, libwpg::WPGPaintInterface m_stencils(), m_currentStencil(0), m_shape(), m_isStencilStarted(false), m_isInStyles(false), m_currentShapeLevel(0), m_currentShapeID(MINUS_ONE), m_extractStencils(false), m_colours(), m_isBackgroundPage(false), m_isShapeStarted(false), m_shadowOffsetX(0.0), m_shadowOffsetY(0.0), - m_currentGeometryList(0), m_currentGeomListCount(0), m_fonts() + m_currentGeometryList(0), m_currentGeomListCount(0), m_fonts(), m_names() {} libvisio::VSDParser::~VSDParser() @@ -196,6 +196,7 @@ void libvisio::VSDParser::handleStreams(WPXInputStream *input, unsigned ptrType, std::vector<unsigned> pointerOrder; std::map<unsigned, libvisio::Pointer> PtrList; std::map<unsigned, libvisio::Pointer> FontFaces; + std::map<unsigned, libvisio::Pointer> NameList; try { @@ -209,6 +210,8 @@ void libvisio::VSDParser::handleStreams(WPXInputStream *input, unsigned ptrType, readPointer(input, ptr); if (ptr.Type == VSD_FONTFACES) FontFaces[i] = ptr; + else if (ptr.Type == VSD_NAME_LIST2) + NameList[i] = ptr; else if (ptr.Type != 0) PtrList[i] = ptr; } @@ -222,12 +225,16 @@ void libvisio::VSDParser::handleStreams(WPXInputStream *input, unsigned ptrType, pointerOrder.clear(); PtrList.clear(); FontFaces.clear(); + NameList.clear(); } std::map<unsigned, libvisio::Pointer>::iterator iter; for (iter = FontFaces.begin(); iter != FontFaces.end(); ++iter) handleStream(iter->second, iter->first, level+1); + for (iter = NameList.begin(); iter != NameList.end(); ++iter) + handleStream(iter->second, iter->first, level+1); + if (!pointerOrder.empty()) { for (unsigned j=0; j < pointerOrder.size(); ++j) @@ -513,9 +520,15 @@ void libvisio::VSDParser::handleChunk(WPXInputStream *input) case VSD_NAME_LIST: readNameList(input); break; + case VSD_NAME_LIST2: + readNameList2(input); + break; case VSD_NAME: readName(input); break; + case VSD_NAME2: + readName2(input); + break; case VSD_FIELD_LIST: readFieldList(input); break; @@ -831,7 +844,7 @@ void libvisio::VSDParser::readPage(WPXInputStream *input) { input->seek(8, WPX_SEEK_CUR); //sub header length and children list length unsigned backgroundPageID = readU32(input); - m_collector->collectPage(m_header.id, m_header.level, backgroundPageID, m_isBackgroundPage); + m_collector->collectPage(m_header.id, m_header.level, backgroundPageID, m_isBackgroundPage, WPXString()); } void libvisio::VSDParser::readGeometry(WPXInputStream *input) @@ -1413,6 +1426,11 @@ void libvisio::VSDParser::readNameList(WPXInputStream * /* input */) m_shape.m_names.clear(); } +void libvisio::VSDParser::readNameList2(WPXInputStream * /* input */) +{ + m_names.clear(); +} + void libvisio::VSDParser::readFieldList(WPXInputStream *input) { if (m_header.trailer) @@ -1744,6 +1762,21 @@ void libvisio::VSDParser::readName(WPXInputStream *input) } } +void libvisio::VSDParser::readName2(WPXInputStream *input) +{ + unsigned short unicharacter = 0; + ::WPXBinaryData name; + input->seek(4, WPX_SEEK_CUR); // skip a dword that seems to be always 1 + while ((unicharacter = readU16(input))) + { + name.append(unicharacter & 0xff); + name.append((unicharacter & 0xff00) >> 8); + } + name.append(unicharacter & 0xff); + name.append((unicharacter & 0xff00) >> 8); + m_names[m_header.id] = VSDName(name, libvisio::VSD_TEXT_UTF16); +} + void libvisio::VSDParser::readTextField(WPXInputStream *input) { unsigned long initialPosition = input->tell(); diff --git a/src/lib/VSDParser.h b/src/lib/VSDParser.h index 3fa8c4a..13498e1 100644 --- a/src/lib/VSDParser.h +++ b/src/lib/VSDParser.h @@ -110,6 +110,9 @@ protected: void readNameList(WPXInputStream *input); virtual void readName(WPXInputStream *input); + virtual void readNameList2(WPXInputStream *input); + virtual void readName2(WPXInputStream *input); + virtual void readFieldList(WPXInputStream *input); virtual void readTextField(WPXInputStream *input); @@ -172,6 +175,7 @@ protected: unsigned m_currentGeomListCount; std::map<unsigned, VSDName> m_fonts; + std::map<unsigned, VSDName> m_names; private: VSDParser(); diff --git a/src/lib/VSDStylesCollector.cpp b/src/lib/VSDStylesCollector.cpp index eeaad50..452f8bd 100644 --- a/src/lib/VSDStylesCollector.cpp +++ b/src/lib/VSDStylesCollector.cpp @@ -244,7 +244,7 @@ void libvisio::VSDStylesCollector::collectPageProps(unsigned /* id */, unsigned _handleLevelChange(level); } -void libvisio::VSDStylesCollector::collectPage(unsigned /* id */, unsigned level, unsigned /* backgroundPageID */, bool /* isBackgroundPage */) +void libvisio::VSDStylesCollector::collectPage(unsigned /* id */, unsigned level, unsigned /* backgroundPageID */, bool /* isBackgroundPage */, const WPXString & /* pageName */) { _handleLevelChange(level); } diff --git a/src/lib/VSDStylesCollector.h b/src/lib/VSDStylesCollector.h index 2d22f8e..ce8d696 100644 --- a/src/lib/VSDStylesCollector.h +++ b/src/lib/VSDStylesCollector.h @@ -91,7 +91,7 @@ public: void collectShapesOrder(unsigned id, unsigned level, const std::vector<unsigned> &shapeIds); void collectForeignDataType(unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height); void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale); - void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, bool isBackgroundPage); + void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, bool isBackgroundPage, const WPXString &pageName); void collectShape(unsigned id, unsigned level, unsigned parent, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle); void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree); void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot); diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp index 4174e16..2885f45 100644 --- a/src/lib/VSDXMLParserBase.cpp +++ b/src/lib/VSDXMLParserBase.cpp @@ -1097,6 +1097,7 @@ void libvisio::VSDXMLParserBase::readPage(xmlTextReaderPtr reader) xmlChar *id = xmlTextReaderGetAttribute(reader, BAD_CAST("ID")); xmlChar *bgndPage = xmlTextReaderGetAttribute(reader, BAD_CAST("BackPage")); xmlChar *background = xmlTextReaderGetAttribute(reader, BAD_CAST("Background")); + xmlChar *pageName = xmlTextReaderGetAttribute(reader, BAD_CAST("NameU")); if (id) { unsigned nId = (unsigned)xmlStringToLong(id); @@ -1104,7 +1105,7 @@ void libvisio::VSDXMLParserBase::readPage(xmlTextReaderPtr reader) bool isBackgroundPage = background ? xmlStringToBool(background) : false; m_isPageStarted = true; m_collector->startPage(nId); - m_collector->collectPage(nId, (unsigned)getElementDepth(reader), backgroundPageID, isBackgroundPage); + m_collector->collectPage(nId, (unsigned)getElementDepth(reader), backgroundPageID, isBackgroundPage, pageName ? WPXString((const char *)pageName) : WPXString()); } if (id) xmlFree(id); @@ -1112,6 +1113,8 @@ void libvisio::VSDXMLParserBase::readPage(xmlTextReaderPtr reader) xmlFree(bgndPage); if (background) xmlFree(background); + if (pageName) + xmlFree(pageName); } void libvisio::VSDXMLParserBase::readText(xmlTextReaderPtr reader)
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits