src/lib/VSDContentCollector.cpp | 2 src/lib/VSDContentCollector.h | 2 src/lib/VSDXTheme.cpp | 179 +++++++++++++++++++++++++++++++++++++++- src/lib/VSDXTheme.h | 10 ++ 4 files changed, 186 insertions(+), 7 deletions(-)
New commits: commit 746fdbc6e6a6f41238dd19f8e20ed48192e86aad Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Mon Jul 22 22:17:35 2013 +0200 Some more parsing of theme information diff --git a/src/lib/VSDXTheme.cpp b/src/lib/VSDXTheme.cpp index a0388f0..97be35d 100644 --- a/src/lib/VSDXTheme.cpp +++ b/src/lib/VSDXTheme.cpp @@ -39,6 +39,12 @@ libvisio::VSDXTheme::~VSDXTheme() { } + +int libvisio::VSDXTheme::getElementToken(xmlTextReaderPtr reader) +{ + return VSDXMLTokenMap::getTokenId(xmlTextReaderConstName(reader)); +} + bool libvisio::VSDXTheme::parse(WPXInputStream *input) { if (!input) @@ -53,8 +59,7 @@ bool libvisio::VSDXTheme::parse(WPXInputStream *input) int ret = xmlTextReaderRead(reader); while (1 == ret) { - int tokenId = VSDXMLTokenMap::getTokenId(xmlTextReaderConstName(reader)); - int tokenType = xmlTextReaderNodeType(reader); + int tokenId = getElementToken(reader); switch (tokenId) { @@ -79,7 +84,7 @@ bool libvisio::VSDXTheme::parse(WPXInputStream *input) boost::optional<libvisio::Colour> libvisio::VSDXTheme::readSrgbClr(xmlTextReaderPtr reader) { boost::optional<libvisio::Colour> retVal; - if (XML_A_SRGBCLR == VSDXMLTokenMap::getTokenId(xmlTextReaderConstName(reader))) + if (XML_A_SRGBCLR == getElementToken(reader)) { xmlChar *val = xmlTextReaderGetAttribute(reader, BAD_CAST("val")); if (val) @@ -100,7 +105,7 @@ boost::optional<libvisio::Colour> libvisio::VSDXTheme::readSrgbClr(xmlTextReader boost::optional<libvisio::Colour> libvisio::VSDXTheme::readSysClr(xmlTextReaderPtr reader) { boost::optional<libvisio::Colour> retVal; - if (XML_A_SYSCLR == VSDXMLTokenMap::getTokenId(xmlTextReaderConstName(reader))) + if (XML_A_SYSCLR == getElementToken(reader)) { xmlChar *lastClr = xmlTextReaderGetAttribute(reader, BAD_CAST("lastClr")); if (lastClr) @@ -120,6 +125,172 @@ boost::optional<libvisio::Colour> libvisio::VSDXTheme::readSysClr(xmlTextReaderP void libvisio::VSDXTheme::readClrScheme(xmlTextReaderPtr reader) { + int ret = 1; + int tokenId = XML_TOKEN_INVALID; + int tokenType = -1; + m_clrScheme.m_variationClrSchemeLst.clear(); + do + { + ret = xmlTextReaderRead(reader); + tokenId = getElementToken(reader); + if (XML_TOKEN_INVALID == tokenId) + { + VSD_DEBUG_MSG(("VSDXTheme::readClrScheme: unknown token %s\n", xmlTextReaderConstName(reader))); + } + tokenType = xmlTextReaderNodeType(reader); + switch (tokenId) + { + case XML_A_SRGBCLR: + readThemeColour(reader, tokenId, m_clrScheme.m_dk1); + break; + case XML_A_DK2: + readThemeColour(reader, tokenId, m_clrScheme.m_dk2); + break; + case XML_A_LT1: + readThemeColour(reader, tokenId, m_clrScheme.m_lt1); + break; + case XML_A_LT2: + readThemeColour(reader, tokenId, m_clrScheme.m_lt2); + break; + case XML_A_ACCENT1: + readThemeColour(reader, tokenId, m_clrScheme.m_accent1); + break; + case XML_A_ACCENT2: + readThemeColour(reader, tokenId, m_clrScheme.m_accent2); + break; + case XML_A_ACCENT3: + readThemeColour(reader, tokenId, m_clrScheme.m_accent3); + break; + case XML_A_ACCENT4: + readThemeColour(reader, tokenId, m_clrScheme.m_accent4); + break; + case XML_A_ACCENT5: + readThemeColour(reader, tokenId, m_clrScheme.m_accent5); + break; + case XML_A_ACCENT6: + readThemeColour(reader, tokenId, m_clrScheme.m_accent6); + break; + case XML_A_HLINK: + readThemeColour(reader, tokenId, m_clrScheme.m_hlink); + break; + case XML_A_FOLHLINK: + readThemeColour(reader, tokenId, m_clrScheme.m_folHlink); + break; + case XML_VT_VARIATIONCLRSCHEMELST: + readVariationClrSchemeLst(reader); + break; + default: + break; + } + } + while ((XML_A_CLRSCHEME != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret); +} + +void libvisio::VSDXTheme::readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr) +{ + int ret = 1; + int tokenId = XML_TOKEN_INVALID; + int tokenType = -1; + boost::optional<libvisio::Colour> colour; + do + { + ret = xmlTextReaderRead(reader); + tokenId = getElementToken(reader); + if (XML_TOKEN_INVALID == tokenId) + { + VSD_DEBUG_MSG(("VSDXTheme::readThemeColour: unknown token %s\n", xmlTextReaderConstName(reader))); + } + tokenType = xmlTextReaderNodeType(reader); + switch (tokenId) + { + case XML_A_SRGBCLR: + colour = readSrgbClr(reader); + break; + case XML_A_SYSCLR: + colour = readSysClr(reader); + break; + default: + break; + } + } + while ((idToken != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret); + + if (colour) + clr = *colour; +} + +void libvisio::VSDXTheme::readVariationClrSchemeLst(xmlTextReaderPtr reader) +{ + int ret = 1; + int tokenId = XML_TOKEN_INVALID; + int tokenType = -1; + do + { + ret = xmlTextReaderRead(reader); + tokenId = getElementToken(reader); + if (XML_TOKEN_INVALID == tokenId) + { + VSD_DEBUG_MSG(("VSDXTheme::readVariationClrSchemeLst: unknown token %s\n", xmlTextReaderConstName(reader))); + } + tokenType = xmlTextReaderNodeType(reader); + switch (tokenId) + { + case XML_VT_VARIATIONSTYLESCHEME: + { + VSDXVariationClrScheme varClrSch; + readVariationClrScheme(reader, varClrSch); + m_clrScheme.m_variationClrSchemeLst.push_back(varClrSch); + break; + } + default: + break; + } + } + while ((XML_VT_VARIATIONSTYLESCHEMELST != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret); +} + +void libvisio::VSDXTheme::readVariationClrScheme(xmlTextReaderPtr reader, VSDXVariationClrScheme &varClrSch) +{ + int ret = 1; + int tokenId = XML_TOKEN_INVALID; + int tokenType = -1; + do + { + ret = xmlTextReaderRead(reader); + tokenId = getElementToken(reader); + if (XML_TOKEN_INVALID == tokenId) + { + VSD_DEBUG_MSG(("VSDXTheme::readVariationClrScheme: unknown token %s\n", xmlTextReaderConstName(reader))); + } + tokenType = xmlTextReaderNodeType(reader); + switch (tokenId) + { + case XML_VT_VARCOLOR1: + readThemeColour(reader, tokenId, varClrSch.m_varColor1); + break; + case XML_VT_VARCOLOR2: + readThemeColour(reader, tokenId, varClrSch.m_varColor2); + break; + case XML_VT_VARCOLOR3: + readThemeColour(reader, tokenId, varClrSch.m_varColor3); + break; + case XML_VT_VARCOLOR4: + readThemeColour(reader, tokenId, varClrSch.m_varColor4); + break; + case XML_VT_VARCOLOR5: + readThemeColour(reader, tokenId, varClrSch.m_varColor5); + break; + case XML_VT_VARCOLOR6: + readThemeColour(reader, tokenId, varClrSch.m_varColor6); + break; + case XML_VT_VARCOLOR7: + readThemeColour(reader, tokenId, varClrSch.m_varColor7); + break; + default: + break; + } + } + while ((XML_VT_VARIATIONSTYLESCHEME != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret); } /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXTheme.h b/src/lib/VSDXTheme.h index 2e1101f..bb8b7e9 100644 --- a/src/lib/VSDXTheme.h +++ b/src/lib/VSDXTheme.h @@ -30,6 +30,7 @@ #ifndef __VSDXTHEME_H__ #define __VSDXTHEME_H__ +#include <vector> #include <boost/optional.hpp> #include <libwpd-stream/libwpd-stream.h> #include "VSDXMLHelper.h" @@ -64,7 +65,7 @@ struct VSDXClrScheme Colour m_accent6; Colour m_hlink; Colour m_folHlink; - std::vector<VSDXVariationClrScheme> variationClrSchemeLst; + std::vector<VSDXVariationClrScheme> m_variationClrSchemeLst; }; class VSDXTheme @@ -82,6 +83,13 @@ private: boost::optional<Colour> readSysClr(xmlTextReaderPtr reader); void readClrScheme(xmlTextReaderPtr reader); + void readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr); + void readVariationClrSchemeLst(xmlTextReaderPtr reader); + void readVariationClrScheme(xmlTextReaderPtr reader, VSDXVariationClrScheme &varClrSch); + + int getElementToken(xmlTextReaderPtr reader); + + VSDXClrScheme m_clrScheme; }; } // namespace libvisio commit 7d74f52e9d7212639427f0c69130e6c4a231a461 Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Mon Jul 22 22:16:15 2013 +0200 Cppcheck: (performance) Function parameter 'weights' should be passed by reference diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp index da345bf..6063fe2 100644 --- a/src/lib/VSDContentCollector.cpp +++ b/src/lib/VSDContentCollector.cpp @@ -1521,7 +1521,7 @@ void libvisio::VSDContentCollector::_generatePolylineFromNURBS(unsigned degree, } } -bool libvisio::VSDContentCollector::_isUniform(const std::vector<double> weights) const +bool libvisio::VSDContentCollector::_isUniform(const std::vector<double> &weights) const { if (weights.empty()) return true; diff --git a/src/lib/VSDContentCollector.h b/src/lib/VSDContentCollector.h index b34e9d1..4889770 100644 --- a/src/lib/VSDContentCollector.h +++ b/src/lib/VSDContentCollector.h @@ -221,7 +221,7 @@ private: void _appendField(WPXString &text); // NURBS processing functions - bool _isUniform(const std::vector<double> weights) const; + bool _isUniform(const std::vector<double> &weights) const; void _generatePolylineFromNURBS(unsigned degree, const std::vector<std::pair<double, double> > &controlPoints, const std::vector<double> &knotVector, const std::vector<double> &weights); void _generateBezierSegmentsFromNURBS(unsigned degree, const std::vector<std::pair<double, double> > &controlPoints,
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits