fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / oox / source / drawingml / themeelementscontext.cxx
bloba171545e7df8fc83e838ef715a1cf89b57055d73
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 ContextHandler
42 public:
43 FillStyleListContext( ContextHandler& rParent, FillStyleList& rFillStyleList );
44 virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
46 private:
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)
59 switch( nElement )
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() );
70 return 0;
73 // ============================================================================
75 class LineStyleListContext : public ContextHandler
77 public:
78 LineStyleListContext( ContextHandler& rParent, LineStyleList& rLineStyleList );
79 virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
81 private:
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)
94 switch( nElement )
96 case A_TOKEN( ln ):
97 mrLineStyleList.push_back( LinePropertiesPtr( new LineProperties ) );
98 return new LinePropertiesContext( *this, xAttribs, *mrLineStyleList.back() );
100 return 0;
103 // ============================================================================
105 class EffectStyleListContext : public ContextHandler
107 public:
108 EffectStyleListContext( ContextHandler& rParent, EffectStyleList& rEffectStyleList );
109 virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
111 private:
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)
123 switch( nElement )
125 case A_TOKEN( effectStyle ):
126 mrEffectStyleList.push_back( EffectPropertiesPtr( new EffectProperties ) );
127 return this;
129 case A_TOKEN( effectLst ): // CT_EffectList
130 if( mrEffectStyleList.back() )
131 return new EffectPropertiesContext( *this, *mrEffectStyleList.back() );
132 break;
134 return 0;
137 // ============================================================================
139 class FontSchemeContext : public ContextHandler
141 public:
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);
146 private:
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 );
161 switch( nElement )
163 case A_TOKEN( majorFont ):
164 mxCharProps.reset( new TextCharacterProperties );
165 mrFontScheme[ XML_major ] = mxCharProps;
166 return this;
167 case A_TOKEN( minorFont ):
168 mxCharProps.reset( new TextCharacterProperties );
169 mrFontScheme[ XML_minor ] = mxCharProps;
170 return this;
172 case A_TOKEN( latin ):
173 if( mxCharProps.get() )
174 mxCharProps->maLatinFont.setAttributes( aAttribs );
175 break;
176 case A_TOKEN( ea ):
177 if( mxCharProps.get() )
178 mxCharProps->maAsianFont.setAttributes( aAttribs );
179 break;
180 case A_TOKEN( cs ):
181 if( mxCharProps.get() )
182 mxCharProps->maComplexFont.setAttributes( aAttribs );
183 break;
185 return 0;
188 void FontSchemeContext::endFastElement( sal_Int32 nElement ) throw (SAXException, RuntimeException)
190 switch( nElement )
192 case A_TOKEN( majorFont ):
193 case A_TOKEN( minorFont ):
194 mxCharProps.reset();
195 break;
199 // ============================================================================
201 ThemeElementsContext::ThemeElementsContext( ContextHandler& rParent, Theme& rTheme ) :
202 ContextHandler( rParent ),
203 mrTheme( rTheme )
207 Reference< XFastContextHandler > ThemeElementsContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
209 // CT_BaseStyles
210 Reference< XFastContextHandler > xRet;
211 switch( nElement )
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 ) );
220 return this;
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() );
231 return 0;
234 // ============================================================================
236 } // namespace drawingml
237 } // namespace oox
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */