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