Avoid potential negative array index access to cached text.
[LibreOffice.git] / docmodel / source / uno / UnoTheme.cxx
bloba7eac05cbd9bdc101ca064d8ae6e9d46fdb60c34
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 #include <docmodel/uno/UnoTheme.hxx>
12 #include <docmodel/theme/ThemeColorType.hxx>
13 #include <cppuhelper/queryinterface.hxx>
14 #include <o3tl/enumrange.hxx>
15 #include <comphelper/sequence.hxx>
16 #include <docmodel/theme/Theme.hxx>
18 using namespace css;
20 OUString UnoTheme::getName() { return mpTheme->GetName(); }
22 css::uno::Sequence<sal_Int32> UnoTheme::getColorSet()
24 std::vector<sal_Int32> aColorScheme(12);
25 auto pColorSet = mpTheme->getColorSet();
26 if (pColorSet)
28 size_t i = 0;
30 for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>())
32 if (eThemeColorType == model::ThemeColorType::Unknown)
33 continue;
34 Color aColor = pColorSet->getColor(eThemeColorType);
35 aColorScheme[i] = sal_Int32(aColor);
36 i++;
39 return comphelper::containerToSequence(aColorScheme);
42 namespace model::theme
44 uno::Reference<util::XTheme> createXTheme(std::shared_ptr<model::Theme> const& pTheme)
46 return new UnoTheme(pTheme);
49 } // end model::theme
51 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */