VSDXTheme.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libvisio project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef __VSDXTHEME_H__
11 #define __VSDXTHEME_H__
12
13 #include <vector>
14 #include <map>
15 #include <boost/optional.hpp>
16 #include <librevenge-stream/librevenge-stream.h>
17 #include "VSDXMLHelper.h"
18
19 namespace libvisio
20 {
21
22 class VSDCollector;
23
24 struct VSDXVariationClrScheme
25 {
26 Colour m_varColor1;
27 Colour m_varColor2;
28 Colour m_varColor3;
29 Colour m_varColor4;
30 Colour m_varColor5;
31 Colour m_varColor6;
32 Colour m_varColor7;
33
34 VSDXVariationClrScheme();
35 };
36
37 struct VSDXClrScheme
38 {
39 Colour m_dk1;
40 Colour m_lt1;
41 Colour m_dk2;
42 Colour m_lt2;
43 Colour m_accent1;
44 Colour m_accent2;
45 Colour m_accent3;
46 Colour m_accent4;
47 Colour m_accent5;
48 Colour m_accent6;
49 Colour m_hlink;
50 Colour m_folHlink;
51 Colour m_bkgnd;
52 std::vector<VSDXVariationClrScheme> m_variationClrSchemeLst;
53
54 VSDXClrScheme();
55 };
56
57 struct VSDXFont
58 {
59 librevenge::RVNGString m_latinTypeFace;
60 librevenge::RVNGString m_eaTypeFace;
61 librevenge::RVNGString m_csTypeFace;
62 std::map<unsigned, librevenge::RVNGString> m_typeFaces;
63
64 VSDXFont();
65 };
66
67 struct VSDXFontScheme
68 {
69 VSDXFont m_majorFont;
70 VSDXFont m_minorFont;
71 unsigned m_schemeId;
72
73 VSDXFontScheme();
74 };
75
76 class VSDXTheme
77 {
78 public:
79 VSDXTheme();
80 ~VSDXTheme();
81 bool parse(librevenge::RVNGInputStream *input);
82 boost::optional<Colour> getThemeColour(unsigned value, unsigned variationIndex = 0) const;
83
84 private:
85 VSDXTheme(const VSDXTheme &);
86 VSDXTheme &operator=(const VSDXTheme &);
87
88 boost::optional<Colour> readSrgbClr(xmlTextReaderPtr reader);
89 boost::optional<Colour> readSysClr(xmlTextReaderPtr reader);
90
91 void readClrScheme(xmlTextReaderPtr reader);
92 void readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr);
93 void readVariationClrSchemeLst(xmlTextReaderPtr reader);
94 void readVariationClrScheme(xmlTextReaderPtr reader, VSDXVariationClrScheme &varClrSch);
95 void readFontScheme(xmlTextReaderPtr reader);
96 void readFont(xmlTextReaderPtr reader, int idToken, VSDXFont &font);
97 bool readTypeFace(xmlTextReaderPtr reader, librevenge::RVNGString &typeFace);
98 bool readTypeFace(xmlTextReaderPtr reader, int &script, librevenge::RVNGString &typeFace);
99
100 int getElementToken(xmlTextReaderPtr reader);
101
102 VSDXClrScheme m_clrScheme;
103 VSDXFontScheme m_fontScheme;
104 };
105
106 } // namespace libvisio
107
108 #endif // __VSDXTHEME_H__
109 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDXVariationClrScheme::m_varColor4
Colour m_varColor4
Definition: VSDXTheme.h:29
XML_VT_VARIATIONCLRSCHEME
const int XML_VT_VARIATIONCLRSCHEME
Definition: tokens.h:299
libvisio::VSDXFontScheme::m_schemeId
unsigned m_schemeId
Definition: VSDXTheme.h:71
XML_A_ACCENT3
const int XML_A_ACCENT3
Definition: tokens.h:211
libvisio::VSDXFont::m_eaTypeFace
librevenge::RVNGString m_eaTypeFace
Definition: VSDXTheme.h:60
XML_A_EA
const int XML_A_EA
Definition: tokens.h:221
libvisio::VSDXTheme::readTypeFace
bool readTypeFace(xmlTextReaderPtr reader, librevenge::RVNGString &typeFace)
Definition: VSDXTheme.cpp:231
libvisio::xmlReaderForStream
std::unique_ptr< xmlTextReader, void(*)(xmlTextReaderPtr)> xmlReaderForStream(librevenge::RVNGInputStream *input, XMLErrorWatcher *watcher=nullptr, bool recover=true)
Definition: libvisio_xml.h:42
libvisio::VSDXClrScheme::m_dk1
Colour m_dk1
Definition: VSDXTheme.h:39
libvisio::VSDXVariationClrScheme::m_varColor2
Colour m_varColor2
Definition: VSDXTheme.h:27
XML_VT_VARCOLOR2
const int XML_VT_VARCOLOR2
Definition: tokens.h:292
libvisio::VSDXTheme::operator=
VSDXTheme & operator=(const VSDXTheme &)
libvisio::VSDXVariationClrScheme::m_varColor1
Colour m_varColor1
Definition: VSDXTheme.h:26
XML_A_DK1
const int XML_A_DK1
Definition: tokens.h:219
libvisio::VSDXVariationClrScheme::m_varColor3
Colour m_varColor3
Definition: VSDXTheme.h:28
libvisio::VSDXTheme::getThemeColour
boost::optional< Colour > getThemeColour(unsigned value, unsigned variationIndex=0) const
Definition: VSDXTheme.cpp:432
XML_VT_VARCOLOR5
const int XML_VT_VARCOLOR5
Definition: tokens.h:295
libvisio::VSDXFont::m_latinTypeFace
librevenge::RVNGString m_latinTypeFace
Definition: VSDXTheme.h:59
libvisio::VSDXTheme::readThemeColour
void readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr)
Definition: VSDXTheme.cpp:323
libvisio::VSDXClrScheme::m_accent1
Colour m_accent1
Definition: VSDXTheme.h:43
libvisio::VSDXFont::m_typeFaces
std::map< unsigned, librevenge::RVNGString > m_typeFaces
Definition: VSDXTheme.h:62
XML_A_DK2
const int XML_A_DK2
Definition: tokens.h:220
libvisio::VSDXClrScheme::m_accent2
Colour m_accent2
Definition: VSDXTheme.h:44
libvisio::VSDXTheme::m_clrScheme
VSDXClrScheme m_clrScheme
Definition: VSDXTheme.h:102
VSD_DEBUG_MSG
#define VSD_DEBUG_MSG(M)
Definition: libvisio_utils.h:42
XML_VT_VARCOLOR1
const int XML_VT_VARCOLOR1
Definition: tokens.h:291
libvisio::VSDXTheme::~VSDXTheme
~VSDXTheme()
Definition: VSDXTheme.cpp:70
libvisio::VSDXVariationClrScheme::m_varColor6
Colour m_varColor6
Definition: VSDXTheme.h:31
libvisio::VSDXTheme::getElementToken
int getElementToken(xmlTextReaderPtr reader)
Definition: VSDXTheme.cpp:75
libvisio::VSDXClrScheme::m_lt1
Colour m_lt1
Definition: VSDXTheme.h:40
libvisio::VSDXClrScheme::m_accent3
Colour m_accent3
Definition: VSDXTheme.h:45
XML_A_FONTSCHEME
const int XML_A_FONTSCHEME
Definition: tokens.h:232
VSDXMLHelper.h
libvisio::VSDXTheme::readFontScheme
void readFontScheme(xmlTextReaderPtr reader)
Definition: VSDXTheme.cpp:158
libvisio::XmlParserException
Definition: libvisio_utils.h:91
libvisio::VSDXClrScheme::m_accent6
Colour m_accent6
Definition: VSDXTheme.h:48
libvisio::VSDXClrScheme
Definition: VSDXTheme.h:37
VSDXMLTokenMap.h
libvisio::VSDXClrScheme::m_dk2
Colour m_dk2
Definition: VSDXTheme.h:41
XML_A_ACCENT2
const int XML_A_ACCENT2
Definition: tokens.h:210
libvisio::Colour
Definition: VSDTypes.h:70
XML_VT_VARCOLOR7
const int XML_VT_VARCOLOR7
Definition: tokens.h:297
libvisio::VSDXTheme::readClrScheme
void readClrScheme(xmlTextReaderPtr reader)
Definition: VSDXTheme.cpp:256
libvisio::VSDXVariationClrScheme
Definition: VSDXTheme.h:24
libvisio::xmlStringToColour
Colour xmlStringToColour(const xmlChar *s)
Definition: libvisio_xml.cpp:115
XML_VT_SCHEMEID
const int XML_VT_SCHEMEID
Definition: tokens.h:289
XML_A_CS
const int XML_A_CS
Definition: tokens.h:218
libvisio::VSDXClrScheme::m_lt2
Colour m_lt2
Definition: VSDXTheme.h:42
libvisio::VSDXTheme::readVariationClrScheme
void readVariationClrScheme(xmlTextReaderPtr reader, VSDXVariationClrScheme &varClrSch)
Definition: VSDXTheme.cpp:387
XML_A_ACCENT6
const int XML_A_ACCENT6
Definition: tokens.h:214
libvisio::VSDXClrScheme::m_hlink
Colour m_hlink
Definition: VSDXTheme.h:49
XML_VT_BKGND
const int XML_VT_BKGND
Definition: tokens.h:273
XML_VT_VARIATIONCLRSCHEMELST
const int XML_VT_VARIATIONCLRSCHEMELST
Definition: tokens.h:300
libvisio::VSDXFontScheme
Definition: VSDXTheme.h:67
libvisio::VSDXTheme::parse
bool parse(librevenge::RVNGInputStream *input)
Definition: VSDXTheme.cpp:80
libvisio::VSDXMLTokenMap::getTokenId
static int getTokenId(const xmlChar *name)
Definition: VSDXMLTokenMap.cpp:21
XML_A_ACCENT5
const int XML_A_ACCENT5
Definition: tokens.h:213
libvisio::VSDXClrScheme::m_bkgnd
Colour m_bkgnd
Definition: VSDXTheme.h:51
XML_A_FONT
const int XML_A_FONT
Definition: tokens.h:231
libvisio::VSDXTheme::VSDXTheme
VSDXTheme()
Definition: VSDXTheme.cpp:64
XML_VT_VARCOLOR4
const int XML_VT_VARCOLOR4
Definition: tokens.h:294
libvisio::VSDXTheme::readSysClr
boost::optional< Colour > readSysClr(xmlTextReaderPtr reader)
Definition: VSDXTheme.cpp:138
libvisio::VSDXFont
Definition: VSDXTheme.h:57
XML_A_ACCENT1
const int XML_A_ACCENT1
Definition: tokens.h:209
XML_A_LATIN
const int XML_A_LATIN
Definition: tokens.h:237
XML_A_CLRSCHEME
const int XML_A_CLRSCHEME
Definition: tokens.h:217
libvisio::VSDXTheme
Definition: VSDXTheme.h:76
XML_VT_VARCOLOR3
const int XML_VT_VARCOLOR3
Definition: tokens.h:293
XML_A_ACCENT4
const int XML_A_ACCENT4
Definition: tokens.h:212
XML_A_SRGBCLR
const int XML_A_SRGBCLR
Definition: tokens.h:253
libvisio::VSDXFont::m_csTypeFace
librevenge::RVNGString m_csTypeFace
Definition: VSDXTheme.h:61
libvisio::VSDXFont::VSDXFont
VSDXFont()
Definition: VSDXTheme.cpp:49
libvisio::VSDXVariationClrScheme::m_varColor5
Colour m_varColor5
Definition: VSDXTheme.h:30
XML_A_HLINK
const int XML_A_HLINK
Definition: tokens.h:236
libvisio::VSDXTheme::readFont
void readFont(xmlTextReaderPtr reader, int idToken, VSDXFont &font)
Definition: VSDXTheme.cpp:190
libvisio::VSDXClrScheme::m_accent4
Colour m_accent4
Definition: VSDXTheme.h:46
libvisio::VSDXTheme::readVariationClrSchemeLst
void readVariationClrSchemeLst(xmlTextReaderPtr reader)
Definition: VSDXTheme.cpp:356
libvisio::VSDXTheme::readSrgbClr
boost::optional< Colour > readSrgbClr(xmlTextReaderPtr reader)
Definition: VSDXTheme.cpp:118
libvisio::VSDXClrScheme::m_variationClrSchemeLst
std::vector< VSDXVariationClrScheme > m_variationClrSchemeLst
Definition: VSDXTheme.h:52
XML_VT_VARCOLOR6
const int XML_VT_VARCOLOR6
Definition: tokens.h:296
XML_TOKEN_INVALID
const int XML_TOKEN_INVALID
Definition: tokens.h:306
libvisio_xml.h
XML_A_FOLHLINK
const int XML_A_FOLHLINK
Definition: tokens.h:230
libvisio::VSDXTheme::m_fontScheme
VSDXFontScheme m_fontScheme
Definition: VSDXTheme.h:103
libvisio::VSDXFontScheme::VSDXFontScheme
VSDXFontScheme()
Definition: VSDXTheme.cpp:57
libvisio_utils.h
libvisio::VSDXFontScheme::m_majorFont
VSDXFont m_majorFont
Definition: VSDXTheme.h:69
VSDXTheme.h
XML_A_MINORFONT
const int XML_A_MINORFONT
Definition: tokens.h:245
libvisio::VSDXClrScheme::VSDXClrScheme
VSDXClrScheme()
Definition: VSDXTheme.cpp:31
XML_A_SYSCLR
const int XML_A_SYSCLR
Definition: tokens.h:254
libvisio::VSDXFontScheme::m_minorFont
VSDXFont m_minorFont
Definition: VSDXTheme.h:70
libvisio::VSDXVariationClrScheme::VSDXVariationClrScheme
VSDXVariationClrScheme()
Definition: VSDXTheme.cpp:20
XML_A_LT1
const int XML_A_LT1
Definition: tokens.h:241
libvisio
Definition: libvisio_utils.h:48
libvisio::VSDXClrScheme::m_folHlink
Colour m_folHlink
Definition: VSDXTheme.h:50
XML_A_MAJORFONT
const int XML_A_MAJORFONT
Definition: tokens.h:244
libvisio::VSDXVariationClrScheme::m_varColor7
Colour m_varColor7
Definition: VSDXTheme.h:32
libvisio::VSDXClrScheme::m_accent5
Colour m_accent5
Definition: VSDXTheme.h:47
XML_A_LT2
const int XML_A_LT2
Definition: tokens.h:242