1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datasourcecontext.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "oox/drawingml/chart/datasourcecontext.hxx"
33 #include "oox/drawingml/chart/datasourcemodel.hxx"
35 using ::rtl::OUString
;
36 using ::oox::core::ContextHandler2Helper
;
37 using ::oox::core::ContextHandlerRef
;
43 // ============================================================================
45 DoubleSequenceContext::DoubleSequenceContext( ContextHandler2Helper
& rParent
, DataSequenceModel
& rModel
) :
46 DataSequenceContextBase( rParent
, rModel
),
51 DoubleSequenceContext::~DoubleSequenceContext()
55 ContextHandlerRef
DoubleSequenceContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
57 switch( getCurrentElement() )
59 case C_TOKEN( numRef
):
63 case C_TOKEN( numCache
):
68 case C_TOKEN( numCache
):
69 case C_TOKEN( numLit
):
72 case C_TOKEN( formatCode
):
74 case C_TOKEN( ptCount
):
75 mrModel
.mnPointCount
= rAttribs
.getInteger( XML_val
, -1 );
78 mnPtIndex
= rAttribs
.getInteger( XML_idx
, -1 );
94 void DoubleSequenceContext::onEndElement( const OUString
& rChars
)
96 switch( getCurrentElement() )
99 mrModel
.maFormula
= rChars
;
101 case C_TOKEN( formatCode
):
102 mrModel
.maFormatCode
= rChars
;
106 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::onEndElement( 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