fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / oox / stylesfragment.cxx
blob10876fc98ab4594ae10cb208c1fe28935ad84e9c
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 "stylesfragment.hxx"
22 #include <oox/helper/attributelist.hxx>
24 namespace oox {
25 namespace xls {
27 using namespace ::oox::core;
29 IndexedColorsContext::IndexedColorsContext( WorkbookFragmentBase& rFragment ) :
30 WorkbookContextBase( rFragment )
34 ContextHandlerRef IndexedColorsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
36 switch( getCurrentElement() )
38 case XLS_TOKEN( indexedColors ):
39 if( nElement == XLS_TOKEN( rgbColor ) ) getStyles().importPaletteColor( rAttribs );
40 break;
42 return 0;
45 ContextHandlerRef IndexedColorsContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
47 switch( getCurrentElement() )
49 case BIFF12_ID_INDEXEDCOLORS:
50 if( nRecId == BIFF12_ID_RGBCOLOR ) getStyles().importPaletteColor( rStrm );
51 break;
53 return 0;
56 ContextHandlerRef FontContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
58 if( mxFont.get() )
59 mxFont->importAttribs( nElement, rAttribs );
60 return 0;
63 void BorderContext::onStartElement( const AttributeList& rAttribs )
65 if( mxBorder.get() && (getCurrentElement() == XLS_TOKEN( border )) )
66 mxBorder->importBorder( rAttribs );
69 ContextHandlerRef BorderContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
71 if( mxBorder.get() ) switch( getCurrentElement() )
73 case XLS_TOKEN( border ):
74 mxBorder->importStyle( nElement, rAttribs );
75 return this;
77 default:
78 if( nElement == XLS_TOKEN( color ) )
79 mxBorder->importColor( getCurrentElement(), rAttribs );
81 return 0;
84 ContextHandlerRef FillContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
86 if( mxFill.get() ) switch( getCurrentElement() )
88 case XLS_TOKEN( fill ):
89 switch( nElement )
91 case XLS_TOKEN( patternFill ): mxFill->importPatternFill( rAttribs ); return this;
92 case XLS_TOKEN( gradientFill ): mxFill->importGradientFill( rAttribs ); return this;
94 break;
95 case XLS_TOKEN( patternFill ):
96 switch( nElement )
98 case XLS_TOKEN( fgColor ): mxFill->importFgColor( rAttribs ); break;
99 case XLS_TOKEN( bgColor ): mxFill->importBgColor( rAttribs ); break;
101 break;
102 case XLS_TOKEN( gradientFill ):
103 if( nElement == XLS_TOKEN( stop ) )
105 mfGradPos = rAttribs.getDouble( XML_position, -1.0 );
106 return this;
108 break;
109 case XLS_TOKEN( stop ):
110 if( nElement == XLS_TOKEN( color ) )
111 mxFill->importColor( rAttribs, mfGradPos );
112 break;
114 return 0;
117 void XfContext::onStartElement( const AttributeList& rAttribs )
119 if( mxXf.get() && (getCurrentElement() == XLS_TOKEN( xf )) )
120 mxXf->importXf( rAttribs, mbCellXf );
123 ContextHandlerRef XfContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
125 if( mxXf.get() ) switch( getCurrentElement() )
127 case XLS_TOKEN( xf ):
128 switch( nElement )
130 case XLS_TOKEN( alignment ): mxXf->importAlignment( rAttribs ); break;
131 case XLS_TOKEN( protection ): mxXf->importProtection( rAttribs ); break;
133 break;
135 return 0;
138 ContextHandlerRef DxfContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
140 if( mxDxf.get() ) switch( getCurrentElement() )
142 case XLS_TOKEN( dxf ):
143 switch( nElement )
145 case XLS_TOKEN( font ): return new FontContext( *this, mxDxf->createFont() );
146 case XLS_TOKEN( border ): return new BorderContext( *this, mxDxf->createBorder() );
147 case XLS_TOKEN( fill ): return new FillContext( *this, mxDxf->createFill() );
149 case XLS_TOKEN( numFmt ): mxDxf->importNumFmt( rAttribs ); break;
150 #if 0
151 case XLS_TOKEN( alignment ): mxDxf->importAlignment( rAttribs ); break;
152 case XLS_TOKEN( protection ): mxDxf->importProtection( rAttribs ); break;
153 #endif
155 break;
157 return 0;
160 StylesFragment::StylesFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
161 WorkbookFragmentBase( rHelper, rFragmentPath )
165 ContextHandlerRef StylesFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
167 switch( getCurrentElement() )
169 case XML_ROOT_CONTEXT:
170 if( nElement == XLS_TOKEN( styleSheet ) ) return this;
171 break;
173 case XLS_TOKEN( styleSheet ):
174 switch( nElement )
176 case XLS_TOKEN( colors ):
177 case XLS_TOKEN( numFmts ):
178 case XLS_TOKEN( fonts ):
179 case XLS_TOKEN( borders ):
180 case XLS_TOKEN( fills ):
181 case XLS_TOKEN( cellXfs ):
182 case XLS_TOKEN( cellStyleXfs ):
183 case XLS_TOKEN( dxfs ):
184 case XLS_TOKEN( cellStyles ): return this;
186 break;
188 case XLS_TOKEN( colors ):
189 if( nElement == XLS_TOKEN( indexedColors ) ) return new IndexedColorsContext( *this );
190 break;
191 case XLS_TOKEN( numFmts ):
192 if( nElement == XLS_TOKEN( numFmt ) ) getStyles().importNumFmt( rAttribs );
193 break;
194 case XLS_TOKEN( fonts ):
195 if( nElement == XLS_TOKEN( font ) ) return new FontContext( *this, getStyles().createFont() );
196 break;
197 case XLS_TOKEN( borders ):
198 if( nElement == XLS_TOKEN( border ) ) return new BorderContext( *this, getStyles().createBorder() );
199 break;
200 case XLS_TOKEN( fills ):
201 if( nElement == XLS_TOKEN( fill ) ) return new FillContext( *this, getStyles().createFill() );
202 break;
203 case XLS_TOKEN( cellXfs ):
204 if( nElement == XLS_TOKEN( xf ) ) return new XfContext( *this, getStyles().createCellXf(), true );
205 break;
206 case XLS_TOKEN( cellStyleXfs ):
207 if( nElement == XLS_TOKEN( xf ) ) return new XfContext( *this, getStyles().createStyleXf(), false );
208 break;
209 case XLS_TOKEN( dxfs ):
210 if( nElement == XLS_TOKEN( dxf ) ) return new DxfContext( *this, getStyles().createDxf() );
211 break;
212 case XLS_TOKEN( cellStyles ):
213 if( nElement == XLS_TOKEN( cellStyle ) ) getStyles().importCellStyle( rAttribs );
214 break;
216 return 0;
219 ContextHandlerRef StylesFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
221 switch( getCurrentElement() )
223 case XML_ROOT_CONTEXT:
224 if( nRecId == BIFF12_ID_STYLESHEET ) return this;
225 break;
227 case BIFF12_ID_STYLESHEET:
228 switch( nRecId )
230 case BIFF12_ID_COLORS:
231 case BIFF12_ID_NUMFMTS:
232 case BIFF12_ID_FONTS:
233 case BIFF12_ID_BORDERS:
234 case BIFF12_ID_FILLS:
235 case BIFF12_ID_CELLXFS:
236 case BIFF12_ID_CELLSTYLEXFS:
237 case BIFF12_ID_DXFS:
238 case BIFF12_ID_CELLSTYLES: return this;
240 break;
242 case BIFF12_ID_COLORS:
243 if( nRecId == BIFF12_ID_INDEXEDCOLORS ) return new IndexedColorsContext( *this );
244 break;
245 case BIFF12_ID_NUMFMTS:
246 if( nRecId == BIFF12_ID_NUMFMT ) getStyles().importNumFmt( rStrm );
247 break;
248 case BIFF12_ID_FONTS:
249 if( nRecId == BIFF12_ID_FONT ) getStyles().createFont()->importFont( rStrm );
250 break;
251 case BIFF12_ID_BORDERS:
252 if( nRecId == BIFF12_ID_BORDER ) getStyles().createBorder()->importBorder( rStrm );
253 break;
254 case BIFF12_ID_FILLS:
255 if( nRecId == BIFF12_ID_FILL ) getStyles().createFill()->importFill( rStrm );
256 break;
257 case BIFF12_ID_CELLXFS:
258 if( nRecId == BIFF12_ID_XF ) getStyles().createCellXf()->importXf( rStrm, true );
259 break;
260 case BIFF12_ID_CELLSTYLEXFS:
261 if( nRecId == BIFF12_ID_XF ) getStyles().createStyleXf()->importXf( rStrm, false );
262 break;
263 case BIFF12_ID_DXFS:
264 if( nRecId == BIFF12_ID_DXF ) getStyles().createDxf()->importDxf( rStrm );
265 break;
266 case BIFF12_ID_CELLSTYLES:
267 if( nRecId == BIFF12_ID_CELLSTYLE ) getStyles().importCellStyle( rStrm );
268 break;
270 return 0;
273 const RecordInfo* StylesFragment::getRecordInfos() const
275 static const RecordInfo spRecInfos[] =
277 { BIFF12_ID_BORDERS, BIFF12_ID_BORDERS + 1 },
278 { BIFF12_ID_CELLSTYLES, BIFF12_ID_CELLSTYLES + 1 },
279 { BIFF12_ID_CELLSTYLEXFS, BIFF12_ID_CELLSTYLEXFS + 1 },
280 { BIFF12_ID_CELLXFS, BIFF12_ID_CELLXFS + 1 },
281 { BIFF12_ID_COLORS, BIFF12_ID_COLORS + 1 },
282 { BIFF12_ID_DXFS, BIFF12_ID_DXFS + 1 },
283 { BIFF12_ID_FILLS, BIFF12_ID_FILLS + 1 },
284 { BIFF12_ID_FONTS, BIFF12_ID_FONTS + 1 },
285 { BIFF12_ID_INDEXEDCOLORS, BIFF12_ID_INDEXEDCOLORS + 1 },
286 { BIFF12_ID_MRUCOLORS, BIFF12_ID_MRUCOLORS + 1 },
287 { BIFF12_ID_NUMFMTS, BIFF12_ID_NUMFMTS + 1 },
288 { BIFF12_ID_STYLESHEET, BIFF12_ID_STYLESHEET + 1 },
289 { BIFF12_ID_TABLESTYLES, BIFF12_ID_TABLESTYLES + 1 },
290 { -1, -1 }
292 return spRecInfos;
295 void StylesFragment::finalizeImport()
297 getStyles().finalizeImport();
300 } // namespace xls
301 } // namespace oox
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */