Update ooo320-m1
[ooovba.git] / xmloff / source / chart / SchXMLSeries2Context.cxx
blob82a8973408782cb3feb079541f2b56e81c3d086a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SchXMLSeries2Context.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #include "SchXMLSeries2Context.hxx"
35 #include "SchXMLPlotAreaContext.hxx"
36 #include "SchXMLSeriesHelper.hxx"
37 #include "SchXMLTools.hxx"
38 #include "PropertyMap.hxx"
40 #include <com/sun/star/chart2/XChartDocument.hpp>
41 #include <com/sun/star/chart2/XDataSeries.hpp>
42 #include <com/sun/star/chart2/XRegressionCurve.hpp>
43 #include <com/sun/star/chart2/data/XDataSink.hpp>
44 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
45 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
47 #include <com/sun/star/chart/ChartAxisAssign.hpp>
48 #include <com/sun/star/chart/ChartSymbolType.hpp>
49 #include <com/sun/star/container/XChild.hpp>
50 #include <com/sun/star/chart/ChartLegendPosition.hpp>
51 #include <com/sun/star/drawing/LineStyle.hpp>
52 #include <com/sun/star/embed/Aspects.hpp>
53 #include <com/sun/star/embed/XVisualObject.hpp>
54 #include <com/sun/star/uno/XComponentContext.hpp>
56 // header for define DBG_ERROR1
57 #include <tools/debug.hxx>
58 #include <rtl/ustrbuf.hxx>
59 #include "xmlnmspe.hxx"
60 #include <xmloff/xmlimp.hxx>
61 #ifndef _XMLOFF_NMSPMAP_HX
62 #include <xmloff/nmspmap.hxx>
63 #endif
64 #include "SchXMLImport.hxx"
65 // header for class XMLPropStyleContext
66 #include <xmloff/prstylei.hxx>
67 #include <xmloff/xmlprmap.hxx>
69 #include <typeinfo>
71 using namespace ::com::sun::star;
72 using namespace ::xmloff::token;
74 using ::com::sun::star::uno::Reference;
75 using ::com::sun::star::uno::Sequence;
76 using ::rtl::OUString;
77 using ::rtl::OUStringBuffer;
79 // ================================================================================
81 namespace
84 OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::data::XDataProvider >& xDataProvider )
86 OUString aResult = rRange;
87 Reference< chart2::data::XRangeXMLConversion > xConversion( xDataProvider, uno::UNO_QUERY );
88 if( xConversion.is())
89 aResult = xConversion->convertRangeFromXML( rRange );
90 return aResult;
93 class SchXMLDomain2Context : public SvXMLImportContext
95 private:
96 SchXMLImportHelper& mrImportHelper;
97 ::std::vector< OUString > & mrAddresses;
99 public:
100 SchXMLDomain2Context( SchXMLImportHelper& rImpHelper,
101 SvXMLImport& rImport,
102 sal_uInt16 nPrefix,
103 const rtl::OUString& rLocalName,
104 ::std::vector< OUString > & rAddresses );
105 virtual ~SchXMLDomain2Context();
106 virtual void StartElement( const Reference< xml::sax::XAttributeList >& xAttrList );
109 SchXMLDomain2Context::SchXMLDomain2Context(
110 SchXMLImportHelper& rImpHelper,
111 SvXMLImport& rImport,
112 sal_uInt16 nPrefix,
113 const rtl::OUString& rLocalName,
114 ::std::vector< ::rtl::OUString > & rAddresses ) :
115 SvXMLImportContext( rImport, nPrefix, rLocalName ),
116 mrImportHelper( rImpHelper ),
117 mrAddresses( rAddresses )
121 SchXMLDomain2Context::~SchXMLDomain2Context()
125 void SchXMLDomain2Context::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
127 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
129 for( sal_Int16 i = 0; i < nAttrCount; i++ )
131 rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
132 rtl::OUString aLocalName;
133 USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
135 if( nPrefix == XML_NAMESPACE_TABLE &&
136 IsXMLToken( aLocalName, XML_CELL_RANGE_ADDRESS ) )
138 Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
139 mrAddresses.push_back( xAttrList->getValueByIndex( i ));
144 void lcl_setAutomaticSymbolSize( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const SvXMLImport& rImport )
146 awt::Size aSymbolSize(140,140);//old default for standard sized charts 7cm height
148 double fScale = 1;
149 uno::Reference< chart::XChartDocument > xChartDoc( rImport.GetModel(), uno::UNO_QUERY );
150 if( xChartDoc.is() )
152 uno::Reference< beans::XPropertySet > xLegendProp( xChartDoc->getLegend(), uno::UNO_QUERY );
153 chart::ChartLegendPosition aLegendPosition = chart::ChartLegendPosition_NONE;
154 if( xLegendProp.is() && (xLegendProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Alignment" ))) >>= aLegendPosition)
155 && chart::ChartLegendPosition_NONE != aLegendPosition )
158 double fFontHeight = 6.0;
159 if( xLegendProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ))) >>= fFontHeight )
160 fScale = 0.75*fFontHeight/6.0;
162 else
164 uno::Reference< embed::XVisualObject > xVisualObject( rImport.GetModel(), uno::UNO_QUERY );
165 if( xVisualObject.is() )
167 awt::Size aPageSize( xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ) );
168 fScale = aPageSize.Height/7000.0;
171 if( fScale>0 )
173 aSymbolSize.Height = static_cast<sal_Int32>( fScale * aSymbolSize.Height );
174 aSymbolSize.Width = aSymbolSize.Height;
177 xSeriesOrPointProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize")),uno::makeAny( aSymbolSize ));
180 void lcl_setSymbolSizeIfNeeded( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const SvXMLImport& rImport )
182 if( !xSeriesOrPointProp.is() )
183 return;
185 sal_Int32 nSymbolType = chart::ChartSymbolType::NONE;
186 if( xSeriesOrPointProp.is() && ( xSeriesOrPointProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolType"))) >>= nSymbolType) )
188 if(chart::ChartSymbolType::NONE!=nSymbolType)
190 if( chart::ChartSymbolType::BITMAPURL==nSymbolType )
192 //set special size for graphics to indicate to use the bitmap size itself
193 xSeriesOrPointProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize")),uno::makeAny( awt::Size(-1,-1) ));
195 else
197 lcl_setAutomaticSymbolSize( xSeriesOrPointProp, rImport );
203 void lcl_resetSymbolSizeForPointsIfNecessary( const uno::Reference< beans::XPropertySet >& xPointProp, const SvXMLImport& rImport
204 , const XMLPropStyleContext * pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
206 uno::Any aASymbolSize( SchXMLTools::getPropertyFromContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize")), pPropStyleContext, pStylesCtxt ) );
207 if( !aASymbolSize.hasValue() )
208 lcl_setSymbolSizeIfNeeded( xPointProp, rImport );
211 void lcl_insertErrorBarLSequencesToMap(
212 tSchXMLLSequencesPerIndex & rInOutMap,
213 const uno::Reference< beans::XPropertySet > & xSeriesProp,
214 bool bYError = true )
216 Reference< chart2::data::XDataSource > xErrorBarSource;
217 const OUString aPropName(
218 bYError
219 ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorBarY" ))
220 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorBarX" )));
221 if( ( xSeriesProp->getPropertyValue( aPropName ) >>= xErrorBarSource ) &&
222 xErrorBarSource.is() )
224 Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSequences(
225 xErrorBarSource->getDataSequences());
226 for( sal_Int32 nIndex = 0; nIndex < aLSequences.getLength(); ++nIndex )
228 // use "0" as data index. This is ok, as it is not used for error bars
229 rInOutMap.insert(
230 tSchXMLLSequencesPerIndex::value_type(
231 tSchXMLIndexWithPart( 0, SCH_XML_PART_ERROR_BARS ), aLSequences[ nIndex ] ));
236 Reference< chart2::data::XLabeledDataSequence > lcl_createAndAddSequenceToSeries( const rtl::OUString& rRole
237 , const rtl::OUString& rRange
238 , const Reference< chart2::data::XDataProvider >& xDataProvider
239 , const Reference< chart2::XDataSeries >& xSeries )
241 Reference< chart2::data::XLabeledDataSequence > xLabeledSeq;
243 Reference< chart2::data::XDataSource > xSeriesSource( xSeries,uno::UNO_QUERY );
244 Reference< chart2::data::XDataSink > xSeriesSink( xSeries, uno::UNO_QUERY );
246 if( !(rRange.getLength() && xDataProvider.is() && xSeriesSource.is() && xSeriesSink.is()) )
247 return xLabeledSeq;
249 // create a new sequence
250 xLabeledSeq = SchXMLTools::GetNewLabeledDataSequence();
252 // set values at the new sequence
253 Reference< chart2::data::XDataSequence > xSeq;
256 xSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( rRange, xDataProvider )));
257 SchXMLTools::setXMLRangePropertyAtDataSequence( xSeq, rRange );
259 catch( const lang::IllegalArgumentException & ex )
261 (void)ex; // avoid warning for pro build
262 OSL_ENSURE( false, ::rtl::OUStringToOString(
263 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IllegalArgumentException caught, Message: " )) +
264 ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
267 Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
268 if( xSeqProp.is())
269 xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( rRole));
270 xLabeledSeq->setValues( xSeq );
272 // add new sequence to data series / push to front to have the correct sequence order if charttype is changed afterwards
273 Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeq( xSeriesSource->getDataSequences());
274 sal_Int32 nOldCount = aOldSeq.getLength();
275 Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeq( nOldCount + 1 );
276 aNewSeq[0]=xLabeledSeq;
277 for( sal_Int32 nN=0; nN<nOldCount; nN++ )
278 aNewSeq[nN+1] = aOldSeq[nN];
279 xSeriesSink->setData( aNewSeq );
281 return xLabeledSeq;
284 } // anonymous namespace
286 // ================================================================================
288 SchXMLSeries2Context::SchXMLSeries2Context(
289 SchXMLImportHelper& rImpHelper,
290 SvXMLImport& rImport, const rtl::OUString& rLocalName,
291 const Reference< chart2::XChartDocument > & xNewDoc,
292 std::vector< SchXMLAxis >& rAxes,
293 ::std::list< DataRowPointStyle >& rStyleList,
294 sal_Int32 nSeriesIndex,
295 sal_Bool bStockHasVolume,
296 GlobalSeriesImportInfo& rGlobalSeriesImportInfo,
297 const OUString & aGlobalChartTypeName,
298 tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
299 bool& rGlobalChartTypeUsedBySeries,
300 const awt::Size & rChartSize ) :
301 SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
302 mrImportHelper( rImpHelper ),
303 mxNewDoc( xNewDoc ),
304 mrAxes( rAxes ),
305 mrStyleList( rStyleList ),
306 m_xSeries(0),
307 mnSeriesIndex( nSeriesIndex ),
308 mnDataPointIndex( 0 ),
309 m_bStockHasVolume( bStockHasVolume ),
310 m_rGlobalSeriesImportInfo(rGlobalSeriesImportInfo),
311 mpAttachedAxis( NULL ),
312 maGlobalChartTypeName( aGlobalChartTypeName ),
313 maSeriesChartTypeName( aGlobalChartTypeName ),
314 m_bHasDomainContext(false),
315 mrLSequencesPerIndex( rLSequencesPerIndex ),
316 mrGlobalChartTypeUsedBySeries( rGlobalChartTypeUsedBySeries ),
317 mbSymbolSizeIsMissingInFile(false),
318 maChartSize( rChartSize )
320 if( 0 == aGlobalChartTypeName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.DonutChartType" ) ) )
322 maSeriesChartTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.PieChartType" ));
323 maGlobalChartTypeName = maSeriesChartTypeName;
327 SchXMLSeries2Context::~SchXMLSeries2Context()
329 OSL_ASSERT( maPostponedSequences.empty());
332 void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
334 // parse attributes
335 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
336 const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetSeriesAttrTokenMap();
337 mnAttachedAxis = 1;
339 bool bHasRange = false;
340 bool bHasLabelRange = false;
342 Reference< chart2::data::XRangeXMLConversion > xRangeConversion;
343 if( mxNewDoc.is())
344 xRangeConversion.set( mxNewDoc->getDataProvider(), uno::UNO_QUERY );
346 for( sal_Int16 i = 0; i < nAttrCount; i++ )
348 rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
349 rtl::OUString aLocalName;
350 rtl::OUString aValue = xAttrList->getValueByIndex( i );
351 USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
353 switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
355 case XML_TOK_SERIES_CELL_RANGE:
356 m_aSeriesRange = aValue;
357 bHasRange = true;
358 break;
359 case XML_TOK_SERIES_LABEL_ADDRESS:
360 m_aSeriesLabelRange = aValue;
361 bHasLabelRange = true;
362 break;
363 case XML_TOK_SERIES_ATTACHED_AXIS:
365 sal_Int32 nNumOfAxes = mrAxes.size();
366 for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ )
368 if( aValue.equals( mrAxes[ nCurrent ].aName ) &&
369 mrAxes[ nCurrent ].eClass == SCH_XML_AXIS_Y )
371 mpAttachedAxis = &( mrAxes[ nCurrent ] );
375 break;
376 case XML_TOK_SERIES_STYLE_NAME:
377 msAutoStyleName = aValue;
378 break;
379 case XML_TOK_SERIES_CHART_CLASS:
381 OUString aClassName;
382 sal_uInt16 nClassPrefix =
383 GetImport().GetNamespaceMap().GetKeyByAttrName(
384 aValue, &aClassName );
385 if( XML_NAMESPACE_CHART == nClassPrefix )
386 maSeriesChartTypeName = SchXMLTools::GetChartTypeByClassName( aClassName, false /* bUseOldNames */ );
388 if( ! maSeriesChartTypeName.getLength())
389 maSeriesChartTypeName = aClassName;
391 break;
395 if( mpAttachedAxis )
397 if( mpAttachedAxis->nIndexInCategory > 0 )
399 // secondary axis => property has to be set (primary is default)
400 mnAttachedAxis = 2;
406 OSL_ASSERT( mxNewDoc.is());
407 if( mxNewDoc.is())
409 if( m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && ! bHasRange )
410 m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable = sal_False;
412 Reference< chart2::data::XDataProvider > xDataProvider( mxNewDoc->getDataProvider() );
413 if( xDataProvider.is())
415 bool bIsCandleStick = maGlobalChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType"));
416 if( maSeriesChartTypeName.getLength() )
418 bIsCandleStick = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType"));
420 else
422 if( bIsCandleStick
423 && m_bStockHasVolume
424 && mnSeriesIndex == 0 )
426 maSeriesChartTypeName = OUString::createFromAscii( "com.sun.star.chart2.ColumnChartType" );
427 bIsCandleStick = false;
429 else
431 maSeriesChartTypeName = maGlobalChartTypeName;
434 if( ! mrGlobalChartTypeUsedBySeries )
435 mrGlobalChartTypeUsedBySeries = (maSeriesChartTypeName.equals( maGlobalChartTypeName ));
436 sal_Int32 nCoordinateSystemIndex = 0;//so far we can only import one coordinate system
437 m_xSeries.set(
438 mrImportHelper.GetNewDataSeries( mxNewDoc, nCoordinateSystemIndex, maSeriesChartTypeName, ! mrGlobalChartTypeUsedBySeries ));
439 Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
440 SchXMLTools::GetNewLabeledDataSequence());
442 if( bIsCandleStick )
444 // set default color for range-line to black (before applying styles)
445 Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
446 if( xSeriesProp.is())
447 xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Color")),
448 uno::makeAny( sal_Int32( 0x000000 ))); // black
450 else if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.PieChartType")))
452 //@todo: this property should be saved
453 Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
454 if( xSeriesProp.is())
455 xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VaryColorsByPoint")),
456 uno::makeAny( true ));
459 // values
460 Reference< chart2::data::XDataSequence > xSeq;
461 if( bHasRange )
464 xSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( m_aSeriesRange, xDataProvider )));
465 SchXMLTools::setXMLRangePropertyAtDataSequence( xSeq, m_aSeriesRange );
467 catch( const lang::IllegalArgumentException & ex )
469 (void)ex; // avoid warning for pro build
470 OSL_ENSURE( false, ::rtl::OUStringToOString(
471 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IllegalArgumentException caught, Message: " )) +
472 ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
475 Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
476 if( xSeqProp.is())
478 OUString aMainRole( OUString::createFromAscii("values-y") );
479 if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType") ) )
480 aMainRole = OUString::createFromAscii("values-size");
481 xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( aMainRole ));
483 xLabeledSeq->setValues( xSeq );
485 // register for setting local data if external data provider is not present
486 maPostponedSequences.insert(
487 tSchXMLLSequencesPerIndex::value_type(
488 tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq ));
490 // label
491 if( bHasLabelRange )
495 Reference< chart2::data::XDataSequence > xLabelSequence(
496 xDataProvider->createDataSequenceByRangeRepresentation(
497 lcl_ConvertRange( m_aSeriesLabelRange, xDataProvider )));
498 xLabeledSeq->setLabel( xLabelSequence );
499 SchXMLTools::setXMLRangePropertyAtDataSequence( xLabelSequence, m_aSeriesLabelRange );
501 catch( const lang::IllegalArgumentException & ex )
503 (void)ex; // avoid warning for pro build
504 OSL_ENSURE( false, ::rtl::OUStringToOString(
505 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IllegalArgumentException caught, Message: " )) +
506 ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
510 // Note: Even if we have no label, we have to register the label
511 // for creation, because internal data always has labels. If
512 // they don't exist in the original, auto-generated labels are
513 // used for the internal data.
514 maPostponedSequences.insert(
515 tSchXMLLSequencesPerIndex::value_type(
516 tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_LABEL ), xLabeledSeq ));
519 Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( &xLabeledSeq, 1 );
520 Reference< chart2::data::XDataSink > xSink( m_xSeries, uno::UNO_QUERY_THROW );
521 xSink->setData( aSeq );
525 catch( uno::Exception & ex )
527 (void)ex; // avoid warning for pro build
528 OSL_ENSURE( false, ::rtl::OUStringToOString(
529 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) +
530 ::rtl::OUString::createFromAscii( typeid( ex ).name()) +
531 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) +
532 ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
535 //init mbSymbolSizeIsMissingInFile:
538 if( msAutoStyleName.getLength() )
540 const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
541 if( pStylesCtxt )
543 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
544 mrImportHelper.GetChartFamilyID(), msAutoStyleName );
546 const XMLPropStyleContext* pPropStyleContext = dynamic_cast< const XMLPropStyleContext * >( pStyle );
548 uno::Any aASymbolSize( SchXMLTools::getPropertyFromContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize"))
549 , pPropStyleContext, pStylesCtxt ) );
550 mbSymbolSizeIsMissingInFile = !aASymbolSize.hasValue();
554 catch( uno::Exception & ex )
556 (void)ex; // avoid warning for pro build
560 struct DomainInfo
562 DomainInfo( const rtl::OUString& rRole, const rtl::OUString& rRange, sal_Int32 nIndex )
563 : aRole(rRole), aRange(rRange), nIndexForLocalData(nIndex)
566 rtl::OUString aRole;
567 rtl::OUString aRange;
568 sal_Int32 nIndexForLocalData;
571 void SchXMLSeries2Context::EndElement()
573 // special handling for different chart types. This is necessary as the
574 // roles are not yet saved in the file format
575 sal_Int32 nDomainCount = maDomainAddresses.size();
576 bool bIsScatterChart = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ScatterChartType"));
577 bool bIsBubbleChart = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType"));
578 bool bDeleteSeries = false;
579 std::vector< DomainInfo > aDomainInfos;
581 //different handling for different chart types necessary
582 if( bIsScatterChart || ( nDomainCount==1 && !bIsBubbleChart ) )
584 DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress, m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex ) ;
585 bool bCreateXValues = true;
586 if( !maDomainAddresses.empty() )
588 if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() )
590 m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
591 m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
593 aDomainInfo.aRange = maDomainAddresses.front();
594 aDomainInfo.nIndexForLocalData = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
595 m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
597 else if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() && !m_bHasDomainContext && mnSeriesIndex==0 )
599 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) ) //wrong old chart files:
601 //for xy charts the first series needs to have a domain
602 //if this by error iss not the case the first series is taken s x values
603 //needed for wrong files created while having an addin (e.g. BoxPlot)
604 m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = m_aSeriesRange;
605 m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
606 bDeleteSeries = true;
607 bCreateXValues = false;//they will be created for the next series
610 if( bCreateXValues )
611 aDomainInfos.push_back( aDomainInfo );
613 else if( bIsBubbleChart )
615 if( nDomainCount>1 )
617 DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), maDomainAddresses[1], m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
618 if( !m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.getLength() )
620 //for bubble chart the second domain contains the x values which should become an index smaller than y values for own data table
621 //->so second first
622 m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress = maDomainAddresses[1];
623 m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
625 aDomainInfos.push_back( aDomainInfo );
626 m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
628 else if( m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.getLength() )
630 DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress, m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex ) ;
631 aDomainInfos.push_back( aDomainInfo );
633 if( nDomainCount>0)
635 DomainInfo aDomainInfo( OUString::createFromAscii("values-y"), maDomainAddresses.front(), m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
636 if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() )
638 m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
639 m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
641 aDomainInfos.push_back( aDomainInfo );
642 m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
646 if( bDeleteSeries )
648 //delete created series
649 SchXMLImportHelper::DeleteDataSeries(
650 m_xSeries, Reference< chart2::XChartDocument >( GetImport().GetModel(), uno::UNO_QUERY ) );
652 else
654 //add style
655 if( msAutoStyleName.getLength() ||
656 mnAttachedAxis != 1 )
658 DataRowPointStyle aStyle(
659 DataRowPointStyle::DATA_SERIES,
660 m_xSeries,
661 -1, 1,
662 msAutoStyleName, mnAttachedAxis );
663 aStyle.mbSymbolSizeForSeriesIsMissingInFile=mbSymbolSizeIsMissingInFile;
664 mrStyleList.push_back( aStyle );
668 Reference< chart2::data::XDataProvider > xDataProvider;
669 if ( mxNewDoc.is() ) {
670 xDataProvider = mxNewDoc->getDataProvider();
672 for( std::vector< DomainInfo >::reverse_iterator aIt( aDomainInfos.rbegin() ); aIt!= aDomainInfos.rend(); ++aIt )
674 DomainInfo aDomainInfo( *aIt );
675 Reference< chart2::data::XLabeledDataSequence > xLabeledSeq =
676 lcl_createAndAddSequenceToSeries( aDomainInfo.aRole, aDomainInfo.aRange, xDataProvider, m_xSeries );
677 if( xLabeledSeq.is() )
679 // register for setting local data if external data provider is not present
680 mrLSequencesPerIndex.insert(
681 tSchXMLLSequencesPerIndex::value_type(
682 tSchXMLIndexWithPart( aDomainInfo.nIndexForLocalData, SCH_XML_PART_VALUES ), xLabeledSeq ));
686 if( !bDeleteSeries )
688 for( tSchXMLLSequencesPerIndex::const_iterator aIt( maPostponedSequences.begin());
689 aIt != maPostponedSequences.end(); ++aIt )
691 sal_Int32 nNewIndex = aIt->first.first + nDomainCount;
692 mrLSequencesPerIndex.insert(
693 tSchXMLLSequencesPerIndex::value_type(
694 tSchXMLIndexWithPart( nNewIndex, aIt->first.second ), aIt->second ));
696 m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
698 maPostponedSequences.clear();
701 SvXMLImportContext* SchXMLSeries2Context::CreateChildContext(
702 USHORT nPrefix,
703 const rtl::OUString& rLocalName,
704 const uno::Reference< xml::sax::XAttributeList >& )
706 SvXMLImportContext* pContext = 0;
707 const SvXMLTokenMap& rTokenMap = mrImportHelper.GetSeriesElemTokenMap();
709 switch( rTokenMap.Get( nPrefix, rLocalName ))
711 case XML_TOK_SERIES_DOMAIN:
712 if( m_xSeries.is())
714 m_bHasDomainContext = true;
715 pContext = new SchXMLDomain2Context(
716 mrImportHelper, GetImport(),
717 nPrefix, rLocalName,
718 maDomainAddresses );
720 break;
722 case XML_TOK_SERIES_MEAN_VALUE_LINE:
723 pContext = new SchXMLStatisticsObjectContext(
724 mrImportHelper, GetImport(),
725 nPrefix, rLocalName,
726 mrStyleList, m_xSeries,
727 SchXMLStatisticsObjectContext::CONTEXT_TYPE_MEAN_VALUE_LINE,
728 maChartSize );
729 break;
730 case XML_TOK_SERIES_REGRESSION_CURVE:
731 pContext = new SchXMLStatisticsObjectContext(
732 mrImportHelper, GetImport(),
733 nPrefix, rLocalName,
734 mrStyleList, m_xSeries,
735 SchXMLStatisticsObjectContext::CONTEXT_TYPE_REGRESSION_CURVE,
736 maChartSize );
737 break;
738 case XML_TOK_SERIES_ERROR_INDICATOR:
739 pContext = new SchXMLStatisticsObjectContext(
740 mrImportHelper, GetImport(),
741 nPrefix, rLocalName,
742 mrStyleList, m_xSeries,
743 SchXMLStatisticsObjectContext::CONTEXT_TYPE_ERROR_INDICATOR,
744 maChartSize );
745 break;
747 case XML_TOK_SERIES_DATA_POINT:
748 pContext = new SchXMLDataPointContext( mrImportHelper, GetImport(), rLocalName,
749 mrStyleList, m_xSeries, mnDataPointIndex, mbSymbolSizeIsMissingInFile );
750 break;
752 default:
753 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
756 return pContext;
759 //static
760 void SchXMLSeries2Context::initSeriesPropertySets( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
761 , const uno::Reference< frame::XModel >& xChartModel )
763 ::std::list< DataRowPointStyle >::iterator iStyle;
765 // iterate over series first and remind propertysets in map
766 // new api <-> old api wrapper
767 ::std::map< Reference< chart2::XDataSeries >, Reference< beans::XPropertySet > > aSeriesMap;
768 for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
770 if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
771 continue;
773 if( !iStyle->m_xOldAPISeries.is() )
774 iStyle->m_xOldAPISeries = SchXMLSeriesHelper::createOldAPISeriesPropertySet( iStyle->m_xSeries, xChartModel );
776 aSeriesMap[iStyle->m_xSeries] = iStyle->m_xOldAPISeries;
780 //initialize m_xOldAPISeries for all other styles also
781 for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
783 if( iStyle->meType == DataRowPointStyle::DATA_SERIES )
784 continue;
785 iStyle->m_xOldAPISeries = aSeriesMap[iStyle->m_xSeries];
789 //static
790 void SchXMLSeries2Context::setDefaultsToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles )
792 ::std::list< DataRowPointStyle >::iterator iStyle;
793 // iterate over series
794 // call initSeriesPropertySets first
796 for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
798 if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
799 continue;
803 uno::Reference< beans::XPropertySet > xSeries( iStyle->m_xOldAPISeries );
804 if( !xSeries.is() )
805 continue;
807 if( rSeriesDefaultsAndStyles.maSymbolTypeDefault.hasValue() )
808 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolType")),rSeriesDefaultsAndStyles.maSymbolTypeDefault);
809 if( rSeriesDefaultsAndStyles.maDataCaptionDefault.hasValue() )
810 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCaption")),rSeriesDefaultsAndStyles.maDataCaptionDefault);
812 if( rSeriesDefaultsAndStyles.maErrorIndicatorDefault.hasValue() )
813 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorIndicator")),rSeriesDefaultsAndStyles.maErrorIndicatorDefault);
814 if( rSeriesDefaultsAndStyles.maErrorCategoryDefault.hasValue() )
815 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorCategory")),rSeriesDefaultsAndStyles.maErrorCategoryDefault);
816 if( rSeriesDefaultsAndStyles.maConstantErrorLowDefault.hasValue() )
817 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorLow")),rSeriesDefaultsAndStyles.maConstantErrorLowDefault);
818 if( rSeriesDefaultsAndStyles.maConstantErrorHighDefault.hasValue() )
819 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorHigh")),rSeriesDefaultsAndStyles.maConstantErrorHighDefault);
820 if( rSeriesDefaultsAndStyles.maPercentageErrorDefault.hasValue() )
821 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PercentageError")),rSeriesDefaultsAndStyles.maPercentageErrorDefault);
822 if( rSeriesDefaultsAndStyles.maErrorMarginDefault.hasValue() )
823 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorMargin")),rSeriesDefaultsAndStyles.maErrorMarginDefault);
825 if( rSeriesDefaultsAndStyles.maMeanValueDefault.hasValue() )
826 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MeanValue")),rSeriesDefaultsAndStyles.maMeanValueDefault);
827 if( rSeriesDefaultsAndStyles.maRegressionCurvesDefault.hasValue() )
828 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RegressionCurves")),rSeriesDefaultsAndStyles.maRegressionCurvesDefault);
830 catch( uno::Exception & )
832 //end of series reached
837 //static
838 void SchXMLSeries2Context::setStylesToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
839 , const SvXMLStylesContext* pStylesCtxt
840 , const SvXMLStyleContext*& rpStyle
841 , ::rtl::OUString& rCurrStyleName
842 , SchXMLImportHelper& rImportHelper
843 , const SvXMLImport& rImport
844 , bool bIsStockChart
845 , tSchXMLLSequencesPerIndex & rInOutLSequencesPerIndex )
847 ::std::list< DataRowPointStyle >::iterator iStyle;
849 // iterate over series
850 for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
852 if( iStyle->meType == DataRowPointStyle::DATA_SERIES )
856 uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
857 if( !xSeriesProp.is() )
858 continue;
860 if( iStyle->mnAttachedAxis != 1 )
862 xSeriesProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Axis" ))
863 , uno::makeAny(chart::ChartAxisAssign::SECONDARY_Y) );
866 if( (iStyle->msStyleName).getLength())
868 if( ! rCurrStyleName.equals( iStyle->msStyleName ))
870 rCurrStyleName = iStyle->msStyleName;
871 rpStyle = pStylesCtxt->FindStyleChildContext(
872 rImportHelper.GetChartFamilyID(), rCurrStyleName );
875 //set style to series
876 // note: SvXMLStyleContext::FillPropertySet is not const
877 XMLPropStyleContext * pPropStyleContext =
878 const_cast< XMLPropStyleContext * >(
879 dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
880 if( pPropStyleContext )
882 // error bar style must be set before the other error
883 // bar properties (which may be alphabetically before
884 // this property)
885 bool bHasErrorBarRangesFromData = false;
887 const ::rtl::OUString aErrorBarStylePropName( RTL_CONSTASCII_USTRINGPARAM("ErrorBarStyle"));
888 uno::Any aErrorBarStyle(
889 SchXMLTools::getPropertyFromContext( aErrorBarStylePropName, pPropStyleContext, pStylesCtxt ));
890 if( aErrorBarStyle.hasValue())
892 xSeriesProp->setPropertyValue( aErrorBarStylePropName, aErrorBarStyle );
893 sal_Int32 eEBStyle = chart::ErrorBarStyle::NONE;
894 bHasErrorBarRangesFromData =
895 ( ( aErrorBarStyle >>= eEBStyle ) &&
896 eEBStyle == chart::ErrorBarStyle::FROM_DATA );
900 //don't set the style to the min max line series of a stock chart
901 //otherwise the min max line properties gets overwritten and the series becomes invisible typically
902 bool bIsMinMaxSeries = false;
903 if( bIsStockChart )
905 if( SchXMLSeriesHelper::isCandleStickSeries( iStyle->m_xSeries
906 , uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) )
907 bIsMinMaxSeries = true;
909 if( !bIsMinMaxSeries )
911 pPropStyleContext->FillPropertySet( xSeriesProp );
912 if( iStyle->mbSymbolSizeForSeriesIsMissingInFile )
913 lcl_setSymbolSizeIfNeeded( xSeriesProp, rImport );
914 if( bHasErrorBarRangesFromData )
915 lcl_insertErrorBarLSequencesToMap( rInOutLSequencesPerIndex, xSeriesProp );
920 catch( uno::Exception & rEx )
922 (void)rEx; // avoid warning for pro build
923 DBG_ERROR1( "Exception caught during setting styles to series: %s",
924 OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
930 // static
931 void SchXMLSeries2Context::setStylesToStatisticsObjects( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
932 , const SvXMLStylesContext* pStylesCtxt
933 , const SvXMLStyleContext*& rpStyle
934 , ::rtl::OUString& rCurrStyleName )
936 ::std::list< DataRowPointStyle >::iterator iStyle;
938 // iterate over regession etc
939 for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
941 if( iStyle->meType == DataRowPointStyle::REGRESSION ||
942 iStyle->meType == DataRowPointStyle::ERROR_INDICATOR ||
943 iStyle->meType == DataRowPointStyle::MEAN_VALUE )
947 uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
948 if( !xSeriesProp.is() )
949 continue;
951 if( (iStyle->msStyleName).getLength())
953 if( ! rCurrStyleName.equals( iStyle->msStyleName ))
955 rCurrStyleName = iStyle->msStyleName;
956 rpStyle = pStylesCtxt->FindStyleChildContext(
957 SchXMLImportHelper::GetChartFamilyID(), rCurrStyleName );
960 // note: SvXMLStyleContext::FillPropertySet is not const
961 XMLPropStyleContext * pPropStyleContext =
962 const_cast< XMLPropStyleContext * >(
963 dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
964 if( pPropStyleContext )
966 Reference< beans::XPropertySet > xStatPropSet;
967 switch( iStyle->meType )
969 case DataRowPointStyle::MEAN_VALUE:
970 xSeriesProp->getPropertyValue(
971 OUString( RTL_CONSTASCII_USTRINGPARAM(
972 "DataMeanValueProperties" ))) >>= xStatPropSet;
973 break;
974 case DataRowPointStyle::REGRESSION:
975 xSeriesProp->getPropertyValue(
976 OUString( RTL_CONSTASCII_USTRINGPARAM(
977 "DataRegressionProperties" ))) >>= xStatPropSet;
978 break;
979 case DataRowPointStyle::ERROR_INDICATOR:
980 xSeriesProp->getPropertyValue(
981 OUString( RTL_CONSTASCII_USTRINGPARAM(
982 "DataErrorProperties" ))) >>= xStatPropSet;
983 break;
984 default:
985 break;
987 if( xStatPropSet.is())
988 pPropStyleContext->FillPropertySet( xStatPropSet );
992 // set equation properties at a regression curve
993 // note: this must be done after setting the regression
994 // properties at the old API, otherwise the curve itself does
995 // not exist here
996 if( iStyle->meType == DataRowPointStyle::REGRESSION && iStyle->m_xEquationProperties.is())
998 OSL_ASSERT( iStyle->m_xSeries.is());
999 Reference< chart2::XRegressionCurve > xRegCurve( SchXMLTools::getRegressionCurve( iStyle->m_xSeries ));
1000 if( xRegCurve.is())
1001 xRegCurve->setEquationProperties( iStyle->m_xEquationProperties );
1004 catch( uno::Exception & rEx )
1006 (void)rEx; // avoid warning for pro build
1007 DBG_ERROR1( "Exception caught during setting styles to series: %s",
1008 OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
1014 //static
1015 void SchXMLSeries2Context::setStylesToDataPoints( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
1016 , const SvXMLStylesContext* pStylesCtxt
1017 , const SvXMLStyleContext*& rpStyle
1018 , ::rtl::OUString& rCurrStyleName
1019 , SchXMLImportHelper& rImportHelper
1020 , const SvXMLImport& rImport
1021 , bool bIsStockChart, bool bIsDonutChart, bool bSwitchOffLinesForScatter )
1023 ::std::list< DataRowPointStyle >::iterator iStyle;
1024 for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
1026 if( iStyle->meType != DataRowPointStyle::DATA_POINT )
1027 continue;
1029 if( iStyle->m_nPointIndex == -1 )
1030 continue;
1032 //ignore datapoint properties for stock charts
1033 //... todo ...
1034 if( bIsStockChart )
1036 if( SchXMLSeriesHelper::isCandleStickSeries( iStyle->m_xSeries, uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) )
1037 continue;
1040 // data point style
1041 for( sal_Int32 i = 0; i < iStyle->m_nPointRepeat; i++ )
1045 uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
1046 if(!xSeriesProp.is())
1047 continue;
1049 uno::Reference< beans::XPropertySet > xPointProp(
1050 SchXMLSeriesHelper::createOldAPIDataPointPropertySet( iStyle->m_xSeries, iStyle->m_nPointIndex + i
1051 , uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) );
1053 if( !xPointProp.is() )
1054 continue;
1056 if( bIsDonutChart )
1058 //set special series styles for donut charts first
1059 if( !rCurrStyleName.equals( iStyle->msSeriesStyleNameForDonuts ) )
1061 rCurrStyleName = iStyle->msSeriesStyleNameForDonuts;
1062 rpStyle = pStylesCtxt->FindStyleChildContext(
1063 rImportHelper.GetChartFamilyID(), rCurrStyleName );
1066 // note: SvXMLStyleContext::FillPropertySet is not const
1067 XMLPropStyleContext * pPropStyleContext =
1068 const_cast< XMLPropStyleContext * >(
1069 dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
1070 if( pPropStyleContext )
1071 pPropStyleContext->FillPropertySet( xPointProp );
1076 //need to set this explicitely here for old files as the new api does not support this property fully anymore
1077 if( bSwitchOffLinesForScatter )
1078 xPointProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lines")),uno::makeAny(sal_False));
1080 catch( uno::Exception & rEx )
1082 (void)rEx; // avoid warning for pro build
1085 if( !rCurrStyleName.equals( iStyle->msStyleName ) )
1087 rCurrStyleName = iStyle->msStyleName;
1088 rpStyle = pStylesCtxt->FindStyleChildContext(
1089 rImportHelper.GetChartFamilyID(), rCurrStyleName );
1092 // note: SvXMLStyleContext::FillPropertySet is not const
1093 XMLPropStyleContext * pPropStyleContext =
1094 const_cast< XMLPropStyleContext * >(
1095 dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
1096 if( pPropStyleContext )
1098 pPropStyleContext->FillPropertySet( xPointProp );
1099 if( iStyle->mbSymbolSizeForSeriesIsMissingInFile )
1100 lcl_resetSymbolSizeForPointsIfNecessary( xPointProp, rImport, pPropStyleContext, pStylesCtxt );
1103 catch( uno::Exception & rEx )
1105 (void)rEx; // avoid warning for pro build
1106 DBG_ERROR1( "Exception caught during setting styles to data points: %s",
1107 OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
1110 } // styles iterator
1113 //static
1114 void SchXMLSeries2Context::switchSeriesLinesOff( ::std::list< DataRowPointStyle >& rSeriesStyleList )
1116 ::std::list< DataRowPointStyle >::iterator iStyle;
1117 // iterate over series
1119 for( iStyle = rSeriesStyleList.begin(); iStyle != rSeriesStyleList.end(); iStyle++ )
1121 if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
1122 continue;
1126 uno::Reference< beans::XPropertySet > xSeries( iStyle->m_xOldAPISeries );
1127 if( !xSeries.is() )
1128 continue;
1130 xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lines")),uno::makeAny(sal_False));
1132 catch( uno::Exception & )
1134 //end of series reached