bump product version to 7.6.3.2-android
[LibreOffice.git] / include / docmodel / theme / Theme.hxx
blob4643f0d0b33a8ce3cd9b8d0a4858089ecd5ec392
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 */
11 #pragma once
13 #include <docmodel/dllapi.h>
14 #include <vector>
16 #include <rtl/ustring.hxx>
17 #include <docmodel/theme/ThemeColor.hxx>
18 #include <docmodel/theme/ThemeColorType.hxx>
19 #include <docmodel/theme/Theme.hxx>
20 #include <docmodel/theme/ColorSet.hxx>
21 #include <docmodel/theme/FormatScheme.hxx>
22 #include <tools/color.hxx>
24 typedef struct _xmlTextWriter* xmlTextWriterPtr;
26 namespace model
28 struct DOCMODEL_DLLPUBLIC ThemeSupplementalFont
30 OUString maScript;
31 OUString maTypeface;
34 struct DOCMODEL_DLLPUBLIC ThemeFont
36 OUString maTypeface;
37 OUString maPanose;
38 sal_Int16 maPitch = 0;
39 sal_Int16 maFamily = 0;
40 sal_Int32 maCharset = 1;
42 sal_Int16 getPitchFamily() const { return (maPitch & 0x0F) | (maFamily & 0x0F) << 4; }
45 class DOCMODEL_DLLPUBLIC FontScheme
47 private:
48 OUString maName;
50 ThemeFont maMinorLatin;
51 ThemeFont maMinorAsian;
52 ThemeFont maMinorComplex;
54 ThemeFont maMajorLatin;
55 ThemeFont maMajorAsian;
56 ThemeFont maMajorComplex;
58 std::vector<ThemeSupplementalFont> maMinorSupplementalFontList;
59 std::vector<ThemeSupplementalFont> maMajorSupplementalFontList;
61 public:
62 FontScheme()
63 : maName("Office")
67 FontScheme(OUString const& rName)
68 : maName(rName)
72 static FontScheme getDefault()
74 FontScheme aDefault;
75 aDefault.maMinorLatin.maTypeface = "Arial";
76 aDefault.maMinorAsian.maTypeface = "DejaVu Sans";
77 aDefault.maMinorComplex.maTypeface = "DejaVu Sans";
79 aDefault.maMajorLatin.maTypeface = "Arial";
80 aDefault.maMajorAsian.maTypeface = "DejaVu Sans";
81 aDefault.maMajorComplex.maTypeface = "DejaVu Sans";
82 return aDefault;
85 const OUString& getName() const { return maName; }
87 ThemeFont const& getMinorLatin() const { return maMinorLatin; }
88 void setMinorLatin(ThemeFont const& aMinor) { maMinorLatin = aMinor; }
90 ThemeFont const& getMinorAsian() const { return maMinorAsian; }
91 void setMinorAsian(ThemeFont const& aMinor) { maMinorAsian = aMinor; }
93 ThemeFont const& getMinorComplex() const { return maMinorComplex; }
94 void setMinorComplex(ThemeFont const& aMinor) { maMinorComplex = aMinor; }
96 ThemeFont const& getMajorLatin() const { return maMajorLatin; }
97 void setMajorLatin(ThemeFont const& aMajor) { maMajorLatin = aMajor; }
99 ThemeFont const& getMajorAsian() const { return maMajorAsian; }
100 void setMajorAsian(ThemeFont const& aMajor) { maMajorAsian = aMajor; }
102 ThemeFont const& getMajorComplex() const { return maMajorComplex; }
103 void setMajorComplex(ThemeFont const& aMajor) { maMajorComplex = aMajor; }
105 OUString findMinorSupplementalTypeface(std::u16string_view rScript) const
107 for (auto const& rSupplementalFont : maMinorSupplementalFontList)
109 if (rSupplementalFont.maScript == rScript)
110 return rSupplementalFont.maTypeface;
112 return OUString();
115 std::vector<ThemeSupplementalFont> const& getMinorSupplementalFontList() const
117 return maMinorSupplementalFontList;
120 void addMinorSupplementalFont(ThemeSupplementalFont const& rfont)
122 maMinorSupplementalFontList.push_back(rfont);
125 void setMinorSupplementalFontList(std::vector<ThemeSupplementalFont> const& rSupplementalFont)
127 maMinorSupplementalFontList = rSupplementalFont;
130 OUString findMajorSupplementalTypeface(std::u16string_view rScript) const
132 for (auto const& rSupplementalFont : maMajorSupplementalFontList)
134 if (rSupplementalFont.maScript == rScript)
135 return rSupplementalFont.maTypeface;
137 return OUString();
140 std::vector<ThemeSupplementalFont> const& getMajorSupplementalFontList() const
142 return maMajorSupplementalFontList;
145 void addMajorSupplementalFont(ThemeSupplementalFont const& rfont)
147 maMajorSupplementalFontList.push_back(rfont);
150 void setMajorSupplementalFontList(std::vector<ThemeSupplementalFont> const& rSupplementalFont)
152 maMajorSupplementalFontList = rSupplementalFont;
156 /// A named theme has a named color set.
157 class DOCMODEL_DLLPUBLIC Theme
159 private:
160 OUString maName;
161 std::shared_ptr<model::ColorSet> mpColorSet;
163 FontScheme maFontScheme = FontScheme::getDefault();
164 FormatScheme maFormatScheme;
166 public:
167 Theme();
168 Theme(OUString const& rName);
170 Theme(Theme const& rTheme);
172 void setFontScheme(FontScheme const& rFontScheme) { maFontScheme = rFontScheme; }
173 FontScheme const& getFontScheme() const { return maFontScheme; }
175 void setFormatScheme(FormatScheme const& rFormatScheme) { maFormatScheme = rFormatScheme; }
176 FormatScheme const& getFormatScheme() const { return maFormatScheme; }
177 FormatScheme& getFormatScheme() { return maFormatScheme; }
179 void setColorSet(std::shared_ptr<model::ColorSet> const& pColorSet) { mpColorSet = pColorSet; }
181 std::shared_ptr<model::ColorSet> const& getColorSet() const { return mpColorSet; }
183 void SetName(const OUString& rName);
184 const OUString& GetName() const;
186 void dumpAsXml(xmlTextWriterPtr pWriter) const;
188 void ToAny(css::uno::Any& rVal) const;
190 static std::unique_ptr<Theme> FromAny(const css::uno::Any& rVal);
192 std::vector<Color> GetColors() const;
194 Color GetColor(model::ThemeColorType eType) const;
197 } // end of namespace model
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */