Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / sfx2 / namedcolor.hxx
blob1c5fe24b5144c443dddf090338cf06cf6d19b42b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
8 */
10 #pragma once
12 #include <sal/config.h>
13 #include <sfx2/dllapi.h>
15 #include <docmodel/color/ComplexColor.hxx>
16 #include <docmodel/theme/ThemeColorType.hxx>
18 struct SFX2_DLLPUBLIC NamedColor
20 Color m_aColor;
21 OUString m_aName;
22 sal_Int16 m_nThemeIndex = -1;
23 sal_Int16 m_nLumMod = 10000;
24 sal_Int16 m_nLumOff = 0;
26 NamedColor() = default;
28 NamedColor(Color const& rColor, OUString const& rName)
29 : m_aColor(rColor)
30 , m_aName(rName)
34 model::ComplexColor getComplexColor()
36 model::ComplexColor aComplexColor;
38 auto eThemeColorType = model::convertToThemeColorType(m_nThemeIndex);
40 if (eThemeColorType != model::ThemeColorType::Unknown)
42 aComplexColor.setThemeColor(eThemeColorType);
44 if (m_nLumMod != 10000)
45 aComplexColor.addTransformation({ model::TransformationType::LumMod, m_nLumMod });
47 if (m_nLumOff != 0)
48 aComplexColor.addTransformation({ model::TransformationType::LumOff, m_nLumOff });
50 aComplexColor.setFinalColor(m_aColor);
52 else
54 aComplexColor.setColor(m_aColor);
57 return aComplexColor;
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */