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 "drawingml/chart/datasourcecontext.hxx"
22 #include "oox/drawingml/chart/datasourcemodel.hxx"
24 #include <osl/diagnose.h>
30 using ::oox::core::ContextHandler2Helper
;
31 using ::oox::core::ContextHandlerRef
;
33 DoubleSequenceContext::DoubleSequenceContext( ContextHandler2Helper
& rParent
, DataSequenceModel
& rModel
) :
34 DataSequenceContextBase( rParent
, rModel
),
39 DoubleSequenceContext::~DoubleSequenceContext()
43 ContextHandlerRef
DoubleSequenceContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
45 switch( getCurrentElement() )
47 case C_TOKEN( numRef
):
51 case C_TOKEN( numCache
):
56 case C_TOKEN( numCache
):
57 case C_TOKEN( numLit
):
60 case C_TOKEN( formatCode
):
62 case C_TOKEN( ptCount
):
63 mrModel
.mnPointCount
= rAttribs
.getInteger( XML_val
, -1 );
66 mnPtIndex
= rAttribs
.getInteger( XML_idx
, -1 );
82 void DoubleSequenceContext::onCharacters( const OUString
& rChars
)
84 switch( getCurrentElement() )
87 mrModel
.maFormula
= rChars
;
89 case C_TOKEN( formatCode
):
90 mrModel
.maFormatCode
= rChars
;
95 /* Import categories as String even though it could
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
;
103 mrModel
.maData
[ mnPtIndex
] <<= rChars
.toDouble();
109 StringSequenceContext::StringSequenceContext( ContextHandler2Helper
& rParent
, DataSequenceModel
& rModel
)
110 : DataSequenceContextBase( rParent
, rModel
)
115 StringSequenceContext::~StringSequenceContext()
119 ContextHandlerRef
StringSequenceContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
121 switch( getCurrentElement() )
123 case C_TOKEN( multiLvlStrRef
):
131 case C_TOKEN( strRef
):
135 case C_TOKEN( strCache
):
140 case C_TOKEN( strCache
):
141 case C_TOKEN( strLit
):
144 case C_TOKEN( ptCount
):
145 mrModel
.mnPointCount
= rAttribs
.getInteger( XML_val
, -1 );
148 mnPtIndex
= rAttribs
.getInteger( XML_idx
, -1 );
164 void StringSequenceContext::onCharacters( const OUString
& rChars
)
166 switch( getCurrentElement() )
169 mrModel
.maFormula
= rChars
;
173 mrModel
.maData
[ mnPtIndex
] <<= rChars
;
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() )
192 case C_TOKEN( xVal
):
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() );
208 case C_TOKEN( plus
):
209 case C_TOKEN( minus
):
211 case C_TOKEN( yVal
):
212 case C_TOKEN( bubbleSize
):
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() );
226 } // namespace drawingml
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */