Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libvisio/src/lib/VSDXTheme.h
Line
Count
Source
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 <optional>
16
#include <array>
17
#include <librevenge-stream/librevenge-stream.h>
18
#include "VSDXMLHelper.h"
19
20
namespace libvisio
21
{
22
23
class VSDCollector;
24
25
struct VSDXVariationClrScheme
26
{
27
  Colour m_varColor1;
28
  Colour m_varColor2;
29
  Colour m_varColor3;
30
  Colour m_varColor4;
31
  Colour m_varColor5;
32
  Colour m_varColor6;
33
  Colour m_varColor7;
34
35
  VSDXVariationClrScheme();
36
};
37
38
struct VSDXClrScheme
39
{
40
  Colour m_dk1;
41
  Colour m_lt1;
42
  Colour m_dk2;
43
  Colour m_lt2;
44
  Colour m_accent1;
45
  Colour m_accent2;
46
  Colour m_accent3;
47
  Colour m_accent4;
48
  Colour m_accent5;
49
  Colour m_accent6;
50
  Colour m_hlink;
51
  Colour m_folHlink;
52
  Colour m_bkgnd;
53
  std::vector<VSDXVariationClrScheme> m_variationClrSchemeLst;
54
55
  VSDXClrScheme();
56
};
57
58
struct VSDXFont
59
{
60
  librevenge::RVNGString m_latinTypeFace;
61
  librevenge::RVNGString m_eaTypeFace;
62
  librevenge::RVNGString m_csTypeFace;
63
  std::map<unsigned, librevenge::RVNGString> m_typeFaces;
64
65
  VSDXFont();
66
};
67
68
struct VSDXFontScheme
69
{
70
  VSDXFont m_majorFont;
71
  VSDXFont m_minorFont;
72
  unsigned m_schemeId;
73
74
  VSDXFontScheme();
75
};
76
77
struct VSDXVariationStyleScheme
78
{
79
  std::array<std::array<unsigned, 4>, 4> m_varStyles;
80
81
  VSDXVariationStyleScheme();
82
};
83
84
class VSDXTheme
85
{
86
public:
87
  VSDXTheme();
88
  ~VSDXTheme();
89
  bool parse(librevenge::RVNGInputStream *input);
90
  std::optional<Colour> getThemeColour(unsigned value, unsigned variationIndex = 0) const;
91
  std::optional<Colour> getStyleColour(unsigned value, unsigned variationIndex = 0) const;
92
  std::optional<Colour> getFillStyleColour(unsigned value) const;
93
189
  size_t getFillStyleLstSize() const { return m_fillStyleLst.size(); }
94
95
private:
96
  VSDXTheme(const VSDXTheme &);
97
  VSDXTheme &operator=(const VSDXTheme &);
98
99
  std::optional<Colour> readSrgbClr(xmlTextReaderPtr reader);
100
  std::optional<Colour> readSysClr(xmlTextReaderPtr reader);
101
  std::optional<Colour> readSchemeClr(xmlTextReaderPtr reader);
102
103
  void readClrScheme(xmlTextReaderPtr reader);
104
  bool readThemeColour(xmlTextReaderPtr reader, int idToken, Colour &clr);
105
  void readVariationClrSchemeLst(xmlTextReaderPtr reader);
106
  void readVariationClrScheme(xmlTextReaderPtr reader, VSDXVariationClrScheme &varClrSch);
107
  void readVariationStyleSchemeLst(xmlTextReaderPtr reader);
108
  void readVariationStyleScheme(xmlTextReaderPtr reader, int idToken, VSDXVariationStyleScheme &vaStyleSch);
109
  void readVarIdx(xmlTextReaderPtr reader, std::array<unsigned, 4>& varStyle);
110
  void readFontScheme(xmlTextReaderPtr reader);
111
  void readFont(xmlTextReaderPtr reader, int idToken, VSDXFont &font);
112
  bool readTypeFace(xmlTextReaderPtr reader, librevenge::RVNGString &typeFace);
113
  bool readTypeFace(xmlTextReaderPtr reader, int &script, librevenge::RVNGString &typeFace);
114
  void readFmtScheme(xmlTextReaderPtr reader);
115
  void readFillStyleLst(xmlTextReaderPtr reader);
116
  void readGradFill(xmlTextReaderPtr reader, std::size_t nPos);
117
  void readGradFillLst(xmlTextReaderPtr reader, std::size_t nPos);
118
119
  int getElementToken(xmlTextReaderPtr reader);
120
  void skipUnimplemented(xmlTextReaderPtr reader, int idToken);
121
122
  VSDXClrScheme m_clrScheme;
123
  VSDXFontScheme m_fontScheme;
124
  std::array<std::vector<std::optional<Colour>>, 6> m_fillStyleLst;
125
  std::vector<VSDXVariationStyleScheme> m_variationStyleSchemeLst;
126
};
127
128
} // namespace libvisio
129
130
#endif // __VSDXTHEME_H__
131
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */