LCOV - code coverage report
Current view: top level - xmloff/source/chart - PropertyMaps.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 157 255 61.6 %
Date: 2012-08-25 Functions: 16 17 94.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 112 331 33.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : // include PropertyMap.hxx with this define
      31                 :            : // to create the maps
      32                 :            : #ifndef _PROPERTYMAP_HXX_
      33                 :            : #define XML_SCH_CREATE_GLOBAL_MAPS
      34                 :            : #include "PropertyMap.hxx"
      35                 :            : #undef XML_SCH_CREATE_GLOBAL_MAPS
      36                 :            : #endif
      37                 :            : 
      38                 :            : #include <sax/tools/converter.hxx>
      39                 :            : 
      40                 :            : #include "XMLChartPropertySetMapper.hxx"
      41                 :            : #include "SchXMLTools.hxx"
      42                 :            : #include <xmloff/EnumPropertyHdl.hxx>
      43                 :            : #include <xmloff/XMLConstantsPropertyHandler.hxx>
      44                 :            : #include <xmloff/attrlist.hxx>
      45                 :            : #include <xmloff/nmspmap.hxx>
      46                 :            : #include <xmloff/xmluconv.hxx>
      47                 :            : #include <xmloff/shapeimport.hxx>
      48                 :            : #include <xmloff/NamedBoolPropertyHdl.hxx>
      49                 :            : #include <xmloff/xmlexp.hxx>
      50                 :            : #include <xmloff/xmltoken.hxx>
      51                 :            : #include "XMLErrorIndicatorPropertyHdl.hxx"
      52                 :            : #include "XMLErrorBarStylePropertyHdl.hxx"
      53                 :            : #include "XMLTextOrientationHdl.hxx"
      54                 :            : #include "XMLSymbolTypePropertyHdl.hxx"
      55                 :            : #include "XMLAxisPositionPropertyHdl.hxx"
      56                 :            : #include <com/sun/star/chart/ChartAxisMarks.hpp>
      57                 :            : #include <com/sun/star/chart/ChartDataCaption.hpp>
      58                 :            : #include <com/sun/star/chart/ChartSymbolType.hpp>
      59                 :            : #include <com/sun/star/drawing/LineStyle.hpp>
      60                 :            : #include <com/sun/star/drawing/FillStyle.hpp>
      61                 :            : #include <com/sun/star/drawing/LineJoint.hpp>
      62                 :            : #include <com/sun/star/chart/ChartDataRowSource.hpp>
      63                 :            : #include <com/sun/star/chart/ChartAxisPosition.hpp>
      64                 :            : 
      65                 :            : // header for any2enum
      66                 :            : #include <comphelper/extract.hxx>
      67                 :            : #include <rtl/ustrbuf.hxx>
      68                 :            : #include <rtl/math.hxx>
      69                 :            : 
      70                 :            : #define SCH_XML_SETFLAG( status, flag )     (status)|= (flag)
      71                 :            : #define SCH_XML_UNSETFLAG( status, flag )   (status) = ((status) | (flag)) - (flag)
      72                 :            : 
      73                 :            : using namespace com::sun::star;
      74                 :            : using namespace ::xmloff::token;
      75                 :            : 
      76                 :            : // the following class implementations are in this file:
      77                 :            : //
      78                 :            : // * XMLChartPropHdlFactory
      79                 :            : // * XMLChartPropertySetMapper
      80                 :            : // * XMLChartExportPropertyMapper
      81                 :            : // * XMLChartImportPropertyMapper
      82                 :            : // * SchXMLStyleExport
      83                 :            : 
      84                 :            : // ----------------------------------------
      85                 :            : 
      86                 :         60 : XMLChartPropHdlFactory::~XMLChartPropHdlFactory()
      87                 :            : {
      88         [ -  + ]:        120 : }
      89                 :            : 
      90                 :       2607 : const XMLPropertyHandler* XMLChartPropHdlFactory::GetPropertyHandler( sal_Int32 nType ) const
      91                 :            : {
      92                 :       2607 :     const XMLPropertyHandler* pHdl = XMLPropertyHandlerFactory::GetPropertyHandler( nType );
      93         [ +  + ]:       2607 :     if( ! pHdl )
      94                 :            :     {
      95   [ +  +  +  +  :        561 :         switch( nType )
          +  +  +  +  +  
          +  +  +  +  +  
             +  +  +  - ]
      96                 :            :         {
      97                 :            :             case XML_SCH_TYPE_AXIS_POSITION:
      98         [ +  - ]:         33 :                 pHdl = new XMLAxisPositionPropertyHdl( false );
      99                 :         33 :                 break;
     100                 :            :             case XML_SCH_TYPE_AXIS_POSITION_VALUE:
     101         [ +  - ]:         33 :                 pHdl = new XMLAxisPositionPropertyHdl( true );
     102                 :         33 :                 break;
     103                 :            : 
     104                 :            :             case XML_SCH_TYPE_AXIS_LABEL_POSITION:
     105                 :            :                 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisLabelPositionEnumMap,
     106         [ +  - ]:         33 :                                                ::getCppuType((const chart::ChartAxisLabelPosition*)0) );
     107                 :         33 :                 break;
     108                 :            : 
     109                 :            :             case XML_SCH_TYPE_TICK_MARK_POSITION:
     110                 :            :                 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisMarkPositionEnumMap,
     111         [ +  - ]:         33 :                                                ::getCppuType((const chart::ChartAxisMarkPosition*)0) );
     112                 :         33 :                 break;
     113                 :            : 
     114                 :            :             case XML_SCH_TYPE_AXIS_ARRANGEMENT:
     115                 :            :                 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisArrangementEnumMap,
     116         [ +  - ]:         33 :                                                ::getCppuType((const chart::ChartAxisArrangeOrderType*)0) );
     117                 :         33 :                 break;
     118                 :            : 
     119                 :            :             case XML_SCH_TYPE_ERROR_BAR_STYLE:
     120                 :            :                 // here we have a constant rather than an enum
     121                 :            :                 pHdl = new XMLErrorBarStylePropertyHdl( aXMLChartErrorBarStyleEnumMap,
     122         [ +  - ]:         33 :                                                ::getCppuType((const sal_Int32*)0) );
     123                 :         33 :                 break;
     124                 :            : 
     125                 :            :             case XML_SCH_TYPE_REGRESSION_TYPE:
     126                 :            :                 pHdl = new XMLEnumPropertyHdl( aXMLChartRegressionCurveTypeEnumMap,
     127         [ +  - ]:         33 :                                                ::getCppuType((const chart::ChartRegressionCurveType*)0) );
     128                 :         33 :                 break;
     129                 :            : 
     130                 :            :             case XML_SCH_TYPE_ERROR_INDICATOR_LOWER:
     131         [ +  - ]:         33 :                 pHdl = new XMLErrorIndicatorPropertyHdl( sal_False );
     132                 :         33 :                 break;
     133                 :            :             case XML_SCH_TYPE_ERROR_INDICATOR_UPPER:
     134         [ +  - ]:         33 :                 pHdl = new XMLErrorIndicatorPropertyHdl( sal_True );
     135                 :         33 :                 break;
     136                 :            : 
     137                 :            :             case XML_SCH_TYPE_SOLID_TYPE:
     138                 :            :                 // here we have a constant rather than an enum
     139                 :            :                 pHdl = new XMLEnumPropertyHdl( aXMLChartSolidTypeEnumMap,
     140         [ +  - ]:         33 :                                                ::getCppuType((const sal_Int32*)0) );
     141                 :         33 :                 break;
     142                 :            :             case XML_SCH_TYPE_LABEL_PLACEMENT_TYPE:
     143                 :            :                 // here we have a constant rather than an enum
     144                 :            :                 pHdl = new XMLEnumPropertyHdl( aXMLChartDataLabelPlacementEnumMap,
     145         [ +  - ]:         33 :                                                 ::getCppuType((const sal_Int32*)0) );
     146                 :         33 :                 break;
     147                 :            :             case XML_SCH_TYPE_DATAROWSOURCE:
     148                 :            :                 pHdl = new XMLEnumPropertyHdl( aXMLChartDataRowSourceTypeEnumMap,
     149         [ +  - ]:         33 :                                                ::getCppuType((const chart::ChartDataRowSource*)0) );
     150                 :         33 :                 break;
     151                 :            :             case XML_SCH_TYPE_TEXT_ORIENTATION:
     152         [ +  - ]:         33 :                 pHdl = new XMLTextOrientationHdl();
     153                 :         33 :                 break;
     154                 :            : 
     155                 :            :             case XML_SCH_TYPE_INTERPOLATION:
     156                 :            :                 pHdl = new XMLEnumPropertyHdl( aXMLChartInterpolationTypeEnumMap,
     157         [ +  - ]:         33 :                                                ::getCppuType((const sal_Int32*)0) );
     158                 :         33 :                 break;
     159                 :            :             case XML_SCH_TYPE_SYMBOL_TYPE:
     160         [ +  - ]:         33 :                 pHdl = new XMLSymbolTypePropertyHdl( false );
     161                 :         33 :                 break;
     162                 :            : 
     163                 :            :             case XML_SCH_TYPE_NAMED_SYMBOL:
     164         [ +  - ]:         33 :                 pHdl = new XMLSymbolTypePropertyHdl( true );
     165                 :         33 :                 break;
     166                 :            : 
     167                 :            :             case XML_SCH_TYPE_MISSING_VALUE_TREATMENT:
     168                 :            :                 pHdl = new XMLEnumPropertyHdl( aXMLChartMissingValueTreatmentEnumMap,
     169         [ +  - ]:         33 :                                                ::getCppuType((const sal_Int32*)0) );
     170                 :         33 :                 break;
     171                 :            :         }
     172         [ +  - ]:        561 :         if( pHdl )
     173                 :        561 :             PutHdlCache( nType, pHdl );
     174                 :            :     }
     175                 :            : 
     176                 :       2607 :     return pHdl;
     177                 :            : }
     178                 :            : 
     179                 :            : // ----------------------------------------
     180                 :            : 
     181                 :         33 : XMLChartPropertySetMapper::XMLChartPropertySetMapper() :
     182 [ +  - ][ +  - ]:         33 :         XMLPropertySetMapper( aXMLChartPropMap, new XMLChartPropHdlFactory )
     183                 :            : {
     184                 :         33 : }
     185                 :            : 
     186                 :         33 : XMLChartPropertySetMapper::~XMLChartPropertySetMapper()
     187                 :            : {
     188         [ -  + ]:         66 : }
     189                 :            : 
     190                 :            : // ----------------------------------------
     191                 :            : 
     192                 :         27 : XMLChartExportPropertyMapper::XMLChartExportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper,
     193                 :            :                                                             SvXMLExport& rExport) :
     194                 :            :         SvXMLExportPropertyMapper( rMapper ),
     195         [ +  - ]:         27 :         msTrue( GetXMLToken( XML_TRUE )),
     196         [ +  - ]:         27 :         msFalse( GetXMLToken( XML_FALSE )),
     197                 :         81 :         mrExport( rExport )
     198                 :            : {
     199                 :            :     // chain draw properties
     200 [ +  - ][ +  - ]:         27 :     ChainExportMapper( XMLShapeExport::CreateShapePropMapper( rExport ));
         [ +  - ][ +  - ]
     201                 :            : 
     202                 :            :     // chain text properties
     203 [ +  - ][ +  - ]:         27 :     ChainExportMapper( XMLTextParagraphExport::CreateParaExtPropMapper( rExport ));
         [ +  - ][ +  - ]
     204                 :         27 : }
     205                 :            : 
     206                 :         27 : XMLChartExportPropertyMapper::~XMLChartExportPropertyMapper()
     207                 :            : {
     208         [ -  + ]:         54 : }
     209                 :            : 
     210                 :        218 : void XMLChartExportPropertyMapper::ContextFilter(
     211                 :            :     std::vector< XMLPropertyState >& rProperties,
     212                 :            :     uno::Reference< beans::XPropertySet > rPropSet ) const
     213                 :            : {
     214                 :        218 :     ::rtl::OUString aAutoPropName;
     215                 :        218 :     sal_Bool bCheckAuto = sal_False;
     216                 :            : 
     217                 :            :     // filter properties
     218 [ +  - ][ +  + ]:       3340 :     for( std::vector< XMLPropertyState >::iterator property = rProperties.begin();
     219                 :       1670 :          property != rProperties.end();
     220                 :            :          ++property )
     221                 :            :     {
     222                 :            :         // find properties with context
     223                 :            :         // to prevent writing this property set mnIndex member to -1
     224 [ +  - ][ +  - ]:       1452 :         switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ))
           [ +  +  +  +  
             +  -  -  + ]
     225                 :            :         {
     226                 :            :             // if Auto... is set the corresponding properties mustn't be exported
     227                 :            :             case XML_SCH_CONTEXT_MIN:
     228                 :         36 :                 bCheckAuto = sal_True;
     229                 :         36 :                 aAutoPropName = ::rtl::OUString( "AutoMin" );
     230                 :         36 :                 break;
     231                 :            :             case XML_SCH_CONTEXT_MAX:
     232                 :         36 :                 bCheckAuto = sal_True;
     233                 :         36 :                 aAutoPropName = ::rtl::OUString( "AutoMax" );
     234                 :         36 :                 break;
     235                 :            :             case XML_SCH_CONTEXT_STEP_MAIN:
     236                 :         36 :                 bCheckAuto = sal_True;
     237                 :         36 :                 aAutoPropName = ::rtl::OUString( "AutoStepMain" );
     238                 :         36 :                 break;
     239                 :            :             case XML_SCH_CONTEXT_STEP_HELP_COUNT:
     240                 :         36 :                 bCheckAuto = sal_True;
     241                 :         36 :                 aAutoPropName = ::rtl::OUString( "AutoStepHelp" );
     242                 :         36 :                 break;
     243                 :            : 
     244                 :            :             case XML_SCH_CONTEXT_ORIGIN:
     245                 :         36 :                 bCheckAuto = sal_True;
     246                 :         36 :                 aAutoPropName = ::rtl::OUString( "AutoOrigin" );
     247                 :         36 :                 break;
     248                 :            : 
     249                 :            :             // the following property is deprecated
     250                 :            :             // elemet-item symbol-image is used now
     251                 :            :             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
     252                 :          0 :                 property->mnIndex = -1;
     253                 :          0 :                 break;
     254                 :            : 
     255                 :            :             case XML_SCH_CONTEXT_STOCK_WITH_VOLUME:
     256                 :            :             case XML_SCH_CONTEXT_LINES_USED:
     257                 :            :                 // note this avoids export of the properties in OASIS format,
     258                 :            :                 // but also for the OOo XML Flat format (used by binfilter),
     259                 :            :                 // because there, the transformation to OOo is done after the
     260                 :            :                 // complete export of the chart in OASIS format.
     261         [ #  # ]:          0 :                 if( mrExport.getExportFlags() & EXPORT_OASIS )
     262                 :          0 :                     property->mnIndex = -1;
     263                 :          0 :                 break;
     264                 :            :         }
     265                 :            : 
     266         [ +  + ]:       1452 :         if( bCheckAuto )
     267                 :            :         {
     268         [ +  - ]:        180 :             if( rPropSet.is())
     269                 :            :             {
     270                 :            :                 try
     271                 :            :                 {
     272                 :        180 :                     sal_Bool bAuto = false;
     273 [ +  - ][ +  - ]:        180 :                     uno::Any aAny = rPropSet->getPropertyValue( aAutoPropName );
     274                 :        180 :                     aAny >>= bAuto;
     275         [ +  - ]:        180 :                     if( bAuto )
     276                 :        180 :                         property->mnIndex = -1;
     277                 :            :                 }
     278         [ #  # ]:          0 :                 catch(const beans::UnknownPropertyException&)
     279                 :            :                 {
     280                 :            :                 }
     281                 :            :             }
     282                 :        180 :             bCheckAuto = sal_False;
     283                 :            :         }
     284                 :            :     }
     285                 :            : 
     286         [ +  - ]:        218 :     SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet);
     287         [ #  # ]:        218 : }
     288                 :            : 
     289                 :          0 : void XMLChartExportPropertyMapper::handleElementItem(
     290                 :            :     SvXMLExport& rExport,
     291                 :            :     const XMLPropertyState& rProperty, sal_uInt16 nFlags,
     292                 :            :     const ::std::vector< XMLPropertyState > *pProperties,
     293                 :            :     sal_uInt32 nIdx ) const
     294                 :            : {
     295      [ #  #  # ]:          0 :     switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ))
     296                 :            :     {
     297                 :            :         case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE:
     298                 :            :             {
     299                 :          0 :                 ::rtl::OUString aURLStr;
     300                 :          0 :                 rProperty.maValue >>= aURLStr;
     301                 :            : 
     302                 :            :                 // export as XLink reference into the package
     303                 :            :                 // if embedding is off
     304         [ #  # ]:          0 :                 ::rtl::OUString sTempURL( mrExport.AddEmbeddedGraphicObject( aURLStr ));
     305         [ #  # ]:          0 :                 if( !sTempURL.isEmpty() )
     306                 :            :                 {
     307         [ #  # ]:          0 :                     mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sTempURL );
     308                 :            :                     mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE,
     309         [ #  # ]:          0 :                                               XML_SIMPLE );
     310                 :            :                     mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE,
     311         [ #  # ]:          0 :                                               XML_ONLOAD );
     312                 :            :                 }
     313                 :            : 
     314                 :            :                 {
     315                 :          0 :                     sal_uInt32 nPropIndex = rProperty.mnIndex;
     316                 :            :                     // this is the element that has to live until the next statement
     317                 :            :                     SvXMLElementExport aElem( mrExport,
     318 [ #  # ][ #  # ]:          0 :                                               getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
     319 [ #  # ][ #  # ]:          0 :                                               getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
     320         [ #  # ]:          0 :                                               sal_True, sal_True );
     321                 :            : 
     322                 :            :                     // export as Base64 embedded graphic
     323                 :            :                     // if embedding is on
     324         [ #  # ]:          0 :                     if( !aURLStr.isEmpty())
     325 [ #  # ][ #  # ]:          0 :                         mrExport.AddEmbeddedGraphicObjectAsBase64( aURLStr );
     326                 :          0 :                 }
     327                 :            :             }
     328                 :          0 :             break;
     329                 :            : 
     330                 :            :         case XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR:
     331                 :            :             {
     332                 :          0 :                 ::rtl::OUString aSeparator;
     333                 :          0 :                 rProperty.maValue >>= aSeparator;
     334                 :            : 
     335         [ #  # ]:          0 :                 if( !aSeparator.isEmpty() )
     336                 :            :                 {
     337                 :          0 :                     sal_uInt32 nPropIndex = rProperty.mnIndex;
     338                 :            :                     SvXMLElementExport aElem( mrExport,
     339 [ #  # ][ #  # ]:          0 :                                               getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
     340 [ #  # ][ #  # ]:          0 :                                               getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
     341         [ #  # ]:          0 :                                               sal_True, sal_True );
     342                 :            : 
     343 [ #  # ][ #  # ]:          0 :                     SchXMLTools::exportText( mrExport, aSeparator, true );
     344                 :          0 :                 }
     345                 :            :             }
     346                 :          0 :             break;
     347                 :            : 
     348                 :            :         default:
     349                 :            :             // call parent
     350                 :            :             SvXMLExportPropertyMapper::handleElementItem( rExport, rProperty,
     351                 :          0 :                                                           nFlags, pProperties, nIdx );
     352                 :          0 :             break;
     353                 :            :     }
     354                 :          0 : }
     355                 :            : 
     356                 :         55 : void XMLChartExportPropertyMapper::handleSpecialItem(
     357                 :            :     SvXMLAttributeList& rAttrList, const XMLPropertyState& rProperty,
     358                 :            :     const SvXMLUnitConverter& rUnitConverter,
     359                 :            :     const SvXMLNamespaceMap& rNamespaceMap,
     360                 :            :     const ::std::vector< XMLPropertyState > *pProperties,
     361                 :            :     sal_uInt32 nIdx ) const
     362                 :            : {
     363                 :         55 :     sal_Bool bHandled = sal_False;
     364                 :            : 
     365                 :         55 :     sal_Int32 nContextId = maPropMapper->GetEntryContextId( rProperty.mnIndex );
     366                 :            : 
     367         [ +  - ]:         55 :     if( nContextId )
     368                 :            :     {
     369                 :         55 :         bHandled = sal_True;
     370                 :            : 
     371 [ +  - ][ +  - ]:         55 :         rtl::OUString sAttrName = maPropMapper->GetEntryXMLName( rProperty.mnIndex );
     372 [ +  - ][ +  - ]:         55 :         sal_uInt16 nNameSpace = maPropMapper->GetEntryNameSpace( rProperty.mnIndex );
     373                 :         55 :         rtl::OUStringBuffer sValueBuffer;
     374                 :         55 :         rtl::OUString sValue;
     375                 :            : 
     376                 :         55 :         sal_Int32 nValue = 0;
     377                 :         55 :         sal_Bool bValue = sal_False;
     378                 :            : 
     379   [ -  -  -  -  :         55 :         switch( nContextId )
             -  -  -  +  
                      - ]
     380                 :            :         {
     381                 :            :             case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
     382                 :            :             case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
     383                 :          0 :                 rProperty.maValue >>= nValue;
     384                 :          0 :                 bValue = (( nValue & chart::ChartAxisMarks::INNER ) == chart::ChartAxisMarks::INNER );
     385         [ #  # ]:          0 :                 ::sax::Converter::convertBool( sValueBuffer, bValue );
     386                 :          0 :                 break;
     387                 :            :             case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
     388                 :            :             case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
     389                 :          0 :                 rProperty.maValue >>= nValue;
     390                 :          0 :                 bValue = (( nValue & chart::ChartAxisMarks::OUTER ) == chart::ChartAxisMarks::OUTER );
     391         [ #  # ]:          0 :                 ::sax::Converter::convertBool( sValueBuffer, bValue );
     392                 :          0 :                 break;
     393                 :            :             case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
     394                 :            :                 {
     395                 :            :                     // convert from 100th degrees to degrees (double)
     396                 :          0 :                     rProperty.maValue >>= nValue;
     397                 :          0 :                     double fVal = (double)(nValue) / 100.0;
     398         [ #  # ]:          0 :                     ::sax::Converter::convertDouble( sValueBuffer, fVal );
     399                 :            :                 }
     400                 :          0 :                 break;
     401                 :            :             case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
     402                 :            :                 {
     403                 :          0 :                     rProperty.maValue >>= nValue;
     404         [ #  # ]:          0 :                     if((( nValue & chart::ChartDataCaption::VALUE ) == chart::ChartDataCaption::VALUE ))
     405                 :            :                     {
     406         [ #  # ]:          0 :                         if( ( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
     407                 :            :                         {
     408 [ #  # ][ #  # ]:          0 :                             const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
                 [ #  # ]
     409         [ #  # ]:          0 :                             if( nCurrentVersion < SvtSaveOptions::ODFVER_012 )
     410 [ #  # ][ #  # ]:          0 :                                 sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
     411                 :            :                             else
     412 [ #  # ][ #  # ]:          0 :                                 sValueBuffer.append( GetXMLToken( XML_VALUE_AND_PERCENTAGE ));
     413                 :            :                         }
     414                 :            :                         else
     415 [ #  # ][ #  # ]:          0 :                             sValueBuffer.append( GetXMLToken( XML_VALUE ));
     416                 :            :                     }
     417         [ #  # ]:          0 :                     else if(( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
     418 [ #  # ][ #  # ]:          0 :                         sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
     419                 :            :                     else
     420 [ #  # ][ #  # ]:          0 :                         sValueBuffer.append( GetXMLToken( XML_NONE ));
     421                 :            :                 }
     422                 :          0 :                 break;
     423                 :            :             case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
     424                 :          0 :                 rProperty.maValue >>= nValue;
     425                 :          0 :                 bValue = (( nValue & chart::ChartDataCaption::TEXT ) == chart::ChartDataCaption::TEXT );
     426         [ #  # ]:          0 :                 ::sax::Converter::convertBool( sValueBuffer, bValue );
     427                 :          0 :                 break;
     428                 :            :             case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
     429                 :          0 :                 rProperty.maValue >>= nValue;
     430                 :          0 :                 bValue = (( nValue & chart::ChartDataCaption::SYMBOL ) == chart::ChartDataCaption::SYMBOL );
     431         [ #  # ]:          0 :                 ::sax::Converter::convertBool( sValueBuffer, bValue );
     432                 :          0 :                 break;
     433                 :            : 
     434                 :            :             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
     435                 :            :             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
     436                 :            :                 {
     437                 :          0 :                     awt::Size aSize;
     438         [ #  # ]:          0 :                     rProperty.maValue >>= aSize;
     439                 :            :                     rUnitConverter.convertMeasureToXML( sValueBuffer,
     440                 :            :                                                    nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH
     441                 :            :                                                    ? aSize.Width
     442 [ #  # ][ #  # ]:          0 :                                                    : aSize.Height );
     443                 :            :                 }
     444                 :          0 :                 break;
     445                 :            : 
     446                 :            :             case XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT:
     447                 :            :                 {
     448                 :            :                     // just for import
     449                 :         55 :                     break;
     450                 :            :                 }
     451                 :            : 
     452                 :            :             default:
     453                 :          0 :                 bHandled = sal_False;
     454                 :          0 :                 break;
     455                 :            :         }
     456                 :            : 
     457         [ -  + ]:         55 :         if( sValueBuffer.getLength())
     458                 :            :         {
     459         [ #  # ]:          0 :             sValue = sValueBuffer.makeStringAndClear();
     460         [ #  # ]:          0 :             sAttrName = rNamespaceMap.GetQNameByKey( nNameSpace, sAttrName );
     461         [ #  # ]:          0 :             rAttrList.AddAttribute( sAttrName, sValue );
     462                 :         55 :         }
     463                 :            :     }
     464                 :            : 
     465         [ -  + ]:         55 :     if( !bHandled )
     466                 :            :     {
     467                 :            :         // call parent
     468                 :          0 :         SvXMLExportPropertyMapper::handleSpecialItem( rAttrList, rProperty, rUnitConverter, rNamespaceMap, pProperties, nIdx );
     469                 :            :     }
     470                 :         55 : }
     471                 :            : 
     472                 :            : // ----------------------------------------
     473                 :            : 
     474                 :          6 : XMLChartImportPropertyMapper::XMLChartImportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper,
     475                 :            :                                                             const SvXMLImport& _rImport ) :
     476                 :            :         SvXMLImportPropertyMapper( rMapper, const_cast< SvXMLImport & >( _rImport )),
     477                 :          6 :         mrImport( const_cast< SvXMLImport & > ( _rImport ))
     478                 :            : {
     479                 :            :     // chain shape mapper for drawing properties
     480                 :            : 
     481                 :            :     // give an empty model. It is only used for numbering rules that don't exist in chart
     482                 :          6 :     uno::Reference< frame::XModel > xEmptyModel;
     483 [ +  - ][ +  - ]:          6 :     ChainImportMapper( XMLShapeImportHelper::CreateShapePropMapper( xEmptyModel, mrImport ));
         [ +  - ][ +  - ]
     484                 :            : 
     485                 :            :     //#i14365# save and load writing-mode for chart elements
     486                 :            :     //The property TextWritingMode is mapped wrongly in the underlying draw mapper, but for draw it is necessary
     487                 :            :     //We remove that property here only for chart thus the chart can use the correct mapping from the writer paragraph settings (attribute 'writing-mode' <-> property 'WritingMode')
     488 [ +  - ][ +  - ]:          6 :     sal_Int32 nUnwantedWrongEntry = maPropMapper->FindEntryIndex( "TextWritingMode", XML_NAMESPACE_STYLE, GetXMLToken(XML_WRITING_MODE) );
                 [ +  - ]
     489 [ +  - ][ +  - ]:          6 :     maPropMapper->RemoveEntry(nUnwantedWrongEntry);
     490                 :            : 
     491                 :            :     // do not chain text properties: on import this is done by shape mapper
     492                 :            :     // to import old documents
     493                 :          6 : }
     494                 :            : 
     495                 :          6 : XMLChartImportPropertyMapper::~XMLChartImportPropertyMapper()
     496                 :            : {
     497         [ -  + ]:         12 : }
     498                 :            : 
     499                 :        180 : bool XMLChartImportPropertyMapper::handleSpecialItem(
     500                 :            :     XMLPropertyState& rProperty,
     501                 :            :     ::std::vector< XMLPropertyState >& rProperties,
     502                 :            :     const ::rtl::OUString& rValue,
     503                 :            :     const SvXMLUnitConverter& rUnitConverter,
     504                 :            :     const SvXMLNamespaceMap& rNamespaceMap ) const
     505                 :            : {
     506                 :        180 :     sal_Int32 nContextId = maPropMapper->GetEntryContextId( rProperty.mnIndex );
     507                 :        180 :     sal_Bool bRet = (nContextId != 0);
     508                 :            : 
     509         [ +  - ]:        180 :     if( nContextId )
     510                 :            :     {
     511                 :        180 :         sal_Int32 nValue = 0;
     512                 :        180 :         bool bValue = false;
     513                 :            : 
     514   [ +  +  -  +  :        180 :         switch( nContextId )
             +  +  -  -  
                      + ]
     515                 :            :         {
     516                 :            :             case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
     517                 :            :             case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
     518         [ +  - ]:         12 :                 ::sax::Converter::convertBool( bValue, rValue );
     519                 :            :                 // modify old value
     520                 :         12 :                 rProperty.maValue >>= nValue;
     521         [ -  + ]:         12 :                 if( bValue )
     522                 :          0 :                     SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::INNER );
     523                 :            :                 else
     524                 :         12 :                     SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::INNER );
     525         [ +  - ]:         12 :                 rProperty.maValue <<= nValue;
     526                 :         12 :                 break;
     527                 :            :             case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
     528                 :            :             case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
     529         [ +  - ]:         12 :                 ::sax::Converter::convertBool( bValue, rValue );
     530                 :            :                 // modify old value
     531                 :         12 :                 rProperty.maValue >>= nValue;
     532         [ +  - ]:         12 :                 if( bValue )
     533                 :         12 :                     SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::OUTER );
     534                 :            :                 else
     535                 :          0 :                     SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::OUTER );
     536         [ +  - ]:         12 :                 rProperty.maValue <<= nValue;
     537                 :         12 :                 break;
     538                 :            :             case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
     539                 :            :                 {
     540                 :            :                     // convert from degrees (double) to 100th degrees (integer)
     541                 :            :                     double fVal;
     542         [ #  # ]:          0 :                     ::sax::Converter::convertDouble( fVal, rValue );
     543                 :          0 :                     nValue = (sal_Int32)( fVal * 100.0 );
     544         [ #  # ]:          0 :                     rProperty.maValue <<= nValue;
     545                 :            :                 }
     546                 :          0 :                 break;
     547                 :            :             case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
     548                 :            :                 {
     549                 :            :                     // modify old value
     550                 :         24 :                     rProperty.maValue >>= nValue;
     551 [ +  - ][ +  - ]:         24 :                     if( IsXMLToken( rValue, XML_NONE ))
     552                 :         24 :                         SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
     553 [ #  # ][ #  # ]:          0 :                     else if( IsXMLToken( rValue, XML_VALUE_AND_PERCENTAGE ) )
     554                 :          0 :                         SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
     555 [ #  # ][ #  # ]:          0 :                     else if( IsXMLToken( rValue, XML_VALUE ) )
     556                 :          0 :                         SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE );
     557                 :            :                     else // must be XML_PERCENTAGE
     558                 :          0 :                         SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::PERCENT );
     559         [ +  - ]:         24 :                     rProperty.maValue <<= nValue;
     560                 :            :                 }
     561                 :         24 :                 break;
     562                 :            :             case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
     563                 :         24 :                 rProperty.maValue >>= nValue;
     564         [ +  - ]:         24 :                 ::sax::Converter::convertBool( bValue, rValue );
     565         [ -  + ]:         24 :                 if( bValue )
     566                 :          0 :                     SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::TEXT );
     567                 :            :                 else
     568                 :         24 :                     SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::TEXT );
     569         [ +  - ]:         24 :                 rProperty.maValue <<= nValue;
     570                 :         24 :                 break;
     571                 :            :             case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
     572                 :         24 :                 rProperty.maValue >>= nValue;
     573         [ +  - ]:         24 :                 ::sax::Converter::convertBool( bValue, rValue );
     574         [ -  + ]:         24 :                 if( bValue )
     575                 :          0 :                     SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
     576                 :            :                 else
     577                 :         24 :                     SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
     578         [ +  - ]:         24 :                 rProperty.maValue <<= nValue;
     579                 :         24 :                 break;
     580                 :            :             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
     581                 :            :             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
     582                 :            :                 {
     583                 :          0 :                     awt::Size aSize;
     584         [ #  # ]:          0 :                     rProperty.maValue >>= aSize;
     585                 :            :                     rUnitConverter.convertMeasureToCore(
     586                 :            :                         (nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH)
     587                 :            :                                                    ? aSize.Width
     588                 :            :                                                    : aSize.Height,
     589 [ #  # ][ #  # ]:          0 :                                                    rValue );
     590         [ #  # ]:          0 :                     rProperty.maValue <<= aSize;
     591                 :            :                 }
     592                 :          0 :                 break;
     593                 :            : 
     594                 :            :             // deprecated from 6.0 beta on
     595                 :            :             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
     596 [ #  # ][ #  # ]:          0 :                 rProperty.maValue <<= mrImport.ResolveGraphicObjectURL( rValue, sal_False );
     597                 :          0 :                 break;
     598                 :            : 
     599                 :            :             default:
     600                 :         84 :                 bRet = sal_False;
     601                 :        180 :                 break;
     602                 :            :         }
     603                 :            :     }
     604                 :            : 
     605                 :            : 
     606                 :            :     // if we didn't handle it, the parent should
     607         [ +  + ]:        180 :     if( !bRet )
     608                 :            :     {
     609                 :            :         // call parent
     610                 :         84 :         bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty, rProperties, rValue, rUnitConverter, rNamespaceMap );
     611                 :            :     }
     612                 :            : 
     613                 :        180 :     return bRet;
     614                 :            : }
     615                 :            : 
     616                 :        168 : void XMLChartImportPropertyMapper::finished( ::std::vector< XMLPropertyState >& /*rProperties*/, sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
     617                 :            : {
     618                 :        168 : }
     619                 :            : 
     620                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10