fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / oox / source / drawingml / chart / datasourcecontext.cxx
blobf4f6b95e00492038444a1678876857a91966a6c5
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/chart/datasourcecontext.hxx"
22 #include "oox/drawingml/chart/datasourcemodel.hxx"
24 namespace oox {
25 namespace drawingml {
26 namespace chart {
28 // ============================================================================
30 using ::oox::core::ContextHandler2Helper;
31 using ::oox::core::ContextHandlerRef;
33 // ============================================================================
35 DoubleSequenceContext::DoubleSequenceContext( ContextHandler2Helper& rParent, DataSequenceModel& rModel ) :
36 DataSequenceContextBase( rParent, rModel ),
37 mnPtIndex( -1 )
41 DoubleSequenceContext::~DoubleSequenceContext()
45 ContextHandlerRef DoubleSequenceContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
47 switch( getCurrentElement() )
49 case C_TOKEN( numRef ):
50 switch( nElement )
52 case C_TOKEN( f ):
53 case C_TOKEN( numCache ):
54 return this;
56 break;
58 case C_TOKEN( numCache ):
59 case C_TOKEN( numLit ):
60 switch( nElement )
62 case C_TOKEN( formatCode ):
63 return this;
64 case C_TOKEN( ptCount ):
65 mrModel.mnPointCount = rAttribs.getInteger( XML_val, -1 );
66 return 0;
67 case C_TOKEN( pt ):
68 mnPtIndex = rAttribs.getInteger( XML_idx, -1 );
69 return this;
71 break;
73 case C_TOKEN( pt ):
74 switch( nElement )
76 case C_TOKEN( v ):
77 return this;
79 break;
81 return 0;
84 void DoubleSequenceContext::onCharacters( const OUString& rChars )
86 switch( getCurrentElement() )
88 case C_TOKEN( f ):
89 mrModel.maFormula = rChars;
90 break;
91 case C_TOKEN( formatCode ):
92 mrModel.maFormatCode = rChars;
93 break;
94 case C_TOKEN( v ):
95 if( mnPtIndex >= 0 )
97 /* Import categories as String even though it could
98 * be values.
99 * n#810508: xVal needs to be imported as double
100 * TODO: NumberFormat conversion, remove the check then.
102 if( isParentElement( C_TOKEN( cat ), 4 ) )
103 mrModel.maData[ mnPtIndex ] <<= rChars;
104 else
105 mrModel.maData[ mnPtIndex ] <<= rChars.toDouble();
107 break;
111 // ============================================================================
113 StringSequenceContext::StringSequenceContext( ContextHandler2Helper& rParent, DataSequenceModel& rModel ) :
114 DataSequenceContextBase( rParent, rModel )
118 StringSequenceContext::~StringSequenceContext()
122 ContextHandlerRef StringSequenceContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
124 switch( getCurrentElement() )
126 case C_TOKEN( multiLvlStrRef ):
127 switch( nElement )
129 case C_TOKEN( f ):
130 return this;
132 break;
134 case C_TOKEN( strRef ):
135 switch( nElement )
137 case C_TOKEN( f ):
138 case C_TOKEN( strCache ):
139 return this;
141 break;
143 case C_TOKEN( strCache ):
144 case C_TOKEN( strLit ):
145 switch( nElement )
147 case C_TOKEN( ptCount ):
148 mrModel.mnPointCount = rAttribs.getInteger( XML_val, -1 );
149 return 0;
150 case C_TOKEN( pt ):
151 mnPtIndex = rAttribs.getInteger( XML_idx, -1 );
152 return this;
154 break;
156 case C_TOKEN( pt ):
157 switch( nElement )
159 case C_TOKEN( v ):
160 return this;
162 break;
164 return 0;
167 void StringSequenceContext::onCharacters( const OUString& rChars )
169 switch( getCurrentElement() )
171 case C_TOKEN( f ):
172 mrModel.maFormula = rChars;
173 break;
174 case C_TOKEN( v ):
175 if( mnPtIndex >= 0 )
176 mrModel.maData[ mnPtIndex ] <<= rChars;
177 break;
181 // ============================================================================
183 DataSourceContext::DataSourceContext( ContextHandler2Helper& rParent, DataSourceModel& rModel ) :
184 ContextBase< DataSourceModel >( rParent, rModel )
188 DataSourceContext::~DataSourceContext()
192 ContextHandlerRef DataSourceContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
194 switch( getCurrentElement() )
196 case C_TOKEN( cat ):
197 case C_TOKEN( xVal ):
198 switch( nElement )
200 case C_TOKEN( multiLvlStrRef ):
201 case C_TOKEN( strLit ):
202 case C_TOKEN( strRef ):
203 OSL_ENSURE( !mrModel.mxDataSeq, "DataSourceContext::onCreateContext - multiple data sequences" );
204 return new StringSequenceContext( *this, mrModel.mxDataSeq.create() );
206 case C_TOKEN( numLit ):
207 case C_TOKEN( numRef ):
208 OSL_ENSURE( !mrModel.mxDataSeq, "DataSourceContext::onCreateContext - multiple data sequences" );
209 return new DoubleSequenceContext( *this, mrModel.mxDataSeq.create() );
211 break;
213 case C_TOKEN( plus ):
214 case C_TOKEN( minus ):
215 case C_TOKEN( val ):
216 case C_TOKEN( yVal ):
217 case C_TOKEN( bubbleSize ):
218 switch( nElement )
220 case C_TOKEN( numLit ):
221 case C_TOKEN( numRef ):
222 OSL_ENSURE( !mrModel.mxDataSeq, "DataSourceContext::onCreateContext - multiple data sequences" );
223 return new DoubleSequenceContext( *this, mrModel.mxDataSeq.create() );
225 break;
227 return 0;
230 // ============================================================================
232 } // namespace chart
233 } // namespace drawingml
234 } // namespace oox
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */