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/.
10 #include <sal/log.hxx>
11 #include "OOXMLFastContextHandlerTheme.hxx"
12 #include <oox/drawingml/theme.hxx>
13 #include <oox/token/namespaces.hxx>
15 using namespace ::com::sun::star
;
17 namespace writerfilter::ooxml
19 OOXMLFastContextHandlerTheme::OOXMLFastContextHandlerTheme(OOXMLFastContextHandler
* pContext
)
20 : OOXMLFastContextHandler(pContext
)
24 uno::Reference
<xml::sax::XFastContextHandler
>
25 OOXMLFastContextHandlerTheme::lcl_createFastChildContext(
26 Token_t Element
, const uno::Reference
<xml::sax::XFastAttributeList
>& Attribs
)
28 if (mpThemeFragmentHandler
.is())
29 return mpThemeFragmentHandler
->createFastChildContext(Element
, Attribs
);
34 void OOXMLFastContextHandlerTheme::lcl_startFastElement(
35 Token_t Element
, const uno::Reference
<xml::sax::XFastAttributeList
>& Attribs
)
37 if (!mpThemeFragmentHandler
.is())
39 auto xThemeFilterBase
= getDocument()->getThemeFilterBase();
40 OUString aThemeFragmentPath
41 = xThemeFilterBase
->getFragmentPathFromFirstTypeFromOfficeDoc(u
"theme");
42 auto pThemePtr
= getDocument()->getTheme();
45 pThemePtr
= std::make_shared
<oox::drawingml::Theme
>();
46 auto pTheme
= std::make_shared
<model::Theme
>();
47 pThemePtr
->setTheme(pTheme
);
48 getDocument()->setTheme(pThemePtr
);
50 mpThemeFragmentHandler
= new oox::drawingml::ThemeFragmentHandler(
51 *xThemeFilterBase
, aThemeFragmentPath
, *pThemePtr
, *pThemePtr
->getTheme());
54 if (mpThemeFragmentHandler
.is())
55 mpThemeFragmentHandler
->startFastElement(Element
, Attribs
);
58 void OOXMLFastContextHandlerTheme::lcl_endFastElement(Token_t Element
)
60 if (mpThemeFragmentHandler
.is())
61 mpThemeFragmentHandler
->endFastElement(Element
);
64 void OOXMLFastContextHandlerTheme::lcl_characters(const OUString
& aChars
)
66 if (mpThemeFragmentHandler
.is())
67 mpThemeFragmentHandler
->characters(aChars
);
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */