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

Generated by: LCOV version 1.10