diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2014-02-04 13:39:05 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2014-02-04 13:42:27 +0100 |
commit | 964e948d1cf5359ec30863fa77983a6ebe983ca2 (patch) | |
tree | 79a8168f0f664c9af30e7809df7571fd1af65f56 /src | |
parent | e6784950aa4ce27414de5fef419bdf5a4a9c4c14 (diff) |
Some other ideas about handling the theminglibvisio-0.0
(cherry picked from commit 3e4d354f8fa163548d710fb87b5d8e18b531229c)
Conflicts:
src/lib/VSDContentCollector.cpp
src/lib/VSDStyles.cpp
Change-Id: Iec8c5f49827ee2b18ddf97d37077b2f0798a0685
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/VSDCollector.h | 5 | ||||
-rw-r--r-- | src/lib/VSDContentCollector.cpp | 23 | ||||
-rw-r--r-- | src/lib/VSDContentCollector.h | 7 | ||||
-rw-r--r-- | src/lib/VSDStencils.cpp | 13 | ||||
-rw-r--r-- | src/lib/VSDStencils.h | 1 | ||||
-rw-r--r-- | src/lib/VSDStyles.cpp | 13 | ||||
-rw-r--r-- | src/lib/VSDStyles.h | 52 | ||||
-rw-r--r-- | src/lib/VSDStylesCollector.cpp | 23 | ||||
-rw-r--r-- | src/lib/VSDStylesCollector.h | 4 |
9 files changed, 129 insertions, 12 deletions
diff --git a/src/lib/VSDCollector.h b/src/lib/VSDCollector.h index af47078..f42be89 100644 --- a/src/lib/VSDCollector.h +++ b/src/lib/VSDCollector.h @@ -60,6 +60,8 @@ public: const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency, const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern, const boost::optional<Colour> &shfgc) = 0; + virtual void collectThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour, + const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour) = 0; virtual void collectGeometry(unsigned id, unsigned level, bool noFill, bool noLine, bool noShow) = 0; virtual void collectMoveTo(unsigned id, unsigned level, double x, double y) = 0; virtual void collectLineTo(unsigned id, unsigned level, double x, double y) = 0; @@ -150,6 +152,9 @@ public: const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled, const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop, const boost::optional<unsigned char> &textDirection) = 0; + virtual void collectStyleThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour, + const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour) = 0; + // Field list virtual void collectFieldList(unsigned id, unsigned level) = 0; virtual void collectTextField(unsigned id, unsigned level, int nameId, int formatStringId) = 0; diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp index 09d6654..3fd5c26 100644 --- a/src/lib/VSDContentCollector.cpp +++ b/src/lib/VSDContentCollector.cpp @@ -96,8 +96,8 @@ libvisio::VSDContentCollector::VSDContentCollector( m_pageOutputDrawing(), m_pageOutputText(), m_documentPageShapeOrders(documentPageShapeOrders), m_pageShapeOrder(m_documentPageShapeOrders.begin()), m_isFirstGeometry(true), m_NURBSData(), m_polylineData(), m_textStream(), m_names(), m_stencilNames(), m_fields(), m_stencilFields(), m_fieldIndex(0), - m_textFormat(VSD_TEXT_ANSI), m_charFormats(), m_paraFormats(), m_lineStyle(), m_fillStyle(), - m_textBlockStyle(), m_defaultCharStyle(), m_defaultParaStyle(), m_currentStyleSheet(0), m_styles(styles), + m_textFormat(VSD_TEXT_ANSI), m_charFormats(), m_paraFormats(), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), + m_themeReference(), m_defaultCharStyle(), m_defaultParaStyle(), m_currentStyleSheet(0), m_styles(styles), m_stencils(stencils), m_stencilShape(0), m_isStencilStarted(false), m_currentGeometryCount(0), m_backgroundPageID(MINUS_ONE), m_currentPageID(0), m_currentPage(), m_pages(), m_splineControlPoints(), m_splineKnotVector(), m_splineX(0.0), m_splineY(0.0), @@ -1069,12 +1069,20 @@ void libvisio::VSDContentCollector::collectFillAndShadow(unsigned level, const b } void libvisio::VSDContentCollector::collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG, - const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency, const boost::optional<double> &fillBGTransparency, + const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency, + const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern, const boost::optional<Colour> &shfgc) { collectFillAndShadow(level, colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowPattern, shfgc, m_shadowOffsetX, m_shadowOffsetY); } +void libvisio::VSDContentCollector::collectThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour, + const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour) +{ + _handleLevelChange(level); + m_themeReference.override(VSDOptionalThemeReference(lineColour, fillColour, shadowColour, fontColour)); +} + void libvisio::VSDContentCollector::collectForeignData(unsigned level, const WPXBinaryData &binaryData) { _handleLevelChange(level); @@ -2627,6 +2635,15 @@ void libvisio::VSDContentCollector::_fillAndShadowProperties(const VSDFillStyle } } +void libvisio::VSDContentCollector::collectStyleThemeReference(unsigned /* level */, const boost::optional<long> &lineColour, + const boost::optional<long> &fillColour, const boost::optional<long> &shadowColour, + const boost::optional<long> &fontColour) +{ + VSDOptionalThemeReference themeReference(lineColour, fillColour, shadowColour, fontColour); + m_styles.addStyleThemeReference(m_currentStyleSheet, themeReference); +} + + void libvisio::VSDContentCollector::collectFieldList(unsigned /* id */, unsigned level) { _handleLevelChange(level); diff --git a/src/lib/VSDContentCollector.h b/src/lib/VSDContentCollector.h index 73db5c9..9475004 100644 --- a/src/lib/VSDContentCollector.h +++ b/src/lib/VSDContentCollector.h @@ -80,6 +80,8 @@ public: const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency, const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern, const boost::optional<Colour> &shfgc); + void collectThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour, + const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour); void collectGeometry(unsigned id, unsigned level, bool noFill, bool noLine, bool noShow); void collectMoveTo(unsigned id, unsigned level, double x, double y); void collectLineTo(unsigned id, unsigned level, double x, double y); @@ -172,6 +174,9 @@ public: const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled, const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop, const boost::optional<unsigned char> &textDirection); + void collectStyleThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour, + const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour); + // Field list void collectFieldList(unsigned id, unsigned level); @@ -288,6 +293,8 @@ private: VSDFillStyle m_fillStyle; VSDTextBlockStyle m_textBlockStyle; + VSDThemeReference m_themeReference; + VSDCharStyle m_defaultCharStyle; VSDParaStyle m_defaultParaStyle; diff --git a/src/lib/VSDStencils.cpp b/src/lib/VSDStencils.cpp index e963f72..7fce21d 100644 --- a/src/lib/VSDStencils.cpp +++ b/src/lib/VSDStencils.cpp @@ -34,9 +34,10 @@ libvisio::VSDShape::VSDShape() : m_geometries(), m_shapeList(), m_fields(), m_foreign(0), m_parent(0), m_masterPage(MINUS_ONE), m_masterShape(MINUS_ONE), m_shapeId(MINUS_ONE), m_lineStyleId(MINUS_ONE), m_fillStyleId(MINUS_ONE), - m_textStyleId(MINUS_ONE), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_charStyle(), m_charList(), - m_paraStyle(), m_paraList(), m_text(), m_names(), m_textFormat(libvisio::VSD_TEXT_UTF16), - m_nurbsData(), m_polylineData(), m_xform(), m_txtxform(0), m_misc() + m_textStyleId(MINUS_ONE), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_charStyle(), + m_themeRef(), m_charList(), m_paraStyle(), m_paraList(), m_text(), m_names(), + m_textFormat(libvisio::VSD_TEXT_UTF16), m_nurbsData(), m_polylineData(), m_xform(), m_txtxform(0), + m_misc() { } @@ -46,8 +47,8 @@ libvisio::VSDShape::VSDShape(const libvisio::VSDShape &shape) m_masterPage(shape.m_masterPage), m_masterShape(shape.m_masterShape), m_shapeId(shape.m_shapeId), m_lineStyleId(shape.m_lineStyleId), m_fillStyleId(shape.m_fillStyleId), m_textStyleId(shape.m_textStyleId), m_lineStyle(shape.m_lineStyle), m_fillStyle(shape.m_fillStyle), m_textBlockStyle(shape.m_textBlockStyle), - m_charStyle(shape.m_charStyle), m_charList(shape.m_charList), m_paraStyle(shape.m_paraStyle), - m_paraList(shape.m_paraList), m_text(shape.m_text), m_names(shape.m_names), + m_charStyle(shape.m_charStyle), m_themeRef(shape.m_themeRef), m_charList(shape.m_charList), + m_paraStyle(shape.m_paraStyle), m_paraList(shape.m_paraList), m_text(shape.m_text), m_names(shape.m_names), m_textFormat(shape.m_textFormat), m_nurbsData(shape.m_nurbsData), m_polylineData(shape.m_polylineData), m_xform(shape.m_xform), m_txtxform(shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : 0), m_misc(shape.m_misc) { @@ -79,6 +80,7 @@ libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shap m_fillStyle = shape.m_fillStyle; m_textBlockStyle = shape.m_textBlockStyle; m_charStyle = shape.m_charStyle; + m_themeRef = shape.m_themeRef; m_charList = shape.m_charList; m_paraStyle = shape.m_paraStyle; m_paraList = shape.m_paraList; @@ -112,6 +114,7 @@ void libvisio::VSDShape::clear() m_fillStyle = VSDOptionalFillStyle(); m_textBlockStyle = VSDOptionalTextBlockStyle(); m_charStyle = VSDOptionalCharStyle(); + m_themeRef = VSDOptionalThemeReference(); m_charList.clear(); m_paraStyle = VSDOptionalParaStyle(); m_paraList.clear(); diff --git a/src/lib/VSDStencils.h b/src/lib/VSDStencils.h index b888584..c610ce9 100644 --- a/src/lib/VSDStencils.h +++ b/src/lib/VSDStencils.h @@ -63,6 +63,7 @@ public: VSDOptionalFillStyle m_fillStyle; VSDOptionalTextBlockStyle m_textBlockStyle; VSDOptionalCharStyle m_charStyle; + VSDOptionalThemeReference m_themeRef; VSDCharacterList m_charList; VSDOptionalParaStyle m_paraStyle; VSDParagraphList m_paraList; diff --git a/src/lib/VSDStyles.cpp b/src/lib/VSDStyles.cpp index e820c0e..bcacbec 100644 --- a/src/lib/VSDStyles.cpp +++ b/src/lib/VSDStyles.cpp @@ -91,6 +91,11 @@ void libvisio::VSDStyles::addParaStyle(unsigned textStyleIndex, const VSDOptiona m_paraStyles[textStyleIndex] = paraStyle; } +void libvisio::VSDStyles::addStyleThemeReference(unsigned styleIndex, const VSDOptionalThemeReference &themeRef) +{ + m_themeRefs[styleIndex] = themeRef; +} + void libvisio::VSDStyles::addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster) { m_lineStyleMasters[lineStyleIndex] = lineStyleMaster; @@ -266,4 +271,12 @@ libvisio::VSDParaStyle libvisio::VSDStyles::getParaStyle(unsigned textStyleIndex return paraStyle; } +libvisio::VSDOptionalThemeReference libvisio::VSDStyles::getOptionalThemeReference(unsigned styleIndex) const +{ + VSDOptionalThemeReference themeReference; + if (MINUS_ONE == styleIndex) + return themeReference; + return themeReference; +} + /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDStyles.h b/src/lib/VSDStyles.h index 1b70303..14321b0 100644 --- a/src/lib/VSDStyles.h +++ b/src/lib/VSDStyles.h @@ -40,6 +40,55 @@ namespace libvisio { +struct VSDOptionalThemeReference +{ + VSDOptionalThemeReference() : + qsLineColour(), qsFillColour(), qsShadowColour(), qsFontColour() {} + VSDOptionalThemeReference(const boost::optional<long> &lineColour, const boost::optional<long> &fillColour, + const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour) : + qsLineColour(lineColour), qsFillColour(fillColour), qsShadowColour(shadowColour), qsFontColour(fontColour) {} + VSDOptionalThemeReference(const VSDOptionalThemeReference &themeRef) : + qsLineColour(themeRef.qsLineColour), qsFillColour(themeRef.qsFillColour), + qsShadowColour(themeRef.qsShadowColour), qsFontColour(themeRef.qsFontColour) {} + ~VSDOptionalThemeReference() {} + void override(const VSDOptionalThemeReference &themeRef) + { + ASSIGN_OPTIONAL(themeRef.qsLineColour, qsLineColour); + ASSIGN_OPTIONAL(themeRef.qsFillColour, qsFillColour); + ASSIGN_OPTIONAL(themeRef.qsShadowColour, qsShadowColour); + ASSIGN_OPTIONAL(themeRef.qsFontColour, qsFontColour); + } + + boost::optional<long> qsLineColour; + boost::optional<long> qsFillColour; + boost::optional<long> qsShadowColour; + boost::optional<long> qsFontColour; +}; + +struct VSDThemeReference +{ + VSDThemeReference() : + qsLineColour(-1), qsFillColour(-1), qsShadowColour(-1), qsFontColour(-1) {} + VSDThemeReference(long lineColour, long fillColour, long shadowColour, long fontColour) : + qsLineColour(lineColour), qsFillColour(fillColour), qsShadowColour(shadowColour), qsFontColour(fontColour) {} + VSDThemeReference(const VSDThemeReference &themeRef) : + qsLineColour(themeRef.qsLineColour), qsFillColour(themeRef.qsFillColour), + qsShadowColour(themeRef.qsShadowColour), qsFontColour(themeRef.qsFontColour) {} + ~VSDThemeReference() {} + void override(const VSDOptionalThemeReference &themeRef) + { + ASSIGN_OPTIONAL(themeRef.qsLineColour, qsLineColour); + ASSIGN_OPTIONAL(themeRef.qsFillColour, qsFillColour); + ASSIGN_OPTIONAL(themeRef.qsShadowColour, qsShadowColour); + ASSIGN_OPTIONAL(themeRef.qsFontColour, qsFontColour); + } + + long qsLineColour; + long qsFillColour; + long qsShadowColour; + long qsFontColour; +}; + struct VSDOptionalLineStyle { VSDOptionalLineStyle() : @@ -445,6 +494,7 @@ public: void addTextBlockStyle(unsigned textStyleIndex, const VSDOptionalTextBlockStyle &textBlockStyle); void addCharStyle(unsigned textStyleIndex, const VSDOptionalCharStyle &charStyle); void addParaStyle(unsigned textStyleIndex, const VSDOptionalParaStyle ¶Style); + void addStyleThemeReference(unsigned styleIndex, const VSDOptionalThemeReference &themeRef); void addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster); void addFillStyleMaster(unsigned fillStyleIndex, unsigned fillStyleMaster); @@ -460,6 +510,7 @@ public: VSDOptionalCharStyle getOptionalCharStyle(unsigned textStyleIndex) const; VSDParaStyle getParaStyle(unsigned textStyleIndex) const; VSDOptionalParaStyle getOptionalParaStyle(unsigned textStyleIndex) const; + VSDOptionalThemeReference getOptionalThemeReference(unsigned styleIndex) const; private: std::map<unsigned, VSDOptionalLineStyle> m_lineStyles; @@ -467,6 +518,7 @@ private: std::map<unsigned, VSDOptionalTextBlockStyle> m_textBlockStyles; std::map<unsigned, VSDOptionalCharStyle> m_charStyles; std::map<unsigned, VSDOptionalParaStyle> m_paraStyles; + std::map<unsigned, VSDOptionalThemeReference> m_themeRefs; std::map<unsigned, unsigned> m_lineStyleMasters; std::map<unsigned, unsigned> m_fillStyleMasters; std::map<unsigned, unsigned> m_textStyleMasters; diff --git a/src/lib/VSDStylesCollector.cpp b/src/lib/VSDStylesCollector.cpp index 7d4195e..abab363 100644 --- a/src/lib/VSDStylesCollector.cpp +++ b/src/lib/VSDStylesCollector.cpp @@ -96,6 +96,12 @@ void libvisio::VSDStylesCollector::collectFillAndShadow(unsigned level, const bo _handleLevelChange(level); } +void libvisio::VSDStylesCollector::collectThemeReference(unsigned level, const boost::optional<long> & /* lineColour */, const boost::optional<long> & /* fillColour */, + const boost::optional<long> & /* shadowColour */, const boost::optional<long> & /* fontColour */) +{ + _handleLevelChange(level); +} + void libvisio::VSDStylesCollector::collectGeometry(unsigned /* id */, unsigned level, bool /* noFill */, bool /* noLine */, bool /* noShow */) { _handleLevelChange(level); @@ -364,21 +370,30 @@ void libvisio::VSDStylesCollector::collectCharIXStyle(unsigned /* id */, unsigne } void libvisio::VSDStylesCollector::collectParaIXStyle(unsigned /* id */, unsigned level, unsigned /* charCount */, const boost::optional<double> & /* indFirst */, - const boost::optional<double> & /* indLeft */, const boost::optional<double> & /* indRight */, const boost::optional<double> & /* spLine */, const boost::optional<double> & /* spBefore */, - const boost::optional<double> & /* spAfter */, const boost::optional<unsigned char> & /* align */, const boost::optional<unsigned> & /* flags */) + const boost::optional<double> & /* indLeft */, const boost::optional<double> & /* indRight */, + const boost::optional<double> & /* spLine */, const boost::optional<double> & /* spBefore */, + const boost::optional<double> & /* spAfter */, const boost::optional<unsigned char> & /* align */, + const boost::optional<unsigned> & /* flags */) { _handleLevelChange(level); } void libvisio::VSDStylesCollector::collectTextBlockStyle(unsigned level, const boost::optional<double> & /* leftMargin */, const boost::optional<double> & /* rightMargin */, - const boost::optional<double> & /* topMargin */, const boost::optional<double> & /* bottomMargin */, const boost::optional<unsigned char> & /* verticalAlign */, - const boost::optional<bool> & /* isBgFilled */, const boost::optional<Colour> & /* bgColour */, const boost::optional<double> & /* defaultTabStop */, + const boost::optional<double> & /* topMargin */, const boost::optional<double> & /* bottomMargin */, + const boost::optional<unsigned char> & /* verticalAlign */, const boost::optional<bool> & /* isBgFilled */, + const boost::optional<Colour> & /* bgColour */, const boost::optional<double> & /* defaultTabStop */, const boost::optional<unsigned char> & /* textDirection */) { _handleLevelChange(level); } +void libvisio::VSDStylesCollector::collectStyleThemeReference(unsigned level, const boost::optional<long> & /* lineColour */, const boost::optional<long> & /* fillColour */, + const boost::optional<long> & /* shadowColour */, const boost::optional<long> & /* fontColour */) +{ + _handleLevelChange(level); +} + void libvisio::VSDStylesCollector::collectFieldList(unsigned /* id */, unsigned level) { _handleLevelChange(level); diff --git a/src/lib/VSDStylesCollector.h b/src/lib/VSDStylesCollector.h index 579df10..c6aa830 100644 --- a/src/lib/VSDStylesCollector.h +++ b/src/lib/VSDStylesCollector.h @@ -71,6 +71,8 @@ public: const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency, const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern, const boost::optional<Colour> &shfgc); + void collectThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour, + const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour); void collectGeometry(unsigned id, unsigned level, bool noFill, bool noLine, bool noShow); void collectMoveTo(unsigned id, unsigned level, double x, double y); void collectLineTo(unsigned id, unsigned level, double x, double y); @@ -163,6 +165,8 @@ public: const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled, const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop, const boost::optional<unsigned char> &textDirection); + void collectStyleThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour, + const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour); // Field list void collectFieldList(unsigned id, unsigned level); |