Bump version to 24.04.3.4
[LibreOffice.git] / external / libvisio / solid-fill-style.patch
blob53dc6a405e714e65cc2773640783f9afc8752f36
1 --- src/lib/VSDStyles.h
2 +++ src/lib/VSDStyles.h
3 @@ -179,14 +177,13 @@ struct VSDFillStyle
4 ASSIGN_OPTIONAL(style.qsFillMatrix, qsFillMatrix);
5 if (theme)
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()
30 : m_clrScheme(),
31 - m_fontScheme()
32 + m_fontScheme(),
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());
40 break;
41 + case XML_A_FMTSCHEME:
42 + readFmtScheme(reader.get());
43 + break;
44 default:
45 break;
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)
54 int ret = 1;
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);
59 if (colour)
60 + {
61 clr = *colour;
62 + return true;
63 + }
64 + return false;
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"));
75 + int ret = 1;
76 + int tokenId = XML_TOKEN_INVALID;
77 + int tokenType = -1;
78 + do
79 + {
80 + ret = xmlTextReaderRead(reader);
81 + tokenId = getElementToken(reader);
82 + if (XML_TOKEN_INVALID == tokenId)
83 + {
84 + VSD_DEBUG_MSG(("VSDXTheme::readFmtScheme: unknown token %s\n", xmlTextReaderConstName(reader)));
85 + }
86 + tokenType = xmlTextReaderNodeType(reader);
87 + switch (tokenId)
88 + {
89 + case XML_A_FILLSTYLELST:
90 + {
91 + readFillStyleLst(reader);
92 + break;
93 + }
94 + default:
95 + // Other style lists not implemented
96 + break;
97 + }
98 + } while ((XML_A_FMTSCHEME != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
101 +void libvisio::VSDXTheme::skipUnimplemented(xmlTextReaderPtr reader, int idToken)
103 + int ret = 1;
104 + int tokenId = XML_TOKEN_INVALID;
105 + int tokenType = -1;
106 + do
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);
128 + int i = 0;
129 + while ((XML_A_FILLSTYLELST != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret)
131 + switch (tokenId)
133 + case XML_A_SOLIDFILL:
135 + Colour colour;
136 + if (readThemeColour(reader, tokenId, colour))
138 + m_fillStyleLst[i] = colour;
140 + break;
142 + default:
143 + // Skip unimplemented fill type
144 + skipUnimplemented(reader, tokenId);
145 + break;
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:
168 ~VSDXTheme();
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;
173 private:
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