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 ContextHandler
43 FillStyleListContext( ContextHandler
& rParent
, FillStyleList
& rFillStyleList
);
44 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& Attribs
) throw (SAXException
, RuntimeException
);
47 FillStyleList
& mrFillStyleList
;
50 FillStyleListContext::FillStyleListContext( ContextHandler
& rParent
, FillStyleList
& rFillStyleList
) :
51 ContextHandler( rParent
),
52 mrFillStyleList( rFillStyleList
)
56 Reference
< XFastContextHandler
> FillStyleListContext::createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& xAttribs
)
57 throw (SAXException
, RuntimeException
)
61 case A_TOKEN( noFill
):
62 case A_TOKEN( solidFill
):
63 case A_TOKEN( gradFill
):
64 case A_TOKEN( blipFill
):
65 case A_TOKEN( pattFill
):
66 case A_TOKEN( grpFill
):
67 mrFillStyleList
.push_back( FillPropertiesPtr( new FillProperties
) );
68 return FillPropertiesContext::createFillContext( *this, nElement
, xAttribs
, *mrFillStyleList
.back() );
73 // ============================================================================
75 class LineStyleListContext
: public ContextHandler
78 LineStyleListContext( ContextHandler
& rParent
, LineStyleList
& rLineStyleList
);
79 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& Attribs
) throw (SAXException
, RuntimeException
);
82 LineStyleList
& mrLineStyleList
;
85 LineStyleListContext::LineStyleListContext( ContextHandler
& rParent
, LineStyleList
& rLineStyleList
) :
86 ContextHandler( rParent
),
87 mrLineStyleList( rLineStyleList
)
91 Reference
< XFastContextHandler
> LineStyleListContext::createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& xAttribs
)
92 throw (SAXException
, RuntimeException
)
97 mrLineStyleList
.push_back( LinePropertiesPtr( new LineProperties
) );
98 return new LinePropertiesContext( *this, xAttribs
, *mrLineStyleList
.back() );
103 // ============================================================================
105 class EffectStyleListContext
: public ContextHandler
108 EffectStyleListContext( ContextHandler
& rParent
, EffectStyleList
& rEffectStyleList
);
109 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& Attribs
) throw (SAXException
, RuntimeException
);
112 EffectStyleList
& mrEffectStyleList
;
115 EffectStyleListContext::EffectStyleListContext( ContextHandler
& rParent
, EffectStyleList
& rEffectStyleList
) :
116 ContextHandler( rParent
),
117 mrEffectStyleList( rEffectStyleList
)
121 Reference
< XFastContextHandler
> EffectStyleListContext::createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& /*xAttribs*/ ) throw (SAXException
, RuntimeException
)
125 case A_TOKEN( effectStyle
):
126 mrEffectStyleList
.push_back( EffectPropertiesPtr( new EffectProperties
) );
129 case A_TOKEN( effectLst
): // CT_EffectList
130 if( mrEffectStyleList
.back() )
131 return new EffectPropertiesContext( *this, *mrEffectStyleList
.back() );
137 // ============================================================================
139 class FontSchemeContext
: public ContextHandler
142 FontSchemeContext( ContextHandler
& rParent
, FontScheme
& rFontScheme
);
143 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& Attribs
) throw (SAXException
, RuntimeException
);
144 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) throw (SAXException
, RuntimeException
);
147 FontScheme
& mrFontScheme
;
148 TextCharacterPropertiesPtr mxCharProps
;
151 FontSchemeContext::FontSchemeContext( ContextHandler
& rParent
, FontScheme
& rFontScheme
) :
152 ContextHandler( rParent
),
153 mrFontScheme( rFontScheme
)
157 Reference
< XFastContextHandler
> FontSchemeContext::createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& rxAttribs
)
158 throw (SAXException
, RuntimeException
)
160 AttributeList
aAttribs( rxAttribs
);
163 case A_TOKEN( majorFont
):
164 mxCharProps
.reset( new TextCharacterProperties
);
165 mrFontScheme
[ XML_major
] = mxCharProps
;
167 case A_TOKEN( minorFont
):
168 mxCharProps
.reset( new TextCharacterProperties
);
169 mrFontScheme
[ XML_minor
] = mxCharProps
;
172 case A_TOKEN( latin
):
173 if( mxCharProps
.get() )
174 mxCharProps
->maLatinFont
.setAttributes( aAttribs
);
177 if( mxCharProps
.get() )
178 mxCharProps
->maAsianFont
.setAttributes( aAttribs
);
181 if( mxCharProps
.get() )
182 mxCharProps
->maComplexFont
.setAttributes( aAttribs
);
188 void FontSchemeContext::endFastElement( sal_Int32 nElement
) throw (SAXException
, RuntimeException
)
192 case A_TOKEN( majorFont
):
193 case A_TOKEN( minorFont
):
199 // ============================================================================
201 ThemeElementsContext::ThemeElementsContext( ContextHandler
& rParent
, Theme
& rTheme
) :
202 ContextHandler( rParent
),
207 Reference
< XFastContextHandler
> ThemeElementsContext::createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
210 Reference
< XFastContextHandler
> xRet
;
213 case A_TOKEN( clrScheme
): // CT_ColorScheme
214 return new clrSchemeContext( *this, mrTheme
.getClrScheme() );
215 case A_TOKEN( fontScheme
): // CT_FontScheme
216 return new FontSchemeContext( *this, mrTheme
.getFontScheme() );
218 case A_TOKEN( fmtScheme
): // CT_StyleMatrix
219 mrTheme
.setStyleName( xAttribs
->getOptionalValue( XML_name
) );
222 case A_TOKEN( fillStyleLst
): // CT_FillStyleList
223 return new FillStyleListContext( *this, mrTheme
.getFillStyleList() );
224 case A_TOKEN( lnStyleLst
): // CT_LineStyleList
225 return new LineStyleListContext( *this, mrTheme
.getLineStyleList() );
226 case A_TOKEN( effectStyleLst
): // CT_EffectStyleList
227 return new EffectStyleListContext( *this, mrTheme
.getEffectStyleList() );
228 case A_TOKEN( bgFillStyleLst
): // CT_BackgroundFillStyleList
229 return new FillStyleListContext( *this, mrTheme
.getBgFillStyleList() );
234 // ============================================================================
236 } // namespace drawingml
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */