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