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 "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
;
39 class FillStyleListContext
: public ContextHandler2
42 FillStyleListContext( ContextHandler2Helper
& rParent
, FillStyleList
& rFillStyleList
);
43 virtual ContextHandlerRef
onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
) SAL_OVERRIDE
;
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
)
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() );
71 class LineStyleListContext
: public ContextHandler2
74 LineStyleListContext( ContextHandler2Helper
& rParent
, LineStyleList
& rLineStyleList
);
75 virtual ContextHandlerRef
onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
) SAL_OVERRIDE
;
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
)
92 mrLineStyleList
.push_back( LinePropertiesPtr( new LineProperties
) );
93 return new LinePropertiesContext( *this, rAttribs
, *mrLineStyleList
.back() );
98 class EffectStyleListContext
: public ContextHandler2
101 EffectStyleListContext( ContextHandler2Helper
& rParent
, EffectStyleList
& rEffectStyleList
);
102 virtual ContextHandlerRef
onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
) SAL_OVERRIDE
;
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*/ )
118 case A_TOKEN( effectStyle
):
119 mrEffectStyleList
.push_back( EffectPropertiesPtr( new EffectProperties
) );
122 case A_TOKEN( effectLst
): // CT_EffectList
123 if( mrEffectStyleList
.back() )
124 return new EffectPropertiesContext( *this, *mrEffectStyleList
.back() );
130 class FontSchemeContext
: public ContextHandler2
133 FontSchemeContext( ContextHandler2Helper
& rParent
, FontScheme
& rFontScheme
);
134 virtual ContextHandlerRef
onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
) SAL_OVERRIDE
;
135 virtual void onEndElement() SAL_OVERRIDE
;
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
)
152 case A_TOKEN( majorFont
):
153 mxCharProps
.reset( new TextCharacterProperties
);
154 mrFontScheme
[ XML_major
] = mxCharProps
;
156 case A_TOKEN( minorFont
):
157 mxCharProps
.reset( new TextCharacterProperties
);
158 mrFontScheme
[ XML_minor
] = mxCharProps
;
161 case A_TOKEN( latin
):
162 if( mxCharProps
.get() )
163 mxCharProps
->maLatinFont
.setAttributes( rAttribs
);
166 if( mxCharProps
.get() )
167 mxCharProps
->maAsianFont
.setAttributes( rAttribs
);
170 if( mxCharProps
.get() )
171 mxCharProps
->maComplexFont
.setAttributes( rAttribs
);
177 void FontSchemeContext::onEndElement()
179 switch( getCurrentElement() )
181 case A_TOKEN( majorFont
):
182 case A_TOKEN( minorFont
):
188 ThemeElementsContext::ThemeElementsContext( ContextHandler2Helper
& rParent
, Theme
& rTheme
) :
189 ContextHandler2( rParent
),
194 ContextHandlerRef
ThemeElementsContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
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() );
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() );
220 } // namespace drawingml
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */