LibreOffice Module xmloff (master) 1
XMLComplexColorExport.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice 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
11
12#include <sal/config.h>
13
15#include <xmloff/xmltoken.hxx>
17#include <xmloff/xmluconv.hxx>
18#include <xmloff/xmlexp.hxx>
19#include <array>
20
21using namespace css;
22using namespace ::xmloff::token;
23
25 : mrExport(rExport)
26{
27}
28
29namespace
30{
31constexpr const std::array<XMLTokenEnum, 12> constThemeColorTypeToToken{
34};
35}
36
37void XMLComplexColorExport::exportXML(const uno::Any& rAny, sal_uInt16 nPrefix,
38 const OUString& rLocalName)
39{
40 uno::Reference<util::XComplexColor> xComplexColor;
41 rAny >>= xComplexColor;
42 if (!xComplexColor.is())
43 return;
44
45 model::ComplexColor aComplexColor = model::color::getFromXComplexColor(xComplexColor);
46 if (aComplexColor.getSchemeType() == model::ThemeColorType::Unknown)
47 return;
48
49 XMLTokenEnum nToken = constThemeColorTypeToToken[sal_Int16(aComplexColor.getSchemeType())];
52 SvXMLElementExport aComplexColorElement(mrExport, nPrefix, rLocalName, true, true);
53
54 for (auto const& rTransform : aComplexColor.getTransformations())
55 {
56 OUString aType;
57 switch (rTransform.meType)
58 {
60 aType = "tint";
61 break;
63 aType = "shade";
64 break;
66 aType = "lummod";
67 break;
69 aType = "lumoff";
70 break;
71 default:
72 break;
73 }
74 if (!aType.isEmpty())
75 {
78 OUString::number(rTransform.mnValue));
80 true, true);
81 }
82 }
83}
84
85/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:907
XMLComplexColorExport(SvXMLExport &rExport)
void exportXML(const css::uno::Any &rAny, sal_uInt16 nPrefix, const OUString &rLocalName)
std::vector< Transformation > const & getTransformations() const
ThemeColorType getSchemeType() const
model::ComplexColor getFromXComplexColor(uno::Reference< util::XComplexColor > const &rxColor)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
@ XML_FOLLOWED_HYPERLINK
Definition: xmltoken.hxx:3508
DefTokenId nToken
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT