GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / oox / source / drawingml / themeelementscontext.cxx
bloba2ff33814ca8cd5856628475c57a8ed3eb690071
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 * This file incorporates work covered by the following license notice:
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 .
20 #include "oox/drawingml/themeelementscontext.hxx"
21 #include "oox/drawingml/clrschemecontext.hxx"
22 #include "oox/drawingml/lineproperties.hxx"
23 #include "oox/drawingml/linepropertiescontext.hxx"
24 #include "oox/drawingml/effectproperties.hxx"
25 #include "oox/drawingml/effectpropertiescontext.hxx"
26 #include "oox/drawingml/fillproperties.hxx"
27 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
28 #include "oox/drawingml/theme.hxx"
29 #include "oox/helper/attributelist.hxx"
31 using namespace ::oox::core;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::xml::sax;
35 namespace oox {
36 namespace drawingml {
38 // ============================================================================
40 class FillStyleListContext : public ContextHandler2
42 public:
43 FillStyleListContext( ContextHandler2Helper& rParent, FillStyleList& rFillStyleList );
44 virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
46 private:
47 FillStyleList& mrFillStyleList;
50 FillStyleListContext::FillStyleListContext( ContextHandler2Helper& rParent, FillStyleList& rFillStyleList ) :
51 ContextHandler2( rParent ),
52 mrFillStyleList( rFillStyleList )
56 ContextHandlerRef FillStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
58 switch( nElement )
60 case A_TOKEN( noFill ):
61 case A_TOKEN( solidFill ):
62 case A_TOKEN( gradFill ):
63 case A_TOKEN( blipFill ):
64 case A_TOKEN( pattFill ):
65 case A_TOKEN( grpFill ):
66 mrFillStyleList.push_back( FillPropertiesPtr( new FillProperties ) );
67 return FillPropertiesContext::createFillContext( *this, nElement, rAttribs, *mrFillStyleList.back() );
69 return 0;
72 // ============================================================================
74 class LineStyleListContext : public ContextHandler2
76 public:
77 LineStyleListContext( ContextHandler2Helper& rParent, LineStyleList& rLineStyleList );
78 virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
80 private:
81 LineStyleList& mrLineStyleList;
84 LineStyleListContext::LineStyleListContext( ContextHandler2Helper& rParent, LineStyleList& rLineStyleList ) :
85 ContextHandler2( rParent ),
86 mrLineStyleList( rLineStyleList )
90 ContextHandlerRef LineStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
92 switch( nElement )
94 case A_TOKEN( ln ):
95 mrLineStyleList.push_back( LinePropertiesPtr( new LineProperties ) );
96 return new LinePropertiesContext( *this, rAttribs, *mrLineStyleList.back() );
98 return 0;
101 // ============================================================================
103 class EffectStyleListContext : public ContextHandler2
105 public:
106 EffectStyleListContext( ContextHandler2Helper& rParent, EffectStyleList& rEffectStyleList );
107 virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
109 private:
110 EffectStyleList& mrEffectStyleList;
113 EffectStyleListContext::EffectStyleListContext( ContextHandler2Helper& rParent, EffectStyleList& rEffectStyleList ) :
114 ContextHandler2( rParent ),
115 mrEffectStyleList( rEffectStyleList )
119 ContextHandlerRef EffectStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
121 switch( nElement )
123 case A_TOKEN( effectStyle ):
124 mrEffectStyleList.push_back( EffectPropertiesPtr( new EffectProperties ) );
125 return this;
127 case A_TOKEN( effectLst ): // CT_EffectList
128 if( mrEffectStyleList.back() )
129 return new EffectPropertiesContext( *this, *mrEffectStyleList.back() );
130 break;
132 return 0;
135 // ============================================================================
137 class FontSchemeContext : public ContextHandler2
139 public:
140 FontSchemeContext( ContextHandler2Helper& rParent, FontScheme& rFontScheme );
141 virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
142 virtual void onEndElement() SAL_OVERRIDE;
144 private:
145 FontScheme& mrFontScheme;
146 TextCharacterPropertiesPtr mxCharProps;
149 FontSchemeContext::FontSchemeContext( ContextHandler2Helper& rParent, FontScheme& rFontScheme ) :
150 ContextHandler2( rParent ),
151 mrFontScheme( rFontScheme )
155 ContextHandlerRef FontSchemeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
157 switch( nElement )
159 case A_TOKEN( majorFont ):
160 mxCharProps.reset( new TextCharacterProperties );
161 mrFontScheme[ XML_major ] = mxCharProps;
162 return this;
163 case A_TOKEN( minorFont ):
164 mxCharProps.reset( new TextCharacterProperties );
165 mrFontScheme[ XML_minor ] = mxCharProps;
166 return this;
168 case A_TOKEN( latin ):
169 if( mxCharProps.get() )
170 mxCharProps->maLatinFont.setAttributes( rAttribs );
171 break;
172 case A_TOKEN( ea ):
173 if( mxCharProps.get() )
174 mxCharProps->maAsianFont.setAttributes( rAttribs );
175 break;
176 case A_TOKEN( cs ):
177 if( mxCharProps.get() )
178 mxCharProps->maComplexFont.setAttributes( rAttribs );
179 break;
181 return 0;
184 void FontSchemeContext::onEndElement()
186 switch( getCurrentElement() )
188 case A_TOKEN( majorFont ):
189 case A_TOKEN( minorFont ):
190 mxCharProps.reset();
191 break;
195 // ============================================================================
197 ThemeElementsContext::ThemeElementsContext( ContextHandler2Helper& rParent, Theme& rTheme ) :
198 ContextHandler2( rParent ),
199 mrTheme( rTheme )
203 ContextHandlerRef ThemeElementsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
205 // CT_BaseStyles
206 switch( nElement )
208 case A_TOKEN( clrScheme ): // CT_ColorScheme
209 return new clrSchemeContext( *this, mrTheme.getClrScheme() );
210 case A_TOKEN( fontScheme ): // CT_FontScheme
211 return new FontSchemeContext( *this, mrTheme.getFontScheme() );
213 case A_TOKEN( fmtScheme ): // CT_StyleMatrix
214 mrTheme.setStyleName( rAttribs.getString( XML_name ).get() );
215 return this;
217 case A_TOKEN( fillStyleLst ): // CT_FillStyleList
218 return new FillStyleListContext( *this, mrTheme.getFillStyleList() );
219 case A_TOKEN( lnStyleLst ): // CT_LineStyleList
220 return new LineStyleListContext( *this, mrTheme.getLineStyleList() );
221 case A_TOKEN( effectStyleLst ): // CT_EffectStyleList
222 return new EffectStyleListContext( *this, mrTheme.getEffectStyleList() );
223 case A_TOKEN( bgFillStyleLst ): // CT_BackgroundFillStyleList
224 return new FillStyleListContext( *this, mrTheme.getBgFillStyleList() );
226 return 0;
229 // ============================================================================
231 } // namespace drawingml
232 } // namespace oox
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */