1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SchXMLSeries2Context.cxx,v $
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>
64 #include "SchXMLImport.hxx"
65 // header for class XMLPropStyleContext
66 #include <xmloff/prstylei.hxx>
67 #include <xmloff/xmlprmap.hxx>
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 // ================================================================================
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
);
89 aResult
= xConversion
->convertRangeFromXML( rRange
);
93 class SchXMLDomain2Context
: public SvXMLImportContext
96 SchXMLImportHelper
& mrImportHelper
;
97 ::std::vector
< OUString
> & mrAddresses
;
100 SchXMLDomain2Context( SchXMLImportHelper
& rImpHelper
,
101 SvXMLImport
& rImport
,
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
,
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
149 uno::Reference
< chart::XChartDocument
> xChartDoc( rImport
.GetModel(), uno::UNO_QUERY
);
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;
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;
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() )
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) ));
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(
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
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()) )
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
);
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
);
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
),
305 mrStyleList( rStyleList
),
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
)
335 sal_Int16 nAttrCount
= xAttrList
.is()? xAttrList
->getLength(): 0;
336 const SvXMLTokenMap
& rAttrTokenMap
= mrImportHelper
.GetSeriesAttrTokenMap();
339 bool bHasRange
= false;
340 bool bHasLabelRange
= false;
342 Reference
< chart2::data::XRangeXMLConversion
> xRangeConversion
;
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
;
359 case XML_TOK_SERIES_LABEL_ADDRESS
:
360 m_aSeriesLabelRange
= aValue
;
361 bHasLabelRange
= true;
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
] );
376 case XML_TOK_SERIES_STYLE_NAME
:
377 msAutoStyleName
= aValue
;
379 case XML_TOK_SERIES_CHART_CLASS
:
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
;
397 if( mpAttachedAxis
->nIndexInCategory
> 0 )
399 // secondary axis => property has to be set (primary is default)
406 OSL_ASSERT( 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"));
424 && mnSeriesIndex
== 0 )
426 maSeriesChartTypeName
= OUString::createFromAscii( "com.sun.star.chart2.ColumnChartType" );
427 bIsCandleStick
= false;
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
438 mrImportHelper
.GetNewDataSeries( mxNewDoc
, nCoordinateSystemIndex
, maSeriesChartTypeName
, ! mrGlobalChartTypeUsedBySeries
));
439 Reference
< chart2::data::XLabeledDataSequence
> xLabeledSeq(
440 SchXMLTools::GetNewLabeledDataSequence());
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 ));
460 Reference
< chart2::data::XDataSequence
> xSeq
;
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
);
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
));
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();
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
562 DomainInfo( const rtl::OUString
& rRole
, const rtl::OUString
& rRange
, sal_Int32 nIndex
)
563 : aRole(rRole
), aRange(rRange
), nIndexForLocalData(nIndex
)
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
611 aDomainInfos
.push_back( aDomainInfo
);
613 else if( bIsBubbleChart
)
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
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
);
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
++;
648 //delete created series
649 SchXMLImportHelper::DeleteDataSeries(
650 m_xSeries
, Reference
< chart2::XChartDocument
>( GetImport().GetModel(), uno::UNO_QUERY
) );
655 if( msAutoStyleName
.getLength() ||
656 mnAttachedAxis
!= 1 )
658 DataRowPointStyle
aStyle(
659 DataRowPointStyle::DATA_SERIES
,
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
));
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(
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
:
714 m_bHasDomainContext
= true;
715 pContext
= new SchXMLDomain2Context(
716 mrImportHelper
, GetImport(),
722 case XML_TOK_SERIES_MEAN_VALUE_LINE
:
723 pContext
= new SchXMLStatisticsObjectContext(
724 mrImportHelper
, GetImport(),
726 mrStyleList
, m_xSeries
,
727 SchXMLStatisticsObjectContext::CONTEXT_TYPE_MEAN_VALUE_LINE
,
730 case XML_TOK_SERIES_REGRESSION_CURVE
:
731 pContext
= new SchXMLStatisticsObjectContext(
732 mrImportHelper
, GetImport(),
734 mrStyleList
, m_xSeries
,
735 SchXMLStatisticsObjectContext::CONTEXT_TYPE_REGRESSION_CURVE
,
738 case XML_TOK_SERIES_ERROR_INDICATOR
:
739 pContext
= new SchXMLStatisticsObjectContext(
740 mrImportHelper
, GetImport(),
742 mrStyleList
, m_xSeries
,
743 SchXMLStatisticsObjectContext::CONTEXT_TYPE_ERROR_INDICATOR
,
747 case XML_TOK_SERIES_DATA_POINT
:
748 pContext
= new SchXMLDataPointContext( mrImportHelper
, GetImport(), rLocalName
,
749 mrStyleList
, m_xSeries
, mnDataPointIndex
, mbSymbolSizeIsMissingInFile
);
753 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
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
)
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
)
785 iStyle
->m_xOldAPISeries
= aSeriesMap
[iStyle
->m_xSeries
];
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
)
803 uno::Reference
< beans::XPropertySet
> xSeries( iStyle
->m_xOldAPISeries
);
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
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
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() )
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
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;
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() );
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() )
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
;
974 case DataRowPointStyle::REGRESSION
:
975 xSeriesProp
->getPropertyValue(
976 OUString( RTL_CONSTASCII_USTRINGPARAM(
977 "DataRegressionProperties" ))) >>= xStatPropSet
;
979 case DataRowPointStyle::ERROR_INDICATOR
:
980 xSeriesProp
->getPropertyValue(
981 OUString( RTL_CONSTASCII_USTRINGPARAM(
982 "DataErrorProperties" ))) >>= xStatPropSet
;
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
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
));
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() );
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
)
1029 if( iStyle
->m_nPointIndex
== -1 )
1032 //ignore datapoint properties for stock charts
1036 if( SchXMLSeriesHelper::isCandleStickSeries( iStyle
->m_xSeries
, uno::Reference
< frame::XModel
>( rImportHelper
.GetChartDocument(), uno::UNO_QUERY
) ) )
1041 for( sal_Int32 i
= 0; i
< iStyle
->m_nPointRepeat
; i
++ )
1045 uno::Reference
< beans::XPropertySet
> xSeriesProp( iStyle
->m_xOldAPISeries
);
1046 if(!xSeriesProp
.is())
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() )
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
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
)
1126 uno::Reference
< beans::XPropertySet
> xSeries( iStyle
->m_xOldAPISeries
);
1130 xSeries
->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lines")),uno::makeAny(sal_False
));
1132 catch( uno::Exception
& )
1134 //end of series reached