/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace css; using namespace xmloff::token; XMLThemeContext::XMLThemeContext(SvXMLImport& rImport, const uno::Reference& xAttrList, css::uno::Reference const& xPage) : SvXMLImportContext(rImport) , m_xPage(xPage) { for (const auto& rAttribute : sax_fastparser::castToFastAttributeList(xAttrList)) { switch (rAttribute.getToken()) { case XML_ELEMENT(LO_EXT, XML_NAME): { m_aTheme["Name"] <<= rAttribute.toString(); break; } } } } XMLThemeContext::~XMLThemeContext() { uno::Any aTheme(m_aTheme.getAsConstPropertyValueList()); uno::Reference xPropertySet(m_xPage, uno::UNO_QUERY); xPropertySet->setPropertyValue("Theme", aTheme); } uno::Reference SAL_CALL XMLThemeContext::createFastChildContext( sal_Int32 nElement, const uno::Reference& xAttribs) { if (nElement == XML_ELEMENT(LO_EXT, XML_COLOR_TABLE)) { return new XMLColorTableContext(GetImport(), xAttribs, m_aTheme); } return nullptr; } XMLColorTableContext::XMLColorTableContext( SvXMLImport& rImport, const uno::Reference& xAttrList, comphelper::SequenceAsHashMap& rTheme) : SvXMLImportContext(rImport) , m_rTheme(rTheme) { for (const auto& rAttribute : sax_fastparser::castToFastAttributeList(xAttrList)) { switch (rAttribute.getToken()) { case XML_ELEMENT(LO_EXT, XML_NAME): { m_rTheme["ColorSchemeName"] <<= rAttribute.toString(); break; } } } } XMLColorTableContext::~XMLColorTableContext() { m_rTheme["ColorScheme"] <<= comphelper::containerToSequence(m_aColorScheme); } uno::Reference SAL_CALL XMLColorTableContext::createFastChildContext( sal_Int32 nElement, const uno::Reference& xAttribs) { if (nElement == XML_ELEMENT(LO_EXT, XML_COLOR)) { return new XMLColorContext(GetImport(), xAttribs, m_aColorScheme); } return nullptr; } XMLColorContext::XMLColorContext(SvXMLImport& rImport, const uno::Reference& xAttrList, std::vector& rColorScheme) : SvXMLImportContext(rImport) { for (const auto& rAttribute : sax_fastparser::castToFastAttributeList(xAttrList)) { switch (rAttribute.getToken()) { case XML_ELEMENT(LO_EXT, XML_COLOR): { util::Color nColor; sax::Converter::convertColor(nColor, rAttribute.toView()); rColorScheme.push_back(nColor); break; } } } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */