LCOV - code coverage report
Current view: top level - xmloff/source/chart - PropertyMaps.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 277 300 92.3 %
Date: 2015-06-13 12:38:46 Functions: 19 19 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11