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/.
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
;
38 // ============================================================================
40 class FillStyleListContext
: public ContextHandler2
43 FillStyleListContext( ContextHandler2Helper
& rParent
, FillStyleList
& rFillStyleList
);
44 virtual ContextHandlerRef
onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
) SAL_OVERRIDE
;
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
)
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() );
72 // ============================================================================
74 class LineStyleListContext
: public ContextHandler2
77 LineStyleListContext( ContextHandler2Helper
& rParent
, LineStyleList
& rLineStyleList
);
78 virtual ContextHandlerRef
onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
) SAL_OVERRIDE
;
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
)
95 mrLineStyleList
.push_back( LinePropertiesPtr( new LineProperties
) );
96 return new LinePropertiesContext( *this, rAttribs
, *mrLineStyleList
.back() );
101 // ============================================================================
103 class EffectStyleListContext
: public ContextHandler2
106 EffectStyleListContext( ContextHandler2Helper
& rParent
, EffectStyleList
& rEffectStyleList
);
107 virtual ContextHandlerRef
onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
) SAL_OVERRIDE
;
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*/ )
123 case A_TOKEN( effectStyle
):
124 mrEffectStyleList
.push_back( EffectPropertiesPtr( new EffectProperties
) );
127 case A_TOKEN( effectLst
): // CT_EffectList
128 if( mrEffectStyleList
.back() )
129 return new EffectPropertiesContext( *this, *mrEffectStyleList
.back() );
135 // ============================================================================
137 class FontSchemeContext
: public ContextHandler2
140 FontSchemeContext( ContextHandler2Helper
& rParent
, FontScheme
& rFontScheme
);
141 virtual ContextHandlerRef
onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
) SAL_OVERRIDE
;
142 virtual void onEndElement() SAL_OVERRIDE
;
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
)
159 case A_TOKEN( majorFont
):
160 mxCharProps
.reset( new TextCharacterProperties
);
161 mrFontScheme
[ XML_major
] = mxCharProps
;
163 case A_TOKEN( minorFont
):
164 mxCharProps
.reset( new TextCharacterProperties
);
165 mrFontScheme
[ XML_minor
] = mxCharProps
;
168 case A_TOKEN( latin
):
169 if( mxCharProps
.get() )
170 mxCharProps
->maLatinFont
.setAttributes( rAttribs
);
173 if( mxCharProps
.get() )
174 mxCharProps
->maAsianFont
.setAttributes( rAttribs
);
177 if( mxCharProps
.get() )
178 mxCharProps
->maComplexFont
.setAttributes( rAttribs
);
184 void FontSchemeContext::onEndElement()
186 switch( getCurrentElement() )
188 case A_TOKEN( majorFont
):
189 case A_TOKEN( minorFont
):
195 // ============================================================================
197 ThemeElementsContext::ThemeElementsContext( ContextHandler2Helper
& rParent
, Theme
& rTheme
) :
198 ContextHandler2( rParent
),
203 ContextHandlerRef
ThemeElementsContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
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() );
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() );
229 // ============================================================================
231 } // namespace drawingml
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */