1 --- src/lib/VSDStyles.h
2 +++ src/lib/VSDStyles.h
3 @@ -179,14 +177,13 @@ struct VSDFillStyle
4 ASSIGN_OPTIONAL(style.qsFillMatrix, qsFillMatrix);
7 - if (!!style.qsFillColour && style.qsFillColour.get() >= 0)
8 - ASSIGN_OPTIONAL(theme->getThemeColour(style.qsFillColour.get()), fgColour);
10 - if (!!style.qsFillColour && style.qsFillColour.get() >= 0)
11 - ASSIGN_OPTIONAL(theme->getThemeColour(style.qsFillColour.get()), bgColour);
13 - if (!!style.qsShadowColour && style.qsShadowColour.get() >= 0)
14 - ASSIGN_OPTIONAL(theme->getThemeColour(style.qsShadowColour.get()), shadowFgColour);
15 + // Quick Style Colour 100 is special. It is the default,
16 + // and it is not saved explicitely in the VSDX file.
17 + ASSIGN_OPTIONAL(theme->getThemeColour(style.qsFillColour.value_or(100)), fgColour);
18 + ASSIGN_OPTIONAL(theme->getThemeColour(style.qsFillColour.value_or(100)), bgColour);
19 + ASSIGN_OPTIONAL(theme->getThemeColour(style.qsShadowColour.value_or(100)), shadowFgColour);
20 + if (!!style.qsFillMatrix && style.qsFillMatrix.get() >= 0)
21 + ASSIGN_OPTIONAL(theme->getFillStyleColour(style.qsFillMatrix.get()), fgColour);
23 ASSIGN_OPTIONAL(style.fgColour, fgColour);
24 ASSIGN_OPTIONAL(style.bgColour, bgColour);
25 --- src/lib/VSDXTheme.cpp
26 +++ src/lib/VSDXTheme.cpp
27 @@ -63,7 +63,8 @@ libvisio::VSDXFontScheme::VSDXFontScheme()
29 libvisio::VSDXTheme::VSDXTheme()
33 + m_fillStyleLst(std::vector<boost::optional<libvisio::Colour>>(6))
37 @@ -102,6 +103,9 @@ bool libvisio::VSDXTheme::parse(librevenge::RVNGInputStream *input)
38 case XML_A_FONTSCHEME:
39 readFontScheme(reader.get());
41 + case XML_A_FMTSCHEME:
42 + readFmtScheme(reader.get());
47 @@ -320,7 +324,7 @@ void libvisio::VSDXTheme::readClrScheme(xmlTextReaderPtr reader)
48 while ((XML_A_CLRSCHEME != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
51 -void libvisio::VSDXTheme::readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr)
52 +bool libvisio::VSDXTheme::readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr)
55 int tokenId = XML_TOKEN_INVALID;
56 @@ -350,7 +354,11 @@ void libvisio::VSDXTheme::readThemeColour(xmlTextReaderPtr reader, int idToken,
57 while ((idToken != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
67 void libvisio::VSDXTheme::readVariationClrSchemeLst(xmlTextReaderPtr reader)
68 @@ -491,4 +499,96 @@ boost::optional<libvisio::Colour> libvisio::VSDXTheme::getThemeColour(unsigned v
69 return boost::optional<libvisio::Colour>();
72 +void libvisio::VSDXTheme::readFmtScheme(xmlTextReaderPtr reader)
74 + VSD_DEBUG_MSG(("VSDXTheme::readFmtScheme\n"));
76 + int tokenId = XML_TOKEN_INVALID;
80 + ret = xmlTextReaderRead(reader);
81 + tokenId = getElementToken(reader);
82 + if (XML_TOKEN_INVALID == tokenId)
84 + VSD_DEBUG_MSG(("VSDXTheme::readFmtScheme: unknown token %s\n", xmlTextReaderConstName(reader)));
86 + tokenType = xmlTextReaderNodeType(reader);
89 + case XML_A_FILLSTYLELST:
91 + readFillStyleLst(reader);
95 + // Other style lists not implemented
98 + } while ((XML_A_FMTSCHEME != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
101 +void libvisio::VSDXTheme::skipUnimplemented(xmlTextReaderPtr reader, int idToken)
104 + int tokenId = XML_TOKEN_INVALID;
105 + int tokenType = -1;
108 + ret = xmlTextReaderRead(reader);
109 + tokenId = getElementToken(reader);
110 + if (XML_TOKEN_INVALID == tokenId)
112 + VSD_DEBUG_MSG(("VSDXTheme::skipUnimplemented: unknown token %s\n", xmlTextReaderConstName(reader)));
114 + tokenType = xmlTextReaderNodeType(reader);
115 + } while ((idToken != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
118 +void libvisio::VSDXTheme::readFillStyleLst(xmlTextReaderPtr reader)
120 + VSD_DEBUG_MSG(("VSDXTheme::readFillStyleLst\n"));
121 + int ret = xmlTextReaderRead(reader);
122 + int tokenId = getElementToken(reader);
123 + if (XML_TOKEN_INVALID == tokenId)
125 + VSD_DEBUG_MSG(("VSDXTheme::readFillStyleLst: unknown token %s\n", xmlTextReaderConstName(reader)));
127 + int tokenType = xmlTextReaderNodeType(reader);
129 + while ((XML_A_FILLSTYLELST != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret)
133 + case XML_A_SOLIDFILL:
136 + if (readThemeColour(reader, tokenId, colour))
138 + m_fillStyleLst[i] = colour;
143 + // Skip unimplemented fill type
144 + skipUnimplemented(reader, tokenId);
147 + ret = xmlTextReaderRead(reader);
148 + tokenId = getElementToken(reader);
149 + if (XML_TOKEN_INVALID == tokenId)
151 + VSD_DEBUG_MSG(("VSDXTheme::readFillStyleLst: unknown token %s\n", xmlTextReaderConstName(reader)));
153 + tokenType = xmlTextReaderNodeType(reader);
157 +boost::optional<libvisio::Colour> libvisio::VSDXTheme::getFillStyleColour(unsigned value) const
159 + if (value == 0 || value > m_fillStyleLst.size())
160 + return boost::optional<libvisio::Colour>();
161 + return m_fillStyleLst[value - 1];
164 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
165 --- src/lib/VSDXTheme.h
166 +++ src/lib/VSDXTheme.h
167 @@ -80,6 +80,7 @@ public:
169 bool parse(librevenge::RVNGInputStream *input);
170 boost::optional<Colour> getThemeColour(unsigned value, unsigned variationIndex = 0) const;
171 + boost::optional<Colour> getFillStyleColour(unsigned value) const;
174 VSDXTheme(const VSDXTheme &);
175 @@ -89,18 +90,22 @@ private:
176 boost::optional<Colour> readSysClr(xmlTextReaderPtr reader);
178 void readClrScheme(xmlTextReaderPtr reader);
179 - void readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr);
180 + bool readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr);
181 void readVariationClrSchemeLst(xmlTextReaderPtr reader);
182 void readVariationClrScheme(xmlTextReaderPtr reader, VSDXVariationClrScheme &varClrSch);
183 void readFontScheme(xmlTextReaderPtr reader);
184 void readFont(xmlTextReaderPtr reader, int idToken, VSDXFont &font);
185 bool readTypeFace(xmlTextReaderPtr reader, librevenge::RVNGString &typeFace);
186 bool readTypeFace(xmlTextReaderPtr reader, int &script, librevenge::RVNGString &typeFace);
187 + void readFmtScheme(xmlTextReaderPtr reader);
188 + void readFillStyleLst(xmlTextReaderPtr reader);
190 int getElementToken(xmlTextReaderPtr reader);
191 + void skipUnimplemented(xmlTextReaderPtr reader, int idToken);
193 VSDXClrScheme m_clrScheme;
194 VSDXFontScheme m_fontScheme;
195 + std::vector<boost::optional<Colour>> m_fillStyleLst;
198 } // namespace libvisio