LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/chart - SchXMLSeries2Context.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 449 0.0 %
Date: 2012-12-27 Functions: 0 24 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             : 
      21             : #include "SchXMLSeries2Context.hxx"
      22             : #include "SchXMLPlotAreaContext.hxx"
      23             : #include "SchXMLSeriesHelper.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/data/XDataSink.hpp>
      31             : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
      32             : 
      33             : #include <com/sun/star/chart/ChartAxisAssign.hpp>
      34             : #include <com/sun/star/chart/ChartSymbolType.hpp>
      35             : #include <com/sun/star/container/XChild.hpp>
      36             : #include <com/sun/star/chart/ChartLegendPosition.hpp>
      37             : #include <com/sun/star/drawing/LineStyle.hpp>
      38             : #include <com/sun/star/embed/Aspects.hpp>
      39             : #include <com/sun/star/embed/XVisualObject.hpp>
      40             : #include <com/sun/star/uno/XComponentContext.hpp>
      41             : 
      42             : // header for define DBG_ERROR1
      43             : #include <tools/debug.hxx>
      44             : #include <rtl/ustrbuf.hxx>
      45             : #include "xmloff/xmlnmspe.hxx"
      46             : #include <xmloff/xmlimp.hxx>
      47             : #include <xmloff/nmspmap.hxx>
      48             : #include "SchXMLImport.hxx"
      49             : // header for class XMLPropStyleContext
      50             : #include <xmloff/prstylei.hxx>
      51             : #include <xmloff/xmlprmap.hxx>
      52             : 
      53             : #include <typeinfo>
      54             : 
      55             : using namespace ::com::sun::star;
      56             : using namespace ::xmloff::token;
      57             : 
      58             : using ::com::sun::star::uno::Reference;
      59             : using ::com::sun::star::uno::Sequence;
      60             : using ::rtl::OUString;
      61             : using ::rtl::OUStringBuffer;
      62             : 
      63             : // ================================================================================
      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 rtl::OUString& rLocalName,
      77             :                           ::std::vector< OUString > & rAddresses );
      78             :     virtual ~SchXMLDomain2Context();
      79             :     virtual void StartElement( const Reference< xml::sax::XAttributeList >& xAttrList );
      80             : };
      81             : 
      82           0 : SchXMLDomain2Context::SchXMLDomain2Context(
      83             :     SvXMLImport& rImport,
      84             :     sal_uInt16 nPrefix,
      85             :     const rtl::OUString& rLocalName,
      86             :     ::std::vector< ::rtl::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 :         rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
     103           0 :         rtl::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( OUString(  "Alignment" )) >>= aLegendPosition)
     126             :             && chart::ChartLegendPosition_NONE != aLegendPosition )
     127             :         {
     128             : 
     129           0 :             double fFontHeight = 6.0;
     130           0 :             if( xLegendProp->getPropertyValue( OUString(  "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(::rtl::OUString("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(::rtl::OUString("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(::rtl::OUString("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( ::rtl::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             :         ? ::rtl::OUString(  "ErrorBarY" )
     191           0 :         : ::rtl::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::XLabeledDataSequence > lcl_createAndAddSequenceToSeries( const rtl::OUString& rRole
     208             :         , const rtl::OUString& rRange
     209             :         , const Reference< chart2::XChartDocument >& xChartDoc
     210             :         , const Reference< chart2::XDataSeries >& xSeries )
     211             : {
     212           0 :     Reference< chart2::data::XLabeledDataSequence > 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             :         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(OUString( "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]=xLabeledSeq;
     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             : } // anonymous namespace
     243             : 
     244             : // ================================================================================
     245             : 
     246           0 : SchXMLSeries2Context::SchXMLSeries2Context(
     247             :     SchXMLImportHelper& rImpHelper,
     248             :     SvXMLImport& rImport, const rtl::OUString& rLocalName,
     249             :     const Reference< chart2::XChartDocument > & xNewDoc,
     250             :     std::vector< SchXMLAxis >& rAxes,
     251             :     ::std::list< DataRowPointStyle >& rStyleList,
     252             :     sal_Int32 nSeriesIndex,
     253             :     sal_Bool bStockHasVolume,
     254             :     GlobalSeriesImportInfo& rGlobalSeriesImportInfo,
     255             :     const OUString & aGlobalChartTypeName,
     256             :     tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
     257             :     bool& rGlobalChartTypeUsedBySeries,
     258             :     const awt::Size & rChartSize ) :
     259             :         SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
     260             :         mrImportHelper( rImpHelper ),
     261             :         mxNewDoc( xNewDoc ),
     262             :         mrAxes( rAxes ),
     263             :         mrStyleList( rStyleList ),
     264             :         m_xSeries(0),
     265             :         mnSeriesIndex( nSeriesIndex ),
     266             :         mnDataPointIndex( 0 ),
     267             :         m_bStockHasVolume( bStockHasVolume ),
     268             :         m_rGlobalSeriesImportInfo(rGlobalSeriesImportInfo),
     269             :         mpAttachedAxis( NULL ),
     270             :         maGlobalChartTypeName( aGlobalChartTypeName ),
     271             :         maSeriesChartTypeName( aGlobalChartTypeName ),
     272             :         m_bHasDomainContext(false),
     273             :         mrLSequencesPerIndex( rLSequencesPerIndex ),
     274             :         mrGlobalChartTypeUsedBySeries( rGlobalChartTypeUsedBySeries ),
     275             :         mbSymbolSizeIsMissingInFile(false),
     276           0 :         maChartSize( rChartSize )
     277             : {
     278           0 :     if( 0 == aGlobalChartTypeName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.DonutChartType" ) ) )
     279             :     {
     280           0 :         maSeriesChartTypeName = ::rtl::OUString("com.sun.star.chart2.PieChartType" );
     281           0 :         maGlobalChartTypeName = maSeriesChartTypeName;
     282             :     }
     283           0 : }
     284             : 
     285           0 : SchXMLSeries2Context::~SchXMLSeries2Context()
     286             : {
     287             :     OSL_ASSERT( maPostponedSequences.empty());
     288           0 : }
     289             : 
     290           0 : void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     291             : {
     292             :     // parse attributes
     293           0 :     sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
     294           0 :     const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetSeriesAttrTokenMap();
     295           0 :     mnAttachedAxis = 1;
     296             : 
     297           0 :     bool bHasRange = false;
     298           0 :     bool bHasLabelRange = false;
     299             : 
     300           0 :     for( sal_Int16 i = 0; i < nAttrCount; i++ )
     301             :     {
     302           0 :         rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
     303           0 :         rtl::OUString aLocalName;
     304           0 :         rtl::OUString aValue = xAttrList->getValueByIndex( i );
     305           0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     306             : 
     307           0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
     308             :         {
     309             :             case XML_TOK_SERIES_CELL_RANGE:
     310           0 :                 m_aSeriesRange = aValue;
     311           0 :                 bHasRange = true;
     312           0 :                 break;
     313             :             case XML_TOK_SERIES_LABEL_ADDRESS:
     314           0 :                 m_aSeriesLabelRange = aValue;
     315           0 :                 bHasLabelRange = true;
     316           0 :                 break;
     317             :             case XML_TOK_SERIES_ATTACHED_AXIS:
     318             :                 {
     319           0 :                     sal_Int32 nNumOfAxes = mrAxes.size();
     320           0 :                     for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ )
     321             :                     {
     322           0 :                         if( aValue.equals( mrAxes[ nCurrent ].aName ) &&
     323           0 :                             mrAxes[ nCurrent ].eDimension == SCH_XML_AXIS_Y )
     324             :                         {
     325           0 :                             mpAttachedAxis = &( mrAxes[ nCurrent ] );
     326             :                         }
     327             :                     }
     328             :                 }
     329           0 :                 break;
     330             :             case XML_TOK_SERIES_STYLE_NAME:
     331           0 :                 msAutoStyleName = aValue;
     332           0 :                 break;
     333             :             case XML_TOK_SERIES_CHART_CLASS:
     334             :                 {
     335           0 :                     OUString aClassName;
     336             :                     sal_uInt16 nClassPrefix =
     337           0 :                         GetImport().GetNamespaceMap().GetKeyByAttrName(
     338           0 :                             aValue, &aClassName );
     339           0 :                     if( XML_NAMESPACE_CHART == nClassPrefix )
     340           0 :                         maSeriesChartTypeName = SchXMLTools::GetChartTypeByClassName( aClassName, false /* bUseOldNames */ );
     341             : 
     342           0 :                     if( maSeriesChartTypeName.isEmpty())
     343           0 :                         maSeriesChartTypeName = aClassName;
     344             :                 }
     345           0 :                 break;
     346             :         }
     347           0 :     }
     348             : 
     349           0 :     if( mpAttachedAxis )
     350             :     {
     351           0 :         if( mpAttachedAxis->nAxisIndex > 0 )
     352             :         {
     353             :             // secondary axis => property has to be set (primary is default)
     354           0 :             mnAttachedAxis = 2;
     355             :         }
     356             :     }
     357             : 
     358             :     try
     359             :     {
     360             :         OSL_ASSERT( mxNewDoc.is());
     361           0 :         if( m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && ! bHasRange )
     362           0 :             m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable = sal_False;
     363             : 
     364           0 :         bool bIsCandleStick = maGlobalChartTypeName == "com.sun.star.chart2.CandleStickChartType";
     365           0 :         if( !maSeriesChartTypeName.isEmpty() )
     366             :         {
     367           0 :             bIsCandleStick = maSeriesChartTypeName == "com.sun.star.chart2.CandleStickChartType";
     368             :         }
     369             :         else
     370             :         {
     371           0 :             if( bIsCandleStick
     372             :                 && m_bStockHasVolume
     373             :                 && mnSeriesIndex == 0 )
     374             :             {
     375           0 :                 maSeriesChartTypeName = OUString( "com.sun.star.chart2.ColumnChartType" );
     376           0 :                 bIsCandleStick = false;
     377             :             }
     378             :             else
     379             :             {
     380           0 :                 maSeriesChartTypeName = maGlobalChartTypeName;
     381             :             }
     382             :         }
     383           0 :         if( ! mrGlobalChartTypeUsedBySeries )
     384           0 :             mrGlobalChartTypeUsedBySeries = (maSeriesChartTypeName.equals( maGlobalChartTypeName ));
     385           0 :         sal_Int32 nCoordinateSystemIndex = 0;//so far we can only import one coordinate system
     386             :         m_xSeries.set(
     387           0 :             mrImportHelper.GetNewDataSeries( mxNewDoc, nCoordinateSystemIndex, maSeriesChartTypeName, ! mrGlobalChartTypeUsedBySeries ));
     388             :         Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
     389           0 :             SchXMLTools::GetNewLabeledDataSequence());
     390             : 
     391           0 :         if( bIsCandleStick )
     392             :         {
     393             :             // set default color for range-line to black (before applying styles)
     394           0 :             Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
     395           0 :             if( xSeriesProp.is())
     396           0 :                 xSeriesProp->setPropertyValue( ::rtl::OUString("Color"),
     397           0 :                                                uno::makeAny( sal_Int32( 0x000000 ))); // black
     398             :         }
     399           0 :         else if ( maSeriesChartTypeName == "com.sun.star.chart2.PieChartType" )
     400             :         {
     401             :             //@todo: this property should be saved
     402           0 :             Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
     403           0 :             if( xSeriesProp.is())
     404           0 :                 xSeriesProp->setPropertyValue( ::rtl::OUString("VaryColorsByPoint"),
     405           0 :                                                uno::makeAny( true ));
     406             :         }
     407             : 
     408             :         // values
     409           0 :         Reference< chart2::data::XDataSequence > xSeq;
     410           0 :         if( bHasRange && !m_aSeriesRange.isEmpty() )
     411           0 :             xSeq = SchXMLTools::CreateDataSequence( m_aSeriesRange, mxNewDoc );
     412             : 
     413           0 :         Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
     414           0 :         if( xSeqProp.is())
     415             :         {
     416           0 :             OUString aMainRole("values-y");
     417           0 :             if ( maSeriesChartTypeName == "com.sun.star.chart2.BubbleChartType" )
     418           0 :                 aMainRole = OUString( "values-size" );
     419           0 :             xSeqProp->setPropertyValue(OUString( "Role" ), uno::makeAny( aMainRole ));
     420             :         }
     421           0 :         xLabeledSeq->setValues( xSeq );
     422             : 
     423             :         // register for setting local data if external data provider is not present
     424             :         maPostponedSequences.insert(
     425             :             tSchXMLLSequencesPerIndex::value_type(
     426           0 :                 tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq ));
     427             : 
     428             :         // label
     429           0 :         if( bHasLabelRange && !m_aSeriesLabelRange.isEmpty() )
     430             :         {
     431             :             Reference< chart2::data::XDataSequence > xLabelSequence =
     432           0 :                 SchXMLTools::CreateDataSequence( m_aSeriesLabelRange, mxNewDoc );
     433           0 :             xLabeledSeq->setLabel( xLabelSequence );
     434             :         }
     435             : 
     436             :         // Note: Even if we have no label, we have to register the label
     437             :         // for creation, because internal data always has labels. If
     438             :         // they don't exist in the original, auto-generated labels are
     439             :         // used for the internal data.
     440             :         maPostponedSequences.insert(
     441             :             tSchXMLLSequencesPerIndex::value_type(
     442           0 :                 tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_LABEL ), xLabeledSeq ));
     443             : 
     444             : 
     445           0 :         Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( &xLabeledSeq, 1 );
     446           0 :         Reference< chart2::data::XDataSink > xSink( m_xSeries, uno::UNO_QUERY_THROW );
     447           0 :         xSink->setData( aSeq );
     448             :     }
     449           0 :     catch( const uno::Exception & ex )
     450             :     {
     451             :         (void)ex; // avoid warning for pro build
     452             :         OSL_FAIL( ::rtl::OUStringToOString(
     453             :                         ::rtl::OUString(  "Exception caught. Type: " ) +
     454             :                         ::rtl::OUString::createFromAscii( typeid( ex ).name()) +
     455             :                         ::rtl::OUString(  ", Message: " ) +
     456             :                         ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
     457             :     }
     458             : 
     459             :     //init mbSymbolSizeIsMissingInFile:
     460             :     try
     461             :     {
     462           0 :         if( !msAutoStyleName.isEmpty() )
     463             :         {
     464           0 :             const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
     465           0 :             if( pStylesCtxt )
     466             :             {
     467             :                 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
     468           0 :                     mrImportHelper.GetChartFamilyID(), msAutoStyleName );
     469             : 
     470           0 :                 const XMLPropStyleContext* pPropStyleContext = dynamic_cast< const XMLPropStyleContext * >( pStyle );
     471             : 
     472             :                 uno::Any aASymbolSize( SchXMLTools::getPropertyFromContext( ::rtl::OUString("SymbolSize")
     473           0 :                     , pPropStyleContext, pStylesCtxt ) );
     474           0 :                 mbSymbolSizeIsMissingInFile = !aASymbolSize.hasValue();
     475             :             }
     476             :         }
     477             :     }
     478           0 :     catch( const uno::Exception & )
     479             :     {
     480             :     }
     481           0 : }
     482             : 
     483           0 : struct DomainInfo
     484             : {
     485           0 :     DomainInfo( const rtl::OUString& rRole, const rtl::OUString& rRange, sal_Int32 nIndex )
     486           0 :         : aRole(rRole), aRange(rRange), nIndexForLocalData(nIndex)
     487           0 :     {}
     488             : 
     489             :     rtl::OUString aRole;
     490             :     rtl::OUString aRange;
     491             :     sal_Int32 nIndexForLocalData;
     492             : };
     493             : 
     494           0 : void SchXMLSeries2Context::EndElement()
     495             : {
     496             :     // special handling for different chart types.  This is necessary as the
     497             :     // roles are not yet saved in the file format
     498           0 :     sal_Int32 nDomainCount = maDomainAddresses.size();
     499           0 :     bool bIsScatterChart = maSeriesChartTypeName == "com.sun.star.chart2.ScatterChartType";
     500           0 :     bool bIsBubbleChart = maSeriesChartTypeName == "com.sun.star.chart2.BubbleChartType";
     501           0 :     bool bDeleteSeries = false;
     502           0 :     std::vector< DomainInfo > aDomainInfos;
     503             : 
     504             :     //different handling for different chart types necessary
     505           0 :     if( bIsScatterChart || ( nDomainCount==1 && !bIsBubbleChart ) )
     506             :     {
     507           0 :         DomainInfo aDomainInfo( OUString( "values-x" ), m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress, m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex ) ;
     508           0 :         bool bCreateXValues = true;
     509           0 :         if( !maDomainAddresses.empty() )
     510             :         {
     511           0 :             if( m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.isEmpty() )
     512             :             {
     513           0 :                 m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
     514           0 :                 m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
     515             :             }
     516           0 :             aDomainInfo.aRange = maDomainAddresses.front();
     517           0 :             aDomainInfo.nIndexForLocalData = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
     518           0 :             m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
     519             :         }
     520           0 :         else if( m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.isEmpty() && !m_bHasDomainContext && mnSeriesIndex==0 )
     521             :         {
     522           0 :             if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) ) //wrong old chart files:
     523             :             {
     524             :                 //for xy charts the first series needs to have a domain
     525             :                 //if this by error iss not the case the first series is taken s x values
     526             :                 //needed for wrong files created while having an addin (e.g. BoxPlot)
     527           0 :                 m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = m_aSeriesRange;
     528           0 :                 m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
     529           0 :                 bDeleteSeries = true;
     530           0 :                 bCreateXValues = false;//they will be created for the next series
     531             :             }
     532             :         }
     533           0 :         if( bCreateXValues )
     534           0 :             aDomainInfos.push_back( aDomainInfo );
     535             :     }
     536           0 :     else if( bIsBubbleChart )
     537             :     {
     538           0 :         if( nDomainCount>1 )
     539             :         {
     540           0 :             DomainInfo aDomainInfo( OUString( "values-x" ), maDomainAddresses[1], m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
     541           0 :             if( m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.isEmpty() )
     542             :             {
     543             :                 //for bubble chart the second domain contains the x values which should become an index smaller than y values for own data table
     544             :                 //->so second first
     545           0 :                 m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress = maDomainAddresses[1];
     546           0 :                 m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
     547             :             }
     548           0 :             aDomainInfos.push_back( aDomainInfo );
     549           0 :             m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
     550             :         }
     551           0 :         else if( !m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.isEmpty() )
     552             :         {
     553           0 :             DomainInfo aDomainInfo( OUString( "values-x" ), m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress, m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex ) ;
     554           0 :             aDomainInfos.push_back( aDomainInfo );
     555             :         }
     556           0 :         if( nDomainCount>0)
     557             :         {
     558           0 :             DomainInfo aDomainInfo( OUString( "values-y" ), maDomainAddresses.front(), m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
     559           0 :             if( m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.isEmpty() )
     560             :             {
     561           0 :                 m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
     562           0 :                 m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
     563             :             }
     564           0 :             aDomainInfos.push_back( aDomainInfo );
     565           0 :             m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
     566             :         }
     567           0 :         else if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.isEmpty() )
     568             :         {
     569           0 :             DomainInfo aDomainInfo( OUString("values-y"), m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress, m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex ) ;
     570           0 :             aDomainInfos.push_back( aDomainInfo );
     571             :         }
     572             :     }
     573             : 
     574           0 :     if( bDeleteSeries )
     575             :     {
     576             :         //delete created series
     577             :         SchXMLImportHelper::DeleteDataSeries(
     578           0 :             m_xSeries, Reference< chart2::XChartDocument >( GetImport().GetModel(), uno::UNO_QUERY ) );
     579             :     }
     580             :     else
     581             :     {
     582             :         //add style
     583           0 :         if( !msAutoStyleName.isEmpty() || mnAttachedAxis != 1 )
     584             :         {
     585             :             DataRowPointStyle aStyle(
     586             :                 DataRowPointStyle::DATA_SERIES,
     587             :                 m_xSeries,
     588             :                 -1, 1,
     589           0 :                 msAutoStyleName, mnAttachedAxis );
     590           0 :             aStyle.mbSymbolSizeForSeriesIsMissingInFile=mbSymbolSizeIsMissingInFile;
     591           0 :             mrStyleList.push_back( aStyle );
     592             :         }
     593             :     }
     594             : 
     595           0 :     for( std::vector< DomainInfo >::reverse_iterator aIt( aDomainInfos.rbegin() ); aIt!= aDomainInfos.rend(); ++aIt )
     596             :     {
     597           0 :         DomainInfo aDomainInfo( *aIt );
     598             :         Reference< chart2::data::XLabeledDataSequence > xLabeledSeq =
     599           0 :             lcl_createAndAddSequenceToSeries( aDomainInfo.aRole, aDomainInfo.aRange, mxNewDoc, m_xSeries );
     600           0 :         if( xLabeledSeq.is() )
     601             :         {
     602             :             // register for setting local data if external data provider is not present
     603             :             mrLSequencesPerIndex.insert(
     604             :                 tSchXMLLSequencesPerIndex::value_type(
     605           0 :                     tSchXMLIndexWithPart( aDomainInfo.nIndexForLocalData, SCH_XML_PART_VALUES ), xLabeledSeq ));
     606             :         }
     607           0 :     }
     608             : 
     609           0 :     if( !bDeleteSeries )
     610             :     {
     611           0 :         for( tSchXMLLSequencesPerIndex::const_iterator aIt( maPostponedSequences.begin());
     612           0 :             aIt != maPostponedSequences.end(); ++aIt )
     613             :         {
     614           0 :             sal_Int32 nNewIndex = aIt->first.first + nDomainCount;
     615             :             mrLSequencesPerIndex.insert(
     616             :                 tSchXMLLSequencesPerIndex::value_type(
     617           0 :                     tSchXMLIndexWithPart( nNewIndex, aIt->first.second ), aIt->second ));
     618             :         }
     619           0 :         m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
     620             :     }
     621           0 :     maPostponedSequences.clear();
     622           0 : }
     623             : 
     624           0 : SvXMLImportContext* SchXMLSeries2Context::CreateChildContext(
     625             :     sal_uInt16 nPrefix,
     626             :     const rtl::OUString& rLocalName,
     627             :     const uno::Reference< xml::sax::XAttributeList >&  )
     628             : {
     629           0 :     SvXMLImportContext* pContext = 0;
     630           0 :     const SvXMLTokenMap& rTokenMap = mrImportHelper.GetSeriesElemTokenMap();
     631             : 
     632           0 :     switch( rTokenMap.Get( nPrefix, rLocalName ))
     633             :     {
     634             :         case XML_TOK_SERIES_DOMAIN:
     635           0 :             if( m_xSeries.is())
     636             :             {
     637           0 :                 m_bHasDomainContext = true;
     638             :                 pContext = new SchXMLDomain2Context(
     639           0 :                     GetImport(),
     640             :                     nPrefix, rLocalName,
     641           0 :                     maDomainAddresses );
     642             :             }
     643           0 :             break;
     644             : 
     645             :         case XML_TOK_SERIES_MEAN_VALUE_LINE:
     646             :             pContext = new SchXMLStatisticsObjectContext(
     647           0 :                 mrImportHelper, GetImport(),
     648             :                 nPrefix, rLocalName, msAutoStyleName,
     649             :                 mrStyleList, m_xSeries,
     650             :                 SchXMLStatisticsObjectContext::CONTEXT_TYPE_MEAN_VALUE_LINE,
     651           0 :                 maChartSize );
     652           0 :             break;
     653             :         case XML_TOK_SERIES_REGRESSION_CURVE:
     654             :             pContext = new SchXMLStatisticsObjectContext(
     655           0 :                 mrImportHelper, GetImport(),
     656             :                 nPrefix, rLocalName, msAutoStyleName,
     657             :                 mrStyleList, m_xSeries,
     658             :                 SchXMLStatisticsObjectContext::CONTEXT_TYPE_REGRESSION_CURVE,
     659           0 :                 maChartSize );
     660           0 :             break;
     661             :         case XML_TOK_SERIES_ERROR_INDICATOR:
     662             :             pContext = new SchXMLStatisticsObjectContext(
     663           0 :                 mrImportHelper, GetImport(),
     664             :                 nPrefix, rLocalName, msAutoStyleName,
     665             :                 mrStyleList, m_xSeries,
     666             :                 SchXMLStatisticsObjectContext::CONTEXT_TYPE_ERROR_INDICATOR,
     667           0 :                 maChartSize );
     668           0 :             break;
     669             : 
     670             :         case XML_TOK_SERIES_DATA_POINT:
     671           0 :             pContext = new SchXMLDataPointContext( GetImport(), rLocalName,
     672           0 :                                                    mrStyleList, m_xSeries, mnDataPointIndex, mbSymbolSizeIsMissingInFile );
     673           0 :             break;
     674             : 
     675             :         default:
     676           0 :             pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     677             :     }
     678             : 
     679           0 :     return pContext;
     680             : }
     681             : 
     682             : //static
     683           0 : void SchXMLSeries2Context::initSeriesPropertySets( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
     684             :         , const uno::Reference< frame::XModel >& xChartModel )
     685             : {
     686           0 :     ::std::list< DataRowPointStyle >::iterator iStyle;
     687             : 
     688             :     // iterate over series first and remind propertysets in map
     689             :     // new api <-> old api wrapper
     690           0 :     ::std::map< Reference< chart2::XDataSeries >, Reference< beans::XPropertySet > > aSeriesMap;
     691           0 :     for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); ++iStyle )
     692             :     {
     693           0 :         if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
     694           0 :             continue;
     695             : 
     696           0 :         if( !iStyle->m_xOldAPISeries.is() )
     697           0 :             iStyle->m_xOldAPISeries = SchXMLSeriesHelper::createOldAPISeriesPropertySet( iStyle->m_xSeries, xChartModel );
     698             : 
     699           0 :         aSeriesMap[iStyle->m_xSeries] = iStyle->m_xOldAPISeries;
     700             : 
     701             :     }
     702             : 
     703             :     //initialize m_xOldAPISeries for all other styles also
     704           0 :     for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); ++iStyle )
     705             :     {
     706           0 :         if( iStyle->meType == DataRowPointStyle::DATA_SERIES )
     707           0 :             continue;
     708           0 :         iStyle->m_xOldAPISeries = aSeriesMap[iStyle->m_xSeries];
     709           0 :     }
     710           0 : }
     711             : 
     712             : //static
     713           0 : void SchXMLSeries2Context::setDefaultsToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles )
     714             : {
     715           0 :     ::std::list< DataRowPointStyle >::iterator iStyle;
     716             :     // iterate over series
     717             :     // call initSeriesPropertySets first
     718             : 
     719           0 :     for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); ++iStyle )
     720             :     {
     721           0 :         if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
     722           0 :             continue;
     723             : 
     724             :         try
     725             :         {
     726           0 :             uno::Reference< beans::XPropertySet > xSeries( iStyle->m_xOldAPISeries );
     727           0 :             if( !xSeries.is() )
     728           0 :                 continue;
     729             : 
     730           0 :             if( rSeriesDefaultsAndStyles.maSymbolTypeDefault.hasValue() )
     731           0 :                 xSeries->setPropertyValue(::rtl::OUString("SymbolType"),rSeriesDefaultsAndStyles.maSymbolTypeDefault);
     732           0 :             if( rSeriesDefaultsAndStyles.maDataCaptionDefault.hasValue() )
     733           0 :                 xSeries->setPropertyValue(::rtl::OUString("DataCaption"),rSeriesDefaultsAndStyles.maDataCaptionDefault);
     734             : 
     735           0 :             if( rSeriesDefaultsAndStyles.maErrorIndicatorDefault.hasValue() )
     736           0 :                 xSeries->setPropertyValue(::rtl::OUString("ErrorIndicator"),rSeriesDefaultsAndStyles.maErrorIndicatorDefault);
     737           0 :             if( rSeriesDefaultsAndStyles.maErrorCategoryDefault.hasValue() )
     738           0 :                 xSeries->setPropertyValue(::rtl::OUString("ErrorCategory"),rSeriesDefaultsAndStyles.maErrorCategoryDefault);
     739           0 :             if( rSeriesDefaultsAndStyles.maConstantErrorLowDefault.hasValue() )
     740           0 :                 xSeries->setPropertyValue(::rtl::OUString("ConstantErrorLow"),rSeriesDefaultsAndStyles.maConstantErrorLowDefault);
     741           0 :             if( rSeriesDefaultsAndStyles.maConstantErrorHighDefault.hasValue() )
     742           0 :                 xSeries->setPropertyValue(::rtl::OUString("ConstantErrorHigh"),rSeriesDefaultsAndStyles.maConstantErrorHighDefault);
     743           0 :             if( rSeriesDefaultsAndStyles.maPercentageErrorDefault.hasValue() )
     744           0 :                 xSeries->setPropertyValue(::rtl::OUString("PercentageError"),rSeriesDefaultsAndStyles.maPercentageErrorDefault);
     745           0 :             if( rSeriesDefaultsAndStyles.maErrorMarginDefault.hasValue() )
     746           0 :                 xSeries->setPropertyValue(::rtl::OUString("ErrorMargin"),rSeriesDefaultsAndStyles.maErrorMarginDefault);
     747             : 
     748           0 :             if( rSeriesDefaultsAndStyles.maMeanValueDefault.hasValue() )
     749           0 :                 xSeries->setPropertyValue(::rtl::OUString("MeanValue"),rSeriesDefaultsAndStyles.maMeanValueDefault);
     750           0 :             if( rSeriesDefaultsAndStyles.maRegressionCurvesDefault.hasValue() )
     751           0 :                 xSeries->setPropertyValue(::rtl::OUString("RegressionCurves"),rSeriesDefaultsAndStyles.maRegressionCurvesDefault);
     752             :         }
     753           0 :         catch( uno::Exception &  )
     754             :         {
     755             :             //end of series reached
     756             :         }
     757             :     }
     758           0 : }
     759             : 
     760             : //static
     761           0 : void SchXMLSeries2Context::setStylesToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
     762             :         , const SvXMLStylesContext* pStylesCtxt
     763             :         , const SvXMLStyleContext*& rpStyle
     764             :         , ::rtl::OUString& rCurrStyleName
     765             :         , SchXMLImportHelper& rImportHelper
     766             :         , const SvXMLImport& rImport
     767             :         , bool bIsStockChart
     768             :         , tSchXMLLSequencesPerIndex & rInOutLSequencesPerIndex )
     769             : {
     770           0 :     ::std::list< DataRowPointStyle >::iterator iStyle;
     771             : 
     772             :     // iterate over series
     773           0 :     for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); ++iStyle )
     774             :     {
     775           0 :         if( iStyle->meType == DataRowPointStyle::DATA_SERIES )
     776             :         {
     777             :             try
     778             :             {
     779           0 :                 uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
     780           0 :                 if( !xSeriesProp.is() )
     781           0 :                     continue;
     782             : 
     783           0 :                 if( iStyle->mnAttachedAxis != 1 )
     784             :                 {
     785           0 :                     xSeriesProp->setPropertyValue( rtl::OUString(  "Axis" )
     786           0 :                         , uno::makeAny(chart::ChartAxisAssign::SECONDARY_Y) );
     787             :                 }
     788             : 
     789           0 :                 if( !(iStyle->msStyleName).isEmpty())
     790             :                 {
     791           0 :                     if( ! rCurrStyleName.equals( iStyle->msStyleName ))
     792             :                     {
     793           0 :                         rCurrStyleName = iStyle->msStyleName;
     794             :                         rpStyle = pStylesCtxt->FindStyleChildContext(
     795           0 :                             rImportHelper.GetChartFamilyID(), rCurrStyleName );
     796             :                     }
     797             : 
     798             :                     //set style to series
     799             :                     // note: SvXMLStyleContext::FillPropertySet is not const
     800             :                     XMLPropStyleContext * pPropStyleContext =
     801             :                         const_cast< XMLPropStyleContext * >(
     802           0 :                             dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
     803           0 :                     if( pPropStyleContext )
     804             :                     {
     805             :                         // error bar style must be set before the other error
     806             :                         // bar properties (which may be alphabetically before
     807             :                         // this property)
     808           0 :                         bool bHasErrorBarRangesFromData = false;
     809             :                         {
     810           0 :                             const ::rtl::OUString aErrorBarStylePropName( "ErrorBarStyle");
     811             :                             uno::Any aErrorBarStyle(
     812           0 :                                 SchXMLTools::getPropertyFromContext( aErrorBarStylePropName, pPropStyleContext, pStylesCtxt ));
     813           0 :                             if( aErrorBarStyle.hasValue())
     814             :                             {
     815           0 :                                 xSeriesProp->setPropertyValue( aErrorBarStylePropName, aErrorBarStyle );
     816           0 :                                 sal_Int32 eEBStyle = chart::ErrorBarStyle::NONE;
     817             :                                 bHasErrorBarRangesFromData =
     818           0 :                                     ( ( aErrorBarStyle >>= eEBStyle ) &&
     819           0 :                                       eEBStyle == chart::ErrorBarStyle::FROM_DATA );
     820           0 :                             }
     821             :                         }
     822             : 
     823             :                         //don't set the style to the min max line series of a stock chart
     824             :                         //otherwise the min max line properties gets overwritten and the series becomes invisible typically
     825           0 :                         bool bIsMinMaxSeries = false;
     826           0 :                         if( bIsStockChart )
     827             :                         {
     828           0 :                             if( SchXMLSeriesHelper::isCandleStickSeries( iStyle->m_xSeries
     829           0 :                                     , uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) )
     830           0 :                                 bIsMinMaxSeries = true;
     831             :                         }
     832           0 :                         if( !bIsMinMaxSeries )
     833             :                         {
     834           0 :                             pPropStyleContext->FillPropertySet( xSeriesProp );
     835           0 :                             if( iStyle->mbSymbolSizeForSeriesIsMissingInFile )
     836           0 :                                 lcl_setSymbolSizeIfNeeded( xSeriesProp, rImport );
     837           0 :                             if( bHasErrorBarRangesFromData )
     838           0 :                                 lcl_insertErrorBarLSequencesToMap( rInOutLSequencesPerIndex, xSeriesProp );
     839             :                         }
     840             :                     }
     841           0 :                 }
     842             :             }
     843           0 :             catch( const uno::Exception & rEx )
     844             :             {
     845             :                 (void)rEx; // avoid warning for pro build
     846             :                 OSL_TRACE( "Exception caught during setting styles to series: %s",
     847             :                                 OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
     848             :             }
     849             :         }
     850             :     }
     851           0 : }
     852             : 
     853             : // static
     854           0 : void SchXMLSeries2Context::setStylesToStatisticsObjects( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
     855             :         , const SvXMLStylesContext* pStylesCtxt
     856             :         , const SvXMLStyleContext*& rpStyle
     857             :         , ::rtl::OUString& rCurrStyleName )
     858             : {
     859           0 :     ::std::list< DataRowPointStyle >::iterator iStyle;
     860             : 
     861             :     // iterate over regession etc
     862           0 :     for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); ++iStyle )
     863             :     {
     864           0 :         if( iStyle->meType == DataRowPointStyle::REGRESSION ||
     865           0 :             iStyle->meType == DataRowPointStyle::ERROR_INDICATOR ||
     866           0 :             iStyle->meType == DataRowPointStyle::MEAN_VALUE )
     867             :         {
     868           0 :             if ( iStyle->meType == DataRowPointStyle::ERROR_INDICATOR )
     869             :             {
     870           0 :                 uno::Reference< beans::XPropertySet > xNewSeriesProp(iStyle->m_xSeries,uno::UNO_QUERY);
     871             : 
     872           0 :                 if (iStyle->m_xErrorXProperties.is())
     873           0 :                     xNewSeriesProp->setPropertyValue("ErrorBarX",uno::makeAny(iStyle->m_xErrorXProperties));
     874             : 
     875           0 :                 if (iStyle->m_xErrorYProperties.is())
     876           0 :                     xNewSeriesProp->setPropertyValue("ErrorBarY",uno::makeAny(iStyle->m_xErrorYProperties));
     877             :             }
     878             : 
     879             :             try
     880             :             {
     881           0 :                 uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
     882           0 :                 if( !xSeriesProp.is() )
     883           0 :                     continue;
     884             : 
     885           0 :                 if( !(iStyle->msStyleName).isEmpty())
     886             :                 {
     887           0 :                     if( ! rCurrStyleName.equals( iStyle->msStyleName ))
     888             :                     {
     889           0 :                         rCurrStyleName = iStyle->msStyleName;
     890             :                         rpStyle = pStylesCtxt->FindStyleChildContext(
     891           0 :                             SchXMLImportHelper::GetChartFamilyID(), rCurrStyleName );
     892             :                     }
     893             : 
     894             :                     // note: SvXMLStyleContext::FillPropertySet is not const
     895             :                     XMLPropStyleContext * pPropStyleContext =
     896             :                         const_cast< XMLPropStyleContext * >(
     897           0 :                             dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
     898           0 :                     if( pPropStyleContext )
     899             :                     {
     900           0 :                         Reference< beans::XPropertySet > xStatPropSet;
     901           0 :                         switch( iStyle->meType )
     902             :                         {
     903             :                             case DataRowPointStyle::MEAN_VALUE:
     904           0 :                                 xSeriesProp->getPropertyValue(
     905           0 :                                     OUString( "DataMeanValueProperties" )) >>= xStatPropSet;
     906           0 :                                 break;
     907             :                             case DataRowPointStyle::REGRESSION:
     908           0 :                                 xSeriesProp->getPropertyValue(
     909           0 :                                     OUString( "DataRegressionProperties" )) >>= xStatPropSet;
     910           0 :                                 break;
     911             :                             case DataRowPointStyle::ERROR_INDICATOR:
     912           0 :                                 xSeriesProp->getPropertyValue(
     913           0 :                                     OUString( "DataErrorProperties" ))  >>= xStatPropSet;
     914           0 :                                 break;
     915             :                             default:
     916           0 :                                 break;
     917             :                         }
     918           0 :                         if( xStatPropSet.is())
     919           0 :                             pPropStyleContext->FillPropertySet( xStatPropSet );
     920             :                     }
     921             :                 }
     922             : 
     923             :                 // set equation properties at a regression curve
     924             :                 // note: this must be done after setting the regression
     925             :                 // properties at the old API, otherwise the curve itself does
     926             :                 // not exist here
     927           0 :                 if( iStyle->meType == DataRowPointStyle::REGRESSION && iStyle->m_xEquationProperties.is())
     928             :                 {
     929             :                     OSL_ASSERT( iStyle->m_xSeries.is());
     930           0 :                     Reference< chart2::XRegressionCurve > xRegCurve( SchXMLTools::getRegressionCurve( iStyle->m_xSeries ));
     931           0 :                     if( xRegCurve.is())
     932           0 :                         xRegCurve->setEquationProperties( iStyle->m_xEquationProperties );
     933           0 :                 }
     934             :             }
     935           0 :             catch( const uno::Exception & rEx )
     936             :             {
     937             :                 (void)rEx; // avoid warning for pro build
     938             :                 OSL_TRACE( "Exception caught during setting styles to series: %s",
     939             :                                 OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
     940             :             }
     941             :         }
     942             :     }
     943           0 : }
     944             : 
     945             : //static
     946           0 : void SchXMLSeries2Context::setStylesToDataPoints( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
     947             :         , const SvXMLStylesContext* pStylesCtxt
     948             :         , const SvXMLStyleContext*& rpStyle
     949             :         , ::rtl::OUString& rCurrStyleName
     950             :         , SchXMLImportHelper& rImportHelper
     951             :         , const SvXMLImport& rImport
     952             :         , bool bIsStockChart, bool bIsDonutChart, bool bSwitchOffLinesForScatter )
     953             : {
     954           0 :     ::std::list< DataRowPointStyle >::iterator iStyle;
     955           0 :     for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); ++iStyle )
     956             :     {
     957           0 :         if( iStyle->meType != DataRowPointStyle::DATA_POINT )
     958           0 :             continue;
     959             : 
     960           0 :         if( iStyle->m_nPointIndex == -1 )
     961           0 :             continue;
     962             : 
     963             :         //ignore datapoint properties for stock charts
     964             :         //... todo ...
     965           0 :         if( bIsStockChart )
     966             :         {
     967           0 :             if( SchXMLSeriesHelper::isCandleStickSeries( iStyle->m_xSeries, uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) )
     968           0 :                 continue;
     969             :         }
     970             : 
     971             :         // data point style
     972           0 :         for( sal_Int32 i = 0; i < iStyle->m_nPointRepeat; i++ )
     973             :         {
     974             :             try
     975             :             {
     976           0 :                 uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
     977           0 :                 if(!xSeriesProp.is())
     978           0 :                     continue;
     979             : 
     980             :                 uno::Reference< beans::XPropertySet > xPointProp(
     981           0 :                     SchXMLSeriesHelper::createOldAPIDataPointPropertySet( iStyle->m_xSeries, iStyle->m_nPointIndex + i
     982           0 :                         , uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) );
     983             : 
     984           0 :                 if( !xPointProp.is() )
     985           0 :                     continue;
     986             : 
     987           0 :                 if( bIsDonutChart )
     988             :                 {
     989             :                     //set special series styles for donut charts first
     990           0 :                     if( !rCurrStyleName.equals( iStyle->msSeriesStyleNameForDonuts ) )
     991             :                     {
     992           0 :                         rCurrStyleName = iStyle->msSeriesStyleNameForDonuts;
     993             :                         rpStyle = pStylesCtxt->FindStyleChildContext(
     994           0 :                             rImportHelper.GetChartFamilyID(), rCurrStyleName );
     995             :                     }
     996             : 
     997             :                     // note: SvXMLStyleContext::FillPropertySet is not const
     998             :                     XMLPropStyleContext * pPropStyleContext =
     999             :                         const_cast< XMLPropStyleContext * >(
    1000           0 :                             dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
    1001           0 :                     if( pPropStyleContext )
    1002           0 :                         pPropStyleContext->FillPropertySet( xPointProp );
    1003             :                 }
    1004             : 
    1005             :                 try
    1006             :                 {
    1007             :                     //need to set this explicitly here for old files as the new api does not support this property fully anymore
    1008           0 :                     if( bSwitchOffLinesForScatter )
    1009           0 :                         xPointProp->setPropertyValue(::rtl::OUString("Lines"),uno::makeAny(sal_False));
    1010             :                 }
    1011           0 :                 catch( const uno::Exception & )
    1012             :                 {
    1013             :                 }
    1014             : 
    1015           0 :                 if( !rCurrStyleName.equals( iStyle->msStyleName ) )
    1016             :                 {
    1017           0 :                     rCurrStyleName = iStyle->msStyleName;
    1018             :                     rpStyle = pStylesCtxt->FindStyleChildContext(
    1019           0 :                         rImportHelper.GetChartFamilyID(), rCurrStyleName );
    1020             :                 }
    1021             : 
    1022             :                 // note: SvXMLStyleContext::FillPropertySet is not const
    1023             :                 XMLPropStyleContext * pPropStyleContext =
    1024             :                     const_cast< XMLPropStyleContext * >(
    1025           0 :                         dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
    1026           0 :                 if( pPropStyleContext )
    1027             :                 {
    1028           0 :                     pPropStyleContext->FillPropertySet( xPointProp );
    1029           0 :                     if( iStyle->mbSymbolSizeForSeriesIsMissingInFile )
    1030           0 :                         lcl_resetSymbolSizeForPointsIfNecessary( xPointProp, rImport, pPropStyleContext, pStylesCtxt );
    1031           0 :                 }
    1032             :             }
    1033           0 :             catch( const uno::Exception & rEx )
    1034             :             {
    1035             :                 (void)rEx; // avoid warning for pro build
    1036             :                 OSL_TRACE( "Exception caught during setting styles to data points: %s",
    1037             :                                     OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
    1038             :             }
    1039             :         }
    1040             :     }   // styles iterator
    1041           0 : }
    1042             : 
    1043             : //static
    1044           0 : void SchXMLSeries2Context::switchSeriesLinesOff( ::std::list< DataRowPointStyle >& rSeriesStyleList )
    1045             : {
    1046           0 :     ::std::list< DataRowPointStyle >::iterator iStyle;
    1047             :     // iterate over series
    1048             : 
    1049           0 :     for( iStyle = rSeriesStyleList.begin(); iStyle != rSeriesStyleList.end(); ++iStyle )
    1050             :     {
    1051           0 :         if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
    1052           0 :             continue;
    1053             : 
    1054             :         try
    1055             :         {
    1056           0 :             uno::Reference< beans::XPropertySet > xSeries( iStyle->m_xOldAPISeries );
    1057           0 :             if( !xSeries.is() )
    1058           0 :                 continue;
    1059             : 
    1060           0 :             xSeries->setPropertyValue(::rtl::OUString("Lines"),uno::makeAny(sal_False));
    1061             :         }
    1062           0 :         catch( uno::Exception &  )
    1063             :         {
    1064             :             //end of series reached
    1065             :         }
    1066             :     }
    1067           0 : }
    1068             : 
    1069             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10