16#include <svx/strings.hrc>
19#include <boost/property_tree/json_parser.hpp>
25constexpr const std::array<const std::array<sal_Int16, 6>, 5> g_aLumMods = {
26 std::array<sal_Int16, 6>{ 10'000, 5'000, 6'500, 7'500, 8'500, 9'500 },
27 std::array<sal_Int16, 6>{ 10'000, 1'000, 2'500, 5'000, 7'500, 9'000 },
28 std::array<sal_Int16, 6>{ 10'000, 2'000, 4'000, 6'000, 7'500, 5'000 },
29 std::array<sal_Int16, 6>{ 10'000, 9'000, 7'500, 5'000, 2'500, 1'000 },
30 std::array<sal_Int16, 6>{ 10'000, 9'500, 8'500, 7'500, 6'500, 5'000 },
33constexpr const std::array<const std::array<sal_Int16, 6>, 5> g_aLumOffs = {
34 std::array<sal_Int16, 6>{ 0, 5'000, 3'500, 2'500, 1'500, 0
'500 },
35 std::array<sal_Int16, 6>{ 0, 9'000, 7'500, 5'000, 2'500, 1'000 },
36 std::array<sal_Int16, 6>{ 0, 8'000, 6'000, 4'000, 0, 0 },
37 std::array<sal_Int16, 6>{ 0, 0, 0, 0, 0, 0 },
38 std::array<sal_Int16, 6>{ 0, 0, 0, 0, 0, 0 },
46 std::shared_ptr<model::ColorSet>
const& pColorSet)
47 : m_pColorSet(pColorSet)
55 const std::array<OUString, 12> aColorNames = {
64 for (
size_t nColor = 0; nColor < aColorNames.size(); ++nColor)
70 auto& aThemeColorData = aThemePaletteCollection.
maColors[nColor];
71 aThemeColorData.meThemeColorType = eThemeType;
74 aThemeColorData.maBaseColor = aThemeColor;
77 double aLuminanceValue = aHSLColor.
getBlue() * 255.0;
79 for (
size_t nEffect : { 0, 1, 2, 3, 4, 5 })
81 auto& rEffect = aThemeColorData.maEffects[nEffect];
84 if (aLuminanceValue < 0.5)
86 else if (aLuminanceValue > 254.5)
88 else if (aLuminanceValue < 50.5)
90 else if (aLuminanceValue > 203.5)
95 rEffect.mnLumOff = g_aLumOffs[
nIndex][nEffect];
96 rEffect.mnLumMod = g_aLumMods[
nIndex][nEffect];
98 rEffect.maColor = aThemeColor;
99 rEffect.maColor.
ApplyLumModOff(rEffect.mnLumMod, rEffect.mnLumOff);
102 sal_Int16 nPercent = rEffect.getPercentage();
107 aTemplate =
SvxResId(RID_SVXSTR_THEME_EFFECT_LIGHTER);
109 else if (nPercent < 0)
111 aTemplate =
SvxResId(RID_SVXSTR_THEME_EFFECT_DARKER);
114 if (!aTemplate.isEmpty())
116 aColorName = aTemplate.replaceAll(
"$THEME_NAME", aColorNames[nColor]);
118 = aColorName.replaceAll(
"$PERCENTAGE", OUString::number(std::abs(nPercent)));
122 aColorName = aColorNames[nColor];
124 rEffect.maColorName = aColorName;
127 return aThemePaletteCollection;
134 boost::property_tree::ptree aTree;
135 boost::property_tree::ptree aColorListTree;
137 for (
size_t nEffect = 0; nEffect < 6; ++nEffect)
139 boost::property_tree::ptree aColorRowTree;
142 auto const& rColorData = aThemePaletteCollection.
maColors[
nIndex];
143 auto const& rEffectData = rColorData.maEffects[nEffect];
145 boost::property_tree::ptree aColorTree;
146 aColorTree.put(
"Value", rEffectData.maColor.AsRGBHexString().toUtf8());
147 aColorTree.put(
"Name", rEffectData.maColorName.toUtf8());
155 boost::property_tree::ptree aDataTree;
157 aColorTree.add_child(
"Data", aDataTree);
158 aColorRowTree.push_back(std::make_pair(
"", aColorTree));
160 aColorListTree.push_back(std::make_pair(
"", aColorRowTree));
163 aTree.add_child(
"ThemeColors", aColorListTree);
165 std::stringstream aStream;
166 boost::property_tree::write_json(aStream, aTree);
168 return OString(aStream.str());
basegfx::BColor getBColor() const
void ApplyLumModOff(sal_Int16 nMod, sal_Int16 nOff)
void setSchemeColor(ThemeColorType eType)
void addTransformation(Transformation const &rTransform)
std::shared_ptr< model::ColorSet > m_pColorSet
ThemePaletteCollection generate()
ThemeColorPaletteManager(std::shared_ptr< model::ColorSet > const &pColorSet)
OUString SvxResId(TranslateId aId)
BColor rgb2hsl(const BColor &rRGBColor)
void convertToJSONTree(boost::property_tree::ptree &rTree, model::ComplexColor const &rComplexColor)
constexpr ThemeColorType convertToThemeColorType(sal_Int32 nIndex)
std::array< ThemePaletteColorData, 12 > maColors