LCOV - code coverage report
Current view: top level - xmloff/source/chart - SchXMLPlotAreaContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 268 579 46.3 %
Date: 2012-08-25 Functions: 27 47 57.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 238 1108 21.5 %

           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 <sax/tools/converter.hxx>
      31                 :            : 
      32                 :            : #include "SchXMLPlotAreaContext.hxx"
      33                 :            : #include "SchXMLImport.hxx"
      34                 :            : #include "SchXMLAxisContext.hxx"
      35                 :            : #include "SchXMLSeries2Context.hxx"
      36                 :            : #include "SchXMLTools.hxx"
      37                 :            : #include <tools/debug.hxx>
      38                 :            : 
      39                 :            : #include <comphelper/processfactory.hxx>
      40                 :            : #include "xmloff/xmlnmspe.hxx"
      41                 :            : #include <xmloff/xmlement.hxx>
      42                 :            : #include <xmloff/nmspmap.hxx>
      43                 :            : #include <xmloff/xmluconv.hxx>
      44                 :            : #include <xmloff/prstylei.hxx>
      45                 :            : #include <xmloff/xmlstyle.hxx>
      46                 :            : #include "xexptran.hxx"
      47                 :            : #include <cppuhelper/implbase1.hxx>
      48                 :            : 
      49                 :            : #include <com/sun/star/awt/Point.hpp>
      50                 :            : #include <com/sun/star/awt/Size.hpp>
      51                 :            : 
      52                 :            : #include <com/sun/star/chart/ChartDataRowSource.hpp>
      53                 :            : #include <com/sun/star/chart/ChartErrorCategory.hpp>
      54                 :            : #include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
      55                 :            : #include <com/sun/star/chart/ErrorBarStyle.hpp>
      56                 :            : #include <com/sun/star/chart/X3DDisplay.hpp>
      57                 :            : #include <com/sun/star/chart/XStatisticDisplay.hpp>
      58                 :            : #include <com/sun/star/chart/XDiagramPositioning.hpp>
      59                 :            : 
      60                 :            : #include <com/sun/star/chart2/data/XDataSink.hpp>
      61                 :            : #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
      62                 :            : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
      63                 :            : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
      64                 :            : #include <com/sun/star/chart2/RelativePosition.hpp>
      65                 :            : 
      66                 :            : #include <com/sun/star/drawing/CameraGeometry.hpp>
      67                 :            : #include <com/sun/star/drawing/FillStyle.hpp>
      68                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      69                 :            : #include <com/sun/star/util/XStringMapping.hpp>
      70                 :            : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      71                 :            : 
      72                 :            : using namespace com::sun::star;
      73                 :            : using namespace ::xmloff::token;
      74                 :            : 
      75                 :            : using ::rtl::OUString;
      76                 :            : using com::sun::star::uno::Reference;
      77                 :            : 
      78                 :            : namespace
      79                 :            : {
      80                 :            : 
      81                 :            : struct lcl_AxisHasCategories : public ::std::unary_function< SchXMLAxis, bool >
      82                 :            : {
      83                 :         12 :     bool operator() ( const SchXMLAxis & rAxis )
      84                 :            :     {
      85                 :         12 :         return rAxis.bHasCategories;
      86                 :            :     }
      87                 :            : };
      88                 :            : 
      89                 :          0 : OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
      90                 :            : {
      91                 :          0 :     OUString aResult = rRange;
      92         [ #  # ]:          0 :     if(!xDoc.is())
      93                 :            :         return aResult;
      94                 :            :     uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
      95 [ #  # ][ #  # ]:          0 :         xDoc->getDataProvider(), uno::UNO_QUERY );
                 [ #  # ]
      96         [ #  # ]:          0 :     if( xConversion.is())
      97 [ #  # ][ #  # ]:          0 :         aResult = xConversion->convertRangeFromXML( rRange );
      98                 :          0 :     return aResult;
      99                 :            : }
     100                 :            : 
     101                 :            : } // anonymous namespace
     102                 :            : 
     103                 :          6 : SchXML3DSceneAttributesHelper::SchXML3DSceneAttributesHelper( SvXMLImport& rImporter )
     104                 :          6 :     : SdXML3DSceneAttributesHelper( rImporter )
     105                 :            : {
     106                 :          6 : }
     107                 :            : 
     108                 :          6 : void SchXML3DSceneAttributesHelper::getCameraDefaultFromDiagram( const uno::Reference< chart::XDiagram >& xDiagram )
     109                 :            : {
     110                 :            :     //different defaults for camera geometry necessary to workaround wrong behaviour in old chart
     111                 :            :     //in future make this version dependent if we have versioning (metastream) for ole objects
     112                 :            : 
     113                 :            :     try
     114                 :            :     {
     115         [ +  - ]:          6 :         uno::Reference< beans::XPropertySet > xProp( xDiagram, uno::UNO_QUERY );
     116         [ +  - ]:          6 :         if( xProp.is() )
     117                 :            :         {
     118                 :          6 :             drawing::CameraGeometry aCamGeo;
     119 [ +  - ][ +  - ]:          6 :             xProp->getPropertyValue( ::rtl::OUString( "D3DCameraGeometry" )) >>= aCamGeo;
                 [ +  - ]
     120                 :          6 :             maVRP.setX( aCamGeo.vrp.PositionX );
     121                 :          6 :             maVRP.setY( aCamGeo.vrp.PositionY );
     122                 :          6 :             maVRP.setZ( aCamGeo.vrp.PositionZ );
     123                 :          6 :             maVPN.setX( aCamGeo.vpn.DirectionX );
     124                 :          6 :             maVPN.setY( aCamGeo.vpn.DirectionY );
     125                 :          6 :             maVPN.setZ( aCamGeo.vpn.DirectionZ );
     126                 :          6 :             maVUP.setX( aCamGeo.vup.DirectionX );
     127                 :          6 :             maVUP.setY( aCamGeo.vup.DirectionY );
     128                 :          6 :             maVUP.setZ( aCamGeo.vup.DirectionZ );
     129         [ #  # ]:          6 :         }
     130                 :            :     }
     131                 :          0 :     catch( const uno::Exception & rEx )
     132                 :            :     {
     133                 :            : #ifdef DBG_UTIL
     134                 :            :         rtl::OString aBStr(rtl::OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
     135                 :            :         OSL_TRACE( "Exception caught for property NumberOfLines: %s", aBStr.getStr());
     136                 :            : #else
     137                 :            :         (void)rEx; // avoid warning for pro build
     138                 :            : #endif
     139                 :            :     }
     140                 :          6 : }
     141                 :            : 
     142                 :          6 : SchXML3DSceneAttributesHelper::~SchXML3DSceneAttributesHelper()
     143                 :            : {
     144         [ -  + ]:          6 : }
     145                 :            : 
     146                 :          6 : SchXMLPlotAreaContext::SchXMLPlotAreaContext(
     147                 :            :     SchXMLImportHelper& rImpHelper,
     148                 :            :     SvXMLImport& rImport, const rtl::OUString& rLocalName,
     149                 :            :     const rtl::OUString& rXLinkHRefAttributeToIndicateDataProvider,
     150                 :            :     ::rtl::OUString& rCategoriesAddress,
     151                 :            :     ::rtl::OUString& rChartAddress,
     152                 :            :     bool& rbHasRangeAtPlotArea,
     153                 :            :     sal_Bool & rAllRangeAddressesAvailable,
     154                 :            :     sal_Bool & rColHasLabels,
     155                 :            :     sal_Bool & rRowHasLabels,
     156                 :            :     chart::ChartDataRowSource & rDataRowSource,
     157                 :            :     SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles,
     158                 :            :     const ::rtl::OUString& aChartTypeServiceName,
     159                 :            :     tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
     160                 :            :     const awt::Size & rChartSize ) :
     161                 :            :         SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
     162                 :            :         mrImportHelper( rImpHelper ),
     163                 :            :         mrCategoriesAddress( rCategoriesAddress ),
     164                 :            :         mrSeriesDefaultsAndStyles( rSeriesDefaultsAndStyles ),
     165                 :            :         mnNumOfLinesProp( 0 ),
     166                 :            :         mbStockHasVolume( sal_False ),
     167                 :            :         mnSeries( 0 ),
     168                 :            :         m_aGlobalSeriesImportInfo( rAllRangeAddressesAvailable ),
     169                 :            :         maSceneImportHelper( rImport ),
     170                 :            :         m_aOuterPositioning( rImport ),
     171                 :            :         m_aInnerPositioning( rImport ),
     172                 :            :         mbPercentStacked(false),
     173                 :            :         m_bAxisPositionAttributeImported(false),
     174                 :            :         m_rXLinkHRefAttributeToIndicateDataProvider(rXLinkHRefAttributeToIndicateDataProvider),
     175                 :            :         mrChartAddress( rChartAddress ),
     176                 :            :         m_rbHasRangeAtPlotArea( rbHasRangeAtPlotArea ),
     177                 :            :         mrColHasLabels( rColHasLabels ),
     178                 :            :         mrRowHasLabels( rRowHasLabels ),
     179                 :            :         mrDataRowSource( rDataRowSource ),
     180                 :            :         maChartTypeServiceName( aChartTypeServiceName ),
     181                 :            :         mrLSequencesPerIndex( rLSequencesPerIndex ),
     182                 :            :         mbGlobalChartTypeUsedBySeries( false ),
     183 [ +  - ][ +  - ]:          6 :         maChartSize( rChartSize )
     184                 :            : {
     185                 :          6 :     m_rbHasRangeAtPlotArea = false;
     186                 :            : 
     187                 :            :     // get Diagram
     188         [ +  - ]:          6 :     uno::Reference< chart::XChartDocument > xDoc( rImpHelper.GetChartDocument(), uno::UNO_QUERY );
     189         [ +  - ]:          6 :     if( xDoc.is())
     190                 :            :     {
     191 [ +  - ][ +  - ]:          6 :         mxDiagram = xDoc->getDiagram();
                 [ +  - ]
     192         [ +  - ]:          6 :         mxNewDoc.set( xDoc, uno::UNO_QUERY );
     193                 :            : 
     194         [ +  - ]:          6 :         maSceneImportHelper.getCameraDefaultFromDiagram( mxDiagram );
     195                 :            :     }
     196                 :            :     DBG_ASSERT( mxDiagram.is(), "Couldn't get XDiagram" );
     197                 :            : 
     198                 :            :     // turn off all axes initially
     199                 :          6 :     uno::Any aFalseBool;
     200         [ +  - ]:          6 :     aFalseBool <<= (sal_Bool)(sal_False);
     201                 :            : 
     202         [ +  - ]:          6 :     uno::Reference< lang::XServiceInfo > xInfo( mxDiagram, uno::UNO_QUERY );
     203         [ +  - ]:          6 :     uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
     204   [ +  -  +  - ]:         12 :     if( xInfo.is() &&
                 [ +  - ]
     205                 :          6 :         xProp.is())
     206                 :            :     {
     207                 :            :         try
     208                 :            :         {
     209         [ +  - ]:          6 :             xProp->setPropertyValue(
     210         [ +  - ]:          6 :                     rtl::OUString( "HasXAxis" ), aFalseBool );
     211         [ +  - ]:          6 :             xProp->setPropertyValue(
     212         [ +  - ]:          6 :                     rtl::OUString( "HasXAxisGrid" ), aFalseBool );
     213         [ +  - ]:          6 :             xProp->setPropertyValue(
     214         [ +  - ]:          6 :                     rtl::OUString( "HasXAxisDescription" ), aFalseBool );
     215         [ +  - ]:          6 :             xProp->setPropertyValue(
     216         [ +  - ]:          6 :                     rtl::OUString( "HasSecondaryXAxis" ), aFalseBool );
     217         [ +  - ]:          6 :             xProp->setPropertyValue(
     218         [ +  - ]:          6 :                     rtl::OUString( "HasSecondaryXAxisDescription" ), aFalseBool );
     219                 :            : 
     220         [ +  - ]:          6 :             xProp->setPropertyValue(
     221         [ +  - ]:          6 :                     rtl::OUString( "HasYAxis" ), aFalseBool );
     222         [ +  - ]:          6 :             xProp->setPropertyValue(
     223         [ +  - ]:          6 :                     rtl::OUString( "HasYAxisGrid" ), aFalseBool );
     224         [ +  - ]:          6 :             xProp->setPropertyValue(
     225         [ +  - ]:          6 :                     rtl::OUString( "HasYAxisDescription" ), aFalseBool );
     226         [ +  - ]:          6 :             xProp->setPropertyValue(
     227         [ +  - ]:          6 :                     rtl::OUString( "HasSecondaryYAxis" ), aFalseBool );
     228         [ +  - ]:          6 :             xProp->setPropertyValue(
     229         [ +  - ]:          6 :                     rtl::OUString( "HasSecondaryYAxisDescription" ), aFalseBool );
     230                 :            : 
     231         [ +  - ]:          6 :             xProp->setPropertyValue(
     232         [ +  - ]:          6 :                     rtl::OUString( "HasZAxis" ), aFalseBool );
     233         [ +  - ]:          6 :             xProp->setPropertyValue(
     234         [ +  - ]:          6 :                     rtl::OUString( "HasZAxisDescription" ), aFalseBool );
     235                 :            : 
     236                 :          6 :             uno::Any aAny;
     237                 :          6 :             chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS;
     238         [ +  - ]:          6 :             aAny <<= eSource;
     239 [ +  - ][ +  - ]:          6 :             xProp->setPropertyValue( rtl::OUString( "DataRowSource" ), aAny );
                 [ #  # ]
     240                 :            :         }
     241         [ #  # ]:          0 :         catch( const beans::UnknownPropertyException & )
     242                 :            :         {
     243                 :            :             OSL_FAIL( "Property required by service not supported" );
     244                 :            :         }
     245                 :          6 :     }
     246                 :          6 : }
     247                 :            : 
     248         [ +  - ]:          6 : SchXMLPlotAreaContext::~SchXMLPlotAreaContext()
     249         [ -  + ]:         12 : {}
     250                 :            : 
     251                 :          6 : void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     252                 :            : {
     253                 :            :     // parse attributes
     254 [ +  - ][ +  - ]:          6 :     sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
                 [ +  - ]
     255         [ +  - ]:          6 :     const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetPlotAreaAttrTokenMap();
     256         [ +  - ]:          6 :     uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
     257                 :            : 
     258         [ +  + ]:         36 :     for( sal_Int16 i = 0; i < nAttrCount; i++ )
     259                 :            :     {
     260 [ +  - ][ +  - ]:         30 :         rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
     261                 :         30 :         rtl::OUString aLocalName;
     262 [ +  - ][ +  - ]:         30 :         rtl::OUString aValue = xAttrList->getValueByIndex( i );
     263         [ +  - ]:         30 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     264                 :            : 
     265 [ +  - ][ +  +  :         30 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
             -  -  -  - ]
     266                 :            :         {
     267                 :            :             case XML_TOK_PA_X:
     268                 :            :             case XML_TOK_PA_Y:
     269                 :            :             case XML_TOK_PA_WIDTH:
     270                 :            :             case XML_TOK_PA_HEIGHT:
     271         [ +  - ]:         24 :                 m_aOuterPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
     272                 :         24 :                 break;
     273                 :            :             case XML_TOK_PA_STYLE_NAME:
     274                 :          6 :                 msAutoStyleName = aValue;
     275                 :          6 :                 break;
     276                 :            :             case XML_TOK_PA_CHART_ADDRESS:
     277         [ #  # ]:          0 :                 mrChartAddress = lcl_ConvertRange( aValue, xNewDoc );
     278                 :            :                 // indicator for getting data from the outside
     279                 :          0 :                 m_rbHasRangeAtPlotArea = true;
     280                 :          0 :                 break;
     281                 :            :             case XML_TOK_PA_DS_HAS_LABELS:
     282                 :            :                 {
     283 [ #  # ][ #  # ]:          0 :                     if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_BOTH )))
     284                 :          0 :                         mrColHasLabels = mrRowHasLabels = sal_True;
     285 [ #  # ][ #  # ]:          0 :                     else if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_ROW )))
     286                 :          0 :                         mrRowHasLabels = sal_True;
     287 [ #  # ][ #  # ]:          0 :                     else if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_COLUMN )))
     288                 :          0 :                         mrColHasLabels = sal_True;
     289                 :            :                 }
     290                 :          0 :                 break;
     291                 :            :             case XML_TOK_PA_TRANSFORM:
     292                 :            :             case XML_TOK_PA_VRP:
     293                 :            :             case XML_TOK_PA_VPN:
     294                 :            :             case XML_TOK_PA_VUP:
     295                 :            :             case XML_TOK_PA_PROJECTION:
     296                 :            :             case XML_TOK_PA_DISTANCE:
     297                 :            :             case XML_TOK_PA_FOCAL_LENGTH:
     298                 :            :             case XML_TOK_PA_SHADOW_SLANT:
     299                 :            :             case XML_TOK_PA_SHADE_MODE:
     300                 :            :             case XML_TOK_PA_AMBIENT_COLOR:
     301                 :            :             case XML_TOK_PA_LIGHTING_MODE:
     302         [ #  # ]:          0 :                 maSceneImportHelper.processSceneAttribute( nPrefix, aLocalName, aValue );
     303                 :          0 :                 break;
     304                 :            :         }
     305                 :         30 :     }
     306                 :            : 
     307         [ -  + ]:          6 :     if( ! mxNewDoc.is())
     308                 :            :     {
     309         [ #  # ]:          0 :         uno::Reference< beans::XPropertySet > xDocProp( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
     310         [ #  # ]:          0 :         if( xDocProp.is())
     311                 :            :         {
     312                 :            :             try
     313                 :            :             {
     314                 :          0 :                 uno::Any aAny;
     315         [ #  # ]:          0 :                 aAny <<= (sal_Bool)(mrColHasLabels);
     316         [ #  # ]:          0 :                 xDocProp->setPropertyValue(
     317                 :            :                     ::rtl::OUString( "DataSourceLabelsInFirstColumn" ),
     318         [ #  # ]:          0 :                     aAny );
     319                 :            : 
     320         [ #  # ]:          0 :                 aAny <<= (sal_Bool)(mrRowHasLabels);
     321         [ #  # ]:          0 :                 xDocProp->setPropertyValue(
     322                 :            :                     ::rtl::OUString( "DataSourceLabelsInFirstRow" ),
     323 [ #  # ][ #  # ]:          0 :                     aAny );
     324                 :            :             }
     325         [ #  # ]:          0 :             catch( const beans::UnknownPropertyException & )
     326                 :            :             {
     327                 :            :                 SAL_WARN( "xmloff.chart", "Properties missing" );
     328                 :            :             }
     329                 :          0 :         }
     330                 :            :     }
     331                 :            : 
     332                 :            :     // set properties
     333         [ +  - ]:          6 :     uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
     334         [ +  - ]:          6 :     if( !msAutoStyleName.isEmpty())
     335                 :            :     {
     336         [ +  - ]:          6 :         if( xProp.is())
     337                 :            :         {
     338                 :          6 :             const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
     339         [ +  - ]:          6 :             if( pStylesCtxt )
     340                 :            :             {
     341                 :            :                 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
     342         [ +  - ]:          6 :                     mrImportHelper.GetChartFamilyID(), msAutoStyleName );
     343                 :            : 
     344                 :            :                 XMLPropStyleContext* pPropStyleContext =
     345                 :            :                     const_cast< XMLPropStyleContext * >(
     346         [ -  + ]:          6 :                         dynamic_cast< const XMLPropStyleContext * >( pStyle ) );
     347         [ +  - ]:          6 :                 if( pPropStyleContext )
     348                 :            :                 {
     349         [ +  - ]:          6 :                     pPropStyleContext->FillPropertySet( xProp );
     350                 :            : 
     351                 :            :                     // get the data row source that was set without having data
     352         [ +  - ]:          6 :                     xProp->getPropertyValue( ::rtl::OUString( "DataRowSource" ))
     353 [ +  - ][ +  - ]:          6 :                         >>= mrDataRowSource;
     354                 :            : 
     355                 :            :                     //lines on/off
     356                 :            :                     //this old property is not supported fully anymore with the new chart, so we need to get the information a little bit different from similar properties
     357                 :            :                     mrSeriesDefaultsAndStyles.maLinesOnProperty = SchXMLTools::getPropertyFromContext(
     358         [ +  - ]:          6 :                         ::rtl::OUString("Lines"), pPropStyleContext, pStylesCtxt );
     359                 :            : 
     360                 :            :                     //handle automatic position and size
     361         [ +  - ]:          6 :                     m_aOuterPositioning.readAutomaticPositioningProperties( pPropStyleContext, pStylesCtxt );
     362                 :            : 
     363                 :            :                     //correct default starting angle for old 3D pies
     364 [ +  - ][ -  + ]:          6 :                     if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_0( GetImport().GetModel() ) )
     365                 :            :                     {
     366                 :          0 :                         bool bIs3d = false;
     367 [ #  # ][ #  # ]:          0 :                         if( xProp.is() && ( xProp->getPropertyValue(::rtl::OUString("Dim3D")) >>= bIs3d ) &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
             #  #  #  # ]
     368                 :            :                             bIs3d )
     369                 :            :                         {
     370 [ #  # ][ #  # ]:          0 :                             if( maChartTypeServiceName == "com.sun.star.chart2.PieChartType" || maChartTypeServiceName == "com.sun.star.chart2.DonutChartType" )
                 [ #  # ]
     371                 :            :                             {
     372                 :          0 :                                 ::rtl::OUString aPropName( ::rtl::OUString("StartingAngle") );
     373         [ #  # ]:          0 :                                 uno::Any aAStartingAngle( SchXMLTools::getPropertyFromContext( aPropName, pPropStyleContext, pStylesCtxt ) );
     374         [ #  # ]:          0 :                                 if( !aAStartingAngle.hasValue() )
     375 [ #  # ][ #  # ]:          0 :                                     xProp->setPropertyValue( aPropName, uno::makeAny(sal_Int32(0)) ) ;
                 [ #  # ]
     376                 :            :                             }
     377                 :            :                         }
     378                 :            :                     }
     379                 :            :                 }
     380                 :            :             }
     381                 :            :         }
     382                 :            :     }
     383                 :            : 
     384                 :            :     //remember default values for dataseries
     385         [ +  - ]:          6 :     if(xProp.is())
     386                 :            :     try
     387                 :            :     {
     388 [ +  - ][ +  - ]:          6 :         mrSeriesDefaultsAndStyles.maSymbolTypeDefault = xProp->getPropertyValue(::rtl::OUString("SymbolType"));
     389 [ +  - ][ +  - ]:          6 :         mrSeriesDefaultsAndStyles.maDataCaptionDefault = xProp->getPropertyValue(::rtl::OUString("DataCaption"));
     390                 :            : 
     391 [ +  - ][ +  - ]:          6 :         mrSeriesDefaultsAndStyles.maMeanValueDefault = xProp->getPropertyValue(::rtl::OUString("MeanValue"));
     392 [ +  - ][ +  - ]:          6 :         mrSeriesDefaultsAndStyles.maRegressionCurvesDefault = xProp->getPropertyValue(::rtl::OUString("RegressionCurves"));
     393                 :            : 
     394                 :          6 :         bool bStacked = false;
     395 [ +  - ][ +  - ]:          6 :         mrSeriesDefaultsAndStyles.maStackedDefault = xProp->getPropertyValue(::rtl::OUString("Stacked"));
     396                 :          6 :         mrSeriesDefaultsAndStyles.maStackedDefault >>= bStacked;
     397 [ +  - ][ +  - ]:          6 :         mrSeriesDefaultsAndStyles.maPercentDefault = xProp->getPropertyValue(::rtl::OUString("Percent"));
     398                 :          6 :         mrSeriesDefaultsAndStyles.maPercentDefault >>= mbPercentStacked;
     399 [ +  - ][ +  - ]:          6 :         mrSeriesDefaultsAndStyles.maStackedBarsConnectedDefault = xProp->getPropertyValue(::rtl::OUString("StackedBarsConnected"));
     400                 :            : 
     401                 :            :         // deep
     402 [ +  - ][ +  - ]:          6 :         uno::Any aDeepProperty( xProp->getPropertyValue(::rtl::OUString("Deep")));
     403                 :            :         // #124488# old versions store a 3d area and 3D line deep chart with Deep==false => workaround for this
     404 [ +  - ][ +  - ]:          6 :         if( ! (bStacked || mbPercentStacked ))
     405                 :            :         {
     406 [ +  - ][ -  + ]:          6 :             if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
     407                 :            :             {
     408                 :          0 :                 bool bIs3d = false;
     409 [ #  # ][ #  # ]:          0 :                 if( ( xProp->getPropertyValue(::rtl::OUString("Dim3D")) >>= bIs3d ) &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                      # ]
     410                 :            :                     bIs3d )
     411                 :            :                 {
     412 [ #  # ][ #  # ]:          0 :                     if( maChartTypeServiceName == "com.sun.star.chart2.AreaChartType" || maChartTypeServiceName == "com.sun.star.chart2.LineChartType" )
                 [ #  # ]
     413                 :            :                     {
     414 [ #  # ][ #  # ]:          0 :                         aDeepProperty <<= uno::makeAny( true );
     415                 :            :                     }
     416                 :            :                 }
     417                 :            :             }
     418                 :            :         }
     419                 :          6 :         mrSeriesDefaultsAndStyles.maDeepDefault = aDeepProperty;
     420                 :            : 
     421 [ +  - ][ +  - ]:          6 :         xProp->getPropertyValue(::rtl::OUString("NumberOfLines")) >>= mnNumOfLinesProp;
     422 [ +  - ][ #  # ]:          6 :         xProp->getPropertyValue(::rtl::OUString("Volume")) >>= mbStockHasVolume;
                 [ +  - ]
     423                 :            :     }
     424         [ #  # ]:          0 :     catch( const uno::Exception & rEx )
     425                 :            :     {
     426                 :            : #ifdef DBG_UTIL
     427                 :            :         rtl::OString aBStr(rtl::OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
     428                 :            :         OSL_TRACE("PlotAreaContext:EndElement(): Exception caught: %s", aBStr.getStr());
     429                 :            : #else
     430                 :            :         (void)rEx; // avoid warning for pro build
     431                 :            : #endif
     432                 :            :     }
     433                 :            :     //
     434                 :            : 
     435                 :          6 :     bool bCreateInternalDataProvider = false;
     436         [ -  + ]:          6 :     if( m_rXLinkHRefAttributeToIndicateDataProvider == "." ) //data comes from the chart itself
     437                 :          0 :         bCreateInternalDataProvider = true;
     438         [ -  + ]:          6 :     else if( m_rXLinkHRefAttributeToIndicateDataProvider == ".." ) //data comes from the parent application
     439                 :          0 :         bCreateInternalDataProvider = false;
     440         [ -  + ]:          6 :     else if( !m_rXLinkHRefAttributeToIndicateDataProvider.isEmpty() ) //not supported so far to get the data by sibling objects -> fall back to chart itself
     441                 :          0 :         bCreateInternalDataProvider = true;
     442         [ +  - ]:          6 :     else if( !m_rbHasRangeAtPlotArea )
     443                 :          6 :         bCreateInternalDataProvider = true;
     444                 :            : 
     445 [ +  - ][ +  - ]:          6 :     if( bCreateInternalDataProvider && mxNewDoc.is() )
                 [ +  - ]
     446                 :            :     {
     447                 :            :         // we have no complete range => we have own data, so switch the data
     448                 :            :         // provider to internal. Clone is not necessary, as we don't have any
     449                 :            :         // data yet.
     450 [ +  - ][ +  - ]:          6 :         mxNewDoc->createInternalDataProvider( false /* bCloneExistingData */ );
     451 [ +  - ][ -  + ]:          6 :         if( xProp.is() && mrDataRowSource!=chart::ChartDataRowSource_COLUMNS )
                 [ -  + ]
     452 [ #  # ][ #  # ]:          0 :             xProp->setPropertyValue( rtl::OUString( "DataRowSource" ), uno::makeAny(mrDataRowSource) );
                 [ #  # ]
     453                 :          6 :     }
     454                 :          6 : }
     455                 :            : 
     456                 :         42 : SvXMLImportContext* SchXMLPlotAreaContext::CreateChildContext(
     457                 :            :     sal_uInt16 nPrefix,
     458                 :            :     const rtl::OUString& rLocalName,
     459                 :            :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     460                 :            : {
     461                 :         42 :     SvXMLImportContext* pContext = 0;
     462                 :         42 :     const SvXMLTokenMap& rTokenMap = mrImportHelper.GetPlotAreaElemTokenMap();
     463                 :            : 
     464   [ -  +  +  +  :         42 :     switch( rTokenMap.Get( nPrefix, rLocalName ))
          +  -  -  -  -  
                      - ]
     465                 :            :     {
     466                 :            :         case XML_TOK_PA_COORDINATE_REGION_EXT:
     467                 :            :         case XML_TOK_PA_COORDINATE_REGION:
     468                 :            :         {
     469         [ #  # ]:          0 :             pContext = new SchXMLCoordinateRegionContext( GetImport(), nPrefix, rLocalName, m_aInnerPositioning );
     470                 :            :         }
     471                 :          0 :         break;
     472                 :            : 
     473                 :            :         case XML_TOK_PA_AXIS:
     474                 :            :         {
     475                 :         12 :             bool bAddMissingXAxisForNetCharts = false;
     476                 :         12 :             bool bAdaptWrongPercentScaleValues = false;
     477         [ -  + ]:         12 :             if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
     478                 :            :             {
     479                 :            :                 //correct errors from older versions
     480                 :            : 
     481                 :            :                 // for NetCharts there were no xAxis exported to older files
     482                 :            :                 // so we need to add the x axis here for those old NetChart files
     483         [ #  # ]:          0 :                 if ( maChartTypeServiceName == "com.sun.star.chart2.NetChartType" )
     484                 :          0 :                     bAddMissingXAxisForNetCharts = true;
     485                 :            : 
     486                 :            :                 //Issue 59288
     487         [ #  # ]:          0 :                 if( mbPercentStacked )
     488                 :          0 :                     bAdaptWrongPercentScaleValues = true;
     489                 :            :             }
     490                 :            : 
     491                 :         12 :             bool bAdaptXAxisOrientationForOld2DBarCharts = false;
     492         [ -  + ]:         12 :             if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_4( GetImport().GetModel() ) )
     493                 :            :             {
     494                 :            :                 //issue74660
     495         [ #  # ]:          0 :                 if ( maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
     496                 :          0 :                     bAdaptXAxisOrientationForOld2DBarCharts = true;
     497                 :            :             }
     498                 :            : 
     499                 :         12 :             pContext = new SchXMLAxisContext( mrImportHelper, GetImport(), rLocalName, mxDiagram, maAxes, mrCategoriesAddress,
     500 [ +  - ][ +  - ]:         12 :                                               bAddMissingXAxisForNetCharts, bAdaptWrongPercentScaleValues, bAdaptXAxisOrientationForOld2DBarCharts, m_bAxisPositionAttributeImported );
     501                 :            :         }
     502                 :         12 :         break;
     503                 :            : 
     504                 :            :         case XML_TOK_PA_SERIES:
     505                 :            :             {
     506         [ +  - ]:         18 :                 if( mxNewDoc.is())
     507                 :            :                 {
     508                 :            :                     pContext = new SchXMLSeries2Context(
     509                 :         18 :                         mrImportHelper, GetImport(), rLocalName,
     510                 :            :                         mxNewDoc, maAxes,
     511                 :            :                         mrSeriesDefaultsAndStyles.maSeriesStyleList,
     512                 :            :                         mnSeries,
     513                 :            :                         mbStockHasVolume,
     514                 :            :                         m_aGlobalSeriesImportInfo,
     515                 :            :                         maChartTypeServiceName,
     516                 :            :                         mrLSequencesPerIndex,
     517         [ +  - ]:         18 :                         mbGlobalChartTypeUsedBySeries, maChartSize );
     518                 :            :                 }
     519                 :         18 :                 mnSeries++;
     520                 :            :             }
     521                 :         18 :             break;
     522                 :            : 
     523                 :            :         case XML_TOK_PA_WALL:
     524                 :          6 :             pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
     525         [ +  - ]:          6 :                                                    SchXMLWallFloorContext::CONTEXT_TYPE_WALL );
     526                 :          6 :             break;
     527                 :            :         case XML_TOK_PA_FLOOR:
     528                 :          6 :             pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
     529         [ +  - ]:          6 :                                                    SchXMLWallFloorContext::CONTEXT_TYPE_FLOOR );
     530                 :          6 :             break;
     531                 :            : 
     532                 :            :         case XML_TOK_PA_LIGHT_SOURCE:
     533                 :          0 :             pContext = maSceneImportHelper.create3DLightContext( nPrefix, rLocalName, xAttrList );
     534                 :          0 :             break;
     535                 :            : 
     536                 :            :         // elements for stock charts
     537                 :            :         case XML_TOK_PA_STOCK_GAIN:
     538                 :          0 :             pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
     539         [ #  # ]:          0 :                                                SchXMLStockContext::CONTEXT_TYPE_GAIN );
     540                 :          0 :             break;
     541                 :            :         case XML_TOK_PA_STOCK_LOSS:
     542                 :          0 :             pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
     543         [ #  # ]:          0 :                                                SchXMLStockContext::CONTEXT_TYPE_LOSS );
     544                 :          0 :             break;
     545                 :            :         case XML_TOK_PA_STOCK_RANGE:
     546                 :          0 :             pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
     547         [ #  # ]:          0 :                                                SchXMLStockContext::CONTEXT_TYPE_RANGE );
     548                 :          0 :             break;
     549                 :            : 
     550                 :            :         default:
     551         [ #  # ]:          0 :             pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     552                 :            :     }
     553                 :            : 
     554                 :         42 :     return pContext;
     555                 :            : }
     556                 :            : 
     557                 :          6 : void SchXMLPlotAreaContext::EndElement()
     558                 :            : {
     559                 :            :     // set categories
     560 [ +  - ][ +  - ]:          6 :     if( !mrCategoriesAddress.isEmpty() && mxNewDoc.is())
                 [ +  - ]
     561                 :            :     {
     562                 :            :         uno::Reference< chart2::data::XDataProvider > xDataProvider(
     563 [ +  - ][ +  - ]:          6 :             mxNewDoc->getDataProvider()  );
     564                 :            :         // @todo: correct coordinate system index
     565                 :          6 :         sal_Int32 nDimension( 0 );
     566                 :            :         ::std::vector< SchXMLAxis >::const_iterator aIt(
     567 [ +  - ][ +  - ]:          6 :             ::std::find_if( maAxes.begin(), maAxes.end(), lcl_AxisHasCategories()));
     568 [ +  - ][ -  + ]:          6 :         if( aIt != maAxes.end())
     569                 :          0 :             nDimension = static_cast< sal_Int32 >( (*aIt).eDimension );
     570                 :            :         SchXMLTools::CreateCategories(
     571                 :            :             xDataProvider, mxNewDoc, mrCategoriesAddress,
     572                 :            :             0 /* nCooSysIndex */,
     573         [ +  - ]:          6 :             nDimension, &mrLSequencesPerIndex );
     574                 :            :     }
     575                 :            : 
     576         [ +  - ]:          6 :     uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY );
     577         [ +  - ]:          6 :     if( xDiaProp.is())
     578                 :            :     {
     579                 :          6 :         sal_Bool bIsThreeDim = sal_False;
     580 [ +  - ][ +  - ]:          6 :         uno::Any aAny = xDiaProp->getPropertyValue( ::rtl::OUString( "Dim3D" ));
     581                 :          6 :         aAny >>= bIsThreeDim;
     582                 :            : 
     583                 :            :         // set 3d scene attributes
     584         [ -  + ]:          6 :         if( bIsThreeDim )
     585                 :            :         {
     586                 :            :             // set scene attributes at diagram
     587         [ #  # ]:          0 :             maSceneImportHelper.setSceneAttributes( xDiaProp );
     588                 :            :         }
     589                 :            : 
     590                 :            :         // set correct number of lines at series
     591 [ -  + ][ #  # ]:          6 :         if( ! m_aGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && mnNumOfLinesProp > 0 && maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
         [ #  # ][ -  + ]
     592                 :            :         {
     593                 :            :             try
     594                 :            :             {
     595         [ #  # ]:          0 :                 xDiaProp->setPropertyValue( ::rtl::OUString(  "NumberOfLines" ),
     596 [ #  # ][ #  # ]:          0 :                                             uno::makeAny( mnNumOfLinesProp ));
                 [ #  # ]
     597                 :            :             }
     598         [ #  # ]:          0 :             catch( const uno::Exception & rEx )
     599                 :            :             {
     600                 :            : #ifdef DBG_UTIL
     601                 :            :                 rtl::OString aBStr(rtl::OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
     602                 :            :                 OSL_TRACE( "Exception caught for property NumberOfLines: %s", aBStr.getStr());
     603                 :            : #else
     604                 :            :                 (void)rEx; // avoid warning for pro build
     605                 :            : #endif
     606                 :            :             }
     607                 :            :         }
     608                 :            : 
     609                 :            :         // #i32366# stock has volume
     610   [ +  -  -  + ]:         18 :         if( ( 0 == mxDiagram->getDiagramType().reverseCompareToAsciiL(
         [ #  # ][ -  + ]
     611 [ +  - ][ +  - ]:         12 :                   RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.StockDiagram" ))) &&
                 [ #  # ]
     612                 :            :             mbStockHasVolume )
     613                 :            :         {
     614                 :            :             try
     615                 :            :             {
     616         [ #  # ]:          0 :                 xDiaProp->setPropertyValue( ::rtl::OUString(  "Volume" ),
     617 [ #  # ][ #  # ]:          0 :                                             uno::makeAny( true ));
                 [ #  # ]
     618                 :            :             }
     619         [ #  # ]:          0 :             catch( const uno::Exception & rEx )
     620                 :            :             {
     621                 :            : #ifdef DBG_UTIL
     622                 :            :                 rtl::OString aBStr(rtl::OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
     623                 :            :                 OSL_TRACE("Exception caught for property Volume: %s", aBStr.getStr());
     624                 :            : #else
     625                 :            :                 (void)rEx; // avoid warning for pro build
     626                 :            : #endif
     627                 :            :             }
     628                 :          6 :         }
     629                 :            :     }
     630                 :            : 
     631                 :            :     // set changed size and position after properties (esp. 3d)
     632                 :            : 
     633         [ +  - ]:          6 :     uno::Reference< chart::XDiagramPositioning > xDiaPos( mxDiagram, uno::UNO_QUERY );
     634         [ +  - ]:          6 :     if( xDiaPos.is())
     635                 :            :     {
     636         [ +  - ]:          6 :         if( !m_aOuterPositioning.isAutomatic() )
     637                 :            :         {
     638         [ -  + ]:          6 :             if( m_aInnerPositioning.hasPosSize() )
     639 [ #  # ][ #  # ]:          0 :                 xDiaPos->setDiagramPositionExcludingAxes( m_aInnerPositioning.getRectangle() );
     640         [ +  - ]:          6 :             else if( m_aOuterPositioning.hasPosSize() )
     641                 :            :             {
     642 [ +  - ][ -  + ]:          6 :                 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_3( GetImport().GetModel() ) ) //old version of OOo did write a wrong rectangle for the diagram size
     643 [ #  # ][ #  # ]:          0 :                     xDiaPos->setDiagramPositionIncludingAxesAndAxisTitles( m_aOuterPositioning.getRectangle() );
     644                 :            :                 else
     645 [ +  - ][ +  - ]:          6 :                     xDiaPos->setDiagramPositionIncludingAxes( m_aOuterPositioning.getRectangle() );
     646                 :            :             }
     647                 :            :         }
     648                 :            :     }
     649                 :            : 
     650 [ +  - ][ +  - ]:          6 :     SchXMLAxisContext::CorrectAxisPositions( uno::Reference< chart2::XChartDocument >( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ), maChartTypeServiceName, GetImport().GetODFVersion(), m_bAxisPositionAttributeImported );
                 [ +  - ]
     651                 :          6 : }
     652                 :            : 
     653                 :            : // ========================================
     654                 :            : 
     655                 :         18 : SchXMLDataPointContext::SchXMLDataPointContext(  SvXMLImport& rImport, const rtl::OUString& rLocalName,
     656                 :            :                                                  ::std::list< DataRowPointStyle >& rStyleList,
     657                 :            :                                                  const ::com::sun::star::uno::Reference<
     658                 :            :                                                     ::com::sun::star::chart2::XDataSeries >& xSeries,
     659                 :            :                                                  sal_Int32& rIndex,
     660                 :            :                                                  bool bSymbolSizeForSeriesIsMissingInFile ) :
     661                 :            :         SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
     662                 :            :         mrStyleList( rStyleList ),
     663                 :            :         m_xSeries( xSeries ),
     664                 :            :         mrIndex( rIndex ),
     665                 :         18 :         mbSymbolSizeForSeriesIsMissingInFile( bSymbolSizeForSeriesIsMissingInFile )
     666                 :            : {
     667                 :         18 : }
     668                 :            : 
     669                 :         18 : SchXMLDataPointContext::~SchXMLDataPointContext()
     670                 :            : {
     671         [ -  + ]:         36 : }
     672                 :            : 
     673                 :         18 : void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     674                 :            : {
     675 [ +  - ][ +  - ]:         18 :     sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
                 [ +  - ]
     676                 :         18 :     ::rtl::OUString aValue;
     677                 :         18 :     ::rtl::OUString sAutoStyleName;
     678                 :         18 :     sal_Int32 nRepeat = 1;
     679                 :            : 
     680         [ +  + ]:         36 :     for( sal_Int16 i = 0; i < nAttrCount; i++ )
     681                 :            :     {
     682 [ +  - ][ +  - ]:         18 :         rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
     683                 :         18 :         rtl::OUString aLocalName;
     684         [ +  - ]:         18 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     685                 :            : 
     686         [ +  - ]:         18 :         if( nPrefix == XML_NAMESPACE_CHART )
     687                 :            :         {
     688 [ +  - ][ -  + ]:         18 :             if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
     689 [ #  # ][ #  # ]:          0 :                 sAutoStyleName = xAttrList->getValueByIndex( i );
     690 [ +  - ][ +  - ]:         18 :             else if( IsXMLToken( aLocalName, XML_REPEATED ) )
     691 [ +  - ][ +  - ]:         18 :                 nRepeat = xAttrList->getValueByIndex( i ).toInt32();
     692                 :            :         }
     693                 :         18 :     }
     694                 :            : 
     695         [ -  + ]:         18 :     if( !sAutoStyleName.isEmpty())
     696                 :            :     {
     697                 :            :         DataRowPointStyle aStyle(
     698                 :            :             DataRowPointStyle::DATA_POINT,
     699         [ #  # ]:          0 :             m_xSeries, mrIndex, nRepeat, sAutoStyleName );
     700                 :          0 :         aStyle.mbSymbolSizeForSeriesIsMissingInFile = mbSymbolSizeForSeriesIsMissingInFile;
     701 [ #  # ][ #  # ]:          0 :         mrStyleList.push_back( aStyle );
     702                 :            :     }
     703                 :         18 :     mrIndex += nRepeat;
     704                 :         18 : }
     705                 :            : 
     706                 :            : // ========================================
     707                 :            : 
     708                 :         12 : SchXMLPositonAttributesHelper::SchXMLPositonAttributesHelper( SvXMLImport& rImporter )
     709                 :            :     : m_rImport( rImporter )
     710                 :            :     , m_aPosition(0,0)
     711                 :            :     , m_aSize(0,0)
     712                 :            :     , m_bHasSizeWidth( false )
     713                 :            :     , m_bHasSizeHeight( false )
     714                 :            :     , m_bHasPositionX( false )
     715                 :            :     , m_bHasPositionY( false )
     716                 :            :     , m_bAutoSize( false )
     717                 :         12 :     , m_bAutoPosition( false )
     718                 :            : {
     719                 :         12 : }
     720                 :            : 
     721                 :         12 : SchXMLPositonAttributesHelper::~SchXMLPositonAttributesHelper()
     722                 :            : {
     723                 :         12 : }
     724                 :            : 
     725                 :          6 : bool SchXMLPositonAttributesHelper::hasSize() const
     726                 :            : {
     727 [ +  - ][ +  - ]:          6 :     return m_bHasSizeWidth && m_bHasSizeHeight;
     728                 :            : }
     729                 :         12 : bool SchXMLPositonAttributesHelper::hasPosition() const
     730                 :            : {
     731 [ +  + ][ +  - ]:         12 :     return m_bHasPositionX && m_bHasPositionY;
     732                 :            : }
     733                 :         12 : bool SchXMLPositonAttributesHelper::hasPosSize() const
     734                 :            : {
     735 [ +  + ][ +  - ]:         12 :     return hasPosition() && hasSize();
     736                 :            : }
     737                 :          6 : bool SchXMLPositonAttributesHelper::isAutomatic() const
     738                 :            : {
     739 [ +  - ][ -  + ]:          6 :     return m_bAutoSize || m_bAutoPosition;
     740                 :            : }
     741                 :          6 : awt::Rectangle SchXMLPositonAttributesHelper::getRectangle() const
     742                 :            : {
     743                 :          6 :     return awt::Rectangle( m_aPosition.X, m_aPosition.Y, m_aSize.Width, m_aSize.Height );
     744                 :            : }
     745                 :            : 
     746                 :         24 : bool SchXMLPositonAttributesHelper::readPositioningAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
     747                 :            : {
     748                 :            :     //returns true if the attribute was proccessed
     749                 :         24 :     bool bReturn = true;
     750                 :            : 
     751         [ +  - ]:         24 :     if( XML_NAMESPACE_SVG == nPrefix )
     752                 :            :     {
     753         [ +  + ]:         24 :         if( IsXMLToken( rLocalName, XML_X ) )
     754                 :            :         {
     755                 :          6 :             m_rImport.GetMM100UnitConverter().convertMeasureToCore(
     756                 :          6 :                     m_aPosition.X, rValue );
     757                 :          6 :             m_bHasPositionX = true;
     758                 :            :         }
     759         [ +  + ]:         18 :         else if( IsXMLToken( rLocalName, XML_Y ) )
     760                 :            :         {
     761                 :          6 :             m_rImport.GetMM100UnitConverter().convertMeasureToCore(
     762                 :          6 :                     m_aPosition.Y, rValue );
     763                 :          6 :             m_bHasPositionY = true;
     764                 :            :         }
     765         [ +  + ]:         12 :         else if( IsXMLToken( rLocalName, XML_WIDTH ) )
     766                 :            :         {
     767                 :          6 :             m_rImport.GetMM100UnitConverter().convertMeasureToCore(
     768                 :          6 :                     m_aSize.Width, rValue );
     769                 :          6 :             m_bHasSizeWidth = true;
     770                 :            :         }
     771         [ +  - ]:          6 :         else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
     772                 :            :         {
     773                 :          6 :             m_rImport.GetMM100UnitConverter().convertMeasureToCore(
     774                 :          6 :                     m_aSize.Height, rValue );
     775                 :          6 :             m_bHasSizeHeight = true;
     776                 :            :         }
     777                 :            :         else
     778                 :          0 :             bReturn = false;
     779                 :            :     }
     780                 :            :     else
     781                 :          0 :         bReturn = false;
     782                 :            : 
     783                 :         24 :     return bReturn;
     784                 :            : }
     785                 :            : 
     786                 :            : 
     787                 :          6 : void SchXMLPositonAttributesHelper::readAutomaticPositioningProperties( XMLPropStyleContext* pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
     788                 :            : {
     789 [ +  - ][ +  - ]:          6 :     if( pPropStyleContext && pStylesCtxt )
     790                 :            :     {
     791                 :            :         //handle automatic position and size
     792                 :            :         SchXMLTools::getPropertyFromContext(
     793         [ +  - ]:          6 :             ::rtl::OUString("AutomaticSize"), pPropStyleContext, pStylesCtxt ) >>= m_bAutoSize;
     794                 :            :         SchXMLTools::getPropertyFromContext(
     795         [ +  - ]:          6 :             ::rtl::OUString("AutomaticPosition"), pPropStyleContext, pStylesCtxt ) >>= m_bAutoPosition;
     796                 :            :     }
     797                 :          6 : }
     798                 :            : 
     799                 :            : // ========================================
     800                 :            : 
     801                 :          0 : SchXMLCoordinateRegionContext::SchXMLCoordinateRegionContext(
     802                 :            :           SvXMLImport& rImport
     803                 :            :         , sal_uInt16 nPrefix
     804                 :            :         , const rtl::OUString& rLocalName
     805                 :            :         , SchXMLPositonAttributesHelper& rPositioning )
     806                 :            :         : SvXMLImportContext( rImport, nPrefix, rLocalName )
     807                 :          0 :         , m_rPositioning( rPositioning )
     808                 :            : {
     809                 :          0 : }
     810                 :            : 
     811                 :          0 : SchXMLCoordinateRegionContext::~SchXMLCoordinateRegionContext()
     812                 :            : {
     813         [ #  # ]:          0 : }
     814                 :            : 
     815                 :          0 : void SchXMLCoordinateRegionContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     816                 :            : {
     817                 :            :     // parse attributes
     818         [ #  # ]:          0 :     sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
     819                 :            : 
     820         [ #  # ]:          0 :     for( sal_Int16 i = 0; i < nAttrCount; i++ )
     821                 :            :     {
     822 [ #  # ][ #  # ]:          0 :         rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
     823                 :          0 :         rtl::OUString aLocalName;
     824 [ #  # ][ #  # ]:          0 :         rtl::OUString aValue = xAttrList->getValueByIndex( i );
     825         [ #  # ]:          0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     826         [ #  # ]:          0 :         m_rPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
     827                 :          0 :     }
     828                 :          0 : }
     829                 :            : 
     830                 :            : // ========================================
     831                 :            : 
     832                 :         12 : SchXMLWallFloorContext::SchXMLWallFloorContext(
     833                 :            :     SchXMLImportHelper& rImpHelper,
     834                 :            :     SvXMLImport& rImport,
     835                 :            :     sal_uInt16 nPrefix,
     836                 :            :     const rtl::OUString& rLocalName,
     837                 :            :     uno::Reference< chart::XDiagram >& xDiagram,
     838                 :            :     ContextType eContextType ) :
     839                 :            :         SvXMLImportContext( rImport, nPrefix, rLocalName ),
     840                 :            :         mrImportHelper( rImpHelper ),
     841                 :            :         mxWallFloorSupplier( xDiagram, uno::UNO_QUERY ),
     842         [ +  - ]:         12 :         meContextType( eContextType )
     843                 :            : {
     844                 :         12 : }
     845                 :            : 
     846                 :         12 : SchXMLWallFloorContext::~SchXMLWallFloorContext()
     847                 :            : {
     848         [ -  + ]:         24 : }
     849                 :            : 
     850                 :         12 : void SchXMLWallFloorContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     851                 :            : {
     852         [ +  - ]:         12 :     if( mxWallFloorSupplier.is())
     853                 :            :     {
     854 [ +  - ][ +  - ]:         12 :         sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
                 [ +  - ]
     855                 :         12 :         rtl::OUString sAutoStyleName;
     856                 :            : 
     857         [ +  + ]:         24 :         for( sal_Int16 i = 0; i < nAttrCount; i++ )
     858                 :            :         {
     859 [ +  - ][ +  - ]:         12 :             rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
     860                 :         12 :             rtl::OUString aLocalName;
     861         [ +  - ]:         12 :             sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     862                 :            : 
     863 [ +  - ][ +  - ]:         24 :             if( nPrefix == XML_NAMESPACE_CHART &&
                 [ +  - ]
     864         [ +  - ]:         12 :                 IsXMLToken( aLocalName, XML_STYLE_NAME ) )
     865                 :            :             {
     866 [ +  - ][ +  - ]:         12 :                 sAutoStyleName = xAttrList->getValueByIndex( i );
     867                 :            :             }
     868                 :         12 :         }
     869                 :            : 
     870                 :            :         // set properties
     871                 :            :         uno::Reference< beans::XPropertySet > xProp( ( meContextType == CONTEXT_TYPE_WALL )
     872         [ +  - ]:          6 :                                                      ? mxWallFloorSupplier->getWall()
     873         [ +  - ]:          6 :                                                      : mxWallFloorSupplier->getFloor(),
     874 [ +  + ][ +  - ]:         24 :                                                      uno::UNO_QUERY );
         [ +  - ][ +  - ]
     875         [ +  - ]:         12 :         if( xProp.is())
     876                 :            :         {
     877         [ +  - ]:         12 :             if( !sAutoStyleName.isEmpty())
     878                 :            :             {
     879                 :         12 :                 const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
     880         [ +  - ]:         12 :                 if( pStylesCtxt )
     881                 :            :                 {
     882                 :            :                     const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
     883         [ +  - ]:         12 :                         mrImportHelper.GetChartFamilyID(), sAutoStyleName );
     884                 :            : 
     885 [ +  - ][ +  - ]:         12 :                     if( pStyle && pStyle->ISA( XMLPropStyleContext ))
         [ +  - ][ +  - ]
                 [ +  - ]
     886         [ +  - ]:         12 :                         (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
     887                 :            :                 }
     888                 :            :             }
     889                 :         12 :         }
     890                 :            :     }
     891                 :         12 : }
     892                 :            : 
     893                 :            : // ========================================
     894                 :            : 
     895                 :          0 : SchXMLStockContext::SchXMLStockContext(
     896                 :            :     SchXMLImportHelper& rImpHelper,
     897                 :            :     SvXMLImport& rImport,
     898                 :            :     sal_uInt16 nPrefix,
     899                 :            :     const rtl::OUString& rLocalName,
     900                 :            :     uno::Reference< chart::XDiagram >& xDiagram,
     901                 :            :     ContextType eContextType ) :
     902                 :            :         SvXMLImportContext( rImport, nPrefix, rLocalName ),
     903                 :            :         mrImportHelper( rImpHelper ),
     904                 :            :         mxStockPropProvider( xDiagram, uno::UNO_QUERY ),
     905         [ #  # ]:          0 :         meContextType( eContextType )
     906                 :            : {
     907                 :          0 : }
     908                 :            : 
     909                 :          0 : SchXMLStockContext::~SchXMLStockContext()
     910                 :            : {
     911         [ #  # ]:          0 : }
     912                 :            : 
     913                 :          0 : void SchXMLStockContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     914                 :            : {
     915         [ #  # ]:          0 :     if( mxStockPropProvider.is())
     916                 :            :     {
     917 [ #  # ][ #  # ]:          0 :         sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
                 [ #  # ]
     918                 :          0 :         rtl::OUString sAutoStyleName;
     919                 :            : 
     920         [ #  # ]:          0 :         for( sal_Int16 i = 0; i < nAttrCount; i++ )
     921                 :            :         {
     922 [ #  # ][ #  # ]:          0 :             rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
     923                 :          0 :             rtl::OUString aLocalName;
     924         [ #  # ]:          0 :             sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     925                 :            : 
     926 [ #  # ][ #  # ]:          0 :             if( nPrefix == XML_NAMESPACE_CHART &&
                 [ #  # ]
     927         [ #  # ]:          0 :                 IsXMLToken( aLocalName, XML_STYLE_NAME ) )
     928                 :            :             {
     929 [ #  # ][ #  # ]:          0 :                 sAutoStyleName = xAttrList->getValueByIndex( i );
     930                 :            :             }
     931                 :          0 :         }
     932                 :            : 
     933         [ #  # ]:          0 :         if( !sAutoStyleName.isEmpty())
     934                 :            :         {
     935                 :            :             // set properties
     936                 :          0 :             uno::Reference< beans::XPropertySet > xProp;
     937   [ #  #  #  # ]:          0 :             switch( meContextType )
     938                 :            :             {
     939                 :            :                 case CONTEXT_TYPE_GAIN:
     940 [ #  # ][ #  # ]:          0 :                     xProp = mxStockPropProvider->getUpBar();
                 [ #  # ]
     941                 :          0 :                     break;
     942                 :            :                 case CONTEXT_TYPE_LOSS:
     943 [ #  # ][ #  # ]:          0 :                     xProp = mxStockPropProvider->getDownBar();
                 [ #  # ]
     944                 :          0 :                     break;
     945                 :            :                 case CONTEXT_TYPE_RANGE:
     946 [ #  # ][ #  # ]:          0 :                     xProp = mxStockPropProvider->getMinMaxLine();
                 [ #  # ]
     947                 :          0 :                     break;
     948                 :            :             }
     949         [ #  # ]:          0 :             if( xProp.is())
     950                 :            :             {
     951                 :          0 :                 const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
     952         [ #  # ]:          0 :                 if( pStylesCtxt )
     953                 :            :                 {
     954                 :            :                     const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
     955         [ #  # ]:          0 :                         mrImportHelper.GetChartFamilyID(), sAutoStyleName );
     956                 :            : 
     957 [ #  # ][ #  # ]:          0 :                     if( pStyle && pStyle->ISA( XMLPropStyleContext ))
         [ #  # ][ #  # ]
                 [ #  # ]
     958         [ #  # ]:          0 :                         (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
     959                 :            :                 }
     960                 :          0 :             }
     961                 :          0 :         }
     962                 :            :     }
     963                 :          0 : }
     964                 :            : 
     965                 :            : // ========================================
     966                 :            : 
     967                 :          0 : void lcl_setErrorBarSequence ( const uno::Reference< chart2::XChartDocument > &xDoc,
     968                 :            :                                const uno::Reference< beans::XPropertySet > &xBarProp,
     969                 :            :                                const rtl::OUString &aRange,
     970                 :            :                                bool bPositiveValue, bool bYError )
     971                 :            : {
     972 [ #  # ][ #  # ]:          0 :     uno::Reference< com::sun::star::chart2::data::XDataProvider > xDataProvider(xDoc->getDataProvider());
     973         [ #  # ]:          0 :     uno::Reference< com::sun::star::chart2::data::XDataSource > xDataSource( xBarProp, uno::UNO_QUERY );
     974         [ #  # ]:          0 :     uno::Reference< com::sun::star::chart2::data::XDataSink > xDataSink( xDataSource, uno::UNO_QUERY );
     975                 :            : 
     976                 :            :     assert( xDataSink.is() && xDataSource.is() && xDataProvider.is() );
     977                 :            : 
     978         [ #  # ]:          0 :     rtl::OUString aXMLRange(lcl_ConvertRange(aRange,xDoc));
     979                 :            : 
     980                 :            :     uno::Reference< chart2::data::XDataSequence > xNewSequence(
     981 [ #  # ][ #  # ]:          0 :         xDataProvider->createDataSequenceByRangeRepresentation( aRange ));
     982                 :            : 
     983         [ #  # ]:          0 :     if( xNewSequence.is())
     984                 :            :     {
     985         [ #  # ]:          0 :         SchXMLTools::setXMLRangePropertyAtDataSequence(xNewSequence,aXMLRange);
     986                 :            : 
     987                 :          0 :         rtl::OUStringBuffer aRoleBuffer("error-bars-");
     988         [ #  # ]:          0 :         if( bYError )
     989         [ #  # ]:          0 :             aRoleBuffer.append( sal_Unicode( 'y' ));
     990                 :            :         else
     991         [ #  # ]:          0 :             aRoleBuffer.append( sal_Unicode( 'x' ));
     992                 :            : 
     993         [ #  # ]:          0 :         rtl::OUString aPlainRole = aRoleBuffer.makeStringAndClear();
     994         [ #  # ]:          0 :         aRoleBuffer.append( aPlainRole );
     995         [ #  # ]:          0 :         aRoleBuffer.append( sal_Unicode( '-' ));
     996                 :            : 
     997         [ #  # ]:          0 :         if( bPositiveValue )
     998 [ #  # ][ #  # ]:          0 :             aRoleBuffer = aRoleBuffer.appendAscii( "positive" );
     999                 :            :         else
    1000 [ #  # ][ #  # ]:          0 :             aRoleBuffer = aRoleBuffer.appendAscii( "negative" );
    1001                 :            : 
    1002         [ #  # ]:          0 :         rtl::OUString aRole = aRoleBuffer.makeStringAndClear();
    1003                 :            : 
    1004         [ #  # ]:          0 :         Reference< beans::XPropertySet > xSeqProp( xNewSequence, uno::UNO_QUERY );
    1005                 :            : 
    1006 [ #  # ][ #  # ]:          0 :         xSeqProp->setPropertyValue("Role", uno::makeAny( aRole ));
                 [ #  # ]
    1007                 :            : 
    1008 [ #  # ][ #  # ]:          0 :         Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
    1009                 :            : 
    1010                 :            :         Reference< chart2::data::XLabeledDataSequence > xLabelSeq(
    1011 [ #  # ][ #  # ]:          0 :             xFact->createInstance("com.sun.star.chart2.data.LabeledDataSequence"), uno::UNO_QUERY );
                 [ #  # ]
    1012                 :            : 
    1013 [ #  # ][ #  # ]:          0 :         xLabelSeq->setValues( xNewSequence );
    1014                 :            : 
    1015                 :            :         uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
    1016 [ #  # ][ #  # ]:          0 :             xDataSource->getDataSequences());
    1017                 :            : 
    1018         [ #  # ]:          0 :         aSequences.realloc( aSequences.getLength() + 1 );
    1019 [ #  # ][ #  # ]:          0 :         aSequences[ aSequences.getLength() - 1 ] = xLabelSeq;
    1020 [ #  # ][ #  # ]:          0 :         xDataSink->setData( aSequences );
                 [ #  # ]
    1021                 :          0 :     }
    1022                 :          0 : }
    1023                 :            : 
    1024                 :          0 : SchXMLStatisticsObjectContext::SchXMLStatisticsObjectContext(
    1025                 :            : 
    1026                 :            :     SchXMLImportHelper& rImpHelper,
    1027                 :            :     SvXMLImport& rImport,
    1028                 :            :     sal_uInt16 nPrefix,
    1029                 :            :     const rtl::OUString& rLocalName,
    1030                 :            :     const rtl::OUString &rSeriesStyleName,
    1031                 :            :     ::std::list< DataRowPointStyle >& rStyleList,
    1032                 :            :     const ::com::sun::star::uno::Reference<
    1033                 :            :                 ::com::sun::star::chart2::XDataSeries >& xSeries,
    1034                 :            :     ContextType eContextType,
    1035                 :            :     const awt::Size & rChartSize ) :
    1036                 :            : 
    1037                 :            :         SvXMLImportContext( rImport, nPrefix, rLocalName ),
    1038                 :            :         mrImportHelper( rImpHelper ),
    1039                 :            :         mrStyleList( rStyleList ),
    1040                 :            :         m_xSeries( xSeries ),
    1041                 :            :         meContextType( eContextType ),
    1042                 :            :         maChartSize( rChartSize ),
    1043                 :          0 :         maSeriesStyleName( rSeriesStyleName)
    1044                 :          0 : {}
    1045                 :            : 
    1046                 :          0 : SchXMLStatisticsObjectContext::~SchXMLStatisticsObjectContext()
    1047                 :            : {
    1048         [ #  # ]:          0 : }
    1049                 :            : 
    1050                 :          0 : void SchXMLStatisticsObjectContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
    1051                 :            : {
    1052 [ #  # ][ #  # ]:          0 :     sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
                 [ #  # ]
    1053                 :          0 :     ::rtl::OUString aValue;
    1054                 :          0 :     ::rtl::OUString sAutoStyleName;
    1055                 :          0 :     rtl::OUString aPosRange;
    1056                 :          0 :     rtl::OUString aNegRange;
    1057                 :          0 :     bool bYError = true;    /// Default errorbar, to be backward compatible with older files!
    1058                 :            : 
    1059         [ #  # ]:          0 :     for( sal_Int16 i = 0; i < nAttrCount; i++ )
    1060                 :            :     {
    1061 [ #  # ][ #  # ]:          0 :         rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
    1062                 :          0 :         rtl::OUString aLocalName;
    1063         [ #  # ]:          0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
    1064                 :            : 
    1065         [ #  # ]:          0 :         if( nPrefix == XML_NAMESPACE_CHART )
    1066                 :            :         {
    1067 [ #  # ][ #  # ]:          0 :             if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
    1068 [ #  # ][ #  # ]:          0 :                 sAutoStyleName = xAttrList->getValueByIndex( i );
    1069 [ #  # ][ #  # ]:          0 :             else if( IsXMLToken( aLocalName, XML_DIMENSION ) )
    1070 [ #  # ][ #  # ]:          0 :                 bYError = xAttrList->getValueByIndex(i) == "y";
    1071 [ #  # ][ #  # ]:          0 :             else if( IsXMLToken( aLocalName, XML_ERROR_UPPER_RANGE) )
    1072 [ #  # ][ #  # ]:          0 :                 aPosRange = xAttrList->getValueByIndex(i);
    1073 [ #  # ][ #  # ]:          0 :             else if( IsXMLToken( aLocalName, XML_ERROR_LOWER_RANGE) )
    1074 [ #  # ][ #  # ]:          0 :                 aNegRange = xAttrList->getValueByIndex(i);
    1075                 :            :         }
    1076                 :          0 :     }
    1077                 :            : 
    1078                 :            :     // note: regression-curves must get a style-object even if there is no
    1079                 :            :     // auto-style set, because they can contain an equation
    1080 [ #  # ][ #  # ]:          0 :     if( !sAutoStyleName.isEmpty() || meContextType == CONTEXT_TYPE_REGRESSION_CURVE )
                 [ #  # ]
    1081                 :            :     {
    1082         [ #  # ]:          0 :         DataRowPointStyle aStyle( DataRowPointStyle::MEAN_VALUE, m_xSeries, -1, 1, sAutoStyleName );
    1083                 :            : 
    1084   [ #  #  #  # ]:          0 :         switch( meContextType )
    1085                 :            :         {
    1086                 :            :             case CONTEXT_TYPE_MEAN_VALUE_LINE:
    1087                 :          0 :                 aStyle.meType = DataRowPointStyle::MEAN_VALUE;
    1088                 :          0 :                 break;
    1089                 :            :             case CONTEXT_TYPE_REGRESSION_CURVE:
    1090                 :          0 :                 aStyle.meType = DataRowPointStyle::REGRESSION;
    1091                 :          0 :                 break;
    1092                 :            :             case CONTEXT_TYPE_ERROR_INDICATOR:
    1093                 :            :                 {
    1094                 :          0 :                     aStyle.meType = DataRowPointStyle::ERROR_INDICATOR;
    1095                 :            : 
    1096                 :            :                     ;
    1097                 :            :                     uno::Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(),
    1098 [ #  # ][ #  # ]:          0 :                                                                         uno::UNO_QUERY );
    1099                 :            : 
    1100         [ #  # ]:          0 :                     uno::Reference< beans::XPropertySet > xBarProp( xFact->createInstance("com.sun.star.chart2.ErrorBar" ),
    1101 [ #  # ][ #  # ]:          0 :                                                                     uno::UNO_QUERY );
    1102                 :            : 
    1103 [ #  # ][ #  # ]:          0 :                     xBarProp->setPropertyValue("ErrorBarStyle",uno::makeAny(com::sun::star::chart::ErrorBarStyle::NONE));
                 [ #  # ]
    1104 [ #  # ][ #  # ]:          0 :                     xBarProp->setPropertyValue("PositiveError",uno::makeAny(static_cast<double>(0.0)));
                 [ #  # ]
    1105 [ #  # ][ #  # ]:          0 :                     xBarProp->setPropertyValue("NegativeError",uno::makeAny(static_cast<double>(0.0)));
                 [ #  # ]
    1106 [ #  # ][ #  # ]:          0 :                     xBarProp->setPropertyValue("Weight",uno::makeAny(static_cast<double>(1.0)));
                 [ #  # ]
    1107 [ #  # ][ #  # ]:          0 :                     xBarProp->setPropertyValue("ShowPositiveError",uno::makeAny(sal_True));
                 [ #  # ]
    1108 [ #  # ][ #  # ]:          0 :                     xBarProp->setPropertyValue("ShowNegativeError",uno::makeAny(sal_True));
                 [ #  # ]
    1109                 :            : 
    1110                 :          0 :                     const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
    1111                 :            : 
    1112                 :            :                     const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
    1113         [ #  # ]:          0 :                         mrImportHelper.GetChartFamilyID(), sAutoStyleName );
    1114                 :            :                     // note: SvXMLStyleContext::FillPropertySet is not const
    1115                 :            :                     XMLPropStyleContext * pErrorStyleContext =
    1116         [ #  # ]:          0 :                         const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
    1117                 :            : 
    1118         [ #  # ]:          0 :                     pErrorStyleContext->FillPropertySet( xBarProp );
    1119                 :            : 
    1120         [ #  # ]:          0 :                     uno::Reference< chart2::XChartDocument > xDoc(GetImport().GetModel(),uno::UNO_QUERY);
    1121                 :            : 
    1122         [ #  # ]:          0 :                     if (!aPosRange.isEmpty())
    1123         [ #  # ]:          0 :                         lcl_setErrorBarSequence(xDoc,xBarProp,aPosRange,true,bYError);
    1124                 :            : 
    1125         [ #  # ]:          0 :                     if (!aNegRange.isEmpty())
    1126         [ #  # ]:          0 :                         lcl_setErrorBarSequence(xDoc,xBarProp,aNegRange,false,bYError);
    1127                 :            : 
    1128         [ #  # ]:          0 :                     if ( !bYError )
    1129                 :            :                     {
    1130         [ #  # ]:          0 :                         aStyle.m_xErrorXProperties.set( xBarProp );
    1131                 :            :                     }
    1132                 :            :                     else
    1133                 :            :                     {
    1134                 :            :                         /// Keep 0DF12 and below support
    1135                 :          0 :                         pStyle = pStylesCtxt->FindStyleChildContext(mrImportHelper.GetChartFamilyID(),
    1136         [ #  # ]:          0 :                                                                     maSeriesStyleName);
    1137                 :            : 
    1138                 :            :                         XMLPropStyleContext * pSeriesStyleContext =
    1139         [ #  # ]:          0 :                             const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
    1140                 :            : 
    1141                 :            :                         uno::Any aAny = SchXMLTools::getPropertyFromContext("ErrorBarStyle",
    1142         [ #  # ]:          0 :                                                                             pSeriesStyleContext,pStylesCtxt);
    1143                 :            : 
    1144         [ #  # ]:          0 :                         if ( aAny.hasValue() )
    1145                 :            :                         {
    1146                 :          0 :                             sal_Int32 aBarStyle = com::sun::star::chart::ErrorBarStyle::NONE;
    1147                 :          0 :                             aAny >>= aBarStyle;
    1148                 :            : 
    1149                 :            :                             aAny = SchXMLTools::getPropertyFromContext("ShowPositiveError",
    1150         [ #  # ]:          0 :                                                                        pSeriesStyleContext,pStylesCtxt);
    1151                 :            : 
    1152 [ #  # ][ #  # ]:          0 :                             xBarProp->setPropertyValue("ShowPositiveError",aAny);
    1153                 :            : 
    1154                 :            :                             aAny = SchXMLTools::getPropertyFromContext("ShowNegativeError",
    1155         [ #  # ]:          0 :                                                                        pSeriesStyleContext,pStylesCtxt);
    1156                 :            : 
    1157 [ #  # ][ #  # ]:          0 :                             xBarProp->setPropertyValue("ShowNegativeError",aAny);
    1158                 :            : 
    1159         [ #  # ]:          0 :                             switch(aBarStyle)
    1160                 :            :                             {
    1161                 :            :                             case com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN:
    1162                 :            :                                 {
    1163                 :            :                                     aAny = SchXMLTools::getPropertyFromContext("NegativeError",
    1164         [ #  # ]:          0 :                                                                                pSeriesStyleContext,pStylesCtxt);
    1165                 :            : 
    1166 [ #  # ][ #  # ]:          0 :                                     xBarProp->setPropertyValue("NegativeError",aAny);
    1167                 :            : 
    1168                 :            :                                     aAny = SchXMLTools::getPropertyFromContext("PositiveError",
    1169         [ #  # ]:          0 :                                                                                pSeriesStyleContext,pStylesCtxt);
    1170                 :            : 
    1171 [ #  # ][ #  # ]:          0 :                                     xBarProp->setPropertyValue("PositiveError",aAny);
    1172                 :            :                                 }
    1173                 :          0 :                                 break;
    1174                 :            :                             default:
    1175                 :          0 :                                 break;
    1176                 :            :                             }
    1177                 :            :                         }
    1178                 :            : 
    1179         [ #  # ]:          0 :                         aStyle.m_xErrorYProperties.set( xBarProp );
    1180                 :          0 :                     }
    1181                 :            :                 }
    1182                 :          0 :                 break;
    1183                 :            :         }
    1184                 :            : 
    1185 [ #  # ][ #  # ]:          0 :         mrStyleList.push_back( aStyle );
    1186                 :          0 :     }
    1187                 :          0 : }
    1188                 :            : 
    1189                 :          0 : SvXMLImportContext* SchXMLStatisticsObjectContext::CreateChildContext(
    1190                 :            :     sal_uInt16 nPrefix,
    1191                 :            :     const rtl::OUString& rLocalName,
    1192                 :            :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
    1193                 :            : {
    1194                 :          0 :     SvXMLImportContext* pContext = 0;
    1195                 :            : 
    1196   [ #  #  #  # ]:          0 :     if( nPrefix == XML_NAMESPACE_CHART &&
                 [ #  # ]
    1197                 :          0 :         IsXMLToken( rLocalName, XML_EQUATION ) )
    1198                 :            :     {
    1199                 :            :         pContext = new SchXMLEquationContext(
    1200         [ #  # ]:          0 :             mrImportHelper, GetImport(), nPrefix, rLocalName, m_xSeries, maChartSize, mrStyleList.back());
    1201                 :            :     }
    1202                 :            :     else
    1203                 :            :     {
    1204                 :          0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
    1205                 :            :     }
    1206                 :            : 
    1207                 :          0 :     return pContext;
    1208                 :            : }
    1209                 :            : 
    1210                 :            : // ========================================
    1211                 :            : 
    1212                 :          0 : SchXMLEquationContext::SchXMLEquationContext(
    1213                 :            :     SchXMLImportHelper& rImpHelper,
    1214                 :            :     SvXMLImport& rImport,
    1215                 :            :     sal_uInt16 nPrefix,
    1216                 :            :     const rtl::OUString& rLocalName,
    1217                 :            :     const ::com::sun::star::uno::Reference<
    1218                 :            :     ::com::sun::star::chart2::XDataSeries >& xSeries,
    1219                 :            :     const awt::Size & rChartSize,
    1220                 :            :     DataRowPointStyle & rRegressionStyle ) :
    1221                 :            :         SvXMLImportContext( rImport, nPrefix, rLocalName ),
    1222                 :            :         mrImportHelper( rImpHelper ),
    1223                 :            :         mrRegressionStyle( rRegressionStyle ),
    1224                 :            :         m_xSeries( xSeries ),
    1225                 :          0 :         maChartSize( rChartSize )
    1226                 :          0 : {}
    1227                 :            : 
    1228                 :          0 : SchXMLEquationContext::~SchXMLEquationContext()
    1229         [ #  # ]:          0 : {}
    1230                 :            : 
    1231                 :          0 : void SchXMLEquationContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
    1232                 :            : {
    1233                 :            :     // parse attributes
    1234 [ #  # ][ #  # ]:          0 :     sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
                 [ #  # ]
    1235                 :          0 :     SchXMLImport& rImport = ( SchXMLImport& )GetImport();
    1236         [ #  # ]:          0 :     const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetRegEquationAttrTokenMap();
    1237                 :          0 :     OUString sAutoStyleName;
    1238                 :            : 
    1239                 :          0 :     bool bShowEquation = true;
    1240                 :          0 :     bool bShowRSquare = false;
    1241                 :          0 :     awt::Point aPosition;
    1242                 :          0 :     bool bHasXPos = false;
    1243                 :          0 :     bool bHasYPos = false;
    1244                 :            : 
    1245         [ #  # ]:          0 :     for( sal_Int16 i = 0; i < nAttrCount; i++ )
    1246                 :            :     {
    1247 [ #  # ][ #  # ]:          0 :         rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
    1248                 :          0 :         rtl::OUString aLocalName;
    1249 [ #  # ][ #  # ]:          0 :         rtl::OUString aValue = xAttrList->getValueByIndex( i );
    1250         [ #  # ]:          0 :         sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
    1251                 :            : 
    1252 [ #  # ][ #  #  :          0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
             #  #  #  # ]
    1253                 :            :         {
    1254                 :            :             case XML_TOK_REGEQ_POS_X:
    1255                 :          0 :                 rImport.GetMM100UnitConverter().convertMeasureToCore(
    1256         [ #  # ]:          0 :                         aPosition.X, aValue );
    1257                 :          0 :                 bHasXPos = true;
    1258                 :          0 :                 break;
    1259                 :            :             case XML_TOK_REGEQ_POS_Y:
    1260                 :          0 :                 rImport.GetMM100UnitConverter().convertMeasureToCore(
    1261         [ #  # ]:          0 :                         aPosition.Y, aValue );
    1262                 :          0 :                 bHasYPos = true;
    1263                 :          0 :                 break;
    1264                 :            :             case XML_TOK_REGEQ_DISPLAY_EQUATION:
    1265         [ #  # ]:          0 :                 ::sax::Converter::convertBool(bShowEquation, aValue);
    1266                 :          0 :                 break;
    1267                 :            :             case XML_TOK_REGEQ_DISPLAY_R_SQUARE:
    1268         [ #  # ]:          0 :                 ::sax::Converter::convertBool(bShowRSquare, aValue);
    1269                 :          0 :                 break;
    1270                 :            :             case XML_TOK_REGEQ_STYLE_NAME:
    1271                 :          0 :                 sAutoStyleName = aValue;
    1272                 :          0 :                 break;
    1273                 :            :         }
    1274                 :          0 :     }
    1275                 :            : 
    1276 [ #  # ][ #  # ]:          0 :     if( !sAutoStyleName.isEmpty() || bShowEquation || bShowRSquare )
         [ #  # ][ #  # ]
    1277                 :            :     {
    1278                 :          0 :         uno::Reference< beans::XPropertySet > xEqProp;
    1279 [ #  # ][ #  # ]:          0 :         uno::Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
    1280         [ #  # ]:          0 :         if( xFact.is())
    1281         [ #  # ]:          0 :             xEqProp.set( xFact->createInstance(
    1282 [ #  # ][ #  # ]:          0 :                              ::rtl::OUString(  "com.sun.star.chart2.RegressionEquation" )), uno::UNO_QUERY );
    1283         [ #  # ]:          0 :         if( xEqProp.is())
    1284                 :            :         {
    1285         [ #  # ]:          0 :             if( !sAutoStyleName.isEmpty() )
    1286                 :            :             {
    1287                 :          0 :                 const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
    1288         [ #  # ]:          0 :                 if( pStylesCtxt )
    1289                 :            :                 {
    1290                 :            :                     const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
    1291         [ #  # ]:          0 :                         mrImportHelper.GetChartFamilyID(), sAutoStyleName );
    1292                 :            :                     // note: SvXMLStyleContext::FillPropertySet is not const
    1293                 :            :                     XMLPropStyleContext * pPropStyleContext =
    1294         [ #  # ]:          0 :                         const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
    1295                 :            : 
    1296         [ #  # ]:          0 :                     if( pPropStyleContext )
    1297         [ #  # ]:          0 :                         pPropStyleContext->FillPropertySet( xEqProp );
    1298                 :            :                 }
    1299                 :            :             }
    1300 [ #  # ][ #  # ]:          0 :             xEqProp->setPropertyValue( OUString( "ShowEquation"), uno::makeAny( bShowEquation ));
                 [ #  # ]
    1301 [ #  # ][ #  # ]:          0 :             xEqProp->setPropertyValue( OUString( "ShowCorrelationCoefficient"), uno::makeAny( bShowRSquare ));
                 [ #  # ]
    1302                 :            : 
    1303 [ #  # ][ #  # ]:          0 :             if( bHasXPos && bHasYPos )
    1304                 :            :             {
    1305                 :          0 :                 chart2::RelativePosition aRelPos;
    1306                 :          0 :                 aRelPos.Primary = static_cast< double >( aPosition.X ) / static_cast< double >( maChartSize.Width );
    1307                 :          0 :                 aRelPos.Secondary = static_cast< double >( aPosition.Y ) / static_cast< double >( maChartSize.Height );
    1308         [ #  # ]:          0 :                 xEqProp->setPropertyValue( OUString(  "RelativePosition" ),
    1309 [ #  # ][ #  # ]:          0 :                                            uno::makeAny( aRelPos ));
    1310                 :            :             }
    1311                 :            :             OSL_ASSERT( mrRegressionStyle.meType == DataRowPointStyle::REGRESSION );
    1312         [ #  # ]:          0 :             mrRegressionStyle.m_xEquationProperties.set( xEqProp );
    1313                 :          0 :         }
    1314                 :          0 :     }
    1315                 :          0 : }
    1316                 :            : 
    1317                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10