fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / chart / datasourcecontext.cxx
blob946b5bdb00d15ba21aaabe4de0f0d87c7851abec
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 "drawingml/chart/datasourcecontext.hxx"
22 #include "oox/drawingml/chart/datasourcemodel.hxx"
24 #include <osl/diagnose.h>
26 namespace oox {
27 namespace drawingml {
28 namespace chart {
30 using ::oox::core::ContextHandler2Helper;
31 using ::oox::core::ContextHandlerRef;
33 DoubleSequenceContext::DoubleSequenceContext( ContextHandler2Helper& rParent, DataSequenceModel& rModel ) :
34 DataSequenceContextBase( rParent, rModel ),
35 mnPtIndex( -1 )
39 DoubleSequenceContext::~DoubleSequenceContext()
43 ContextHandlerRef DoubleSequenceContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
45 switch( getCurrentElement() )
47 case C_TOKEN( numRef ):
48 switch( nElement )
50 case C_TOKEN( f ):
51 case C_TOKEN( numCache ):
52 return this;
54 break;
56 case C_TOKEN( numCache ):
57 case C_TOKEN( numLit ):
58 switch( nElement )
60 case C_TOKEN( formatCode ):
61 return this;
62 case C_TOKEN( ptCount ):
63 mrModel.mnPointCount = rAttribs.getInteger( XML_val, -1 );
64 return 0;
65 case C_TOKEN( pt ):
66 mnPtIndex = rAttribs.getInteger( XML_idx, -1 );
67 return this;
69 break;
71 case C_TOKEN( pt ):
72 switch( nElement )
74 case C_TOKEN( v ):
75 return this;
77 break;
79 return 0;
82 void DoubleSequenceContext::onCharacters( const OUString& rChars )
84 switch( getCurrentElement() )
86 case C_TOKEN( f ):
87 mrModel.maFormula = rChars;
88 break;
89 case C_TOKEN( formatCode ):
90 mrModel.maFormatCode = rChars;
91 break;
92 case C_TOKEN( v ):
93 if( mnPtIndex >= 0 )
95 /* Import categories as String even though it could
96 * be values.
97 * n#810508: xVal needs to be imported as double
98 * TODO: NumberFormat conversion, remove the check then.
100 if( isParentElement( C_TOKEN( cat ), 4 ) )
101 mrModel.maData[ mnPtIndex ] <<= rChars;
102 else
103 mrModel.maData[ mnPtIndex ] <<= rChars.toDouble();
105 break;
109 StringSequenceContext::StringSequenceContext( ContextHandler2Helper& rParent, DataSequenceModel& rModel )
110 : DataSequenceContextBase( rParent, rModel )
111 , mnPtIndex(-1)
115 StringSequenceContext::~StringSequenceContext()
119 ContextHandlerRef StringSequenceContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
121 switch( getCurrentElement() )
123 case C_TOKEN( multiLvlStrRef ):
124 switch( nElement )
126 case C_TOKEN( f ):
127 return this;
129 break;
131 case C_TOKEN( strRef ):
132 switch( nElement )
134 case C_TOKEN( f ):
135 case C_TOKEN( strCache ):
136 return this;
138 break;
140 case C_TOKEN( strCache ):
141 case C_TOKEN( strLit ):
142 switch( nElement )
144 case C_TOKEN( ptCount ):
145 mrModel.mnPointCount = rAttribs.getInteger( XML_val, -1 );
146 return 0;
147 case C_TOKEN( pt ):
148 mnPtIndex = rAttribs.getInteger( XML_idx, -1 );
149 return this;
151 break;
153 case C_TOKEN( pt ):
154 switch( nElement )
156 case C_TOKEN( v ):
157 return this;
159 break;
161 return 0;
164 void StringSequenceContext::onCharacters( const OUString& rChars )
166 switch( getCurrentElement() )
168 case C_TOKEN( f ):
169 mrModel.maFormula = rChars;
170 break;
171 case C_TOKEN( v ):
172 if( mnPtIndex >= 0 )
173 mrModel.maData[ mnPtIndex ] <<= rChars;
174 break;
178 DataSourceContext::DataSourceContext( ContextHandler2Helper& rParent, DataSourceModel& rModel ) :
179 ContextBase< DataSourceModel >( rParent, rModel )
183 DataSourceContext::~DataSourceContext()
187 ContextHandlerRef DataSourceContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
189 switch( getCurrentElement() )
191 case C_TOKEN( cat ):
192 case C_TOKEN( xVal ):
193 switch( nElement )
195 case C_TOKEN( multiLvlStrRef ):
196 case C_TOKEN( strLit ):
197 case C_TOKEN( strRef ):
198 OSL_ENSURE( !mrModel.mxDataSeq, "DataSourceContext::onCreateContext - multiple data sequences" );
199 return new StringSequenceContext( *this, mrModel.mxDataSeq.create() );
201 case C_TOKEN( numLit ):
202 case C_TOKEN( numRef ):
203 OSL_ENSURE( !mrModel.mxDataSeq, "DataSourceContext::onCreateContext - multiple data sequences" );
204 return new DoubleSequenceContext( *this, mrModel.mxDataSeq.create() );
206 break;
208 case C_TOKEN( plus ):
209 case C_TOKEN( minus ):
210 case C_TOKEN( val ):
211 case C_TOKEN( yVal ):
212 case C_TOKEN( bubbleSize ):
213 switch( nElement )
215 case C_TOKEN( numLit ):
216 case C_TOKEN( numRef ):
217 OSL_ENSURE( !mrModel.mxDataSeq, "DataSourceContext::onCreateContext - multiple data sequences" );
218 return new DoubleSequenceContext( *this, mrModel.mxDataSeq.create() );
220 break;
222 return 0;
225 } // namespace chart
226 } // namespace drawingml
227 } // namespace oox
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */