diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-09-18 17:01:12 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-09-18 17:01:58 +0200 |
commit | 006e0a44f9cf2a70cb2da31c0667bd882df06d84 (patch) | |
tree | dfd720786099bf159cc96d098d20973c36cb975b | |
parent | 96a2aff0c44b216d8f22dfbf4d86918393b8ea08 (diff) |
Prepare for the new VSDX file-format (ooxml version)
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | src/lib/Makefile.am | 56 | ||||
-rw-r--r-- | src/lib/VSD11Parser.cpp | 18 | ||||
-rw-r--r-- | src/lib/VSD11Parser.h | 8 | ||||
-rw-r--r-- | src/lib/VSD6Parser.cpp | 18 | ||||
-rw-r--r-- | src/lib/VSD6Parser.h | 8 | ||||
-rw-r--r-- | src/lib/VSDCharacterList.cpp (renamed from src/lib/VSDXCharacterList.cpp) | 64 | ||||
-rw-r--r-- | src/lib/VSDCharacterList.h (renamed from src/lib/VSDXCharacterList.h) | 28 | ||||
-rw-r--r-- | src/lib/VSDCollector.h (renamed from src/lib/VSDXCollector.h) | 26 | ||||
-rw-r--r-- | src/lib/VSDContentCollector.cpp (renamed from src/lib/VSDXContentCollector.cpp) | 220 | ||||
-rw-r--r-- | src/lib/VSDContentCollector.h (renamed from src/lib/VSDXContentCollector.h) | 70 | ||||
-rw-r--r-- | src/lib/VSDDocumentStructure.h (renamed from src/lib/VSDXDocumentStructure.h) | 6 | ||||
-rw-r--r-- | src/lib/VSDFieldList.cpp (renamed from src/lib/VSDXFieldList.cpp) | 64 | ||||
-rw-r--r-- | src/lib/VSDFieldList.h (renamed from src/lib/VSDXFieldList.h) | 58 | ||||
-rw-r--r-- | src/lib/VSDGeometryList.cpp | 492 | ||||
-rw-r--r-- | src/lib/VSDGeometryList.h (renamed from src/lib/VSDXGeometryList.h) | 56 | ||||
-rw-r--r-- | src/lib/VSDInternalStream.cpp | 7 | ||||
-rw-r--r-- | src/lib/VSDInternalStream.h | 3 | ||||
-rw-r--r-- | src/lib/VSDOutputElementList.cpp | 441 | ||||
-rw-r--r-- | src/lib/VSDOutputElementList.h (renamed from src/lib/VSDXOutputElementList.h) | 22 | ||||
-rw-r--r-- | src/lib/VSDPages.cpp (renamed from src/lib/VSDXPages.cpp) | 28 | ||||
-rw-r--r-- | src/lib/VSDPages.h (renamed from src/lib/VSDXPages.h) | 34 | ||||
-rw-r--r-- | src/lib/VSDParagraphList.cpp (renamed from src/lib/VSDXParagraphList.cpp) | 58 | ||||
-rw-r--r-- | src/lib/VSDParagraphList.h (renamed from src/lib/VSDXParagraphList.h) | 24 | ||||
-rw-r--r-- | src/lib/VSDParser.cpp (renamed from src/lib/VSDXParser.cpp) | 142 | ||||
-rw-r--r-- | src/lib/VSDParser.h (renamed from src/lib/VSDXParser.h) | 58 | ||||
-rw-r--r-- | src/lib/VSDShapeList.cpp (renamed from src/lib/VSDXShapeList.cpp) | 40 | ||||
-rw-r--r-- | src/lib/VSDShapeList.h (renamed from src/lib/VSDXShapeList.h) | 18 | ||||
-rw-r--r-- | src/lib/VSDStencils.cpp (renamed from src/lib/VSDXStencils.cpp) | 54 | ||||
-rw-r--r-- | src/lib/VSDStencils.h (renamed from src/lib/VSDXStencils.h) | 68 | ||||
-rw-r--r-- | src/lib/VSDStyles.cpp (renamed from src/lib/VSDXStyles.cpp) | 126 | ||||
-rw-r--r-- | src/lib/VSDStyles.h (renamed from src/lib/VSDXStyles.h) | 90 | ||||
-rw-r--r-- | src/lib/VSDStylesCollector.cpp (renamed from src/lib/VSDXStylesCollector.cpp) | 120 | ||||
-rw-r--r-- | src/lib/VSDStylesCollector.h (renamed from src/lib/VSDXStylesCollector.h) | 44 | ||||
-rw-r--r-- | src/lib/VSDTypes.h (renamed from src/lib/VSDXTypes.h) | 16 | ||||
-rw-r--r-- | src/lib/VSDXGeometryList.cpp | 492 | ||||
-rw-r--r-- | src/lib/VSDXOutputElementList.cpp | 441 | ||||
-rw-r--r-- | src/lib/VSDZipStream.cpp | 395 | ||||
-rw-r--r-- | src/lib/VSDZipStream.h | 64 | ||||
-rw-r--r-- | src/lib/VisioDocument.cpp | 6 | ||||
-rw-r--r-- | src/lib/makefile.mk | 24 |
41 files changed, 2251 insertions, 1769 deletions
diff --git a/configure.ac b/configure.ac index f4398d9..cbbe94f 100644 --- a/configure.ac +++ b/configure.ac @@ -41,8 +41,21 @@ PKG_CHECK_MODULES([LIBVISIO],[ libwpd-0.9 libwpd-stream-0.9 libwpg-0.2 + libxml-2.0 ]) +# ========= +# Find zlib +# ========= +PKG_CHECK_MODULES([ZLIB],[zlib],[],[ + AC_CHECK_HEADER(zlib.h, [ZLIB_CFLAGS=], + [AC_MSG_ERROR(zlib.h not found. install zlib)], []) + AC_CHECK_LIB(z, inflate, [ ZLIB_LIBS=-lz ], + [AC_MSG_ERROR(zlib not found or functional)], []) +]) +AC_SUBST(ZLIB_CFLAGS) +AC_SUBST(ZLIB_LIBS) + # =========================== # Find required boost headers # =========================== diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index ebe1a9a..ab6b2d5 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -23,39 +23,41 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \ VSD6Parser.cpp \ VSDInternalStream.cpp \ VSDSVGGenerator.cpp \ - VSDXCharacterList.cpp \ - VSDXContentCollector.cpp \ - VSDXFieldList.cpp \ - VSDXGeometryList.cpp \ - VSDXOutputElementList.cpp \ - VSDXPages.cpp \ - VSDXParagraphList.cpp \ - VSDXParser.cpp \ - VSDXShapeList.cpp \ - VSDXStencils.cpp \ + VSDCharacterList.cpp \ + VSDContentCollector.cpp \ + VSDFieldList.cpp \ + VSDGeometryList.cpp \ + VSDOutputElementList.cpp \ + VSDPages.cpp \ + VSDParagraphList.cpp \ + VSDParser.cpp \ + VSDShapeList.cpp \ + VSDStencils.cpp \ VSDStringVector.cpp \ - VSDXStyles.cpp \ - VSDXStylesCollector.cpp \ + VSDStyles.cpp \ + VSDStylesCollector.cpp \ + VSDZipStream.cpp \ libvisio_utils.h \ VSD11Parser.h \ VSD6Parser.h \ VSDInternalStream.h \ VSDSVGGenerator.h \ - VSDXCharacterList.h \ - VSDXCollector.h \ - VSDXContentCollector.h \ - VSDXDocumentStructure.h \ - VSDXFieldList.h \ - VSDXGeometryList.h \ - VSDXOutputElementList.h \ - VSDXPages.h \ - VSDXParagraphList.h \ - VSDXParser.h \ - VSDXShapeList.h \ - VSDXStencils.h \ - VSDXStyles.h \ - VSDXStylesCollector.h \ - VSDXTypes.h + VSDCharacterList.h \ + VSDCollector.h \ + VSDContentCollector.h \ + VSDDocumentStructure.h \ + VSDFieldList.h \ + VSDGeometryList.h \ + VSDOutputElementList.h \ + VSDPages.h \ + VSDParagraphList.h \ + VSDParser.h \ + VSDShapeList.h \ + VSDStencils.h \ + VSDStyles.h \ + VSDStylesCollector.h \ + VSDTypes.h \ + VSDZipStream.h if OS_WIN32 diff --git a/src/lib/VSD11Parser.cpp b/src/lib/VSD11Parser.cpp index 9d848a8..841f9d2 100644 --- a/src/lib/VSD11Parser.cpp +++ b/src/lib/VSD11Parser.cpp @@ -35,12 +35,12 @@ #include "libvisio_utils.h" #include "VSD11Parser.h" #include "VSDInternalStream.h" -#include "VSDXDocumentStructure.h" -#include "VSDXContentCollector.h" -#include "VSDXStylesCollector.h" +#include "VSDDocumentStructure.h" +#include "VSDContentCollector.h" +#include "VSDStylesCollector.h" libvisio::VSD11Parser::VSD11Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter) - : VSDXParser(input, painter) + : VSDParser(input, painter) {} libvisio::VSD11Parser::~VSD11Parser() @@ -123,7 +123,7 @@ void libvisio::VSD11Parser::readText(WPXInputStream *input) void libvisio::VSD11Parser::readCharIX(WPXInputStream *input) { - VSDXFont fontFace; + VSDFont fontFace; unsigned charCount = readU32(input); unsigned short fontID = readU16(input); input->seek(1, WPX_SEEK_CUR); // Color ID @@ -172,7 +172,7 @@ void libvisio::VSD11Parser::readCharIX(WPXInputStream *input) { VSD_DEBUG_MSG(("Found stencil character style\n")); if (!m_stencilShape.m_charStyle) - m_stencilShape.m_charStyle= new VSDXCharStyle(charCount, fontID, fontColour, fontSize, + m_stencilShape.m_charStyle= new VSDCharStyle(charCount, fontID, fontColour, fontSize, bold, italic, underline, doubleunderline, strikeout, doublestrikeout, allcaps, initcaps, smallcaps, superscript, subscript, fontFace); } @@ -208,7 +208,7 @@ void libvisio::VSD11Parser::readParaIX(WPXInputStream *input) { VSD_DEBUG_MSG(("Found stencil paragraph style\n")); if (!m_stencilShape.m_paraStyle) - m_stencilShape.m_paraStyle= new VSDXParaStyle(charCount, indFirst, indLeft, indRight, + m_stencilShape.m_paraStyle= new VSDParaStyle(charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align, flags); } else @@ -248,7 +248,7 @@ void libvisio::VSD11Parser::readFillAndShadow(WPXInputStream *input) { VSD_DEBUG_MSG(("Found stencil fill\n")); if (!m_stencilShape.m_fillStyle) - m_stencilShape.m_fillStyle = new VSDXFillStyle(colourIndexFG, colourIndexBG, fillPattern, + m_stencilShape.m_fillStyle = new VSDFillStyle(colourIndexFG, colourIndexBG, fillPattern, fillFGTransparency, fillBGTransparency, shfgc, shadowPattern, shadowOffsetX, shadowOffsetY); } @@ -266,7 +266,7 @@ void libvisio::VSD11Parser::readName(WPXInputStream *input) name.append(readU8(input)); if (m_isStencilStarted) - m_stencilShape.m_names[m_header.id] = VSDXName(name, libvisio::VSD_TEXT_UTF16); + m_stencilShape.m_names[m_header.id] = VSDName(name, libvisio::VSD_TEXT_UTF16); else m_collector->collectName(m_header.id, m_header.level, name, libvisio::VSD_TEXT_UTF16); } diff --git a/src/lib/VSD11Parser.h b/src/lib/VSD11Parser.h index d9aa35f..3557af9 100644 --- a/src/lib/VSD11Parser.h +++ b/src/lib/VSD11Parser.h @@ -35,13 +35,13 @@ #include <iostream> #include <libwpd/libwpd.h> #include <libwpg/libwpg.h> -#include "VSDXParser.h" +#include "VSDParser.h" #include "VSDInternalStream.h" namespace libvisio { -class VSD11Parser : public VSDXParser +class VSD11Parser : public VSDParser { public: explicit VSD11Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter); @@ -56,8 +56,8 @@ private: void readTextField(WPXInputStream *input); VSD11Parser(); - VSD11Parser(const VSDXParser &); - VSD11Parser &operator=(const VSDXParser &); + VSD11Parser(const VSDParser &); + VSD11Parser &operator=(const VSDParser &); }; } // namespace libvisio diff --git a/src/lib/VSD6Parser.cpp b/src/lib/VSD6Parser.cpp index 2ed034f..f968fd1 100644 --- a/src/lib/VSD6Parser.cpp +++ b/src/lib/VSD6Parser.cpp @@ -35,12 +35,12 @@ #include "libvisio_utils.h" #include "VSD6Parser.h" #include "VSDInternalStream.h" -#include "VSDXDocumentStructure.h" -#include "VSDXContentCollector.h" -#include "VSDXStylesCollector.h" +#include "VSDDocumentStructure.h" +#include "VSDContentCollector.h" +#include "VSDStylesCollector.h" libvisio::VSD6Parser::VSD6Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter) - : VSDXParser(input, painter) + : VSDParser(input, painter) {} libvisio::VSD6Parser::~VSD6Parser() @@ -104,7 +104,7 @@ void libvisio::VSD6Parser::readText(WPXInputStream *input) void libvisio::VSD6Parser::readCharIX(WPXInputStream *input) { - VSDXFont fontFace; + VSDFont fontFace; unsigned charCount = readU32(input); unsigned short fontID = readU16(input); input->seek(1, WPX_SEEK_CUR); // Color ID @@ -153,7 +153,7 @@ void libvisio::VSD6Parser::readCharIX(WPXInputStream *input) { VSD_DEBUG_MSG(("Found stencil character style\n")); if (!m_stencilShape.m_charStyle) - m_stencilShape.m_charStyle= new VSDXCharStyle(charCount, fontID, fontColour, fontSize, + m_stencilShape.m_charStyle= new VSDCharStyle(charCount, fontID, fontColour, fontSize, bold, italic, underline, doubleunderline, strikeout, doublestrikeout, allcaps, initcaps, smallcaps, superscript, subscript, fontFace); } @@ -187,7 +187,7 @@ void libvisio::VSD6Parser::readParaIX(WPXInputStream *input) { VSD_DEBUG_MSG(("Found stencil paragraph style\n")); if (!m_stencilShape.m_paraStyle) - m_stencilShape.m_paraStyle= new VSDXParaStyle(charCount, indFirst, indLeft, indRight, + m_stencilShape.m_paraStyle= new VSDParaStyle(charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align, 0); } else @@ -220,7 +220,7 @@ void libvisio::VSD6Parser::readFillAndShadow(WPXInputStream *input) else if (m_isStencilStarted) { if (!m_stencilShape.m_fillStyle) - m_stencilShape.m_fillStyle = new VSDXFillStyle(colourIndexFG, colourIndexBG, fillPattern, + m_stencilShape.m_fillStyle = new VSDFillStyle(colourIndexFG, colourIndexBG, fillPattern, fillFGTransparency, fillBGTransparency, shfgc, shadowPattern, m_currentStencil->m_shadowOffsetX, m_currentStencil->m_shadowOffsetY); } @@ -238,7 +238,7 @@ void libvisio::VSD6Parser::readName(WPXInputStream *input) if (m_isStencilStarted) { - m_stencilShape.m_names[m_header.id] = VSDXName(name, libvisio::VSD_TEXT_ANSI); + m_stencilShape.m_names[m_header.id] = VSDName(name, libvisio::VSD_TEXT_ANSI); } else m_collector->collectName(m_header.id, m_header.level, name, libvisio::VSD_TEXT_ANSI); diff --git a/src/lib/VSD6Parser.h b/src/lib/VSD6Parser.h index c62397c..6c403b5 100644 --- a/src/lib/VSD6Parser.h +++ b/src/lib/VSD6Parser.h @@ -35,13 +35,13 @@ #include <iostream> #include <libwpd/libwpd.h> #include <libwpg/libwpg.h> -#include "VSDXParser.h" +#include "VSDParser.h" #include "VSDInternalStream.h" namespace libvisio { -class VSD6Parser : public VSDXParser +class VSD6Parser : public VSDParser { public: explicit VSD6Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter); @@ -56,8 +56,8 @@ private: void readTextField(WPXInputStream *input); VSD6Parser(); - VSD6Parser(const VSDXParser &); - VSD6Parser &operator=(const VSDXParser &); + VSD6Parser(const VSDParser &); + VSD6Parser &operator=(const VSDParser &); }; } // namespace libvisio diff --git a/src/lib/VSDXCharacterList.cpp b/src/lib/VSDCharacterList.cpp index 6aa2edc..24aa5bf 100644 --- a/src/lib/VSDXCharacterList.cpp +++ b/src/lib/VSDCharacterList.cpp @@ -28,34 +28,34 @@ * instead of those above. */ -#include "VSDXCollector.h" -#include "VSDXCharacterList.h" +#include "VSDCollector.h" +#include "VSDCharacterList.h" namespace libvisio { -class VSDXCharacterListElement +class VSDCharacterListElement { public: - VSDXCharacterListElement() {} - virtual ~VSDXCharacterListElement() {} - virtual void handle(VSDXCollector *collector) = 0; - virtual VSDXCharacterListElement *clone() = 0; + VSDCharacterListElement() {} + virtual ~VSDCharacterListElement() {} + virtual void handle(VSDCollector *collector) = 0; + virtual VSDCharacterListElement *clone() = 0; }; -class VSDXCharIX : public VSDXCharacterListElement +class VSDCharIX : public VSDCharacterListElement { public: - VSDXCharIX(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, + VSDCharIX(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace) : + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace) : m_id(id), m_level(level), m_charCount(charCount), m_fontID(fontID), m_fontColour(fontColour), m_fontSize(fontSize), m_bold(bold), m_italic(italic), m_underline(underline), m_doubleunderline(doubleunderline), m_strikeout(strikeout), m_doublestrikeout(doublestrikeout), m_allcaps(allcaps), m_initcaps(initcaps), m_smallcaps(smallcaps), m_superscript(superscript), m_subscript(subscript), m_fontFace(fontFace) {} - ~VSDXCharIX() {} - void handle(VSDXCollector *collector); - VSDXCharacterListElement *clone(); + ~VSDCharIX() {} + void handle(VSDCollector *collector); + VSDCharacterListElement *clone(); private: unsigned m_id, m_level; unsigned m_charCount; @@ -64,76 +64,76 @@ private: double m_fontSize; bool m_bold, m_italic, m_underline, m_doubleunderline, m_strikeout, m_doublestrikeout; bool m_allcaps, m_initcaps, m_smallcaps, m_superscript, m_subscript; - VSDXFont m_fontFace; + VSDFont m_fontFace; }; } // namespace libvisio -void libvisio::VSDXCharIX::handle(VSDXCollector *collector) +void libvisio::VSDCharIX::handle(VSDCollector *collector) { - collector->collectVSDXCharStyle(m_id, m_level, m_charCount, m_fontID, m_fontColour, m_fontSize, m_bold, m_italic, m_underline, + collector->collectVSDCharStyle(m_id, m_level, m_charCount, m_fontID, m_fontColour, m_fontSize, m_bold, m_italic, m_underline, m_doubleunderline, m_strikeout, m_doublestrikeout, m_allcaps, m_initcaps, m_smallcaps, m_superscript, m_subscript, m_fontFace); } -libvisio::VSDXCharacterListElement *libvisio::VSDXCharIX::clone() +libvisio::VSDCharacterListElement *libvisio::VSDCharIX::clone() { - return new VSDXCharIX(m_id, m_level, m_charCount, m_fontID, m_fontColour, m_fontSize, m_bold, m_italic, m_underline, + return new VSDCharIX(m_id, m_level, m_charCount, m_fontID, m_fontColour, m_fontSize, m_bold, m_italic, m_underline, m_doubleunderline, m_strikeout, m_doublestrikeout, m_allcaps, m_initcaps, m_smallcaps, m_superscript, m_subscript, m_fontFace); } -libvisio::VSDXCharacterList::VSDXCharacterList() : +libvisio::VSDCharacterList::VSDCharacterList() : m_elements(), m_elementsOrder() { } -libvisio::VSDXCharacterList::VSDXCharacterList(const libvisio::VSDXCharacterList &charList) : +libvisio::VSDCharacterList::VSDCharacterList(const libvisio::VSDCharacterList &charList) : m_elements(), m_elementsOrder(charList.m_elementsOrder) { - std::map<unsigned, VSDXCharacterListElement *>::const_iterator iter = charList.m_elements.begin(); + std::map<unsigned, VSDCharacterListElement *>::const_iterator iter = charList.m_elements.begin(); for (; iter != charList.m_elements.end(); ++iter) m_elements[iter->first] = iter->second->clone(); } -libvisio::VSDXCharacterList &libvisio::VSDXCharacterList::operator=(const libvisio::VSDXCharacterList &charList) +libvisio::VSDCharacterList &libvisio::VSDCharacterList::operator=(const libvisio::VSDCharacterList &charList) { clear(); - std::map<unsigned, VSDXCharacterListElement *>::const_iterator iter = charList.m_elements.begin(); + std::map<unsigned, VSDCharacterListElement *>::const_iterator iter = charList.m_elements.begin(); for (; iter != charList.m_elements.end(); ++iter) m_elements[iter->first] = iter->second->clone(); m_elementsOrder = charList.m_elementsOrder; return *this; } -libvisio::VSDXCharacterList::~VSDXCharacterList() +libvisio::VSDCharacterList::~VSDCharacterList() { clear(); } -void libvisio::VSDXCharacterList::addCharIX(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, +void libvisio::VSDCharacterList::addCharIX(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace) + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace) { - m_elements[id] = new VSDXCharIX(id, level, charCount, fontID, fontColour, fontSize, bold, italic, underline, doubleunderline, + m_elements[id] = new VSDCharIX(id, level, charCount, fontID, fontColour, fontSize, bold, italic, underline, doubleunderline, strikeout, doublestrikeout, allcaps, initcaps, smallcaps, superscript, subscript, fontFace); } -void libvisio::VSDXCharacterList::setElementsOrder(const std::vector<unsigned> &elementsOrder) +void libvisio::VSDCharacterList::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) +void libvisio::VSDCharacterList::handle(VSDCollector *collector) { if (empty()) return; - std::map<unsigned, VSDXCharacterListElement *>::iterator iter; + std::map<unsigned, VSDCharacterListElement *>::iterator iter; if (!m_elementsOrder.empty()) { for (unsigned i = 0; i < m_elementsOrder.size(); i++) @@ -150,9 +150,9 @@ void libvisio::VSDXCharacterList::handle(VSDXCollector *collector) } } -void libvisio::VSDXCharacterList::clear() +void libvisio::VSDCharacterList::clear() { - for (std::map<unsigned, VSDXCharacterListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) + for (std::map<unsigned, VSDCharacterListElement *>::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/VSDCharacterList.h index 1ceed63..e0e7456 100644 --- a/src/lib/VSDXCharacterList.h +++ b/src/lib/VSDCharacterList.h @@ -28,42 +28,42 @@ * instead of those above. */ -#ifndef __VSDXCHARACTERLIST_H__ -#define __VSDXCHARACTERLIST_H__ +#ifndef __VSDCHARACTERLIST_H__ +#define __VSDCHARACTERLIST_H__ #include <vector> #include <map> -#include "VSDXTypes.h" +#include "VSDTypes.h" namespace libvisio { -class VSDXCharacterListElement; -class VSDXCollector; +class VSDCharacterListElement; +class VSDCollector; -class VSDXCharacterList +class VSDCharacterList { public: - VSDXCharacterList(); - VSDXCharacterList(const VSDXCharacterList &charList); - ~VSDXCharacterList(); - VSDXCharacterList &operator=(const VSDXCharacterList &charList); + VSDCharacterList(); + VSDCharacterList(const VSDCharacterList &charList); + ~VSDCharacterList(); + VSDCharacterList &operator=(const VSDCharacterList &charList); void addCharIX(unsigned id, unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace); + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace); void setElementsOrder(const std::vector<unsigned> &m_elementsOrder); - void handle(VSDXCollector *collector); + void handle(VSDCollector *collector); void clear(); bool empty() const { return (m_elements.empty()); } private: - std::map<unsigned, VSDXCharacterListElement *> m_elements; + std::map<unsigned, VSDCharacterListElement *> m_elements; std::vector<unsigned> m_elementsOrder; }; } // namespace libvisio -#endif // __VSDXCHARACTERLIST_H__ +#endif // __VSDCHARACTERLIST_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXCollector.h b/src/lib/VSDCollector.h index 1b86177..c314370 100644 --- a/src/lib/VSDXCollector.h +++ b/src/lib/VSDCollector.h @@ -28,20 +28,20 @@ * instead of those above. */ -#ifndef VSDXCOLLECTOR_H -#define VSDXCOLLECTOR_H +#ifndef VSDCOLLECTOR_H +#define VSDCOLLECTOR_H #include <vector> -#include "VSDXParser.h" +#include "VSDParser.h" namespace libvisio { -class VSDXCollector +class VSDCollector { public: - VSDXCollector() {}; - virtual ~VSDXCollector() {} + VSDCollector() {}; + virtual ~VSDCollector() {} virtual void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) = 0; virtual void collectForeignData(unsigned id, unsigned level, const WPXBinaryData &binaryData) = 0; @@ -83,10 +83,10 @@ public: virtual void collectColours(const std::vector<Colour> &colours) = 0; virtual void collectFont(unsigned short fontID, const ::WPXBinaryData &textStream, TextFormat format) = 0; virtual void collectText(unsigned id, unsigned level, const ::WPXBinaryData &textStream, TextFormat format) = 0; - virtual void collectVSDXCharStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, + virtual void collectVSDCharStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace) = 0; - virtual void collectVSDXParaStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace) = 0; + virtual void collectVSDParaStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags) = 0; virtual void collectTextBlock(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, unsigned char verticalAlign, unsigned char bgClrId, const Colour &bgColour, double defaultTabStop, @@ -105,7 +105,7 @@ public: unsigned char fillFGTransparency, unsigned char fillBGTransparency, unsigned char shadowPattern, Colour shfgc) = 0; virtual void collectCharIXStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace) = 0; + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace) = 0; virtual void collectParaIXStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags) = 0; virtual void collectTextBlockStyle(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, @@ -131,11 +131,11 @@ protected: } private: - VSDXCollector(const VSDXCollector &); - VSDXCollector &operator=(const VSDXCollector &); + VSDCollector(const VSDCollector &); + VSDCollector &operator=(const VSDCollector &); }; } // namespace libvisio -#endif /* VSDXCOLLECTOR_H */ +#endif /* VSDCOLLECTOR_H */ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDContentCollector.cpp index 3ad5acd..e08ccb6 100644 --- a/src/lib/VSDXContentCollector.cpp +++ b/src/lib/VSDContentCollector.cpp @@ -32,8 +32,8 @@ #include <stack> #include <boost/spirit/include/classic.hpp> -#include "VSDXContentCollector.h" -#include "VSDXParser.h" +#include "VSDContentCollector.h" +#include "VSDParser.h" #include "VSDInternalStream.h" #define DUMP_BITMAP 0 @@ -103,12 +103,12 @@ static void _appendUCS4(WPXString &text, unsigned ucs4Character) } // anonymous namespace -libvisio::VSDXContentCollector::VSDXContentCollector( +libvisio::VSDContentCollector::VSDContentCollector( libwpg::WPGPaintInterface *painter, std::vector<std::map<unsigned, XForm> > &groupXFormsSequence, std::vector<std::map<unsigned, unsigned> > &groupMembershipsSequence, std::vector<std::list<unsigned> > &documentPageShapeOrders, - VSDXStyles &styles, VSDXStencils &stencils + VSDStyles &styles, VSDStencils &stencils ) : m_painter(painter), m_isPageStarted(false), m_pageWidth(0.0), m_pageHeight(0.0), m_shadowOffsetX(0.0), m_shadowOffsetY(0.0), @@ -135,7 +135,7 @@ libvisio::VSDXContentCollector::VSDXContentCollector( { } -void libvisio::VSDXContentCollector::_fillAndShadowProperties(unsigned colourIndexFG, unsigned colourIndexBG, unsigned fillPattern, +void libvisio::VSDContentCollector::_fillAndShadowProperties(unsigned colourIndexFG, unsigned colourIndexBG, unsigned fillPattern, unsigned fillFGTransparency, unsigned fillBGTransparency, unsigned shadowPattern, Colour shfgc, double shadowOffsetX, double shadowOffsetY) { @@ -350,7 +350,7 @@ void libvisio::VSDXContentCollector::_fillAndShadowProperties(unsigned colourInd m_styleProps.insert("draw:fill", m_fillType); } -void libvisio::VSDXContentCollector::_applyLinePattern() +void libvisio::VSDContentCollector::_applyLinePattern() { int dots1 = 0; int dots2 = 0; @@ -524,7 +524,7 @@ void libvisio::VSDXContentCollector::_applyLinePattern() m_styleProps.insert("draw:stroke", "solid"); } -void libvisio::VSDXContentCollector::_lineProperties(double strokeWidth, Colour c, unsigned linePattern, unsigned startMarker, unsigned endMarker, unsigned lineCap) +void libvisio::VSDContentCollector::_lineProperties(double strokeWidth, Colour c, unsigned linePattern, unsigned startMarker, unsigned endMarker, unsigned lineCap) { m_linePattern = linePattern; @@ -570,7 +570,7 @@ void libvisio::VSDXContentCollector::_lineProperties(double strokeWidth, Colour } } -const char *libvisio::VSDXContentCollector::_linePropertiesMarkerViewbox(unsigned marker) +const char *libvisio::VSDContentCollector::_linePropertiesMarkerViewbox(unsigned marker) { switch (marker) { @@ -606,7 +606,7 @@ const char *libvisio::VSDXContentCollector::_linePropertiesMarkerViewbox(unsigne } } -const char *libvisio::VSDXContentCollector::_linePropertiesMarkerPath(unsigned marker) +const char *libvisio::VSDContentCollector::_linePropertiesMarkerPath(unsigned marker) { switch (marker) { @@ -655,7 +655,7 @@ const char *libvisio::VSDXContentCollector::_linePropertiesMarkerPath(unsigned m } } -double libvisio::VSDXContentCollector::_linePropertiesMarkerScale(unsigned marker) +double libvisio::VSDContentCollector::_linePropertiesMarkerScale(unsigned marker) { switch (marker) { @@ -674,7 +674,7 @@ double libvisio::VSDXContentCollector::_linePropertiesMarkerScale(unsigned marke } } -void libvisio::VSDXContentCollector::_flushCurrentPath() +void libvisio::VSDContentCollector::_flushCurrentPath() { WPXPropertyListVector path; WPXPropertyList fillPathProps(m_styleProps); @@ -751,7 +751,7 @@ void libvisio::VSDXContentCollector::_flushCurrentPath() m_shapeOutputDrawing->addEndLayer(); } -void libvisio::VSDXContentCollector::_flushText() +void libvisio::VSDContentCollector::_flushText() { if (!m_textStream.size()) return; @@ -835,7 +835,7 @@ void libvisio::VSDXContentCollector::_flushText() unsigned long textBufferPosition = 0; const unsigned char *pTextBuffer = m_textStream.getDataBuffer(); - for (std::vector<VSDXParaStyle>::iterator paraIt = m_paraFormats.begin(); + for (std::vector<VSDParaStyle>::iterator paraIt = m_paraFormats.begin(); paraIt < m_paraFormats.end() || charIndex < m_charFormats.size(); ++paraIt) { WPXPropertyList paraProps; @@ -983,7 +983,7 @@ void libvisio::VSDXContentCollector::_flushText() if (charIndex < m_charFormats.size() && paraCharCount && m_charFormats[charIndex].charCount > paraCharCount) { // Insert duplicate - std::vector<VSDXCharStyle>::iterator charIt = m_charFormats.begin() + charIndex; + std::vector<VSDCharStyle>::iterator charIt = m_charFormats.begin() + charIndex; m_charFormats.insert(charIt, m_charFormats[charIndex]); m_charFormats[charIndex].charCount = paraCharCount; m_charFormats[charIndex+1].charCount -= paraCharCount; @@ -995,7 +995,7 @@ void libvisio::VSDXContentCollector::_flushText() m_shapeOutputText->addEndTextObject(); } -void libvisio::VSDXContentCollector::_flushCurrentForeignData() +void libvisio::VSDContentCollector::_flushCurrentForeignData() { double xmiddle = m_foreignOffsetX + m_foreignWidth / 2.0; double ymiddle = m_foreignOffsetY + m_foreignHeight / 2.0; @@ -1040,11 +1040,11 @@ void libvisio::VSDXContentCollector::_flushCurrentForeignData() m_currentForeignProps.clear(); } -void libvisio::VSDXContentCollector::_flushCurrentPage() +void libvisio::VSDContentCollector::_flushCurrentPage() { if (!m_pageShapeOrder.empty()) { - std::stack<std::pair<unsigned, VSDXOutputElementList> > groupTextStack; + std::stack<std::pair<unsigned, VSDOutputElementList> > groupTextStack; for (std::list<unsigned>::iterator iterList = m_pageShapeOrder.begin(); iterList != m_pageShapeOrder.end(); ++iterList) { std::map<unsigned, unsigned>::iterator iterGroup = m_groupMemberships.find(*iterList); @@ -1065,7 +1065,7 @@ void libvisio::VSDXContentCollector::_flushCurrentPage() } } - std::map<unsigned, VSDXOutputElementList>::iterator iter; + std::map<unsigned, VSDOutputElementList>::iterator iter; iter = m_pageOutputDrawing.find(*iterList); if (iter != m_pageOutputDrawing.end()) m_currentPage.append(iter->second); @@ -1073,7 +1073,7 @@ void libvisio::VSDXContentCollector::_flushCurrentPage() if (iter != m_pageOutputText.end()) groupTextStack.push(std::make_pair(*iterList, iter->second)); else - groupTextStack.push(std::make_pair(*iterList, VSDXOutputElementList())); + groupTextStack.push(std::make_pair(*iterList, VSDOutputElementList())); } while (!groupTextStack.empty()) { @@ -1086,7 +1086,7 @@ void libvisio::VSDXContentCollector::_flushCurrentPage() } #define LIBVISIO_EPSILON 1E-10 -void libvisio::VSDXContentCollector::collectEllipticalArcTo(unsigned /* id */, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) +void libvisio::VSDContentCollector::collectEllipticalArcTo(unsigned /* id */, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) { _handleLevelChange(level); @@ -1159,7 +1159,7 @@ void libvisio::VSDXContentCollector::collectEllipticalArcTo(unsigned /* id */, u m_currentLineGeometry.push_back(arc); } -void libvisio::VSDXContentCollector::collectEllipse(unsigned /* id */, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop) +void libvisio::VSDContentCollector::collectEllipse(unsigned /* id */, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop) { _handleLevelChange(level); WPXPropertyList ellipse; @@ -1205,7 +1205,7 @@ void libvisio::VSDXContentCollector::collectEllipse(unsigned /* id */, unsigned m_currentLineGeometry.push_back(ellipse); } -void libvisio::VSDXContentCollector::collectInfiniteLine(unsigned /* id */, unsigned level, double x1, double y1, double x2, double y2) +void libvisio::VSDContentCollector::collectInfiniteLine(unsigned /* id */, unsigned level, double x1, double y1, double x2, double y2) { _handleLevelChange(level); transformPoint(x1, y1); @@ -1294,13 +1294,13 @@ void libvisio::VSDXContentCollector::collectInfiniteLine(unsigned /* id */, unsi m_currentLineGeometry.push_back(infLine); } -void libvisio::VSDXContentCollector::collectLine(unsigned /* id */, unsigned level, double strokeWidth, Colour c, unsigned linePattern, unsigned char startMarker, unsigned char endMarker, unsigned lineCap) +void libvisio::VSDContentCollector::collectLine(unsigned /* id */, unsigned level, double strokeWidth, Colour c, unsigned linePattern, unsigned char startMarker, unsigned char endMarker, unsigned lineCap) { _handleLevelChange(level); _lineProperties(strokeWidth, c, linePattern, startMarker, endMarker, lineCap); } -void libvisio::VSDXContentCollector::collectFillAndShadow(unsigned /* id */, unsigned level, unsigned colourIndexFG, unsigned colourIndexBG, +void libvisio::VSDContentCollector::collectFillAndShadow(unsigned /* id */, unsigned level, unsigned colourIndexFG, unsigned colourIndexBG, unsigned fillPattern, unsigned fillFGTransparency, unsigned fillBGTransparency, unsigned shadowPattern, Colour shfgc, double shadowOffsetX, double shadowOffsetY) { @@ -1308,18 +1308,18 @@ void libvisio::VSDXContentCollector::collectFillAndShadow(unsigned /* id */, uns _fillAndShadowProperties(colourIndexFG, colourIndexBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowPattern, shfgc, shadowOffsetX, shadowOffsetY); } -void libvisio::VSDXContentCollector::collectFillAndShadow(unsigned id, unsigned level, unsigned colourIndexFG, unsigned colourIndexBG, unsigned fillPattern, unsigned fillFGTransparency, unsigned fillBGTransparency, unsigned shadowPattern, Colour shfgc) +void libvisio::VSDContentCollector::collectFillAndShadow(unsigned id, unsigned level, unsigned colourIndexFG, unsigned colourIndexBG, unsigned fillPattern, unsigned fillFGTransparency, unsigned fillBGTransparency, unsigned shadowPattern, Colour shfgc) { collectFillAndShadow(id, level, colourIndexFG, colourIndexBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowPattern, shfgc, m_shadowOffsetX, m_shadowOffsetY); } -void libvisio::VSDXContentCollector::collectForeignData(unsigned /* id */, unsigned level, const WPXBinaryData &binaryData) +void libvisio::VSDContentCollector::collectForeignData(unsigned /* id */, unsigned level, const WPXBinaryData &binaryData) { _handleLevelChange(level); _handleForeignData(binaryData); } -void libvisio::VSDXContentCollector::collectOLEList(unsigned /* id */, unsigned level) +void libvisio::VSDContentCollector::collectOLEList(unsigned /* id */, unsigned level) { _handleLevelChange(level); m_currentForeignData.clear(); @@ -1327,13 +1327,13 @@ void libvisio::VSDXContentCollector::collectOLEList(unsigned /* id */, unsigned _handleForeignData(binaryData); } -void libvisio::VSDXContentCollector::collectOLEData(unsigned /* id */, unsigned level, const WPXBinaryData &oleData) +void libvisio::VSDContentCollector::collectOLEData(unsigned /* id */, unsigned level, const WPXBinaryData &oleData) { _handleLevelChange(level); m_currentForeignData.append(oleData); } -void libvisio::VSDXContentCollector::_handleForeignData(const WPXBinaryData &binaryData) +void libvisio::VSDContentCollector::_handleForeignData(const WPXBinaryData &binaryData) { if (m_foreignType == 1 || m_foreignType == 4) // Image { @@ -1439,7 +1439,7 @@ void libvisio::VSDXContentCollector::_handleForeignData(const WPXBinaryData &bin } } -void libvisio::VSDXContentCollector::collectGeometry(unsigned /* id */, unsigned level, unsigned char geomFlags) +void libvisio::VSDContentCollector::collectGeometry(unsigned /* id */, unsigned level, unsigned char geomFlags) { _handleLevelChange(level); m_x = 0.0; @@ -1467,7 +1467,7 @@ void libvisio::VSDXContentCollector::collectGeometry(unsigned /* id */, unsigned m_currentGeometryCount++; } -void libvisio::VSDXContentCollector::collectMoveTo(unsigned /* id */, unsigned level, double x, double y) +void libvisio::VSDContentCollector::collectMoveTo(unsigned /* id */, unsigned level, double x, double y) { _handleLevelChange(level); m_originalX = x; @@ -1485,7 +1485,7 @@ void libvisio::VSDXContentCollector::collectMoveTo(unsigned /* id */, unsigned l m_currentLineGeometry.push_back(end); } -void libvisio::VSDXContentCollector::collectLineTo(unsigned /* id */, unsigned level, double x, double y) +void libvisio::VSDContentCollector::collectLineTo(unsigned /* id */, unsigned level, double x, double y) { _handleLevelChange(level); m_originalX = x; @@ -1503,7 +1503,7 @@ void libvisio::VSDXContentCollector::collectLineTo(unsigned /* id */, unsigned l m_currentLineGeometry.push_back(end); } -void libvisio::VSDXContentCollector::collectArcTo(unsigned /* id */, unsigned level, double x2, double y2, double bow) +void libvisio::VSDContentCollector::collectArcTo(unsigned /* id */, unsigned level, double x2, double y2, double bow) { _handleLevelChange(level); m_originalX = x2; @@ -1553,7 +1553,7 @@ void libvisio::VSDXContentCollector::collectArcTo(unsigned /* id */, unsigned le #define VSD_NUM_POLYLINES_PER_NURBS 200 -void libvisio::VSDXContentCollector::collectNURBSTo(unsigned /* id */, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree, std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) +void libvisio::VSDContentCollector::collectNURBSTo(unsigned /* id */, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree, std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) { _handleLevelChange(level); @@ -1627,7 +1627,7 @@ void libvisio::VSDXContentCollector::collectNURBSTo(unsigned /* id */, unsigned m_currentLineGeometry.push_back(NURBS); } -double libvisio::VSDXContentCollector::_NURBSBasis(unsigned knot, unsigned degree, double point, const std::vector<double> &knotVector) +double libvisio::VSDContentCollector::_NURBSBasis(unsigned knot, unsigned degree, double point, const std::vector<double> &knotVector) { double basis = 0; if (!knotVector.size()) @@ -1649,7 +1649,7 @@ double libvisio::VSDXContentCollector::_NURBSBasis(unsigned knot, unsigned degre } /* NURBS with incomplete data */ -void libvisio::VSDXContentCollector::collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID) +void libvisio::VSDContentCollector::collectNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID) { std::map<unsigned, NURBSData>::const_iterator iter; std::map<unsigned, NURBSData>::const_iterator iterEnd; @@ -1663,8 +1663,8 @@ void libvisio::VSDXContentCollector::collectNURBSTo(unsigned id, unsigned level, } // Get stencil geometry so as to find stencil NURBS data ID - VSDXGeometryListElement *element = m_stencilShape->m_geometries[m_currentGeometryCount-1].getElement(id); - VSDXNURBSTo2 *tmpElement = dynamic_cast<VSDXNURBSTo2 *>(element); + VSDGeometryListElement *element = m_stencilShape->m_geometries[m_currentGeometryCount-1].getElement(id); + VSDNURBSTo2 *tmpElement = dynamic_cast<VSDNURBSTo2 *>(element); if (!tmpElement) { _handleLevelChange(level); @@ -1694,7 +1694,7 @@ void libvisio::VSDXContentCollector::collectNURBSTo(unsigned id, unsigned level, _handleLevelChange(level); } -void libvisio::VSDXContentCollector::collectPolylineTo(unsigned /* id */ , unsigned level, double x, double y, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > &points) +void libvisio::VSDContentCollector::collectPolylineTo(unsigned /* id */ , unsigned level, double x, double y, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > &points) { _handleLevelChange(level); @@ -1732,7 +1732,7 @@ void libvisio::VSDXContentCollector::collectPolylineTo(unsigned /* id */ , unsig } /* Polyline with incomplete data */ -void libvisio::VSDXContentCollector::collectPolylineTo(unsigned id, unsigned level, double x, double y, unsigned dataID) +void libvisio::VSDContentCollector::collectPolylineTo(unsigned id, unsigned level, double x, double y, unsigned dataID) { std::map<unsigned, PolylineData>::const_iterator iter; std::map<unsigned, PolylineData>::const_iterator iterEnd; @@ -1745,8 +1745,8 @@ void libvisio::VSDXContentCollector::collectPolylineTo(unsigned id, unsigned lev } // Get stencil geometry so as to find stencil polyline data ID - VSDXGeometryListElement *element = m_stencilShape->m_geometries[m_currentGeometryCount-1].getElement(id); - dataID = dynamic_cast<VSDXPolylineTo2 *>(element)->m_dataID; + VSDGeometryListElement *element = m_stencilShape->m_geometries[m_currentGeometryCount-1].getElement(id); + dataID = dynamic_cast<VSDPolylineTo2 *>(element)->m_dataID; iter = m_stencilShape->m_polylineData.find(dataID); iterEnd = m_stencilShape->m_polylineData.end(); } @@ -1766,7 +1766,7 @@ void libvisio::VSDXContentCollector::collectPolylineTo(unsigned id, unsigned lev } /* NURBS shape data */ -void libvisio::VSDXContentCollector::collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, unsigned degree, double lastKnot, std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) +void libvisio::VSDContentCollector::collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, unsigned degree, double lastKnot, std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) { _handleLevelChange(level); NURBSData data; @@ -1781,7 +1781,7 @@ void libvisio::VSDXContentCollector::collectShapeData(unsigned id, unsigned leve } /* Polyline shape data */ -void libvisio::VSDXContentCollector::collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points) +void libvisio::VSDContentCollector::collectShapeData(unsigned id, unsigned level, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points) { _handleLevelChange(level); PolylineData data; @@ -1791,13 +1791,13 @@ void libvisio::VSDXContentCollector::collectShapeData(unsigned id, unsigned leve m_polylineData[id] = data; } -void libvisio::VSDXContentCollector::collectXFormData(unsigned /* id */, unsigned level, const XForm &xform) +void libvisio::VSDContentCollector::collectXFormData(unsigned /* id */, unsigned level, const XForm &xform) { _handleLevelChange(level); m_xform = xform; } -void libvisio::VSDXContentCollector::collectTxtXForm(unsigned /* id */, unsigned level, const XForm &txtxform) +void libvisio::VSDContentCollector::collectTxtXForm(unsigned /* id */, unsigned level, const XForm &txtxform) { _handleLevelChange(level); if (m_txtxform) @@ -1807,7 +1807,7 @@ void libvisio::VSDXContentCollector::collectTxtXForm(unsigned /* id */, unsigned m_txtxform->y = m_txtxform->pinY - m_txtxform->pinLocY; } -void libvisio::VSDXContentCollector::applyXForm(double &x, double &y, const XForm &xform) +void libvisio::VSDContentCollector::applyXForm(double &x, double &y, const XForm &xform) { x -= xform.pinLocX; y -= xform.pinLocY; @@ -1826,7 +1826,7 @@ void libvisio::VSDXContentCollector::applyXForm(double &x, double &y, const XFor y += xform.pinY; } -void libvisio::VSDXContentCollector::transformPoint(double &x, double &y, XForm *txtxform) +void libvisio::VSDContentCollector::transformPoint(double &x, double &y, XForm *txtxform) { // We are interested for the while in shapes xforms only if (!m_isShapeStarted) @@ -1859,7 +1859,7 @@ void libvisio::VSDXContentCollector::transformPoint(double &x, double &y, XForm y = m_pageHeight - y; } -void libvisio::VSDXContentCollector::transformAngle(double &angle, XForm *txtxform) +void libvisio::VSDContentCollector::transformAngle(double &angle, XForm *txtxform) { // We are interested for the while in shape xforms only if (!m_isShapeStarted) @@ -1877,7 +1877,7 @@ void libvisio::VSDXContentCollector::transformAngle(double &angle, XForm *txtxfo angle = fmod(2.0*M_PI + (y1 > y0 ? 1.0 : -1.0)*acos((x1-x0) / sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0))), 2.0*M_PI); } -void libvisio::VSDXContentCollector::transformFlips(bool &flipX, bool &flipY) +void libvisio::VSDContentCollector::transformFlips(bool &flipX, bool &flipY) { if (!m_isShapeStarted) return; @@ -1908,12 +1908,12 @@ void libvisio::VSDXContentCollector::transformFlips(bool &flipX, bool &flipY) } } -void libvisio::VSDXContentCollector::collectShapeId(unsigned /* id */, unsigned level, unsigned /* shapeId */) +void libvisio::VSDContentCollector::collectShapeId(unsigned /* id */, unsigned level, unsigned /* shapeId */) { _handleLevelChange(level); } -void libvisio::VSDXContentCollector::collectForeignDataType(unsigned /* id */, unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height) +void libvisio::VSDContentCollector::collectForeignDataType(unsigned /* id */, unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height) { _handleLevelChange(level); m_foreignType = foreignType; @@ -1924,7 +1924,7 @@ void libvisio::VSDXContentCollector::collectForeignDataType(unsigned /* id */, u m_foreignHeight = height; } -void libvisio::VSDXContentCollector::collectPageProps(unsigned /* id */, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale) +void libvisio::VSDContentCollector::collectPageProps(unsigned /* id */, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale) { _handleLevelChange(level); m_pageWidth = pageWidth; @@ -1937,13 +1937,13 @@ void libvisio::VSDXContentCollector::collectPageProps(unsigned /* id */, unsigne m_currentPage.m_pageHeight = m_scale*m_pageHeight; } -void libvisio::VSDXContentCollector::collectPage(unsigned /* id */, unsigned level, unsigned backgroundPageID) +void libvisio::VSDContentCollector::collectPage(unsigned /* id */, unsigned level, unsigned backgroundPageID) { _handleLevelChange(level); m_currentPage.m_backgroundPageID = backgroundPageID; } -void libvisio::VSDXContentCollector::collectShape(unsigned id, unsigned level, unsigned masterPage, unsigned masterShape, unsigned lineStyleId, unsigned fillStyleId, unsigned textStyleId) +void libvisio::VSDContentCollector::collectShape(unsigned id, unsigned level, unsigned masterPage, unsigned masterShape, unsigned lineStyleId, unsigned fillStyleId, unsigned textStyleId) { _handleLevelChange(level); m_currentShapeLevel = level; @@ -1981,21 +1981,21 @@ void libvisio::VSDXContentCollector::collectShape(unsigned id, unsigned level, u m_charFormats.clear(); m_paraFormats.clear(); - m_defaultCharStyle = VSDXCharStyle(); + m_defaultCharStyle = VSDCharStyle(); if (m_styles.getCharStyle(0)) m_defaultCharStyle = *(m_styles.getCharStyle(0)); - m_defaultParaStyle = VSDXParaStyle(); + m_defaultParaStyle = VSDParaStyle(); if (m_styles.getParaStyle(0)) m_defaultParaStyle = *(m_styles.getParaStyle(0)); - m_textBlockStyle = VSDXTextBlockStyle(); + m_textBlockStyle = VSDTextBlockStyle(); if (m_styles.getTextBlockStyle(0)) m_textBlockStyle = *(m_styles.getTextBlockStyle(0)); m_currentShapeId = id; - m_pageOutputDrawing[m_currentShapeId] = VSDXOutputElementList(); - m_pageOutputText[m_currentShapeId] = VSDXOutputElementList(); + m_pageOutputDrawing[m_currentShapeId] = VSDOutputElementList(); + m_pageOutputText[m_currentShapeId] = VSDOutputElementList(); m_shapeOutputDrawing = &m_pageOutputDrawing[m_currentShapeId]; m_shapeOutputText = &m_pageOutputText[m_currentShapeId]; m_isShapeStarted = true; @@ -2010,7 +2010,7 @@ void libvisio::VSDXContentCollector::collectShape(unsigned id, unsigned level, u m_stencilShape = 0; if (masterPage != 0xffffffff && masterShape != 0xffffffff) { - const VSDXStencil *stencil = m_stencils.getStencil(masterPage); + const VSDStencil *stencil = m_stencils.getStencil(masterPage); if (stencil) m_stencilShape = stencil->getStencilShape(masterShape); // Initialize the shape from stencil content @@ -2031,7 +2031,7 @@ void libvisio::VSDXContentCollector::collectShape(unsigned id, unsigned level, u m_textStream = m_stencilShape->m_text; m_textFormat = m_stencilShape->m_textFormat; - for (std::map< unsigned, VSDXName>::const_iterator iterData = m_stencilShape->m_names.begin(); iterData != m_stencilShape->m_names.end(); ++iterData) + for (std::map< unsigned, VSDName>::const_iterator iterData = m_stencilShape->m_names.begin(); iterData != m_stencilShape->m_names.end(); ++iterData) { WPXString nameString; _convertDataToString(nameString, iterData->second.m_data, iterData->second.m_format); @@ -2041,7 +2041,7 @@ void libvisio::VSDXContentCollector::collectShape(unsigned id, unsigned level, u m_stencilFields = m_stencilShape->m_fields; for (unsigned i = 0; i < m_stencilFields.size(); i++) { - VSDXFieldListElement *elem = m_stencilFields.getElement(i); + VSDFieldListElement *elem = m_stencilFields.getElement(i); if (elem) m_fields.push_back(elem->getString(m_stencilNames)); else @@ -2094,12 +2094,12 @@ void libvisio::VSDXContentCollector::collectShape(unsigned id, unsigned level, u m_fieldIndex = 0; } -void libvisio::VSDXContentCollector::collectUnhandledChunk(unsigned /* id */, unsigned level) +void libvisio::VSDContentCollector::collectUnhandledChunk(unsigned /* id */, unsigned level) { _handleLevelChange(level); } -void libvisio::VSDXContentCollector::collectColours(const std::vector<Colour> &colours) +void libvisio::VSDContentCollector::collectColours(const std::vector<Colour> &colours) { m_colours.clear(); m_colours.reserve(colours.size()); @@ -2107,9 +2107,9 @@ void libvisio::VSDXContentCollector::collectColours(const std::vector<Colour> &c m_colours.push_back(colours[i]); } -void libvisio::VSDXContentCollector::collectFont(unsigned short fontID, const WPXBinaryData &textStream, TextFormat format) +void libvisio::VSDContentCollector::collectFont(unsigned short fontID, const WPXBinaryData &textStream, TextFormat format) { - VSDXFont font; + VSDFont font; font.name.clear(); _convertDataToString(font.name, textStream, format); font.encoding = format; @@ -2117,7 +2117,7 @@ void libvisio::VSDXContentCollector::collectFont(unsigned short fontID, const WP } -void libvisio::VSDXContentCollector::collectSplineStart(unsigned /* id */, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) +void libvisio::VSDContentCollector::collectSplineStart(unsigned /* id */, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) { m_splineLevel = level; m_splineKnotVector.push_back(firstKnot); @@ -2129,7 +2129,7 @@ void libvisio::VSDXContentCollector::collectSplineStart(unsigned /* id */, unsig } -void libvisio::VSDXContentCollector::collectSplineKnot(unsigned /* id */, unsigned /* level */, double x, double y, double knot) +void libvisio::VSDContentCollector::collectSplineKnot(unsigned /* id */, unsigned /* level */, double x, double y, double knot) { m_splineKnotVector.push_back(knot); m_splineControlPoints.push_back(std::pair<double,double>(m_splineX,m_splineY)); @@ -2138,7 +2138,7 @@ void libvisio::VSDXContentCollector::collectSplineKnot(unsigned /* id */, unsign } -void libvisio::VSDXContentCollector::collectSplineEnd() +void libvisio::VSDContentCollector::collectSplineEnd() { if (m_splineKnotVector.empty() || m_splineControlPoints.empty()) { @@ -2156,7 +2156,7 @@ void libvisio::VSDXContentCollector::collectSplineEnd() } -void libvisio::VSDXContentCollector::collectText(unsigned /*id*/, unsigned level, const WPXBinaryData &textStream, TextFormat format) +void libvisio::VSDContentCollector::collectText(unsigned /*id*/, unsigned level, const WPXBinaryData &textStream, TextFormat format) { _handleLevelChange(level); @@ -2164,42 +2164,42 @@ void libvisio::VSDXContentCollector::collectText(unsigned /*id*/, unsigned level m_textFormat = format; } -void libvisio::VSDXContentCollector::collectVSDXParaStyle(unsigned /* id */ , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, +void libvisio::VSDContentCollector::collectVSDParaStyle(unsigned /* id */ , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags) { _handleLevelChange(level); - VSDXParaStyle format(charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align, flags); + VSDParaStyle format(charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align, flags); m_paraFormats.push_back(format); } -void libvisio::VSDXContentCollector::collectVSDXCharStyle(unsigned /*id*/ , unsigned level, unsigned charCount, +void libvisio::VSDContentCollector::collectVSDCharStyle(unsigned /*id*/ , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace) + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace) { _handleLevelChange(level); - VSDXCharStyle format(charCount, fontID, fontColour, fontSize, bold, italic, + VSDCharStyle format(charCount, fontID, fontColour, fontSize, bold, italic, underline, doubleunderline, strikeout, doublestrikeout, allcaps, initcaps, smallcaps, superscript, subscript, fontFace); m_charFormats.push_back(format); } -void libvisio::VSDXContentCollector::collectTextBlock(unsigned /* id */, unsigned level, double leftMargin, double rightMargin, +void libvisio::VSDContentCollector::collectTextBlock(unsigned /* id */, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, unsigned char verticalAlign, unsigned char bgClrId, const Colour &bgColour, double defaultTabStop, unsigned char textDirection) { _handleLevelChange(level); - m_textBlockStyle = VSDXTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, verticalAlign, bgClrId, bgColour, defaultTabStop, textDirection); + m_textBlockStyle = VSDTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, verticalAlign, bgClrId, bgColour, defaultTabStop, textDirection); } -void libvisio::VSDXContentCollector::collectNameList(unsigned /*id*/, unsigned level) +void libvisio::VSDContentCollector::collectNameList(unsigned /*id*/, unsigned level) { _handleLevelChange(level); m_names.clear(); } -void libvisio::VSDXContentCollector::_convertDataToString(WPXString &result, const WPXBinaryData &data, TextFormat format) +void libvisio::VSDContentCollector::_convertDataToString(WPXString &result, const WPXBinaryData &data, TextFormat format) { if (!data.size()) return; @@ -2208,7 +2208,7 @@ void libvisio::VSDXContentCollector::_convertDataToString(WPXString &result, con appendCharacters(result, tmpData, format); } -void libvisio::VSDXContentCollector::collectName(unsigned id, unsigned level, const WPXBinaryData &name, TextFormat format) +void libvisio::VSDContentCollector::collectName(unsigned id, unsigned level, const WPXBinaryData &name, TextFormat format) { _handleLevelChange(level); @@ -2217,86 +2217,86 @@ void libvisio::VSDXContentCollector::collectName(unsigned id, unsigned level, co m_names[id] = nameString; } -void libvisio::VSDXContentCollector::collectPageSheet(unsigned /* id */, unsigned level) +void libvisio::VSDContentCollector::collectPageSheet(unsigned /* id */, unsigned level) { _handleLevelChange(level); m_currentShapeLevel = level; } -void libvisio::VSDXContentCollector::collectStyleSheet(unsigned /* id */, unsigned level, unsigned /* parentLineStyle */, unsigned /* parentFillStyle */, unsigned /* parentTextStyle */) +void libvisio::VSDContentCollector::collectStyleSheet(unsigned /* id */, unsigned level, unsigned /* parentLineStyle */, unsigned /* parentFillStyle */, unsigned /* parentTextStyle */) { _handleLevelChange(level); } -void libvisio::VSDXContentCollector::collectLineStyle(unsigned /* id */, unsigned level, double /* strokeWidth */, Colour /* c */, unsigned char /* linePattern */, unsigned char /*startMarker*/, unsigned char /*endMarker*/, unsigned char /* lineCap */) +void libvisio::VSDContentCollector::collectLineStyle(unsigned /* id */, unsigned level, double /* strokeWidth */, Colour /* c */, unsigned char /* linePattern */, unsigned char /*startMarker*/, unsigned char /*endMarker*/, unsigned char /* lineCap */) { _handleLevelChange(level); } -void libvisio::VSDXContentCollector::collectFillStyle(unsigned /*id*/, unsigned level, unsigned char /*colourIndexFG*/, unsigned char /*colourIndexBG*/, unsigned char /*fillPattern*/, unsigned char /*fillFGTransparency*/, unsigned char /*fillBGTransparency*/, unsigned char /*shadowPattern*/, Colour /*shfgc*/, double /*shadowOffsetX*/, double /*shadowOffsetY*/) +void libvisio::VSDContentCollector::collectFillStyle(unsigned /*id*/, unsigned level, unsigned char /*colourIndexFG*/, unsigned char /*colourIndexBG*/, unsigned char /*fillPattern*/, unsigned char /*fillFGTransparency*/, unsigned char /*fillBGTransparency*/, unsigned char /*shadowPattern*/, Colour /*shfgc*/, double /*shadowOffsetX*/, double /*shadowOffsetY*/) { _handleLevelChange(level); } -void libvisio::VSDXContentCollector::collectFillStyle(unsigned /*id*/, unsigned level, unsigned char /*colourIndexFG*/, unsigned char /*colourIndexBG*/, unsigned char /*fillPattern*/, unsigned char /*fillFGTransparency*/, unsigned char /*fillBGTransparency*/, unsigned char /*shadowPattern*/, Colour /*shfgc*/) +void libvisio::VSDContentCollector::collectFillStyle(unsigned /*id*/, unsigned level, unsigned char /*colourIndexFG*/, unsigned char /*colourIndexBG*/, unsigned char /*fillPattern*/, unsigned char /*fillFGTransparency*/, unsigned char /*fillBGTransparency*/, unsigned char /*shadowPattern*/, Colour /*shfgc*/) { _handleLevelChange(level); } -void libvisio::VSDXContentCollector::collectCharIXStyle(unsigned /*id*/ , unsigned level, unsigned /*charCount*/, unsigned short /*fontID*/, Colour /*fontColour*/, double /*fontSize*/, +void libvisio::VSDContentCollector::collectCharIXStyle(unsigned /*id*/ , unsigned level, unsigned /*charCount*/, unsigned short /*fontID*/, Colour /*fontColour*/, double /*fontSize*/, bool /*bold*/, bool /*italic*/, bool /*underline*/, bool /* doubleunderline */, bool /* strikeout */, bool /* doublestrikeout */, - bool /* allcaps */, bool /* initcaps */, bool /* smallcaps */, bool /* superscript */, bool /* subscript */, VSDXFont /*fontFace*/) + bool /* allcaps */, bool /* initcaps */, bool /* smallcaps */, bool /* superscript */, bool /* subscript */, VSDFont /*fontFace*/) { _handleLevelChange(level); } -void libvisio::VSDXContentCollector::collectParaIXStyle(unsigned /* id */, unsigned level, unsigned /* charCount */, double /* indFirst */, double /* indLeft */, double /* indRight */, +void libvisio::VSDContentCollector::collectParaIXStyle(unsigned /* id */, unsigned level, unsigned /* charCount */, double /* indFirst */, double /* indLeft */, double /* indRight */, double /* spLine */, double /* spBefore */, double /* spAfter */, unsigned char /* align */, unsigned /* flags */) { _handleLevelChange(level); } -void libvisio::VSDXContentCollector::collectTextBlockStyle(unsigned /* id */, unsigned level, double /* leftMargin */, double /* rightMargin */, +void libvisio::VSDContentCollector::collectTextBlockStyle(unsigned /* id */, unsigned level, double /* leftMargin */, double /* rightMargin */, double /* topMargin */, double /* bottomMargin */, unsigned char /* verticalAlign */, unsigned char /* bgClrId */, const Colour & /* colour */, double /* defaultTabStop */, unsigned char /* textDirection */) { _handleLevelChange(level); } -void libvisio::VSDXContentCollector::lineStyleFromStyleSheet(unsigned styleId) +void libvisio::VSDContentCollector::lineStyleFromStyleSheet(unsigned styleId) { lineStyleFromStyleSheet(m_styles.getLineStyle(styleId)); } -void libvisio::VSDXContentCollector::lineStyleFromStyleSheet(const VSDXLineStyle *style) +void libvisio::VSDContentCollector::lineStyleFromStyleSheet(const VSDLineStyle *style) { if (style) _lineProperties(style->width, style->colour, style->pattern, style->startMarker, style->endMarker, style->cap); } -void libvisio::VSDXContentCollector::fillStyleFromStyleSheet(unsigned styleId) +void libvisio::VSDContentCollector::fillStyleFromStyleSheet(unsigned styleId) { fillStyleFromStyleSheet(m_styles.getFillStyle(styleId)); } -void libvisio::VSDXContentCollector::fillStyleFromStyleSheet(const VSDXFillStyle *style) +void libvisio::VSDContentCollector::fillStyleFromStyleSheet(const VSDFillStyle *style) { if (style) _fillAndShadowProperties(style->fgColourId, style->bgColourId, style->pattern, style->fgTransparency, style->bgTransparency, style->shadowPattern, style->shadowFgColour, style->shadowOffsetX, style->shadowOffsetY); } -void libvisio::VSDXContentCollector::collectFieldList(unsigned /* id */, unsigned level) +void libvisio::VSDContentCollector::collectFieldList(unsigned /* id */, unsigned level) { _handleLevelChange(level); m_fields.clear(); } -void libvisio::VSDXContentCollector::collectTextField(unsigned id, unsigned level, int nameId, int formatStringId) +void libvisio::VSDContentCollector::collectTextField(unsigned id, unsigned level, int nameId, int formatStringId) { _handleLevelChange(level); - VSDXFieldListElement *element = m_stencilFields.getElement(m_fields.size()); + VSDFieldListElement *element = m_stencilFields.getElement(m_fields.size()); if (element) { if (nameId == -2) @@ -2311,18 +2311,18 @@ void libvisio::VSDXContentCollector::collectTextField(unsigned id, unsigned leve } else { - VSDXTextField tmpField(id, level, nameId, formatStringId); + VSDTextField tmpField(id, level, nameId, formatStringId); m_fields.push_back(tmpField.getString(m_names)); } } -void libvisio::VSDXContentCollector::collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId) +void libvisio::VSDContentCollector::collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId) { _handleLevelChange(level); - VSDXFieldListElement *pElement = m_stencilFields.getElement(m_fields.size()); + VSDFieldListElement *pElement = m_stencilFields.getElement(m_fields.size()); if (pElement) { - VSDXFieldListElement *element = pElement->clone(); + VSDFieldListElement *element = pElement->clone(); if (element) { element->setValue(number); @@ -2341,12 +2341,12 @@ void libvisio::VSDXContentCollector::collectNumericField(unsigned id, unsigned l } else { - VSDXNumericField tmpField(id, level, format, number, formatStringId); + VSDNumericField tmpField(id, level, format, number, formatStringId); m_fields.push_back(tmpField.getString(m_names)); } } -void libvisio::VSDXContentCollector::_handleLevelChange(unsigned level) +void libvisio::VSDContentCollector::_handleLevelChange(unsigned level) { if (m_currentLevel == level) return; @@ -2393,7 +2393,7 @@ void libvisio::VSDXContentCollector::_handleLevelChange(unsigned level) m_currentLevel = level; } -void libvisio::VSDXContentCollector::startPage(unsigned pageId) +void libvisio::VSDContentCollector::startPage(unsigned pageId) { if (m_isShapeStarted) { @@ -2416,12 +2416,12 @@ void libvisio::VSDXContentCollector::startPage(unsigned pageId) m_groupMemberships = m_groupMembershipsSequence[m_currentPageNumber-1]; if (m_documentPageShapeOrders.size() >= m_currentPageNumber) m_pageShapeOrder = m_documentPageShapeOrders[m_currentPageNumber-1]; - m_currentPage = libvisio::VSDXPage(); + m_currentPage = libvisio::VSDPage(); m_currentPage.m_currentPageID = pageId; m_isPageStarted = true; } -void libvisio::VSDXContentCollector::endPage() +void libvisio::VSDContentCollector::endPage() { if (m_isPageStarted) { @@ -2432,12 +2432,12 @@ void libvisio::VSDXContentCollector::endPage() } } -void libvisio::VSDXContentCollector::endPages() +void libvisio::VSDContentCollector::endPages() { m_pages.draw(m_painter); } -bool libvisio::VSDXContentCollector::parseFormatId( const char *formatString, unsigned short &result ) +bool libvisio::VSDContentCollector::parseFormatId( const char *formatString, unsigned short &result ) { using namespace ::boost::spirit::classic; @@ -2467,7 +2467,7 @@ bool libvisio::VSDXContentCollector::parseFormatId( const char *formatString, un return false; } -void libvisio::VSDXContentCollector::appendCharacters(WPXString &text, const std::vector<unsigned char> &characters, TextFormat format) +void libvisio::VSDContentCollector::appendCharacters(WPXString &text, const std::vector<unsigned char> &characters, TextFormat format) { if (format == VSD_TEXT_UTF16) return appendCharacters(text, characters); @@ -2750,7 +2750,7 @@ void libvisio::VSDXContentCollector::appendCharacters(WPXString &text, const std } } -void libvisio::VSDXContentCollector::appendCharacters(WPXString &text, const std::vector<unsigned char> &characters) +void libvisio::VSDContentCollector::appendCharacters(WPXString &text, const std::vector<unsigned char> &characters) { std::vector<unsigned char>::const_iterator iter = characters.begin(); while (iter != characters.end()) diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDContentCollector.h index 6b03841..3cf9792 100644 --- a/src/lib/VSDXContentCollector.h +++ b/src/lib/VSDContentCollector.h @@ -28,8 +28,8 @@ * instead of those above. */ -#ifndef VSDXCONTENTCOLLECTOR_H -#define VSDXCONTENTCOLLECTOR_H +#ifndef VSDCONTENTCOLLECTOR_H +#define VSDCONTENTCOLLECTOR_H #include <locale.h> #include <sstream> @@ -40,26 +40,26 @@ #include <vector> #include <libwpg/libwpg.h> #include "libvisio_utils.h" -#include "VSDXCollector.h" -#include "VSDXParser.h" -#include "VSDXOutputElementList.h" -#include "VSDXStyles.h" -#include "VSDXPages.h" +#include "VSDCollector.h" +#include "VSDParser.h" +#include "VSDOutputElementList.h" +#include "VSDStyles.h" +#include "VSDPages.h" namespace libvisio { -class VSDXContentCollector : public VSDXCollector +class VSDContentCollector : public VSDCollector { public: - VSDXContentCollector( + VSDContentCollector( libwpg::WPGPaintInterface *painter, std::vector<std::map<unsigned, XForm> > &groupXFormsSequence, std::vector<std::map<unsigned, unsigned> > &groupMembershipsSequence, std::vector<std::list<unsigned> > &documentPageShapeOrders, - VSDXStyles &styles, VSDXStencils &stencils + VSDStyles &styles, VSDStencils &stencils ); - virtual ~VSDXContentCollector() + virtual ~VSDContentCollector() { if (m_txtxform) delete(m_txtxform); }; @@ -105,10 +105,10 @@ public: void collectColours(const std::vector<Colour> &colours); void collectFont(unsigned short fontID, const WPXBinaryData &textStream, TextFormat format); void collectText(unsigned id, unsigned level, const WPXBinaryData &textStream, TextFormat format); - void collectVSDXCharStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, + void collectVSDCharStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace); - void collectVSDXParaStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace); + void collectVSDParaStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags); void collectTextBlock(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, unsigned char verticalAlign, unsigned char bgClrId, const Colour &bgColour, double defaultTabStop, unsigned char textDirection); @@ -127,7 +127,7 @@ public: unsigned char fillFGTransparency, unsigned char fillBGTransparency, unsigned char shadowPattern, Colour shfgc); void collectCharIXStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace); + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace); void collectParaIXStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags); void collectTextBlockStyle(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, unsigned char verticalAlign, @@ -144,8 +144,8 @@ public: private: - VSDXContentCollector(const VSDXContentCollector &); - VSDXContentCollector &operator=(const VSDXContentCollector &); + VSDContentCollector(const VSDContentCollector &); + VSDContentCollector &operator=(const VSDContentCollector &); libwpg::WPGPaintInterface *m_painter; void applyXForm(double &x, double &y, const XForm &xform); @@ -167,8 +167,8 @@ private: void lineStyleFromStyleSheet(unsigned styleId); void fillStyleFromStyleSheet(unsigned styleId); - void lineStyleFromStyleSheet(const VSDXLineStyle *style); - void fillStyleFromStyleSheet(const VSDXFillStyle *style); + void lineStyleFromStyleSheet(const VSDLineStyle *style); + void fillStyleFromStyleSheet(const VSDFillStyle *style); void _applyLinePattern(); void _lineProperties(double strokeWidth, Colour c, unsigned linePattern, unsigned startMarker, unsigned endMarker, unsigned lineCap); @@ -220,16 +220,16 @@ private: bool m_noFill; bool m_noShow; std::vector<Colour> m_colours; - std::map<unsigned short, VSDXFont> m_fonts; + std::map<unsigned short, VSDFont> m_fonts; unsigned m_currentLevel; bool m_isShapeStarted; std::map<unsigned, unsigned> &m_groupMemberships; std::vector<std::map<unsigned, XForm> > &m_groupXFormsSequence; std::vector<std::map<unsigned, unsigned> > &m_groupMembershipsSequence; unsigned m_currentPageNumber; - VSDXOutputElementList *m_shapeOutputDrawing, *m_shapeOutputText; - std::map<unsigned, VSDXOutputElementList> m_pageOutputDrawing; - std::map<unsigned, VSDXOutputElementList> m_pageOutputText; + VSDOutputElementList *m_shapeOutputDrawing, *m_shapeOutputText; + std::map<unsigned, VSDOutputElementList> m_pageOutputDrawing; + std::map<unsigned, VSDOutputElementList> m_pageOutputText; std::vector<std::list<unsigned> > &m_documentPageShapeOrders; std::list<unsigned> &m_pageShapeOrder; bool m_isFirstGeometry; @@ -239,29 +239,29 @@ private: WPXBinaryData m_textStream; std::map<unsigned, WPXString> m_names, m_stencilNames; std::vector<WPXString> m_fields; - VSDXFieldList m_stencilFields; + VSDFieldList m_stencilFields; unsigned m_fieldIndex; TextFormat m_textFormat; - std::vector<VSDXCharStyle> m_charFormats; - std::vector<VSDXParaStyle> m_paraFormats; + std::vector<VSDCharStyle> m_charFormats; + std::vector<VSDParaStyle> m_paraFormats; - VSDXTextBlockStyle m_textBlockStyle; + VSDTextBlockStyle m_textBlockStyle; - VSDXCharStyle m_defaultCharStyle; - VSDXParaStyle m_defaultParaStyle; + VSDCharStyle m_defaultCharStyle; + VSDParaStyle m_defaultParaStyle; - VSDXStyles m_styles; + VSDStyles m_styles; - VSDXStencils m_stencils; - const VSDXStencilShape *m_stencilShape; + VSDStencils m_stencils; + const VSDStencilShape *m_stencilShape; bool m_isStencilStarted; unsigned m_currentGeometryCount; unsigned m_backgroundPageID; unsigned m_currentPageID; - VSDXPage m_currentPage; - VSDXPages m_pages; + VSDPage m_currentPage; + VSDPages m_pages; std::vector<std::pair<double, double> > m_splineControlPoints; std::vector<double> m_splineKnotVector; @@ -274,5 +274,5 @@ private: } // namespace libvisio -#endif /* VSDXCONTENTCOLLECTOR_H */ +#endif /* VSDCONTENTCOLLECTOR_H */ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXDocumentStructure.h b/src/lib/VSDDocumentStructure.h index 2c8f0be..774fe29 100644 --- a/src/lib/VSDXDocumentStructure.h +++ b/src/lib/VSDDocumentStructure.h @@ -28,8 +28,8 @@ * instead of those above. */ -#ifndef VSDXDOCUMENTSTRUCTURE_H -#define VSDXDOCUMENTSTRUCTURE_H +#ifndef VSDDOCUMENTSTRUCTURE_H +#define VSDDOCUMENTSTRUCTURE_H #define VSD_FOREIGN_DATA 0x0c #define VSD_OLE_LIST 0x0d @@ -235,5 +235,5 @@ #define VSD_FIELD_FORMAT_Unknown 0xffff -#endif /* VSDXDOCUMENTSTRUCTURE_H */ +#endif /* VSDDOCUMENTSTRUCTURE_H */ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXFieldList.cpp b/src/lib/VSDFieldList.cpp index 3674019..b9d6043 100644 --- a/src/lib/VSDXFieldList.cpp +++ b/src/lib/VSDFieldList.cpp @@ -29,20 +29,20 @@ */ #include <time.h> -#include "VSDXCollector.h" -#include "VSDXFieldList.h" +#include "VSDCollector.h" +#include "VSDFieldList.h" -void libvisio::VSDXTextField::handle(VSDXCollector *collector) +void libvisio::VSDTextField::handle(VSDCollector *collector) { collector->collectTextField(m_id, m_level, m_nameId, m_formatStringId); } -libvisio::VSDXFieldListElement *libvisio::VSDXTextField::clone() +libvisio::VSDFieldListElement *libvisio::VSDTextField::clone() { - return new VSDXTextField(m_id, m_level, m_nameId, m_formatStringId); + return new VSDTextField(m_id, m_level, m_nameId, m_formatStringId); } -WPXString libvisio::VSDXTextField::getString(const std::map<unsigned, WPXString> &strVec) +WPXString libvisio::VSDTextField::getString(const std::map<unsigned, WPXString> &strVec) { std::map<unsigned, WPXString>::const_iterator iter = strVec.find(m_nameId); if (iter != strVec.end()) @@ -51,25 +51,25 @@ WPXString libvisio::VSDXTextField::getString(const std::map<unsigned, WPXString> return WPXString(); } -void libvisio::VSDXTextField::setNameId(int nameId) +void libvisio::VSDTextField::setNameId(int nameId) { m_nameId = nameId; } -void libvisio::VSDXNumericField::handle(VSDXCollector *collector) +void libvisio::VSDNumericField::handle(VSDCollector *collector) { collector->collectNumericField(m_id, m_level, m_format, m_number, m_formatStringId); } -libvisio::VSDXFieldListElement *libvisio::VSDXNumericField::clone() +libvisio::VSDFieldListElement *libvisio::VSDNumericField::clone() { - return new VSDXNumericField(m_id, m_level, m_format, m_number, m_formatStringId); + return new VSDNumericField(m_id, m_level, m_format, m_number, m_formatStringId); } #define MAX_BUFFER 1024 -WPXString libvisio::VSDXNumericField::datetimeToString(const char *format, double datetime) +WPXString libvisio::VSDNumericField::datetimeToString(const char *format, double datetime) { WPXString result; char buffer[MAX_BUFFER]; @@ -79,7 +79,7 @@ WPXString libvisio::VSDXNumericField::datetimeToString(const char *format, doubl return result; } -WPXString libvisio::VSDXNumericField::getString(const std::map<unsigned, WPXString> &) +WPXString libvisio::VSDNumericField::getString(const std::map<unsigned, WPXString> &) { if (m_format == 0xffff) return WPXString(); @@ -169,17 +169,17 @@ WPXString libvisio::VSDXNumericField::getString(const std::map<unsigned, WPXStri } } -void libvisio::VSDXNumericField::setFormat(unsigned short format) +void libvisio::VSDNumericField::setFormat(unsigned short format) { m_format = format; } -void libvisio::VSDXNumericField::setValue(double number) +void libvisio::VSDNumericField::setValue(double number) { m_number = number; } -libvisio::VSDXFieldList::VSDXFieldList() : +libvisio::VSDFieldList::VSDFieldList() : m_elements(), m_elementsOrder(), m_id(0), @@ -187,23 +187,23 @@ libvisio::VSDXFieldList::VSDXFieldList() : { } -libvisio::VSDXFieldList::VSDXFieldList(const libvisio::VSDXFieldList &fieldList) : +libvisio::VSDFieldList::VSDFieldList(const libvisio::VSDFieldList &fieldList) : m_elements(), m_elementsOrder(fieldList.m_elementsOrder), m_id(fieldList.m_id), m_level(fieldList.m_level) { - std::map<unsigned, VSDXFieldListElement *>::const_iterator iter = fieldList.m_elements.begin(); + std::map<unsigned, VSDFieldListElement *>::const_iterator iter = fieldList.m_elements.begin(); for (; iter != fieldList.m_elements.end(); ++iter) m_elements[iter->first] = iter->second->clone(); } -libvisio::VSDXFieldList &libvisio::VSDXFieldList::operator=(const libvisio::VSDXFieldList &fieldList) +libvisio::VSDFieldList &libvisio::VSDFieldList::operator=(const libvisio::VSDFieldList &fieldList) { if (this != &fieldList) { clear(); - std::map<unsigned, VSDXFieldListElement *>::const_iterator iter = fieldList.m_elements.begin(); + std::map<unsigned, VSDFieldListElement *>::const_iterator iter = fieldList.m_elements.begin(); for (; iter != fieldList.m_elements.end(); ++iter) m_elements[iter->first] = iter->second->clone(); m_elementsOrder = fieldList.m_elementsOrder; @@ -213,41 +213,41 @@ libvisio::VSDXFieldList &libvisio::VSDXFieldList::operator=(const libvisio::VSDX return *this; } -libvisio::VSDXFieldList::~VSDXFieldList() +libvisio::VSDFieldList::~VSDFieldList() { clear(); } -void libvisio::VSDXFieldList::setElementsOrder(const std::vector<unsigned> &elementsOrder) +void libvisio::VSDFieldList::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::VSDXFieldList::addFieldList(unsigned id, unsigned level) +void libvisio::VSDFieldList::addFieldList(unsigned id, unsigned level) { m_id = id; m_level = level; } -void libvisio::VSDXFieldList::addTextField(unsigned id, unsigned level, int nameId, int formatStringId) +void libvisio::VSDFieldList::addTextField(unsigned id, unsigned level, int nameId, int formatStringId) { - m_elements[id] = new VSDXTextField(id, level, nameId, formatStringId); + m_elements[id] = new VSDTextField(id, level, nameId, formatStringId); } -void libvisio::VSDXFieldList::addNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId) +void libvisio::VSDFieldList::addNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId) { - m_elements[id] = new VSDXNumericField(id, level, format, number, formatStringId); + m_elements[id] = new VSDNumericField(id, level, format, number, formatStringId); } -void libvisio::VSDXFieldList::handle(VSDXCollector *collector) +void libvisio::VSDFieldList::handle(VSDCollector *collector) { if (empty()) return; collector->collectFieldList(m_id, m_level); - std::map<unsigned, VSDXFieldListElement *>::iterator iter; + std::map<unsigned, VSDFieldListElement *>::iterator iter; if (!m_elementsOrder.empty()) { for (unsigned i = 0; i < m_elementsOrder.size(); i++) @@ -264,20 +264,20 @@ void libvisio::VSDXFieldList::handle(VSDXCollector *collector) } } -void libvisio::VSDXFieldList::clear() +void libvisio::VSDFieldList::clear() { - for (std::map<unsigned, VSDXFieldListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) + for (std::map<unsigned, VSDFieldListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) delete iter->second; m_elements.clear(); m_elementsOrder.clear(); } -libvisio::VSDXFieldListElement *libvisio::VSDXFieldList::getElement(unsigned index) +libvisio::VSDFieldListElement *libvisio::VSDFieldList::getElement(unsigned index) { if (m_elementsOrder.size() > index) index = m_elementsOrder[index]; - std::map<unsigned, VSDXFieldListElement *>::const_iterator iter = m_elements.find(index); + std::map<unsigned, VSDFieldListElement *>::const_iterator iter = m_elements.find(index); if (iter != m_elements.end()) return iter->second; else diff --git a/src/lib/VSDXFieldList.h b/src/lib/VSDFieldList.h index 7ae9cd8..b0853bc 100644 --- a/src/lib/VSDXFieldList.h +++ b/src/lib/VSDFieldList.h @@ -28,44 +28,44 @@ * instead of those above. */ -#ifndef __VSDXFIELDLIST_H__ -#define __VSDXFIELDLIST_H__ +#ifndef __VSDFIELDLIST_H__ +#define __VSDFIELDLIST_H__ #include <vector> #include <map> #include <libwpd/libwpd.h> -#include "VSDXDocumentStructure.h" -#include "VSDXTypes.h" +#include "VSDDocumentStructure.h" +#include "VSDTypes.h" namespace libvisio { -class VSDXCollector; +class VSDCollector; -class VSDXFieldListElement +class VSDFieldListElement { public: - VSDXFieldListElement() {} - virtual ~VSDXFieldListElement() {} - virtual void handle(VSDXCollector *collector) = 0; - virtual VSDXFieldListElement *clone() = 0; + VSDFieldListElement() {} + virtual ~VSDFieldListElement() {} + virtual void handle(VSDCollector *collector) = 0; + virtual VSDFieldListElement *clone() = 0; virtual WPXString getString(const std::map<unsigned, WPXString>&) = 0; virtual void setNameId(int) = 0; virtual void setFormat(unsigned short) = 0; virtual void setValue(double) = 0; }; -class VSDXTextField : public VSDXFieldListElement +class VSDTextField : public VSDFieldListElement { public: - VSDXTextField(unsigned id, unsigned level, int nameId, int formatStringId) + VSDTextField(unsigned id, unsigned level, int nameId, int formatStringId) : m_id(id), m_level(level), m_nameId(nameId), m_formatStringId(formatStringId) {} - ~VSDXTextField() {} - void handle(VSDXCollector *collector); - VSDXFieldListElement *clone(); + ~VSDTextField() {} + void handle(VSDCollector *collector); + VSDFieldListElement *clone(); WPXString getString(const std::map<unsigned, WPXString> &strVec); void setNameId(int nameId); void setFormat(unsigned short) {} @@ -75,18 +75,18 @@ private: int m_nameId, m_formatStringId; }; -class VSDXNumericField : public VSDXFieldListElement +class VSDNumericField : public VSDFieldListElement { public: - VSDXNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId) + VSDNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId) : m_id(id), m_level(level), m_format(format), m_number(number), m_formatStringId(formatStringId) {} - ~VSDXNumericField() {} - void handle(VSDXCollector *collector); - VSDXFieldListElement *clone(); + ~VSDNumericField() {} + void handle(VSDCollector *collector); + VSDFieldListElement *clone(); WPXString getString(const std::map<unsigned, WPXString> &); void setNameId(int) {} void setFormat(unsigned short format); @@ -99,19 +99,19 @@ private: int m_formatStringId; }; -class VSDXFieldList +class VSDFieldList { public: - VSDXFieldList(); - VSDXFieldList(const VSDXFieldList &fieldList); - ~VSDXFieldList(); - VSDXFieldList &operator=(const VSDXFieldList &fieldList); + VSDFieldList(); + VSDFieldList(const VSDFieldList &fieldList); + ~VSDFieldList(); + VSDFieldList &operator=(const VSDFieldList &fieldList); void setElementsOrder(const std::vector<unsigned> &m_elementsOrder); void addFieldList(unsigned id, unsigned level); void addTextField(unsigned id, unsigned level, int nameId, int formatStringId); void addNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId); void addClonedField(unsigned id); - void handle(VSDXCollector *collector); + void handle(VSDCollector *collector); void clear(); unsigned long size() const { @@ -121,14 +121,14 @@ public: { return (m_elements.empty()); } - VSDXFieldListElement *getElement(unsigned index); + VSDFieldListElement *getElement(unsigned index); private: - std::map<unsigned, VSDXFieldListElement *> m_elements; + std::map<unsigned, VSDFieldListElement *> m_elements; std::vector<unsigned> m_elementsOrder; unsigned m_id, m_level; }; } // namespace libvisio -#endif // __VSDXFIELDLIST_H__ +#endif // __VSDFIELDLIST_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDGeometryList.cpp b/src/lib/VSDGeometryList.cpp new file mode 100644 index 0000000..5047c38 --- /dev/null +++ b/src/lib/VSDGeometryList.cpp @@ -0,0 +1,492 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libvisio + * Version: MPL 1.1 / GPLv2+ / LGPLv2+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> + * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> + * + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPLv2+"), or + * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), + * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable + * instead of those above. + */ + +#include "VSDCollector.h" +#include "VSDGeometryList.h" +#include "libvisio_utils.h" + +namespace libvisio +{ + + +class VSDGeometry : public VSDGeometryListElement +{ +public: + VSDGeometry(unsigned id, unsigned level, unsigned geomFlags) : + m_id(id), m_level(level), m_geomFlags(geomFlags) {} + ~VSDGeometry() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id; + unsigned m_level; + unsigned char m_geomFlags; +}; + +class VSDMoveTo : public VSDGeometryListElement +{ +public: + VSDMoveTo(unsigned id, unsigned level, double x, double y) : + m_id(id), m_level(level), m_x(x), m_y(y) {} + ~VSDMoveTo() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x, m_y; +}; + +class VSDLineTo : public VSDGeometryListElement +{ +public: + VSDLineTo(unsigned id, unsigned level, double x, double y) : + m_id(id), m_level(level), m_x(x), m_y(y) {} + ~VSDLineTo() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x, m_y; +}; + +class VSDArcTo : public VSDGeometryListElement +{ +public: + VSDArcTo(unsigned id, unsigned level, double x2, double y2, double bow) : + m_id(id), m_level(level), m_x2(x2), m_y2(y2), m_bow(bow) {} + ~VSDArcTo() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x2, m_y2, m_bow; +}; + +class VSDEllipse : public VSDGeometryListElement +{ +public: + VSDEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop) : + m_id(id), m_level(level), m_cx(cx), m_cy(cy), m_xleft(xleft), m_yleft(yleft), m_xtop(xtop), m_ytop(ytop) {} + ~VSDEllipse() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_cx, m_cy, m_xleft, m_yleft, m_xtop, m_ytop; +}; + +class VSDEllipticalArcTo : public VSDGeometryListElement +{ +public: + VSDEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) : + m_id(id), m_level(level), m_x3(x3), m_y3(y3), m_x2(x2), m_y2(y2), m_angle(angle), m_ecc(ecc) {} + ~VSDEllipticalArcTo() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x3, m_y3, m_x2, m_y2, m_angle, m_ecc; +}; + +class VSDNURBSTo1 : public VSDGeometryListElement +{ +public: + VSDNURBSTo1(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree, std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) : + m_id(id), m_level(level), m_x2(x2), m_y2(y2), m_xType(xType), m_yType(yType), m_degree(degree), m_controlPoints(controlPoints), m_knotVector(knotVector), m_weights(weights) {} + ~VSDNURBSTo1() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x2, m_y2; + unsigned m_xType, m_yType; + unsigned m_degree; + std::vector<std::pair<double, double> > m_controlPoints; + std::vector<double> m_knotVector, m_weights; +}; + +class VSDPolylineTo1 : public VSDGeometryListElement +{ +public: + VSDPolylineTo1(unsigned id , unsigned level, double x, double y, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points) : + m_id(id), m_level(level), m_x(x), m_y(y), m_xType(xType), m_yType(yType), m_points(points) {} + ~VSDPolylineTo1() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x, m_y; + unsigned m_xType, m_yType; + std::vector<std::pair<double, double> > m_points; +}; + +class VSDSplineStart : public VSDGeometryListElement +{ +public: + VSDSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) : + m_id(id), m_level(level), m_x(x), m_y(y), m_secondKnot(secondKnot), m_firstKnot(firstKnot), m_lastKnot(lastKnot), m_degree(degree) {} + ~VSDSplineStart() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x, m_y; + double m_secondKnot, m_firstKnot, m_lastKnot; + unsigned m_degree; +}; + +class VSDSplineKnot : public VSDGeometryListElement +{ +public: + VSDSplineKnot(unsigned id, unsigned level, double x, double y, double knot) : + m_id(id), m_level(level), m_x(x), m_y(y), m_knot(knot) {} + ~VSDSplineKnot() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x, m_y; + double m_knot; +}; + +class VSDInfiniteLine : public VSDGeometryListElement +{ +public: + VSDInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2) : + m_id(id), m_level(level), m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2) {} + ~VSDInfiniteLine() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x1, m_y1, m_x2, m_y2; +}; + +} // namespace libvisio + + +void libvisio::VSDGeometry::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectGeometry(m_id, m_level, m_geomFlags); +} + +libvisio::VSDGeometryListElement *libvisio::VSDGeometry::clone() +{ + return new VSDGeometry(m_id, m_level, m_geomFlags); +} + + +void libvisio::VSDMoveTo::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectMoveTo(m_id, m_level, m_x, m_y); +} + +libvisio::VSDGeometryListElement *libvisio::VSDMoveTo::clone() +{ + return new VSDMoveTo(m_id, m_level, m_x, m_y); +} + + +void libvisio::VSDLineTo::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectLineTo(m_id, m_level, m_x, m_y); +} + +libvisio::VSDGeometryListElement *libvisio::VSDLineTo::clone() +{ + return new VSDLineTo(m_id, m_level, m_x, m_y); +} + + +void libvisio::VSDArcTo::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectArcTo(m_id, m_level, m_x2, m_y2, m_bow); +} + +libvisio::VSDGeometryListElement *libvisio::VSDArcTo::clone() +{ + return new VSDArcTo(m_id, m_level, m_x2, m_y2, m_bow); +} + + +void libvisio::VSDEllipse::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectEllipse(m_id, m_level, m_cx, m_cy, m_xleft, m_yleft, m_xtop, m_ytop); +} + +libvisio::VSDGeometryListElement *libvisio::VSDEllipse::clone() +{ + return new VSDEllipse(m_id, m_level, m_cx, m_cy, m_xleft, m_yleft, m_xtop, m_ytop); +} + + +void libvisio::VSDEllipticalArcTo::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectEllipticalArcTo(m_id, m_level, m_x3, m_y3, m_x2, m_y2, m_angle, m_ecc); +} + +libvisio::VSDGeometryListElement *libvisio::VSDEllipticalArcTo::clone() +{ + return new VSDEllipticalArcTo(m_id, m_level, m_x3, m_y3, m_x2, m_y2, m_angle, m_ecc); +} + + +void libvisio::VSDNURBSTo1::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectNURBSTo(m_id, m_level, m_x2, m_y2, m_xType, m_yType, m_degree, m_controlPoints, m_knotVector, m_weights); +} + +libvisio::VSDGeometryListElement *libvisio::VSDNURBSTo1::clone() +{ + return new VSDNURBSTo1(m_id, m_level, m_x2, m_y2, m_xType, m_yType, m_degree, m_controlPoints, m_knotVector, m_weights); +} + + +void libvisio::VSDNURBSTo2::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectNURBSTo(m_id, m_level, m_x2, m_y2, m_knot, m_knotPrev, m_weight, m_weightPrev, m_dataID); +} + +libvisio::VSDGeometryListElement *libvisio::VSDNURBSTo2::clone() +{ + return new VSDNURBSTo2(m_id, m_level, m_x2, m_y2, m_knot, m_knotPrev, m_weight, m_weightPrev, m_dataID); +} + + +void libvisio::VSDPolylineTo1::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectPolylineTo(m_id, m_level, m_x, m_y, m_xType, m_yType, m_points); +} + +libvisio::VSDGeometryListElement *libvisio::VSDPolylineTo1::clone() +{ + return new VSDPolylineTo1(m_id, m_level, m_x, m_y, m_xType, m_yType, m_points); +} + + +void libvisio::VSDPolylineTo2::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectPolylineTo(m_id, m_level, m_x, m_y, m_dataID); +} + +libvisio::VSDGeometryListElement *libvisio::VSDPolylineTo2::clone() +{ + return new VSDPolylineTo2(m_id, m_level, m_x, m_y, m_dataID); +} + + +void libvisio::VSDSplineStart::handle(VSDCollector *collector) +{ + collector->collectSplineStart(m_id, m_level, m_x, m_y, m_secondKnot, m_firstKnot, m_lastKnot, m_degree); +} + +libvisio::VSDGeometryListElement *libvisio::VSDSplineStart::clone() +{ + return new VSDSplineStart(m_id, m_level, m_x, m_y, m_secondKnot, m_firstKnot, m_lastKnot, m_degree); +} + + +void libvisio::VSDSplineKnot::handle(VSDCollector *collector) +{ + collector->collectSplineKnot(m_id, m_level, m_x, m_y, m_knot); +} + +libvisio::VSDGeometryListElement *libvisio::VSDSplineKnot::clone() +{ + return new VSDSplineKnot(m_id, m_level, m_x, m_y, m_knot); +} + + +void libvisio::VSDInfiniteLine::handle(VSDCollector *collector) +{ + collector->collectSplineEnd(); + collector->collectInfiniteLine(m_id, m_level, m_x1, m_y1, m_x2, m_y2); +} + +libvisio::VSDGeometryListElement *libvisio::VSDInfiniteLine::clone() +{ + return new VSDInfiniteLine(m_id, m_level, m_x1, m_y1, m_x2, m_y2); +} + + +libvisio::VSDGeometryList::VSDGeometryList() : + m_elements(), + m_elementsOrder() +{ +} + +libvisio::VSDGeometryList::VSDGeometryList(const VSDGeometryList &geomList) : + m_elements(), + m_elementsOrder(geomList.m_elementsOrder) +{ + std::map<unsigned, VSDGeometryListElement *>::const_iterator iter = geomList.m_elements.begin(); + for (; iter != geomList.m_elements.end(); ++iter) + m_elements[iter->first] = iter->second->clone(); +} + +libvisio::VSDGeometryList &libvisio::VSDGeometryList::operator=(const VSDGeometryList &geomList) +{ + clear(); + std::map<unsigned, VSDGeometryListElement *>::const_iterator iter = geomList.m_elements.begin(); + for (; iter != geomList.m_elements.end(); ++iter) + m_elements[iter->first] = iter->second->clone(); + m_elementsOrder = geomList.m_elementsOrder; + return *this; +} + +libvisio::VSDGeometryList::~VSDGeometryList() +{ + clear(); +} + +void libvisio::VSDGeometryList::addGeometry(unsigned id, unsigned level, unsigned char geomFlags) +{ + m_elements[id] = new VSDGeometry(id, level, geomFlags); +} + +void libvisio::VSDGeometryList::addMoveTo(unsigned id, unsigned level, double x, double y) +{ + m_elements[id] = new VSDMoveTo(id, level, x, y); +} + +void libvisio::VSDGeometryList::addLineTo(unsigned id, unsigned level, double x, double y) +{ + m_elements[id] = new VSDLineTo(id, level, x, y); +} + +void libvisio::VSDGeometryList::addArcTo(unsigned id, unsigned level, double x2, double y2, double bow) +{ + m_elements[id] = new VSDArcTo(id, level, x2, y2, bow); +} + +void libvisio::VSDGeometryList::addNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree, std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) +{ + m_elements[id] = new VSDNURBSTo1(id, level, x2, y2, xType, yType, degree, controlPoints, knotVector, weights); +} + +void libvisio::VSDGeometryList::addNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID) +{ + m_elements[id] = new VSDNURBSTo2(id, level, x2, y2, knot, knotPrev, weight, weightPrev, dataID); +} + +void libvisio::VSDGeometryList::addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points) +{ + m_elements[id] = new VSDPolylineTo1(id, level, x, y, xType, yType, points); +} + +void libvisio::VSDGeometryList::addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned dataID) +{ + m_elements[id] = new VSDPolylineTo2(id, level, x, y, dataID); +} + +void libvisio::VSDGeometryList::addEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop) +{ + m_elements[id] = new VSDEllipse(id, level, cx, cy, xleft, yleft, xtop, ytop); +} + +void libvisio::VSDGeometryList::addEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) +{ + m_elements[id] = new VSDEllipticalArcTo(id, level, x3, y3, x2, y2, angle, ecc); +} + +void libvisio::VSDGeometryList::addSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) +{ + m_elements[id] = new VSDSplineStart(id, level, x, y, secondKnot, firstKnot, lastKnot, degree); +} + +void libvisio::VSDGeometryList::addSplineKnot(unsigned id, unsigned level, double x, double y, double knot) +{ + m_elements[id] = new VSDSplineKnot(id, level, x, y, knot); +} + +void libvisio::VSDGeometryList::addInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2) +{ + m_elements[id] = new VSDInfiniteLine(id, level, x1, y1, x2, y2); +} + +void libvisio::VSDGeometryList::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::VSDGeometryList::handle(VSDCollector *collector) const +{ + if (empty()) + return; + std::map<unsigned, VSDGeometryListElement *>::const_iterator iter; + if (!m_elementsOrder.empty()) + { + 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); + } + collector->collectSplineEnd(); +} + +void libvisio::VSDGeometryList::clear() +{ + for (std::map<unsigned, VSDGeometryListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) + delete iter->second; + m_elements.clear(); + m_elementsOrder.clear(); +} + +libvisio::VSDGeometryListElement *libvisio::VSDGeometryList::getElement(unsigned index) const +{ + if (m_elementsOrder.size() > index) + index = m_elementsOrder[index]; + + std::map<unsigned, VSDGeometryListElement *>::const_iterator iter = m_elements.find(index); + if (iter != m_elements.end()) + return iter->second; + else + return 0; +} +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXGeometryList.h b/src/lib/VSDGeometryList.h index af96a38..f05dd5f 100644 --- a/src/lib/VSDXGeometryList.h +++ b/src/lib/VSDGeometryList.h @@ -28,8 +28,8 @@ * instead of those above. */ -#ifndef __VSDXGEOMETRYLIST_H__ -#define __VSDXGEOMETRYLIST_H__ +#ifndef __VSDGEOMETRYLIST_H__ +#define __VSDGEOMETRYLIST_H__ #include <vector> #include <map> @@ -37,16 +37,16 @@ namespace libvisio { -class VSDXGeometryListElement; -class VSDXCollector; +class VSDGeometryListElement; +class VSDCollector; -class VSDXGeometryList +class VSDGeometryList { public: - VSDXGeometryList(); - VSDXGeometryList(const VSDXGeometryList &geomList); - ~VSDXGeometryList(); - VSDXGeometryList &operator=(const VSDXGeometryList &geomList); + VSDGeometryList(); + VSDGeometryList(const VSDGeometryList &geomList); + ~VSDGeometryList(); + VSDGeometryList &operator=(const VSDGeometryList &geomList); void addGeometry(unsigned id, unsigned level, unsigned char geomFlags); void addMoveTo(unsigned id, unsigned level, double x, double y); @@ -62,13 +62,13 @@ public: void addSplineKnot(unsigned id, unsigned level, double x, double y, double knot); void addInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2); void setElementsOrder(const std::vector<unsigned> &m_elementsOrder); - void handle(VSDXCollector *collector) const; + void handle(VSDCollector *collector) const; void clear(); bool empty() const { return (m_elements.empty()); } - VSDXGeometryListElement *getElement(unsigned index) const; + VSDGeometryListElement *getElement(unsigned index) const; std::vector<unsigned> getElementsOrder() const { return m_elementsOrder; @@ -78,41 +78,41 @@ public: return m_elements.size(); } private: - std::map<unsigned, VSDXGeometryListElement *> m_elements; + std::map<unsigned, VSDGeometryListElement *> m_elements; std::vector<unsigned> m_elementsOrder; }; -class VSDXGeometryListElement +class VSDGeometryListElement { public: - VSDXGeometryListElement() {} - virtual ~VSDXGeometryListElement() {} - virtual void handle(VSDXCollector *collector) = 0; - virtual VSDXGeometryListElement *clone() = 0; + VSDGeometryListElement() {} + virtual ~VSDGeometryListElement() {} + virtual void handle(VSDCollector *collector) = 0; + virtual VSDGeometryListElement *clone() = 0; }; -class VSDXPolylineTo2 : public VSDXGeometryListElement +class VSDPolylineTo2 : public VSDGeometryListElement { public: - VSDXPolylineTo2(unsigned id , unsigned level, double x, double y, unsigned dataID) : + VSDPolylineTo2(unsigned id , unsigned level, double x, double y, unsigned dataID) : m_dataID(dataID), m_id(id), m_level(level), m_x(x), m_y(y) {} - ~VSDXPolylineTo2() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); + ~VSDPolylineTo2() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); unsigned m_dataID; private: unsigned m_id, m_level; double m_x, m_y; }; -class VSDXNURBSTo2 : public VSDXGeometryListElement +class VSDNURBSTo2 : public VSDGeometryListElement { public: - VSDXNURBSTo2(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID) : + VSDNURBSTo2(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID) : m_dataID(dataID), m_id(id), m_level(level), m_x2(x2), m_y2(y2), m_knot(knot), m_knotPrev(knotPrev), m_weight(weight), m_weightPrev(weightPrev) {} - ~VSDXNURBSTo2() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); + ~VSDNURBSTo2() {} + void handle(VSDCollector *collector); + VSDGeometryListElement *clone(); unsigned m_dataID; private: unsigned m_id, m_level; @@ -124,5 +124,5 @@ private: } // namespace libvisio -#endif // __VSDXGEOMETRYLIST_H__ +#endif // __VSDGEOMETRYLIST_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDInternalStream.cpp b/src/lib/VSDInternalStream.cpp index cafa091..a9d59fe 100644 --- a/src/lib/VSDInternalStream.cpp +++ b/src/lib/VSDInternalStream.cpp @@ -32,6 +32,13 @@ #include "VSDInternalStream.h" +VSDInternalStream::VSDInternalStream(const std::vector<unsigned char> &buffer) : + WPXInputStream(), + m_offset(0), + m_buffer(buffer) +{ +} + VSDInternalStream::VSDInternalStream(WPXInputStream *input, unsigned long size, bool compressed) : WPXInputStream(), m_offset(0), diff --git a/src/lib/VSDInternalStream.h b/src/lib/VSDInternalStream.h index 8be280c..38f1d42 100644 --- a/src/lib/VSDInternalStream.h +++ b/src/lib/VSDInternalStream.h @@ -39,7 +39,8 @@ class VSDInternalStream : public WPXInputStream { public: - VSDInternalStream(WPXInputStream *input, unsigned long size, bool compressed); + VSDInternalStream(WPXInputStream *input, unsigned long size, bool compressed=false); + VSDInternalStream(const std::vector<unsigned char> &buffer); ~VSDInternalStream() {} bool isOLEStream() diff --git a/src/lib/VSDOutputElementList.cpp b/src/lib/VSDOutputElementList.cpp new file mode 100644 index 0000000..7ec9e13 --- /dev/null +++ b/src/lib/VSDOutputElementList.cpp @@ -0,0 +1,441 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libvisio + * Version: MPL 1.1 / GPLv2+ / LGPLv2+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> + * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> + * + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPLv2+"), or + * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), + * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable + * instead of those above. + */ + +#include "VSDOutputElementList.h" + +namespace libvisio +{ + +class VSDOutputElement +{ +public: + VSDOutputElement() {} + virtual ~VSDOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter) = 0; + virtual VSDOutputElement *clone() = 0; +}; + + +class VSDStyleOutputElement : public VSDOutputElement +{ +public: + VSDStyleOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec); + virtual ~VSDStyleOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDStyleOutputElement(m_propList, m_propListVec); + } +private: + WPXPropertyList m_propList; + WPXPropertyListVector m_propListVec; +}; + + +class VSDPathOutputElement : public VSDOutputElement +{ +public: + VSDPathOutputElement(const WPXPropertyListVector &propListVec); + virtual ~VSDPathOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDPathOutputElement(m_propListVec); + } +private: + WPXPropertyListVector m_propListVec; +}; + + +class VSDGraphicObjectOutputElement : public VSDOutputElement +{ +public: + VSDGraphicObjectOutputElement(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData); + virtual ~VSDGraphicObjectOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDGraphicObjectOutputElement(m_propList, m_binaryData); + } +private: + WPXPropertyList m_propList; + WPXBinaryData m_binaryData; +}; + + +class VSDStartTextObjectOutputElement : public VSDOutputElement +{ +public: + VSDStartTextObjectOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec); + virtual ~VSDStartTextObjectOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDStartTextObjectOutputElement(m_propList, m_propListVec); + } +private: + WPXPropertyList m_propList; + WPXPropertyListVector m_propListVec; +}; + + +class VSDStartTextLineOutputElement : public VSDOutputElement +{ +public: + VSDStartTextLineOutputElement(const WPXPropertyList &propList); + virtual ~VSDStartTextLineOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDStartTextLineOutputElement(m_propList); + } +private: + WPXPropertyList m_propList; +}; + + +class VSDStartLayerOutputElement : public VSDOutputElement +{ +public: + VSDStartLayerOutputElement(const WPXPropertyList &propList); + virtual ~VSDStartLayerOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDStartLayerOutputElement(m_propList); + } +private: + WPXPropertyList m_propList; +}; + + +class VSDEndLayerOutputElement : public VSDOutputElement +{ +public: + VSDEndLayerOutputElement(); + virtual ~VSDEndLayerOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDEndLayerOutputElement(); + } +}; + + +class VSDStartTextSpanOutputElement : public VSDOutputElement +{ +public: + VSDStartTextSpanOutputElement(const WPXPropertyList &propList); + virtual ~VSDStartTextSpanOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDStartTextSpanOutputElement(m_propList); + } +private: + WPXPropertyList m_propList; +}; + + +class VSDInsertTextOutputElement : public VSDOutputElement +{ +public: + VSDInsertTextOutputElement(const WPXString &text); + virtual ~VSDInsertTextOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDInsertTextOutputElement(m_text); + } +private: + WPXString m_text; +}; + + +class VSDEndTextSpanOutputElement : public VSDOutputElement +{ +public: + VSDEndTextSpanOutputElement(); + virtual ~VSDEndTextSpanOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDEndTextSpanOutputElement(); + } +}; + + +class VSDEndTextLineOutputElement : public VSDOutputElement +{ +public: + VSDEndTextLineOutputElement(); + virtual ~VSDEndTextLineOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDEndTextLineOutputElement(); + } +}; + + +class VSDEndTextObjectOutputElement : public VSDOutputElement +{ +public: + VSDEndTextObjectOutputElement(); + virtual ~VSDEndTextObjectOutputElement() {} + virtual void draw(libwpg::WPGPaintInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDEndTextObjectOutputElement(); + } +}; + +} // namespace libvisio + +libvisio::VSDStyleOutputElement::VSDStyleOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) : + m_propList(propList), m_propListVec(propListVec) {} + +void libvisio::VSDStyleOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->setStyle(m_propList, m_propListVec); +} + + +libvisio::VSDPathOutputElement::VSDPathOutputElement(const WPXPropertyListVector &propListVec) : + m_propListVec(propListVec) {} + +void libvisio::VSDPathOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->drawPath(m_propListVec); +} + + +libvisio::VSDGraphicObjectOutputElement::VSDGraphicObjectOutputElement(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData) : + m_propList(propList), m_binaryData(binaryData) {} + +void libvisio::VSDGraphicObjectOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->drawGraphicObject(m_propList, m_binaryData); +} + + +libvisio::VSDStartTextObjectOutputElement::VSDStartTextObjectOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) : + m_propList(propList), m_propListVec(propListVec) {} + +void libvisio::VSDStartTextObjectOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->startTextObject(m_propList, m_propListVec); +} + +libvisio::VSDStartTextSpanOutputElement::VSDStartTextSpanOutputElement(const WPXPropertyList &propList) : + m_propList(propList) {} + +void libvisio::VSDStartTextSpanOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->startTextSpan(m_propList); +} + + +libvisio::VSDStartLayerOutputElement::VSDStartLayerOutputElement(const WPXPropertyList &propList) : + m_propList(propList) {} + +void libvisio::VSDStartLayerOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->startLayer(m_propList); +} + + +libvisio::VSDEndLayerOutputElement::VSDEndLayerOutputElement() {} + +void libvisio::VSDEndLayerOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->endLayer(); +} + + +libvisio::VSDStartTextLineOutputElement::VSDStartTextLineOutputElement(const WPXPropertyList &propList) : + m_propList(propList) {} + +void libvisio::VSDStartTextLineOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->startTextLine(m_propList); +} + + +libvisio::VSDInsertTextOutputElement::VSDInsertTextOutputElement(const WPXString &text) : + m_text(text) {} + +void libvisio::VSDInsertTextOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->insertText(m_text); +} + +libvisio::VSDEndTextSpanOutputElement::VSDEndTextSpanOutputElement() {} + +void libvisio::VSDEndTextSpanOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->endTextSpan(); +} + + +libvisio::VSDEndTextLineOutputElement::VSDEndTextLineOutputElement() {} + +void libvisio::VSDEndTextLineOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->endTextLine(); +} + + +libvisio::VSDEndTextObjectOutputElement::VSDEndTextObjectOutputElement() {} + +void libvisio::VSDEndTextObjectOutputElement::draw(libwpg::WPGPaintInterface *painter) +{ + if (painter) + painter->endTextObject(); +} + + +libvisio::VSDOutputElementList::VSDOutputElementList() + : m_elements() +{ +} + +libvisio::VSDOutputElementList::VSDOutputElementList(const libvisio::VSDOutputElementList &elementList) + : m_elements() +{ + std::vector<libvisio::VSDOutputElement *>::const_iterator iter; + for (iter = elementList.m_elements.begin(); iter != elementList.m_elements.end(); ++iter) + m_elements.push_back((*iter)->clone()); +} + +libvisio::VSDOutputElementList &libvisio::VSDOutputElementList::operator=(const libvisio::VSDOutputElementList &elementList) +{ + for (std::vector<VSDOutputElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) + delete (*iter); + + m_elements.clear(); + + for (std::vector<VSDOutputElement *>::const_iterator cstiter = elementList.m_elements.begin(); cstiter != elementList.m_elements.end(); ++cstiter) + m_elements.push_back((*cstiter)->clone()); + + return *this; +} + +void libvisio::VSDOutputElementList::append(const libvisio::VSDOutputElementList &elementList) +{ + for (std::vector<VSDOutputElement *>::const_iterator cstiter = elementList.m_elements.begin(); cstiter != elementList.m_elements.end(); ++cstiter) + m_elements.push_back((*cstiter)->clone()); +} + +libvisio::VSDOutputElementList::~VSDOutputElementList() +{ + for (std::vector<VSDOutputElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) + delete (*iter); + m_elements.clear(); +} + +void libvisio::VSDOutputElementList::draw(libwpg::WPGPaintInterface *painter) const +{ + for (std::vector<VSDOutputElement *>::const_iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) + (*iter)->draw(painter); +} + +void libvisio::VSDOutputElementList::addStyle(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) +{ + m_elements.push_back(new VSDStyleOutputElement(propList, propListVec)); +} + +void libvisio::VSDOutputElementList::addPath(const WPXPropertyListVector &propListVec) +{ + m_elements.push_back(new VSDPathOutputElement(propListVec)); +} + +void libvisio::VSDOutputElementList::addGraphicObject(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData) +{ + m_elements.push_back(new VSDGraphicObjectOutputElement(propList, binaryData)); +} + +void libvisio::VSDOutputElementList::addStartTextObject(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) +{ + m_elements.push_back(new VSDStartTextObjectOutputElement(propList, propListVec)); +} + +void libvisio::VSDOutputElementList::addStartTextLine(const WPXPropertyList &propList) +{ + m_elements.push_back(new VSDStartTextLineOutputElement(propList)); +} + +void libvisio::VSDOutputElementList::addStartTextSpan(const WPXPropertyList &propList) +{ + m_elements.push_back(new VSDStartTextSpanOutputElement(propList)); +} + +void libvisio::VSDOutputElementList::addInsertText(const WPXString &text) +{ + m_elements.push_back(new VSDInsertTextOutputElement(text)); +} + +void libvisio::VSDOutputElementList::addEndTextSpan() +{ + m_elements.push_back(new VSDEndTextSpanOutputElement()); +} + +void libvisio::VSDOutputElementList::addEndTextLine() +{ + m_elements.push_back(new VSDEndTextLineOutputElement()); +} + +void libvisio::VSDOutputElementList::addEndTextObject() +{ + m_elements.push_back(new VSDEndTextObjectOutputElement()); +} + +void libvisio::VSDOutputElementList::addStartLayer(const WPXPropertyList &propList) +{ + m_elements.push_back(new VSDStartLayerOutputElement(propList)); +} + +void libvisio::VSDOutputElementList::addEndLayer() +{ + m_elements.push_back(new VSDEndLayerOutputElement()); +} + +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXOutputElementList.h b/src/lib/VSDOutputElementList.h index 6c5904b..0ae203f 100644 --- a/src/lib/VSDXOutputElementList.h +++ b/src/lib/VSDOutputElementList.h @@ -28,8 +28,8 @@ * instead of those above. */ -#ifndef __VSDXOUTPUTELEMENTLIST_H__ -#define __VSDXOUTPUTELEMENTLIST_H__ +#ifndef __VSDOUTPUTELEMENTLIST_H__ +#define __VSDOUTPUTELEMENTLIST_H__ #include <map> #include <list> @@ -40,16 +40,16 @@ namespace libvisio { -class VSDXOutputElement; +class VSDOutputElement; -class VSDXOutputElementList +class VSDOutputElementList { public: - VSDXOutputElementList(); - VSDXOutputElementList(const VSDXOutputElementList &elementList); - VSDXOutputElementList &operator=(const VSDXOutputElementList &elementList); - virtual ~VSDXOutputElementList(); - void append(const VSDXOutputElementList &elementList); + VSDOutputElementList(); + VSDOutputElementList(const VSDOutputElementList &elementList); + VSDOutputElementList &operator=(const VSDOutputElementList &elementList); + virtual ~VSDOutputElementList(); + void append(const VSDOutputElementList &elementList); void draw(libwpg::WPGPaintInterface *painter) const; void addStyle(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec); void addPath(const WPXPropertyListVector &propListVec); @@ -68,11 +68,11 @@ public: return m_elements.empty(); } private: - std::vector<VSDXOutputElement *> m_elements; + std::vector<VSDOutputElement *> m_elements; }; } // namespace libvisio -#endif // __VSDXOUTPUTELEMENTLIST_H__ +#endif // __VSDOUTPUTELEMENTLIST_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXPages.cpp b/src/lib/VSDPages.cpp index 56da18a..de4deda 100644 --- a/src/lib/VSDXPages.cpp +++ b/src/lib/VSDPages.cpp @@ -28,28 +28,28 @@ * instead of those above. */ -#include "VSDXPages.h" +#include "VSDPages.h" #include "libvisio_utils.h" -libvisio::VSDXPage::VSDXPage() +libvisio::VSDPage::VSDPage() : m_pageWidth(0.0), m_pageHeight(0.0), m_currentPageID(0), m_backgroundPageID(0xffffffff), m_pageElements() { } -libvisio::VSDXPage::VSDXPage(const libvisio::VSDXPage &page) +libvisio::VSDPage::VSDPage(const libvisio::VSDPage &page) : m_pageWidth(page.m_pageWidth), m_pageHeight(page.m_pageHeight), m_currentPageID(page.m_currentPageID), m_backgroundPageID(page.m_backgroundPageID), m_pageElements(page.m_pageElements) { } -libvisio::VSDXPage::~VSDXPage() +libvisio::VSDPage::~VSDPage() { } -libvisio::VSDXPage &libvisio::VSDXPage::operator=(const libvisio::VSDXPage &page) +libvisio::VSDPage &libvisio::VSDPage::operator=(const libvisio::VSDPage &page) { if (this != &page) { @@ -62,36 +62,36 @@ libvisio::VSDXPage &libvisio::VSDXPage::operator=(const libvisio::VSDXPage &page return *this; } -void libvisio::VSDXPage::append(const libvisio::VSDXOutputElementList &outputElements) +void libvisio::VSDPage::append(const libvisio::VSDOutputElementList &outputElements) { m_pageElements.append(outputElements); } -void libvisio::VSDXPage::draw(libwpg::WPGPaintInterface *painter) const +void libvisio::VSDPage::draw(libwpg::WPGPaintInterface *painter) const { if (painter) m_pageElements.draw(painter); } -libvisio::VSDXPages::VSDXPages() +libvisio::VSDPages::VSDPages() : m_pages(), m_pagesOrder() { } -void libvisio::VSDXPages::addPage(const libvisio::VSDXPage &page) +void libvisio::VSDPages::addPage(const libvisio::VSDPage &page) { m_pagesOrder.push_back(page.m_currentPageID); m_pages[page.m_currentPageID] = page; } -void libvisio::VSDXPages::draw(libwpg::WPGPaintInterface *painter) +void libvisio::VSDPages::draw(libwpg::WPGPaintInterface *painter) { if (!painter) return; for (unsigned i = 0; i < m_pagesOrder.size(); ++i) { - std::map<unsigned, libvisio::VSDXPage>::iterator iter = m_pages.find(m_pagesOrder[i]); + std::map<unsigned, libvisio::VSDPage>::iterator iter = m_pages.find(m_pagesOrder[i]); if (iter == m_pages.end()) continue; WPXPropertyList pageProps; @@ -103,14 +103,14 @@ void libvisio::VSDXPages::draw(libwpg::WPGPaintInterface *painter) } } -void libvisio::VSDXPages::_drawWithBackground(libwpg::WPGPaintInterface *painter, const libvisio::VSDXPage &page) +void libvisio::VSDPages::_drawWithBackground(libwpg::WPGPaintInterface *painter, const libvisio::VSDPage &page) { if (!painter) return; if (page.m_backgroundPageID != 0xffffffff) { - std::map<unsigned, libvisio::VSDXPage>::iterator iter = m_pages.find(page.m_backgroundPageID); + std::map<unsigned, libvisio::VSDPage>::iterator iter = m_pages.find(page.m_backgroundPageID); if (iter != m_pages.end()) _drawWithBackground(painter, iter->second); } @@ -118,7 +118,7 @@ void libvisio::VSDXPages::_drawWithBackground(libwpg::WPGPaintInterface *painter } -libvisio::VSDXPages::~VSDXPages() +libvisio::VSDPages::~VSDPages() { } diff --git a/src/lib/VSDXPages.h b/src/lib/VSDPages.h index e18287a..d7e72f6 100644 --- a/src/lib/VSDXPages.h +++ b/src/lib/VSDPages.h @@ -28,43 +28,43 @@ * instead of those above. */ -#ifndef __VSDXPAGES_H__ -#define __VSDXPAGES_H__ +#ifndef __VSDPAGES_H__ +#define __VSDPAGES_H__ -#include "VSDXOutputElementList.h" +#include "VSDOutputElementList.h" namespace libvisio { -class VSDXPage +class VSDPage { public: - VSDXPage(); - VSDXPage(const VSDXPage &page); - ~VSDXPage(); - VSDXPage &operator=(const VSDXPage &page); - void append(const VSDXOutputElementList &outputElements); + VSDPage(); + VSDPage(const VSDPage &page); + ~VSDPage(); + VSDPage &operator=(const VSDPage &page); + void append(const VSDOutputElementList &outputElements); void draw(libwpg::WPGPaintInterface *painter) const; double m_pageWidth, m_pageHeight; unsigned m_currentPageID, m_backgroundPageID; - VSDXOutputElementList m_pageElements; + VSDOutputElementList m_pageElements; }; -class VSDXPages +class VSDPages { public: - VSDXPages(); - ~VSDXPages(); - void addPage(const VSDXPage &page); + VSDPages(); + ~VSDPages(); + void addPage(const VSDPage &page); void draw(libwpg::WPGPaintInterface *painter); private: - void _drawWithBackground(libwpg::WPGPaintInterface *painter, const VSDXPage &page); - std::map<unsigned, VSDXPage> m_pages; + void _drawWithBackground(libwpg::WPGPaintInterface *painter, const VSDPage &page); + std::map<unsigned, VSDPage> m_pages; std::vector<unsigned> m_pagesOrder; }; } // namespace libvisio -#endif // __VSDXPAGES_H__ +#endif // __VSDPAGES_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXParagraphList.cpp b/src/lib/VSDParagraphList.cpp index 4d393e9..210756b 100644 --- a/src/lib/VSDXParagraphList.cpp +++ b/src/lib/VSDParagraphList.cpp @@ -28,31 +28,31 @@ * instead of those above. */ -#include "VSDXCollector.h" -#include "VSDXParagraphList.h" +#include "VSDCollector.h" +#include "VSDParagraphList.h" namespace libvisio { -class VSDXParagraphListElement +class VSDParagraphListElement { public: - VSDXParagraphListElement() {} - virtual ~VSDXParagraphListElement() {} - virtual void handle(VSDXCollector *collector) = 0; - virtual VSDXParagraphListElement *clone() = 0; + VSDParagraphListElement() {} + virtual ~VSDParagraphListElement() {} + virtual void handle(VSDCollector *collector) = 0; + virtual VSDParagraphListElement *clone() = 0; }; -class VSDXParaIX : public VSDXParagraphListElement +class VSDParaIX : public VSDParagraphListElement { public: - VSDXParaIX(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, + VSDParaIX(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags) : m_id(id), m_level(level), m_charCount(charCount), m_indFirst(indFirst), m_indLeft(indLeft), m_indRight(indRight), m_spLine(spLine), m_spBefore(spBefore), m_spAfter(spAfter), m_align(align), m_flags(flags) {} - ~VSDXParaIX() {} - void handle(VSDXCollector *collector); - VSDXParagraphListElement *clone(); + ~VSDParaIX() {} + void handle(VSDCollector *collector); + VSDParagraphListElement *clone(); private: unsigned m_id, m_level; unsigned m_charCount; @@ -68,67 +68,67 @@ private: } // namespace libvisio -void libvisio::VSDXParaIX::handle(VSDXCollector *collector) +void libvisio::VSDParaIX::handle(VSDCollector *collector) { - collector->collectVSDXParaStyle(m_id, m_level, m_charCount, m_indFirst, m_indLeft, m_indRight, + collector->collectVSDParaStyle(m_id, m_level, m_charCount, m_indFirst, m_indLeft, m_indRight, m_spLine, m_spBefore, m_spAfter, m_align, m_flags); } -libvisio::VSDXParagraphListElement *libvisio::VSDXParaIX::clone() +libvisio::VSDParagraphListElement *libvisio::VSDParaIX::clone() { - return new VSDXParaIX(m_id, m_level, m_charCount, m_indFirst, m_indLeft, m_indRight, + return new VSDParaIX(m_id, m_level, m_charCount, m_indFirst, m_indLeft, m_indRight, m_spLine, m_spBefore, m_spAfter, m_align, m_flags); } -libvisio::VSDXParagraphList::VSDXParagraphList() : +libvisio::VSDParagraphList::VSDParagraphList() : m_elements(), m_elementsOrder() { } -libvisio::VSDXParagraphList::VSDXParagraphList(const libvisio::VSDXParagraphList ¶List) : +libvisio::VSDParagraphList::VSDParagraphList(const libvisio::VSDParagraphList ¶List) : m_elements(), m_elementsOrder(paraList.m_elementsOrder) { - std::map<unsigned, VSDXParagraphListElement *>::const_iterator iter = paraList.m_elements.begin(); + std::map<unsigned, VSDParagraphListElement *>::const_iterator iter = paraList.m_elements.begin(); for (; iter != paraList.m_elements.end(); ++iter) m_elements[iter->first] = iter->second->clone(); } -libvisio::VSDXParagraphList &libvisio::VSDXParagraphList::operator=(const libvisio::VSDXParagraphList ¶List) +libvisio::VSDParagraphList &libvisio::VSDParagraphList::operator=(const libvisio::VSDParagraphList ¶List) { clear(); - std::map<unsigned, VSDXParagraphListElement *>::const_iterator iter = paraList.m_elements.begin(); + std::map<unsigned, VSDParagraphListElement *>::const_iterator iter = paraList.m_elements.begin(); for (; iter != paraList.m_elements.end(); ++iter) m_elements[iter->first] = iter->second->clone(); m_elementsOrder = paraList.m_elementsOrder; return *this; } -libvisio::VSDXParagraphList::~VSDXParagraphList() +libvisio::VSDParagraphList::~VSDParagraphList() { clear(); } -void libvisio::VSDXParagraphList::addParaIX(unsigned id, unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, +void libvisio::VSDParagraphList::addParaIX(unsigned id, unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags) { - m_elements[id] = new VSDXParaIX(id, level, charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align, flags); + m_elements[id] = new VSDParaIX(id, level, charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align, flags); } -void libvisio::VSDXParagraphList::setElementsOrder(const std::vector<unsigned> &elementsOrder) +void libvisio::VSDParagraphList::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::VSDXParagraphList::handle(VSDXCollector *collector) +void libvisio::VSDParagraphList::handle(VSDCollector *collector) { if (empty()) return; - std::map<unsigned, VSDXParagraphListElement *>::iterator iter; + std::map<unsigned, VSDParagraphListElement *>::iterator iter; if (!m_elementsOrder.empty()) { for (unsigned i = 0; i < m_elementsOrder.size(); i++) @@ -145,9 +145,9 @@ void libvisio::VSDXParagraphList::handle(VSDXCollector *collector) } } -void libvisio::VSDXParagraphList::clear() +void libvisio::VSDParagraphList::clear() { - for (std::map<unsigned, VSDXParagraphListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) + for (std::map<unsigned, VSDParagraphListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) delete iter->second; m_elements.clear(); m_elementsOrder.clear(); diff --git a/src/lib/VSDXParagraphList.h b/src/lib/VSDParagraphList.h index 1df29ec..d26c335 100644 --- a/src/lib/VSDXParagraphList.h +++ b/src/lib/VSDParagraphList.h @@ -28,8 +28,8 @@ * instead of those above. */ -#ifndef __VSDXPARAGRAPHLIST_H__ -#define __VSDXPARAGRAPHLIST_H__ +#ifndef __VSDPARAGRAPHLIST_H__ +#define __VSDPARAGRAPHLIST_H__ #include <vector> #include <map> @@ -37,32 +37,32 @@ namespace libvisio { -class VSDXParagraphListElement; -class VSDXCollector; +class VSDParagraphListElement; +class VSDCollector; -class VSDXParagraphList +class VSDParagraphList { public: - VSDXParagraphList(); - VSDXParagraphList(const VSDXParagraphList ¶List); - ~VSDXParagraphList(); - VSDXParagraphList &operator=(const VSDXParagraphList ¶List); + VSDParagraphList(); + VSDParagraphList(const VSDParagraphList ¶List); + ~VSDParagraphList(); + VSDParagraphList &operator=(const VSDParagraphList ¶List); void addParaIX(unsigned id, unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags); void setElementsOrder(const std::vector<unsigned> &m_elementsOrder); - void handle(VSDXCollector *collector); + void handle(VSDCollector *collector); void clear(); bool empty() const { return (m_elements.empty()); } private: - std::map<unsigned, VSDXParagraphListElement *> m_elements; + std::map<unsigned, VSDParagraphListElement *> m_elements; std::vector<unsigned> m_elementsOrder; }; } // namespace libvisio -#endif // __VSDXPARAGRAPHLIST_H__ +#endif // __VSDPARAGRAPHLIST_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDParser.cpp index b04df4c..b99bcd9 100644 --- a/src/lib/VSDXParser.cpp +++ b/src/lib/VSDParser.cpp @@ -35,23 +35,23 @@ #include <cmath> #include <set> #include "libvisio_utils.h" -#include "VSDXParser.h" +#include "VSDParser.h" #include "VSDInternalStream.h" -#include "VSDXDocumentStructure.h" -#include "VSDXContentCollector.h" -#include "VSDXStylesCollector.h" - -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_fieldList(), m_charList(new VSDXCharacterList()), - m_paraList(new VSDXParagraphList()), m_charListVector(), m_paraListVector(), +#include "VSDDocumentStructure.h" +#include "VSDContentCollector.h" +#include "VSDStylesCollector.h" + +libvisio::VSDParser::VSDParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter) + : m_input(input), m_painter(painter), m_header(), m_collector(0), m_geomList(new VSDGeometryList()), + m_geomListVector(), m_fieldList(), m_charList(new VSDCharacterList()), + m_paraList(new VSDParagraphList()), m_charListVector(), m_paraListVector(), m_shapeList(), m_currentLevel(0), m_stencils(), m_currentStencil(0), m_stencilShape(), m_isStencilStarted(false), m_isInStyles(false), m_currentShapeLevel(0), m_currentShapeID((unsigned)-1), m_extractStencils(false) {} -libvisio::VSDXParser::~VSDXParser() +libvisio::VSDParser::~VSDParser() { if (m_geomList) { @@ -70,7 +70,7 @@ libvisio::VSDXParser::~VSDXParser() } } -bool libvisio::VSDXParser::parseMain() +bool libvisio::VSDParser::parseMain() { if (!m_input) { @@ -92,14 +92,14 @@ bool libvisio::VSDXParser::parseMain() std::vector<std::map<unsigned, unsigned> > groupMembershipsSequence; std::vector<std::list<unsigned> > documentPageShapeOrders; - VSDXStylesCollector stylesCollector(groupXFormsSequence, groupMembershipsSequence, documentPageShapeOrders); + VSDStylesCollector stylesCollector(groupXFormsSequence, groupMembershipsSequence, documentPageShapeOrders); m_collector = &stylesCollector; if (!parseDocument(&trailerStream)) return false; - VSDXStyles styles = stylesCollector.getStyleSheets(); + VSDStyles styles = stylesCollector.getStyleSheets(); - VSDXContentCollector contentCollector(m_painter, groupXFormsSequence, groupMembershipsSequence, documentPageShapeOrders, styles, m_stencils); + VSDContentCollector contentCollector(m_painter, groupXFormsSequence, groupMembershipsSequence, documentPageShapeOrders, styles, m_stencils); m_collector = &contentCollector; if (!parseDocument(&trailerStream)) return false; @@ -107,7 +107,7 @@ bool libvisio::VSDXParser::parseMain() return true; } -bool libvisio::VSDXParser::parseDocument(WPXInputStream *input) +bool libvisio::VSDParser::parseDocument(WPXInputStream *input) { try { @@ -120,13 +120,13 @@ bool libvisio::VSDXParser::parseDocument(WPXInputStream *input) } } -bool libvisio::VSDXParser::extractStencils() +bool libvisio::VSDParser::extractStencils() { m_extractStencils = true; return parseMain(); } -void libvisio::VSDXParser::handleStreams(WPXInputStream *input, unsigned shift, unsigned level) +void libvisio::VSDParser::handleStreams(WPXInputStream *input, unsigned shift, unsigned level) { // Parse out pointers to streams input->seek(shift, WPX_SEEK_SET); @@ -178,19 +178,19 @@ void libvisio::VSDXParser::handleStreams(WPXInputStream *input, unsigned shift, } -void libvisio::VSDXParser::handleStream(const Pointer &ptr, unsigned idx, unsigned level) +void libvisio::VSDParser::handleStream(const Pointer &ptr, unsigned idx, unsigned level) { m_header.level = level; m_header.id = idx; m_header.chunkType = ptr.Type; _handleLevelChange(level); - VSDXStencil tmpStencil; + VSDStencil tmpStencil; bool compressed = ((ptr.Format & 2) == 2); m_input->seek(ptr.Offset, WPX_SEEK_SET); VSDInternalStream tmpInput(m_input, ptr.Length, compressed); unsigned shift = compressed ? 4 : 0; - VSD_DEBUG_MSG(("VSDXParser::handleStream: level %i, ptr.Type 0x%.8x, ptr.Offset 0x%.8x, ptr.Length 0x%.8x, ptr.Format 0x%.4x\n", + VSD_DEBUG_MSG(("VSDParser::handleStream: level %i, ptr.Type 0x%.8x, ptr.Offset 0x%.8x, ptr.Length 0x%.8x, ptr.Format 0x%.4x\n", level, ptr.Type, ptr.Offset, ptr.Length, ptr.Format)); switch (ptr.Type) @@ -225,13 +225,13 @@ void libvisio::VSDXParser::handleStream(const Pointer &ptr, unsigned idx, unsign case VSD_SHAPE_SHAPE: m_currentShapeID = idx; if (m_isStencilStarted) - m_stencilShape = VSDXStencilShape(); + m_stencilShape = VSDStencilShape(); break; case VSD_SHAPE_FOREIGN: m_currentShapeID = idx; if (m_isStencilStarted) { - m_stencilShape = VSDXStencilShape(); + m_stencilShape = VSDStencilShape(); m_stencilShape.m_foreign = new ForeignData(); } break; @@ -300,7 +300,7 @@ void libvisio::VSDXParser::handleStream(const Pointer &ptr, unsigned idx, unsign } -void libvisio::VSDXParser::handleBlob(WPXInputStream *input, unsigned level) +void libvisio::VSDParser::handleBlob(WPXInputStream *input, unsigned level) { try { @@ -312,12 +312,12 @@ void libvisio::VSDXParser::handleBlob(WPXInputStream *input, unsigned level) } catch (EndOfStreamException &) { - VSD_DEBUG_MSG(("VSDXParser::handleBlob - catching EndOfStreamException\n")); + VSD_DEBUG_MSG(("VSDParser::handleBlob - catching EndOfStreamException\n")); } } -void libvisio::VSDXParser::handleChunks(WPXInputStream *input, unsigned level) +void libvisio::VSDParser::handleChunks(WPXInputStream *input, unsigned level) { long endPos = 0; @@ -334,7 +334,7 @@ void libvisio::VSDXParser::handleChunks(WPXInputStream *input, unsigned level) } } -void libvisio::VSDXParser::handleChunk(WPXInputStream *input) +void libvisio::VSDParser::handleChunk(WPXInputStream *input) { switch (m_header.chunkType) { @@ -473,7 +473,7 @@ void libvisio::VSDXParser::handleChunk(WPXInputStream *input) } } -void libvisio::VSDXParser::_handleLevelChange(unsigned level) +void libvisio::VSDParser::_handleLevelChange(unsigned level) { if (level == m_currentLevel) return; @@ -483,29 +483,29 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level) m_charListVector.push_back(m_charList); m_paraListVector.push_back(m_paraList); // 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_paraList = new VSDXParagraphList(); + m_geomList = new VSDGeometryList(); + m_charList = new VSDCharacterList(); + m_paraList = new VSDParagraphList(); m_shapeList.handle(m_collector); m_shapeList.clear(); } if (level <= m_currentShapeLevel) { - for (std::vector<VSDXGeometryList *>::iterator iter = m_geomListVector.begin(); iter != m_geomListVector.end(); ++iter) + for (std::vector<VSDGeometryList *>::iterator iter = m_geomListVector.begin(); iter != m_geomListVector.end(); ++iter) { (*iter)->handle(m_collector); (*iter)->clear(); delete *iter; } m_geomListVector.clear(); - for (std::vector<VSDXCharacterList *>::iterator iter2 = m_charListVector.begin(); iter2 != m_charListVector.end(); ++iter2) + for (std::vector<VSDCharacterList *>::iterator iter2 = m_charListVector.begin(); iter2 != m_charListVector.end(); ++iter2) { (*iter2)->handle(m_collector); (*iter2)->clear(); delete *iter2; } m_charListVector.clear(); - for (std::vector<VSDXParagraphList *>::iterator iter3 = m_paraListVector.begin(); iter3 != m_paraListVector.end(); ++iter3) + for (std::vector<VSDParagraphList *>::iterator iter3 = m_paraListVector.begin(); iter3 != m_paraListVector.end(); ++iter3) { (*iter3)->handle(m_collector); (*iter3)->clear(); @@ -523,7 +523,7 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level) // --- READERS --- -void libvisio::VSDXParser::readEllipticalArcTo(WPXInputStream *input) +void libvisio::VSDParser::readEllipticalArcTo(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double x3 = readDouble(input); // End x @@ -545,7 +545,7 @@ void libvisio::VSDXParser::readEllipticalArcTo(WPXInputStream *input) } -void libvisio::VSDXParser::readForeignData(WPXInputStream *input) +void libvisio::VSDParser::readForeignData(WPXInputStream *input) { unsigned long tmpBytesRead = 0; const unsigned char *buffer = input->read(m_header.dataLength, tmpBytesRead); @@ -563,12 +563,12 @@ void libvisio::VSDXParser::readForeignData(WPXInputStream *input) m_collector->collectForeignData(m_header.id, m_header.level, binaryData); } -void libvisio::VSDXParser::readOLEList(WPXInputStream * /* input */) +void libvisio::VSDParser::readOLEList(WPXInputStream * /* input */) { m_collector->collectOLEList(m_header.id, m_header.level); } -void libvisio::VSDXParser::readOLEData(WPXInputStream *input) +void libvisio::VSDParser::readOLEData(WPXInputStream *input) { unsigned long tmpBytesRead = 0; const unsigned char *buffer = input->read(m_header.dataLength, tmpBytesRead); @@ -586,7 +586,7 @@ void libvisio::VSDXParser::readOLEData(WPXInputStream *input) m_collector->collectOLEData(m_header.id, m_header.level, oleData); } -void libvisio::VSDXParser::readEllipse(WPXInputStream *input) +void libvisio::VSDParser::readEllipse(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double cx = readDouble(input); @@ -607,7 +607,7 @@ void libvisio::VSDXParser::readEllipse(WPXInputStream *input) m_geomList->addEllipse(m_header.id, m_header.level, cx, cy, xleft, yleft, xtop, ytop); } -void libvisio::VSDXParser::readLine(WPXInputStream *input) +void libvisio::VSDParser::readLine(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double strokeWidth = readDouble(input); @@ -628,13 +628,13 @@ void libvisio::VSDXParser::readLine(WPXInputStream *input) else if (m_isStencilStarted) { if (!m_stencilShape.m_lineStyle) - m_stencilShape.m_lineStyle = new VSDXLineStyle(strokeWidth, c, linePattern, startMarker, endMarker, lineCap); + m_stencilShape.m_lineStyle = new VSDLineStyle(strokeWidth, c, linePattern, startMarker, endMarker, lineCap); } else m_collector->collectLine(m_header.id, m_header.level, strokeWidth, c, linePattern, startMarker, endMarker, lineCap); } -void libvisio::VSDXParser::readTextBlock(WPXInputStream *input) +void libvisio::VSDParser::readTextBlock(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double leftMargin = readDouble(input); @@ -662,7 +662,7 @@ void libvisio::VSDXParser::readTextBlock(WPXInputStream *input) else if (m_isStencilStarted) { if (!m_stencilShape.m_textBlockStyle) - m_stencilShape.m_textBlockStyle = new VSDXTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, + m_stencilShape.m_textBlockStyle = new VSDTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, verticalAlign, bgClrId, c, defaultTabStop, textDirection); } else @@ -670,10 +670,10 @@ void libvisio::VSDXParser::readTextBlock(WPXInputStream *input) verticalAlign, bgClrId, c, defaultTabStop, textDirection); } -void libvisio::VSDXParser::readGeomList(WPXInputStream *input) +void libvisio::VSDParser::readGeomList(WPXInputStream *input) { if (m_isStencilStarted) - m_stencilShape.m_geometries.push_back(VSDXGeometryList()); + m_stencilShape.m_geometries.push_back(VSDGeometryList()); uint32_t subHeaderLength = readU32(input); uint32_t childrenListLength = readU32(input); input->seek(subHeaderLength, WPX_SEEK_CUR); @@ -692,7 +692,7 @@ void libvisio::VSDXParser::readGeomList(WPXInputStream *input) } } -void libvisio::VSDXParser::readCharList(WPXInputStream *input) +void libvisio::VSDParser::readCharList(WPXInputStream *input) { uint32_t subHeaderLength = readU32(input); uint32_t childrenListLength = readU32(input); @@ -707,7 +707,7 @@ void libvisio::VSDXParser::readCharList(WPXInputStream *input) m_collector->collectUnhandledChunk(m_header.id, m_header.level); } -void libvisio::VSDXParser::readParaList(WPXInputStream *input) +void libvisio::VSDParser::readParaList(WPXInputStream *input) { uint32_t subHeaderLength = readU32(input); uint32_t childrenListLength = readU32(input); @@ -722,14 +722,14 @@ void libvisio::VSDXParser::readParaList(WPXInputStream *input) m_collector->collectUnhandledChunk(m_header.id, m_header.level); } -void libvisio::VSDXParser::readPage(WPXInputStream *input) +void libvisio::VSDParser::readPage(WPXInputStream *input) { input->seek(8, WPX_SEEK_CUR); //sub header length and children list length uint32_t backgroundPageID = readU32(input); m_collector->collectPage(m_header.id, m_header.level, backgroundPageID); } -void libvisio::VSDXParser::readGeometry(WPXInputStream *input) +void libvisio::VSDParser::readGeometry(WPXInputStream *input) { unsigned char geomFlags = readU8(input); @@ -739,7 +739,7 @@ void libvisio::VSDXParser::readGeometry(WPXInputStream *input) m_geomList->addGeometry(m_header.id, m_header.level, geomFlags); } -void libvisio::VSDXParser::readMoveTo(WPXInputStream *input) +void libvisio::VSDParser::readMoveTo(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double x = readDouble(input); @@ -752,7 +752,7 @@ void libvisio::VSDXParser::readMoveTo(WPXInputStream *input) m_geomList->addMoveTo(m_header.id, m_header.level, x, y); } -void libvisio::VSDXParser::readLineTo(WPXInputStream *input) +void libvisio::VSDParser::readLineTo(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double x = readDouble(input); @@ -765,7 +765,7 @@ void libvisio::VSDXParser::readLineTo(WPXInputStream *input) m_geomList->addLineTo(m_header.id, m_header.level, x, y); } -void libvisio::VSDXParser::readArcTo(WPXInputStream *input) +void libvisio::VSDParser::readArcTo(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double x2 = readDouble(input); @@ -780,7 +780,7 @@ void libvisio::VSDXParser::readArcTo(WPXInputStream *input) m_geomList->addArcTo(m_header.id, m_header.level, x2, y2, bow); } -void libvisio::VSDXParser::readXFormData(WPXInputStream *input) +void libvisio::VSDParser::readXFormData(WPXInputStream *input) { XForm xform; input->seek(1, WPX_SEEK_CUR); @@ -803,7 +803,7 @@ void libvisio::VSDXParser::readXFormData(WPXInputStream *input) m_collector->collectXFormData(m_header.id, m_header.level, xform); } -void libvisio::VSDXParser::readTxtXForm(WPXInputStream *input) +void libvisio::VSDParser::readTxtXForm(WPXInputStream *input) { XForm txtxform; input->seek(1, WPX_SEEK_CUR); @@ -824,14 +824,14 @@ void libvisio::VSDXParser::readTxtXForm(WPXInputStream *input) m_collector->collectTxtXForm(m_header.id, m_header.level, txtxform); } -void libvisio::VSDXParser::readShapeId(WPXInputStream *input) +void libvisio::VSDParser::readShapeId(WPXInputStream *input) { unsigned shapeId = readU32(input); m_shapeList.addShapeId(m_header.id, m_header.level, shapeId); } -void libvisio::VSDXParser::readShapeList(WPXInputStream *input) +void libvisio::VSDParser::readShapeList(WPXInputStream *input) { uint32_t subHeaderLength = readU32(input); uint32_t childrenListLength = readU32(input); @@ -846,7 +846,7 @@ void libvisio::VSDXParser::readShapeList(WPXInputStream *input) m_collector->collectUnhandledChunk(m_header.id, m_header.level); } -void libvisio::VSDXParser::readForeignDataType(WPXInputStream *input) +void libvisio::VSDParser::readForeignDataType(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double imgOffsetX = readDouble(input); @@ -875,7 +875,7 @@ void libvisio::VSDXParser::readForeignDataType(WPXInputStream *input) m_collector->collectForeignDataType(m_header.id, m_header.level, foreignType, foreignFormat, imgOffsetX, imgOffsetY, imgWidth, imgHeight); } -void libvisio::VSDXParser::readPageProps(WPXInputStream *input) +void libvisio::VSDParser::readPageProps(WPXInputStream *input) { // Skip bytes representing unit to *display* (value is always inches) input->seek(1, WPX_SEEK_CUR); @@ -900,7 +900,7 @@ void libvisio::VSDXParser::readPageProps(WPXInputStream *input) m_collector->collectPageProps(m_header.id, m_header.level, pageWidth, pageHeight, shadowOffsetX, shadowOffsetY, scale); } -void libvisio::VSDXParser::readShape(WPXInputStream *input) +void libvisio::VSDParser::readShape(WPXInputStream *input) { if (m_header.id != (unsigned)-1) m_currentShapeID = m_header.id; @@ -927,7 +927,7 @@ void libvisio::VSDXParser::readShape(WPXInputStream *input) m_currentShapeID = (unsigned)-1; } -void libvisio::VSDXParser::readNURBSTo(WPXInputStream *input) +void libvisio::VSDParser::readNURBSTo(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double x = readDouble(input); @@ -1092,7 +1092,7 @@ void libvisio::VSDXParser::readNURBSTo(WPXInputStream *input) } } -void libvisio::VSDXParser::readPolylineTo(WPXInputStream *input) +void libvisio::VSDParser::readPolylineTo(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double x = readDouble(input); @@ -1197,7 +1197,7 @@ void libvisio::VSDXParser::readPolylineTo(WPXInputStream *input) } } -void libvisio::VSDXParser::readInfiniteLine(WPXInputStream *input) +void libvisio::VSDParser::readInfiniteLine(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double x1 = readDouble(input); @@ -1213,7 +1213,7 @@ void libvisio::VSDXParser::readInfiniteLine(WPXInputStream *input) m_geomList->addInfiniteLine(m_header.id, m_header.level, x1, y1, x2, y2); } -void libvisio::VSDXParser::readShapeData(WPXInputStream *input) +void libvisio::VSDParser::readShapeData(WPXInputStream *input) { unsigned char dataType = readU8(input); @@ -1287,7 +1287,7 @@ void libvisio::VSDXParser::readShapeData(WPXInputStream *input) } } -void libvisio::VSDXParser::readSplineStart(WPXInputStream *input) +void libvisio::VSDParser::readSplineStart(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double x = readDouble(input); @@ -1304,7 +1304,7 @@ void libvisio::VSDXParser::readSplineStart(WPXInputStream *input) m_geomList->addSplineStart(m_header.id, m_header.level, x, y, secondKnot, firstKnot, lastKnot, degree); } -void libvisio::VSDXParser::readSplineKnot(WPXInputStream *input) +void libvisio::VSDParser::readSplineKnot(WPXInputStream *input) { input->seek(1, WPX_SEEK_CUR); double x = readDouble(input); @@ -1318,7 +1318,7 @@ void libvisio::VSDXParser::readSplineKnot(WPXInputStream *input) m_geomList->addSplineKnot(m_header.id, m_header.level, x, y, knot); } -void libvisio::VSDXParser::readNameList(WPXInputStream * /* input */) +void libvisio::VSDParser::readNameList(WPXInputStream * /* input */) { if (m_isStencilStarted) m_stencilShape.m_names.clear(); @@ -1326,7 +1326,7 @@ void libvisio::VSDXParser::readNameList(WPXInputStream * /* input */) m_collector->collectNameList(m_header.id, m_header.level); } -void libvisio::VSDXParser::readFieldList(WPXInputStream *input) +void libvisio::VSDParser::readFieldList(WPXInputStream *input) { uint32_t subHeaderLength = readU32(input); uint32_t childrenListLength = readU32(input); @@ -1350,7 +1350,7 @@ void libvisio::VSDXParser::readFieldList(WPXInputStream *input) } } -void libvisio::VSDXParser::readColours(WPXInputStream *input) +void libvisio::VSDParser::readColours(WPXInputStream *input) { input->seek(6, WPX_SEEK_SET); unsigned numColours = readU8(input); @@ -1372,7 +1372,7 @@ void libvisio::VSDXParser::readColours(WPXInputStream *input) m_collector->collectColours(colours); } -void libvisio::VSDXParser::readFont(WPXInputStream *input) +void libvisio::VSDParser::readFont(WPXInputStream *input) { input->seek(4, WPX_SEEK_CUR); ::WPXBinaryData textStream; @@ -1389,7 +1389,7 @@ void libvisio::VSDXParser::readFont(WPXInputStream *input) m_collector->collectFont(m_header.id, textStream, libvisio::VSD_TEXT_UTF16); } -void libvisio::VSDXParser::readFontIX(WPXInputStream *input) +void libvisio::VSDParser::readFontIX(WPXInputStream *input) { input->seek(2, WPX_SEEK_CUR); unsigned char codePage = readU8(input); @@ -1444,7 +1444,7 @@ void libvisio::VSDXParser::readFontIX(WPXInputStream *input) /* StyleSheet readers */ -void libvisio::VSDXParser::readStyleSheet(WPXInputStream *input) +void libvisio::VSDParser::readStyleSheet(WPXInputStream *input) { input->seek(0x22, WPX_SEEK_CUR); unsigned lineStyle = readU32(input); @@ -1456,7 +1456,7 @@ void libvisio::VSDXParser::readStyleSheet(WPXInputStream *input) m_collector->collectStyleSheet(m_header.id, m_header.level, lineStyle, fillStyle, textStyle); } -void libvisio::VSDXParser::readPageSheet(WPXInputStream * /* input */) +void libvisio::VSDParser::readPageSheet(WPXInputStream * /* input */) { m_currentShapeLevel = m_header.level; m_collector->collectPageSheet(m_header.id, m_header.level); diff --git a/src/lib/VSDXParser.h b/src/lib/VSDParser.h index eb15889..43bb959 100644 --- a/src/lib/VSDXParser.h +++ b/src/lib/VSDParser.h @@ -28,8 +28,8 @@ * instead of those above. */ -#ifndef __VSDXPARSER_H__ -#define __VSDXPARSER_H__ +#ifndef __VSDPARSER_H__ +#define __VSDPARSER_H__ #include <stdio.h> #include <iostream> @@ -38,18 +38,18 @@ #include <libwpd/libwpd.h> #include <libwpd-stream/libwpd-stream.h> #include <libwpg/libwpg.h> -#include "VSDXTypes.h" -#include "VSDXGeometryList.h" -#include "VSDXFieldList.h" -#include "VSDXCharacterList.h" -#include "VSDXParagraphList.h" -#include "VSDXShapeList.h" -#include "VSDXStencils.h" +#include "VSDTypes.h" +#include "VSDGeometryList.h" +#include "VSDFieldList.h" +#include "VSDCharacterList.h" +#include "VSDParagraphList.h" +#include "VSDShapeList.h" +#include "VSDStencils.h" namespace libvisio { -class VSDXCollector; +class VSDCollector; struct Pointer { @@ -60,11 +60,11 @@ struct Pointer unsigned ListSize; }; -class VSDXParser +class VSDParser { public: - explicit VSDXParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter); - virtual ~VSDXParser(); + explicit VSDParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter); + virtual ~VSDParser(); bool parseMain(); bool extractStencils(); @@ -135,20 +135,20 @@ protected: WPXInputStream *m_input; libwpg::WPGPaintInterface *m_painter; ChunkHeader m_header; - VSDXCollector *m_collector; - VSDXGeometryList *m_geomList; - std::vector<VSDXGeometryList *> m_geomListVector; - VSDXFieldList m_fieldList; - VSDXCharacterList *m_charList; - VSDXParagraphList *m_paraList; - std::vector<VSDXCharacterList *> m_charListVector; - std::vector<VSDXParagraphList *> m_paraListVector; - VSDXShapeList m_shapeList; + VSDCollector *m_collector; + VSDGeometryList *m_geomList; + std::vector<VSDGeometryList *> m_geomListVector; + VSDFieldList m_fieldList; + VSDCharacterList *m_charList; + VSDParagraphList *m_paraList; + std::vector<VSDCharacterList *> m_charListVector; + std::vector<VSDParagraphList *> m_paraListVector; + VSDShapeList m_shapeList; unsigned m_currentLevel; - VSDXStencils m_stencils; - VSDXStencil *m_currentStencil; - VSDXStencilShape m_stencilShape; + VSDStencils m_stencils; + VSDStencil *m_currentStencil; + VSDStencilShape m_stencilShape; bool m_isStencilStarted; bool m_isInStyles; unsigned m_currentShapeLevel; @@ -157,13 +157,13 @@ protected: bool m_extractStencils; private: - VSDXParser(); - VSDXParser(const VSDXParser &); - VSDXParser &operator=(const VSDXParser &); + VSDParser(); + VSDParser(const VSDParser &); + VSDParser &operator=(const VSDParser &); }; } // namespace libvisio -#endif // __VSDXPARSER_H__ +#endif // __VSDPARSER_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXShapeList.cpp b/src/lib/VSDShapeList.cpp index cf58e3f..04bbd8e 100644 --- a/src/lib/VSDXShapeList.cpp +++ b/src/lib/VSDShapeList.cpp @@ -28,27 +28,27 @@ * instead of those above. */ -#include "VSDXCollector.h" -#include "VSDXShapeList.h" +#include "VSDCollector.h" +#include "VSDShapeList.h" namespace libvisio { -class VSDXShapeListElement +class VSDShapeListElement { public: - VSDXShapeListElement() {} - virtual ~VSDXShapeListElement() {} - virtual void handle(VSDXCollector *collector) = 0; + VSDShapeListElement() {} + virtual ~VSDShapeListElement() {} + virtual void handle(VSDCollector *collector) = 0; }; -class VSDXShapeId : public VSDXShapeListElement +class VSDShapeId : public VSDShapeListElement { public: - VSDXShapeId(unsigned id, unsigned level, unsigned shapeId) : + VSDShapeId(unsigned id, unsigned level, unsigned shapeId) : m_id(id), m_level(level), m_shapeId(shapeId) {} - ~VSDXShapeId() {} - void handle(VSDXCollector *collector); + ~VSDShapeId() {} + void handle(VSDCollector *collector); private: unsigned m_id; unsigned m_level; @@ -58,39 +58,39 @@ private: } // namespace libvisio -void libvisio::VSDXShapeId::handle(VSDXCollector *collector) +void libvisio::VSDShapeId::handle(VSDCollector *collector) { collector->collectShapeId(m_id, m_level, m_shapeId); } -libvisio::VSDXShapeList::VSDXShapeList() : +libvisio::VSDShapeList::VSDShapeList() : m_elements(), m_elementsOrder() { } -libvisio::VSDXShapeList::~VSDXShapeList() +libvisio::VSDShapeList::~VSDShapeList() { clear(); } -void libvisio::VSDXShapeList::addShapeId(unsigned id, unsigned level, unsigned shapeId) +void libvisio::VSDShapeList::addShapeId(unsigned id, unsigned level, unsigned shapeId) { - m_elements[id] = new VSDXShapeId(id, level, shapeId); + m_elements[id] = new VSDShapeId(id, level, shapeId); } -void libvisio::VSDXShapeList::setElementsOrder(const std::vector<unsigned> &elementsOrder) +void libvisio::VSDShapeList::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::VSDXShapeList::handle(VSDXCollector *collector) +void libvisio::VSDShapeList::handle(VSDCollector *collector) { if (empty()) return; - std::map<unsigned, VSDXShapeListElement *>::iterator iter; + std::map<unsigned, VSDShapeListElement *>::iterator iter; if (!m_elementsOrder.empty()) { for (unsigned i = 0; i < m_elementsOrder.size(); i++) @@ -107,9 +107,9 @@ void libvisio::VSDXShapeList::handle(VSDXCollector *collector) } } -void libvisio::VSDXShapeList::clear() +void libvisio::VSDShapeList::clear() { - for (std::map<unsigned, VSDXShapeListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) + for (std::map<unsigned, VSDShapeListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) delete iter->second; m_elements.clear(); m_elementsOrder.clear(); diff --git a/src/lib/VSDXShapeList.h b/src/lib/VSDShapeList.h index 17ae708..7171a4e 100644 --- a/src/lib/VSDXShapeList.h +++ b/src/lib/VSDShapeList.h @@ -28,8 +28,8 @@ * instead of those above. */ -#ifndef __VSDXSHAPELIST_H__ -#define __VSDXSHAPELIST_H__ +#ifndef __VSDSHAPELIST_H__ +#define __VSDSHAPELIST_H__ #include <vector> #include <map> @@ -37,27 +37,27 @@ namespace libvisio { -class VSDXShapeListElement; +class VSDShapeListElement; -class VSDXShapeList +class VSDShapeList { public: - VSDXShapeList(); - ~VSDXShapeList(); + VSDShapeList(); + ~VSDShapeList(); void addShapeId(unsigned id, unsigned level, unsigned shapeId); void setElementsOrder(const std::vector<unsigned> &elementsOrder); - void handle(VSDXCollector *collector); + void handle(VSDCollector *collector); void clear(); bool empty() const { return (m_elements.empty()); } private: - std::map<unsigned, VSDXShapeListElement *> m_elements; + std::map<unsigned, VSDShapeListElement *> m_elements; std::vector<unsigned> m_elementsOrder; }; } // namespace libvisio -#endif // __VSDXSHAPELIST_H__ +#endif // __VSDSHAPELIST_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXStencils.cpp b/src/lib/VSDStencils.cpp index e9b1178..beeed24 100644 --- a/src/lib/VSDXStencils.cpp +++ b/src/lib/VSDStencils.cpp @@ -28,10 +28,10 @@ * instead of those above. */ -#include "VSDXStencils.h" +#include "VSDStencils.h" #include "libvisio_utils.h" -libvisio::VSDXStencilShape::VSDXStencilShape() +libvisio::VSDStencilShape::VSDStencilShape() : m_geometries(), m_fields(), m_foreign(0), m_lineStyleId(0xffffffff), m_fillStyleId(0xffffffff), m_textStyleId(0xffffffff), m_lineStyle(0), m_fillStyle(0), m_textBlockStyle(0), m_charStyle(0), m_paraStyle(0), @@ -39,19 +39,19 @@ libvisio::VSDXStencilShape::VSDXStencilShape() { } -libvisio::VSDXStencilShape::VSDXStencilShape(const libvisio::VSDXStencilShape &shape) +libvisio::VSDStencilShape::VSDStencilShape(const libvisio::VSDStencilShape &shape) : m_geometries(shape.m_geometries), m_fields(shape.m_fields), m_foreign(shape.m_foreign ? new ForeignData(*(shape.m_foreign)) : 0), m_lineStyleId(shape.m_lineStyleId), m_fillStyleId(shape.m_fillStyleId), m_textStyleId(shape.m_textStyleId), - m_lineStyle(shape.m_lineStyle ? new VSDXLineStyle(*(shape.m_lineStyle)) : 0), - m_fillStyle(shape.m_fillStyle ? new VSDXFillStyle(*(shape.m_fillStyle)) : 0), - m_textBlockStyle(shape.m_textBlockStyle ? new VSDXTextBlockStyle(*(shape.m_textBlockStyle)) : 0), - m_charStyle(shape.m_charStyle ? new VSDXCharStyle(*(shape.m_charStyle)) : 0), - m_paraStyle(shape.m_paraStyle ? new VSDXParaStyle(*(shape.m_paraStyle)) : 0), + m_lineStyle(shape.m_lineStyle ? new VSDLineStyle(*(shape.m_lineStyle)) : 0), + m_fillStyle(shape.m_fillStyle ? new VSDFillStyle(*(shape.m_fillStyle)) : 0), + m_textBlockStyle(shape.m_textBlockStyle ? new VSDTextBlockStyle(*(shape.m_textBlockStyle)) : 0), + m_charStyle(shape.m_charStyle ? new VSDCharStyle(*(shape.m_charStyle)) : 0), + m_paraStyle(shape.m_paraStyle ? new VSDParaStyle(*(shape.m_paraStyle)) : 0), 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) {} -libvisio::VSDXStencilShape::~VSDXStencilShape() +libvisio::VSDStencilShape::~VSDStencilShape() { if (m_foreign) delete m_foreign; @@ -67,7 +67,7 @@ libvisio::VSDXStencilShape::~VSDXStencilShape() delete m_paraStyle; } -libvisio::VSDXStencilShape &libvisio::VSDXStencilShape::operator=(const libvisio::VSDXStencilShape &shape) +libvisio::VSDStencilShape &libvisio::VSDStencilShape::operator=(const libvisio::VSDStencilShape &shape) { if (this != &shape) { @@ -81,19 +81,19 @@ libvisio::VSDXStencilShape &libvisio::VSDXStencilShape::operator=(const libvisio m_textStyleId = shape.m_textStyleId; if (m_lineStyle) delete m_lineStyle; - m_lineStyle = shape.m_lineStyle ? new VSDXLineStyle(*(shape.m_lineStyle)) : 0; + m_lineStyle = shape.m_lineStyle ? new VSDLineStyle(*(shape.m_lineStyle)) : 0; if (m_fillStyle) delete m_fillStyle; - m_fillStyle = shape.m_fillStyle ? new VSDXFillStyle(*(shape.m_fillStyle)) : 0; + m_fillStyle = shape.m_fillStyle ? new VSDFillStyle(*(shape.m_fillStyle)) : 0; if (m_textBlockStyle) delete m_textBlockStyle; - m_textBlockStyle = shape.m_textBlockStyle ? new VSDXTextBlockStyle(*(shape.m_textBlockStyle)) : 0; + m_textBlockStyle = shape.m_textBlockStyle ? new VSDTextBlockStyle(*(shape.m_textBlockStyle)) : 0; if (m_charStyle) delete m_charStyle; - m_charStyle = shape.m_charStyle ? new VSDXCharStyle(*(shape.m_charStyle)) : 0; + m_charStyle = shape.m_charStyle ? new VSDCharStyle(*(shape.m_charStyle)) : 0; if (m_paraStyle) delete m_paraStyle; - m_paraStyle = shape.m_paraStyle ? new VSDXParaStyle(*(shape.m_paraStyle)) : 0; + m_paraStyle = shape.m_paraStyle ? new VSDParaStyle(*(shape.m_paraStyle)) : 0; m_text = shape.m_text; m_names = shape.m_names; m_textFormat = shape.m_textFormat; @@ -104,21 +104,21 @@ libvisio::VSDXStencilShape &libvisio::VSDXStencilShape::operator=(const libvisio } -libvisio::VSDXStencil::VSDXStencil() +libvisio::VSDStencil::VSDStencil() : m_shapes(), m_shadowOffsetX(0.0), m_shadowOffsetY(0.0) { } -libvisio::VSDXStencil::VSDXStencil(const libvisio::VSDXStencil &stencil) +libvisio::VSDStencil::VSDStencil(const libvisio::VSDStencil &stencil) : m_shapes(stencil.m_shapes), m_shadowOffsetX(stencil.m_shadowOffsetX), m_shadowOffsetY(stencil.m_shadowOffsetY) { } -libvisio::VSDXStencil::~VSDXStencil() +libvisio::VSDStencil::~VSDStencil() { } -libvisio::VSDXStencil &libvisio::VSDXStencil::operator=(const libvisio::VSDXStencil &stencil) +libvisio::VSDStencil &libvisio::VSDStencil::operator=(const libvisio::VSDStencil &stencil) { if (this != &stencil) { @@ -129,14 +129,14 @@ libvisio::VSDXStencil &libvisio::VSDXStencil::operator=(const libvisio::VSDXSten return *this; } -void libvisio::VSDXStencil::addStencilShape(unsigned id, const VSDXStencilShape &shape) +void libvisio::VSDStencil::addStencilShape(unsigned id, const VSDStencilShape &shape) { m_shapes[id] = shape; } -const libvisio::VSDXStencilShape *libvisio::VSDXStencil::getStencilShape(unsigned id) const +const libvisio::VSDStencilShape *libvisio::VSDStencil::getStencilShape(unsigned id) const { - std::map<unsigned, VSDXStencilShape>::const_iterator iter = m_shapes.find(id); + std::map<unsigned, VSDStencilShape>::const_iterator iter = m_shapes.find(id); if (iter != m_shapes.end()) return &(iter->second); else @@ -145,23 +145,23 @@ const libvisio::VSDXStencilShape *libvisio::VSDXStencil::getStencilShape(unsigne -libvisio::VSDXStencils::VSDXStencils() : +libvisio::VSDStencils::VSDStencils() : m_stencils() { } -libvisio::VSDXStencils::~VSDXStencils() +libvisio::VSDStencils::~VSDStencils() { } -void libvisio::VSDXStencils::addStencil(unsigned idx, const libvisio::VSDXStencil &stencil) +void libvisio::VSDStencils::addStencil(unsigned idx, const libvisio::VSDStencil &stencil) { m_stencils[idx] = stencil; } -const libvisio::VSDXStencil *libvisio::VSDXStencils::getStencil(unsigned idx) const +const libvisio::VSDStencil *libvisio::VSDStencils::getStencil(unsigned idx) const { - std::map<unsigned, VSDXStencil>::const_iterator iter = m_stencils.find(idx); + std::map<unsigned, VSDStencil>::const_iterator iter = m_stencils.find(idx); if (iter != m_stencils.end()) return &(iter->second); else diff --git a/src/lib/VSDXStencils.h b/src/lib/VSDStencils.h index 926a150..65b8ada 100644 --- a/src/lib/VSDXStencils.h +++ b/src/lib/VSDStencils.h @@ -28,74 +28,74 @@ * instead of those above. */ -#ifndef __VSDXSTENCILS_H__ -#define __VSDXSTENCILS_H__ +#ifndef __VSDSTENCILS_H__ +#define __VSDSTENCILS_H__ #include <map> #include <vector> -#include "VSDXStyles.h" -#include "VSDXGeometryList.h" -#include "VSDXFieldList.h" -#include "VSDXTypes.h" +#include "VSDStyles.h" +#include "VSDGeometryList.h" +#include "VSDFieldList.h" +#include "VSDTypes.h" namespace libvisio { -class VSDXStencilShape +class VSDStencilShape { public: - VSDXStencilShape(); - VSDXStencilShape(const VSDXStencilShape &shape); - ~VSDXStencilShape(); - VSDXStencilShape &operator=(const VSDXStencilShape &shape); + VSDStencilShape(); + VSDStencilShape(const VSDStencilShape &shape); + ~VSDStencilShape(); + VSDStencilShape &operator=(const VSDStencilShape &shape); - std::vector<VSDXGeometryList> m_geometries; - VSDXFieldList m_fields; + std::vector<VSDGeometryList> m_geometries; + VSDFieldList m_fields; ForeignData *m_foreign; unsigned m_lineStyleId, m_fillStyleId, m_textStyleId; - VSDXLineStyle *m_lineStyle; - VSDXFillStyle *m_fillStyle; - VSDXTextBlockStyle *m_textBlockStyle; - VSDXCharStyle *m_charStyle; - VSDXParaStyle *m_paraStyle; + VSDLineStyle *m_lineStyle; + VSDFillStyle *m_fillStyle; + VSDTextBlockStyle *m_textBlockStyle; + VSDCharStyle *m_charStyle; + VSDParaStyle *m_paraStyle; WPXBinaryData m_text; - std::map< unsigned, VSDXName > m_names; + std::map< unsigned, VSDName > m_names; TextFormat m_textFormat; std::map<unsigned, NURBSData> m_nurbsData; std::map<unsigned, PolylineData> m_polylineData; }; -class VSDXStencil +class VSDStencil { public: - VSDXStencil(); - VSDXStencil(const VSDXStencil &stencil); - ~VSDXStencil(); - VSDXStencil &operator=(const VSDXStencil &stencil); - void addStencilShape(unsigned id, const VSDXStencilShape &shape); - const VSDXStencilShape *getStencilShape(unsigned id) const; - std::map<unsigned, VSDXStencilShape> m_shapes; + VSDStencil(); + VSDStencil(const VSDStencil &stencil); + ~VSDStencil(); + VSDStencil &operator=(const VSDStencil &stencil); + void addStencilShape(unsigned id, const VSDStencilShape &shape); + const VSDStencilShape *getStencilShape(unsigned id) const; + std::map<unsigned, VSDStencilShape> m_shapes; double m_shadowOffsetX; double m_shadowOffsetY; }; -class VSDXStencils +class VSDStencils { public: - VSDXStencils(); - ~VSDXStencils(); - void addStencil(unsigned idx, const VSDXStencil &stencil); - const VSDXStencil *getStencil(unsigned idx) const; + VSDStencils(); + ~VSDStencils(); + void addStencil(unsigned idx, const VSDStencil &stencil); + const VSDStencil *getStencil(unsigned idx) const; unsigned count() const { return m_stencils.size(); } private: - std::map<unsigned, VSDXStencil> m_stencils; + std::map<unsigned, VSDStencil> m_stencils; }; } // namespace libvisio -#endif // __VSDXSTENCILS_H__ +#endif // __VSDSTENCILS_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXStyles.cpp b/src/lib/VSDStyles.cpp index 33eddab..5da76dc 100644 --- a/src/lib/VSDXStyles.cpp +++ b/src/lib/VSDStyles.cpp @@ -28,80 +28,80 @@ * instead of those above. */ -#include "VSDXStyles.h" +#include "VSDStyles.h" #define NOMASTER 0xffffffff -libvisio::VSDXStyles::VSDXStyles() : +libvisio::VSDStyles::VSDStyles() : m_lineStyles(), m_fillStyles(), m_textBlockStyles(), m_charStyles(), m_paraStyles(), m_lineStyleMasters(), m_fillStyleMasters(), m_textStyleMasters() { } -libvisio::VSDXStyles::VSDXStyles(const libvisio::VSDXStyles &styles) : +libvisio::VSDStyles::VSDStyles(const libvisio::VSDStyles &styles) : m_lineStyles(), m_fillStyles(), m_textBlockStyles(), m_charStyles(), m_paraStyles(), m_lineStyleMasters(styles.m_lineStyleMasters), m_fillStyleMasters(styles.m_fillStyleMasters), m_textStyleMasters(styles.m_textStyleMasters) { - for (std::map<unsigned, VSDXFillStyle *>::const_iterator iterFillStyle = styles.m_fillStyles.begin(); + for (std::map<unsigned, VSDFillStyle *>::const_iterator iterFillStyle = styles.m_fillStyles.begin(); iterFillStyle != styles.m_fillStyles.end(); ++iterFillStyle) { if (iterFillStyle->second) - m_fillStyles[iterFillStyle->first] = new VSDXFillStyle(*(iterFillStyle->second)); + m_fillStyles[iterFillStyle->first] = new VSDFillStyle(*(iterFillStyle->second)); } - for (std::map<unsigned, VSDXLineStyle *>::const_iterator iterLineStyle = styles.m_lineStyles.begin(); + for (std::map<unsigned, VSDLineStyle *>::const_iterator iterLineStyle = styles.m_lineStyles.begin(); iterLineStyle != styles.m_lineStyles.end(); ++iterLineStyle) { if (iterLineStyle->second) - m_lineStyles[iterLineStyle->first] = new VSDXLineStyle(*(iterLineStyle->second)); + m_lineStyles[iterLineStyle->first] = new VSDLineStyle(*(iterLineStyle->second)); } - for (std::map<unsigned, VSDXTextBlockStyle *>::const_iterator iterTextBlockStyle = styles.m_textBlockStyles.begin(); + for (std::map<unsigned, VSDTextBlockStyle *>::const_iterator iterTextBlockStyle = styles.m_textBlockStyles.begin(); iterTextBlockStyle != styles.m_textBlockStyles.end(); ++iterTextBlockStyle) { if (iterTextBlockStyle->second) - m_textBlockStyles[iterTextBlockStyle->first] = new VSDXTextBlockStyle(*(iterTextBlockStyle->second)); + m_textBlockStyles[iterTextBlockStyle->first] = new VSDTextBlockStyle(*(iterTextBlockStyle->second)); } - for (std::map<unsigned, VSDXCharStyle *>::const_iterator iterCharStyle = styles.m_charStyles.begin(); + for (std::map<unsigned, VSDCharStyle *>::const_iterator iterCharStyle = styles.m_charStyles.begin(); iterCharStyle != styles.m_charStyles.end(); ++iterCharStyle) { if (iterCharStyle->second) - m_charStyles[iterCharStyle->first] = new VSDXCharStyle(*(iterCharStyle->second)); + m_charStyles[iterCharStyle->first] = new VSDCharStyle(*(iterCharStyle->second)); } - for (std::map<unsigned, VSDXParaStyle *>::const_iterator iterParaStyle = styles.m_paraStyles.begin(); + for (std::map<unsigned, VSDParaStyle *>::const_iterator iterParaStyle = styles.m_paraStyles.begin(); iterParaStyle != styles.m_paraStyles.end(); ++iterParaStyle) { if (iterParaStyle->second) - m_paraStyles[iterParaStyle->first] = new VSDXParaStyle(*(iterParaStyle->second)); + m_paraStyles[iterParaStyle->first] = new VSDParaStyle(*(iterParaStyle->second)); } } -libvisio::VSDXStyles::~VSDXStyles() +libvisio::VSDStyles::~VSDStyles() { - for (std::map<unsigned, VSDXFillStyle *>::iterator iterFillStyle = m_fillStyles.begin(); + for (std::map<unsigned, VSDFillStyle *>::iterator iterFillStyle = m_fillStyles.begin(); iterFillStyle != m_fillStyles.end(); ++iterFillStyle) { if (iterFillStyle->second) delete iterFillStyle->second; } - for (std::map<unsigned, VSDXLineStyle *>::iterator iterLineStyle = m_lineStyles.begin(); + for (std::map<unsigned, VSDLineStyle *>::iterator iterLineStyle = m_lineStyles.begin(); iterLineStyle != m_lineStyles.end(); ++iterLineStyle) { if (iterLineStyle->second) delete iterLineStyle->second; } - for (std::map<unsigned, VSDXTextBlockStyle *>::iterator iterTextBlockStyle = m_textBlockStyles.begin(); + for (std::map<unsigned, VSDTextBlockStyle *>::iterator iterTextBlockStyle = m_textBlockStyles.begin(); iterTextBlockStyle != m_textBlockStyles.end(); ++iterTextBlockStyle) { if (iterTextBlockStyle->second) delete (iterTextBlockStyle->second); } - for (std::map<unsigned, VSDXCharStyle *>::iterator iterCharStyle = m_charStyles.begin(); + for (std::map<unsigned, VSDCharStyle *>::iterator iterCharStyle = m_charStyles.begin(); iterCharStyle != m_charStyles.end(); ++iterCharStyle) { if (iterCharStyle->second) delete (iterCharStyle->second); } - for (std::map<unsigned, VSDXParaStyle *>::iterator iterParaStyle = m_paraStyles.begin(); + for (std::map<unsigned, VSDParaStyle *>::iterator iterParaStyle = m_paraStyles.begin(); iterParaStyle != m_paraStyles.end(); ++iterParaStyle) { if (iterParaStyle->second) @@ -109,37 +109,37 @@ libvisio::VSDXStyles::~VSDXStyles() } } -libvisio::VSDXStyles &libvisio::VSDXStyles::operator=(const libvisio::VSDXStyles &styles) +libvisio::VSDStyles &libvisio::VSDStyles::operator=(const libvisio::VSDStyles &styles) { - for (std::map<unsigned, VSDXFillStyle *>::iterator iterFillStyle = m_fillStyles.begin(); + for (std::map<unsigned, VSDFillStyle *>::iterator iterFillStyle = m_fillStyles.begin(); iterFillStyle != m_fillStyles.end(); ++iterFillStyle) { if (iterFillStyle->second) delete iterFillStyle->second; } m_fillStyles.clear(); - for (std::map<unsigned, VSDXLineStyle *>::iterator iterLineStyle = m_lineStyles.begin(); + for (std::map<unsigned, VSDLineStyle *>::iterator iterLineStyle = m_lineStyles.begin(); iterLineStyle != m_lineStyles.end(); ++iterLineStyle) { if (iterLineStyle->second) delete iterLineStyle->second; } m_lineStyles.clear(); - for (std::map<unsigned, VSDXTextBlockStyle *>::iterator iterTextBlockStyle = m_textBlockStyles.begin(); + for (std::map<unsigned, VSDTextBlockStyle *>::iterator iterTextBlockStyle = m_textBlockStyles.begin(); iterTextBlockStyle != m_textBlockStyles.end(); ++iterTextBlockStyle) { if (iterTextBlockStyle->second) delete (iterTextBlockStyle->second); } m_textBlockStyles.clear(); - for (std::map<unsigned, VSDXCharStyle *>::iterator iterCharStyle = m_charStyles.begin(); + for (std::map<unsigned, VSDCharStyle *>::iterator iterCharStyle = m_charStyles.begin(); iterCharStyle != m_charStyles.end(); ++iterCharStyle) { if (iterCharStyle->second) delete (iterCharStyle->second); } m_charStyles.clear(); - for (std::map<unsigned, VSDXParaStyle *>::iterator iterParaStyle = m_paraStyles.begin(); + for (std::map<unsigned, VSDParaStyle *>::iterator iterParaStyle = m_paraStyles.begin(); iterParaStyle != m_paraStyles.end(); ++iterParaStyle) { if (iterParaStyle->second) @@ -147,35 +147,35 @@ libvisio::VSDXStyles &libvisio::VSDXStyles::operator=(const libvisio::VSDXStyles } m_paraStyles.clear(); - for (std::map<unsigned, VSDXFillStyle *>::const_iterator cstIterFillStyle = styles.m_fillStyles.begin(); + for (std::map<unsigned, VSDFillStyle *>::const_iterator cstIterFillStyle = styles.m_fillStyles.begin(); cstIterFillStyle != styles.m_fillStyles.end(); ++cstIterFillStyle) { if (cstIterFillStyle->second) - m_fillStyles[cstIterFillStyle->first] = new VSDXFillStyle(*(cstIterFillStyle->second)); + m_fillStyles[cstIterFillStyle->first] = new VSDFillStyle(*(cstIterFillStyle->second)); } - for (std::map<unsigned, VSDXLineStyle *>::const_iterator cstIterLineStyle = styles.m_lineStyles.begin(); + for (std::map<unsigned, VSDLineStyle *>::const_iterator cstIterLineStyle = styles.m_lineStyles.begin(); cstIterLineStyle != styles.m_lineStyles.end(); ++cstIterLineStyle) { if (cstIterLineStyle->second) - m_lineStyles[cstIterLineStyle->first] = new VSDXLineStyle(*(cstIterLineStyle->second)); + m_lineStyles[cstIterLineStyle->first] = new VSDLineStyle(*(cstIterLineStyle->second)); } - for (std::map<unsigned, VSDXTextBlockStyle *>::const_iterator cstIterTextBlockStyle = styles.m_textBlockStyles.begin(); + for (std::map<unsigned, VSDTextBlockStyle *>::const_iterator cstIterTextBlockStyle = styles.m_textBlockStyles.begin(); cstIterTextBlockStyle != styles.m_textBlockStyles.end(); ++cstIterTextBlockStyle) { if (cstIterTextBlockStyle->second) - m_textBlockStyles[cstIterTextBlockStyle->first] = new VSDXTextBlockStyle(*(cstIterTextBlockStyle->second)); + m_textBlockStyles[cstIterTextBlockStyle->first] = new VSDTextBlockStyle(*(cstIterTextBlockStyle->second)); } - for (std::map<unsigned, VSDXCharStyle *>::const_iterator cstIterCharStyle = styles.m_charStyles.begin(); + for (std::map<unsigned, VSDCharStyle *>::const_iterator cstIterCharStyle = styles.m_charStyles.begin(); cstIterCharStyle != styles.m_charStyles.end(); ++cstIterCharStyle) { if (cstIterCharStyle->second) - m_charStyles[cstIterCharStyle->first] = new VSDXCharStyle(*(cstIterCharStyle->second)); + m_charStyles[cstIterCharStyle->first] = new VSDCharStyle(*(cstIterCharStyle->second)); } - for (std::map<unsigned, VSDXParaStyle *>::const_iterator cstIterParaStyle = styles.m_paraStyles.begin(); + for (std::map<unsigned, VSDParaStyle *>::const_iterator cstIterParaStyle = styles.m_paraStyles.begin(); cstIterParaStyle != styles.m_paraStyles.end(); ++cstIterParaStyle) { if (cstIterParaStyle->second) - m_paraStyles[cstIterParaStyle->first] = new VSDXParaStyle(*(cstIterParaStyle->second)); + m_paraStyles[cstIterParaStyle->first] = new VSDParaStyle(*(cstIterParaStyle->second)); } m_lineStyleMasters = styles.m_lineStyleMasters; @@ -185,80 +185,80 @@ libvisio::VSDXStyles &libvisio::VSDXStyles::operator=(const libvisio::VSDXStyles return *this; } -void libvisio::VSDXStyles::addLineStyle(unsigned lineStyleIndex, VSDXLineStyle *lineStyle) +void libvisio::VSDStyles::addLineStyle(unsigned lineStyleIndex, VSDLineStyle *lineStyle) { if (lineStyle) { - std::map<unsigned, VSDXLineStyle *>::iterator iter = m_lineStyles.lower_bound(lineStyleIndex); + std::map<unsigned, VSDLineStyle *>::iterator iter = m_lineStyles.lower_bound(lineStyleIndex); if (iter != m_lineStyles.end() && !(m_lineStyles.key_comp()(lineStyleIndex, iter->first)) && iter->second) delete iter->second; - m_lineStyles.insert(iter, std::map<unsigned, VSDXLineStyle *>::value_type(lineStyleIndex, new VSDXLineStyle(*lineStyle))); + m_lineStyles.insert(iter, std::map<unsigned, VSDLineStyle *>::value_type(lineStyleIndex, new VSDLineStyle(*lineStyle))); } } -void libvisio::VSDXStyles::addFillStyle(unsigned fillStyleIndex, VSDXFillStyle *fillStyle) +void libvisio::VSDStyles::addFillStyle(unsigned fillStyleIndex, VSDFillStyle *fillStyle) { if (fillStyle) { - std::map<unsigned, VSDXFillStyle *>::iterator iter = m_fillStyles.lower_bound(fillStyleIndex); + std::map<unsigned, VSDFillStyle *>::iterator iter = m_fillStyles.lower_bound(fillStyleIndex); if (iter != m_fillStyles.end() && !(m_fillStyles.key_comp()(fillStyleIndex, iter->first))&& iter->second) delete iter->second; - m_fillStyles.insert(iter, std::map<unsigned, VSDXFillStyle *>::value_type(fillStyleIndex, new VSDXFillStyle(*fillStyle))); + m_fillStyles.insert(iter, std::map<unsigned, VSDFillStyle *>::value_type(fillStyleIndex, new VSDFillStyle(*fillStyle))); } } -void libvisio::VSDXStyles::addTextBlockStyle(unsigned textStyleIndex, VSDXTextBlockStyle *textBlockStyle) +void libvisio::VSDStyles::addTextBlockStyle(unsigned textStyleIndex, VSDTextBlockStyle *textBlockStyle) { if (textBlockStyle) { - std::map<unsigned, VSDXTextBlockStyle *>::iterator iter = m_textBlockStyles.lower_bound(textStyleIndex); + std::map<unsigned, VSDTextBlockStyle *>::iterator iter = m_textBlockStyles.lower_bound(textStyleIndex); if (iter != m_textBlockStyles.end() && !(m_textBlockStyles.key_comp()(textStyleIndex, iter->first)) && iter->second) delete iter->second; - m_textBlockStyles.insert(iter, std::map<unsigned, VSDXTextBlockStyle *>::value_type(textStyleIndex, new VSDXTextBlockStyle(*textBlockStyle))); + m_textBlockStyles.insert(iter, std::map<unsigned, VSDTextBlockStyle *>::value_type(textStyleIndex, new VSDTextBlockStyle(*textBlockStyle))); } } -void libvisio::VSDXStyles::addCharStyle(unsigned textStyleIndex, VSDXCharStyle *charStyle) +void libvisio::VSDStyles::addCharStyle(unsigned textStyleIndex, VSDCharStyle *charStyle) { if (charStyle) { - std::map<unsigned, VSDXCharStyle *>::iterator iter = m_charStyles.lower_bound(textStyleIndex); + std::map<unsigned, VSDCharStyle *>::iterator iter = m_charStyles.lower_bound(textStyleIndex); if (iter != m_charStyles.end() && !(m_charStyles.key_comp()(textStyleIndex, iter->first)) && iter->second) delete iter->second; - m_charStyles.insert(iter, std::map<unsigned, VSDXCharStyle *>::value_type(textStyleIndex, new VSDXCharStyle(*charStyle))); + m_charStyles.insert(iter, std::map<unsigned, VSDCharStyle *>::value_type(textStyleIndex, new VSDCharStyle(*charStyle))); } } -void libvisio::VSDXStyles::addParaStyle(unsigned textStyleIndex, VSDXParaStyle *paraStyle) +void libvisio::VSDStyles::addParaStyle(unsigned textStyleIndex, VSDParaStyle *paraStyle) { if (paraStyle) { - std::map<unsigned, VSDXParaStyle *>::iterator iter = m_paraStyles.lower_bound(textStyleIndex); + std::map<unsigned, VSDParaStyle *>::iterator iter = m_paraStyles.lower_bound(textStyleIndex); if (iter != m_paraStyles.end() && !(m_paraStyles.key_comp()(textStyleIndex, iter->first)) && iter->second) delete iter->second; - m_paraStyles.insert(iter, std::map<unsigned, VSDXParaStyle *>::value_type(textStyleIndex, new VSDXParaStyle(*paraStyle))); + m_paraStyles.insert(iter, std::map<unsigned, VSDParaStyle *>::value_type(textStyleIndex, new VSDParaStyle(*paraStyle))); } } -void libvisio::VSDXStyles::addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster) +void libvisio::VSDStyles::addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster) { m_lineStyleMasters[lineStyleIndex] = lineStyleMaster; } -void libvisio::VSDXStyles::addFillStyleMaster(unsigned fillStyleIndex, unsigned fillStyleMaster) +void libvisio::VSDStyles::addFillStyleMaster(unsigned fillStyleIndex, unsigned fillStyleMaster) { m_fillStyleMasters[fillStyleIndex] = fillStyleMaster; } -void libvisio::VSDXStyles::addTextStyleMaster(unsigned textStyleIndex, unsigned textStyleMaster) +void libvisio::VSDStyles::addTextStyleMaster(unsigned textStyleIndex, unsigned textStyleMaster) { m_textStyleMasters[textStyleIndex] = textStyleMaster; } -const libvisio::VSDXLineStyle *libvisio::VSDXStyles::getLineStyle(unsigned lineStyleIndex) const +const libvisio::VSDLineStyle *libvisio::VSDStyles::getLineStyle(unsigned lineStyleIndex) const { unsigned tmpIndex = lineStyleIndex; - std::map<unsigned, VSDXLineStyle *>::const_iterator iterStyle; + std::map<unsigned, VSDLineStyle *>::const_iterator iterStyle; while (true) { iterStyle = m_lineStyles.find(tmpIndex); @@ -274,10 +274,10 @@ const libvisio::VSDXLineStyle *libvisio::VSDXStyles::getLineStyle(unsigned lineS return 0; } -const libvisio::VSDXFillStyle *libvisio::VSDXStyles::getFillStyle(unsigned fillStyleIndex) const +const libvisio::VSDFillStyle *libvisio::VSDStyles::getFillStyle(unsigned fillStyleIndex) const { unsigned tmpIndex = fillStyleIndex; - std::map<unsigned, VSDXFillStyle *>::const_iterator iterStyle; + std::map<unsigned, VSDFillStyle *>::const_iterator iterStyle; while (true) { iterStyle = m_fillStyles.find(tmpIndex); @@ -293,10 +293,10 @@ const libvisio::VSDXFillStyle *libvisio::VSDXStyles::getFillStyle(unsigned fillS return 0; } -const libvisio::VSDXTextBlockStyle *libvisio::VSDXStyles::getTextBlockStyle(unsigned textStyleIndex) const +const libvisio::VSDTextBlockStyle *libvisio::VSDStyles::getTextBlockStyle(unsigned textStyleIndex) const { unsigned tmpIndex = textStyleIndex; - std::map<unsigned, VSDXTextBlockStyle *>::const_iterator iterStyle; + std::map<unsigned, VSDTextBlockStyle *>::const_iterator iterStyle; while (true) { iterStyle = m_textBlockStyles.find(tmpIndex); @@ -312,10 +312,10 @@ const libvisio::VSDXTextBlockStyle *libvisio::VSDXStyles::getTextBlockStyle(unsi return 0; } -const libvisio::VSDXCharStyle *libvisio::VSDXStyles::getCharStyle(unsigned textStyleIndex) const +const libvisio::VSDCharStyle *libvisio::VSDStyles::getCharStyle(unsigned textStyleIndex) const { unsigned tmpIndex = textStyleIndex; - std::map<unsigned, VSDXCharStyle *>::const_iterator iterStyle; + std::map<unsigned, VSDCharStyle *>::const_iterator iterStyle; while (true) { iterStyle = m_charStyles.find(tmpIndex); @@ -331,10 +331,10 @@ const libvisio::VSDXCharStyle *libvisio::VSDXStyles::getCharStyle(unsigned textS return 0; } -const libvisio::VSDXParaStyle *libvisio::VSDXStyles::getParaStyle(unsigned textStyleIndex) const +const libvisio::VSDParaStyle *libvisio::VSDStyles::getParaStyle(unsigned textStyleIndex) const { unsigned tmpIndex = textStyleIndex; - std::map<unsigned, VSDXParaStyle *>::const_iterator iterStyle; + std::map<unsigned, VSDParaStyle *>::const_iterator iterStyle; while (true) { iterStyle = m_paraStyles.find(tmpIndex); diff --git a/src/lib/VSDXStyles.h b/src/lib/VSDStyles.h index 13c4ff7..7a49052 100644 --- a/src/lib/VSDXStyles.h +++ b/src/lib/VSDStyles.h @@ -28,25 +28,25 @@ * instead of those above. */ -#ifndef __VSDXSTYLES_H__ -#define __VSDXSTYLES_H__ +#ifndef __VSDSTYLES_H__ +#define __VSDSTYLES_H__ #include <map> #include <vector> #include <libwpg/libwpg.h> -#include "VSDXTypes.h" +#include "VSDTypes.h" namespace libvisio { -struct VSDXLineStyle +struct VSDLineStyle { - VSDXLineStyle() + VSDLineStyle() : width(0.01), colour(), pattern(0), startMarker(0), endMarker(0), cap(0) {} - VSDXLineStyle(double w, Colour col, unsigned char p, unsigned char sm, + VSDLineStyle(double w, Colour col, unsigned char p, unsigned char sm, unsigned char em, unsigned char c) : width(w), colour(col), pattern(p), startMarker(sm), endMarker(em), cap(c) {} - ~VSDXLineStyle() {} + ~VSDLineStyle() {} double width; Colour colour; unsigned char pattern; @@ -55,13 +55,13 @@ struct VSDXLineStyle unsigned char cap; }; -struct VSDXFillStyle +struct VSDFillStyle { - VSDXFillStyle() + VSDFillStyle() : fgColourId(1), bgColourId(0), pattern(0), fgTransparency(0), bgTransparency(0), shadowFgColour(), shadowPattern(0), shadowOffsetX(0), shadowOffsetY(0) {} - VSDXFillStyle(unsigned char fgcId, unsigned char bgcId, unsigned char p, unsigned char fga, unsigned char bga, Colour sfgc, unsigned char shp, double shX, double shY) + VSDFillStyle(unsigned char fgcId, unsigned char bgcId, unsigned char p, unsigned char fga, unsigned char bga, Colour sfgc, unsigned char shp, double shX, double shY) : fgColourId(fgcId), bgColourId(bgcId), pattern(p), fgTransparency(fga), bgTransparency(bga), shadowFgColour(sfgc), shadowPattern(shp), shadowOffsetX(shX), shadowOffsetY(shY) {} - ~VSDXFillStyle() {} + ~VSDFillStyle() {} unsigned char fgColourId; // Colour fgColour; unsigned char bgColourId; @@ -77,9 +77,9 @@ struct VSDXFillStyle double shadowOffsetY; }; -struct VSDXCharStyle +struct VSDCharStyle { - VSDXCharStyle() : + VSDCharStyle() : charCount(0), faceID(0), colour(), @@ -96,7 +96,7 @@ struct VSDXCharStyle superscript(false), subscript(false), face() {} - VSDXCharStyle(unsigned cc, unsigned short id, Colour c, double s, bool b, bool i, bool u, bool du, bool so, bool dso, bool ac, bool ic, bool sc, bool super, bool sub, VSDXFont f) : + VSDCharStyle(unsigned cc, unsigned short id, Colour c, double s, bool b, bool i, bool u, bool du, bool so, bool dso, bool ac, bool ic, bool sc, bool super, bool sub, VSDFont f) : charCount(cc), faceID(id), colour(c), @@ -113,7 +113,7 @@ struct VSDXCharStyle superscript(super), subscript(sub), face(f) {} - ~VSDXCharStyle() {} + ~VSDCharStyle() {} unsigned charCount; unsigned short faceID; Colour colour; @@ -129,12 +129,12 @@ struct VSDXCharStyle bool smallcaps; bool superscript; bool subscript; - VSDXFont face; + VSDFont face; }; -struct VSDXParaStyle +struct VSDParaStyle { - VSDXParaStyle() : + VSDParaStyle() : charCount(0), indFirst(0.0), indLeft(0.0), @@ -144,7 +144,7 @@ struct VSDXParaStyle spAfter(0.0), align(1), flags(0) {} - VSDXParaStyle(unsigned cc, double ifst, double il, double ir, double sl, double sb, double sa, unsigned char a, unsigned f) : + VSDParaStyle(unsigned cc, double ifst, double il, double ir, double sl, double sb, double sa, unsigned char a, unsigned f) : charCount(cc), indFirst(ifst), indLeft(il), @@ -154,7 +154,7 @@ struct VSDXParaStyle spAfter(sa), align(a), flags(f) {} - ~VSDXParaStyle() {} + ~VSDParaStyle() {} unsigned charCount; double indFirst; double indLeft; @@ -166,9 +166,9 @@ struct VSDXParaStyle unsigned flags; }; -struct VSDXTextBlockStyle +struct VSDTextBlockStyle { - VSDXTextBlockStyle() : + VSDTextBlockStyle() : leftMargin(0.0), rightMargin(0.0), topMargin(0.0), @@ -178,7 +178,7 @@ struct VSDXTextBlockStyle textBkgndColour(0xff,0xff,0xff,0), defaultTabStop(0.5), textDirection(0) {} - VSDXTextBlockStyle(double lm, double rm, double tm, double bm, unsigned char va, unsigned char bgClrId, Colour bgClr, double defTab, unsigned char td) : + VSDTextBlockStyle(double lm, double rm, double tm, double bm, unsigned char va, unsigned char bgClrId, Colour bgClr, double defTab, unsigned char td) : leftMargin(lm), rightMargin(rm), topMargin(tm), @@ -188,7 +188,7 @@ struct VSDXTextBlockStyle textBkgndColour(bgClr), defaultTabStop(defTab), textDirection(td) {} - ~VSDXTextBlockStyle() {} + ~VSDTextBlockStyle() {} double leftMargin; double rightMargin; double topMargin; @@ -200,35 +200,35 @@ struct VSDXTextBlockStyle unsigned char textDirection; }; -class VSDXStyles +class VSDStyles { public: - VSDXStyles(); - VSDXStyles(const VSDXStyles &styles); - ~VSDXStyles(); - VSDXStyles &operator=(const VSDXStyles &styles); - void addLineStyle(unsigned lineStyleIndex, VSDXLineStyle *lineStyle); - void addFillStyle(unsigned fillStyleIndex, VSDXFillStyle *fillStyle); - void addTextBlockStyle(unsigned textStyleIndex, VSDXTextBlockStyle *textBlockStyle); - void addCharStyle(unsigned textStyleIndex, VSDXCharStyle *charStyle); - void addParaStyle(unsigned textStyleIndex, VSDXParaStyle *paraStyle); + VSDStyles(); + VSDStyles(const VSDStyles &styles); + ~VSDStyles(); + VSDStyles &operator=(const VSDStyles &styles); + void addLineStyle(unsigned lineStyleIndex, VSDLineStyle *lineStyle); + void addFillStyle(unsigned fillStyleIndex, VSDFillStyle *fillStyle); + void addTextBlockStyle(unsigned textStyleIndex, VSDTextBlockStyle *textBlockStyle); + void addCharStyle(unsigned textStyleIndex, VSDCharStyle *charStyle); + void addParaStyle(unsigned textStyleIndex, VSDParaStyle *paraStyle); void addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster); void addFillStyleMaster(unsigned fillStyleIndex, unsigned fillStyleMaster); void addTextStyleMaster(unsigned textStyleIndex, unsigned textStyleMaster); - const VSDXLineStyle *getLineStyle(unsigned lineStyleIndex) const; - const VSDXFillStyle *getFillStyle(unsigned fillStyleIndex) const; - const VSDXTextBlockStyle *getTextBlockStyle(unsigned textStyleIndex) const; - const VSDXCharStyle *getCharStyle(unsigned textStyleIndex) const; - const VSDXParaStyle *getParaStyle(unsigned textStyleIndex) const; + const VSDLineStyle *getLineStyle(unsigned lineStyleIndex) const; + const VSDFillStyle *getFillStyle(unsigned fillStyleIndex) const; + const VSDTextBlockStyle *getTextBlockStyle(unsigned textStyleIndex) const; + const VSDCharStyle *getCharStyle(unsigned textStyleIndex) const; + const VSDParaStyle *getParaStyle(unsigned textStyleIndex) const; private: - std::map<unsigned, VSDXLineStyle *> m_lineStyles; - std::map<unsigned, VSDXFillStyle *> m_fillStyles; - std::map<unsigned, VSDXTextBlockStyle *> m_textBlockStyles; - std::map<unsigned, VSDXCharStyle *> m_charStyles; - std::map<unsigned, VSDXParaStyle *> m_paraStyles; + std::map<unsigned, VSDLineStyle *> m_lineStyles; + std::map<unsigned, VSDFillStyle *> m_fillStyles; + std::map<unsigned, VSDTextBlockStyle *> m_textBlockStyles; + std::map<unsigned, VSDCharStyle *> m_charStyles; + std::map<unsigned, VSDParaStyle *> m_paraStyles; std::map<unsigned, unsigned> m_lineStyleMasters; std::map<unsigned, unsigned> m_fillStyleMasters; std::map<unsigned, unsigned> m_textStyleMasters; @@ -237,5 +237,5 @@ private: } // namespace libvisio -#endif // __VSDXSTYLES_H__ +#endif // __VSDSTYLES_H__ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXStylesCollector.cpp b/src/lib/VSDStylesCollector.cpp index d7212a1..959cbc8 100644 --- a/src/lib/VSDXStylesCollector.cpp +++ b/src/lib/VSDStylesCollector.cpp @@ -30,9 +30,9 @@ #include <vector> #include <map> -#include "VSDXStylesCollector.h" +#include "VSDStylesCollector.h" -libvisio::VSDXStylesCollector::VSDXStylesCollector( +libvisio::VSDStylesCollector::VSDStylesCollector( std::vector<std::map<unsigned, XForm> > &groupXFormsSequence, std::vector<std::map<unsigned, unsigned> > &groupMembershipsSequence, std::vector<std::list<unsigned> > &documentPageShapeOrders @@ -53,69 +53,69 @@ libvisio::VSDXStylesCollector::VSDXStylesCollector( m_documentPageShapeOrders.clear(); } -void libvisio::VSDXStylesCollector::collectEllipticalArcTo(unsigned /* id */, unsigned level, double /* x3 */, double /* y3 */, +void libvisio::VSDStylesCollector::collectEllipticalArcTo(unsigned /* id */, unsigned level, double /* x3 */, double /* y3 */, double /* x2 */, double /* y2 */, double /* angle */, double /* ecc */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectForeignData(unsigned /* id */, unsigned level, const WPXBinaryData & /* binaryData */) +void libvisio::VSDStylesCollector::collectForeignData(unsigned /* id */, unsigned level, const WPXBinaryData & /* binaryData */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectOLEData(unsigned /* id */, unsigned level, const WPXBinaryData & /* oleData */) +void libvisio::VSDStylesCollector::collectOLEData(unsigned /* id */, unsigned level, const WPXBinaryData & /* oleData */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectEllipse(unsigned /* id */, unsigned level, double /* cx */, double /* cy */, +void libvisio::VSDStylesCollector::collectEllipse(unsigned /* id */, unsigned level, double /* cx */, double /* cy */, double /* xleft */, double /* yleft */, double /* xtop */, double /* ytop */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectLine(unsigned /* id */, unsigned level, double /* strokeWidth */, Colour /* c */, +void libvisio::VSDStylesCollector::collectLine(unsigned /* id */, unsigned level, double /* strokeWidth */, Colour /* c */, unsigned /* linePattern */, unsigned char /*startMarker*/, unsigned char /*endMarker*/, unsigned /* lineCap */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectFillAndShadow(unsigned /* id */, unsigned level, unsigned /* colourIndexFG */, unsigned /* colourIndexBG */, +void libvisio::VSDStylesCollector::collectFillAndShadow(unsigned /* id */, unsigned level, unsigned /* colourIndexFG */, unsigned /* colourIndexBG */, unsigned /* fillPattern */, unsigned /* fillFGTransparency */, unsigned /* fillBGTransparency */, unsigned /* shadowPattern */, Colour /* shfgc */, double /* shadowOffsetX */, double /* shadowOffsetY */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectFillAndShadow(unsigned /* id */, unsigned level, unsigned /* colourIndexFG */, unsigned /* colourIndexBG */, +void libvisio::VSDStylesCollector::collectFillAndShadow(unsigned /* id */, unsigned level, unsigned /* colourIndexFG */, unsigned /* colourIndexBG */, unsigned /* fillPattern */, unsigned /* fillFGTransparency */, unsigned /* fillBGTransparency */, unsigned /* shadowPattern */, Colour /* shfgc */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectGeometry(unsigned /* id */, unsigned level, unsigned char /* geomFlags */) +void libvisio::VSDStylesCollector::collectGeometry(unsigned /* id */, unsigned level, unsigned char /* geomFlags */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectMoveTo(unsigned /* id */, unsigned level, double /* x */, double /* y */) +void libvisio::VSDStylesCollector::collectMoveTo(unsigned /* id */, unsigned level, double /* x */, double /* y */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectLineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */) +void libvisio::VSDStylesCollector::collectLineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectArcTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */, double /* bow */) +void libvisio::VSDStylesCollector::collectArcTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */, double /* bow */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectNURBSTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */, +void libvisio::VSDStylesCollector::collectNURBSTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */, unsigned char /* xType */, unsigned char /* yType */, unsigned /* degree */, std::vector<std::pair<double, double> > /* controlPoints */, std::vector<double> /* knotVector */, std::vector<double> /* weights */) @@ -123,70 +123,70 @@ void libvisio::VSDXStylesCollector::collectNURBSTo(unsigned /* id */, unsigned l _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectNURBSTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */, double /* knot */, +void libvisio::VSDStylesCollector::collectNURBSTo(unsigned /* id */, unsigned level, double /* x2 */, double /* y2 */, double /* knot */, double /* knotPrev */, double /* weight */, double /* weightPrev */, unsigned /* dataID */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectPolylineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */, +void libvisio::VSDStylesCollector::collectPolylineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */, unsigned char /* xType */, unsigned char /* yType */, std::vector<std::pair<double, double> > & /* points */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectPolylineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */, unsigned /* dataID */) +void libvisio::VSDStylesCollector::collectPolylineTo(unsigned /* id */, unsigned level, double /* x */, double /* y */, unsigned /* dataID */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectSplineStart(unsigned /* id */, unsigned level, double /* x */, double /* y */, +void libvisio::VSDStylesCollector::collectSplineStart(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* secondKnot */, double /* firstKnot */, double /* lastKnot */, unsigned /* degree */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectSplineKnot(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* knot */) +void libvisio::VSDStylesCollector::collectSplineKnot(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* knot */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectSplineEnd() +void libvisio::VSDStylesCollector::collectSplineEnd() { } -void libvisio::VSDXStylesCollector::collectInfiniteLine(unsigned /* id */, unsigned level, double /* x1 */, double /* y1 */, double /* x2 */, double /* y2 */) +void libvisio::VSDStylesCollector::collectInfiniteLine(unsigned /* id */, unsigned level, double /* x1 */, double /* y1 */, double /* x2 */, double /* y2 */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectShapeData(unsigned /* id */, unsigned level, unsigned char /* xType */, unsigned char /* yType */, +void libvisio::VSDStylesCollector::collectShapeData(unsigned /* id */, unsigned level, unsigned char /* xType */, unsigned char /* yType */, unsigned /* degree */, double /*lastKnot*/, std::vector<std::pair<double, double> > /* controlPoints */, std::vector<double> /* knotVector */, std::vector<double> /* weights */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectShapeData(unsigned /* id */, unsigned level, unsigned char /* xType */, unsigned char /* yType */, +void libvisio::VSDStylesCollector::collectShapeData(unsigned /* id */, unsigned level, unsigned char /* xType */, unsigned char /* yType */, std::vector<std::pair<double, double> > /* points */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectXFormData(unsigned /* id */, unsigned level, const XForm &xform) +void libvisio::VSDStylesCollector::collectXFormData(unsigned /* id */, unsigned level, const XForm &xform) { _handleLevelChange(level); if (m_isShapeStarted) m_groupXForms[m_currentShapeId] = xform; } -void libvisio::VSDXStylesCollector::collectTxtXForm(unsigned /* id */, unsigned level, const XForm & /* txtxform */) +void libvisio::VSDStylesCollector::collectTxtXForm(unsigned /* id */, unsigned level, const XForm & /* txtxform */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectShapeId(unsigned /* id */, unsigned level, unsigned shapeId) +void libvisio::VSDStylesCollector::collectShapeId(unsigned /* id */, unsigned level, unsigned shapeId) { _handleLevelChange(level); if (m_isShapeStarted) @@ -194,24 +194,24 @@ void libvisio::VSDXStylesCollector::collectShapeId(unsigned /* id */, unsigned l m_shapeList.push_back(shapeId); } -void libvisio::VSDXStylesCollector::collectForeignDataType(unsigned /* id */, unsigned level, unsigned /* foreignType */, unsigned /* foreignFormat */, +void libvisio::VSDStylesCollector::collectForeignDataType(unsigned /* id */, unsigned level, unsigned /* foreignType */, unsigned /* foreignFormat */, double /* offsetX */, double /* offsetY */, double /* width */, double /* height */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectPageProps(unsigned /* id */, unsigned level, double /* pageWidth */, double /* pageHeight */, +void libvisio::VSDStylesCollector::collectPageProps(unsigned /* id */, unsigned level, double /* pageWidth */, double /* pageHeight */, double /* shadowOffsetX */, double /* shadowOffsetY */, double /* scale */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectPage(unsigned /* id */, unsigned level, unsigned /* backgroundPageID */) +void libvisio::VSDStylesCollector::collectPage(unsigned /* id */, unsigned level, unsigned /* backgroundPageID */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectShape(unsigned id, unsigned level, unsigned /*masterPage*/, unsigned /*masterShape*/, +void libvisio::VSDStylesCollector::collectShape(unsigned id, unsigned level, unsigned /*masterPage*/, unsigned /*masterShape*/, unsigned /* lineStyle */, unsigned /* fillStyle */, unsigned /* textStyle */) { _handleLevelChange(level); @@ -220,57 +220,57 @@ void libvisio::VSDXStylesCollector::collectShape(unsigned id, unsigned level, un m_isShapeStarted = true; } -void libvisio::VSDXStylesCollector::collectUnhandledChunk(unsigned /* id */, unsigned level) +void libvisio::VSDStylesCollector::collectUnhandledChunk(unsigned /* id */, unsigned level) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectColours(const std::vector<Colour> & /* colours */) +void libvisio::VSDStylesCollector::collectColours(const std::vector<Colour> & /* colours */) { } -void libvisio::VSDXStylesCollector::collectFont(unsigned short /* fontID */, const ::WPXBinaryData & /* textStream */, TextFormat /* format */) +void libvisio::VSDStylesCollector::collectFont(unsigned short /* fontID */, const ::WPXBinaryData & /* textStream */, TextFormat /* format */) { } -void libvisio::VSDXStylesCollector::collectText(unsigned /*id*/, unsigned level, const ::WPXBinaryData & /*textStream*/, TextFormat /*format*/) +void libvisio::VSDStylesCollector::collectText(unsigned /*id*/, unsigned level, const ::WPXBinaryData & /*textStream*/, TextFormat /*format*/) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectVSDXParaStyle(unsigned /* id */ , unsigned level, unsigned /* charCount */, double /* indFirst */, double /* indLeft */, +void libvisio::VSDStylesCollector::collectVSDParaStyle(unsigned /* id */ , unsigned level, unsigned /* charCount */, double /* indFirst */, double /* indLeft */, double /* indRight */, double /* spLine */, double /* spBefore */, double /* spAfter */, unsigned char /* align */, unsigned /* flags */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectVSDXCharStyle(unsigned /*id*/ , unsigned level, unsigned /*charCount*/, unsigned short /*fontID*/, +void libvisio::VSDStylesCollector::collectVSDCharStyle(unsigned /*id*/ , unsigned level, unsigned /*charCount*/, unsigned short /*fontID*/, Colour /*fontColour*/, double /*fontSize*/, bool /*bold*/, bool /*italic*/, bool /*underline*/, bool /* doubleunderline */, bool /* strikeout */, bool /* doublestrikeout */, bool /* allcaps */, - bool /* initcaps */, bool /* smallcaps */, bool /* superscript */, bool /* subscript */, VSDXFont /*fontFace*/) + bool /* initcaps */, bool /* smallcaps */, bool /* superscript */, bool /* subscript */, VSDFont /*fontFace*/) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectTextBlock(unsigned /* id */, unsigned level, double /* leftMargin */, double /* rightMargin */, +void libvisio::VSDStylesCollector::collectTextBlock(unsigned /* id */, unsigned level, double /* leftMargin */, double /* rightMargin */, double /* topMargin */, double /* bottomMargin */, unsigned char /* verticalAlign */, unsigned char /* bgClrId */, const Colour & /* colour */, double /* defaultTabStop */, unsigned char /* textDirection */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectName(unsigned /*id*/, unsigned level, const ::WPXBinaryData & /*name*/, TextFormat /*format*/) +void libvisio::VSDStylesCollector::collectName(unsigned /*id*/, unsigned level, const ::WPXBinaryData & /*name*/, TextFormat /*format*/) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectPageSheet(unsigned /* id */, unsigned level) +void libvisio::VSDStylesCollector::collectPageSheet(unsigned /* id */, unsigned level) { _handleLevelChange(level); m_currentShapeLevel = level; } -void libvisio::VSDXStylesCollector::collectStyleSheet(unsigned id, unsigned level, unsigned lineStyleParent, unsigned fillStyleParent, unsigned textStyleParent) +void libvisio::VSDStylesCollector::collectStyleSheet(unsigned id, unsigned level, unsigned lineStyleParent, unsigned fillStyleParent, unsigned textStyleParent) { _handleLevelChange(level); // reusing the shape level for style sheet to avoid another variable @@ -287,11 +287,11 @@ void libvisio::VSDXStylesCollector::collectStyleSheet(unsigned id, unsigned leve m_isStyleStarted = true; } -void libvisio::VSDXStylesCollector::collectLineStyle(unsigned /* id */, unsigned level, double strokeWidth, Colour c, unsigned char linePattern, +void libvisio::VSDStylesCollector::collectLineStyle(unsigned /* id */, unsigned level, double strokeWidth, Colour c, unsigned char linePattern, unsigned char startMarker, unsigned char endMarker, unsigned char lineCap) { if (!m_lineStyle) - m_lineStyle = new VSDXLineStyle(); + m_lineStyle = new VSDLineStyle(); m_lineStyle->width = strokeWidth; m_lineStyle->colour = c; @@ -303,12 +303,12 @@ void libvisio::VSDXStylesCollector::collectLineStyle(unsigned /* id */, unsigned _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectFillStyle(unsigned /*id*/, unsigned level, unsigned char colourIndexFG, unsigned char colourIndexBG, +void libvisio::VSDStylesCollector::collectFillStyle(unsigned /*id*/, unsigned level, unsigned char colourIndexFG, unsigned char colourIndexBG, unsigned char fillPattern, unsigned char fillFGTransparency, unsigned char fillBGTransparency, unsigned char shadowPattern, Colour shfgc, double shadowOffsetX, double shadowOffsetY) { if (!m_fillStyle) - m_fillStyle = new VSDXFillStyle(); + m_fillStyle = new VSDFillStyle(); m_fillStyle->fgColourId = colourIndexFG; m_fillStyle->bgColourId = colourIndexBG; @@ -324,57 +324,57 @@ void libvisio::VSDXStylesCollector::collectFillStyle(unsigned /*id*/, unsigned l _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectParaIXStyle(unsigned /*id*/, unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, +void libvisio::VSDStylesCollector::collectParaIXStyle(unsigned /*id*/, unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags) { _handleLevelChange(level); if (!m_paraStyle) - m_paraStyle = new VSDXParaStyle(charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align, flags); + m_paraStyle = new VSDParaStyle(charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align, flags); } -void libvisio::VSDXStylesCollector::collectCharIXStyle(unsigned /*id*/ , unsigned level, unsigned charCount, unsigned short fontID, +void libvisio::VSDStylesCollector::collectCharIXStyle(unsigned /*id*/ , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, bool allcaps, bool initcaps, bool smallcaps, - bool superscript, bool subscript, VSDXFont fontFace) + bool superscript, bool subscript, VSDFont fontFace) { _handleLevelChange(level); if (!m_charStyle) - m_charStyle = new VSDXCharStyle(charCount, fontID, fontColour, fontSize, bold, italic, underline, doubleunderline, strikeout, doublestrikeout, + m_charStyle = new VSDCharStyle(charCount, fontID, fontColour, fontSize, bold, italic, underline, doubleunderline, strikeout, doublestrikeout, allcaps, initcaps, smallcaps, superscript, subscript, fontFace); } -void libvisio::VSDXStylesCollector::collectTextBlockStyle(unsigned /* id */, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, +void libvisio::VSDStylesCollector::collectTextBlockStyle(unsigned /* id */, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, unsigned char verticalAlign, unsigned char bgClrId, const Colour &bgColour, double defaultTabStop, unsigned char textDirection) { _handleLevelChange(level); if (!m_textBlockStyle) - m_textBlockStyle = new VSDXTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, verticalAlign, bgClrId, bgColour, defaultTabStop, textDirection); + m_textBlockStyle = new VSDTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, verticalAlign, bgClrId, bgColour, defaultTabStop, textDirection); } -void libvisio::VSDXStylesCollector::collectFillStyle(unsigned id, unsigned level, unsigned char colourIndexFG, unsigned char colourIndexBG, +void libvisio::VSDStylesCollector::collectFillStyle(unsigned id, unsigned level, unsigned char colourIndexFG, unsigned char colourIndexBG, unsigned char fillPattern, unsigned char fillFGTransparency, unsigned char fillBGTransparency, unsigned char shadowPattern, Colour shfgc) { collectFillStyle(id, level, colourIndexFG, colourIndexBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowPattern, shfgc, m_shadowOffsetX, m_shadowOffsetY); } -void libvisio::VSDXStylesCollector::collectFieldList(unsigned /* id */, unsigned level) +void libvisio::VSDStylesCollector::collectFieldList(unsigned /* id */, unsigned level) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectTextField(unsigned /* id */, unsigned level, int /* nameId */, int /* formatStringId */) +void libvisio::VSDStylesCollector::collectTextField(unsigned /* id */, unsigned level, int /* nameId */, int /* formatStringId */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectNumericField(unsigned /* id */, unsigned level, unsigned short /* format */, double /* number */, int /* formatStringId */) +void libvisio::VSDStylesCollector::collectNumericField(unsigned /* id */, unsigned level, unsigned short /* format */, double /* number */, int /* formatStringId */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::startPage(unsigned /* pageId */) +void libvisio::VSDStylesCollector::startPage(unsigned /* pageId */) { m_groupXForms.clear(); m_groupMemberships.clear(); @@ -382,7 +382,7 @@ void libvisio::VSDXStylesCollector::startPage(unsigned /* pageId */) m_groupShapeOrder.clear(); } -void libvisio::VSDXStylesCollector::endPage() +void libvisio::VSDStylesCollector::endPage() { _handleLevelChange(0); m_groupXFormsSequence.push_back(m_groupXForms); @@ -403,7 +403,7 @@ void libvisio::VSDXStylesCollector::endPage() m_documentPageShapeOrders.push_back(m_pageShapeOrder); } -void libvisio::VSDXStylesCollector::_handleLevelChange(unsigned level) +void libvisio::VSDStylesCollector::_handleLevelChange(unsigned level) { if (m_currentLevel == level) return; @@ -446,7 +446,7 @@ void libvisio::VSDXStylesCollector::_handleLevelChange(unsigned level) m_currentLevel = level; } -void libvisio::VSDXStylesCollector::_flushShapeList() +void libvisio::VSDStylesCollector::_flushShapeList() { if (m_shapeList.empty()) return; diff --git a/src/lib/VSDXStylesCollector.h b/src/lib/VSDStylesCollector.h index 5ddb288..9abb1d9 100644 --- a/src/lib/VSDXStylesCollector.h +++ b/src/lib/VSDStylesCollector.h @@ -28,29 +28,29 @@ * instead of those above. */ -#ifndef VSDXSTYLESCOLLECTOR_H -#define VSDXSTYLESCOLLECTOR_H +#ifndef VSDSTYLESCOLLECTOR_H +#define VSDSTYLESCOLLECTOR_H #include <map> #include <vector> #include <list> -#include "VSDXCollector.h" -#include "VSDXParser.h" +#include "VSDCollector.h" +#include "VSDParser.h" #include "libvisio_utils.h" -#include "VSDXStyles.h" +#include "VSDStyles.h" namespace libvisio { -class VSDXStylesCollector : public VSDXCollector +class VSDStylesCollector : public VSDCollector { public: - VSDXStylesCollector( + VSDStylesCollector( std::vector<std::map<unsigned, XForm> > &groupXFormsSequence, std::vector<std::map<unsigned, unsigned> > &groupMembershipsSequence, std::vector<std::list<unsigned> > &documentPageShapeOrders ); - virtual ~VSDXStylesCollector() {}; + virtual ~VSDStylesCollector() {}; void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc); void collectForeignData(unsigned id, unsigned level, const WPXBinaryData &binaryData); @@ -96,10 +96,10 @@ public: void collectFont(unsigned short fontID, const ::WPXBinaryData &textStream, TextFormat format); void collectText(unsigned id, unsigned level, const ::WPXBinaryData &textStream, TextFormat format); - void collectVSDXCharStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, + void collectVSDCharStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace); - void collectVSDXParaStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace); + void collectVSDParaStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags); void collectTextBlock(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, unsigned char verticalAlign, unsigned char bgClrId, const Colour &bgColour, double defaultTabStop, unsigned char textDirection); @@ -120,7 +120,7 @@ public: unsigned char fillFGTransparency, unsigned char fillBGTransparency, unsigned char shadowPattern, Colour shfgc); void collectCharIXStyle(unsigned id , unsigned level, unsigned charCount, unsigned short fontID, Colour fontColour, double fontSize, bool bold, bool italic, bool underline, bool doubleunderline, bool strikeout, bool doublestrikeout, - bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDXFont fontFace); + bool allcaps, bool initcaps, bool smallcaps, bool superscript, bool subscript, VSDFont fontFace); void collectParaIXStyle(unsigned id , unsigned level, unsigned charCount, double indFirst, double indLeft, double indRight, double spLine, double spBefore, double spAfter, unsigned char align, unsigned flags); void collectTextBlockStyle(unsigned id, unsigned level, double leftMargin, double rightMargin, double topMargin, double bottomMargin, unsigned char verticalAlign, @@ -136,15 +136,15 @@ public: void endPage(); void endPages() {} - VSDXStyles getStyleSheets() const + VSDStyles getStyleSheets() const { return m_styles; } private: - VSDXStylesCollector(const VSDXStylesCollector &); - VSDXStylesCollector &operator=(const VSDXStylesCollector &); + VSDStylesCollector(const VSDStylesCollector &); + VSDStylesCollector &operator=(const VSDStylesCollector &); void _handleLevelChange(unsigned level); void _flushShapeList(); @@ -166,12 +166,12 @@ private: std::list<unsigned> m_shapeList; unsigned m_currentStyleSheet; - VSDXStyles m_styles; - VSDXLineStyle *m_lineStyle; - VSDXFillStyle *m_fillStyle; - VSDXTextBlockStyle *m_textBlockStyle; - VSDXCharStyle *m_charStyle; - VSDXParaStyle *m_paraStyle; + VSDStyles m_styles; + VSDLineStyle *m_lineStyle; + VSDFillStyle *m_fillStyle; + VSDTextBlockStyle *m_textBlockStyle; + VSDCharStyle *m_charStyle; + VSDParaStyle *m_paraStyle; unsigned m_lineStyleMaster; unsigned m_fillStyleMaster; @@ -182,5 +182,5 @@ private: } -#endif /* VSDXSTYLESCOLLECTOR_H */ +#endif /* VSDSTYLESCOLLECTOR_H */ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXTypes.h b/src/lib/VSDTypes.h index d150910..4f70240 100644 --- a/src/lib/VSDXTypes.h +++ b/src/lib/VSDTypes.h @@ -28,8 +28,8 @@ * instead of those above. */ -#ifndef VSDXTYPES_H -#define VSDXTYPES_H +#ifndef VSDTYPES_H +#define VSDTYPES_H #include <libwpd/libwpd.h> @@ -149,25 +149,25 @@ enum TextFormat VSD_TEXT_UTF16 }; -class VSDXName +class VSDName { public: - VSDXName(const WPXBinaryData &data, TextFormat format) + VSDName(const WPXBinaryData &data, TextFormat format) : m_data(data), m_format(format) {} - VSDXName() : m_data(), m_format(VSD_TEXT_ANSI) {} + VSDName() : m_data(), m_format(VSD_TEXT_ANSI) {} WPXBinaryData m_data; TextFormat m_format; }; -struct VSDXFont +struct VSDFont { WPXString name; TextFormat encoding; - VSDXFont() : name("Arial"), encoding(libvisio::VSD_TEXT_ANSI) {} + VSDFont() : name("Arial"), encoding(libvisio::VSD_TEXT_ANSI) {} }; } // namespace libvisio -#endif /* VSDXTYPES_H */ +#endif /* VSDTYPES_H */ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXGeometryList.cpp b/src/lib/VSDXGeometryList.cpp deleted file mode 100644 index 5699475..0000000 --- a/src/lib/VSDXGeometryList.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libvisio - * Version: MPL 1.1 / GPLv2+ / LGPLv2+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> - * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> - * - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPLv2+"), or - * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), - * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable - * instead of those above. - */ - -#include "VSDXCollector.h" -#include "VSDXGeometryList.h" -#include "libvisio_utils.h" - -namespace libvisio -{ - - -class VSDXGeometry : public VSDXGeometryListElement -{ -public: - VSDXGeometry(unsigned id, unsigned level, unsigned geomFlags) : - m_id(id), m_level(level), m_geomFlags(geomFlags) {} - ~VSDXGeometry() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id; - unsigned m_level; - unsigned char m_geomFlags; -}; - -class VSDXMoveTo : public VSDXGeometryListElement -{ -public: - VSDXMoveTo(unsigned id, unsigned level, double x, double y) : - m_id(id), m_level(level), m_x(x), m_y(y) {} - ~VSDXMoveTo() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_x, m_y; -}; - -class VSDXLineTo : public VSDXGeometryListElement -{ -public: - VSDXLineTo(unsigned id, unsigned level, double x, double y) : - m_id(id), m_level(level), m_x(x), m_y(y) {} - ~VSDXLineTo() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_x, m_y; -}; - -class VSDXArcTo : public VSDXGeometryListElement -{ -public: - VSDXArcTo(unsigned id, unsigned level, double x2, double y2, double bow) : - m_id(id), m_level(level), m_x2(x2), m_y2(y2), m_bow(bow) {} - ~VSDXArcTo() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_x2, m_y2, m_bow; -}; - -class VSDXEllipse : public VSDXGeometryListElement -{ -public: - VSDXEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop) : - m_id(id), m_level(level), m_cx(cx), m_cy(cy), m_xleft(xleft), m_yleft(yleft), m_xtop(xtop), m_ytop(ytop) {} - ~VSDXEllipse() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_cx, m_cy, m_xleft, m_yleft, m_xtop, m_ytop; -}; - -class VSDXEllipticalArcTo : public VSDXGeometryListElement -{ -public: - VSDXEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) : - m_id(id), m_level(level), m_x3(x3), m_y3(y3), m_x2(x2), m_y2(y2), m_angle(angle), m_ecc(ecc) {} - ~VSDXEllipticalArcTo() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_x3, m_y3, m_x2, m_y2, m_angle, m_ecc; -}; - -class VSDXNURBSTo1 : public VSDXGeometryListElement -{ -public: - VSDXNURBSTo1(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree, std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) : - m_id(id), m_level(level), m_x2(x2), m_y2(y2), m_xType(xType), m_yType(yType), m_degree(degree), m_controlPoints(controlPoints), m_knotVector(knotVector), m_weights(weights) {} - ~VSDXNURBSTo1() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_x2, m_y2; - unsigned m_xType, m_yType; - unsigned m_degree; - std::vector<std::pair<double, double> > m_controlPoints; - std::vector<double> m_knotVector, m_weights; -}; - -class VSDXPolylineTo1 : public VSDXGeometryListElement -{ -public: - VSDXPolylineTo1(unsigned id , unsigned level, double x, double y, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points) : - m_id(id), m_level(level), m_x(x), m_y(y), m_xType(xType), m_yType(yType), m_points(points) {} - ~VSDXPolylineTo1() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_x, m_y; - unsigned m_xType, m_yType; - std::vector<std::pair<double, double> > m_points; -}; - -class VSDXSplineStart : public VSDXGeometryListElement -{ -public: - VSDXSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) : - m_id(id), m_level(level), m_x(x), m_y(y), m_secondKnot(secondKnot), m_firstKnot(firstKnot), m_lastKnot(lastKnot), m_degree(degree) {} - ~VSDXSplineStart() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_x, m_y; - double m_secondKnot, m_firstKnot, m_lastKnot; - unsigned m_degree; -}; - -class VSDXSplineKnot : public VSDXGeometryListElement -{ -public: - VSDXSplineKnot(unsigned id, unsigned level, double x, double y, double knot) : - m_id(id), m_level(level), m_x(x), m_y(y), m_knot(knot) {} - ~VSDXSplineKnot() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_x, m_y; - double m_knot; -}; - -class VSDXInfiniteLine : public VSDXGeometryListElement -{ -public: - VSDXInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2) : - m_id(id), m_level(level), m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2) {} - ~VSDXInfiniteLine() {} - void handle(VSDXCollector *collector); - VSDXGeometryListElement *clone(); -private: - unsigned m_id, m_level; - double m_x1, m_y1, m_x2, m_y2; -}; - -} // namespace libvisio - - -void libvisio::VSDXGeometry::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectGeometry(m_id, m_level, m_geomFlags); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXGeometry::clone() -{ - return new VSDXGeometry(m_id, m_level, m_geomFlags); -} - - -void libvisio::VSDXMoveTo::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectMoveTo(m_id, m_level, m_x, m_y); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXMoveTo::clone() -{ - return new VSDXMoveTo(m_id, m_level, m_x, m_y); -} - - -void libvisio::VSDXLineTo::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectLineTo(m_id, m_level, m_x, m_y); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXLineTo::clone() -{ - return new VSDXLineTo(m_id, m_level, m_x, m_y); -} - - -void libvisio::VSDXArcTo::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectArcTo(m_id, m_level, m_x2, m_y2, m_bow); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXArcTo::clone() -{ - return new VSDXArcTo(m_id, m_level, m_x2, m_y2, m_bow); -} - - -void libvisio::VSDXEllipse::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectEllipse(m_id, m_level, m_cx, m_cy, m_xleft, m_yleft, m_xtop, m_ytop); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXEllipse::clone() -{ - return new VSDXEllipse(m_id, m_level, m_cx, m_cy, m_xleft, m_yleft, m_xtop, m_ytop); -} - - -void libvisio::VSDXEllipticalArcTo::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectEllipticalArcTo(m_id, m_level, m_x3, m_y3, m_x2, m_y2, m_angle, m_ecc); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXEllipticalArcTo::clone() -{ - return new VSDXEllipticalArcTo(m_id, m_level, m_x3, m_y3, m_x2, m_y2, m_angle, m_ecc); -} - - -void libvisio::VSDXNURBSTo1::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectNURBSTo(m_id, m_level, m_x2, m_y2, m_xType, m_yType, m_degree, m_controlPoints, m_knotVector, m_weights); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXNURBSTo1::clone() -{ - return new VSDXNURBSTo1(m_id, m_level, m_x2, m_y2, m_xType, m_yType, m_degree, m_controlPoints, m_knotVector, m_weights); -} - - -void libvisio::VSDXNURBSTo2::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectNURBSTo(m_id, m_level, m_x2, m_y2, m_knot, m_knotPrev, m_weight, m_weightPrev, m_dataID); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXNURBSTo2::clone() -{ - return new VSDXNURBSTo2(m_id, m_level, m_x2, m_y2, m_knot, m_knotPrev, m_weight, m_weightPrev, m_dataID); -} - - -void libvisio::VSDXPolylineTo1::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectPolylineTo(m_id, m_level, m_x, m_y, m_xType, m_yType, m_points); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXPolylineTo1::clone() -{ - return new VSDXPolylineTo1(m_id, m_level, m_x, m_y, m_xType, m_yType, m_points); -} - - -void libvisio::VSDXPolylineTo2::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectPolylineTo(m_id, m_level, m_x, m_y, m_dataID); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXPolylineTo2::clone() -{ - return new VSDXPolylineTo2(m_id, m_level, m_x, m_y, m_dataID); -} - - -void libvisio::VSDXSplineStart::handle(VSDXCollector *collector) -{ - collector->collectSplineStart(m_id, m_level, m_x, m_y, m_secondKnot, m_firstKnot, m_lastKnot, m_degree); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXSplineStart::clone() -{ - return new VSDXSplineStart(m_id, m_level, m_x, m_y, m_secondKnot, m_firstKnot, m_lastKnot, m_degree); -} - - -void libvisio::VSDXSplineKnot::handle(VSDXCollector *collector) -{ - collector->collectSplineKnot(m_id, m_level, m_x, m_y, m_knot); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXSplineKnot::clone() -{ - return new VSDXSplineKnot(m_id, m_level, m_x, m_y, m_knot); -} - - -void libvisio::VSDXInfiniteLine::handle(VSDXCollector *collector) -{ - collector->collectSplineEnd(); - collector->collectInfiniteLine(m_id, m_level, m_x1, m_y1, m_x2, m_y2); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXInfiniteLine::clone() -{ - return new VSDXInfiniteLine(m_id, m_level, m_x1, m_y1, m_x2, m_y2); -} - - -libvisio::VSDXGeometryList::VSDXGeometryList() : - m_elements(), - m_elementsOrder() -{ -} - -libvisio::VSDXGeometryList::VSDXGeometryList(const VSDXGeometryList &geomList) : - m_elements(), - m_elementsOrder(geomList.m_elementsOrder) -{ - std::map<unsigned, VSDXGeometryListElement *>::const_iterator iter = geomList.m_elements.begin(); - for (; iter != geomList.m_elements.end(); ++iter) - m_elements[iter->first] = iter->second->clone(); -} - -libvisio::VSDXGeometryList &libvisio::VSDXGeometryList::operator=(const VSDXGeometryList &geomList) -{ - clear(); - std::map<unsigned, VSDXGeometryListElement *>::const_iterator iter = geomList.m_elements.begin(); - for (; iter != geomList.m_elements.end(); ++iter) - m_elements[iter->first] = iter->second->clone(); - m_elementsOrder = geomList.m_elementsOrder; - return *this; -} - -libvisio::VSDXGeometryList::~VSDXGeometryList() -{ - clear(); -} - -void libvisio::VSDXGeometryList::addGeometry(unsigned id, unsigned level, unsigned char geomFlags) -{ - m_elements[id] = new VSDXGeometry(id, level, geomFlags); -} - -void libvisio::VSDXGeometryList::addMoveTo(unsigned id, unsigned level, double x, double y) -{ - m_elements[id] = new VSDXMoveTo(id, level, x, y); -} - -void libvisio::VSDXGeometryList::addLineTo(unsigned id, unsigned level, double x, double y) -{ - m_elements[id] = new VSDXLineTo(id, level, x, y); -} - -void libvisio::VSDXGeometryList::addArcTo(unsigned id, unsigned level, double x2, double y2, double bow) -{ - m_elements[id] = new VSDXArcTo(id, level, x2, y2, bow); -} - -void libvisio::VSDXGeometryList::addNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree, std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights) -{ - m_elements[id] = new VSDXNURBSTo1(id, level, x2, y2, xType, yType, degree, controlPoints, knotVector, weights); -} - -void libvisio::VSDXGeometryList::addNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID) -{ - m_elements[id] = new VSDXNURBSTo2(id, level, x2, y2, knot, knotPrev, weight, weightPrev, dataID); -} - -void libvisio::VSDXGeometryList::addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points) -{ - m_elements[id] = new VSDXPolylineTo1(id, level, x, y, xType, yType, points); -} - -void libvisio::VSDXGeometryList::addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned dataID) -{ - m_elements[id] = new VSDXPolylineTo2(id, level, x, y, dataID); -} - -void libvisio::VSDXGeometryList::addEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop) -{ - m_elements[id] = new VSDXEllipse(id, level, cx, cy, xleft, yleft, xtop, ytop); -} - -void libvisio::VSDXGeometryList::addEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) -{ - m_elements[id] = new VSDXEllipticalArcTo(id, level, x3, y3, x2, y2, angle, ecc); -} - -void libvisio::VSDXGeometryList::addSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) -{ - m_elements[id] = new VSDXSplineStart(id, level, x, y, secondKnot, firstKnot, lastKnot, degree); -} - -void libvisio::VSDXGeometryList::addSplineKnot(unsigned id, unsigned level, double x, double y, double knot) -{ - m_elements[id] = new VSDXSplineKnot(id, level, x, y, knot); -} - -void libvisio::VSDXGeometryList::addInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2) -{ - m_elements[id] = new VSDXInfiniteLine(id, level, x1, y1, x2, y2); -} - -void libvisio::VSDXGeometryList::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::VSDXGeometryList::handle(VSDXCollector *collector) const -{ - if (empty()) - return; - std::map<unsigned, VSDXGeometryListElement *>::const_iterator iter; - if (!m_elementsOrder.empty()) - { - 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); - } - collector->collectSplineEnd(); -} - -void libvisio::VSDXGeometryList::clear() -{ - for (std::map<unsigned, VSDXGeometryListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) - delete iter->second; - m_elements.clear(); - m_elementsOrder.clear(); -} - -libvisio::VSDXGeometryListElement *libvisio::VSDXGeometryList::getElement(unsigned index) const -{ - if (m_elementsOrder.size() > index) - index = m_elementsOrder[index]; - - std::map<unsigned, VSDXGeometryListElement *>::const_iterator iter = m_elements.find(index); - if (iter != m_elements.end()) - return iter->second; - else - return 0; -} -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXOutputElementList.cpp b/src/lib/VSDXOutputElementList.cpp deleted file mode 100644 index 24e81e2..0000000 --- a/src/lib/VSDXOutputElementList.cpp +++ /dev/null @@ -1,441 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libvisio - * Version: MPL 1.1 / GPLv2+ / LGPLv2+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> - * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> - * - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPLv2+"), or - * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), - * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable - * instead of those above. - */ - -#include "VSDXOutputElementList.h" - -namespace libvisio -{ - -class VSDXOutputElement -{ -public: - VSDXOutputElement() {} - virtual ~VSDXOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter) = 0; - virtual VSDXOutputElement *clone() = 0; -}; - - -class VSDXStyleOutputElement : public VSDXOutputElement -{ -public: - VSDXStyleOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec); - virtual ~VSDXStyleOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXStyleOutputElement(m_propList, m_propListVec); - } -private: - WPXPropertyList m_propList; - WPXPropertyListVector m_propListVec; -}; - - -class VSDXPathOutputElement : public VSDXOutputElement -{ -public: - VSDXPathOutputElement(const WPXPropertyListVector &propListVec); - virtual ~VSDXPathOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXPathOutputElement(m_propListVec); - } -private: - WPXPropertyListVector m_propListVec; -}; - - -class VSDXGraphicObjectOutputElement : public VSDXOutputElement -{ -public: - VSDXGraphicObjectOutputElement(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData); - virtual ~VSDXGraphicObjectOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXGraphicObjectOutputElement(m_propList, m_binaryData); - } -private: - WPXPropertyList m_propList; - WPXBinaryData m_binaryData; -}; - - -class VSDXStartTextObjectOutputElement : public VSDXOutputElement -{ -public: - VSDXStartTextObjectOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec); - virtual ~VSDXStartTextObjectOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXStartTextObjectOutputElement(m_propList, m_propListVec); - } -private: - WPXPropertyList m_propList; - WPXPropertyListVector m_propListVec; -}; - - -class VSDXStartTextLineOutputElement : public VSDXOutputElement -{ -public: - VSDXStartTextLineOutputElement(const WPXPropertyList &propList); - virtual ~VSDXStartTextLineOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXStartTextLineOutputElement(m_propList); - } -private: - WPXPropertyList m_propList; -}; - - -class VSDXStartLayerOutputElement : public VSDXOutputElement -{ -public: - VSDXStartLayerOutputElement(const WPXPropertyList &propList); - virtual ~VSDXStartLayerOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXStartLayerOutputElement(m_propList); - } -private: - WPXPropertyList m_propList; -}; - - -class VSDXEndLayerOutputElement : public VSDXOutputElement -{ -public: - VSDXEndLayerOutputElement(); - virtual ~VSDXEndLayerOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXEndLayerOutputElement(); - } -}; - - -class VSDXStartTextSpanOutputElement : public VSDXOutputElement -{ -public: - VSDXStartTextSpanOutputElement(const WPXPropertyList &propList); - virtual ~VSDXStartTextSpanOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXStartTextSpanOutputElement(m_propList); - } -private: - WPXPropertyList m_propList; -}; - - -class VSDXInsertTextOutputElement : public VSDXOutputElement -{ -public: - VSDXInsertTextOutputElement(const WPXString &text); - virtual ~VSDXInsertTextOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXInsertTextOutputElement(m_text); - } -private: - WPXString m_text; -}; - - -class VSDXEndTextSpanOutputElement : public VSDXOutputElement -{ -public: - VSDXEndTextSpanOutputElement(); - virtual ~VSDXEndTextSpanOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXEndTextSpanOutputElement(); - } -}; - - -class VSDXEndTextLineOutputElement : public VSDXOutputElement -{ -public: - VSDXEndTextLineOutputElement(); - virtual ~VSDXEndTextLineOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXEndTextLineOutputElement(); - } -}; - - -class VSDXEndTextObjectOutputElement : public VSDXOutputElement -{ -public: - VSDXEndTextObjectOutputElement(); - virtual ~VSDXEndTextObjectOutputElement() {} - virtual void draw(libwpg::WPGPaintInterface *painter); - virtual VSDXOutputElement *clone() - { - return new VSDXEndTextObjectOutputElement(); - } -}; - -} // namespace libvisio - -libvisio::VSDXStyleOutputElement::VSDXStyleOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) : - m_propList(propList), m_propListVec(propListVec) {} - -void libvisio::VSDXStyleOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->setStyle(m_propList, m_propListVec); -} - - -libvisio::VSDXPathOutputElement::VSDXPathOutputElement(const WPXPropertyListVector &propListVec) : - m_propListVec(propListVec) {} - -void libvisio::VSDXPathOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->drawPath(m_propListVec); -} - - -libvisio::VSDXGraphicObjectOutputElement::VSDXGraphicObjectOutputElement(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData) : - m_propList(propList), m_binaryData(binaryData) {} - -void libvisio::VSDXGraphicObjectOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->drawGraphicObject(m_propList, m_binaryData); -} - - -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::VSDXStartTextSpanOutputElement::VSDXStartTextSpanOutputElement(const WPXPropertyList &propList) : - m_propList(propList) {} - -void libvisio::VSDXStartTextSpanOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->startTextSpan(m_propList); -} - - -libvisio::VSDXStartLayerOutputElement::VSDXStartLayerOutputElement(const WPXPropertyList &propList) : - m_propList(propList) {} - -void libvisio::VSDXStartLayerOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->startLayer(m_propList); -} - - -libvisio::VSDXEndLayerOutputElement::VSDXEndLayerOutputElement() {} - -void libvisio::VSDXEndLayerOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->endLayer(); -} - - -libvisio::VSDXStartTextLineOutputElement::VSDXStartTextLineOutputElement(const WPXPropertyList &propList) : - m_propList(propList) {} - -void libvisio::VSDXStartTextLineOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->startTextLine(m_propList); -} - - -libvisio::VSDXInsertTextOutputElement::VSDXInsertTextOutputElement(const WPXString &text) : - m_text(text) {} - -void libvisio::VSDXInsertTextOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->insertText(m_text); -} - -libvisio::VSDXEndTextSpanOutputElement::VSDXEndTextSpanOutputElement() {} - -void libvisio::VSDXEndTextSpanOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->endTextSpan(); -} - - -libvisio::VSDXEndTextLineOutputElement::VSDXEndTextLineOutputElement() {} - -void libvisio::VSDXEndTextLineOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->endTextLine(); -} - - -libvisio::VSDXEndTextObjectOutputElement::VSDXEndTextObjectOutputElement() {} - -void libvisio::VSDXEndTextObjectOutputElement::draw(libwpg::WPGPaintInterface *painter) -{ - if (painter) - painter->endTextObject(); -} - - -libvisio::VSDXOutputElementList::VSDXOutputElementList() - : m_elements() -{ -} - -libvisio::VSDXOutputElementList::VSDXOutputElementList(const libvisio::VSDXOutputElementList &elementList) - : m_elements() -{ - std::vector<libvisio::VSDXOutputElement *>::const_iterator iter; - for (iter = elementList.m_elements.begin(); iter != elementList.m_elements.end(); ++iter) - m_elements.push_back((*iter)->clone()); -} - -libvisio::VSDXOutputElementList &libvisio::VSDXOutputElementList::operator=(const libvisio::VSDXOutputElementList &elementList) -{ - for (std::vector<VSDXOutputElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) - delete (*iter); - - m_elements.clear(); - - for (std::vector<VSDXOutputElement *>::const_iterator cstiter = elementList.m_elements.begin(); cstiter != elementList.m_elements.end(); ++cstiter) - m_elements.push_back((*cstiter)->clone()); - - return *this; -} - -void libvisio::VSDXOutputElementList::append(const libvisio::VSDXOutputElementList &elementList) -{ - for (std::vector<VSDXOutputElement *>::const_iterator cstiter = elementList.m_elements.begin(); cstiter != elementList.m_elements.end(); ++cstiter) - m_elements.push_back((*cstiter)->clone()); -} - -libvisio::VSDXOutputElementList::~VSDXOutputElementList() -{ - for (std::vector<VSDXOutputElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) - delete (*iter); - m_elements.clear(); -} - -void libvisio::VSDXOutputElementList::draw(libwpg::WPGPaintInterface *painter) const -{ - for (std::vector<VSDXOutputElement *>::const_iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter) - (*iter)->draw(painter); -} - -void libvisio::VSDXOutputElementList::addStyle(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) -{ - m_elements.push_back(new VSDXStyleOutputElement(propList, propListVec)); -} - -void libvisio::VSDXOutputElementList::addPath(const WPXPropertyListVector &propListVec) -{ - m_elements.push_back(new VSDXPathOutputElement(propListVec)); -} - -void libvisio::VSDXOutputElementList::addGraphicObject(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData) -{ - m_elements.push_back(new VSDXGraphicObjectOutputElement(propList, binaryData)); -} - -void libvisio::VSDXOutputElementList::addStartTextObject(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) -{ - m_elements.push_back(new VSDXStartTextObjectOutputElement(propList, propListVec)); -} - -void libvisio::VSDXOutputElementList::addStartTextLine(const WPXPropertyList &propList) -{ - m_elements.push_back(new VSDXStartTextLineOutputElement(propList)); -} - -void libvisio::VSDXOutputElementList::addStartTextSpan(const WPXPropertyList &propList) -{ - m_elements.push_back(new VSDXStartTextSpanOutputElement(propList)); -} - -void libvisio::VSDXOutputElementList::addInsertText(const WPXString &text) -{ - m_elements.push_back(new VSDXInsertTextOutputElement(text)); -} - -void libvisio::VSDXOutputElementList::addEndTextSpan() -{ - m_elements.push_back(new VSDXEndTextSpanOutputElement()); -} - -void libvisio::VSDXOutputElementList::addEndTextLine() -{ - m_elements.push_back(new VSDXEndTextLineOutputElement()); -} - -void libvisio::VSDXOutputElementList::addEndTextObject() -{ - m_elements.push_back(new VSDXEndTextObjectOutputElement()); -} - -void libvisio::VSDXOutputElementList::addStartLayer(const WPXPropertyList &propList) -{ - m_elements.push_back(new VSDXStartLayerOutputElement(propList)); -} - -void libvisio::VSDXOutputElementList::addEndLayer() -{ - m_elements.push_back(new VSDXEndLayerOutputElement()); -} - -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDZipStream.cpp b/src/lib/VSDZipStream.cpp new file mode 100644 index 0000000..1dd486f --- /dev/null +++ b/src/lib/VSDZipStream.cpp @@ -0,0 +1,395 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libvisio + * Version: MPL 1.1 / GPLv2+ / LGPLv2+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch> + * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> + * + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPLv2+"), or + * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), + * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable + * instead of those above. + */ + + +#include <string> +#include <string.h> +#include <zlib.h> +#include <map> +#include "VSDZipStream.h" +#include "VSDInternalStream.h" +#include "libvisio_utils.h" + +namespace +{ + +struct LocalFileHeader +{ + unsigned short general_flag; + unsigned short compression; + unsigned crc32; + unsigned compressed_size; + unsigned uncompressed_size; + std::string filename; + LocalFileHeader() + : general_flag(0), compression(0), crc32(0), compressed_size(0), uncompressed_size(0), filename() {} + ~LocalFileHeader() {} +}; + +struct CentralDirectoryEntry +{ + unsigned short general_flag; + unsigned short compression; + unsigned crc32; + unsigned compressed_size; + unsigned uncompressed_size; + unsigned offset; + std::string filename; + CentralDirectoryEntry() + : general_flag(0), compression(0), crc32(0), compressed_size(0), uncompressed_size(0), offset(0), filename() {} + ~CentralDirectoryEntry() {} +}; + +struct CentralDirectoryEnd +{ + unsigned cdir_size; + unsigned cdir_offset; + CentralDirectoryEnd() + : cdir_size(0), cdir_offset(0) {} + ~CentralDirectoryEnd() {} +}; + +} // anonymous namespace + +namespace libvisio +{ + +struct VSDZipStreamImpl +{ + WPXInputStream *m_input; + unsigned m_cdir_offset; + std::map<std::string, CentralDirectoryEntry> m_cdir; + bool m_initialized; + VSDZipStreamImpl(WPXInputStream *input) + : m_input(input), m_cdir_offset(0), m_cdir(), m_initialized(false) {} + ~VSDZipStreamImpl() {} + + bool isZipStream(); + WPXInputStream *getSubstream(const char *name); +private: + VSDZipStreamImpl(const VSDZipStreamImpl &); + VSDZipStreamImpl &operator=(const VSDZipStreamImpl &); + + bool findCentralDirectoryEnd(); + bool readCentralDirectoryEnd(CentralDirectoryEnd &end); + bool readCentralDirectory(const CentralDirectoryEnd &end); + bool readLocalFileHeader(LocalFileHeader &header); + bool areHeadersConsistent(const LocalFileHeader &header, const CentralDirectoryEntry &entry); +}; + +} // namespace libvisio + + +using namespace libvisio; + + +libvisio::VSDZipStream::VSDZipStream(WPXInputStream *input) : + WPXInputStream(), + m_pImpl(new VSDZipStreamImpl(input)) +{ +} + +libvisio::VSDZipStream::~VSDZipStream() +{ + if (m_pImpl) + delete m_pImpl; +} + +const unsigned char *libvisio::VSDZipStream::read(unsigned long numBytes, unsigned long &numBytesRead) +{ + return m_pImpl->m_input->read(numBytes, numBytesRead); +} + +int libvisio::VSDZipStream::seek(long offset, WPX_SEEK_TYPE seekType) +{ + return m_pImpl->m_input->seek(offset, seekType); +} + +long libvisio::VSDZipStream::tell() +{ + return m_pImpl->m_input->tell(); +} + +bool libvisio::VSDZipStream::atEOS() +{ + return m_pImpl->m_input->atEOS(); +} + +bool libvisio::VSDZipStream::isOLEStream() +{ + return m_pImpl->isZipStream(); +} + +WPXInputStream *libvisio::VSDZipStream::getDocumentOLEStream(const char *name) +{ + if (!m_pImpl->isZipStream()) + return 0; + return m_pImpl->getSubstream(name); +} + +#define CDIR_ENTRY_SIG 0x02014b50 +#define LOC_FILE_HEADER_SIG 0x04034b50 +#define CDIR_END_SIG 0x06054b50 + +bool libvisio::VSDZipStreamImpl::findCentralDirectoryEnd() +{ + m_input->seek(m_cdir_offset, WPX_SEEK_SET); + try + { + while (!m_input->atEOS()) + { + unsigned signature = readU32(m_input); + if (signature == CDIR_END_SIG) + { + m_input->seek(-4, WPX_SEEK_CUR); + m_cdir_offset = m_input->tell(); + return true; + } + else + m_input->seek(-3, WPX_SEEK_CUR); + } + } + catch (...) + { + return false; + } + return false; +} + +bool libvisio::VSDZipStreamImpl::isZipStream() +{ + if (m_cdir_offset) + { + if(m_cdir.empty()) + return false; + return true; + } + if (m_initialized) + return false; + m_initialized = true; + if (!findCentralDirectoryEnd()) + return false; + CentralDirectoryEnd end; + if (!readCentralDirectoryEnd(end)) + return false; + if (!readCentralDirectory(end)) + return false; + CentralDirectoryEntry entry = m_cdir.begin()->second; + m_input->seek(entry.offset, WPX_SEEK_SET); + LocalFileHeader header; + if (!readLocalFileHeader(header)) + return false; + if (!areHeadersConsistent(header, entry)) + return false; + return true; +} + +bool libvisio::VSDZipStreamImpl::readCentralDirectory(const CentralDirectoryEnd &end) +{ + try + { + m_input->seek(end.cdir_offset, WPX_SEEK_SET); + while (!m_input->atEOS()) + { + unsigned signature = readU32(m_input); + if (signature != CDIR_ENTRY_SIG) + { + if (m_cdir.empty()) + return false; + else + return true; + } + + CentralDirectoryEntry entry; + m_input->seek(4, WPX_SEEK_CUR); + entry.general_flag = readU16(m_input); + entry.compression = readU16(m_input); + m_input->seek(4, WPX_SEEK_CUR); + entry.crc32 = readU32(m_input); + entry.compressed_size = readU32(m_input); + entry.uncompressed_size = readU32(m_input); + unsigned short filename_size = readU16(m_input); + unsigned short extra_field_size = readU16(m_input); + unsigned short file_comment_size = readU16(m_input); + m_input->seek(8, WPX_SEEK_CUR); + entry.offset = readU32(m_input); + entry.filename.clear(); + entry.filename.reserve(filename_size); + unsigned long bytesRead = 0; + const unsigned char *buffer = m_input->read(filename_size, bytesRead); + entry.filename.assign((const char *)buffer, bytesRead); + m_input->seek(extra_field_size+file_comment_size, WPX_SEEK_CUR); + + m_cdir[entry.filename] = entry; + } + } + catch (...) + { + return false; + } + return true; +} + +WPXInputStream *libvisio::VSDZipStreamImpl::getSubstream(const char *name) +{ + if (m_cdir.empty()) + return 0; + std::map<std::string, CentralDirectoryEntry>::const_iterator iter = m_cdir.lower_bound(name); + if (iter == m_cdir.end()) + return 0; + if (m_cdir.key_comp()(name, iter->first)) + { + size_t name_length = strlen(name); + if (iter->first.compare(0, name_length, name)) + return 0; + } + CentralDirectoryEntry entry = iter->second; + m_input->seek(entry.offset, WPX_SEEK_SET); + LocalFileHeader header; + if (!readLocalFileHeader(header)) + return 0; + if (!areHeadersConsistent(header, entry)) + return 0; + if (!entry.compression) + return new VSDInternalStream(m_input, entry.compressed_size); + else + { + int ret; + z_stream strm; + + /* allocate inflate state */ + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + strm.avail_in = 0; + strm.next_in = Z_NULL; + ret = inflateInit2(&strm,-MAX_WBITS); + if (ret != Z_OK) + return 0; + + unsigned long numBytesRead = 0; + const unsigned char *compressedData = m_input->read(entry.compressed_size, numBytesRead); + if (numBytesRead != entry.compressed_size) + return 0; + + strm.avail_in = numBytesRead; + strm.next_in = (Bytef *)compressedData; + + std::vector<unsigned char>data(entry.uncompressed_size); + + strm.avail_out = entry.uncompressed_size; + strm.next_out = reinterpret_cast<Bytef *>(&data[0]); + ret = inflate(&strm, Z_FINISH); + switch (ret) + { + case Z_NEED_DICT: + case Z_DATA_ERROR: + case Z_MEM_ERROR: + (void)inflateEnd(&strm); + data.clear(); + return 0; + } + (void)inflateEnd(&strm); + return new VSDInternalStream(data); + } +} + +bool libvisio::VSDZipStreamImpl::readCentralDirectoryEnd(CentralDirectoryEnd &end) +{ + try + { + unsigned signature = readU32(m_input); + if (signature != CDIR_END_SIG) + return false; + + m_input->seek(8, WPX_SEEK_CUR); + end.cdir_size = readU32(m_input); + end.cdir_offset = readU32(m_input); + unsigned short comment_size = readU16(m_input); + m_input->seek(comment_size, WPX_SEEK_CUR); + } + catch (...) + { + return false; + } + return true; +} + +bool libvisio::VSDZipStreamImpl::readLocalFileHeader(LocalFileHeader &header) +{ + try + { + unsigned signature = readU32(m_input); + if (signature != LOC_FILE_HEADER_SIG) + return false; + + m_input->seek(2, WPX_SEEK_CUR); + header.general_flag = readU16(m_input); + header.compression = readU16(m_input); + m_input->seek(4, WPX_SEEK_CUR); + header.crc32 = readU32(m_input); + header.compressed_size = readU32(m_input); + header.uncompressed_size = readU32(m_input); + unsigned short filename_size = readU16(m_input); + unsigned short extra_field_size = readU16(m_input); + header.filename.clear(); + header.filename.reserve(filename_size); + unsigned long bytesRead = 0; + const unsigned char *buffer = m_input->read(filename_size, bytesRead); + header.filename.assign((const char *)buffer, bytesRead); + m_input->seek(extra_field_size, WPX_SEEK_CUR); + } + catch (...) + { + return false; + } + return true; +} + +bool libvisio::VSDZipStreamImpl::areHeadersConsistent(const LocalFileHeader &header, const CentralDirectoryEntry &entry) +{ + if (header.general_flag != entry.general_flag) + return false; + if (header.compression != entry.compression) + return false; + if (!(header.general_flag & 0x08)) + { + if (header.crc32 != entry.crc32) + return false; + if (header.compressed_size != entry.compressed_size) + return false; + if (header.uncompressed_size != entry.uncompressed_size) + return false; + } + return true; +} + + +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDZipStream.h b/src/lib/VSDZipStream.h new file mode 100644 index 0000000..5f325bb --- /dev/null +++ b/src/lib/VSDZipStream.h @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libvisio + * Version: MPL 1.1 / GPLv2+ / LGPLv2+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch> + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPLv2+"), or + * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), + * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable + * instead of those above. + */ + + +#ifndef __VSDZIPSTREAM_H__ +#define __VSDZIPSTREAM_H__ + +#include <vector> + +#include <libwpd-stream/libwpd-stream.h> + +namespace libvisio +{ +struct VSDZipStreamImpl; + +class VSDZipStream : public WPXInputStream +{ +public: + VSDZipStream(WPXInputStream *input); + ~VSDZipStream(); + + bool isOLEStream(); + WPXInputStream *getDocumentOLEStream(const char *); + + const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead); + int seek(long offset, WPX_SEEK_TYPE seekType); + long tell(); + bool atEOS(); + +private: + VSDZipStream(const VSDZipStream &); + VSDZipStream &operator=(const VSDZipStream &); + VSDZipStreamImpl *m_pImpl; +}; + +} // namespace libvisio + +#endif +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VisioDocument.cpp b/src/lib/VisioDocument.cpp index d530075..247c699 100644 --- a/src/lib/VisioDocument.cpp +++ b/src/lib/VisioDocument.cpp @@ -33,7 +33,7 @@ #include "libvisio.h" #include "libvisio_utils.h" #include "VSDSVGGenerator.h" -#include "VSDXParser.h" +#include "VSDParser.h" #include "VSD6Parser.h" #include "VSD11Parser.h" @@ -100,7 +100,7 @@ bool libvisio::VisioDocument::parse(::WPXInputStream *input, libwpg::WPGPaintInt docStream->seek(0x1A, WPX_SEEK_SET); unsigned char version = readU8(docStream); - VSDXParser *parser; + VSDParser *parser; switch(version) { case 6: @@ -149,7 +149,7 @@ bool libvisio::VisioDocument::parseStencils(::WPXInputStream *input, libwpg::WPG docStream->seek(0x1A, WPX_SEEK_SET); unsigned char version = readU8(docStream); - VSDXParser *parser; + VSDParser *parser; switch(version) { case 6: diff --git a/src/lib/makefile.mk b/src/lib/makefile.mk index 2c42ad2..ea28bc9 100644 --- a/src/lib/makefile.mk +++ b/src/lib/makefile.mk @@ -35,19 +35,19 @@ SLOFILES= \ $(SLO)$/VSD6Parser.obj \ $(SLO)$/VSDInternalStream.obj \ $(SLO)$/VSDSVGGenerator.obj \ - $(SLO)$/VSDXCharacterList.obj \ - $(SLO)$/VSDXContentCollector.obj \ - $(SLO)$/VSDXFieldList.obj \ - $(SLO)$/VSDXGeometryList.obj \ - $(SLO)$/VSDXOutputElementList.obj \ - $(SLO)$/VSDXPages.obj \ - $(SLO)$/VSDXParagraphList.obj \ - $(SLO)$/VSDXParser.obj \ - $(SLO)$/VSDXShapeList.obj \ - $(SLO)$/VSDXStencils.obj \ + $(SLO)$/VSDCharacterList.obj \ + $(SLO)$/VSDContentCollector.obj \ + $(SLO)$/VSDFieldList.obj \ + $(SLO)$/VSDGeometryList.obj \ + $(SLO)$/VSDOutputElementList.obj \ + $(SLO)$/VSDPages.obj \ + $(SLO)$/VSDParagraphList.obj \ + $(SLO)$/VSDParser.obj \ + $(SLO)$/VSDShapeList.obj \ + $(SLO)$/VSDStencils.obj \ $(SLO)$/VSDStringVector.obj \ - $(SLO)$/VSDXStylesCollector.obj \ - $(SLO)$/VSDXStyles.obj + $(SLO)$/VSDStylesCollector.obj \ + $(SLO)$/VSDStyles.obj LIB1ARCHIV=$(LB)$/libvisiolib.a LIB1TARGET=$(SLB)$/$(TARGET).lib |