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

Generated by: LCOV version 1.10