2010-10-12 15:53:47 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-11-12 17:21:24 +00:00
/*
* This file is part of the LibreOffice project .
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice :
*
* Licensed to the Apache Software Foundation ( ASF ) under one or more
* contributor license agreements . See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership . The ASF licenses this file to you under the Apache
* License , Version 2.0 ( the " License " ) ; you may not use this file
* except in compliance with the License . You may obtain a copy of
* the License at http : //www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
2001-02-14 16:16:39 +00:00
// include PropertyMap.hxx with this define
// to create the maps
2016-04-12 20:02:02 +02:00
# ifndef INCLUDED_XMLOFF_SOURCE_CHART_PROPERTYMAP_HXX
2001-02-14 16:16:39 +00:00
# define XML_SCH_CREATE_GLOBAL_MAPS
# include "PropertyMap.hxx"
# undef XML_SCH_CREATE_GLOBAL_MAPS
# endif
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
# include <sax/tools/converter.hxx>
2007-10-22 15:32:28 +00:00
# include "SchXMLTools.hxx"
2013-06-02 22:22:43 +02:00
# include "XMLChartPropertySetMapper.hxx"
# include "XMLErrorIndicatorPropertyHdl.hxx"
# include "XMLErrorBarStylePropertyHdl.hxx"
# include "XMLTextOrientationHdl.hxx"
# include "XMLSymbolTypePropertyHdl.hxx"
# include "XMLAxisPositionPropertyHdl.hxx"
2014-07-26 14:44:38 -04:00
# include "../draw/propimp0.hxx"
2013-06-02 22:22:43 +02:00
2007-06-27 13:46:37 +00:00
# include <xmloff/EnumPropertyHdl.hxx>
# include <xmloff/XMLConstantsPropertyHandler.hxx>
# include <xmloff/attrlist.hxx>
# include <xmloff/nmspmap.hxx>
# include <xmloff/xmluconv.hxx>
# include <xmloff/shapeimport.hxx>
# include <xmloff/NamedBoolPropertyHdl.hxx>
# include <xmloff/xmlexp.hxx>
# include <xmloff/xmltoken.hxx>
2013-06-02 22:22:43 +02:00
2000-11-27 08:09:12 +00:00
# include <com/sun/star/drawing/LineStyle.hpp>
# include <com/sun/star/drawing/FillStyle.hpp>
# include <com/sun/star/drawing/LineJoint.hpp>
2013-06-02 22:22:43 +02:00
# include <com/sun/star/chart/ChartAxisMarks.hpp>
# include <com/sun/star/chart/ChartDataCaption.hpp>
# include <com/sun/star/chart/ChartSymbolType.hpp>
2001-04-25 15:36:55 +00:00
# include <com/sun/star/chart/ChartDataRowSource.hpp>
2008-12-12 12:17:17 +00:00
# include <com/sun/star/chart/ChartAxisPosition.hpp>
2013-04-22 10:22:42 +02:00
# include <com/sun/star/chart2/XChartDocument.hpp>
# include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
2000-09-18 16:07:07 +00:00
2001-04-25 15:36:55 +00:00
# include <comphelper/extract.hxx>
2000-09-18 16:07:07 +00:00
# include <rtl/ustrbuf.hxx>
2004-07-13 07:02:29 +00:00
# include <rtl/math.hxx>
2000-11-27 08:09:12 +00:00
# define SCH_XML_SETFLAG( status, flag ) (status)|= (flag)
# define SCH_XML_UNSETFLAG( status, flag ) (status) = ((status) | (flag)) - (flag)
2000-09-18 16:07:07 +00:00
using namespace com : : sun : : star ;
2001-06-29 20:07:26 +00:00
using namespace : : xmloff : : token ;
2000-09-18 16:07:07 +00:00
2014-07-26 14:44:38 -04:00
namespace {
SvXMLEnumMapEntry const aLineStyleMap [ ] =
{
{ XML_NONE , drawing : : LineStyle_NONE } ,
{ XML_SOLID , drawing : : LineStyle_SOLID } ,
{ XML_DASH , drawing : : LineStyle_DASH } ,
{ XML_TOKEN_INVALID , 0 }
} ;
}
2001-02-14 16:16:39 +00:00
// the following class implementations are in this file:
2014-02-25 23:15:32 +01:00
2001-02-14 16:16:39 +00:00
// * XMLChartPropHdlFactory
// * XMLChartPropertySetMapper
// * XMLChartExportPropertyMapper
// * XMLChartImportPropertyMapper
// * SchXMLStyleExport
2000-11-27 08:09:12 +00:00
2000-09-18 16:07:07 +00:00
XMLChartPropHdlFactory : : ~ XMLChartPropHdlFactory ( )
{
}
const XMLPropertyHandler * XMLChartPropHdlFactory : : GetPropertyHandler ( sal_Int32 nType ) const
{
const XMLPropertyHandler * pHdl = XMLPropertyHandlerFactory : : GetPropertyHandler ( nType ) ;
if ( ! pHdl )
{
switch ( nType )
{
2008-12-12 12:17:17 +00:00
case XML_SCH_TYPE_AXIS_POSITION :
pHdl = new XMLAxisPositionPropertyHdl ( false ) ;
break ;
case XML_SCH_TYPE_AXIS_POSITION_VALUE :
pHdl = new XMLAxisPositionPropertyHdl ( true ) ;
break ;
case XML_SCH_TYPE_AXIS_LABEL_POSITION :
pHdl = new XMLEnumPropertyHdl ( aXMLChartAxisLabelPositionEnumMap ,
2014-05-20 23:29:28 +02:00
cppu : : UnoType < chart : : ChartAxisLabelPosition > : : get ( ) ) ;
2008-12-12 12:17:17 +00:00
break ;
case XML_SCH_TYPE_TICK_MARK_POSITION :
pHdl = new XMLEnumPropertyHdl ( aXMLChartAxisMarkPositionEnumMap ,
2014-05-20 23:29:28 +02:00
cppu : : UnoType < chart : : ChartAxisMarkPosition > : : get ( ) ) ;
2008-12-12 12:17:17 +00:00
break ;
2000-09-18 16:07:07 +00:00
case XML_SCH_TYPE_AXIS_ARRANGEMENT :
pHdl = new XMLEnumPropertyHdl ( aXMLChartAxisArrangementEnumMap ,
2014-05-20 23:29:28 +02:00
cppu : : UnoType < chart : : ChartAxisArrangeOrderType > : : get ( ) ) ;
2000-09-18 16:07:07 +00:00
break ;
2008-03-06 14:42:58 +00:00
case XML_SCH_TYPE_ERROR_BAR_STYLE :
// here we have a constant rather than an enum
2008-06-04 08:47:23 +00:00
pHdl = new XMLErrorBarStylePropertyHdl ( aXMLChartErrorBarStyleEnumMap ,
2014-05-10 00:14:44 +02:00
: : cppu : : UnoType < sal_Int32 > : : get ( ) ) ;
2000-09-18 16:07:07 +00:00
break ;
2000-12-15 16:51:17 +00:00
case XML_SCH_TYPE_ERROR_INDICATOR_LOWER :
2014-01-28 19:58:40 +01:00
pHdl = new XMLErrorIndicatorPropertyHdl ( false ) ;
2000-12-15 16:51:17 +00:00
break ;
case XML_SCH_TYPE_ERROR_INDICATOR_UPPER :
2014-01-28 19:58:40 +01:00
pHdl = new XMLErrorIndicatorPropertyHdl ( true ) ;
2000-12-15 16:51:17 +00:00
break ;
2000-09-18 16:07:07 +00:00
case XML_SCH_TYPE_SOLID_TYPE :
// here we have a constant rather than an enum
2001-06-05 13:09:28 +00:00
pHdl = new XMLEnumPropertyHdl ( aXMLChartSolidTypeEnumMap ,
2014-05-10 00:14:44 +02:00
: : cppu : : UnoType < sal_Int32 > : : get ( ) ) ;
2000-09-18 16:07:07 +00:00
break ;
2007-11-23 10:35:00 +00:00
case XML_SCH_TYPE_LABEL_PLACEMENT_TYPE :
// here we have a constant rather than an enum
pHdl = new XMLEnumPropertyHdl ( aXMLChartDataLabelPlacementEnumMap ,
2014-05-10 00:14:44 +02:00
: : cppu : : UnoType < sal_Int32 > : : get ( ) ) ;
2007-11-23 10:35:00 +00:00
break ;
2001-05-11 17:17:56 +00:00
case XML_SCH_TYPE_DATAROWSOURCE :
pHdl = new XMLEnumPropertyHdl ( aXMLChartDataRowSourceTypeEnumMap ,
2014-05-20 23:29:28 +02:00
cppu : : UnoType < chart : : ChartDataRowSource > : : get ( ) ) ;
2001-05-11 17:17:56 +00:00
break ;
2001-10-30 13:53:54 +00:00
case XML_SCH_TYPE_TEXT_ORIENTATION :
pHdl = new XMLTextOrientationHdl ( ) ;
break ;
2004-07-13 07:02:29 +00:00
case XML_SCH_TYPE_INTERPOLATION :
pHdl = new XMLEnumPropertyHdl ( aXMLChartInterpolationTypeEnumMap ,
2014-05-10 00:14:44 +02:00
: : cppu : : UnoType < sal_Int32 > : : get ( ) ) ;
2004-08-20 07:12:06 +00:00
break ;
case XML_SCH_TYPE_SYMBOL_TYPE :
pHdl = new XMLSymbolTypePropertyHdl ( false ) ;
break ;
case XML_SCH_TYPE_NAMED_SYMBOL :
pHdl = new XMLSymbolTypePropertyHdl ( true ) ;
break ;
2008-07-30 10:45:31 +00:00
case XML_SCH_TYPE_MISSING_VALUE_TREATMENT :
pHdl = new XMLEnumPropertyHdl ( aXMLChartMissingValueTreatmentEnumMap ,
2014-05-10 00:14:44 +02:00
: : cppu : : UnoType < sal_Int32 > : : get ( ) ) ;
2008-07-30 10:45:31 +00:00
break ;
2014-07-26 14:44:38 -04:00
case XML_SCH_TYPE_LABEL_BORDER_STYLE :
pHdl = new XMLEnumPropertyHdl ( aLineStyleMap , cppu : : UnoType < drawing : : LineStyle > : : get ( ) ) ;
break ;
case XML_SCH_TYPE_LABEL_BORDER_OPACITY :
2015-11-10 10:29:15 +01:00
pHdl = new XMLOpacityPropertyHdl ( nullptr ) ;
2014-07-26 14:44:38 -04:00
break ;
default :
;
2001-10-30 13:53:54 +00:00
}
2000-09-18 16:07:07 +00:00
if ( pHdl )
PutHdlCache ( nType , pHdl ) ;
}
return pHdl ;
}
2013-12-20 03:17:14 +01:00
XMLChartPropertySetMapper : : XMLChartPropertySetMapper ( bool bForExport ) :
XMLPropertySetMapper ( aXMLChartPropMap , new XMLChartPropHdlFactory , bForExport )
2000-09-18 16:07:07 +00:00
{
}
XMLChartPropertySetMapper : : ~ XMLChartPropertySetMapper ( )
{
}
2014-06-30 09:53:06 +02:00
XMLChartExportPropertyMapper : : XMLChartExportPropertyMapper ( const rtl : : Reference < XMLPropertySetMapper > & rMapper ,
2001-05-11 17:17:56 +00:00
SvXMLExport & rExport ) :
2000-11-07 12:33:09 +00:00
SvXMLExportPropertyMapper ( rMapper ) ,
2001-05-11 17:17:56 +00:00
mrExport ( rExport )
2000-11-07 12:33:09 +00:00
{
2001-06-01 11:35:30 +00:00
// chain draw properties
ChainExportMapper ( XMLShapeExport : : CreateShapePropMapper ( rExport ) ) ;
// chain text properties
ChainExportMapper ( XMLTextParagraphExport : : CreateParaExtPropMapper ( rExport ) ) ;
2000-11-07 12:33:09 +00:00
}
XMLChartExportPropertyMapper : : ~ XMLChartExportPropertyMapper ( )
{
}
void XMLChartExportPropertyMapper : : ContextFilter (
2013-09-04 15:35:18 +01:00
bool bEnableFoFontFamily ,
2000-09-18 16:07:07 +00:00
std : : vector < XMLPropertyState > & rProperties ,
2016-04-11 16:05:03 +02:00
const uno : : Reference < beans : : XPropertySet > & rPropSet ) const
2000-09-18 16:07:07 +00:00
{
2013-04-07 12:06:47 +02:00
OUString aAutoPropName ;
2013-09-17 23:22:55 +09:00
bool bCheckAuto = false ;
2000-12-09 14:59:31 +00:00
2000-09-18 16:07:07 +00:00
// filter properties
for ( std : : vector < XMLPropertyState > : : iterator property = rProperties . begin ( ) ;
property ! = rProperties . end ( ) ;
2011-01-01 21:16:54 +00:00
+ + property )
2000-09-18 16:07:07 +00:00
{
// find properties with context
// to prevent writing this property set mnIndex member to -1
2000-11-07 12:33:09 +00:00
switch ( getPropertySetMapper ( ) - > GetEntryContextId ( property - > mnIndex ) )
2000-09-18 16:07:07 +00:00
{
2000-12-09 14:59:31 +00:00
// if Auto... is set the corresponding properties mustn't be exported
case XML_SCH_CONTEXT_MIN :
2013-09-17 23:22:55 +09:00
bCheckAuto = true ;
2013-03-19 21:15:00 +01:00
aAutoPropName = " AutoMin " ;
2000-12-09 14:59:31 +00:00
break ;
case XML_SCH_CONTEXT_MAX :
2013-09-17 23:22:55 +09:00
bCheckAuto = true ;
2013-03-19 21:15:00 +01:00
aAutoPropName = " AutoMax " ;
2000-12-09 14:59:31 +00:00
break ;
case XML_SCH_CONTEXT_STEP_MAIN :
2013-09-17 23:22:55 +09:00
bCheckAuto = true ;
2013-03-19 21:15:00 +01:00
aAutoPropName = " AutoStepMain " ;
2000-12-09 14:59:31 +00:00
break ;
2008-07-02 10:35:35 +00:00
case XML_SCH_CONTEXT_STEP_HELP_COUNT :
2013-09-17 23:22:55 +09:00
bCheckAuto = true ;
2013-03-19 21:15:00 +01:00
aAutoPropName = " AutoStepHelp " ;
2008-07-02 10:35:35 +00:00
break ;
2004-07-13 07:02:29 +00:00
2000-12-09 14:59:31 +00:00
case XML_SCH_CONTEXT_ORIGIN :
2013-09-17 23:22:55 +09:00
bCheckAuto = true ;
2013-03-19 21:15:00 +01:00
aAutoPropName = " AutoOrigin " ;
2000-12-09 14:59:31 +00:00
break ;
2001-08-16 12:28:49 +00:00
// the following property is deprecated
2015-03-13 19:47:38 +01:00
// element-item symbol-image is used now
2001-08-16 12:28:49 +00:00
case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME :
property - > mnIndex = - 1 ;
2004-07-13 07:02:29 +00:00
break ;
2007-04-16 12:32:48 +00:00
case XML_SCH_CONTEXT_STOCK_WITH_VOLUME :
case XML_SCH_CONTEXT_LINES_USED :
// note this avoids export of the properties in OASIS format,
// but also for the OOo XML Flat format (used by binfilter),
// because there, the transformation to OOo is done after the
// complete export of the chart in OASIS format.
2014-12-28 14:22:51 +02:00
if ( mrExport . getExportFlags ( ) & SvXMLExportFlags : : OASIS )
2007-04-16 12:32:48 +00:00
property - > mnIndex = - 1 ;
break ;
2000-12-09 14:59:31 +00:00
}
if ( bCheckAuto )
{
if ( rPropSet . is ( ) )
{
try
{
2014-04-07 16:42:18 +02:00
bool bAuto = false ;
2000-12-09 14:59:31 +00:00
uno : : Any aAny = rPropSet - > getPropertyValue ( aAutoPropName ) ;
aAny > > = bAuto ;
if ( bAuto )
property - > mnIndex = - 1 ;
}
2011-06-16 00:26:29 +01:00
catch ( const beans : : UnknownPropertyException & )
2000-12-09 14:59:31 +00:00
{
}
}
2013-09-17 23:22:55 +09:00
bCheckAuto = false ;
2000-09-18 16:07:07 +00:00
}
}
2000-12-05 22:05:47 +00:00
2013-09-04 15:35:18 +01:00
SvXMLExportPropertyMapper : : ContextFilter ( bEnableFoFontFamily , rProperties , rPropSet ) ;
2000-09-18 16:07:07 +00:00
}
void XMLChartExportPropertyMapper : : handleElementItem (
2001-10-25 19:57:03 +00:00
SvXMLExport & rExport ,
2014-12-25 17:43:19 +02:00
const XMLPropertyState & rProperty , SvXmlExportFlags nFlags ,
2000-10-19 13:25:20 +00:00
const : : std : : vector < XMLPropertyState > * pProperties ,
sal_uInt32 nIdx ) const
2000-09-18 16:07:07 +00:00
{
2001-08-14 12:09:38 +00:00
switch ( getPropertySetMapper ( ) - > GetEntryContextId ( rProperty . mnIndex ) )
{
case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE :
{
2013-04-07 12:06:47 +02:00
OUString aURLStr ;
2001-08-14 12:09:38 +00:00
rProperty . maValue > > = aURLStr ;
// export as XLink reference into the package
// if embedding is off
2013-04-07 12:06:47 +02:00
OUString sTempURL ( mrExport . AddEmbeddedGraphicObject ( aURLStr ) ) ;
2012-01-25 17:00:07 -02:00
if ( ! sTempURL . isEmpty ( ) )
2001-08-14 12:09:38 +00:00
{
mrExport . AddAttribute ( XML_NAMESPACE_XLINK , XML_HREF , sTempURL ) ;
}
{
sal_uInt32 nPropIndex = rProperty . mnIndex ;
// this is the element that has to live until the next statement
SvXMLElementExport aElem ( mrExport ,
getPropertySetMapper ( ) - > GetEntryNameSpace ( nPropIndex ) ,
getPropertySetMapper ( ) - > GetEntryXMLName ( nPropIndex ) ,
2014-03-28 16:28:51 +02:00
true , true ) ;
2001-08-14 12:09:38 +00:00
// export as Base64 embedded graphic
// if embedding is on
2012-01-25 17:00:07 -02:00
if ( ! aURLStr . isEmpty ( ) )
2001-08-14 12:09:38 +00:00
mrExport . AddEmbeddedGraphicObjectAsBase64 ( aURLStr ) ;
}
}
break ;
2007-10-22 15:32:28 +00:00
case XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR :
{
2013-04-07 12:06:47 +02:00
OUString aSeparator ;
2007-10-22 15:32:28 +00:00
rProperty . maValue > > = aSeparator ;
2012-01-25 17:00:07 -02:00
if ( ! aSeparator . isEmpty ( ) )
2007-10-22 15:32:28 +00:00
{
sal_uInt32 nPropIndex = rProperty . mnIndex ;
SvXMLElementExport aElem ( mrExport ,
getPropertySetMapper ( ) - > GetEntryNameSpace ( nPropIndex ) ,
getPropertySetMapper ( ) - > GetEntryXMLName ( nPropIndex ) ,
2014-03-28 16:28:51 +02:00
true , true ) ;
2007-10-22 15:32:28 +00:00
SchXMLTools : : exportText ( mrExport , aSeparator , true ) ;
}
}
break ;
2001-08-14 12:09:38 +00:00
default :
// call parent
2001-10-25 19:57:03 +00:00
SvXMLExportPropertyMapper : : handleElementItem ( rExport , rProperty ,
nFlags , pProperties , nIdx ) ;
2001-08-14 12:09:38 +00:00
break ;
}
2000-09-18 16:07:07 +00:00
}
2013-04-22 10:22:42 +02:00
namespace {
OUString convertRange ( const OUString & rRange , const uno : : Reference < chart2 : : XChartDocument > & xDoc )
{
OUString aResult = rRange ;
if ( ! xDoc . is ( ) )
return aResult ;
uno : : Reference < chart2 : : data : : XRangeXMLConversion > xConversion (
xDoc - > getDataProvider ( ) , uno : : UNO_QUERY ) ;
if ( xConversion . is ( ) )
aResult = xConversion - > convertRangeToXML ( rRange ) ;
return aResult ;
}
}
2000-09-18 16:07:07 +00:00
void XMLChartExportPropertyMapper : : handleSpecialItem (
SvXMLAttributeList & rAttrList , const XMLPropertyState & rProperty ,
2000-10-19 13:25:20 +00:00
const SvXMLUnitConverter & rUnitConverter ,
const SvXMLNamespaceMap & rNamespaceMap ,
const : : std : : vector < XMLPropertyState > * pProperties ,
sal_uInt32 nIdx ) const
2000-09-18 16:07:07 +00:00
{
2013-09-17 23:22:55 +09:00
bool bHandled = false ;
2001-08-10 12:37:45 +00:00
2013-08-16 11:12:04 -04:00
sal_Int32 nContextId = getPropertySetMapper ( ) - > GetEntryContextId ( rProperty . mnIndex ) ;
2000-09-18 16:07:07 +00:00
if ( nContextId )
{
2013-09-17 23:22:55 +09:00
bHandled = true ;
2001-08-10 12:37:45 +00:00
2013-08-16 11:12:04 -04:00
OUString sAttrName = getPropertySetMapper ( ) - > GetEntryXMLName ( rProperty . mnIndex ) ;
sal_uInt16 nNameSpace = getPropertySetMapper ( ) - > GetEntryNameSpace ( rProperty . mnIndex ) ;
2013-04-07 12:06:47 +02:00
OUStringBuffer sValueBuffer ;
OUString sValue ;
2000-09-18 16:07:07 +00:00
sal_Int32 nValue = 0 ;
2013-09-17 23:22:55 +09:00
bool bValue = false ;
2000-09-18 16:07:07 +00:00
switch ( nContextId )
{
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER :
case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER :
2000-09-18 16:07:07 +00:00
rProperty . maValue > > = nValue ;
bValue = ( ( nValue & chart : : ChartAxisMarks : : INNER ) = = chart : : ChartAxisMarks : : INNER ) ;
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertBool ( sValueBuffer , bValue ) ;
2000-09-18 16:07:07 +00:00
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER :
case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER :
2000-09-18 16:07:07 +00:00
rProperty . maValue > > = nValue ;
bValue = ( ( nValue & chart : : ChartAxisMarks : : OUTER ) = = chart : : ChartAxisMarks : : OUTER ) ;
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertBool ( sValueBuffer , bValue ) ;
2000-09-18 16:07:07 +00:00
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION :
2000-09-18 16:07:07 +00:00
{
// convert from 100th degrees to degrees (double)
rProperty . maValue > > = nValue ;
double fVal = ( double ) ( nValue ) / 100.0 ;
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertDouble ( sValueBuffer , fVal ) ;
2000-09-18 16:07:07 +00:00
}
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER :
2000-09-18 16:07:07 +00:00
{
rProperty . maValue > > = nValue ;
if ( ( ( nValue & chart : : ChartDataCaption : : VALUE ) = = chart : : ChartDataCaption : : VALUE ) )
2007-10-22 15:32:28 +00:00
{
2008-06-04 08:47:23 +00:00
if ( ( nValue & chart : : ChartDataCaption : : PERCENT ) = = chart : : ChartDataCaption : : PERCENT )
{
const SvtSaveOptions : : ODFDefaultVersion nCurrentVersion ( SvtSaveOptions ( ) . GetODFDefaultVersion ( ) ) ;
if ( nCurrentVersion < SvtSaveOptions : : ODFVER_012 )
sValueBuffer . append ( GetXMLToken ( XML_PERCENTAGE ) ) ;
else
sValueBuffer . append ( GetXMLToken ( XML_VALUE_AND_PERCENTAGE ) ) ;
}
2007-10-22 15:32:28 +00:00
else
sValueBuffer . append ( GetXMLToken ( XML_VALUE ) ) ;
}
2000-09-18 16:07:07 +00:00
else if ( ( nValue & chart : : ChartDataCaption : : PERCENT ) = = chart : : ChartDataCaption : : PERCENT )
2001-06-29 20:07:26 +00:00
sValueBuffer . append ( GetXMLToken ( XML_PERCENTAGE ) ) ;
2000-09-18 16:07:07 +00:00
else
2001-06-29 20:07:26 +00:00
sValueBuffer . append ( GetXMLToken ( XML_NONE ) ) ;
2000-09-18 16:07:07 +00:00
}
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT :
2000-09-18 16:07:07 +00:00
rProperty . maValue > > = nValue ;
bValue = ( ( nValue & chart : : ChartDataCaption : : TEXT ) = = chart : : ChartDataCaption : : TEXT ) ;
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertBool ( sValueBuffer , bValue ) ;
2000-09-18 16:07:07 +00:00
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL :
2000-09-18 16:07:07 +00:00
rProperty . maValue > > = nValue ;
bValue = ( ( nValue & chart : : ChartDataCaption : : SYMBOL ) = = chart : : ChartDataCaption : : SYMBOL ) ;
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertBool ( sValueBuffer , bValue ) ;
2000-09-18 16:07:07 +00:00
break ;
2001-05-10 11:41:11 +00:00
case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH :
case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT :
{
awt : : Size aSize ;
rProperty . maValue > > = aSize ;
2011-10-11 14:19:09 +02:00
rUnitConverter . convertMeasureToXML ( sValueBuffer ,
2001-05-10 11:41:11 +00:00
nContextId = = XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH
? aSize . Width
: aSize . Height ) ;
}
break ;
2001-05-17 12:24:32 +00:00
2001-08-10 12:37:45 +00:00
case XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT :
{
// just for import
break ;
}
2004-07-13 07:02:29 +00:00
2013-04-22 10:22:42 +02:00
case XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE :
{
OUString aRangeStr ;
rProperty . maValue > > = aRangeStr ;
sValueBuffer . append ( convertRange ( aRangeStr , mxChartDoc ) ) ;
}
break ;
2013-06-05 19:22:57 +02:00
case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE :
{
OUString aServiceName ;
rProperty . maValue > > = aServiceName ;
2013-10-25 17:35:42 +02:00
if ( aServiceName = = " com.sun.star.chart2.LinearRegressionCurve " )
2013-06-05 19:22:57 +02:00
sValueBuffer . append ( GetXMLToken ( XML_LINEAR ) ) ;
2013-10-25 17:35:42 +02:00
else if ( aServiceName = = " com.sun.star.chart2.LogarithmicRegressionCurve " )
2013-06-05 19:22:57 +02:00
sValueBuffer . append ( GetXMLToken ( XML_LOGARITHMIC ) ) ;
2013-10-25 17:35:42 +02:00
else if ( aServiceName = = " com.sun.star.chart2.ExponentialRegressionCurve " )
2013-06-05 19:22:57 +02:00
sValueBuffer . append ( GetXMLToken ( XML_EXPONENTIAL ) ) ;
2013-10-25 17:35:42 +02:00
else if ( aServiceName = = " com.sun.star.chart2.PotentialRegressionCurve " )
2013-06-05 19:22:57 +02:00
sValueBuffer . append ( GetXMLToken ( XML_POWER ) ) ;
2013-10-25 17:35:42 +02:00
else if ( aServiceName = = " com.sun.star.chart2.PolynomialRegressionCurve " )
2013-06-05 19:22:57 +02:00
sValueBuffer . append ( GetXMLToken ( XML_POLYNOMIAL ) ) ;
2013-10-25 17:35:42 +02:00
else if ( aServiceName = = " com.sun.star.chart2.MovingAverageRegressionCurve " )
2013-06-05 19:22:57 +02:00
sValueBuffer . append ( GetXMLToken ( XML_MOVING_AVERAGE ) ) ;
}
break ;
2013-04-22 10:22:42 +02:00
2001-08-10 12:37:45 +00:00
default :
2013-09-17 23:22:55 +09:00
bHandled = false ;
2001-08-10 12:37:45 +00:00
break ;
2000-09-18 16:07:07 +00:00
}
2001-08-10 12:37:45 +00:00
2013-06-18 19:53:19 +02:00
if ( ! sValueBuffer . isEmpty ( ) )
2000-12-09 14:59:31 +00:00
{
sValue = sValueBuffer . makeStringAndClear ( ) ;
sAttrName = rNamespaceMap . GetQNameByKey ( nNameSpace , sAttrName ) ;
2003-03-27 17:21:03 +00:00
rAttrList . AddAttribute ( sAttrName , sValue ) ;
2000-12-09 14:59:31 +00:00
}
2000-09-18 16:07:07 +00:00
}
2001-08-10 12:37:45 +00:00
if ( ! bHandled )
2000-09-18 16:07:07 +00:00
{
// call parent
2000-10-19 13:25:20 +00:00
SvXMLExportPropertyMapper : : handleSpecialItem ( rAttrList , rProperty , rUnitConverter , rNamespaceMap , pProperties , nIdx ) ;
2000-09-18 16:07:07 +00:00
}
}
2016-04-11 16:05:03 +02:00
void XMLChartExportPropertyMapper : : setChartDoc ( const uno : : Reference < chart2 : : XChartDocument > & xChartDoc )
2013-04-22 10:22:42 +02:00
{
mxChartDoc = xChartDoc ;
}
2014-06-30 09:53:06 +02:00
XMLChartImportPropertyMapper : : XMLChartImportPropertyMapper ( const rtl : : Reference < XMLPropertySetMapper > & rMapper ,
2006-06-19 17:00:40 +00:00
const SvXMLImport & _rImport ) :
SvXMLImportPropertyMapper ( rMapper , const_cast < SvXMLImport & > ( _rImport ) ) ,
mrImport ( const_cast < SvXMLImport & > ( _rImport ) )
2000-09-18 16:07:07 +00:00
{
2001-01-11 16:00:38 +00:00
// chain shape mapper for drawing properties
// give an empty model. It is only used for numbering rules that don't exist in chart
uno : : Reference < frame : : XModel > xEmptyModel ;
2002-02-22 10:33:00 +00:00
ChainImportMapper ( XMLShapeImportHelper : : CreateShapePropMapper ( xEmptyModel , mrImport ) ) ;
2001-06-01 11:35:30 +00:00
2008-11-26 15:19:48 +00:00
//#i14365# save and load writing-mode for chart elements
//The property TextWritingMode is mapped wrongly in the underlying draw mapper, but for draw it is necessary
//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')
sal_Int32 nUnwantedWrongEntry = maPropMapper - > FindEntryIndex ( " TextWritingMode " , XML_NAMESPACE_STYLE , GetXMLToken ( XML_WRITING_MODE ) ) ;
maPropMapper - > RemoveEntry ( nUnwantedWrongEntry ) ;
2001-06-15 10:08:42 +00:00
// do not chain text properties: on import this is done by shape mapper
// to import old documents
2000-09-18 16:07:07 +00:00
}
XMLChartImportPropertyMapper : : ~ XMLChartImportPropertyMapper ( )
{
}
2010-10-04 15:36:52 +01:00
bool XMLChartImportPropertyMapper : : handleSpecialItem (
2000-09-18 16:07:07 +00:00
XMLPropertyState & rProperty ,
: : std : : vector < XMLPropertyState > & rProperties ,
2013-04-07 12:06:47 +02:00
const OUString & rValue ,
2000-09-18 16:07:07 +00:00
const SvXMLUnitConverter & rUnitConverter ,
const SvXMLNamespaceMap & rNamespaceMap ) const
{
2000-11-27 08:09:12 +00:00
sal_Int32 nContextId = maPropMapper - > GetEntryContextId ( rProperty . mnIndex ) ;
2013-09-17 23:22:55 +09:00
bool bRet = ( nContextId ! = 0 ) ;
2000-11-27 08:09:12 +00:00
if ( nContextId )
{
sal_Int32 nValue = 0 ;
2010-10-04 15:36:52 +01:00
bool bValue = false ;
2000-11-27 08:09:12 +00:00
switch ( nContextId )
{
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER :
case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER :
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertBool ( bValue , rValue ) ;
2000-11-27 08:09:12 +00:00
// modify old value
rProperty . maValue > > = nValue ;
if ( bValue )
SCH_XML_SETFLAG ( nValue , chart : : ChartAxisMarks : : INNER ) ;
else
SCH_XML_UNSETFLAG ( nValue , chart : : ChartAxisMarks : : INNER ) ;
rProperty . maValue < < = nValue ;
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER :
case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER :
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertBool ( bValue , rValue ) ;
2000-11-27 08:09:12 +00:00
// modify old value
rProperty . maValue > > = nValue ;
if ( bValue )
SCH_XML_SETFLAG ( nValue , chart : : ChartAxisMarks : : OUTER ) ;
else
SCH_XML_UNSETFLAG ( nValue , chart : : ChartAxisMarks : : OUTER ) ;
rProperty . maValue < < = nValue ;
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION :
2000-11-27 08:09:12 +00:00
{
// convert from degrees (double) to 100th degrees (integer)
double fVal ;
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertDouble ( fVal , rValue ) ;
2000-11-27 08:09:12 +00:00
nValue = ( sal_Int32 ) ( fVal * 100.0 ) ;
rProperty . maValue < < = nValue ;
}
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER :
2000-11-27 08:09:12 +00:00
{
// modify old value
rProperty . maValue > > = nValue ;
2001-06-29 20:07:26 +00:00
if ( IsXMLToken ( rValue , XML_NONE ) )
2000-11-27 08:09:12 +00:00
SCH_XML_UNSETFLAG ( nValue , chart : : ChartDataCaption : : VALUE | chart : : ChartDataCaption : : PERCENT ) ;
2007-10-22 15:32:28 +00:00
else if ( IsXMLToken ( rValue , XML_VALUE_AND_PERCENTAGE ) )
SCH_XML_SETFLAG ( nValue , chart : : ChartDataCaption : : VALUE | chart : : ChartDataCaption : : PERCENT ) ;
2001-06-29 20:07:26 +00:00
else if ( IsXMLToken ( rValue , XML_VALUE ) )
2000-11-27 08:09:12 +00:00
SCH_XML_SETFLAG ( nValue , chart : : ChartDataCaption : : VALUE ) ;
2001-06-29 20:07:26 +00:00
else // must be XML_PERCENTAGE
2000-11-27 08:09:12 +00:00
SCH_XML_SETFLAG ( nValue , chart : : ChartDataCaption : : PERCENT ) ;
rProperty . maValue < < = nValue ;
}
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT :
2000-11-27 08:09:12 +00:00
rProperty . maValue > > = nValue ;
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertBool ( bValue , rValue ) ;
2000-11-27 08:09:12 +00:00
if ( bValue )
SCH_XML_SETFLAG ( nValue , chart : : ChartDataCaption : : TEXT ) ;
else
SCH_XML_UNSETFLAG ( nValue , chart : : ChartDataCaption : : TEXT ) ;
rProperty . maValue < < = nValue ;
break ;
2001-01-11 16:00:38 +00:00
case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL :
2000-11-27 08:09:12 +00:00
rProperty . maValue > > = nValue ;
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
: : sax : : Converter : : convertBool ( bValue , rValue ) ;
2000-11-27 08:09:12 +00:00
if ( bValue )
SCH_XML_SETFLAG ( nValue , chart : : ChartDataCaption : : SYMBOL ) ;
else
SCH_XML_UNSETFLAG ( nValue , chart : : ChartDataCaption : : SYMBOL ) ;
rProperty . maValue < < = nValue ;
break ;
2001-05-10 11:41:11 +00:00
case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH :
case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT :
{
awt : : Size aSize ;
rProperty . maValue > > = aSize ;
2011-10-11 14:19:09 +02:00
rUnitConverter . convertMeasureToCore (
( nContextId = = XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH )
2001-05-10 11:41:11 +00:00
? aSize . Width
: aSize . Height ,
rValue ) ;
rProperty . maValue < < = aSize ;
}
break ;
2001-08-14 12:09:38 +00:00
2013-04-22 10:22:42 +02:00
case XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE :
{
rProperty . maValue < < = rValue ;
}
break ;
2001-08-14 12:09:38 +00:00
// deprecated from 6.0 beta on
2001-05-11 17:17:56 +00:00
case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME :
2014-03-31 09:05:32 +02:00
rProperty . maValue < < = mrImport . ResolveGraphicObjectURL ( rValue , false ) ;
2001-05-11 17:17:56 +00:00
break ;
2001-08-14 12:09:38 +00:00
2013-06-05 19:22:57 +02:00
case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE :
{
if ( IsXMLToken ( rValue , XML_LINEAR ) )
rProperty . maValue < < = OUString ( " com.sun.star.chart2.LinearRegressionCurve " ) ;
else if ( IsXMLToken ( rValue , XML_LOGARITHMIC ) )
rProperty . maValue < < = OUString ( " com.sun.star.chart2.LogarithmicRegressionCurve " ) ;
else if ( IsXMLToken ( rValue , XML_EXPONENTIAL ) )
rProperty . maValue < < = OUString ( " com.sun.star.chart2.ExponentialRegressionCurve " ) ;
else if ( IsXMLToken ( rValue , XML_POWER ) )
rProperty . maValue < < = OUString ( " com.sun.star.chart2.PotentialRegressionCurve " ) ;
else if ( IsXMLToken ( rValue , XML_POLYNOMIAL ) )
rProperty . maValue < < = OUString ( " com.sun.star.chart2.PolynomialRegressionCurve " ) ;
else if ( IsXMLToken ( rValue , XML_MOVING_AVERAGE ) )
rProperty . maValue < < = OUString ( " com.sun.star.chart2.MovingAverageRegressionCurve " ) ;
}
break ;
2000-11-27 08:09:12 +00:00
default :
2013-09-17 23:22:55 +09:00
bRet = false ;
2000-11-27 08:09:12 +00:00
break ;
}
}
2001-08-10 12:37:45 +00:00
// if we didn't handle it, the parent should
if ( ! bRet )
2000-11-27 08:09:12 +00:00
{
// call parent
bRet = SvXMLImportPropertyMapper : : handleSpecialItem ( rProperty , rProperties , rValue , rUnitConverter , rNamespaceMap ) ;
}
return bRet ;
2000-09-18 16:07:07 +00:00
}
2006-06-19 17:00:40 +00:00
void XMLChartImportPropertyMapper : : finished ( : : std : : vector < XMLPropertyState > & /*rProperties*/ , sal_Int32 /*nStartIndex*/ , sal_Int32 /*nEndIndex*/ ) const
2000-09-18 16:07:07 +00:00
{
}
2010-10-12 15:53:47 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */