/src/libreoffice/oox/source/drawingml/themefragmenthandler.cxx
Line | Count | Source |
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 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #include <oox/drawingml/themefragmenthandler.hxx> |
21 | | #include <drawingml/objectdefaultcontext.hxx> |
22 | | #include <oox/drawingml/theme.hxx> |
23 | | #include <oox/token/namespaces.hxx> |
24 | | #include <oox/helper/attributelist.hxx> |
25 | | #include <drawingml/themeelementscontext.hxx> |
26 | | |
27 | | using namespace ::oox::core; |
28 | | |
29 | | namespace oox::drawingml |
30 | | { |
31 | | |
32 | | ThemeFragmentHandler::ThemeFragmentHandler(XmlFilterBase& rFilter, const OUString& rFragmentPath, Theme& rOoxTheme, model::Theme& rTheme) |
33 | 5.55k | : FragmentHandler2(rFilter, rFragmentPath) |
34 | 5.55k | , mrOoxTheme(rOoxTheme) |
35 | 5.55k | , mrTheme(rTheme) |
36 | 5.55k | { |
37 | 5.55k | } |
38 | | |
39 | | ThemeFragmentHandler::~ThemeFragmentHandler() |
40 | 5.55k | { |
41 | 5.55k | } |
42 | | |
43 | | ContextHandlerRef ThemeFragmentHandler::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/) |
44 | 26.7k | { |
45 | | // CT_OfficeStyleSheet |
46 | 26.7k | if (getCurrentElement() == A_TOKEN(theme)) |
47 | 16.1k | { |
48 | 16.1k | switch (nElement) |
49 | 16.1k | { |
50 | 4.24k | case A_TOKEN( themeElements ): // CT_BaseStyles |
51 | 4.24k | return new ThemeElementsContext(*this, mrOoxTheme, mrTheme); |
52 | 3.12k | case A_TOKEN( objectDefaults ): // CT_ObjectStyleDefaults |
53 | 3.12k | return new objectDefaultContext(*this, mrOoxTheme); |
54 | 3.12k | case A_TOKEN( extraClrSchemeLst ): // CT_ColorSchemeList |
55 | 3.12k | return nullptr; |
56 | 0 | case A_TOKEN( custClrLst ): // CustomColorList |
57 | 0 | return nullptr; |
58 | 482 | case A_TOKEN( ext ): // CT_OfficeArtExtension |
59 | 482 | return nullptr; |
60 | 16.1k | } |
61 | 16.1k | } |
62 | 10.6k | else if (getCurrentElement() == XML_ROOT_CONTEXT) |
63 | 3.55k | { |
64 | 3.55k | return this; |
65 | 3.55k | } |
66 | | |
67 | 12.2k | return nullptr; |
68 | 26.7k | } |
69 | | |
70 | | void ThemeFragmentHandler::onStartElement(const AttributeList& rAttribs) |
71 | 4.24k | { |
72 | 4.24k | if (getCurrentElement() == A_TOKEN(theme)) |
73 | 4.24k | { |
74 | 4.24k | OUString aName = rAttribs.getStringDefaulted(XML_name); |
75 | 4.24k | mrOoxTheme.setThemeName(aName); |
76 | 4.24k | mrTheme.SetName(aName); |
77 | 4.24k | } |
78 | 4.24k | } |
79 | | |
80 | | } // namespace oox::drawingml |
81 | | |
82 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |