fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / themeelementscontext.cxx
blobd28150b223627f9c590b7c6c1cf5b82984c98ca8
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 "drawingml/themeelementscontext.hxx"
21 #include "drawingml/clrschemecontext.hxx"
22 #include "oox/drawingml/lineproperties.hxx"
23 #include "drawingml/linepropertiescontext.hxx"
24 #include "oox/drawingml/fillproperties.hxx"
25 #include "drawingml/fillpropertiesgroupcontext.hxx"
26 #include "drawingml/textcharacterproperties.hxx"
27 #include "oox/drawingml/theme.hxx"
28 #include "oox/helper/attributelist.hxx"
29 #include "effectproperties.hxx"
30 #include "effectpropertiescontext.hxx"
32 using namespace ::oox::core;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::xml::sax;
36 namespace oox {
37 namespace drawingml {
39 class FillStyleListContext : public ContextHandler2
41 public:
42 FillStyleListContext( ContextHandler2Helper& rParent, FillStyleList& rFillStyleList );
43 virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
45 private:
46 FillStyleList& mrFillStyleList;
49 FillStyleListContext::FillStyleListContext( ContextHandler2Helper& rParent, FillStyleList& rFillStyleList ) :
50 ContextHandler2( rParent ),
51 mrFillStyleList( rFillStyleList )
55 ContextHandlerRef FillStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
57 switch( nElement )
59 case A_TOKEN( noFill ):
60 case A_TOKEN( solidFill ):
61 case A_TOKEN( gradFill ):
62 case A_TOKEN( blipFill ):
63 case A_TOKEN( pattFill ):
64 case A_TOKEN( grpFill ):
65 mrFillStyleList.push_back( FillPropertiesPtr( new FillProperties ) );
66 return FillPropertiesContext::createFillContext( *this, nElement, rAttribs, *mrFillStyleList.back() );
68 return 0;
71 class LineStyleListContext : public ContextHandler2
73 public:
74 LineStyleListContext( ContextHandler2Helper& rParent, LineStyleList& rLineStyleList );
75 virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
77 private:
78 LineStyleList& mrLineStyleList;
81 LineStyleListContext::LineStyleListContext( ContextHandler2Helper& rParent, LineStyleList& rLineStyleList ) :
82 ContextHandler2( rParent ),
83 mrLineStyleList( rLineStyleList )
87 ContextHandlerRef LineStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
89 switch( nElement )
91 case A_TOKEN( ln ):
92 mrLineStyleList.push_back( LinePropertiesPtr( new LineProperties ) );
93 return new LinePropertiesContext( *this, rAttribs, *mrLineStyleList.back() );
95 return 0;
98 class EffectStyleListContext : public ContextHandler2
100 public:
101 EffectStyleListContext( ContextHandler2Helper& rParent, EffectStyleList& rEffectStyleList );
102 virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
104 private:
105 EffectStyleList& mrEffectStyleList;
108 EffectStyleListContext::EffectStyleListContext( ContextHandler2Helper& rParent, EffectStyleList& rEffectStyleList ) :
109 ContextHandler2( rParent ),
110 mrEffectStyleList( rEffectStyleList )
114 ContextHandlerRef EffectStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
116 switch( nElement )
118 case A_TOKEN( effectStyle ):
119 mrEffectStyleList.push_back( EffectPropertiesPtr( new EffectProperties ) );
120 return this;
122 case A_TOKEN( effectLst ): // CT_EffectList
123 if( mrEffectStyleList.back() )
124 return new EffectPropertiesContext( *this, *mrEffectStyleList.back() );
125 break;
127 return 0;
130 class FontSchemeContext : public ContextHandler2
132 public:
133 FontSchemeContext( ContextHandler2Helper& rParent, FontScheme& rFontScheme );
134 virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
135 virtual void onEndElement() SAL_OVERRIDE;
137 private:
138 FontScheme& mrFontScheme;
139 TextCharacterPropertiesPtr mxCharProps;
142 FontSchemeContext::FontSchemeContext( ContextHandler2Helper& rParent, FontScheme& rFontScheme ) :
143 ContextHandler2( rParent ),
144 mrFontScheme( rFontScheme )
148 ContextHandlerRef FontSchemeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
150 switch( nElement )
152 case A_TOKEN( majorFont ):
153 mxCharProps.reset( new TextCharacterProperties );
154 mrFontScheme[ XML_major ] = mxCharProps;
155 return this;
156 case A_TOKEN( minorFont ):
157 mxCharProps.reset( new TextCharacterProperties );
158 mrFontScheme[ XML_minor ] = mxCharProps;
159 return this;
161 case A_TOKEN( latin ):
162 if( mxCharProps.get() )
163 mxCharProps->maLatinFont.setAttributes( rAttribs );
164 break;
165 case A_TOKEN( ea ):
166 if( mxCharProps.get() )
167 mxCharProps->maAsianFont.setAttributes( rAttribs );
168 break;
169 case A_TOKEN( cs ):
170 if( mxCharProps.get() )
171 mxCharProps->maComplexFont.setAttributes( rAttribs );
172 break;
174 return 0;
177 void FontSchemeContext::onEndElement()
179 switch( getCurrentElement() )
181 case A_TOKEN( majorFont ):
182 case A_TOKEN( minorFont ):
183 mxCharProps.reset();
184 break;
188 ThemeElementsContext::ThemeElementsContext( ContextHandler2Helper& rParent, Theme& rTheme ) :
189 ContextHandler2( rParent ),
190 mrTheme( rTheme )
194 ContextHandlerRef ThemeElementsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
196 // CT_BaseStyles
197 switch( nElement )
199 case A_TOKEN( clrScheme ): // CT_ColorScheme
200 return new clrSchemeContext( *this, mrTheme.getClrScheme() );
201 case A_TOKEN( fontScheme ): // CT_FontScheme
202 return new FontSchemeContext( *this, mrTheme.getFontScheme() );
204 case A_TOKEN( fmtScheme ): // CT_StyleMatrix
205 mrTheme.setStyleName( rAttribs.getString( XML_name ).get() );
206 return this;
208 case A_TOKEN( fillStyleLst ): // CT_FillStyleList
209 return new FillStyleListContext( *this, mrTheme.getFillStyleList() );
210 case A_TOKEN( lnStyleLst ): // CT_LineStyleList
211 return new LineStyleListContext( *this, mrTheme.getLineStyleList() );
212 case A_TOKEN( effectStyleLst ): // CT_EffectStyleList
213 return new EffectStyleListContext( *this, mrTheme.getEffectStyleList() );
214 case A_TOKEN( bgFillStyleLst ): // CT_BackgroundFillStyleList
215 return new FillStyleListContext( *this, mrTheme.getBgFillStyleList() );
217 return 0;
220 } // namespace drawingml
221 } // namespace oox
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */