From 964e948d1cf5359ec30863fa77983a6ebe983ca2 Mon Sep 17 00:00:00 2001 From: Fridrich Štrba Date: Tue, 4 Feb 2014 13:39:05 +0100 Subject: Some other ideas about handling the theming (cherry picked from commit 3e4d354f8fa163548d710fb87b5d8e18b531229c) Conflicts: src/lib/VSDContentCollector.cpp src/lib/VSDStyles.cpp Change-Id: Iec8c5f49827ee2b18ddf97d37077b2f0798a0685 --- src/lib/VSDCollector.h | 5 ++++ src/lib/VSDContentCollector.cpp | 23 +++++++++++++++--- src/lib/VSDContentCollector.h | 7 ++++++ src/lib/VSDStencils.cpp | 13 +++++++---- src/lib/VSDStencils.h | 1 + src/lib/VSDStyles.cpp | 13 +++++++++++ src/lib/VSDStyles.h | 52 +++++++++++++++++++++++++++++++++++++++++ src/lib/VSDStylesCollector.cpp | 23 ++++++++++++++---- 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 &fillPattern, const boost::optional &fillFGTransparency, const boost::optional &fillBGTransparency, const boost::optional &shadowPattern, const boost::optional &shfgc) = 0; + virtual void collectThemeReference(unsigned level, const boost::optional &lineColour, const boost::optional &fillColour, + const boost::optional &shadowColour, const boost::optional &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 &verticalAlign, const boost::optional &isBgFilled, const boost::optional &bgColour, const boost::optional &defaultTabStop, const boost::optional &textDirection) = 0; + virtual void collectStyleThemeReference(unsigned level, const boost::optional &lineColour, const boost::optional &fillColour, + const boost::optional &shadowColour, const boost::optional &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 &colourFG, const boost::optional &colourBG, - const boost::optional &fillPattern, const boost::optional &fillFGTransparency, const boost::optional &fillBGTransparency, + const boost::optional &fillPattern, const boost::optional &fillFGTransparency, + const boost::optional &fillBGTransparency, const boost::optional &shadowPattern, const boost::optional &shfgc) { collectFillAndShadow(level, colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowPattern, shfgc, m_shadowOffsetX, m_shadowOffsetY); } +void libvisio::VSDContentCollector::collectThemeReference(unsigned level, const boost::optional &lineColour, const boost::optional &fillColour, + const boost::optional &shadowColour, const boost::optional &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 &lineColour, + const boost::optional &fillColour, const boost::optional &shadowColour, + const boost::optional &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 &fillPattern, const boost::optional &fillFGTransparency, const boost::optional &fillBGTransparency, const boost::optional &shadowPattern, const boost::optional &shfgc); + void collectThemeReference(unsigned level, const boost::optional &lineColour, const boost::optional &fillColour, + const boost::optional &shadowColour, const boost::optional &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 &verticalAlign, const boost::optional &isBgFilled, const boost::optional &bgColour, const boost::optional &defaultTabStop, const boost::optional &textDirection); + void collectStyleThemeReference(unsigned level, const boost::optional &lineColour, const boost::optional &fillColour, + const boost::optional &shadowColour, const boost::optional &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 &lineColour, const boost::optional &fillColour, + const boost::optional &shadowColour, const boost::optional &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 qsLineColour; + boost::optional qsFillColour; + boost::optional qsShadowColour; + boost::optional 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 m_lineStyles; @@ -467,6 +518,7 @@ private: std::map m_textBlockStyles; std::map m_charStyles; std::map m_paraStyles; + std::map m_themeRefs; std::map m_lineStyleMasters; std::map m_fillStyleMasters; std::map 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 & /* lineColour */, const boost::optional & /* fillColour */, + const boost::optional & /* shadowColour */, const boost::optional & /* 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 & /* indFirst */, - const boost::optional & /* indLeft */, const boost::optional & /* indRight */, const boost::optional & /* spLine */, const boost::optional & /* spBefore */, - const boost::optional & /* spAfter */, const boost::optional & /* align */, const boost::optional & /* flags */) + const boost::optional & /* indLeft */, const boost::optional & /* indRight */, + const boost::optional & /* spLine */, const boost::optional & /* spBefore */, + const boost::optional & /* spAfter */, const boost::optional & /* align */, + const boost::optional & /* flags */) { _handleLevelChange(level); } void libvisio::VSDStylesCollector::collectTextBlockStyle(unsigned level, const boost::optional & /* leftMargin */, const boost::optional & /* rightMargin */, - const boost::optional & /* topMargin */, const boost::optional & /* bottomMargin */, const boost::optional & /* verticalAlign */, - const boost::optional & /* isBgFilled */, const boost::optional & /* bgColour */, const boost::optional & /* defaultTabStop */, + const boost::optional & /* topMargin */, const boost::optional & /* bottomMargin */, + const boost::optional & /* verticalAlign */, const boost::optional & /* isBgFilled */, + const boost::optional & /* bgColour */, const boost::optional & /* defaultTabStop */, const boost::optional & /* textDirection */) { _handleLevelChange(level); } +void libvisio::VSDStylesCollector::collectStyleThemeReference(unsigned level, const boost::optional & /* lineColour */, const boost::optional & /* fillColour */, + const boost::optional & /* shadowColour */, const boost::optional & /* 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 &fillPattern, const boost::optional &fillFGTransparency, const boost::optional &fillBGTransparency, const boost::optional &shadowPattern, const boost::optional &shfgc); + void collectThemeReference(unsigned level, const boost::optional &lineColour, const boost::optional &fillColour, + const boost::optional &shadowColour, const boost::optional &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 &verticalAlign, const boost::optional &isBgFilled, const boost::optional &bgColour, const boost::optional &defaultTabStop, const boost::optional &textDirection); + void collectStyleThemeReference(unsigned level, const boost::optional &lineColour, const boost::optional &fillColour, + const boost::optional &shadowColour, const boost::optional &fontColour); // Field list void collectFieldList(unsigned id, unsigned level); -- cgit v1.2.3