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/chart/datasourcecontext.hxx"
22 #include "oox/drawingml/chart/datasourcemodel.hxx"
28 // ============================================================================
30 using ::oox::core::ContextHandler2Helper
;
31 using ::oox::core::ContextHandlerRef
;
33 // ============================================================================
35 DoubleSequenceContext::DoubleSequenceContext( ContextHandler2Helper
& rParent
, DataSequenceModel
& rModel
) :
36 DataSequenceContextBase( rParent
, rModel
),
41 DoubleSequenceContext::~DoubleSequenceContext()
45 ContextHandlerRef
DoubleSequenceContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
47 switch( getCurrentElement() )
49 case C_TOKEN( numRef
):
53 case C_TOKEN( numCache
):
58 case C_TOKEN( numCache
):
59 case C_TOKEN( numLit
):
62 case C_TOKEN( formatCode
):
64 case C_TOKEN( ptCount
):
65 mrModel
.mnPointCount
= rAttribs
.getInteger( XML_val
, -1 );
68 mnPtIndex
= rAttribs
.getInteger( XML_idx
, -1 );
84 void DoubleSequenceContext::onCharacters( const OUString
& rChars
)
86 switch( getCurrentElement() )
89 mrModel
.maFormula
= rChars
;
91 case C_TOKEN( formatCode
):
92 mrModel
.maFormatCode
= rChars
;
97 /* Import categories as String even though it could
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
;
105 mrModel
.maData
[ mnPtIndex
] <<= rChars
.toDouble();
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
):
134 case C_TOKEN( strRef
):
138 case C_TOKEN( strCache
):
143 case C_TOKEN( strCache
):
144 case C_TOKEN( strLit
):
147 case C_TOKEN( ptCount
):
148 mrModel
.mnPointCount
= rAttribs
.getInteger( XML_val
, -1 );
151 mnPtIndex
= rAttribs
.getInteger( XML_idx
, -1 );
167 void StringSequenceContext::onCharacters( const OUString
& rChars
)
169 switch( getCurrentElement() )
172 mrModel
.maFormula
= rChars
;
176 mrModel
.maData
[ mnPtIndex
] <<= rChars
;
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() )
197 case C_TOKEN( xVal
):
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() );
213 case C_TOKEN( plus
):
214 case C_TOKEN( minus
):
216 case C_TOKEN( yVal
):
217 case C_TOKEN( bubbleSize
):
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() );
230 // ============================================================================
233 } // namespace drawingml
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */