LCOV - code coverage report
Current view: top level - xmloff/source/chart - SchXMLChartContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 249 569 43.8 %
Date: 2012-08-25 Functions: 14 27 51.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 265 1215 21.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "SchXMLChartContext.hxx"
      31                 :            : #include "SchXMLImport.hxx"
      32                 :            : #include "SchXMLLegendContext.hxx"
      33                 :            : #include "SchXMLPlotAreaContext.hxx"
      34                 :            : #include "SchXMLParagraphContext.hxx"
      35                 :            : #include "SchXMLTableContext.hxx"
      36                 :            : #include "SchXMLSeriesHelper.hxx"
      37                 :            : #include "SchXMLSeries2Context.hxx"
      38                 :            : #include "SchXMLTools.hxx"
      39                 :            : #include <comphelper/mediadescriptor.hxx>
      40                 :            : #include <tools/debug.hxx>
      41                 :            : #include "xmloff/xmlnmspe.hxx"
      42                 :            : #include <xmloff/xmlement.hxx>
      43                 :            : #include <xmloff/xmltoken.hxx>
      44                 :            : #include <xmloff/nmspmap.hxx>
      45                 :            : #include <xmloff/xmluconv.hxx>
      46                 :            : #include <xmloff/xmlstyle.hxx>
      47                 :            : #include <xmloff/prstylei.hxx>
      48                 :            : 
      49                 :            : #include "vector"
      50                 :            : #include <com/sun/star/chart/XChartDocument.hpp>
      51                 :            : #include <com/sun/star/chart/XDiagram.hpp>
      52                 :            : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      53                 :            : #include <com/sun/star/util/XStringMapping.hpp>
      54                 :            : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      55                 :            : #include <com/sun/star/drawing/XDrawPage.hpp>
      56                 :            : #include <com/sun/star/chart/ChartDataRowSource.hpp>
      57                 :            : #include <com/sun/star/chart/ChartSeriesAddress.hpp>
      58                 :            : #include <com/sun/star/awt/PosSize.hpp>
      59                 :            : #include <com/sun/star/embed/Aspects.hpp>
      60                 :            : #include <com/sun/star/embed/XVisualObject.hpp>
      61                 :            : 
      62                 :            : #include <com/sun/star/chart2/XChartDocument.hpp>
      63                 :            : #include <com/sun/star/chart2/data/XDataSink.hpp>
      64                 :            : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
      65                 :            : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
      66                 :            : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
      67                 :            : #include <com/sun/star/chart2/XTitled.hpp>
      68                 :            : 
      69                 :            : using namespace com::sun::star;
      70                 :            : using namespace ::xmloff::token;
      71                 :            : using ::rtl::OUString;
      72                 :            : using com::sun::star::uno::Reference;
      73                 :            : using namespace ::SchXMLTools;
      74                 :            : 
      75                 :            : namespace
      76                 :            : {
      77                 :            : 
      78                 :          0 : void lcl_setRoleAtLabeledSequence(
      79                 :            :     const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq,
      80                 :            :     const ::rtl::OUString &rRole )
      81                 :            : {
      82                 :            :     // set role of sequence
      83 [ #  # ][ #  # ]:          0 :     uno::Reference< chart2::data::XDataSequence > xValues( xLSeq->getValues());
      84         [ #  # ]:          0 :     if( xValues.is())
      85                 :            :     {
      86         [ #  # ]:          0 :         uno::Reference< beans::XPropertySet > xProp( xValues, uno::UNO_QUERY );
      87         [ #  # ]:          0 :         if( xProp.is())
      88 [ #  # ][ #  # ]:          0 :             xProp->setPropertyValue(OUString( "Role" ), uno::makeAny( rRole ));
                 [ #  # ]
      89                 :          0 :     }
      90                 :          0 : }
      91                 :            : 
      92                 :          0 : void lcl_MoveDataToCandleStickSeries(
      93                 :            :     const uno::Reference< chart2::data::XDataSource > & xDataSource,
      94                 :            :     const uno::Reference< chart2::XDataSeries > & xDestination,
      95                 :            :     const OUString & rRole )
      96                 :            : {
      97                 :            :     try
      98                 :            :     {
      99                 :            :         uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledSeq(
     100 [ #  # ][ #  # ]:          0 :             xDataSource->getDataSequences());
     101         [ #  # ]:          0 :         if( aLabeledSeq.getLength())
     102                 :            :         {
     103 [ #  # ][ #  # ]:          0 :             lcl_setRoleAtLabeledSequence( aLabeledSeq[0], rRole );
     104                 :            : 
     105                 :            :             // add to data series
     106         [ #  # ]:          0 :             uno::Reference< chart2::data::XDataSource > xSource( xDestination, uno::UNO_QUERY_THROW );
     107                 :            :             // @todo: realloc only once outside this function
     108 [ #  # ][ #  # ]:          0 :             uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aData( xSource->getDataSequences());
     109         [ #  # ]:          0 :             aData.realloc( aData.getLength() + 1);
     110 [ #  # ][ #  # ]:          0 :             aData[ aData.getLength() - 1 ] = aLabeledSeq[0];
                 [ #  # ]
     111         [ #  # ]:          0 :             uno::Reference< chart2::data::XDataSink > xSink( xDestination, uno::UNO_QUERY_THROW );
     112 [ #  # ][ #  # ]:          0 :             xSink->setData( aData );
                 [ #  # ]
     113 [ #  # ][ #  # ]:          0 :         }
     114                 :            :     }
     115                 :          0 :     catch(const uno::Exception&)
     116                 :            :     {
     117                 :            :         OSL_FAIL( "Exception caught while moving data to candlestick series" );
     118                 :            :     }
     119                 :          0 : }
     120                 :            : 
     121                 :          0 : void lcl_setRoleAtFirstSequence(
     122                 :            :     const uno::Reference< chart2::XDataSeries > & xSeries,
     123                 :            :     const ::rtl::OUString & rRole )
     124                 :            : {
     125         [ #  # ]:          0 :     uno::Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
     126         [ #  # ]:          0 :     if( xSource.is())
     127                 :            :     {
     128 [ #  # ][ #  # ]:          0 :         uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSeq( xSource->getDataSequences());
     129         [ #  # ]:          0 :         if( aSeq.getLength())
     130 [ #  # ][ #  # ]:          0 :             lcl_setRoleAtLabeledSequence( aSeq[0], rRole );
                 [ #  # ]
     131                 :          0 :     }
     132                 :          0 : }
     133                 :            : 
     134                 :          6 : void lcl_removeEmptyChartTypeGroups( const uno::Reference< chart2::XChartDocument > & xDoc )
     135                 :            : {
     136         [ +  - ]:          6 :     if( ! xDoc.is())
     137                 :            :         return;
     138                 :            : 
     139 [ +  - ][ +  - ]:          6 :     uno::Reference< chart2::XDiagram > xDia( xDoc->getFirstDiagram());
     140         [ -  + ]:          6 :     if( ! xDia.is())
     141                 :            :         return;
     142                 :            : 
     143                 :            :     try
     144                 :            :     {
     145                 :            :         // count all charttype groups to be able to leave at least one
     146                 :          6 :         sal_Int32 nRemainingGroups = 0;
     147         [ +  - ]:          6 :         uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDia, uno::UNO_QUERY_THROW );
     148                 :            :         uno::Sequence< uno::Reference< chart2::XCoordinateSystem > >
     149 [ +  - ][ +  - ]:          6 :             aCooSysSeq( xCooSysCnt->getCoordinateSystems());
     150         [ +  + ]:         12 :         for( sal_Int32 nI = aCooSysSeq.getLength(); nI--; )
     151                 :            :         {
     152 [ +  - ][ +  - ]:          6 :             uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nI], uno::UNO_QUERY_THROW );
     153 [ +  - ][ +  - ]:          6 :             nRemainingGroups += xCTCnt->getChartTypes().getLength();
                 [ +  - ]
     154                 :          6 :         }
     155                 :            : 
     156                 :            :         // delete all empty groups, but leave at least  group (empty or not)
     157 [ +  - ][ -  + ]:          6 :         for( sal_Int32 nI = aCooSysSeq.getLength(); nI-- && (nRemainingGroups > 1); )
                 [ -  + ]
     158                 :            :         {
     159 [ #  # ][ #  # ]:          0 :             uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nI], uno::UNO_QUERY_THROW );
     160 [ #  # ][ #  # ]:          0 :             uno::Sequence< uno::Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
     161 [ #  # ][ #  # ]:          0 :             for( sal_Int32 nJ=aCTSeq.getLength(); nJ-- && (nRemainingGroups > 1); )
                 [ #  # ]
     162                 :            :             {
     163 [ #  # ][ #  # ]:          0 :                 uno::Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nJ], uno::UNO_QUERY_THROW );
     164 [ #  # ][ #  # ]:          0 :                 if( xDSCnt->getDataSeries().getLength() == 0 )
         [ #  # ][ #  # ]
     165                 :            :                 {
     166                 :            :                     // note: iterator stays valid as we have a local sequence
     167 [ #  # ][ #  # ]:          0 :                     xCTCnt->removeChartType( aCTSeq[nJ] );
                 [ #  # ]
     168                 :          0 :                     --nRemainingGroups;
     169                 :            :                 }
     170                 :          0 :             }
     171 [ #  # ][ +  - ]:          6 :         }
     172                 :            :     }
     173   [ #  #  #  # ]:          0 :     catch(const uno::Exception& ex)
     174                 :            :     {
     175         [ #  # ]:          0 :         rtl::OString aBStr(rtl::OUStringToOString(ex.Message, RTL_TEXTENCODING_ASCII_US));
     176                 :          0 :         OSL_TRACE( "Exception caught while removing empty chart types: %s", aBStr.getStr());
     177         [ +  - ]:          6 :     }
     178                 :            : }
     179                 :            : 
     180                 :          0 : uno::Sequence< sal_Int32 > lcl_getNumberSequenceFromString( const ::rtl::OUString& rStr, bool bAddOneToEachOldIndex )
     181                 :            : {
     182                 :          0 :     const sal_Unicode aSpace( ' ' );
     183                 :            : 
     184                 :            :     // count number of entries
     185         [ #  # ]:          0 :     ::std::vector< sal_Int32 > aVec;
     186                 :          0 :     sal_Int32 nLastPos = 0;
     187                 :          0 :     sal_Int32 nPos = 0;
     188         [ #  # ]:          0 :     while( nPos != -1 )
     189                 :            :     {
     190                 :          0 :         nPos = rStr.indexOf( aSpace, nLastPos );
     191         [ #  # ]:          0 :         if( nPos > nLastPos )
     192                 :            :         {
     193         [ #  # ]:          0 :             aVec.push_back( rStr.copy( nLastPos, (nPos - nLastPos) ).toInt32() );
     194                 :            :         }
     195         [ #  # ]:          0 :         if( nPos != -1 )
     196                 :          0 :             nLastPos = nPos + 1;
     197                 :            :     }
     198                 :            :     // last entry
     199   [ #  #  #  # ]:          0 :     if( nLastPos != 0 &&
                 [ #  # ]
     200                 :          0 :         rStr.getLength() > nLastPos )
     201                 :            :     {
     202         [ #  # ]:          0 :         aVec.push_back( rStr.copy( nLastPos, (rStr.getLength() - nLastPos) ).toInt32() );
     203                 :            :     }
     204                 :            : 
     205                 :          0 :     const sal_Int32 nVecSize = aVec.size();
     206         [ #  # ]:          0 :     uno::Sequence< sal_Int32 > aSeq( nVecSize );
     207                 :            : 
     208         [ #  # ]:          0 :     if(!bAddOneToEachOldIndex)
     209                 :            :     {
     210         [ #  # ]:          0 :         sal_Int32* pSeqArr = aSeq.getArray();
     211         [ #  # ]:          0 :         for( nPos = 0; nPos < nVecSize; ++nPos )
     212                 :            :         {
     213         [ #  # ]:          0 :             pSeqArr[ nPos ] = aVec[ nPos ];
     214                 :            :         }
     215                 :            :     }
     216         [ #  # ]:          0 :     else if( bAddOneToEachOldIndex )
     217                 :            :     {
     218         [ #  # ]:          0 :         aSeq.realloc( nVecSize+1 );
     219         [ #  # ]:          0 :         aSeq[0]=0;
     220                 :            : 
     221         [ #  # ]:          0 :         sal_Int32* pSeqArr = aSeq.getArray();
     222         [ #  # ]:          0 :         for( nPos = 0; nPos < nVecSize; ++nPos )
     223                 :            :         {
     224         [ #  # ]:          0 :             pSeqArr[ nPos+1 ] = aVec[ nPos ]+1;
     225                 :            :         }
     226                 :            :     }
     227                 :            : 
     228                 :          0 :     return aSeq;
     229                 :            : }
     230                 :            : 
     231                 :            : } // anonymous namespace
     232                 :            : 
     233                 :            : // ----------------------------------------
     234                 :            : 
     235                 :          6 : SchXMLChartContext::SchXMLChartContext( SchXMLImportHelper& rImpHelper,
     236                 :            :                                         SvXMLImport& rImport, const rtl::OUString& rLocalName ) :
     237                 :            :         SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
     238                 :            :         mrImportHelper( rImpHelper ),
     239                 :            :         m_bHasRangeAtPlotArea( false ),
     240                 :            :         m_bHasTableElement( false ),
     241                 :            :         mbAllRangeAddressesAvailable( sal_True ),
     242                 :            :         mbColHasLabels( sal_False ),
     243                 :            :         mbRowHasLabels( sal_False ),
     244                 :            :         meDataRowSource( chart::ChartDataRowSource_COLUMNS ),
     245 [ +  - ][ +  - ]:          6 :         mbIsStockChart( false )
         [ +  - ][ +  - ]
     246                 :            : {
     247                 :          6 : }
     248                 :            : 
     249         [ +  - ]:          6 : SchXMLChartContext::~SchXMLChartContext()
     250         [ -  + ]:         12 : {}
     251                 :            : 
     252                 :          6 : void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     253                 :            : {
     254                 :            :     // parse attributes
     255 [ +  - ][ +  - ]:          6 :     sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
                 [ +  - ]
     256         [ +  - ]:          6 :     const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetChartAttrTokenMap();
     257                 :            : 
     258         [ +  - ]:          6 :     uno::Reference< embed::XVisualObject > xVisualObject( mrImportHelper.GetChartDocument(), uno::UNO_QUERY);
     259                 :            :     DBG_ASSERT(xVisualObject.is(),"need xVisualObject for page size");
     260         [ +  - ]:          6 :     if( xVisualObject.is() )
     261 [ +  - ][ +  - ]:          6 :         maChartSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ); //#i103460# take the size given from the parent frame as default
     262                 :            : 
     263                 :            :     // this flag is necessarry for pie charts in the core
     264                 :          6 :     sal_Bool bSetSwitchData = sal_False;
     265                 :            : 
     266                 :          6 :     ::rtl::OUString sAutoStyleName;
     267                 :          6 :     ::rtl::OUString aOldChartTypeName;
     268                 :          6 :     bool bHasAddin = false;
     269                 :            : 
     270         [ +  + ]:         30 :     for( sal_Int16 i = 0; i < nAttrCount; i++ )
     271                 :            :     {
     272 [ +  - ][ +  - ]:         24 :         rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
     273                 :         24 :         rtl::OUString aLocalName;
     274 [ +  - ][ +  - ]:         24 :         rtl::OUString aValue = xAttrList->getValueByIndex( i );
     275         [ +  - ]:         24 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     276                 :            : 
     277 [ +  - ][ -  +  :         24 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
          +  +  +  -  -  
                      - ]
     278                 :            :         {
     279                 :            :             case XML_TOK_CHART_HREF:
     280                 :          0 :                 m_aXLinkHRefAttributeToIndicateDataProvider = aValue;
     281                 :          0 :                 break;
     282                 :            : 
     283                 :            :             case XML_TOK_CHART_CLASS:
     284                 :            :                 {
     285                 :          6 :                     rtl::OUString sClassName;
     286                 :            :                     sal_uInt16 nClassPrefix =
     287                 :          6 :                         GetImport().GetNamespaceMap().GetKeyByAttrName(
     288         [ +  - ]:          6 :                                 aValue, &sClassName );
     289         [ +  - ]:          6 :                     if( XML_NAMESPACE_CHART == nClassPrefix )
     290                 :            :                     {
     291         [ +  - ]:          6 :                         SchXMLChartTypeEnum eChartTypeEnum = SchXMLTools::GetChartTypeEnum( sClassName );
     292         [ +  - ]:          6 :                         if( eChartTypeEnum != XML_CHART_CLASS_UNKNOWN )
     293                 :            :                         {
     294         [ +  - ]:          6 :                             aOldChartTypeName = SchXMLTools::GetChartTypeByClassName( sClassName, true /* bUseOldNames */ );
     295         [ +  - ]:          6 :                             maChartTypeServiceName = SchXMLTools::GetChartTypeByClassName( sClassName, false /* bUseOldNames */ );
     296      [ -  -  + ]:          6 :                             switch( eChartTypeEnum )
     297                 :            :                             {
     298                 :            :                             case XML_CHART_CLASS_CIRCLE:
     299                 :          0 :                                 bSetSwitchData = sal_True;
     300                 :          0 :                                 break;
     301                 :            :                             case XML_CHART_CLASS_STOCK:
     302                 :          0 :                                 mbIsStockChart = true;
     303                 :          0 :                                 break;
     304                 :            :                             default:
     305                 :          6 :                                 break;
     306                 :            :                             }
     307                 :            :                         }
     308                 :            :                     }
     309         [ #  # ]:          0 :                     else if( XML_NAMESPACE_OOO == nClassPrefix )
     310                 :            :                     {
     311                 :            :                         // service is taken from add-in-name attribute
     312                 :          0 :                         bHasAddin = true;
     313                 :            : 
     314                 :          0 :                         aOldChartTypeName = sClassName;
     315                 :          0 :                         maChartTypeServiceName = sClassName;
     316                 :          6 :                     }
     317                 :            :                 }
     318                 :          6 :                 break;
     319                 :            : 
     320                 :            :             case XML_TOK_CHART_WIDTH:
     321                 :          6 :                 GetImport().GetMM100UnitConverter().convertMeasureToCore(
     322         [ +  - ]:          6 :                         maChartSize.Width, aValue );
     323                 :          6 :                 break;
     324                 :            : 
     325                 :            :             case XML_TOK_CHART_HEIGHT:
     326                 :          6 :                 GetImport().GetMM100UnitConverter().convertMeasureToCore(
     327         [ +  - ]:          6 :                         maChartSize.Height, aValue );
     328                 :          6 :                 break;
     329                 :            : 
     330                 :            :             case XML_TOK_CHART_STYLE_NAME:
     331                 :          6 :                 sAutoStyleName = aValue;
     332                 :          6 :                 break;
     333                 :            : 
     334                 :            :             case XML_TOK_CHART_COL_MAPPING:
     335                 :          0 :                 msColTrans = aValue;
     336                 :          0 :                 break;
     337                 :            :             case XML_TOK_CHART_ROW_MAPPING:
     338                 :          0 :                 msRowTrans = aValue;
     339                 :          0 :                 break;
     340                 :            :         }
     341                 :         24 :     }
     342                 :            : 
     343         [ -  + ]:          6 :     if( aOldChartTypeName.isEmpty() )
     344                 :            :     {
     345                 :            :         OSL_FAIL( "need a charttype to create a diagram" );
     346                 :            :         //set a fallback value:
     347         [ #  # ]:          0 :         ::rtl::OUString aChartClass_Bar( GetXMLToken(XML_BAR ) );
     348         [ #  # ]:          0 :         aOldChartTypeName = SchXMLTools::GetChartTypeByClassName( aChartClass_Bar, true /* bUseOldNames */ );
     349         [ #  # ]:          0 :         maChartTypeServiceName = SchXMLTools::GetChartTypeByClassName( aChartClass_Bar, false /* bUseOldNames */ );
     350                 :            :     }
     351                 :            : 
     352                 :            :     //  Set the size of the draw page.
     353         [ +  - ]:          6 :     if( xVisualObject.is() )
     354 [ +  - ][ +  - ]:          6 :         xVisualObject->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, maChartSize );
     355                 :            : 
     356         [ +  - ]:          6 :     InitChart( aOldChartTypeName, bSetSwitchData);
     357                 :            : 
     358         [ -  + ]:          6 :     if( bHasAddin )
     359                 :            :     {
     360                 :            :         //correct charttype serveice name when having an addin
     361                 :            :         //and don't refresh addin during load
     362         [ #  # ]:          0 :         uno::Reference< beans::XPropertySet > xDocProp( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
     363         [ #  # ]:          0 :         if( xDocProp.is() )
     364                 :            :         {
     365                 :            :             try
     366                 :            :             {
     367 [ #  # ][ #  # ]:          0 :                 xDocProp->getPropertyValue( ::rtl::OUString( "BaseDiagram" )) >>= aOldChartTypeName;
     368         [ #  # ]:          0 :                 maChartTypeServiceName =  SchXMLTools::GetNewChartTypeName( aOldChartTypeName );
     369 [ #  # ][ #  # ]:          0 :                 xDocProp->setPropertyValue( rtl::OUString( "RefreshAddInAllowed" ) , uno::makeAny( sal_False) );
         [ #  # ][ #  # ]
     370                 :            :             }
     371         [ #  # ]:          0 :             catch(const uno::Exception&)
     372                 :            :             {
     373                 :            :                 OSL_FAIL( "Exception during import SchXMLChartContext::StartElement" );
     374                 :            :             }
     375                 :          0 :         }
     376                 :            :     }
     377                 :            : 
     378                 :            :     // set auto-styles for Area
     379 [ +  - ][ +  - ]:          6 :     uno::Reference< beans::XPropertySet > xProp( mrImportHelper.GetChartDocument()->getArea(), uno::UNO_QUERY );
                 [ +  - ]
     380         [ +  - ]:          6 :     if( xProp.is())
     381                 :            :     {
     382                 :          6 :         const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
     383         [ +  - ]:          6 :         if( pStylesCtxt )
     384                 :            :         {
     385                 :            :             const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
     386         [ +  - ]:          6 :                 mrImportHelper.GetChartFamilyID(), sAutoStyleName );
     387                 :            : 
     388 [ +  - ][ +  - ]:          6 :             if( pStyle && pStyle->ISA( XMLPropStyleContext ))
         [ +  - ][ +  - ]
                 [ +  - ]
     389         [ +  - ]:          6 :                 (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
     390                 :            :         }
     391                 :          6 :     }
     392                 :          6 : }
     393                 :            : 
     394                 :            : namespace
     395                 :            : {
     396                 :            : 
     397 [ #  # ][ #  # ]:          0 : struct NewDonutSeries
     398                 :            : {
     399                 :            :     ::com::sun::star::uno::Reference<
     400                 :            :                 ::com::sun::star::chart2::XDataSeries > m_xSeries;
     401                 :            :     ::rtl::OUString msStyleName;
     402                 :            :     sal_Int32 mnAttachedAxis;
     403                 :            : 
     404                 :            :     ::std::vector< ::rtl::OUString > m_aSeriesStyles;
     405                 :            :     ::std::vector< ::rtl::OUString > m_aPointStyles;
     406                 :            : 
     407                 :          0 :     NewDonutSeries( const ::com::sun::star::uno::Reference<
     408                 :            :                 ::com::sun::star::chart2::XDataSeries >& xSeries, sal_Int32 nPointCount )
     409                 :            :                     : m_xSeries( xSeries )
     410 [ #  # ][ #  # ]:          0 :                     , mnAttachedAxis( 1 )
     411                 :            :     {
     412         [ #  # ]:          0 :         m_aPointStyles.resize(nPointCount);
     413         [ #  # ]:          0 :         m_aSeriesStyles.resize(nPointCount);
     414                 :          0 :     }
     415                 :            : 
     416                 :          0 :     void setSeriesStyleNameToPoint( const ::rtl::OUString& rStyleName, sal_Int32 nPointIndex )
     417                 :            :     {
     418                 :            :         DBG_ASSERT(nPointIndex < static_cast<sal_Int32>(m_aSeriesStyles.size()),"donut point <-> series count mismatch");
     419         [ #  # ]:          0 :         if( nPointIndex < static_cast<sal_Int32>(m_aSeriesStyles.size()) )
     420                 :          0 :             m_aSeriesStyles[nPointIndex]=rStyleName;
     421                 :          0 :     }
     422                 :            : 
     423                 :          0 :     void setPointStyleNameToPoint( const ::rtl::OUString& rStyleName, sal_Int32 nPointIndex )
     424                 :            :     {
     425                 :            :         DBG_ASSERT(nPointIndex < static_cast<sal_Int32>(m_aPointStyles.size()),"donut point <-> series count mismatch");
     426         [ #  # ]:          0 :         if( nPointIndex < static_cast<sal_Int32>(m_aPointStyles.size()) )
     427                 :          0 :             m_aPointStyles[nPointIndex]=rStyleName;
     428                 :          0 :     }
     429                 :            : 
     430                 :          0 :     ::std::list< DataRowPointStyle > creatStyleList()
     431                 :            :     {
     432         [ #  # ]:          0 :         ::std::list< DataRowPointStyle > aRet;
     433                 :            : 
     434                 :            :         DataRowPointStyle aSeriesStyle( DataRowPointStyle::DATA_SERIES
     435         [ #  # ]:          0 :             , m_xSeries, -1, 1, msStyleName, mnAttachedAxis );
     436         [ #  # ]:          0 :         aRet.push_back( aSeriesStyle );
     437                 :            : 
     438                 :          0 :         sal_Int32 nPointIndex=0;
     439                 :          0 :         ::std::vector< ::rtl::OUString >::iterator aPointIt( m_aPointStyles.begin() );
     440                 :          0 :         ::std::vector< ::rtl::OUString >::iterator aPointEnd( m_aPointStyles.end() );
     441 [ #  # ][ #  # ]:          0 :         while( aPointIt != aPointEnd )
     442                 :            :         {
     443                 :            :             DataRowPointStyle aPointStyle( DataRowPointStyle::DATA_POINT
     444         [ #  # ]:          0 :                 , m_xSeries, nPointIndex, 1, *aPointIt, mnAttachedAxis );
     445         [ #  # ]:          0 :             if( nPointIndex < static_cast<sal_Int32>(m_aSeriesStyles.size()) )
     446                 :            :             {
     447                 :          0 :                 aPointStyle.msSeriesStyleNameForDonuts = m_aSeriesStyles[nPointIndex];
     448                 :            :             }
     449   [ #  #  #  # ]:          0 :             if( !aPointStyle.msSeriesStyleNameForDonuts.isEmpty()
                 [ #  # ]
     450                 :          0 :                 || !aPointStyle.msStyleName.isEmpty() )
     451         [ #  # ]:          0 :                 aRet.push_back( aPointStyle );
     452                 :          0 :             ++aPointIt;
     453                 :          0 :             ++nPointIndex;
     454         [ #  # ]:          0 :         }
     455                 :            : 
     456         [ #  # ]:          0 :         return aRet;
     457                 :            :     }
     458                 :            : };
     459                 :            : 
     460                 :          0 : void lcl_swapPointAndSeriesStylesForDonutCharts( ::std::list< DataRowPointStyle >& rStyleList
     461                 :            :         , const ::std::map< ::com::sun::star::uno::Reference<
     462                 :            :                 ::com::sun::star::chart2::XDataSeries> , sal_Int32 >& rSeriesMap )
     463                 :            : {
     464                 :          0 :     ::std::list< DataRowPointStyle >::iterator aIt(rStyleList.begin());
     465                 :          0 :     ::std::list< DataRowPointStyle >::iterator aEnd(rStyleList.end());
     466                 :            : 
     467                 :            :     //detect old series count
     468                 :            :     //and add old series to aSeriesMap
     469                 :            :     ::std::map< ::com::sun::star::uno::Reference<
     470         [ #  # ]:          0 :                 ::com::sun::star::chart2::XDataSeries >, sal_Int32 > aSeriesMap(rSeriesMap);
     471                 :          0 :     sal_Int32 nOldSeriesCount = 0;
     472                 :            :     {
     473                 :          0 :         sal_Int32 nMaxOldSeriesIndex = 0;
     474                 :          0 :         sal_Int32 nOldSeriesIndex = 0;
     475         [ #  # ]:          0 :         for( aIt = rStyleList.begin(); aIt != aEnd; ++aIt )
     476                 :            :         {
     477         [ #  # ]:          0 :             DataRowPointStyle aStyle(*aIt);
     478   [ #  #  #  # ]:          0 :             if(aStyle.meType == DataRowPointStyle::DATA_SERIES &&
                 [ #  # ]
     479                 :          0 :                     aStyle.m_xSeries.is() )
     480                 :            :             {
     481                 :          0 :                 nMaxOldSeriesIndex = nOldSeriesIndex;
     482                 :            : 
     483 [ #  # ][ #  # ]:          0 :                 if( aSeriesMap.end() == aSeriesMap.find(aStyle.m_xSeries) )
     484         [ #  # ]:          0 :                     aSeriesMap[aStyle.m_xSeries] = nOldSeriesIndex;
     485                 :            : 
     486                 :          0 :                 nOldSeriesIndex++;
     487                 :            :             }
     488         [ #  # ]:          0 :         }
     489                 :          0 :         nOldSeriesCount = nMaxOldSeriesIndex+1;
     490                 :            :     }
     491                 :            : 
     492                 :            : 
     493                 :            :     //initialize new series styles
     494                 :          0 :     ::std::map< Reference< chart2::XDataSeries >, sal_Int32 >::const_iterator aSeriesMapIt( aSeriesMap.begin() );
     495                 :          0 :     ::std::map< Reference< chart2::XDataSeries >, sal_Int32 >::const_iterator aSeriesMapEnd( aSeriesMap.end() );
     496                 :            : 
     497                 :            :     //sort by index
     498         [ #  # ]:          0 :     ::std::vector< NewDonutSeries > aNewSeriesVector;
     499                 :            :     {
     500         [ #  # ]:          0 :         ::std::map< sal_Int32, Reference< chart2::XDataSeries > > aIndexSeriesMap;
     501         [ #  # ]:          0 :         for( ; aSeriesMapIt != aSeriesMapEnd; ++aSeriesMapIt )
     502 [ #  # ][ #  # ]:          0 :             aIndexSeriesMap[aSeriesMapIt->second] = aSeriesMapIt->first;
     503                 :            : 
     504                 :          0 :         ::std::map< sal_Int32, Reference< chart2::XDataSeries > >::const_iterator aIndexIt( aIndexSeriesMap.begin() );
     505                 :          0 :         ::std::map< sal_Int32, Reference< chart2::XDataSeries > >::const_iterator aIndexEnd( aIndexSeriesMap.end() );
     506                 :            : 
     507         [ #  # ]:          0 :         for( ; aIndexIt != aIndexEnd; ++aIndexIt )
     508 [ #  # ][ #  # ]:          0 :             aNewSeriesVector.push_back( NewDonutSeries(aIndexIt->second,nOldSeriesCount) );
                 [ #  # ]
     509                 :            :     }
     510                 :            : 
     511                 :            :     //overwrite attached axis information according to old series styles
     512         [ #  # ]:          0 :     for( aIt = rStyleList.begin(); aIt != aEnd; ++aIt )
     513                 :            :     {
     514         [ #  # ]:          0 :         DataRowPointStyle aStyle(*aIt);
     515         [ #  # ]:          0 :         if(aStyle.meType == DataRowPointStyle::DATA_SERIES )
     516                 :            :         {
     517         [ #  # ]:          0 :             aSeriesMapIt = aSeriesMap.find( aStyle.m_xSeries );
     518 [ #  # ][ #  # ]:          0 :             if( aSeriesMapIt != aSeriesMapEnd && aSeriesMapIt->second < static_cast<sal_Int32>(aNewSeriesVector.size()) )
                 [ #  # ]
     519                 :          0 :                 aNewSeriesVector[aSeriesMapIt->second].mnAttachedAxis = aStyle.mnAttachedAxis;
     520                 :            :         }
     521         [ #  # ]:          0 :     }
     522                 :            : 
     523                 :            :     //overwrite new series style names with old series style name information
     524         [ #  # ]:          0 :     for( aIt = rStyleList.begin(); aIt != aEnd; ++aIt )
     525                 :            :     {
     526         [ #  # ]:          0 :         DataRowPointStyle aStyle(*aIt);
     527         [ #  # ]:          0 :         if( aStyle.meType == DataRowPointStyle::DATA_SERIES )
     528                 :            :         {
     529         [ #  # ]:          0 :             aSeriesMapIt = aSeriesMap.find(aStyle.m_xSeries);
     530         [ #  # ]:          0 :             if( aSeriesMapEnd != aSeriesMapIt )
     531                 :            :             {
     532                 :          0 :                 sal_Int32 nNewPointIndex = aSeriesMapIt->second;
     533                 :            : 
     534                 :          0 :                 ::std::vector< NewDonutSeries >::iterator aNewSeriesIt( aNewSeriesVector.begin() );
     535                 :          0 :                 ::std::vector< NewDonutSeries >::iterator aNewSeriesEnd( aNewSeriesVector.end() );
     536                 :            : 
     537 [ #  # ][ #  # ]:          0 :                 for( ;aNewSeriesIt!=aNewSeriesEnd; ++aNewSeriesIt)
     538         [ #  # ]:          0 :                     aNewSeriesIt->setSeriesStyleNameToPoint( aStyle.msStyleName, nNewPointIndex );
     539                 :            :             }
     540                 :            :         }
     541         [ #  # ]:          0 :     }
     542                 :            : 
     543                 :            :     //overwrite new series style names with point style name information
     544         [ #  # ]:          0 :     for( aIt = rStyleList.begin(); aIt != aEnd; ++aIt )
     545                 :            :     {
     546         [ #  # ]:          0 :         DataRowPointStyle aStyle(*aIt);
     547         [ #  # ]:          0 :         if( aStyle.meType == DataRowPointStyle::DATA_POINT )
     548                 :            :         {
     549         [ #  # ]:          0 :             aSeriesMapIt = aSeriesMap.find(aStyle.m_xSeries);
     550         [ #  # ]:          0 :             if( aSeriesMapEnd != aSeriesMapIt )
     551                 :            :             {
     552                 :          0 :                 sal_Int32 nNewPointIndex = aSeriesMapIt->second;
     553                 :          0 :                 sal_Int32 nNewSeriesIndex = aStyle.m_nPointIndex;
     554                 :          0 :                 sal_Int32 nRepeatCount = aStyle.m_nPointRepeat;
     555                 :            : 
     556 [ #  # ][ #  # ]:          0 :                 while( nRepeatCount && (nNewSeriesIndex>=0) && (nNewSeriesIndex< static_cast<sal_Int32>(aNewSeriesVector.size()) ) )
         [ #  # ][ #  # ]
     557                 :            :                 {
     558                 :          0 :                     NewDonutSeries& rNewSeries( aNewSeriesVector[nNewSeriesIndex] );
     559         [ #  # ]:          0 :                     rNewSeries.setPointStyleNameToPoint( aStyle.msStyleName, nNewPointIndex );
     560                 :            : 
     561                 :          0 :                     nRepeatCount--;
     562                 :          0 :                     nNewSeriesIndex++;
     563                 :            :                 }
     564                 :            :             }
     565                 :            :         }
     566         [ #  # ]:          0 :     }
     567                 :            : 
     568                 :            :     //put information from aNewSeriesVector to output parameter rStyleList
     569                 :          0 :     rStyleList.clear();
     570                 :            : 
     571                 :          0 :     ::std::vector< NewDonutSeries >::iterator aNewSeriesIt( aNewSeriesVector.begin() );
     572                 :          0 :     ::std::vector< NewDonutSeries >::iterator aNewSeriesEnd( aNewSeriesVector.end() );
     573 [ #  # ][ #  # ]:          0 :     for( ;aNewSeriesIt!=aNewSeriesEnd; ++aNewSeriesIt)
     574                 :            :     {
     575         [ #  # ]:          0 :         ::std::list< DataRowPointStyle > aList( aNewSeriesIt->creatStyleList() );
     576         [ #  # ]:          0 :         rStyleList.insert(rStyleList.end(),aList.begin(),aList.end());
     577                 :          0 :     }
     578                 :          0 : }
     579                 :            : 
     580                 :         12 : bool lcl_SpecialHandlingForDonutChartNeeded(
     581                 :            :     const ::rtl::OUString & rServiceName,
     582                 :            :     const SvXMLImport & rImport )
     583                 :            : {
     584                 :         12 :     bool bResult = false;
     585         [ -  + ]:         12 :     if( rServiceName == "com.sun.star.chart2.DonutChartType" )
     586                 :            :     {
     587                 :          0 :         bResult = SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( rImport.GetModel() );
     588                 :            :     }
     589                 :         12 :     return bResult;
     590                 :            : }
     591                 :            : 
     592                 :            : } // anonymous namespace
     593                 :            : 
     594                 :            : 
     595                 :          0 : void lcl_ApplyDataFromRectangularRangeToDiagram(
     596                 :            :         const uno::Reference< chart2::XChartDocument >& xNewDoc
     597                 :            :         , const rtl::OUString& rRectangularRange
     598                 :            :         , ::com::sun::star::chart::ChartDataRowSource eDataRowSource
     599                 :            :         , bool bRowHasLabels, bool bColHasLabels
     600                 :            :         , bool bSwitchOnLabelsAndCategoriesForOwnData
     601                 :            :         , const rtl::OUString& sColTrans
     602                 :            :         , const rtl::OUString& sRowTrans )
     603                 :            : {
     604         [ #  # ]:          0 :     if( !xNewDoc.is() )
     605                 :            :         return;
     606                 :            : 
     607 [ #  # ][ #  # ]:          0 :     uno::Reference< chart2::XDiagram > xNewDia( xNewDoc->getFirstDiagram());
     608 [ #  # ][ #  # ]:          0 :     uno::Reference< chart2::data::XDataProvider > xDataProvider( xNewDoc->getDataProvider() );
     609 [ #  # ][ #  # ]:          0 :     if( !xNewDia.is() || !xDataProvider.is() )
                 [ #  # ]
     610                 :            :         return;
     611                 :            : 
     612                 :            :     sal_Bool bFirstCellAsLabel =
     613         [ #  # ]:          0 :         (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bRowHasLabels : bColHasLabels;
     614                 :            :     sal_Bool bHasCateories =
     615         [ #  # ]:          0 :         (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bColHasLabels : bRowHasLabels;
     616                 :            : 
     617         [ #  # ]:          0 :     if( bSwitchOnLabelsAndCategoriesForOwnData )
     618                 :            :     {
     619                 :          0 :         bFirstCellAsLabel = true;
     620                 :          0 :         bHasCateories = true;
     621                 :            :     }
     622                 :            : 
     623         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aArgs( 3 );
     624         [ #  # ]:          0 :     aArgs[0] = beans::PropertyValue(
     625                 :            :         ::rtl::OUString( "CellRangeRepresentation" ),
     626                 :            :         -1, uno::makeAny( rRectangularRange ),
     627         [ #  # ]:          0 :         beans::PropertyState_DIRECT_VALUE );
     628         [ #  # ]:          0 :     aArgs[1] = beans::PropertyValue(
     629                 :            :         ::rtl::OUString( "DataRowSource" ),
     630                 :            :         -1, uno::makeAny( eDataRowSource ),
     631         [ #  # ]:          0 :         beans::PropertyState_DIRECT_VALUE );
     632         [ #  # ]:          0 :     aArgs[2] = beans::PropertyValue(
     633                 :            :         ::rtl::OUString( "FirstCellAsLabel" ),
     634                 :            :         -1, uno::makeAny( bFirstCellAsLabel ),
     635         [ #  # ]:          0 :         beans::PropertyState_DIRECT_VALUE );
     636                 :            : 
     637 [ #  # ][ #  # ]:          0 :     if( !sColTrans.isEmpty() || !sRowTrans.isEmpty() )
                 [ #  # ]
     638                 :            :     {
     639         [ #  # ]:          0 :         aArgs.realloc( aArgs.getLength() + 1 );
     640         [ #  # ]:          0 :         aArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
     641                 :            :             ::rtl::OUString( "SequenceMapping" ),
     642                 :          0 :             -1, uno::makeAny( !sColTrans.isEmpty()
     643 [ #  # ][ #  # ]:          0 :                 ? lcl_getNumberSequenceFromString( sColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() )
     644 [ #  # ][ #  # ]:          0 :                 : lcl_getNumberSequenceFromString( sRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ),
     645 [ #  # ][ #  # ]:          0 :         beans::PropertyState_DIRECT_VALUE );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     646                 :            :     }
     647                 :            : 
     648                 :            :     //work around wrong writer ranges ( see Issue 58464 )
     649                 :            :     {
     650                 :          0 :         rtl::OUString aChartOleObjectName;
     651         [ #  # ]:          0 :         uno::Reference< frame::XModel > xModel(xNewDoc, uno::UNO_QUERY );
     652         [ #  # ]:          0 :         if( xModel.is() )
     653                 :            :         {
     654 [ #  # ][ #  # ]:          0 :             comphelper::MediaDescriptor aMediaDescriptor( xModel->getArgs() );
         [ #  # ][ #  # ]
     655                 :            : 
     656                 :            :             comphelper::MediaDescriptor::const_iterator aIt(
     657         [ #  # ]:          0 :                 aMediaDescriptor.find( rtl::OUString(  "HierarchicalDocumentName" )));
     658 [ #  # ][ #  # ]:          0 :             if( aIt != aMediaDescriptor.end() )
     659                 :            :             {
     660 [ #  # ][ #  # ]:          0 :                 aChartOleObjectName = (*aIt).second.get< ::rtl::OUString >();
     661         [ #  # ]:          0 :             }
     662                 :            :         }
     663         [ #  # ]:          0 :         if( !aChartOleObjectName.isEmpty() )
     664                 :            :         {
     665         [ #  # ]:          0 :             aArgs.realloc( aArgs.getLength() + 1 );
     666         [ #  # ]:          0 :             aArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
     667                 :            :                 ::rtl::OUString( "ChartOleObjectName" ),
     668                 :            :                 -1, uno::makeAny( aChartOleObjectName ),
     669         [ #  # ]:          0 :                 beans::PropertyState_DIRECT_VALUE );
     670                 :          0 :         }
     671                 :            :     }
     672                 :            : 
     673                 :            : 
     674                 :            :     uno::Reference< chart2::data::XDataSource > xDataSource(
     675 [ #  # ][ #  # ]:          0 :         xDataProvider->createDataSource( aArgs ));
     676                 :            : 
     677         [ #  # ]:          0 :     aArgs.realloc( aArgs.getLength() + 2 );
     678         [ #  # ]:          0 :     aArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 2 ] = beans::PropertyValue(
     679                 :            :         ::rtl::OUString( "HasCategories" ),
     680                 :            :         -1, uno::makeAny( bHasCateories ),
     681         [ #  # ]:          0 :         beans::PropertyState_DIRECT_VALUE );
     682         [ #  # ]:          0 :     aArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
     683                 :            :         ::rtl::OUString("UseCategoriesAsX"),
     684                 :            :         -1, uno::makeAny( sal_False ),//categories in ODF files are not to be used as x values (independent from what is offered in our ui)
     685         [ #  # ]:          0 :         beans::PropertyState_DIRECT_VALUE );
     686                 :            : 
     687 [ #  # ][ #  # ]:          0 :     xNewDia->setDiagramData( xDataSource, aArgs );
         [ #  # ][ #  # ]
                 [ #  # ]
     688                 :            : }
     689                 :            : 
     690                 :          6 : void SchXMLChartContext::EndElement()
     691                 :            : {
     692                 :          6 :     uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
     693         [ +  - ]:          6 :     uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
     694         [ +  - ]:          6 :     uno::Reference< chart2::XChartDocument > xNewDoc( xDoc, uno::UNO_QUERY );
     695                 :            : 
     696         [ +  - ]:          6 :     if( xProp.is())
     697                 :            :     {
     698         [ +  - ]:          6 :         if( !maMainTitle.isEmpty())
     699                 :            :         {
     700 [ +  - ][ +  - ]:          6 :             uno::Reference< beans::XPropertySet > xTitleProp( xDoc->getTitle(), uno::UNO_QUERY );
                 [ +  - ]
     701         [ +  - ]:          6 :             if( xTitleProp.is())
     702                 :            :             {
     703                 :            :                 try
     704                 :            :                 {
     705                 :          6 :                     uno::Any aAny;
     706         [ +  - ]:          6 :                     aAny <<= maMainTitle;
     707 [ +  - ][ +  - ]:          6 :                     xTitleProp->setPropertyValue( rtl::OUString(  "String" ), aAny );
                 [ #  # ]
     708                 :            :                 }
     709         [ #  # ]:          0 :                 catch(const beans::UnknownPropertyException&)
     710                 :            :                 {
     711                 :            :                     OSL_FAIL( "Property String for Title not available" );
     712                 :            :                 }
     713                 :          6 :             }
     714                 :            :         }
     715         [ +  - ]:          6 :         if( !maSubTitle.isEmpty())
     716                 :            :         {
     717 [ +  - ][ +  - ]:          6 :             uno::Reference< beans::XPropertySet > xTitleProp( xDoc->getSubTitle(), uno::UNO_QUERY );
                 [ +  - ]
     718         [ +  - ]:          6 :             if( xTitleProp.is())
     719                 :            :             {
     720                 :            :                 try
     721                 :            :                 {
     722                 :          6 :                     uno::Any aAny;
     723         [ +  - ]:          6 :                     aAny <<= maSubTitle;
     724 [ +  - ][ +  - ]:          6 :                     xTitleProp->setPropertyValue( rtl::OUString(  "String" ), aAny );
                 [ #  # ]
     725                 :            :                 }
     726         [ #  # ]:          0 :                 catch(const beans::UnknownPropertyException&)
     727                 :            :                 {
     728                 :            :                     OSL_FAIL( "Property String for Title not available" );
     729                 :            :                 }
     730                 :          6 :             }
     731                 :            :         }
     732                 :            :     }
     733                 :            : 
     734                 :            :     // cleanup: remove empty chart type groups
     735         [ +  - ]:          6 :     lcl_removeEmptyChartTypeGroups( xNewDoc );
     736                 :            : 
     737                 :            :     // set stack mode before a potential chart type detection (in case we have a rectangular range)
     738 [ +  - ][ +  - ]:          6 :     uno::Reference< chart::XDiagram > xDiagram( xDoc->getDiagram() );
     739         [ +  - ]:          6 :     uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
     740         [ +  - ]:          6 :     if( xDiaProp.is())
     741                 :            :     {
     742         [ -  + ]:          6 :         if( maSeriesDefaultsAndStyles.maStackedDefault.hasValue())
     743 [ #  # ][ #  # ]:          0 :             xDiaProp->setPropertyValue(::rtl::OUString("Stacked"),maSeriesDefaultsAndStyles.maStackedDefault);
     744         [ -  + ]:          6 :         if( maSeriesDefaultsAndStyles.maPercentDefault.hasValue())
     745 [ #  # ][ #  # ]:          0 :             xDiaProp->setPropertyValue(::rtl::OUString("Percent"),maSeriesDefaultsAndStyles.maPercentDefault);
     746         [ +  - ]:          6 :         if( maSeriesDefaultsAndStyles.maDeepDefault.hasValue())
     747 [ +  - ][ +  - ]:          6 :             xDiaProp->setPropertyValue(::rtl::OUString("Deep"),maSeriesDefaultsAndStyles.maDeepDefault);
     748         [ +  - ]:          6 :         if( maSeriesDefaultsAndStyles.maStackedBarsConnectedDefault.hasValue())
     749 [ +  - ][ +  - ]:          6 :             xDiaProp->setPropertyValue(::rtl::OUString("StackedBarsConnected"),maSeriesDefaultsAndStyles.maStackedBarsConnectedDefault);
     750                 :            :     }
     751                 :            : 
     752                 :            :     //the OOo 2.0 implementation and older has a bug with donuts
     753                 :            :     bool bSpecialHandlingForDonutChart = lcl_SpecialHandlingForDonutChartNeeded(
     754         [ +  - ]:          6 :         maChartTypeServiceName, GetImport());
     755                 :            : 
     756                 :            :     // apply data
     757         [ -  + ]:          6 :     if(!xNewDoc.is())
     758                 :          6 :         return;
     759                 :            : 
     760                 :          6 :     bool bHasOwnData = false;
     761         [ -  + ]:          6 :     if( m_aXLinkHRefAttributeToIndicateDataProvider == "." ) //data comes from the chart itself
     762                 :          0 :         bHasOwnData = true;
     763         [ -  + ]:          6 :     else if( m_aXLinkHRefAttributeToIndicateDataProvider == ".." ) //data comes from the parent application
     764                 :          0 :         bHasOwnData = false;
     765         [ -  + ]:          6 :     else if( !m_aXLinkHRefAttributeToIndicateDataProvider.isEmpty() ) //not supported so far to get the data by sibling objects -> fall back to chart itself if data are available
     766                 :          0 :         bHasOwnData = m_bHasTableElement;
     767                 :            :     else
     768                 :          6 :         bHasOwnData = !m_bHasRangeAtPlotArea;
     769                 :            : 
     770 [ +  - ][ +  - ]:          6 :     if( xNewDoc->hasInternalDataProvider())
                 [ +  - ]
     771                 :            :     {
     772 [ -  + ][ #  # ]:          6 :         if( !m_bHasTableElement && m_aXLinkHRefAttributeToIndicateDataProvider != "." )
                 [ -  + ]
     773                 :            :         {
     774                 :            :             //#i103147# ODF, workaround broken files with a missing table:cell-range-address at the plot-area
     775         [ #  # ]:          0 :             bool bSwitchSuccessful = SchXMLTools::switchBackToDataProviderFromParent( xNewDoc, maLSequencesPerIndex );
     776                 :          0 :             bHasOwnData = !bSwitchSuccessful;
     777                 :            :         }
     778                 :            :         else
     779                 :          6 :             bHasOwnData = true;//e.g. in case of copy->paste from calc to impress
     780                 :            :     }
     781         [ #  # ]:          0 :     else if( bHasOwnData )
     782                 :            :     {
     783 [ #  # ][ #  # ]:          0 :         xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ );
     784                 :            :     }
     785         [ +  - ]:          6 :     if( bHasOwnData )
     786                 :          6 :         msChartAddress = ::rtl::OUString( "all" );
     787                 :            : 
     788                 :          6 :     bool bSwitchRangesFromOuterToInternalIfNecessary = false;
     789 [ -  + ][ #  # ]:          6 :     if( !bHasOwnData && mbAllRangeAddressesAvailable )
     790                 :            :     {
     791                 :            :         // special handling for stock chart (merge series together)
     792         [ #  # ]:          0 :         if( mbIsStockChart )
     793         [ #  # ]:          0 :             MergeSeriesForStockChart();
     794                 :            :     }
     795         [ +  - ]:          6 :     else if( !msChartAddress.isEmpty() )
     796                 :            :     {
     797                 :            :         //own data or only rectangular range available
     798                 :            : 
     799 [ +  - ][ +  - ]:          6 :         if( xNewDoc->hasInternalDataProvider() )
                 [ +  - ]
     800         [ +  - ]:          6 :             SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc );
     801                 :            : 
     802 [ +  - ][ +  - ]:          6 :         bool bOlderThan2_3 = SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( Reference< frame::XModel >( xNewDoc, uno::UNO_QUERY ));
     803 [ #  # ][ #  # ]:          6 :         bool bOldFileWithOwnDataFromRows = (bOlderThan2_3 && bHasOwnData && (meDataRowSource==chart::ChartDataRowSource_ROWS)); // in this case there are range addresses that are simply wrong.
                 [ -  + ]
     804                 :            : 
     805 [ +  - ][ +  - ]:          6 :         if( mbAllRangeAddressesAvailable && !bSpecialHandlingForDonutChart && !mbIsStockChart &&
         [ +  - ][ +  - ]
     806                 :          6 :             !bOldFileWithOwnDataFromRows )
     807                 :            :         {
     808                 :            :             //bHasOwnData is true in this case!
     809                 :            :             //e.g. for normal files with own data or also in case of copy paste scenario (e.g. calc to impress)
     810                 :          6 :             bSwitchRangesFromOuterToInternalIfNecessary = true;
     811                 :            :         }
     812                 :            :         else
     813                 :            :         {
     814                 :            :             //apply data from rectangular range
     815                 :            : 
     816                 :            :             // create datasource from data provider with rectangular range parameters and change the diagram setDiagramData
     817                 :            :             try
     818                 :            :             {
     819 [ #  # ][ #  # ]:          0 :                 if( bOlderThan2_3 && xDiaProp.is() )//for older charts the hidden cells were removed by calc on the fly
                 [ #  # ]
     820 [ #  # ][ #  # ]:          0 :                     xDiaProp->setPropertyValue(::rtl::OUString("IncludeHiddenCells"),uno::makeAny(false));
                 [ #  # ]
     821                 :            : 
     822                 :            :                 // note: mbRowHasLabels means the first row contains labels, that means we have "column-descriptions",
     823                 :            :                 // (analogously mbColHasLabels means we have "row-descriptions")
     824         [ #  # ]:          6 :                 lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans );
     825                 :            :             }
     826   [ #  #  #  # ]:          0 :             catch(const uno::Exception&)
     827                 :            :             {
     828                 :            :                 //try to fallback to internal data
     829                 :            :                 OSL_FAIL( "Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram try to fallback to internal data" );
     830         [ #  # ]:          0 :                 if(!bHasOwnData)
     831                 :            :                 {
     832                 :          0 :                     bHasOwnData = true;
     833                 :          0 :                     msChartAddress = ::rtl::OUString( "all" );
     834   [ #  #  #  #  :          0 :                     if( !xNewDoc->hasInternalDataProvider() )
                   #  # ]
     835                 :            :                     {
     836   [ #  #  #  # ]:          0 :                         xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ );
     837   [ #  #  #  # ]:          0 :                         SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc );
     838                 :            :                         try
     839                 :            :                         {
     840         [ #  # ]:          0 :                             lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans );
     841                 :            :                         }
     842         [ #  # ]:          0 :                         catch(const uno::Exception&)
     843                 :            :                         {
     844                 :            :                             OSL_FAIL( "Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram fallback to internal data failed also" );
     845                 :            :                         }
     846                 :            :                     }
     847                 :            :                 }
     848                 :            :             }
     849                 :            :         }
     850                 :            :     }
     851                 :            :     else
     852                 :            :     {
     853                 :            :         OSL_FAIL( " Must not get here" );
     854                 :            :     }
     855                 :            : 
     856                 :            :     // now all series and data point properties are available and can be set
     857                 :            :     {
     858         [ -  + ]:          6 :         if( bSpecialHandlingForDonutChart )
     859                 :            :         {
     860 [ #  # ][ #  # ]:          0 :             uno::Reference< chart2::XDiagram > xNewDiagram( xNewDoc->getFirstDiagram() );
     861                 :            :             lcl_swapPointAndSeriesStylesForDonutCharts( maSeriesDefaultsAndStyles.maSeriesStyleList
     862 [ #  # ][ #  # ]:          0 :                 , SchXMLSeriesHelper::getDataSeriesIndexMapFromDiagram(xNewDiagram) );
     863                 :            :         }
     864                 :            : 
     865 [ +  - ][ +  - ]:          6 :         SchXMLSeries2Context::initSeriesPropertySets( maSeriesDefaultsAndStyles, uno::Reference< frame::XModel >(xDoc, uno::UNO_QUERY ) );
     866                 :            : 
     867                 :            :         //set defaults from diagram to the new series:
     868                 :            :         //check whether we need to remove lines from symbol only charts
     869                 :          6 :         bool bSwitchOffLinesForScatter = false;
     870                 :            :         {
     871                 :          6 :             bool bLinesOn = true;
     872 [ +  - ][ +  - ]:          6 :             if( (maSeriesDefaultsAndStyles.maLinesOnProperty >>= bLinesOn) && !bLinesOn )
                 [ +  - ]
     873                 :            :             {
     874         [ -  + ]:          6 :                 if( 0 == maChartTypeServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ScatterChartType" ) ) )
     875                 :            :                 {
     876                 :          0 :                     bSwitchOffLinesForScatter = true;
     877         [ #  # ]:          0 :                     SchXMLSeries2Context::switchSeriesLinesOff( maSeriesDefaultsAndStyles.maSeriesStyleList );
     878                 :            :                 }
     879                 :            :             }
     880                 :            :         }
     881         [ +  - ]:          6 :         SchXMLSeries2Context::setDefaultsToSeries( maSeriesDefaultsAndStyles );
     882                 :            : 
     883                 :            :         // set autostyles for series and data points
     884                 :          6 :         const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
     885                 :          6 :         const SvXMLStyleContext* pStyle = NULL;
     886                 :          6 :         ::rtl::OUString sCurrStyleName;
     887                 :            : 
     888         [ +  - ]:          6 :         if( pStylesCtxt )
     889                 :            :         {
     890                 :            :             //iterate over data-series first
     891                 :            :             //don't set series styles for donut charts
     892         [ +  - ]:          6 :             if( !bSpecialHandlingForDonutChart )
     893                 :            :             {
     894                 :            :                 SchXMLSeries2Context::setStylesToSeries( maSeriesDefaultsAndStyles
     895         [ +  - ]:          6 :                                                          , pStylesCtxt, pStyle, sCurrStyleName, mrImportHelper, GetImport(), mbIsStockChart, maLSequencesPerIndex );
     896                 :            :                 // ... then set attributes for statistics (after their existence was set in the series)
     897                 :            :                 SchXMLSeries2Context::setStylesToStatisticsObjects( maSeriesDefaultsAndStyles
     898         [ +  - ]:          6 :                             , pStylesCtxt, pStyle, sCurrStyleName );
     899                 :            :             }
     900                 :            :         }
     901                 :            : 
     902                 :            :         //#i98319# call switchRangesFromOuterToInternalIfNecessary before the data point styles are applied, otherwise in copy->paste scenario the data point styles do get lost
     903         [ +  - ]:          6 :         if( bSwitchRangesFromOuterToInternalIfNecessary )
     904                 :            :         {
     905 [ +  - ][ +  - ]:          6 :             if( xNewDoc->hasInternalDataProvider() )
                 [ +  - ]
     906         [ +  - ]:          6 :                 SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary( maTable, maLSequencesPerIndex, xNewDoc, meDataRowSource );
     907                 :            :         }
     908                 :            : 
     909         [ +  - ]:          6 :         if( pStylesCtxt )
     910                 :            :         {
     911                 :            :             // ... then iterate over data-point attributes, so the latter are not overwritten
     912                 :            :             SchXMLSeries2Context::setStylesToDataPoints( maSeriesDefaultsAndStyles
     913         [ +  - ]:          6 :                             , pStylesCtxt, pStyle, sCurrStyleName, mrImportHelper, GetImport(), mbIsStockChart, bSpecialHandlingForDonutChart, bSwitchOffLinesForScatter );
     914                 :          6 :         }
     915                 :            :     }
     916                 :            : 
     917         [ +  - ]:          6 :     if( xProp.is())
     918 [ +  - ][ +  - ]:          6 :         xProp->setPropertyValue( rtl::OUString( "RefreshAddInAllowed" ) , uno::makeAny( sal_True) );
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  + ][ +  - ]
     919                 :            : }
     920                 :            : 
     921                 :          0 : void SchXMLChartContext::MergeSeriesForStockChart()
     922                 :            : {
     923                 :            :     OSL_ASSERT( mbIsStockChart );
     924                 :            :     try
     925                 :            :     {
     926                 :          0 :         uno::Reference< chart::XChartDocument > xOldDoc( mrImportHelper.GetChartDocument());
     927         [ #  # ]:          0 :         uno::Reference< chart2::XChartDocument > xDoc( xOldDoc, uno::UNO_QUERY_THROW );
     928 [ #  # ][ #  # ]:          0 :         uno::Reference< chart2::XDiagram > xDiagram( xDoc->getFirstDiagram());
     929         [ #  # ]:          0 :         if( ! xDiagram.is())
     930                 :          0 :             return;
     931                 :            : 
     932                 :          0 :         bool bHasJapaneseCandlestick = true;
     933                 :          0 :         uno::Reference< chart2::XDataSeriesContainer > xDSContainer;
     934         [ #  # ]:          0 :         uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
     935 [ #  # ][ #  # ]:          0 :         uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
     936         [ #  # ]:          0 :         for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
     937                 :            :         {
     938 [ #  # ][ #  # ]:          0 :             uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
     939 [ #  # ][ #  # ]:          0 :             uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
     940         [ #  # ]:          0 :             for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx )
     941                 :            :             {
     942 [ #  # ][ #  # ]:          0 :                 if( aChartTypes[nCTIdx]->getChartType() == "com.sun.star.chart2.CandleStickChartType" )
         [ #  # ][ #  # ]
     943                 :            :                 {
     944 [ #  # ][ #  # ]:          0 :                     xDSContainer.set( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW );
     945 [ #  # ][ #  # ]:          0 :                     uno::Reference< beans::XPropertySet > xCTProp( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW );
     946 [ #  # ][ #  # ]:          0 :                     xCTProp->getPropertyValue( ::rtl::OUString( "Japanese" )) >>= bHasJapaneseCandlestick;
     947                 :          0 :                     break;
     948                 :            :                 }
     949                 :            :             }
     950         [ #  # ]:          0 :         }
     951                 :            : 
     952         [ #  # ]:          0 :         if( xDSContainer.is())
     953                 :            :         {
     954                 :            :             // with japanese candlesticks: open, low, high, close
     955                 :            :             // otherwise: low, high, close
     956 [ #  # ][ #  # ]:          0 :             uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSContainer->getDataSeries());
     957                 :          0 :             const sal_Int32 nSeriesCount( aSeriesSeq.getLength());
     958         [ #  # ]:          0 :             const sal_Int32 nSeriesPerCandleStick = bHasJapaneseCandlestick ? 4: 3;
     959                 :          0 :             sal_Int32 nCandleStickCount = nSeriesCount / nSeriesPerCandleStick;
     960                 :            :             OSL_ASSERT( nSeriesPerCandleStick * nCandleStickCount == nSeriesCount );
     961         [ #  # ]:          0 :             uno::Sequence< uno::Reference< chart2::XDataSeries > > aNewSeries( nCandleStickCount );
     962         [ #  # ]:          0 :             for( sal_Int32 i=0; i<nCandleStickCount; ++i )
     963                 :            :             {
     964                 :          0 :                 sal_Int32 nSeriesIndex = i*nSeriesPerCandleStick;
     965         [ #  # ]:          0 :                 if( bHasJapaneseCandlestick )
     966                 :            :                 {
     967                 :            :                     // open values
     968 [ #  # ][ #  # ]:          0 :                     lcl_setRoleAtFirstSequence( aSeriesSeq[ nSeriesIndex ], OUString( "values-first" ));
     969 [ #  # ][ #  # ]:          0 :                     aNewSeries[i] = aSeriesSeq[ nSeriesIndex ];
                 [ #  # ]
     970                 :            :                     // low values
     971                 :            :                     lcl_MoveDataToCandleStickSeries(
     972         [ #  # ]:          0 :                         uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
     973 [ #  # ][ #  # ]:          0 :                         aNewSeries[i], OUString( "values-min" ));
                 [ #  # ]
     974                 :            :                 }
     975                 :            :                 else
     976                 :            :                 {
     977                 :            :                     // low values
     978 [ #  # ][ #  # ]:          0 :                     lcl_setRoleAtFirstSequence( aSeriesSeq[ nSeriesIndex ], OUString( "values-min" ));
     979 [ #  # ][ #  # ]:          0 :                     aNewSeries[i] = aSeriesSeq[ nSeriesIndex ];
                 [ #  # ]
     980                 :            :                 }
     981                 :            :                 // high values
     982                 :            :                 lcl_MoveDataToCandleStickSeries(
     983         [ #  # ]:          0 :                     uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
     984 [ #  # ][ #  # ]:          0 :                     aNewSeries[i], OUString( "values-max" ));
                 [ #  # ]
     985                 :            :                 // close values
     986                 :            :                 lcl_MoveDataToCandleStickSeries(
     987         [ #  # ]:          0 :                     uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
     988 [ #  # ][ #  # ]:          0 :                     aNewSeries[i], OUString( "values-last" ));
                 [ #  # ]
     989                 :            :             }
     990 [ #  # ][ #  # ]:          0 :             xDSContainer->setDataSeries( aNewSeries );
         [ #  # ][ #  # ]
     991 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
                 [ #  # ]
     992                 :            :     }
     993                 :          0 :     catch(const uno::Exception&)
     994                 :            :     {
     995                 :            :         OSL_FAIL( "Exception while merging series for stock chart" );
     996                 :            :     }
     997                 :            : }
     998                 :            : 
     999                 :         30 : SvXMLImportContext* SchXMLChartContext::CreateChildContext(
    1000                 :            :     sal_uInt16 nPrefix,
    1001                 :            :     const rtl::OUString& rLocalName,
    1002                 :            :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
    1003                 :            : {
    1004                 :            :     static const sal_Bool bTrue = sal_True;
    1005 [ +  + ][ +  - ]:         30 :     static const uno::Any aTrueBool( &bTrue, ::getBooleanCppuType());
         [ +  - ][ #  # ]
    1006                 :            : 
    1007                 :         30 :     SvXMLImportContext* pContext = 0;
    1008         [ +  - ]:         30 :     const SvXMLTokenMap& rTokenMap = mrImportHelper.GetChartElemTokenMap();
    1009                 :         30 :     uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
    1010         [ +  - ]:         30 :     uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
    1011                 :            : 
    1012 [ +  - ][ +  +  :         30 :     switch( rTokenMap.Get( nPrefix, rLocalName ))
             +  +  +  - ]
    1013                 :            :     {
    1014                 :            :         case XML_TOK_CHART_PLOT_AREA:
    1015                 :          6 :             pContext = new SchXMLPlotAreaContext( mrImportHelper, GetImport(), rLocalName,
    1016                 :            :                                                   m_aXLinkHRefAttributeToIndicateDataProvider,
    1017                 :            :                                                   msCategoriesAddress,
    1018                 :            :                                                   msChartAddress, m_bHasRangeAtPlotArea, mbAllRangeAddressesAvailable,
    1019                 :            :                                                   mbColHasLabels, mbRowHasLabels,
    1020                 :            :                                                   meDataRowSource,
    1021                 :            :                                                   maSeriesDefaultsAndStyles,
    1022                 :            :                                                   maChartTypeServiceName,
    1023 [ +  - ][ +  - ]:          6 :                                                   maLSequencesPerIndex, maChartSize );
    1024                 :          6 :             break;
    1025                 :            : 
    1026                 :            :         case XML_TOK_CHART_TITLE:
    1027         [ +  - ]:          6 :             if( xDoc.is())
    1028                 :            :             {
    1029         [ +  - ]:          6 :                 if( xProp.is())
    1030                 :            :                 {
    1031 [ +  - ][ +  - ]:          6 :                     xProp->setPropertyValue( rtl::OUString( "HasMainTitle" ), aTrueBool );
    1032                 :            :                 }
    1033 [ +  - ][ +  - ]:          6 :                 uno::Reference< drawing::XShape > xTitleShape( xDoc->getTitle(), uno::UNO_QUERY );
                 [ +  - ]
    1034                 :          6 :                 pContext = new SchXMLTitleContext( mrImportHelper, GetImport(),
    1035 [ +  - ][ +  - ]:          6 :                                                    rLocalName, maMainTitle, xTitleShape );
    1036                 :            :             }
    1037                 :          6 :             break;
    1038                 :            : 
    1039                 :            :         case XML_TOK_CHART_SUBTITLE:
    1040         [ +  - ]:          6 :             if( xDoc.is())
    1041                 :            :             {
    1042         [ +  - ]:          6 :                 if( xProp.is())
    1043                 :            :                 {
    1044 [ +  - ][ +  - ]:          6 :                     xProp->setPropertyValue( rtl::OUString( "HasSubTitle" ), aTrueBool );
    1045                 :            :                 }
    1046 [ +  - ][ +  - ]:          6 :                 uno::Reference< drawing::XShape > xTitleShape( xDoc->getSubTitle(), uno::UNO_QUERY );
                 [ +  - ]
    1047                 :          6 :                 pContext = new SchXMLTitleContext( mrImportHelper, GetImport(),
    1048 [ +  - ][ +  - ]:          6 :                                                    rLocalName, maSubTitle, xTitleShape );
    1049                 :            :             }
    1050                 :          6 :             break;
    1051                 :            : 
    1052                 :            :         case XML_TOK_CHART_LEGEND:
    1053 [ +  - ][ +  - ]:          6 :             pContext = new SchXMLLegendContext( mrImportHelper, GetImport(), rLocalName );
    1054                 :          6 :             break;
    1055                 :            : 
    1056                 :            :         case XML_TOK_CHART_TABLE:
    1057                 :            :             {
    1058                 :            :                 SchXMLTableContext * pTableContext =
    1059 [ +  - ][ +  - ]:          6 :                     new SchXMLTableContext( mrImportHelper, GetImport(), rLocalName, maTable );
    1060                 :          6 :                 m_bHasTableElement = true;
    1061                 :            :                 // #i85913# take into account column- and row- mapping for
    1062                 :            :                 // charts with own data only for those which were not copied
    1063                 :            :                 // from a place where they got data from the container.  Note,
    1064                 :            :                 // that this requires the plot-area been read before the table
    1065                 :            :                 // (which is required in the ODF spec)
    1066                 :            :                 // Note: For stock charts and donut charts with special handling
    1067                 :            :                 // the mapping must not be applied!
    1068 [ +  - ][ +  - ]:         12 :                 if( msChartAddress.isEmpty() && !mbIsStockChart &&
         [ +  - ][ +  - ]
    1069                 :            :                     !lcl_SpecialHandlingForDonutChartNeeded(
    1070         [ +  - ]:          6 :                         maChartTypeServiceName, GetImport()))
    1071                 :            :                 {
    1072         [ -  + ]:          6 :                     if( !msColTrans.isEmpty() )
    1073                 :            :                     {
    1074                 :            :                         OSL_ASSERT( msRowTrans.isEmpty() );
    1075 [ #  # ][ #  # ]:          0 :                         pTableContext->setColumnPermutation( lcl_getNumberSequenceFromString( msColTrans, true ));
                 [ #  # ]
    1076                 :          0 :                         msColTrans = OUString();
    1077                 :            :                     }
    1078         [ -  + ]:          6 :                     else if( !msRowTrans.isEmpty() )
    1079                 :            :                     {
    1080 [ #  # ][ #  # ]:          0 :                         pTableContext->setRowPermutation( lcl_getNumberSequenceFromString( msRowTrans, true ));
                 [ #  # ]
    1081                 :          0 :                         msRowTrans = OUString();
    1082                 :            :                     }
    1083                 :            :                 }
    1084                 :          6 :                 pContext = pTableContext;
    1085                 :            :             }
    1086                 :          6 :             break;
    1087                 :            : 
    1088                 :            :         default:
    1089                 :            :             // try importing as an additional shape
    1090         [ #  # ]:          0 :             if( ! mxDrawPage.is())
    1091                 :            :             {
    1092         [ #  # ]:          0 :                 uno::Reference< drawing::XDrawPageSupplier  > xSupp( xDoc, uno::UNO_QUERY );
    1093         [ #  # ]:          0 :                 if( xSupp.is())
    1094 [ #  # ][ #  # ]:          0 :                     mxDrawPage = uno::Reference< drawing::XShapes >( xSupp->getDrawPage(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
    1095                 :            : 
    1096                 :          0 :                 DBG_ASSERT( mxDrawPage.is(), "Invalid Chart Page" );
    1097                 :            :             }
    1098         [ #  # ]:          0 :             if( mxDrawPage.is())
    1099                 :          0 :                 pContext = GetImport().GetShapeImport()->CreateGroupChildContext(
    1100 [ #  # ][ #  # ]:          0 :                     GetImport(), nPrefix, rLocalName, xAttrList, mxDrawPage );
         [ #  # ][ #  # ]
    1101                 :          0 :             break;
    1102                 :            :     }
    1103                 :            : 
    1104         [ -  + ]:         30 :     if( ! pContext )
    1105 [ #  # ][ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
    1106                 :            : 
    1107                 :         30 :     return pContext;
    1108                 :            : }
    1109                 :            : 
    1110                 :            : 
    1111                 :            : /*
    1112                 :            :     With a locked controller the following is done here:
    1113                 :            :         1.  Hide title, subtitle, and legend.
    1114                 :            :         2.  Set the size of the draw page.
    1115                 :            :         3.  Set a (logically) empty data set.
    1116                 :            :         4.  Set the chart type.
    1117                 :            : */
    1118                 :          6 : void SchXMLChartContext::InitChart(
    1119                 :            :     const OUString & rChartTypeServiceName, // currently the old service name
    1120                 :            :     sal_Bool /* bSetSwitchData */ )
    1121                 :            : {
    1122                 :          6 :     uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
    1123                 :            :     DBG_ASSERT( xDoc.is(), "No valid document!" );
    1124         [ +  - ]:          6 :     uno::Reference< frame::XModel > xModel (xDoc, uno::UNO_QUERY );
    1125                 :            : 
    1126                 :            :     // Remove Title and Diagram ("De-InitNew")
    1127         [ +  - ]:          6 :     uno::Reference< chart2::XChartDocument > xNewDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
    1128         [ +  - ]:          6 :     if( xNewDoc.is())
    1129                 :            :     {
    1130 [ +  - ][ +  - ]:          6 :         xNewDoc->setFirstDiagram( 0 );
                 [ +  - ]
    1131         [ +  - ]:          6 :         uno::Reference< chart2::XTitled > xTitled( xNewDoc, uno::UNO_QUERY );
    1132         [ +  - ]:          6 :         if( xTitled.is())
    1133 [ +  - ][ +  - ]:          6 :             xTitled->setTitleObject( 0 );
                 [ +  - ]
    1134                 :            :     }
    1135                 :            : 
    1136                 :            :     //  Set the chart type via setting the diagram.
    1137 [ +  - ][ +  - ]:          6 :     if( !rChartTypeServiceName.isEmpty() && xDoc.is())
                 [ +  - ]
    1138                 :            :     {
    1139         [ +  - ]:          6 :         uno::Reference< lang::XMultiServiceFactory > xFact( xDoc, uno::UNO_QUERY );
    1140         [ +  - ]:          6 :         if( xFact.is())
    1141                 :            :         {
    1142 [ +  - ][ +  - ]:          6 :             uno::Reference< chart::XDiagram > xDia( xFact->createInstance( rChartTypeServiceName ), uno::UNO_QUERY );
                 [ +  - ]
    1143         [ +  - ]:          6 :             if( xDia.is())
    1144 [ +  - ][ +  - ]:          6 :                 xDoc->setDiagram( xDia );
    1145                 :          6 :         }
    1146                 :          6 :     }
    1147                 :          6 : }
    1148                 :            : 
    1149                 :            : // ----------------------------------------
    1150                 :            : 
    1151                 :         12 : SchXMLTitleContext::SchXMLTitleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
    1152                 :            :                                         const rtl::OUString& rLocalName,
    1153                 :            :                                         rtl::OUString& rTitle,
    1154                 :            :                                         uno::Reference< drawing::XShape >& xTitleShape ) :
    1155                 :            :         SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
    1156                 :            :         mrImportHelper( rImpHelper ),
    1157                 :            :         mrTitle( rTitle ),
    1158                 :         12 :         mxTitleShape( xTitleShape )
    1159                 :            : {
    1160                 :         12 : }
    1161                 :            : 
    1162                 :         12 : SchXMLTitleContext::~SchXMLTitleContext()
    1163         [ -  + ]:         24 : {}
    1164                 :            : 
    1165                 :         12 : void SchXMLTitleContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
    1166                 :            : {
    1167 [ +  - ][ +  - ]:         12 :     sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
                 [ +  - ]
    1168                 :            : 
    1169                 :         12 :     com::sun::star::awt::Point maPosition;
    1170                 :         12 :     bool bHasXPosition=false;
    1171                 :         12 :     bool bHasYPosition=false;
    1172                 :            : 
    1173         [ +  + ]:         48 :     for( sal_Int16 i = 0; i < nAttrCount; i++ )
    1174                 :            :     {
    1175 [ +  - ][ +  - ]:         36 :         rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
    1176                 :         36 :         rtl::OUString aLocalName;
    1177 [ +  - ][ +  - ]:         36 :         rtl::OUString aValue = xAttrList->getValueByIndex( i );
    1178         [ +  - ]:         36 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
    1179                 :            : 
    1180         [ +  + ]:         36 :         if( nPrefix == XML_NAMESPACE_SVG )
    1181                 :            :         {
    1182 [ +  - ][ +  + ]:         24 :             if( IsXMLToken( aLocalName, XML_X ) )
    1183                 :            :             {
    1184                 :         12 :                 GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1185         [ +  - ]:         12 :                         maPosition.X, aValue );
    1186                 :         12 :                 bHasXPosition = true;
    1187                 :            :             }
    1188 [ +  - ][ +  - ]:         12 :             else if( IsXMLToken( aLocalName, XML_Y ) )
    1189                 :            :             {
    1190                 :         12 :                 GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1191         [ +  - ]:         12 :                         maPosition.Y, aValue );
    1192                 :         12 :                 bHasYPosition = true;
    1193                 :            :             }
    1194                 :            :         }
    1195         [ +  - ]:         12 :         else if( nPrefix == XML_NAMESPACE_CHART )
    1196                 :            :         {
    1197 [ +  - ][ +  - ]:         12 :             if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
    1198                 :         12 :                 msAutoStyleName = aValue;
    1199                 :            :         }
    1200                 :         36 :     }
    1201                 :            : 
    1202                 :            : 
    1203         [ +  - ]:         12 :     if( mxTitleShape.is())
    1204                 :            :     {
    1205 [ +  - ][ +  - ]:         12 :         if( bHasXPosition && bHasYPosition )
    1206 [ +  - ][ +  - ]:         12 :             mxTitleShape->setPosition( maPosition );
    1207                 :            : 
    1208         [ +  - ]:         12 :         uno::Reference< beans::XPropertySet > xProp( mxTitleShape, uno::UNO_QUERY );
    1209         [ +  - ]:         12 :         if( xProp.is())
    1210                 :            :         {
    1211                 :         12 :             const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
    1212         [ +  - ]:         12 :             if( pStylesCtxt )
    1213                 :            :             {
    1214                 :            :                 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
    1215         [ +  - ]:         12 :                     mrImportHelper.GetChartFamilyID(), msAutoStyleName );
    1216                 :            : 
    1217 [ +  - ][ +  - ]:         12 :                 if( pStyle && pStyle->ISA( XMLPropStyleContext ))
         [ +  - ][ +  - ]
                 [ +  - ]
    1218         [ +  - ]:         12 :                     (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
    1219                 :            :             }
    1220                 :         12 :         }
    1221                 :            :     }
    1222                 :         12 : }
    1223                 :            : 
    1224                 :         12 : SvXMLImportContext* SchXMLTitleContext::CreateChildContext(
    1225                 :            :     sal_uInt16 nPrefix,
    1226                 :            :     const rtl::OUString& rLocalName,
    1227                 :            :     const uno::Reference< xml::sax::XAttributeList >& )
    1228                 :            : {
    1229                 :         12 :     SvXMLImportContext* pContext = 0;
    1230                 :            : 
    1231   [ +  -  +  - ]:         24 :     if( nPrefix == XML_NAMESPACE_TEXT &&
                 [ +  - ]
    1232                 :         12 :         IsXMLToken( rLocalName, XML_P ) )
    1233                 :            :     {
    1234         [ +  - ]:         12 :         pContext = new SchXMLParagraphContext( GetImport(), rLocalName, mrTitle );
    1235                 :            :     }
    1236                 :            :     else
    1237         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
    1238                 :            : 
    1239                 :         12 :     return pContext;
    1240                 :            : }
    1241                 :            : 
    1242                 :            : // ----------------------------------------
    1243                 :            : 
    1244                 :            : 
    1245                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10