xref: /AOO41X/main/xmloff/source/chart/SchXMLSeries2Context.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "SchXMLSeries2Context.hxx"
32*cdf0e10cSrcweir #include "SchXMLPlotAreaContext.hxx"
33*cdf0e10cSrcweir #include "SchXMLSeriesHelper.hxx"
34*cdf0e10cSrcweir #include "SchXMLTools.hxx"
35*cdf0e10cSrcweir #include "PropertyMap.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/chart2/XDataSeries.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/chart2/XRegressionCurve.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataSink.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataReceiver.hpp>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisAssign.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/chart/ChartSymbolType.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/chart/ChartLegendPosition.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/embed/Aspects.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/embed/XVisualObject.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir // header for define DBG_ERROR1
53*cdf0e10cSrcweir #include <tools/debug.hxx>
54*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
55*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
56*cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
57*cdf0e10cSrcweir #ifndef _XMLOFF_NMSPMAP_HX
58*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
59*cdf0e10cSrcweir #endif
60*cdf0e10cSrcweir #include "SchXMLImport.hxx"
61*cdf0e10cSrcweir // header for class XMLPropStyleContext
62*cdf0e10cSrcweir #include <xmloff/prstylei.hxx>
63*cdf0e10cSrcweir #include <xmloff/xmlprmap.hxx>
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir #include <typeinfo>
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir using namespace ::com::sun::star;
68*cdf0e10cSrcweir using namespace ::xmloff::token;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
71*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
72*cdf0e10cSrcweir using ::rtl::OUString;
73*cdf0e10cSrcweir using ::rtl::OUStringBuffer;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir // ================================================================================
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir namespace
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir class SchXMLDomain2Context : public SvXMLImportContext
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir private:
83*cdf0e10cSrcweir 	SchXMLImportHelper& mrImportHelper;
84*cdf0e10cSrcweir 	::std::vector< OUString > & mrAddresses;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir public:
87*cdf0e10cSrcweir 	SchXMLDomain2Context( SchXMLImportHelper& rImpHelper,
88*cdf0e10cSrcweir                           SvXMLImport& rImport,
89*cdf0e10cSrcweir                           sal_uInt16 nPrefix,
90*cdf0e10cSrcweir                           const rtl::OUString& rLocalName,
91*cdf0e10cSrcweir                           ::std::vector< OUString > & rAddresses );
92*cdf0e10cSrcweir 	virtual ~SchXMLDomain2Context();
93*cdf0e10cSrcweir 	virtual void StartElement( const Reference< xml::sax::XAttributeList >& xAttrList );
94*cdf0e10cSrcweir };
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir SchXMLDomain2Context::SchXMLDomain2Context(
97*cdf0e10cSrcweir 	SchXMLImportHelper& rImpHelper,
98*cdf0e10cSrcweir 	SvXMLImport& rImport,
99*cdf0e10cSrcweir 	sal_uInt16 nPrefix,
100*cdf0e10cSrcweir 	const rtl::OUString& rLocalName,
101*cdf0e10cSrcweir 	::std::vector< ::rtl::OUString > & rAddresses ) :
102*cdf0e10cSrcweir 		SvXMLImportContext( rImport, nPrefix, rLocalName ),
103*cdf0e10cSrcweir 		mrImportHelper( rImpHelper ),
104*cdf0e10cSrcweir 		mrAddresses( rAddresses )
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir SchXMLDomain2Context::~SchXMLDomain2Context()
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir }
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir void SchXMLDomain2Context::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 	for( sal_Int16 i = 0; i < nAttrCount; i++ )
117*cdf0e10cSrcweir 	{
118*cdf0e10cSrcweir 		rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
119*cdf0e10cSrcweir 		rtl::OUString aLocalName;
120*cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 		if( nPrefix == XML_NAMESPACE_TABLE &&
123*cdf0e10cSrcweir 			IsXMLToken( aLocalName, XML_CELL_RANGE_ADDRESS ) )
124*cdf0e10cSrcweir 		{
125*cdf0e10cSrcweir             Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
126*cdf0e10cSrcweir             mrAddresses.push_back( xAttrList->getValueByIndex( i ));
127*cdf0e10cSrcweir 		}
128*cdf0e10cSrcweir 	}
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir void lcl_setAutomaticSymbolSize( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const SvXMLImport& rImport )
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir     awt::Size aSymbolSize(140,140);//old default for standard sized charts 7cm height
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     double fScale = 1;
136*cdf0e10cSrcweir     uno::Reference< chart::XChartDocument > xChartDoc( rImport.GetModel(), uno::UNO_QUERY );
137*cdf0e10cSrcweir     if( xChartDoc.is() )
138*cdf0e10cSrcweir     {
139*cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xLegendProp( xChartDoc->getLegend(), uno::UNO_QUERY );
140*cdf0e10cSrcweir         chart::ChartLegendPosition aLegendPosition = chart::ChartLegendPosition_NONE;
141*cdf0e10cSrcweir         if( xLegendProp.is() && (xLegendProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Alignment" ))) >>= aLegendPosition)
142*cdf0e10cSrcweir             && chart::ChartLegendPosition_NONE != aLegendPosition )
143*cdf0e10cSrcweir         {
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir             double fFontHeight = 6.0;
146*cdf0e10cSrcweir             if( xLegendProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ))) >>= fFontHeight )
147*cdf0e10cSrcweir                 fScale = 0.75*fFontHeight/6.0;
148*cdf0e10cSrcweir         }
149*cdf0e10cSrcweir         else
150*cdf0e10cSrcweir         {
151*cdf0e10cSrcweir             uno::Reference< embed::XVisualObject > xVisualObject( rImport.GetModel(), uno::UNO_QUERY );
152*cdf0e10cSrcweir             if( xVisualObject.is() )
153*cdf0e10cSrcweir             {
154*cdf0e10cSrcweir                 awt::Size aPageSize( xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ) );
155*cdf0e10cSrcweir                 fScale = aPageSize.Height/7000.0;
156*cdf0e10cSrcweir             }
157*cdf0e10cSrcweir         }
158*cdf0e10cSrcweir         if( fScale>0 )
159*cdf0e10cSrcweir         {
160*cdf0e10cSrcweir             aSymbolSize.Height = static_cast<sal_Int32>( fScale * aSymbolSize.Height );
161*cdf0e10cSrcweir             aSymbolSize.Width = aSymbolSize.Height;
162*cdf0e10cSrcweir         }
163*cdf0e10cSrcweir     }
164*cdf0e10cSrcweir     xSeriesOrPointProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize")),uno::makeAny( aSymbolSize ));
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir void lcl_setSymbolSizeIfNeeded( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const SvXMLImport& rImport )
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir     if( !xSeriesOrPointProp.is() )
170*cdf0e10cSrcweir         return;
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     sal_Int32 nSymbolType = chart::ChartSymbolType::NONE;
173*cdf0e10cSrcweir     if( xSeriesOrPointProp.is() && ( xSeriesOrPointProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolType"))) >>= nSymbolType) )
174*cdf0e10cSrcweir     {
175*cdf0e10cSrcweir         if(chart::ChartSymbolType::NONE!=nSymbolType)
176*cdf0e10cSrcweir         {
177*cdf0e10cSrcweir             if( chart::ChartSymbolType::BITMAPURL==nSymbolType )
178*cdf0e10cSrcweir             {
179*cdf0e10cSrcweir                 //set special size for graphics to indicate to use the bitmap size itself
180*cdf0e10cSrcweir                 xSeriesOrPointProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize")),uno::makeAny( awt::Size(-1,-1) ));
181*cdf0e10cSrcweir             }
182*cdf0e10cSrcweir             else
183*cdf0e10cSrcweir             {
184*cdf0e10cSrcweir                 lcl_setAutomaticSymbolSize( xSeriesOrPointProp, rImport );
185*cdf0e10cSrcweir             }
186*cdf0e10cSrcweir         }
187*cdf0e10cSrcweir     }
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir void lcl_resetSymbolSizeForPointsIfNecessary( const uno::Reference< beans::XPropertySet >& xPointProp, const SvXMLImport& rImport
191*cdf0e10cSrcweir     , const XMLPropStyleContext * pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir     uno::Any aASymbolSize( SchXMLTools::getPropertyFromContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize")), pPropStyleContext, pStylesCtxt ) );
194*cdf0e10cSrcweir     if( !aASymbolSize.hasValue() )
195*cdf0e10cSrcweir         lcl_setSymbolSizeIfNeeded( xPointProp, rImport );
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir void lcl_insertErrorBarLSequencesToMap(
199*cdf0e10cSrcweir     tSchXMLLSequencesPerIndex & rInOutMap,
200*cdf0e10cSrcweir     const uno::Reference< beans::XPropertySet > & xSeriesProp,
201*cdf0e10cSrcweir     bool bYError = true )
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir     Reference< chart2::data::XDataSource > xErrorBarSource;
204*cdf0e10cSrcweir     const OUString aPropName(
205*cdf0e10cSrcweir         bYError
206*cdf0e10cSrcweir         ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorBarY" ))
207*cdf0e10cSrcweir         : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorBarX" )));
208*cdf0e10cSrcweir     if( ( xSeriesProp->getPropertyValue( aPropName ) >>= xErrorBarSource ) &&
209*cdf0e10cSrcweir         xErrorBarSource.is() )
210*cdf0e10cSrcweir     {
211*cdf0e10cSrcweir         Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSequences(
212*cdf0e10cSrcweir             xErrorBarSource->getDataSequences());
213*cdf0e10cSrcweir         for( sal_Int32 nIndex = 0; nIndex < aLSequences.getLength(); ++nIndex )
214*cdf0e10cSrcweir         {
215*cdf0e10cSrcweir             // use "0" as data index. This is ok, as it is not used for error bars
216*cdf0e10cSrcweir             rInOutMap.insert(
217*cdf0e10cSrcweir                 tSchXMLLSequencesPerIndex::value_type(
218*cdf0e10cSrcweir                     tSchXMLIndexWithPart( 0, SCH_XML_PART_ERROR_BARS ), aLSequences[ nIndex ] ));
219*cdf0e10cSrcweir         }
220*cdf0e10cSrcweir     }
221*cdf0e10cSrcweir }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir Reference< chart2::data::XLabeledDataSequence > lcl_createAndAddSequenceToSeries( const rtl::OUString& rRole
224*cdf0e10cSrcweir         , const rtl::OUString& rRange
225*cdf0e10cSrcweir         , const Reference< chart2::XChartDocument >& xChartDoc
226*cdf0e10cSrcweir         , const Reference< chart2::XDataSeries >& xSeries )
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir     Reference< chart2::data::XLabeledDataSequence > xLabeledSeq;
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     Reference< chart2::data::XDataSource > xSeriesSource( xSeries,uno::UNO_QUERY );
231*cdf0e10cSrcweir     Reference< chart2::data::XDataSink > xSeriesSink( xSeries, uno::UNO_QUERY );
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     if( !(rRange.getLength() && xChartDoc.is() && xSeriesSource.is() && xSeriesSink.is()) )
234*cdf0e10cSrcweir         return xLabeledSeq;
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir     // create a new sequence
237*cdf0e10cSrcweir     xLabeledSeq = SchXMLTools::GetNewLabeledDataSequence();
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     // set values at the new sequence
240*cdf0e10cSrcweir     Reference< chart2::data::XDataSequence > xSeq = SchXMLTools::CreateDataSequence( rRange, xChartDoc );
241*cdf0e10cSrcweir     Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
242*cdf0e10cSrcweir     if( xSeqProp.is())
243*cdf0e10cSrcweir         xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( rRole));
244*cdf0e10cSrcweir     xLabeledSeq->setValues( xSeq );
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     // add new sequence to data series / push to front to have the correct sequence order if charttype is changed afterwards
247*cdf0e10cSrcweir     Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeq( xSeriesSource->getDataSequences());
248*cdf0e10cSrcweir     sal_Int32 nOldCount = aOldSeq.getLength();
249*cdf0e10cSrcweir     Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeq( nOldCount + 1 );
250*cdf0e10cSrcweir     aNewSeq[0]=xLabeledSeq;
251*cdf0e10cSrcweir     for( sal_Int32 nN=0; nN<nOldCount; nN++ )
252*cdf0e10cSrcweir         aNewSeq[nN+1] = aOldSeq[nN];
253*cdf0e10cSrcweir     xSeriesSink->setData( aNewSeq );
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     return xLabeledSeq;
256*cdf0e10cSrcweir }
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir } // anonymous namespace
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir // ================================================================================
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir SchXMLSeries2Context::SchXMLSeries2Context(
263*cdf0e10cSrcweir 	SchXMLImportHelper& rImpHelper,
264*cdf0e10cSrcweir 	SvXMLImport& rImport, const rtl::OUString& rLocalName,
265*cdf0e10cSrcweir     const Reference< chart2::XChartDocument > & xNewDoc,
266*cdf0e10cSrcweir 	std::vector< SchXMLAxis >& rAxes,
267*cdf0e10cSrcweir 	::std::list< DataRowPointStyle >& rStyleList,
268*cdf0e10cSrcweir 	sal_Int32 nSeriesIndex,
269*cdf0e10cSrcweir 	sal_Bool bStockHasVolume,
270*cdf0e10cSrcweir     GlobalSeriesImportInfo& rGlobalSeriesImportInfo,
271*cdf0e10cSrcweir     const OUString & aGlobalChartTypeName,
272*cdf0e10cSrcweir     tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
273*cdf0e10cSrcweir     bool& rGlobalChartTypeUsedBySeries,
274*cdf0e10cSrcweir     const awt::Size & rChartSize ) :
275*cdf0e10cSrcweir 		SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
276*cdf0e10cSrcweir         mrImportHelper( rImpHelper ),
277*cdf0e10cSrcweir         mxNewDoc( xNewDoc ),
278*cdf0e10cSrcweir 		mrAxes( rAxes ),
279*cdf0e10cSrcweir         mrStyleList( rStyleList ),
280*cdf0e10cSrcweir 		m_xSeries(0),
281*cdf0e10cSrcweir 		mnSeriesIndex( nSeriesIndex ),
282*cdf0e10cSrcweir 		mnDataPointIndex( 0 ),
283*cdf0e10cSrcweir         m_bStockHasVolume( bStockHasVolume ),
284*cdf0e10cSrcweir         m_rGlobalSeriesImportInfo(rGlobalSeriesImportInfo),
285*cdf0e10cSrcweir         mpAttachedAxis( NULL ),
286*cdf0e10cSrcweir 		maGlobalChartTypeName( aGlobalChartTypeName ),
287*cdf0e10cSrcweir         maSeriesChartTypeName( aGlobalChartTypeName ),
288*cdf0e10cSrcweir         m_bHasDomainContext(false),
289*cdf0e10cSrcweir         mrLSequencesPerIndex( rLSequencesPerIndex ),
290*cdf0e10cSrcweir         mrGlobalChartTypeUsedBySeries( rGlobalChartTypeUsedBySeries ),
291*cdf0e10cSrcweir         mbSymbolSizeIsMissingInFile(false),
292*cdf0e10cSrcweir         maChartSize( rChartSize )
293*cdf0e10cSrcweir {
294*cdf0e10cSrcweir     if( 0 == aGlobalChartTypeName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.DonutChartType" ) ) )
295*cdf0e10cSrcweir     {
296*cdf0e10cSrcweir         maSeriesChartTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.PieChartType" ));
297*cdf0e10cSrcweir         maGlobalChartTypeName = maSeriesChartTypeName;
298*cdf0e10cSrcweir     }
299*cdf0e10cSrcweir }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir SchXMLSeries2Context::~SchXMLSeries2Context()
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir     OSL_ASSERT( maPostponedSequences.empty());
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	// parse attributes
309*cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
310*cdf0e10cSrcweir 	const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetSeriesAttrTokenMap();
311*cdf0e10cSrcweir 	mnAttachedAxis = 1;
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir     bool bHasRange = false;
314*cdf0e10cSrcweir     bool bHasLabelRange = false;
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 	for( sal_Int16 i = 0; i < nAttrCount; i++ )
317*cdf0e10cSrcweir 	{
318*cdf0e10cSrcweir 		rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
319*cdf0e10cSrcweir 		rtl::OUString aLocalName;
320*cdf0e10cSrcweir 		rtl::OUString aValue = xAttrList->getValueByIndex( i );
321*cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 		switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
324*cdf0e10cSrcweir 		{
325*cdf0e10cSrcweir 			case XML_TOK_SERIES_CELL_RANGE:
326*cdf0e10cSrcweir                 m_aSeriesRange = aValue;
327*cdf0e10cSrcweir                 bHasRange = true;
328*cdf0e10cSrcweir 				break;
329*cdf0e10cSrcweir 			case XML_TOK_SERIES_LABEL_ADDRESS:
330*cdf0e10cSrcweir                 m_aSeriesLabelRange = aValue;
331*cdf0e10cSrcweir                 bHasLabelRange = true;
332*cdf0e10cSrcweir 				break;
333*cdf0e10cSrcweir 			case XML_TOK_SERIES_ATTACHED_AXIS:
334*cdf0e10cSrcweir 				{
335*cdf0e10cSrcweir 					sal_Int32 nNumOfAxes = mrAxes.size();
336*cdf0e10cSrcweir 					for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ )
337*cdf0e10cSrcweir 					{
338*cdf0e10cSrcweir 						if( aValue.equals( mrAxes[ nCurrent ].aName ) &&
339*cdf0e10cSrcweir 							mrAxes[ nCurrent ].eDimension == SCH_XML_AXIS_Y )
340*cdf0e10cSrcweir 						{
341*cdf0e10cSrcweir 							mpAttachedAxis = &( mrAxes[ nCurrent ] );
342*cdf0e10cSrcweir 						}
343*cdf0e10cSrcweir 					}
344*cdf0e10cSrcweir 				}
345*cdf0e10cSrcweir 				break;
346*cdf0e10cSrcweir 			case XML_TOK_SERIES_STYLE_NAME:
347*cdf0e10cSrcweir 				msAutoStyleName = aValue;
348*cdf0e10cSrcweir 				break;
349*cdf0e10cSrcweir 			case XML_TOK_SERIES_CHART_CLASS:
350*cdf0e10cSrcweir                 {
351*cdf0e10cSrcweir                     OUString aClassName;
352*cdf0e10cSrcweir 					sal_uInt16 nClassPrefix =
353*cdf0e10cSrcweir 						GetImport().GetNamespaceMap().GetKeyByAttrName(
354*cdf0e10cSrcweir                             aValue, &aClassName );
355*cdf0e10cSrcweir 					if( XML_NAMESPACE_CHART == nClassPrefix )
356*cdf0e10cSrcweir                         maSeriesChartTypeName = SchXMLTools::GetChartTypeByClassName( aClassName, false /* bUseOldNames */ );
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir                     if( ! maSeriesChartTypeName.getLength())
359*cdf0e10cSrcweir                         maSeriesChartTypeName = aClassName;
360*cdf0e10cSrcweir                 }
361*cdf0e10cSrcweir 				break;
362*cdf0e10cSrcweir 		}
363*cdf0e10cSrcweir 	}
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     if( mpAttachedAxis )
366*cdf0e10cSrcweir 	{
367*cdf0e10cSrcweir 		if( mpAttachedAxis->nAxisIndex > 0 )
368*cdf0e10cSrcweir 		{
369*cdf0e10cSrcweir 			// secondary axis => property has to be set (primary is default)
370*cdf0e10cSrcweir 			mnAttachedAxis = 2;
371*cdf0e10cSrcweir 		}
372*cdf0e10cSrcweir 	}
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir     try
375*cdf0e10cSrcweir     {
376*cdf0e10cSrcweir         OSL_ASSERT( mxNewDoc.is());
377*cdf0e10cSrcweir         if( m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && ! bHasRange )
378*cdf0e10cSrcweir             m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable = sal_False;
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir         bool bIsCandleStick = maGlobalChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType"));
381*cdf0e10cSrcweir         if( maSeriesChartTypeName.getLength() )
382*cdf0e10cSrcweir         {
383*cdf0e10cSrcweir             bIsCandleStick = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType"));
384*cdf0e10cSrcweir         }
385*cdf0e10cSrcweir         else
386*cdf0e10cSrcweir         {
387*cdf0e10cSrcweir             if( bIsCandleStick
388*cdf0e10cSrcweir                 && m_bStockHasVolume
389*cdf0e10cSrcweir                 && mnSeriesIndex == 0 )
390*cdf0e10cSrcweir             {
391*cdf0e10cSrcweir                 maSeriesChartTypeName = OUString::createFromAscii( "com.sun.star.chart2.ColumnChartType" );
392*cdf0e10cSrcweir                 bIsCandleStick = false;
393*cdf0e10cSrcweir             }
394*cdf0e10cSrcweir             else
395*cdf0e10cSrcweir             {
396*cdf0e10cSrcweir                 maSeriesChartTypeName = maGlobalChartTypeName;
397*cdf0e10cSrcweir             }
398*cdf0e10cSrcweir         }
399*cdf0e10cSrcweir         if( ! mrGlobalChartTypeUsedBySeries )
400*cdf0e10cSrcweir             mrGlobalChartTypeUsedBySeries = (maSeriesChartTypeName.equals( maGlobalChartTypeName ));
401*cdf0e10cSrcweir         sal_Int32 nCoordinateSystemIndex = 0;//so far we can only import one coordinate system
402*cdf0e10cSrcweir         m_xSeries.set(
403*cdf0e10cSrcweir             mrImportHelper.GetNewDataSeries( mxNewDoc, nCoordinateSystemIndex, maSeriesChartTypeName, ! mrGlobalChartTypeUsedBySeries ));
404*cdf0e10cSrcweir         Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
405*cdf0e10cSrcweir             SchXMLTools::GetNewLabeledDataSequence());
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir         if( bIsCandleStick )
408*cdf0e10cSrcweir         {
409*cdf0e10cSrcweir             // set default color for range-line to black (before applying styles)
410*cdf0e10cSrcweir             Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
411*cdf0e10cSrcweir             if( xSeriesProp.is())
412*cdf0e10cSrcweir                 xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Color")),
413*cdf0e10cSrcweir                                                uno::makeAny( sal_Int32( 0x000000 ))); // black
414*cdf0e10cSrcweir         }
415*cdf0e10cSrcweir         else if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.PieChartType")))
416*cdf0e10cSrcweir         {
417*cdf0e10cSrcweir             //@todo: this property should be saved
418*cdf0e10cSrcweir             Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
419*cdf0e10cSrcweir             if( xSeriesProp.is())
420*cdf0e10cSrcweir                 xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VaryColorsByPoint")),
421*cdf0e10cSrcweir                                                uno::makeAny( true ));
422*cdf0e10cSrcweir         }
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir         // values
425*cdf0e10cSrcweir         Reference< chart2::data::XDataSequence > xSeq;
426*cdf0e10cSrcweir         if( bHasRange && m_aSeriesRange.getLength() )
427*cdf0e10cSrcweir             xSeq = SchXMLTools::CreateDataSequence( m_aSeriesRange, mxNewDoc );
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir         Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
430*cdf0e10cSrcweir         if( xSeqProp.is())
431*cdf0e10cSrcweir         {
432*cdf0e10cSrcweir             OUString aMainRole( OUString::createFromAscii("values-y") );
433*cdf0e10cSrcweir             if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType") ) )
434*cdf0e10cSrcweir                 aMainRole = OUString::createFromAscii("values-size");
435*cdf0e10cSrcweir             xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( aMainRole ));
436*cdf0e10cSrcweir         }
437*cdf0e10cSrcweir         xLabeledSeq->setValues( xSeq );
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir         // register for setting local data if external data provider is not present
440*cdf0e10cSrcweir         maPostponedSequences.insert(
441*cdf0e10cSrcweir             tSchXMLLSequencesPerIndex::value_type(
442*cdf0e10cSrcweir                 tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq ));
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir         // label
445*cdf0e10cSrcweir         if( bHasLabelRange && m_aSeriesLabelRange.getLength() )
446*cdf0e10cSrcweir         {
447*cdf0e10cSrcweir             Reference< chart2::data::XDataSequence > xLabelSequence =
448*cdf0e10cSrcweir                 SchXMLTools::CreateDataSequence( m_aSeriesLabelRange, mxNewDoc );
449*cdf0e10cSrcweir             xLabeledSeq->setLabel( xLabelSequence );
450*cdf0e10cSrcweir         }
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir         // Note: Even if we have no label, we have to register the label
453*cdf0e10cSrcweir         // for creation, because internal data always has labels. If
454*cdf0e10cSrcweir         // they don't exist in the original, auto-generated labels are
455*cdf0e10cSrcweir         // used for the internal data.
456*cdf0e10cSrcweir         maPostponedSequences.insert(
457*cdf0e10cSrcweir             tSchXMLLSequencesPerIndex::value_type(
458*cdf0e10cSrcweir                 tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_LABEL ), xLabeledSeq ));
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir         Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( &xLabeledSeq, 1 );
462*cdf0e10cSrcweir         Reference< chart2::data::XDataSink > xSink( m_xSeries, uno::UNO_QUERY_THROW );
463*cdf0e10cSrcweir         xSink->setData( aSeq );
464*cdf0e10cSrcweir     }
465*cdf0e10cSrcweir     catch( uno::Exception & ex )
466*cdf0e10cSrcweir     {
467*cdf0e10cSrcweir         (void)ex; // avoid warning for pro build
468*cdf0e10cSrcweir         OSL_ENSURE( false, ::rtl::OUStringToOString(
469*cdf0e10cSrcweir                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) +
470*cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii( typeid( ex ).name()) +
471*cdf0e10cSrcweir                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) +
472*cdf0e10cSrcweir                         ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
473*cdf0e10cSrcweir     }
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir     //init mbSymbolSizeIsMissingInFile:
476*cdf0e10cSrcweir     try
477*cdf0e10cSrcweir     {
478*cdf0e10cSrcweir         if( msAutoStyleName.getLength() )
479*cdf0e10cSrcweir         {
480*cdf0e10cSrcweir             const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
481*cdf0e10cSrcweir 	        if( pStylesCtxt )
482*cdf0e10cSrcweir 	        {
483*cdf0e10cSrcweir 		        const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
484*cdf0e10cSrcweir 			        mrImportHelper.GetChartFamilyID(), msAutoStyleName );
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir                 const XMLPropStyleContext* pPropStyleContext = dynamic_cast< const XMLPropStyleContext * >( pStyle );
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir                 uno::Any aASymbolSize( SchXMLTools::getPropertyFromContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize"))
489*cdf0e10cSrcweir                     , pPropStyleContext, pStylesCtxt ) );
490*cdf0e10cSrcweir                 mbSymbolSizeIsMissingInFile = !aASymbolSize.hasValue();
491*cdf0e10cSrcweir 	        }
492*cdf0e10cSrcweir         }
493*cdf0e10cSrcweir     }
494*cdf0e10cSrcweir     catch( uno::Exception & ex )
495*cdf0e10cSrcweir     {
496*cdf0e10cSrcweir         (void)ex; // avoid warning for pro build
497*cdf0e10cSrcweir     }
498*cdf0e10cSrcweir }
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir struct DomainInfo
501*cdf0e10cSrcweir {
502*cdf0e10cSrcweir     DomainInfo( const rtl::OUString& rRole, const rtl::OUString& rRange, sal_Int32 nIndex )
503*cdf0e10cSrcweir         : aRole(rRole), aRange(rRange), nIndexForLocalData(nIndex)
504*cdf0e10cSrcweir     {}
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir     rtl::OUString aRole;
507*cdf0e10cSrcweir     rtl::OUString aRange;
508*cdf0e10cSrcweir     sal_Int32 nIndexForLocalData;
509*cdf0e10cSrcweir };
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir void SchXMLSeries2Context::EndElement()
512*cdf0e10cSrcweir {
513*cdf0e10cSrcweir     // special handling for different chart types.  This is necessary as the
514*cdf0e10cSrcweir     // roles are not yet saved in the file format
515*cdf0e10cSrcweir     sal_Int32 nDomainCount = maDomainAddresses.size();
516*cdf0e10cSrcweir     bool bIsScatterChart = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ScatterChartType"));
517*cdf0e10cSrcweir     bool bIsBubbleChart = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType"));
518*cdf0e10cSrcweir     bool bDeleteSeries = false;
519*cdf0e10cSrcweir     std::vector< DomainInfo > aDomainInfos;
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir     //different handling for different chart types necessary
522*cdf0e10cSrcweir     if( bIsScatterChart || ( nDomainCount==1 && !bIsBubbleChart ) )
523*cdf0e10cSrcweir     {
524*cdf0e10cSrcweir         DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress, m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex ) ;
525*cdf0e10cSrcweir         bool bCreateXValues = true;
526*cdf0e10cSrcweir         if( !maDomainAddresses.empty() )
527*cdf0e10cSrcweir         {
528*cdf0e10cSrcweir             if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() )
529*cdf0e10cSrcweir             {
530*cdf0e10cSrcweir                 m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
531*cdf0e10cSrcweir                 m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
532*cdf0e10cSrcweir             }
533*cdf0e10cSrcweir             aDomainInfo.aRange = maDomainAddresses.front();
534*cdf0e10cSrcweir             aDomainInfo.nIndexForLocalData = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
535*cdf0e10cSrcweir             m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
536*cdf0e10cSrcweir         }
537*cdf0e10cSrcweir         else if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() && !m_bHasDomainContext && mnSeriesIndex==0 )
538*cdf0e10cSrcweir         {
539*cdf0e10cSrcweir             if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) ) //wrong old chart files:
540*cdf0e10cSrcweir             {
541*cdf0e10cSrcweir                 //for xy charts the first series needs to have a domain
542*cdf0e10cSrcweir                 //if this by error iss not the case the first series is taken s x values
543*cdf0e10cSrcweir                 //needed for wrong files created while having an addin (e.g. BoxPlot)
544*cdf0e10cSrcweir                 m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = m_aSeriesRange;
545*cdf0e10cSrcweir                 m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
546*cdf0e10cSrcweir                 bDeleteSeries = true;
547*cdf0e10cSrcweir                 bCreateXValues = false;//they will be created for the next series
548*cdf0e10cSrcweir             }
549*cdf0e10cSrcweir         }
550*cdf0e10cSrcweir         if( bCreateXValues )
551*cdf0e10cSrcweir             aDomainInfos.push_back( aDomainInfo );
552*cdf0e10cSrcweir     }
553*cdf0e10cSrcweir     else if( bIsBubbleChart )
554*cdf0e10cSrcweir     {
555*cdf0e10cSrcweir         if( nDomainCount>1 )
556*cdf0e10cSrcweir         {
557*cdf0e10cSrcweir             DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), maDomainAddresses[1], m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
558*cdf0e10cSrcweir             if( !m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.getLength() )
559*cdf0e10cSrcweir             {
560*cdf0e10cSrcweir                 //for bubble chart the second domain contains the x values which should become an index smaller than y values for own data table
561*cdf0e10cSrcweir                 //->so second first
562*cdf0e10cSrcweir                 m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress = maDomainAddresses[1];
563*cdf0e10cSrcweir                 m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
564*cdf0e10cSrcweir             }
565*cdf0e10cSrcweir             aDomainInfos.push_back( aDomainInfo );
566*cdf0e10cSrcweir             m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
567*cdf0e10cSrcweir         }
568*cdf0e10cSrcweir         else if( m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.getLength() )
569*cdf0e10cSrcweir         {
570*cdf0e10cSrcweir             DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress, m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex ) ;
571*cdf0e10cSrcweir             aDomainInfos.push_back( aDomainInfo );
572*cdf0e10cSrcweir         }
573*cdf0e10cSrcweir         if( nDomainCount>0)
574*cdf0e10cSrcweir         {
575*cdf0e10cSrcweir             DomainInfo aDomainInfo( OUString::createFromAscii("values-y"), maDomainAddresses.front(), m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
576*cdf0e10cSrcweir             if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() )
577*cdf0e10cSrcweir             {
578*cdf0e10cSrcweir                 m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
579*cdf0e10cSrcweir                 m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
580*cdf0e10cSrcweir             }
581*cdf0e10cSrcweir             aDomainInfos.push_back( aDomainInfo );
582*cdf0e10cSrcweir             m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
583*cdf0e10cSrcweir         }
584*cdf0e10cSrcweir         else if( m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() )
585*cdf0e10cSrcweir         {
586*cdf0e10cSrcweir             DomainInfo aDomainInfo( OUString::createFromAscii("values-y"), m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress, m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex ) ;
587*cdf0e10cSrcweir             aDomainInfos.push_back( aDomainInfo );
588*cdf0e10cSrcweir         }
589*cdf0e10cSrcweir     }
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir     if( bDeleteSeries )
592*cdf0e10cSrcweir     {
593*cdf0e10cSrcweir         //delete created series
594*cdf0e10cSrcweir         SchXMLImportHelper::DeleteDataSeries(
595*cdf0e10cSrcweir             m_xSeries, Reference< chart2::XChartDocument >( GetImport().GetModel(), uno::UNO_QUERY ) );
596*cdf0e10cSrcweir     }
597*cdf0e10cSrcweir     else
598*cdf0e10cSrcweir     {
599*cdf0e10cSrcweir         //add style
600*cdf0e10cSrcweir 	    if( msAutoStyleName.getLength() ||
601*cdf0e10cSrcweir 		    mnAttachedAxis != 1 )
602*cdf0e10cSrcweir 	    {
603*cdf0e10cSrcweir 		    DataRowPointStyle aStyle(
604*cdf0e10cSrcweir                 DataRowPointStyle::DATA_SERIES,
605*cdf0e10cSrcweir                 m_xSeries,
606*cdf0e10cSrcweir                 -1, 1,
607*cdf0e10cSrcweir                 msAutoStyleName, mnAttachedAxis );
608*cdf0e10cSrcweir             aStyle.mbSymbolSizeForSeriesIsMissingInFile=mbSymbolSizeIsMissingInFile;
609*cdf0e10cSrcweir 		    mrStyleList.push_back( aStyle );
610*cdf0e10cSrcweir 	    }
611*cdf0e10cSrcweir     }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir     for( std::vector< DomainInfo >::reverse_iterator aIt( aDomainInfos.rbegin() ); aIt!= aDomainInfos.rend(); ++aIt )
614*cdf0e10cSrcweir     {
615*cdf0e10cSrcweir         DomainInfo aDomainInfo( *aIt );
616*cdf0e10cSrcweir         Reference< chart2::data::XLabeledDataSequence > xLabeledSeq =
617*cdf0e10cSrcweir             lcl_createAndAddSequenceToSeries( aDomainInfo.aRole, aDomainInfo.aRange, mxNewDoc, m_xSeries );
618*cdf0e10cSrcweir         if( xLabeledSeq.is() )
619*cdf0e10cSrcweir         {
620*cdf0e10cSrcweir             // register for setting local data if external data provider is not present
621*cdf0e10cSrcweir             mrLSequencesPerIndex.insert(
622*cdf0e10cSrcweir                 tSchXMLLSequencesPerIndex::value_type(
623*cdf0e10cSrcweir                     tSchXMLIndexWithPart( aDomainInfo.nIndexForLocalData, SCH_XML_PART_VALUES ), xLabeledSeq ));
624*cdf0e10cSrcweir         }
625*cdf0e10cSrcweir     }
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir     if( !bDeleteSeries )
628*cdf0e10cSrcweir     {
629*cdf0e10cSrcweir         for( tSchXMLLSequencesPerIndex::const_iterator aIt( maPostponedSequences.begin());
630*cdf0e10cSrcweir             aIt != maPostponedSequences.end(); ++aIt )
631*cdf0e10cSrcweir         {
632*cdf0e10cSrcweir             sal_Int32 nNewIndex = aIt->first.first + nDomainCount;
633*cdf0e10cSrcweir             mrLSequencesPerIndex.insert(
634*cdf0e10cSrcweir                 tSchXMLLSequencesPerIndex::value_type(
635*cdf0e10cSrcweir                     tSchXMLIndexWithPart( nNewIndex, aIt->first.second ), aIt->second ));
636*cdf0e10cSrcweir         }
637*cdf0e10cSrcweir         m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
638*cdf0e10cSrcweir     }
639*cdf0e10cSrcweir     maPostponedSequences.clear();
640*cdf0e10cSrcweir }
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir SvXMLImportContext* SchXMLSeries2Context::CreateChildContext(
643*cdf0e10cSrcweir 	sal_uInt16 nPrefix,
644*cdf0e10cSrcweir 	const rtl::OUString& rLocalName,
645*cdf0e10cSrcweir 	const uno::Reference< xml::sax::XAttributeList >&  )
646*cdf0e10cSrcweir {
647*cdf0e10cSrcweir 	SvXMLImportContext* pContext = 0;
648*cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap = mrImportHelper.GetSeriesElemTokenMap();
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir 	switch( rTokenMap.Get( nPrefix, rLocalName ))
651*cdf0e10cSrcweir 	{
652*cdf0e10cSrcweir 		case XML_TOK_SERIES_DOMAIN:
653*cdf0e10cSrcweir             if( m_xSeries.is())
654*cdf0e10cSrcweir             {
655*cdf0e10cSrcweir                 m_bHasDomainContext = true;
656*cdf0e10cSrcweir 				pContext = new SchXMLDomain2Context(
657*cdf0e10cSrcweir 					mrImportHelper, GetImport(),
658*cdf0e10cSrcweir 					nPrefix, rLocalName,
659*cdf0e10cSrcweir                     maDomainAddresses );
660*cdf0e10cSrcweir 			}
661*cdf0e10cSrcweir 			break;
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir         case XML_TOK_SERIES_MEAN_VALUE_LINE:
664*cdf0e10cSrcweir             pContext = new SchXMLStatisticsObjectContext(
665*cdf0e10cSrcweir                 mrImportHelper, GetImport(),
666*cdf0e10cSrcweir                 nPrefix, rLocalName,
667*cdf0e10cSrcweir                 mrStyleList, m_xSeries,
668*cdf0e10cSrcweir                 SchXMLStatisticsObjectContext::CONTEXT_TYPE_MEAN_VALUE_LINE,
669*cdf0e10cSrcweir                 maChartSize );
670*cdf0e10cSrcweir             break;
671*cdf0e10cSrcweir         case XML_TOK_SERIES_REGRESSION_CURVE:
672*cdf0e10cSrcweir             pContext = new SchXMLStatisticsObjectContext(
673*cdf0e10cSrcweir                 mrImportHelper, GetImport(),
674*cdf0e10cSrcweir                 nPrefix, rLocalName,
675*cdf0e10cSrcweir                 mrStyleList, m_xSeries,
676*cdf0e10cSrcweir                 SchXMLStatisticsObjectContext::CONTEXT_TYPE_REGRESSION_CURVE,
677*cdf0e10cSrcweir                 maChartSize );
678*cdf0e10cSrcweir             break;
679*cdf0e10cSrcweir         case XML_TOK_SERIES_ERROR_INDICATOR:
680*cdf0e10cSrcweir             pContext = new SchXMLStatisticsObjectContext(
681*cdf0e10cSrcweir                 mrImportHelper, GetImport(),
682*cdf0e10cSrcweir                 nPrefix, rLocalName,
683*cdf0e10cSrcweir                 mrStyleList, m_xSeries,
684*cdf0e10cSrcweir                 SchXMLStatisticsObjectContext::CONTEXT_TYPE_ERROR_INDICATOR,
685*cdf0e10cSrcweir                 maChartSize );
686*cdf0e10cSrcweir             break;
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 		case XML_TOK_SERIES_DATA_POINT:
689*cdf0e10cSrcweir 			pContext = new SchXMLDataPointContext( mrImportHelper, GetImport(), rLocalName,
690*cdf0e10cSrcweir 												   mrStyleList, m_xSeries, mnDataPointIndex, mbSymbolSizeIsMissingInFile );
691*cdf0e10cSrcweir 			break;
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir 		default:
694*cdf0e10cSrcweir 			pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
695*cdf0e10cSrcweir 	}
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir 	return pContext;
698*cdf0e10cSrcweir }
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir //static
701*cdf0e10cSrcweir void SchXMLSeries2Context::initSeriesPropertySets( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
702*cdf0e10cSrcweir         , const uno::Reference< frame::XModel >& xChartModel )
703*cdf0e10cSrcweir {
704*cdf0e10cSrcweir     ::std::list< DataRowPointStyle >::iterator iStyle;
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir     // iterate over series first and remind propertysets in map
707*cdf0e10cSrcweir     // new api <-> old api wrapper
708*cdf0e10cSrcweir     ::std::map< Reference< chart2::XDataSeries >, Reference< beans::XPropertySet > > aSeriesMap;
709*cdf0e10cSrcweir 	for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
710*cdf0e10cSrcweir 	{
711*cdf0e10cSrcweir 		if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
712*cdf0e10cSrcweir             continue;
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir         if( !iStyle->m_xOldAPISeries.is() )
715*cdf0e10cSrcweir             iStyle->m_xOldAPISeries = SchXMLSeriesHelper::createOldAPISeriesPropertySet( iStyle->m_xSeries, xChartModel );
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir         aSeriesMap[iStyle->m_xSeries] = iStyle->m_xOldAPISeries;
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir     }
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir     //initialize m_xOldAPISeries for all other styles also
722*cdf0e10cSrcweir     for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
723*cdf0e10cSrcweir 	{
724*cdf0e10cSrcweir 		if( iStyle->meType == DataRowPointStyle::DATA_SERIES )
725*cdf0e10cSrcweir             continue;
726*cdf0e10cSrcweir         iStyle->m_xOldAPISeries = aSeriesMap[iStyle->m_xSeries];
727*cdf0e10cSrcweir     }
728*cdf0e10cSrcweir }
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir //static
731*cdf0e10cSrcweir void SchXMLSeries2Context::setDefaultsToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles )
732*cdf0e10cSrcweir {
733*cdf0e10cSrcweir     ::std::list< DataRowPointStyle >::iterator iStyle;
734*cdf0e10cSrcweir     // iterate over series
735*cdf0e10cSrcweir     // call initSeriesPropertySets first
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir 	for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
738*cdf0e10cSrcweir 	{
739*cdf0e10cSrcweir 		if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
740*cdf0e10cSrcweir             continue;
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir         try
743*cdf0e10cSrcweir         {
744*cdf0e10cSrcweir             uno::Reference< beans::XPropertySet > xSeries( iStyle->m_xOldAPISeries );
745*cdf0e10cSrcweir             if( !xSeries.is() )
746*cdf0e10cSrcweir                 continue;
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maSymbolTypeDefault.hasValue() )
749*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolType")),rSeriesDefaultsAndStyles.maSymbolTypeDefault);
750*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maDataCaptionDefault.hasValue() )
751*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCaption")),rSeriesDefaultsAndStyles.maDataCaptionDefault);
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maErrorIndicatorDefault.hasValue() )
754*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorIndicator")),rSeriesDefaultsAndStyles.maErrorIndicatorDefault);
755*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maErrorCategoryDefault.hasValue() )
756*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorCategory")),rSeriesDefaultsAndStyles.maErrorCategoryDefault);
757*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maConstantErrorLowDefault.hasValue() )
758*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorLow")),rSeriesDefaultsAndStyles.maConstantErrorLowDefault);
759*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maConstantErrorHighDefault.hasValue() )
760*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorHigh")),rSeriesDefaultsAndStyles.maConstantErrorHighDefault);
761*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maPercentageErrorDefault.hasValue() )
762*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PercentageError")),rSeriesDefaultsAndStyles.maPercentageErrorDefault);
763*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maErrorMarginDefault.hasValue() )
764*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorMargin")),rSeriesDefaultsAndStyles.maErrorMarginDefault);
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maMeanValueDefault.hasValue() )
767*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MeanValue")),rSeriesDefaultsAndStyles.maMeanValueDefault);
768*cdf0e10cSrcweir             if( rSeriesDefaultsAndStyles.maRegressionCurvesDefault.hasValue() )
769*cdf0e10cSrcweir                 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RegressionCurves")),rSeriesDefaultsAndStyles.maRegressionCurvesDefault);
770*cdf0e10cSrcweir         }
771*cdf0e10cSrcweir         catch( uno::Exception &  )
772*cdf0e10cSrcweir         {
773*cdf0e10cSrcweir             //end of series reached
774*cdf0e10cSrcweir         }
775*cdf0e10cSrcweir     }
776*cdf0e10cSrcweir }
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir //static
779*cdf0e10cSrcweir void SchXMLSeries2Context::setStylesToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
780*cdf0e10cSrcweir         , const SvXMLStylesContext* pStylesCtxt
781*cdf0e10cSrcweir         , const SvXMLStyleContext*& rpStyle
782*cdf0e10cSrcweir         , ::rtl::OUString& rCurrStyleName
783*cdf0e10cSrcweir         , SchXMLImportHelper& rImportHelper
784*cdf0e10cSrcweir         , const SvXMLImport& rImport
785*cdf0e10cSrcweir         , bool bIsStockChart
786*cdf0e10cSrcweir         , tSchXMLLSequencesPerIndex & rInOutLSequencesPerIndex )
787*cdf0e10cSrcweir {
788*cdf0e10cSrcweir     ::std::list< DataRowPointStyle >::iterator iStyle;
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir     // iterate over series
791*cdf0e10cSrcweir 	for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
792*cdf0e10cSrcweir 	{
793*cdf0e10cSrcweir 		if( iStyle->meType == DataRowPointStyle::DATA_SERIES )
794*cdf0e10cSrcweir 		{
795*cdf0e10cSrcweir             try
796*cdf0e10cSrcweir 			{
797*cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
798*cdf0e10cSrcweir                 if( !xSeriesProp.is() )
799*cdf0e10cSrcweir                     continue;
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir                 if( iStyle->mnAttachedAxis != 1 )
802*cdf0e10cSrcweir 				{
803*cdf0e10cSrcweir 					xSeriesProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Axis" ))
804*cdf0e10cSrcweir                         , uno::makeAny(chart::ChartAxisAssign::SECONDARY_Y) );
805*cdf0e10cSrcweir 				}
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir 				if( (iStyle->msStyleName).getLength())
808*cdf0e10cSrcweir 				{
809*cdf0e10cSrcweir 					if( ! rCurrStyleName.equals( iStyle->msStyleName ))
810*cdf0e10cSrcweir 					{
811*cdf0e10cSrcweir 						rCurrStyleName = iStyle->msStyleName;
812*cdf0e10cSrcweir 						rpStyle = pStylesCtxt->FindStyleChildContext(
813*cdf0e10cSrcweir 							rImportHelper.GetChartFamilyID(), rCurrStyleName );
814*cdf0e10cSrcweir 					}
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir                     //set style to series
817*cdf0e10cSrcweir                     // note: SvXMLStyleContext::FillPropertySet is not const
818*cdf0e10cSrcweir                     XMLPropStyleContext * pPropStyleContext =
819*cdf0e10cSrcweir                         const_cast< XMLPropStyleContext * >(
820*cdf0e10cSrcweir                             dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
821*cdf0e10cSrcweir                     if( pPropStyleContext )
822*cdf0e10cSrcweir                     {
823*cdf0e10cSrcweir                         // error bar style must be set before the other error
824*cdf0e10cSrcweir                         // bar properties (which may be alphabetically before
825*cdf0e10cSrcweir                         // this property)
826*cdf0e10cSrcweir                         bool bHasErrorBarRangesFromData = false;
827*cdf0e10cSrcweir                         {
828*cdf0e10cSrcweir                             const ::rtl::OUString aErrorBarStylePropName( RTL_CONSTASCII_USTRINGPARAM("ErrorBarStyle"));
829*cdf0e10cSrcweir                             uno::Any aErrorBarStyle(
830*cdf0e10cSrcweir                                 SchXMLTools::getPropertyFromContext( aErrorBarStylePropName, pPropStyleContext, pStylesCtxt ));
831*cdf0e10cSrcweir                             if( aErrorBarStyle.hasValue())
832*cdf0e10cSrcweir                             {
833*cdf0e10cSrcweir                                 xSeriesProp->setPropertyValue( aErrorBarStylePropName, aErrorBarStyle );
834*cdf0e10cSrcweir                                 sal_Int32 eEBStyle = chart::ErrorBarStyle::NONE;
835*cdf0e10cSrcweir                                 bHasErrorBarRangesFromData =
836*cdf0e10cSrcweir                                     ( ( aErrorBarStyle >>= eEBStyle ) &&
837*cdf0e10cSrcweir                                       eEBStyle == chart::ErrorBarStyle::FROM_DATA );
838*cdf0e10cSrcweir                             }
839*cdf0e10cSrcweir                         }
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir                         //don't set the style to the min max line series of a stock chart
842*cdf0e10cSrcweir                         //otherwise the min max line properties gets overwritten and the series becomes invisible typically
843*cdf0e10cSrcweir                         bool bIsMinMaxSeries = false;
844*cdf0e10cSrcweir                         if( bIsStockChart )
845*cdf0e10cSrcweir                         {
846*cdf0e10cSrcweir                             if( SchXMLSeriesHelper::isCandleStickSeries( iStyle->m_xSeries
847*cdf0e10cSrcweir                                     , uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) )
848*cdf0e10cSrcweir                                 bIsMinMaxSeries = true;
849*cdf0e10cSrcweir                         }
850*cdf0e10cSrcweir                         if( !bIsMinMaxSeries )
851*cdf0e10cSrcweir                         {
852*cdf0e10cSrcweir                             pPropStyleContext->FillPropertySet( xSeriesProp );
853*cdf0e10cSrcweir                             if( iStyle->mbSymbolSizeForSeriesIsMissingInFile )
854*cdf0e10cSrcweir                                 lcl_setSymbolSizeIfNeeded( xSeriesProp, rImport );
855*cdf0e10cSrcweir                             if( bHasErrorBarRangesFromData )
856*cdf0e10cSrcweir                                 lcl_insertErrorBarLSequencesToMap( rInOutLSequencesPerIndex, xSeriesProp );
857*cdf0e10cSrcweir                         }
858*cdf0e10cSrcweir                     }
859*cdf0e10cSrcweir 				}
860*cdf0e10cSrcweir 			}
861*cdf0e10cSrcweir 			catch( uno::Exception & rEx )
862*cdf0e10cSrcweir 			{
863*cdf0e10cSrcweir                 (void)rEx; // avoid warning for pro build
864*cdf0e10cSrcweir                 DBG_ERROR1( "Exception caught during setting styles to series: %s",
865*cdf0e10cSrcweir                                 OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
866*cdf0e10cSrcweir 			}
867*cdf0e10cSrcweir 		}
868*cdf0e10cSrcweir     }
869*cdf0e10cSrcweir }
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir // static
872*cdf0e10cSrcweir void SchXMLSeries2Context::setStylesToStatisticsObjects( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
873*cdf0e10cSrcweir         , const SvXMLStylesContext* pStylesCtxt
874*cdf0e10cSrcweir         , const SvXMLStyleContext*& rpStyle
875*cdf0e10cSrcweir         , ::rtl::OUString& rCurrStyleName )
876*cdf0e10cSrcweir {
877*cdf0e10cSrcweir     ::std::list< DataRowPointStyle >::iterator iStyle;
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir     // iterate over regession etc
880*cdf0e10cSrcweir 	for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
881*cdf0e10cSrcweir     {
882*cdf0e10cSrcweir         if( iStyle->meType == DataRowPointStyle::REGRESSION ||
883*cdf0e10cSrcweir             iStyle->meType == DataRowPointStyle::ERROR_INDICATOR ||
884*cdf0e10cSrcweir             iStyle->meType == DataRowPointStyle::MEAN_VALUE )
885*cdf0e10cSrcweir         {
886*cdf0e10cSrcweir             try
887*cdf0e10cSrcweir             {
888*cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
889*cdf0e10cSrcweir                 if( !xSeriesProp.is() )
890*cdf0e10cSrcweir                     continue;
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir 				if( (iStyle->msStyleName).getLength())
893*cdf0e10cSrcweir 				{
894*cdf0e10cSrcweir 					if( ! rCurrStyleName.equals( iStyle->msStyleName ))
895*cdf0e10cSrcweir 					{
896*cdf0e10cSrcweir 						rCurrStyleName = iStyle->msStyleName;
897*cdf0e10cSrcweir 						rpStyle = pStylesCtxt->FindStyleChildContext(
898*cdf0e10cSrcweir 							SchXMLImportHelper::GetChartFamilyID(), rCurrStyleName );
899*cdf0e10cSrcweir 					}
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir                     // note: SvXMLStyleContext::FillPropertySet is not const
902*cdf0e10cSrcweir                     XMLPropStyleContext * pPropStyleContext =
903*cdf0e10cSrcweir                         const_cast< XMLPropStyleContext * >(
904*cdf0e10cSrcweir                             dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
905*cdf0e10cSrcweir                     if( pPropStyleContext )
906*cdf0e10cSrcweir                     {
907*cdf0e10cSrcweir                         Reference< beans::XPropertySet > xStatPropSet;
908*cdf0e10cSrcweir                         switch( iStyle->meType )
909*cdf0e10cSrcweir                         {
910*cdf0e10cSrcweir                             case DataRowPointStyle::MEAN_VALUE:
911*cdf0e10cSrcweir                                 xSeriesProp->getPropertyValue(
912*cdf0e10cSrcweir                                     OUString( RTL_CONSTASCII_USTRINGPARAM(
913*cdf0e10cSrcweir                                                   "DataMeanValueProperties" ))) >>= xStatPropSet;
914*cdf0e10cSrcweir                                 break;
915*cdf0e10cSrcweir                             case DataRowPointStyle::REGRESSION:
916*cdf0e10cSrcweir                                 xSeriesProp->getPropertyValue(
917*cdf0e10cSrcweir                                     OUString( RTL_CONSTASCII_USTRINGPARAM(
918*cdf0e10cSrcweir                                                   "DataRegressionProperties" ))) >>= xStatPropSet;
919*cdf0e10cSrcweir                                 break;
920*cdf0e10cSrcweir                             case DataRowPointStyle::ERROR_INDICATOR:
921*cdf0e10cSrcweir                                 xSeriesProp->getPropertyValue(
922*cdf0e10cSrcweir                                     OUString( RTL_CONSTASCII_USTRINGPARAM(
923*cdf0e10cSrcweir                                                   "DataErrorProperties" )))  >>= xStatPropSet;
924*cdf0e10cSrcweir                                 break;
925*cdf0e10cSrcweir                             default:
926*cdf0e10cSrcweir                                 break;
927*cdf0e10cSrcweir                         }
928*cdf0e10cSrcweir                         if( xStatPropSet.is())
929*cdf0e10cSrcweir                             pPropStyleContext->FillPropertySet( xStatPropSet );
930*cdf0e10cSrcweir                     }
931*cdf0e10cSrcweir                 }
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir                 // set equation properties at a regression curve
934*cdf0e10cSrcweir                 // note: this must be done after setting the regression
935*cdf0e10cSrcweir                 // properties at the old API, otherwise the curve itself does
936*cdf0e10cSrcweir                 // not exist here
937*cdf0e10cSrcweir                 if( iStyle->meType == DataRowPointStyle::REGRESSION && iStyle->m_xEquationProperties.is())
938*cdf0e10cSrcweir                 {
939*cdf0e10cSrcweir                     OSL_ASSERT( iStyle->m_xSeries.is());
940*cdf0e10cSrcweir                     Reference< chart2::XRegressionCurve > xRegCurve( SchXMLTools::getRegressionCurve( iStyle->m_xSeries ));
941*cdf0e10cSrcweir                     if( xRegCurve.is())
942*cdf0e10cSrcweir                         xRegCurve->setEquationProperties( iStyle->m_xEquationProperties );
943*cdf0e10cSrcweir                 }
944*cdf0e10cSrcweir             }
945*cdf0e10cSrcweir 			catch( uno::Exception & rEx )
946*cdf0e10cSrcweir 			{
947*cdf0e10cSrcweir                 (void)rEx; // avoid warning for pro build
948*cdf0e10cSrcweir                 DBG_ERROR1( "Exception caught during setting styles to series: %s",
949*cdf0e10cSrcweir                                 OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
950*cdf0e10cSrcweir 			}
951*cdf0e10cSrcweir 		}
952*cdf0e10cSrcweir     }
953*cdf0e10cSrcweir }
954*cdf0e10cSrcweir 
955*cdf0e10cSrcweir //static
956*cdf0e10cSrcweir void SchXMLSeries2Context::setStylesToDataPoints( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
957*cdf0e10cSrcweir         , const SvXMLStylesContext* pStylesCtxt
958*cdf0e10cSrcweir         , const SvXMLStyleContext*& rpStyle
959*cdf0e10cSrcweir         , ::rtl::OUString& rCurrStyleName
960*cdf0e10cSrcweir         , SchXMLImportHelper& rImportHelper
961*cdf0e10cSrcweir         , const SvXMLImport& rImport
962*cdf0e10cSrcweir         , bool bIsStockChart, bool bIsDonutChart, bool bSwitchOffLinesForScatter )
963*cdf0e10cSrcweir {
964*cdf0e10cSrcweir     ::std::list< DataRowPointStyle >::iterator iStyle;
965*cdf0e10cSrcweir     for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
966*cdf0e10cSrcweir 	{
967*cdf0e10cSrcweir         if( iStyle->meType != DataRowPointStyle::DATA_POINT )
968*cdf0e10cSrcweir             continue;
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir 		if( iStyle->m_nPointIndex == -1 )
971*cdf0e10cSrcweir             continue;
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir 		//ignore datapoint properties for stock charts
974*cdf0e10cSrcweir         //... todo ...
975*cdf0e10cSrcweir         if( bIsStockChart )
976*cdf0e10cSrcweir         {
977*cdf0e10cSrcweir             if( SchXMLSeriesHelper::isCandleStickSeries( iStyle->m_xSeries, uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) )
978*cdf0e10cSrcweir                 continue;
979*cdf0e10cSrcweir         }
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir         // data point style
982*cdf0e10cSrcweir 		for( sal_Int32 i = 0; i < iStyle->m_nPointRepeat; i++ )
983*cdf0e10cSrcweir 		{
984*cdf0e10cSrcweir 			try
985*cdf0e10cSrcweir 			{
986*cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
987*cdf0e10cSrcweir                 if(!xSeriesProp.is())
988*cdf0e10cSrcweir                     continue;
989*cdf0e10cSrcweir 
990*cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet > xPointProp(
991*cdf0e10cSrcweir                     SchXMLSeriesHelper::createOldAPIDataPointPropertySet( iStyle->m_xSeries, iStyle->m_nPointIndex + i
992*cdf0e10cSrcweir                         , uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) );
993*cdf0e10cSrcweir 
994*cdf0e10cSrcweir                 if( !xPointProp.is() )
995*cdf0e10cSrcweir                     continue;
996*cdf0e10cSrcweir 
997*cdf0e10cSrcweir                 if( bIsDonutChart )
998*cdf0e10cSrcweir                 {
999*cdf0e10cSrcweir                     //set special series styles for donut charts first
1000*cdf0e10cSrcweir                     if( !rCurrStyleName.equals( iStyle->msSeriesStyleNameForDonuts ) )
1001*cdf0e10cSrcweir 					{
1002*cdf0e10cSrcweir 						rCurrStyleName = iStyle->msSeriesStyleNameForDonuts;
1003*cdf0e10cSrcweir 						rpStyle = pStylesCtxt->FindStyleChildContext(
1004*cdf0e10cSrcweir 							rImportHelper.GetChartFamilyID(), rCurrStyleName );
1005*cdf0e10cSrcweir 					}
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir                     // note: SvXMLStyleContext::FillPropertySet is not const
1008*cdf0e10cSrcweir                     XMLPropStyleContext * pPropStyleContext =
1009*cdf0e10cSrcweir                         const_cast< XMLPropStyleContext * >(
1010*cdf0e10cSrcweir                             dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
1011*cdf0e10cSrcweir                     if( pPropStyleContext )
1012*cdf0e10cSrcweir 						pPropStyleContext->FillPropertySet( xPointProp );
1013*cdf0e10cSrcweir                 }
1014*cdf0e10cSrcweir 
1015*cdf0e10cSrcweir                 try
1016*cdf0e10cSrcweir                 {
1017*cdf0e10cSrcweir                     //need to set this explicitely here for old files as the new api does not support this property fully anymore
1018*cdf0e10cSrcweir                     if( bSwitchOffLinesForScatter )
1019*cdf0e10cSrcweir                         xPointProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lines")),uno::makeAny(sal_False));
1020*cdf0e10cSrcweir                 }
1021*cdf0e10cSrcweir                 catch( uno::Exception & rEx )
1022*cdf0e10cSrcweir                 {
1023*cdf0e10cSrcweir                     (void)rEx; // avoid warning for pro build
1024*cdf0e10cSrcweir                 }
1025*cdf0e10cSrcweir 
1026*cdf0e10cSrcweir 				if( !rCurrStyleName.equals( iStyle->msStyleName ) )
1027*cdf0e10cSrcweir 				{
1028*cdf0e10cSrcweir 					rCurrStyleName = iStyle->msStyleName;
1029*cdf0e10cSrcweir 					rpStyle = pStylesCtxt->FindStyleChildContext(
1030*cdf0e10cSrcweir 						rImportHelper.GetChartFamilyID(), rCurrStyleName );
1031*cdf0e10cSrcweir 				}
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir                 // note: SvXMLStyleContext::FillPropertySet is not const
1034*cdf0e10cSrcweir                 XMLPropStyleContext * pPropStyleContext =
1035*cdf0e10cSrcweir                     const_cast< XMLPropStyleContext * >(
1036*cdf0e10cSrcweir                         dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
1037*cdf0e10cSrcweir                 if( pPropStyleContext )
1038*cdf0e10cSrcweir                 {
1039*cdf0e10cSrcweir                     pPropStyleContext->FillPropertySet( xPointProp );
1040*cdf0e10cSrcweir                     if( iStyle->mbSymbolSizeForSeriesIsMissingInFile )
1041*cdf0e10cSrcweir                         lcl_resetSymbolSizeForPointsIfNecessary( xPointProp, rImport, pPropStyleContext, pStylesCtxt );
1042*cdf0e10cSrcweir                 }
1043*cdf0e10cSrcweir 			}
1044*cdf0e10cSrcweir 			catch( uno::Exception & rEx )
1045*cdf0e10cSrcweir 			{
1046*cdf0e10cSrcweir                 (void)rEx; // avoid warning for pro build
1047*cdf0e10cSrcweir 				DBG_ERROR1( "Exception caught during setting styles to data points: %s",
1048*cdf0e10cSrcweir                                     OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
1049*cdf0e10cSrcweir 			}
1050*cdf0e10cSrcweir 		}
1051*cdf0e10cSrcweir 	}	// styles iterator
1052*cdf0e10cSrcweir }
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir //static
1055*cdf0e10cSrcweir void SchXMLSeries2Context::switchSeriesLinesOff( ::std::list< DataRowPointStyle >& rSeriesStyleList )
1056*cdf0e10cSrcweir {
1057*cdf0e10cSrcweir     ::std::list< DataRowPointStyle >::iterator iStyle;
1058*cdf0e10cSrcweir     // iterate over series
1059*cdf0e10cSrcweir 
1060*cdf0e10cSrcweir 	for( iStyle = rSeriesStyleList.begin(); iStyle != rSeriesStyleList.end(); iStyle++ )
1061*cdf0e10cSrcweir 	{
1062*cdf0e10cSrcweir 		if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
1063*cdf0e10cSrcweir             continue;
1064*cdf0e10cSrcweir 
1065*cdf0e10cSrcweir         try
1066*cdf0e10cSrcweir         {
1067*cdf0e10cSrcweir             uno::Reference< beans::XPropertySet > xSeries( iStyle->m_xOldAPISeries );
1068*cdf0e10cSrcweir             if( !xSeries.is() )
1069*cdf0e10cSrcweir                 continue;
1070*cdf0e10cSrcweir 
1071*cdf0e10cSrcweir             xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lines")),uno::makeAny(sal_False));
1072*cdf0e10cSrcweir         }
1073*cdf0e10cSrcweir         catch( uno::Exception &  )
1074*cdf0e10cSrcweir         {
1075*cdf0e10cSrcweir             //end of series reached
1076*cdf0e10cSrcweir         }
1077*cdf0e10cSrcweir     }
1078*cdf0e10cSrcweir }
1079