LCOV - code coverage report
Current view: top level - xmloff/source/chart - SchXMLSeries2Context.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 492 0.0 %
Date: 2014-04-14 Functions: 0 26 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10