1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
11 #include <docmodel/theme/ColorSet.hxx>
14 #include <libxml/xmlwriter.h>
15 #include <sal/log.hxx>
19 ColorSet::ColorSet(OUString
const& rName
)
24 void ColorSet::add(model::ThemeColorType eType
, Color aColorData
)
26 if (eType
== model::ThemeColorType::Unknown
)
28 maColors
[sal_Int16(eType
)] = aColorData
;
31 Color
ColorSet::getColor(model::ThemeColorType eType
) const
33 if (eType
== model::ThemeColorType::Unknown
)
35 SAL_WARN("svx", "ColorSet::getColor with ThemeColorType::Unknown");
38 return maColors
[size_t(eType
)];
41 Color
ColorSet::resolveColor(model::ComplexColor
const& rComplexColor
) const
43 auto eThemeType
= rComplexColor
.getThemeColorType();
44 if (eThemeType
== model::ThemeColorType::Unknown
)
46 SAL_WARN("svx", "ColorSet::resolveColor with ThemeColorType::Unknown");
49 Color aColor
= getColor(eThemeType
);
50 return rComplexColor
.applyTransformations(aColor
);
53 void ColorSet::dumpAsXml(xmlTextWriterPtr pWriter
) const
55 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("ColorSet"));
56 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("ptr"), "%p", this);
57 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("maName"),
58 BAD_CAST(maName
.toUtf8().getStr()));
60 for (const auto& rColor
: maColors
)
62 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("Color"));
65 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(ss
.str().c_str()));
66 (void)xmlTextWriterEndElement(pWriter
);
69 (void)xmlTextWriterEndElement(pWriter
);
72 } // end of namespace svx
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */