Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / xmloff / source / chart / PropertyMaps.cxx
blob30ff2a6d11600b2bf6acd34995a04e0f61a9cb2e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 // include PropertyMap.hxx with this define
21 // to create the maps
22 #ifndef INCLUDED_XMLOFF_SOURCE_CHART_PROPERTYMAP_HXX
23 #define XML_SCH_CREATE_GLOBAL_MAPS
24 #include "PropertyMap.hxx"
25 #undef XML_SCH_CREATE_GLOBAL_MAPS
26 #endif
28 #include <sax/tools/converter.hxx>
30 #include "SchXMLTools.hxx"
31 #include "XMLChartPropertySetMapper.hxx"
32 #include "XMLErrorIndicatorPropertyHdl.hxx"
33 #include "XMLErrorBarStylePropertyHdl.hxx"
34 #include "XMLTextOrientationHdl.hxx"
35 #include "XMLSymbolTypePropertyHdl.hxx"
36 #include "XMLAxisPositionPropertyHdl.hxx"
37 #include "../draw/propimp0.hxx"
39 #include <xmloff/EnumPropertyHdl.hxx>
40 #include <xmloff/XMLConstantsPropertyHandler.hxx>
41 #include <xmloff/attrlist.hxx>
42 #include <xmloff/nmspmap.hxx>
43 #include <xmloff/xmluconv.hxx>
44 #include <xmloff/shapeimport.hxx>
45 #include <xmloff/NamedBoolPropertyHdl.hxx>
46 #include <xmloff/xmlexp.hxx>
47 #include <xmloff/xmltoken.hxx>
49 #include <com/sun/star/drawing/LineStyle.hpp>
50 #include <com/sun/star/drawing/FillStyle.hpp>
51 #include <com/sun/star/drawing/LineJoint.hpp>
52 #include <com/sun/star/chart/ChartAxisMarks.hpp>
53 #include <com/sun/star/chart/ChartDataCaption.hpp>
54 #include <com/sun/star/chart/ChartSymbolType.hpp>
55 #include <com/sun/star/chart/ChartDataRowSource.hpp>
56 #include <com/sun/star/chart/ChartAxisPosition.hpp>
57 #include <com/sun/star/chart2/XChartDocument.hpp>
58 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
60 #include <comphelper/extract.hxx>
61 #include <rtl/ustrbuf.hxx>
62 #include <rtl/math.hxx>
64 #define SCH_XML_SETFLAG( status, flag ) (status)|= (flag)
65 #define SCH_XML_UNSETFLAG( status, flag ) (status) = ((status) | (flag)) - (flag)
67 using namespace com::sun::star;
68 using namespace ::xmloff::token;
70 namespace {
72 SvXMLEnumMapEntry const aLineStyleMap[] =
74 { XML_NONE, drawing::LineStyle_NONE },
75 { XML_SOLID, drawing::LineStyle_SOLID },
76 { XML_DASH, drawing::LineStyle_DASH },
77 { XML_TOKEN_INVALID, 0 }
82 // the following class implementations are in this file:
84 // * XMLChartPropHdlFactory
85 // * XMLChartPropertySetMapper
86 // * XMLChartExportPropertyMapper
87 // * XMLChartImportPropertyMapper
88 // * SchXMLStyleExport
90 XMLChartPropHdlFactory::~XMLChartPropHdlFactory()
94 const XMLPropertyHandler* XMLChartPropHdlFactory::GetPropertyHandler( sal_Int32 nType ) const
96 const XMLPropertyHandler* pHdl = XMLPropertyHandlerFactory::GetPropertyHandler( nType );
97 if( ! pHdl )
99 switch( nType )
101 case XML_SCH_TYPE_AXIS_POSITION:
102 pHdl = new XMLAxisPositionPropertyHdl( false );
103 break;
104 case XML_SCH_TYPE_AXIS_POSITION_VALUE:
105 pHdl = new XMLAxisPositionPropertyHdl( true );
106 break;
108 case XML_SCH_TYPE_AXIS_LABEL_POSITION:
109 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisLabelPositionEnumMap,
110 cppu::UnoType<chart::ChartAxisLabelPosition>::get());
111 break;
113 case XML_SCH_TYPE_TICK_MARK_POSITION:
114 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisMarkPositionEnumMap,
115 cppu::UnoType<chart::ChartAxisMarkPosition>::get());
116 break;
118 case XML_SCH_TYPE_AXIS_ARRANGEMENT:
119 pHdl = new XMLEnumPropertyHdl( aXMLChartAxisArrangementEnumMap,
120 cppu::UnoType<chart::ChartAxisArrangeOrderType>::get());
121 break;
123 case XML_SCH_TYPE_ERROR_BAR_STYLE:
124 // here we have a constant rather than an enum
125 pHdl = new XMLErrorBarStylePropertyHdl( aXMLChartErrorBarStyleEnumMap,
126 ::cppu::UnoType<sal_Int32>::get() );
127 break;
129 case XML_SCH_TYPE_ERROR_INDICATOR_LOWER:
130 pHdl = new XMLErrorIndicatorPropertyHdl( false );
131 break;
132 case XML_SCH_TYPE_ERROR_INDICATOR_UPPER:
133 pHdl = new XMLErrorIndicatorPropertyHdl( true );
134 break;
136 case XML_SCH_TYPE_SOLID_TYPE:
137 // here we have a constant rather than an enum
138 pHdl = new XMLEnumPropertyHdl( aXMLChartSolidTypeEnumMap,
139 ::cppu::UnoType<sal_Int32>::get() );
140 break;
141 case XML_SCH_TYPE_LABEL_PLACEMENT_TYPE:
142 // here we have a constant rather than an enum
143 pHdl = new XMLEnumPropertyHdl( aXMLChartDataLabelPlacementEnumMap,
144 ::cppu::UnoType<sal_Int32>::get() );
145 break;
146 case XML_SCH_TYPE_DATAROWSOURCE:
147 pHdl = new XMLEnumPropertyHdl( aXMLChartDataRowSourceTypeEnumMap,
148 cppu::UnoType<chart::ChartDataRowSource>::get());
149 break;
150 case XML_SCH_TYPE_TEXT_ORIENTATION:
151 pHdl = new XMLTextOrientationHdl();
152 break;
154 case XML_SCH_TYPE_INTERPOLATION:
155 pHdl = new XMLEnumPropertyHdl( aXMLChartInterpolationTypeEnumMap,
156 ::cppu::UnoType<sal_Int32>::get() );
157 break;
158 case XML_SCH_TYPE_SYMBOL_TYPE:
159 pHdl = new XMLSymbolTypePropertyHdl( false );
160 break;
162 case XML_SCH_TYPE_NAMED_SYMBOL:
163 pHdl = new XMLSymbolTypePropertyHdl( true );
164 break;
166 case XML_SCH_TYPE_MISSING_VALUE_TREATMENT:
167 pHdl = new XMLEnumPropertyHdl( aXMLChartMissingValueTreatmentEnumMap,
168 ::cppu::UnoType<sal_Int32>::get() );
169 break;
170 case XML_SCH_TYPE_LABEL_BORDER_STYLE:
171 pHdl = new XMLEnumPropertyHdl(aLineStyleMap, cppu::UnoType<drawing::LineStyle>::get());
172 break;
173 case XML_SCH_TYPE_LABEL_BORDER_OPACITY:
174 pHdl = new XMLOpacityPropertyHdl(nullptr);
175 break;
176 default:
179 if( pHdl )
180 PutHdlCache( nType, pHdl );
183 return pHdl;
186 XMLChartPropertySetMapper::XMLChartPropertySetMapper( bool bForExport ) :
187 XMLPropertySetMapper( aXMLChartPropMap, new XMLChartPropHdlFactory, bForExport )
191 XMLChartPropertySetMapper::~XMLChartPropertySetMapper()
195 XMLChartExportPropertyMapper::XMLChartExportPropertyMapper( const rtl::Reference< XMLPropertySetMapper >& rMapper,
196 SvXMLExport& rExport) :
197 SvXMLExportPropertyMapper( rMapper ),
198 mrExport( rExport )
200 // chain draw properties
201 ChainExportMapper( XMLShapeExport::CreateShapePropMapper( rExport ));
203 // chain text properties
204 ChainExportMapper( XMLTextParagraphExport::CreateParaExtPropMapper( rExport ));
207 XMLChartExportPropertyMapper::~XMLChartExportPropertyMapper()
211 void XMLChartExportPropertyMapper::ContextFilter(
212 bool bEnableFoFontFamily,
213 std::vector< XMLPropertyState >& rProperties,
214 const uno::Reference< beans::XPropertySet >& rPropSet ) const
216 OUString aAutoPropName;
217 bool bCheckAuto = false;
219 // filter properties
220 for( std::vector< XMLPropertyState >::iterator property = rProperties.begin();
221 property != rProperties.end();
222 ++property )
224 // find properties with context
225 // to prevent writing this property set mnIndex member to -1
226 switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ))
228 // if Auto... is set the corresponding properties mustn't be exported
229 case XML_SCH_CONTEXT_MIN:
230 bCheckAuto = true;
231 aAutoPropName = "AutoMin";
232 break;
233 case XML_SCH_CONTEXT_MAX:
234 bCheckAuto = true;
235 aAutoPropName = "AutoMax";
236 break;
237 case XML_SCH_CONTEXT_STEP_MAIN:
238 bCheckAuto = true;
239 aAutoPropName = "AutoStepMain";
240 break;
241 case XML_SCH_CONTEXT_STEP_HELP_COUNT:
242 bCheckAuto = true;
243 aAutoPropName = "AutoStepHelp";
244 break;
246 case XML_SCH_CONTEXT_ORIGIN:
247 bCheckAuto = true;
248 aAutoPropName = "AutoOrigin";
249 break;
251 // the following property is deprecated
252 // element-item symbol-image is used now
253 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
254 property->mnIndex = -1;
255 break;
257 case XML_SCH_CONTEXT_STOCK_WITH_VOLUME:
258 case XML_SCH_CONTEXT_LINES_USED:
259 // note this avoids export of the properties in OASIS format,
260 // but also for the OOo XML Flat format (used by binfilter),
261 // because there, the transformation to OOo is done after the
262 // complete export of the chart in OASIS format.
263 if( mrExport.getExportFlags() & SvXMLExportFlags::OASIS )
264 property->mnIndex = -1;
265 break;
268 if( bCheckAuto )
270 if( rPropSet.is())
274 bool bAuto = false;
275 uno::Any aAny = rPropSet->getPropertyValue( aAutoPropName );
276 aAny >>= bAuto;
277 if( bAuto )
278 property->mnIndex = -1;
280 catch(const beans::UnknownPropertyException&)
284 bCheckAuto = false;
288 SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rProperties, rPropSet);
291 void XMLChartExportPropertyMapper::handleElementItem(
292 SvXMLExport& rExport,
293 const XMLPropertyState& rProperty, SvXmlExportFlags nFlags,
294 const ::std::vector< XMLPropertyState > *pProperties,
295 sal_uInt32 nIdx ) const
297 switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ))
299 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE:
301 OUString aURLStr;
302 rProperty.maValue >>= aURLStr;
304 // export as XLink reference into the package
305 // if embedding is off
306 OUString sTempURL( mrExport.AddEmbeddedGraphicObject( aURLStr ));
307 if( !sTempURL.isEmpty() )
309 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sTempURL );
313 sal_uInt32 nPropIndex = rProperty.mnIndex;
314 // this is the element that has to live until the next statement
315 SvXMLElementExport aElem( mrExport,
316 getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
317 getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
318 true, true );
320 // export as Base64 embedded graphic
321 // if embedding is on
322 if( !aURLStr.isEmpty())
323 mrExport.AddEmbeddedGraphicObjectAsBase64( aURLStr );
326 break;
328 case XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR:
330 OUString aSeparator;
331 rProperty.maValue >>= aSeparator;
333 if( !aSeparator.isEmpty() )
335 sal_uInt32 nPropIndex = rProperty.mnIndex;
336 SvXMLElementExport aElem( mrExport,
337 getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
338 getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
339 true, true );
341 SchXMLTools::exportText( mrExport, aSeparator, true );
344 break;
346 default:
347 // call parent
348 SvXMLExportPropertyMapper::handleElementItem( rExport, rProperty,
349 nFlags, pProperties, nIdx );
350 break;
354 namespace {
356 OUString convertRange( const OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
358 OUString aResult = rRange;
359 if( !xDoc.is() )
360 return aResult;
361 uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
362 xDoc->getDataProvider(), uno::UNO_QUERY );
365 if( xConversion.is())
366 aResult = xConversion->convertRangeToXML( rRange );
368 catch (css::lang::IllegalArgumentException&)
372 return aResult;
377 void XMLChartExportPropertyMapper::handleSpecialItem(
378 SvXMLAttributeList& rAttrList, const XMLPropertyState& rProperty,
379 const SvXMLUnitConverter& rUnitConverter,
380 const SvXMLNamespaceMap& rNamespaceMap,
381 const ::std::vector< XMLPropertyState > *pProperties,
382 sal_uInt32 nIdx ) const
384 bool bHandled = false;
386 sal_Int32 nContextId = getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex );
388 if( nContextId )
390 bHandled = true;
392 OUString sAttrName = getPropertySetMapper()->GetEntryXMLName( rProperty.mnIndex );
393 sal_uInt16 nNameSpace = getPropertySetMapper()->GetEntryNameSpace( rProperty.mnIndex );
394 OUStringBuffer sValueBuffer;
395 OUString sValue;
397 sal_Int32 nValue = 0;
398 bool bValue = false;
400 switch( nContextId )
402 case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
403 case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
404 rProperty.maValue >>= nValue;
405 bValue = (( nValue & chart::ChartAxisMarks::INNER ) == chart::ChartAxisMarks::INNER );
406 ::sax::Converter::convertBool( sValueBuffer, bValue );
407 break;
408 case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
409 case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
410 rProperty.maValue >>= nValue;
411 bValue = (( nValue & chart::ChartAxisMarks::OUTER ) == chart::ChartAxisMarks::OUTER );
412 ::sax::Converter::convertBool( sValueBuffer, bValue );
413 break;
414 case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
416 // convert from 100th degrees to degrees (double)
417 rProperty.maValue >>= nValue;
418 double fVal = (double)(nValue) / 100.0;
419 ::sax::Converter::convertDouble( sValueBuffer, fVal );
421 break;
422 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
424 rProperty.maValue >>= nValue;
425 if((( nValue & chart::ChartDataCaption::VALUE ) == chart::ChartDataCaption::VALUE ))
427 if( ( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
429 const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
430 if( nCurrentVersion < SvtSaveOptions::ODFVER_012 )
431 sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
432 else
433 sValueBuffer.append( GetXMLToken( XML_VALUE_AND_PERCENTAGE ));
435 else
436 sValueBuffer.append( GetXMLToken( XML_VALUE ));
438 else if(( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
439 sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
440 else
441 sValueBuffer.append( GetXMLToken( XML_NONE ));
443 break;
444 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
445 rProperty.maValue >>= nValue;
446 bValue = (( nValue & chart::ChartDataCaption::TEXT ) == chart::ChartDataCaption::TEXT );
447 ::sax::Converter::convertBool( sValueBuffer, bValue );
448 break;
449 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
450 rProperty.maValue >>= nValue;
451 bValue = (( nValue & chart::ChartDataCaption::SYMBOL ) == chart::ChartDataCaption::SYMBOL );
452 ::sax::Converter::convertBool( sValueBuffer, bValue );
453 break;
454 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
455 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
457 awt::Size aSize;
458 rProperty.maValue >>= aSize;
459 rUnitConverter.convertMeasureToXML( sValueBuffer,
460 nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH
461 ? aSize.Width
462 : aSize.Height );
464 break;
466 case XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT:
468 // just for import
469 break;
472 case XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE:
474 OUString aRangeStr;
475 rProperty.maValue >>= aRangeStr;
476 sValueBuffer.append(convertRange(aRangeStr, mxChartDoc));
478 break;
479 case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE:
481 OUString aServiceName;
482 rProperty.maValue >>= aServiceName;
483 if (aServiceName == "com.sun.star.chart2.LinearRegressionCurve")
484 sValueBuffer.append( GetXMLToken( XML_LINEAR ));
485 else if (aServiceName == "com.sun.star.chart2.LogarithmicRegressionCurve")
486 sValueBuffer.append( GetXMLToken( XML_LOGARITHMIC ));
487 else if (aServiceName == "com.sun.star.chart2.ExponentialRegressionCurve")
488 sValueBuffer.append( GetXMLToken( XML_EXPONENTIAL ));
489 else if (aServiceName == "com.sun.star.chart2.PotentialRegressionCurve")
490 sValueBuffer.append( GetXMLToken( XML_POWER ));
491 else if (aServiceName == "com.sun.star.chart2.PolynomialRegressionCurve")
492 sValueBuffer.append( GetXMLToken( XML_POLYNOMIAL ));
493 else if (aServiceName == "com.sun.star.chart2.MovingAverageRegressionCurve")
494 sValueBuffer.append( GetXMLToken( XML_MOVING_AVERAGE ));
496 break;
498 default:
499 bHandled = false;
500 break;
503 if( !sValueBuffer.isEmpty())
505 sValue = sValueBuffer.makeStringAndClear();
506 sAttrName = rNamespaceMap.GetQNameByKey( nNameSpace, sAttrName );
507 rAttrList.AddAttribute( sAttrName, sValue );
511 if( !bHandled )
513 // call parent
514 SvXMLExportPropertyMapper::handleSpecialItem( rAttrList, rProperty, rUnitConverter, rNamespaceMap, pProperties, nIdx );
518 void XMLChartExportPropertyMapper::setChartDoc( const uno::Reference< chart2::XChartDocument >& xChartDoc )
520 mxChartDoc = xChartDoc;
523 XMLChartImportPropertyMapper::XMLChartImportPropertyMapper( const rtl::Reference< XMLPropertySetMapper >& rMapper,
524 const SvXMLImport& _rImport ) :
525 SvXMLImportPropertyMapper( rMapper, const_cast< SvXMLImport & >( _rImport )),
526 mrImport( const_cast< SvXMLImport & > ( _rImport ))
528 // chain shape mapper for drawing properties
530 // give an empty model. It is only used for numbering rules that don't exist in chart
531 uno::Reference< frame::XModel > xEmptyModel;
532 ChainImportMapper( XMLShapeImportHelper::CreateShapePropMapper( xEmptyModel, mrImport ));
534 //#i14365# save and load writing-mode for chart elements
535 //The property TextWritingMode is mapped wrongly in the underlying draw mapper, but for draw it is necessary
536 //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')
537 sal_Int32 nUnwantedWrongEntry = maPropMapper->FindEntryIndex( "TextWritingMode", XML_NAMESPACE_STYLE, GetXMLToken(XML_WRITING_MODE) );
538 maPropMapper->RemoveEntry(nUnwantedWrongEntry);
540 // do not chain text properties: on import this is done by shape mapper
541 // to import old documents
544 XMLChartImportPropertyMapper::~XMLChartImportPropertyMapper()
548 bool XMLChartImportPropertyMapper::handleSpecialItem(
549 XMLPropertyState& rProperty,
550 ::std::vector< XMLPropertyState >& rProperties,
551 const OUString& rValue,
552 const SvXMLUnitConverter& rUnitConverter,
553 const SvXMLNamespaceMap& rNamespaceMap ) const
555 sal_Int32 nContextId = maPropMapper->GetEntryContextId( rProperty.mnIndex );
556 bool bRet = (nContextId != 0);
558 if( nContextId )
560 sal_Int32 nValue = 0;
561 bool bValue = false;
563 switch( nContextId )
565 case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
566 case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
567 ::sax::Converter::convertBool( bValue, rValue );
568 // modify old value
569 rProperty.maValue >>= nValue;
570 if( bValue )
571 SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::INNER );
572 else
573 SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::INNER );
574 rProperty.maValue <<= nValue;
575 break;
576 case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
577 case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
578 ::sax::Converter::convertBool( bValue, rValue );
579 // modify old value
580 rProperty.maValue >>= nValue;
581 if( bValue )
582 SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::OUTER );
583 else
584 SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::OUTER );
585 rProperty.maValue <<= nValue;
586 break;
587 case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
589 // convert from degrees (double) to 100th degrees (integer)
590 double fVal;
591 ::sax::Converter::convertDouble( fVal, rValue );
592 nValue = (sal_Int32)( fVal * 100.0 );
593 rProperty.maValue <<= nValue;
595 break;
596 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
598 // modify old value
599 rProperty.maValue >>= nValue;
600 if( IsXMLToken( rValue, XML_NONE ))
601 SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
602 else if( IsXMLToken( rValue, XML_VALUE_AND_PERCENTAGE ) )
603 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
604 else if( IsXMLToken( rValue, XML_VALUE ) )
605 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE );
606 else // must be XML_PERCENTAGE
607 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::PERCENT );
608 rProperty.maValue <<= nValue;
610 break;
611 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
612 rProperty.maValue >>= nValue;
613 ::sax::Converter::convertBool( bValue, rValue );
614 if( bValue )
615 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::TEXT );
616 else
617 SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::TEXT );
618 rProperty.maValue <<= nValue;
619 break;
620 case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
621 rProperty.maValue >>= nValue;
622 ::sax::Converter::convertBool( bValue, rValue );
623 if( bValue )
624 SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
625 else
626 SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
627 rProperty.maValue <<= nValue;
628 break;
629 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
630 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
632 awt::Size aSize;
633 rProperty.maValue >>= aSize;
634 rUnitConverter.convertMeasureToCore(
635 (nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH)
636 ? aSize.Width
637 : aSize.Height,
638 rValue );
639 rProperty.maValue <<= aSize;
641 break;
643 case XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE:
645 rProperty.maValue <<= rValue;
647 break;
649 // deprecated from 6.0 beta on
650 case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
651 rProperty.maValue <<= mrImport.ResolveGraphicObjectURL( rValue, false );
652 break;
654 case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE:
656 if (IsXMLToken( rValue, XML_LINEAR ))
657 rProperty.maValue <<= OUString("com.sun.star.chart2.LinearRegressionCurve");
658 else if (IsXMLToken( rValue, XML_LOGARITHMIC))
659 rProperty.maValue <<= OUString("com.sun.star.chart2.LogarithmicRegressionCurve");
660 else if (IsXMLToken( rValue, XML_EXPONENTIAL))
661 rProperty.maValue <<= OUString("com.sun.star.chart2.ExponentialRegressionCurve");
662 else if (IsXMLToken( rValue, XML_POWER))
663 rProperty.maValue <<= OUString("com.sun.star.chart2.PotentialRegressionCurve");
664 else if (IsXMLToken( rValue, XML_POLYNOMIAL))
665 rProperty.maValue <<= OUString("com.sun.star.chart2.PolynomialRegressionCurve");
666 else if (IsXMLToken( rValue, XML_MOVING_AVERAGE))
667 rProperty.maValue <<= OUString("com.sun.star.chart2.MovingAverageRegressionCurve");
669 break;
671 default:
672 bRet = false;
673 break;
677 // if we didn't handle it, the parent should
678 if( !bRet )
680 // call parent
681 bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty, rProperties, rValue, rUnitConverter, rNamespaceMap );
684 return bRet;
687 void XMLChartImportPropertyMapper::finished( ::std::vector< XMLPropertyState >& /*rProperties*/, sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
691 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */