Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / xmloff / source / chart / SchXMLPlotAreaContext.cxx
blob04b31d872bad7bdeb92139dfdea3704f5c9d92eb
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 <sax/tools/converter.hxx>
22 #include "SchXMLPlotAreaContext.hxx"
23 #include "SchXMLRegressionCurveObjectContext.hxx"
24 #include "SchXMLImport.hxx"
25 #include "SchXMLAxisContext.hxx"
26 #include "SchXMLSeries2Context.hxx"
27 #include "SchXMLTools.hxx"
29 #include <comphelper/processfactory.hxx>
30 #include <xmloff/xmlnmspe.hxx>
31 #include <xmloff/xmlement.hxx>
32 #include <xmloff/nmspmap.hxx>
33 #include <xmloff/xmluconv.hxx>
34 #include <xmloff/prstylei.hxx>
35 #include <xmloff/xmlstyle.hxx>
36 #include "xexptran.hxx"
38 #include <com/sun/star/awt/Point.hpp>
39 #include <com/sun/star/awt/Size.hpp>
40 #include <com/sun/star/chart/ChartDataRowSource.hpp>
41 #include <com/sun/star/chart/ChartErrorCategory.hpp>
42 #include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
43 #include <com/sun/star/chart/ErrorBarStyle.hpp>
44 #include <com/sun/star/chart/X3DDisplay.hpp>
45 #include <com/sun/star/chart/XStatisticDisplay.hpp>
46 #include <com/sun/star/chart/XDiagramPositioning.hpp>
47 #include <com/sun/star/chart2/RelativePosition.hpp>
48 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
49 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
50 #include <com/sun/star/chart2/data/XDataSink.hpp>
51 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
52 #include <com/sun/star/chart2/data/LabeledDataSequence.hpp>
53 #include <com/sun/star/drawing/CameraGeometry.hpp>
54 #include <com/sun/star/drawing/FillStyle.hpp>
55 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
56 #include <com/sun/star/lang/XServiceInfo.hpp>
57 #include <com/sun/star/util/XStringMapping.hpp>
58 #include <com/sun/star/xml/sax/XAttributeList.hpp>
60 using namespace com::sun::star;
61 using namespace ::xmloff::token;
63 using com::sun::star::uno::Reference;
65 namespace
68 struct lcl_AxisHasCategories : public ::std::unary_function< SchXMLAxis, bool >
70 bool operator() ( const SchXMLAxis & rAxis )
72 return rAxis.bHasCategories;
76 OUString lcl_ConvertRange( const OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
78 OUString aResult = rRange;
79 if(!xDoc.is())
80 return aResult;
81 uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
82 xDoc->getDataProvider(), uno::UNO_QUERY );
83 if( xConversion.is())
84 aResult = xConversion->convertRangeFromXML( rRange );
85 return aResult;
88 } // anonymous namespace
90 SchXML3DSceneAttributesHelper::SchXML3DSceneAttributesHelper( SvXMLImport& rImporter )
91 : SdXML3DSceneAttributesHelper( rImporter )
95 void SchXML3DSceneAttributesHelper::getCameraDefaultFromDiagram( const uno::Reference< chart::XDiagram >& xDiagram )
97 //different defaults for camera geometry necessary to workaround wrong behaviour in old chart
98 //in future make this version dependent if we have versioning (metastream) for ole objects
102 uno::Reference< beans::XPropertySet > xProp( xDiagram, uno::UNO_QUERY );
103 if( xProp.is() )
105 drawing::CameraGeometry aCamGeo;
106 xProp->getPropertyValue("D3DCameraGeometry") >>= aCamGeo;
107 maVRP.setX( aCamGeo.vrp.PositionX );
108 maVRP.setY( aCamGeo.vrp.PositionY );
109 maVRP.setZ( aCamGeo.vrp.PositionZ );
110 maVPN.setX( aCamGeo.vpn.DirectionX );
111 maVPN.setY( aCamGeo.vpn.DirectionY );
112 maVPN.setZ( aCamGeo.vpn.DirectionZ );
113 maVUP.setX( aCamGeo.vup.DirectionX );
114 maVUP.setY( aCamGeo.vup.DirectionY );
115 maVUP.setZ( aCamGeo.vup.DirectionZ );
118 catch( const uno::Exception & rEx )
120 OString aBStr(OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
121 SAL_INFO("xmloff.chart", "Exception caught for property NumberOfLines: " << aBStr);
125 SchXML3DSceneAttributesHelper::~SchXML3DSceneAttributesHelper()
129 SchXMLPlotAreaContext::SchXMLPlotAreaContext(
130 SchXMLImportHelper& rImpHelper,
131 SvXMLImport& rImport, const OUString& rLocalName,
132 const OUString& rXLinkHRefAttributeToIndicateDataProvider,
133 OUString& rCategoriesAddress,
134 OUString& rChartAddress,
135 bool & rbHasRangeAtPlotArea,
136 bool & rAllRangeAddressesAvailable,
137 bool & rColHasLabels,
138 bool & rRowHasLabels,
139 chart::ChartDataRowSource & rDataRowSource,
140 SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles,
141 const OUString& aChartTypeServiceName,
142 tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
143 const awt::Size & rChartSize ) :
144 SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
145 mrImportHelper( rImpHelper ),
146 mrCategoriesAddress( rCategoriesAddress ),
147 mrSeriesDefaultsAndStyles( rSeriesDefaultsAndStyles ),
148 mnNumOfLinesProp( 0 ),
149 mbStockHasVolume( false ),
150 mnSeries( 0 ),
151 m_aGlobalSeriesImportInfo( rAllRangeAddressesAvailable ),
152 maSceneImportHelper( rImport ),
153 m_aOuterPositioning( rImport ),
154 m_aInnerPositioning( rImport ),
155 mbPercentStacked(false),
156 m_bAxisPositionAttributeImported(false),
157 m_rXLinkHRefAttributeToIndicateDataProvider(rXLinkHRefAttributeToIndicateDataProvider),
158 mrChartAddress( rChartAddress ),
159 m_rbHasRangeAtPlotArea( rbHasRangeAtPlotArea ),
160 mrColHasLabels( rColHasLabels ),
161 mrRowHasLabels( rRowHasLabels ),
162 mrDataRowSource( rDataRowSource ),
163 maChartTypeServiceName( aChartTypeServiceName ),
164 mrLSequencesPerIndex( rLSequencesPerIndex ),
165 mbGlobalChartTypeUsedBySeries( false ),
166 maChartSize( rChartSize )
168 m_rbHasRangeAtPlotArea = false;
170 // get Diagram
171 uno::Reference< chart::XChartDocument > xDoc( rImpHelper.GetChartDocument(), uno::UNO_QUERY );
172 if( xDoc.is())
174 mxDiagram = xDoc->getDiagram();
175 mxNewDoc.set( xDoc, uno::UNO_QUERY );
177 maSceneImportHelper.getCameraDefaultFromDiagram( mxDiagram );
179 SAL_WARN_IF( !mxDiagram.is(),"xmloff.chart", "Couldn't get XDiagram" );
181 // turn off all axes initially
182 uno::Any aFalseBool;
183 aFalseBool <<= false;
185 uno::Reference< lang::XServiceInfo > xInfo( mxDiagram, uno::UNO_QUERY );
186 uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
187 if( xInfo.is() &&
188 xProp.is())
192 xProp->setPropertyValue("HasXAxis", aFalseBool );
193 xProp->setPropertyValue("HasXAxisGrid", aFalseBool );
194 xProp->setPropertyValue("HasXAxisDescription", aFalseBool );
195 xProp->setPropertyValue("HasSecondaryXAxis", aFalseBool );
196 xProp->setPropertyValue("HasSecondaryXAxisDescription", aFalseBool );
198 xProp->setPropertyValue("HasYAxis", aFalseBool );
199 xProp->setPropertyValue("HasYAxisGrid", aFalseBool );
200 xProp->setPropertyValue("HasYAxisDescription", aFalseBool );
201 xProp->setPropertyValue("HasSecondaryYAxis", aFalseBool );
202 xProp->setPropertyValue("HasSecondaryYAxisDescription", aFalseBool );
204 xProp->setPropertyValue("HasZAxis", aFalseBool );
205 xProp->setPropertyValue("HasZAxisDescription", aFalseBool );
207 chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS;
208 xProp->setPropertyValue("DataRowSource", uno::Any(eSource) );
210 catch( const beans::UnknownPropertyException & )
212 SAL_WARN("xmloff.chart", "Property required by service not supported" );
217 SchXMLPlotAreaContext::~SchXMLPlotAreaContext()
220 void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
222 // parse attributes
223 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
224 const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetPlotAreaAttrTokenMap();
225 uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
227 for( sal_Int16 i = 0; i < nAttrCount; i++ )
229 OUString sAttrName = xAttrList->getNameByIndex( i );
230 OUString aLocalName;
231 OUString aValue = xAttrList->getValueByIndex( i );
232 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
234 switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
236 case XML_TOK_PA_X:
237 case XML_TOK_PA_Y:
238 case XML_TOK_PA_WIDTH:
239 case XML_TOK_PA_HEIGHT:
240 m_aOuterPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
241 break;
242 case XML_TOK_PA_STYLE_NAME:
243 msAutoStyleName = aValue;
244 break;
245 case XML_TOK_PA_CHART_ADDRESS:
246 mrChartAddress = lcl_ConvertRange( aValue, xNewDoc );
247 // indicator for getting data from the outside
248 m_rbHasRangeAtPlotArea = true;
249 break;
250 case XML_TOK_PA_DS_HAS_LABELS:
252 if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_BOTH )))
253 mrColHasLabels = mrRowHasLabels = true;
254 else if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_ROW )))
255 mrRowHasLabels = true;
256 else if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_COLUMN )))
257 mrColHasLabels = true;
259 break;
260 case XML_TOK_PA_TRANSFORM:
261 case XML_TOK_PA_VRP:
262 case XML_TOK_PA_VPN:
263 case XML_TOK_PA_VUP:
264 case XML_TOK_PA_PROJECTION:
265 case XML_TOK_PA_DISTANCE:
266 case XML_TOK_PA_FOCAL_LENGTH:
267 case XML_TOK_PA_SHADOW_SLANT:
268 case XML_TOK_PA_SHADE_MODE:
269 case XML_TOK_PA_AMBIENT_COLOR:
270 case XML_TOK_PA_LIGHTING_MODE:
271 maSceneImportHelper.processSceneAttribute( nPrefix, aLocalName, aValue );
272 break;
276 if( ! mxNewDoc.is())
278 uno::Reference< beans::XPropertySet > xDocProp( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
279 if( xDocProp.is())
283 xDocProp->setPropertyValue("DataSourceLabelsInFirstColumn", uno::Any(mrColHasLabels) );
284 xDocProp->setPropertyValue("DataSourceLabelsInFirstRow", uno::Any(mrRowHasLabels) );
286 catch( const beans::UnknownPropertyException & )
288 SAL_WARN("xmloff.chart", "Properties missing" );
293 // set properties
294 uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
295 if( !msAutoStyleName.isEmpty())
297 if( xProp.is())
299 const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
300 if( pStylesCtxt )
302 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
303 SchXMLImportHelper::GetChartFamilyID(), msAutoStyleName );
305 XMLPropStyleContext* pPropStyleContext =
306 const_cast< XMLPropStyleContext * >(
307 dynamic_cast< const XMLPropStyleContext * >( pStyle ) );
308 if( pPropStyleContext )
310 pPropStyleContext->FillPropertySet( xProp );
312 // get the data row source that was set without having data
313 xProp->getPropertyValue("DataRowSource")
314 >>= mrDataRowSource;
316 //lines on/off
317 //this old property is not supported fully anymore with the new chart, so we need to get the information a little bit different from similar properties
318 mrSeriesDefaultsAndStyles.maLinesOnProperty = SchXMLTools::getPropertyFromContext(
319 "Lines", pPropStyleContext, pStylesCtxt );
321 //handle automatic position and size
322 m_aOuterPositioning.readAutomaticPositioningProperties( pPropStyleContext, pStylesCtxt );
324 //correct default starting angle for old 3D pies
325 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_0( GetImport().GetModel() ) )
327 bool bIs3d = false;
328 if( xProp.is() && ( xProp->getPropertyValue("Dim3D") >>= bIs3d ) &&
329 bIs3d )
331 if( maChartTypeServiceName == "com.sun.star.chart2.PieChartType" || maChartTypeServiceName == "com.sun.star.chart2.DonutChartType" )
333 OUString aPropName( "StartingAngle" );
334 uno::Any aAStartingAngle( SchXMLTools::getPropertyFromContext( aPropName, pPropStyleContext, pStylesCtxt ) );
335 if( !aAStartingAngle.hasValue() )
336 xProp->setPropertyValue( aPropName, uno::makeAny(sal_Int32(0)) ) ;
345 //remember default values for dataseries
346 if(xProp.is())
350 mrSeriesDefaultsAndStyles.maSymbolTypeDefault = xProp->getPropertyValue("SymbolType");
351 mrSeriesDefaultsAndStyles.maDataCaptionDefault = xProp->getPropertyValue("DataCaption");
353 mrSeriesDefaultsAndStyles.maMeanValueDefault = xProp->getPropertyValue("MeanValue");
354 mrSeriesDefaultsAndStyles.maRegressionCurvesDefault = xProp->getPropertyValue("RegressionCurves");
356 bool bStacked = false;
357 mrSeriesDefaultsAndStyles.maStackedDefault = xProp->getPropertyValue("Stacked");
358 mrSeriesDefaultsAndStyles.maStackedDefault >>= bStacked;
359 mrSeriesDefaultsAndStyles.maPercentDefault = xProp->getPropertyValue("Percent");
360 mrSeriesDefaultsAndStyles.maPercentDefault >>= mbPercentStacked;
361 mrSeriesDefaultsAndStyles.maStackedBarsConnectedDefault = xProp->getPropertyValue("StackedBarsConnected");
363 // deep
364 uno::Any aDeepProperty( xProp->getPropertyValue("Deep"));
365 // #124488# old versions store a 3d area and 3D line deep chart with Deep==false => workaround for this
366 if( ! (bStacked || mbPercentStacked ))
368 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
370 bool bIs3d = false;
371 if( ( xProp->getPropertyValue("Dim3D") >>= bIs3d ) &&
372 bIs3d )
374 if( maChartTypeServiceName == "com.sun.star.chart2.AreaChartType" || maChartTypeServiceName == "com.sun.star.chart2.LineChartType" )
376 aDeepProperty <<= uno::makeAny( true );
381 mrSeriesDefaultsAndStyles.maDeepDefault = aDeepProperty;
383 xProp->getPropertyValue("NumberOfLines") >>= mnNumOfLinesProp;
384 xProp->getPropertyValue("Volume") >>= mbStockHasVolume;
386 catch( const uno::Exception & rEx )
388 OString aBStr(OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
389 SAL_INFO("xmloff.chart", "PlotAreaContext:EndElement(): Exception caught: " << aBStr);
391 } // if
393 bool bCreateInternalDataProvider = false;
394 if( m_rXLinkHRefAttributeToIndicateDataProvider == "." ) //data comes from the chart itself
395 bCreateInternalDataProvider = true;
396 else if( m_rXLinkHRefAttributeToIndicateDataProvider == ".." ) //data comes from the parent application
397 bCreateInternalDataProvider = false;
398 else if( !m_rXLinkHRefAttributeToIndicateDataProvider.isEmpty() ) //not supported so far to get the data by sibling objects -> fall back to chart itself
399 bCreateInternalDataProvider = true;
400 else if( !m_rbHasRangeAtPlotArea )
401 bCreateInternalDataProvider = true;
403 if( bCreateInternalDataProvider && mxNewDoc.is() )
405 // we have no complete range => we have own data, so switch the data
406 // provider to internal. Clone is not necessary, as we don't have any
407 // data yet.
408 mxNewDoc->createInternalDataProvider( false /* bCloneExistingData */ );
409 if( xProp.is() && mrDataRowSource!=chart::ChartDataRowSource_COLUMNS )
410 xProp->setPropertyValue("DataRowSource", uno::makeAny(mrDataRowSource) );
414 SvXMLImportContext* SchXMLPlotAreaContext::CreateChildContext(
415 sal_uInt16 nPrefix,
416 const OUString& rLocalName,
417 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
419 SvXMLImportContext* pContext = nullptr;
420 const SvXMLTokenMap& rTokenMap = mrImportHelper.GetPlotAreaElemTokenMap();
422 switch( rTokenMap.Get( nPrefix, rLocalName ))
424 case XML_TOK_PA_COORDINATE_REGION_EXT:
425 case XML_TOK_PA_COORDINATE_REGION:
427 pContext = new SchXMLCoordinateRegionContext( GetImport(), nPrefix, rLocalName, m_aInnerPositioning );
429 break;
431 case XML_TOK_PA_AXIS:
433 bool bAddMissingXAxisForNetCharts = false;
434 bool bAdaptWrongPercentScaleValues = false;
435 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
437 //correct errors from older versions
439 // for NetCharts there were no xAxis exported to older files
440 // so we need to add the x axis here for those old NetChart files
441 if ( maChartTypeServiceName == "com.sun.star.chart2.NetChartType" )
442 bAddMissingXAxisForNetCharts = true;
444 //Issue 59288
445 if( mbPercentStacked )
446 bAdaptWrongPercentScaleValues = true;
449 bool bAdaptXAxisOrientationForOld2DBarCharts = false;
450 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_4( GetImport().GetModel() ) )
452 //issue74660
453 if ( maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
454 bAdaptXAxisOrientationForOld2DBarCharts = true;
457 pContext = new SchXMLAxisContext( mrImportHelper, GetImport(), rLocalName, mxDiagram, maAxes, mrCategoriesAddress,
458 bAddMissingXAxisForNetCharts, bAdaptWrongPercentScaleValues, bAdaptXAxisOrientationForOld2DBarCharts, m_bAxisPositionAttributeImported );
460 break;
462 case XML_TOK_PA_SERIES:
464 if( mxNewDoc.is())
466 pContext = new SchXMLSeries2Context(
467 mrImportHelper, GetImport(), rLocalName,
468 mxNewDoc, maAxes,
469 mrSeriesDefaultsAndStyles.maSeriesStyleList,
470 mrSeriesDefaultsAndStyles.maRegressionStyleList,
471 mnSeries,
472 mbStockHasVolume,
473 m_aGlobalSeriesImportInfo,
474 maChartTypeServiceName,
475 mrLSequencesPerIndex,
476 mbGlobalChartTypeUsedBySeries, maChartSize );
478 mnSeries++;
480 break;
482 case XML_TOK_PA_WALL:
483 pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
484 SchXMLWallFloorContext::CONTEXT_TYPE_WALL );
485 break;
486 case XML_TOK_PA_FLOOR:
487 pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
488 SchXMLWallFloorContext::CONTEXT_TYPE_FLOOR );
489 break;
491 case XML_TOK_PA_LIGHT_SOURCE:
492 pContext = maSceneImportHelper.create3DLightContext( nPrefix, rLocalName, xAttrList );
493 break;
495 // elements for stock charts
496 case XML_TOK_PA_STOCK_GAIN:
497 pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
498 SchXMLStockContext::CONTEXT_TYPE_GAIN );
499 break;
500 case XML_TOK_PA_STOCK_LOSS:
501 pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
502 SchXMLStockContext::CONTEXT_TYPE_LOSS );
503 break;
504 case XML_TOK_PA_STOCK_RANGE:
505 pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
506 SchXMLStockContext::CONTEXT_TYPE_RANGE );
507 break;
509 default:
510 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
513 return pContext;
516 void SchXMLPlotAreaContext::EndElement()
518 // set categories
519 if( !mrCategoriesAddress.isEmpty() && mxNewDoc.is())
521 uno::Reference< chart2::data::XDataProvider > xDataProvider(
522 mxNewDoc->getDataProvider() );
523 // @todo: correct coordinate system index
524 sal_Int32 nDimension( 0 );
525 ::std::vector< SchXMLAxis >::const_iterator aIt(
526 ::std::find_if( maAxes.begin(), maAxes.end(), lcl_AxisHasCategories()));
527 if( aIt != maAxes.end())
528 nDimension = static_cast< sal_Int32 >( (*aIt).eDimension );
529 SchXMLTools::CreateCategories(
530 xDataProvider, mxNewDoc, mrCategoriesAddress,
531 0 /* nCooSysIndex */,
532 nDimension, &mrLSequencesPerIndex );
535 uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY );
536 if( xDiaProp.is())
538 bool bIsThreeDim = false;
539 uno::Any aAny = xDiaProp->getPropertyValue("Dim3D");
540 aAny >>= bIsThreeDim;
542 // set 3d scene attributes
543 if( bIsThreeDim )
545 // set scene attributes at diagram
546 maSceneImportHelper.setSceneAttributes( xDiaProp );
549 // set correct number of lines at series
550 if( ! m_aGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && mnNumOfLinesProp > 0 && maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
554 xDiaProp->setPropertyValue("NumberOfLines",
555 uno::makeAny( mnNumOfLinesProp ));
557 catch( const uno::Exception & rEx )
559 OString aBStr(OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
560 SAL_INFO("xmloff.chart", "Exception caught for property NumberOfLines: " << aBStr);
564 // #i32366# stock has volume
565 if( mxDiagram->getDiagramType() == "com.sun.star.chart.StockDiagram" &&
566 mbStockHasVolume )
570 xDiaProp->setPropertyValue("Volume",
571 uno::makeAny( true ));
573 catch( const uno::Exception & rEx )
575 OString aBStr(OUStringToOString(rEx.Message, RTL_TEXTENCODING_ASCII_US));
576 SAL_INFO("xmloff.chart", "Exception caught for property Volume: " << aBStr);
581 // set changed size and position after properties (esp. 3d)
583 uno::Reference< chart::XDiagramPositioning > xDiaPos( mxDiagram, uno::UNO_QUERY );
584 if( xDiaPos.is())
586 if( !m_aOuterPositioning.isAutomatic() )
588 if( m_aInnerPositioning.hasPosSize() )
589 xDiaPos->setDiagramPositionExcludingAxes( m_aInnerPositioning.getRectangle() );
590 else if( m_aOuterPositioning.hasPosSize() )
592 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_3( GetImport().GetModel() ) ) //old version of OOo did write a wrong rectangle for the diagram size
593 xDiaPos->setDiagramPositionIncludingAxesAndAxisTitles( m_aOuterPositioning.getRectangle() );
594 else
595 xDiaPos->setDiagramPositionIncludingAxes( m_aOuterPositioning.getRectangle() );
600 SchXMLAxisContext::CorrectAxisPositions( uno::Reference< chart2::XChartDocument >( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ), maChartTypeServiceName, GetImport().GetODFVersion(), m_bAxisPositionAttributeImported );
603 SchXMLDataPointContext::SchXMLDataPointContext( SvXMLImport& rImport, const OUString& rLocalName,
604 ::std::list< DataRowPointStyle >& rStyleList,
605 const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
606 sal_Int32& rIndex,
607 bool bSymbolSizeForSeriesIsMissingInFile ) :
608 SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
609 mrStyleList( rStyleList ),
610 m_xSeries( xSeries ),
611 mrIndex( rIndex ),
612 mbSymbolSizeForSeriesIsMissingInFile( bSymbolSizeForSeriesIsMissingInFile )
616 SchXMLDataPointContext::~SchXMLDataPointContext()
620 void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
622 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
623 OUString sAutoStyleName;
624 sal_Int32 nRepeat = 1;
626 for( sal_Int16 i = 0; i < nAttrCount; i++ )
628 OUString sAttrName = xAttrList->getNameByIndex( i );
629 OUString aLocalName;
630 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
632 if( nPrefix == XML_NAMESPACE_CHART )
634 if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
635 sAutoStyleName = xAttrList->getValueByIndex( i );
636 else if( IsXMLToken( aLocalName, XML_REPEATED ) )
637 nRepeat = xAttrList->getValueByIndex( i ).toInt32();
641 if( !sAutoStyleName.isEmpty())
643 DataRowPointStyle aStyle(
644 DataRowPointStyle::DATA_POINT,
645 m_xSeries, mrIndex, nRepeat, sAutoStyleName );
646 aStyle.mbSymbolSizeForSeriesIsMissingInFile = mbSymbolSizeForSeriesIsMissingInFile;
647 mrStyleList.push_back( aStyle );
649 mrIndex += nRepeat;
652 SchXMLPositionAttributesHelper::SchXMLPositionAttributesHelper( SvXMLImport& rImporter )
653 : m_rImport( rImporter )
654 , m_aPosition(0,0)
655 , m_aSize(0,0)
656 , m_bHasSizeWidth( false )
657 , m_bHasSizeHeight( false )
658 , m_bHasPositionX( false )
659 , m_bHasPositionY( false )
660 , m_bAutoSize( false )
661 , m_bAutoPosition( false )
665 SchXMLPositionAttributesHelper::~SchXMLPositionAttributesHelper()
669 bool SchXMLPositionAttributesHelper::hasSize() const
671 return m_bHasSizeWidth && m_bHasSizeHeight;
673 bool SchXMLPositionAttributesHelper::hasPosition() const
675 return m_bHasPositionX && m_bHasPositionY;
677 bool SchXMLPositionAttributesHelper::hasPosSize() const
679 return hasPosition() && hasSize();
681 bool SchXMLPositionAttributesHelper::isAutomatic() const
683 return m_bAutoSize || m_bAutoPosition;
686 void SchXMLPositionAttributesHelper::readPositioningAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
688 if( XML_NAMESPACE_SVG == nPrefix )
690 if( IsXMLToken( rLocalName, XML_X ) )
692 m_rImport.GetMM100UnitConverter().convertMeasureToCore(
693 m_aPosition.X, rValue );
694 m_bHasPositionX = true;
696 else if( IsXMLToken( rLocalName, XML_Y ) )
698 m_rImport.GetMM100UnitConverter().convertMeasureToCore(
699 m_aPosition.Y, rValue );
700 m_bHasPositionY = true;
702 else if( IsXMLToken( rLocalName, XML_WIDTH ) )
704 m_rImport.GetMM100UnitConverter().convertMeasureToCore(
705 m_aSize.Width, rValue );
706 m_bHasSizeWidth = true;
708 else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
710 m_rImport.GetMM100UnitConverter().convertMeasureToCore(
711 m_aSize.Height, rValue );
712 m_bHasSizeHeight = true;
717 void SchXMLPositionAttributesHelper::readAutomaticPositioningProperties( XMLPropStyleContext* pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
719 if( pPropStyleContext && pStylesCtxt )
721 //handle automatic position and size
722 SchXMLTools::getPropertyFromContext(
723 "AutomaticSize", pPropStyleContext, pStylesCtxt ) >>= m_bAutoSize;
724 SchXMLTools::getPropertyFromContext(
725 "AutomaticPosition", pPropStyleContext, pStylesCtxt ) >>= m_bAutoPosition;
729 SchXMLCoordinateRegionContext::SchXMLCoordinateRegionContext(
730 SvXMLImport& rImport
731 , sal_uInt16 nPrefix
732 , const OUString& rLocalName
733 , SchXMLPositionAttributesHelper& rPositioning )
734 : SvXMLImportContext( rImport, nPrefix, rLocalName )
735 , m_rPositioning( rPositioning )
739 SchXMLCoordinateRegionContext::~SchXMLCoordinateRegionContext()
743 void SchXMLCoordinateRegionContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
745 // parse attributes
746 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
748 for( sal_Int16 i = 0; i < nAttrCount; i++ )
750 OUString sAttrName = xAttrList->getNameByIndex( i );
751 OUString aLocalName;
752 OUString aValue = xAttrList->getValueByIndex( i );
753 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
754 m_rPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
758 SchXMLWallFloorContext::SchXMLWallFloorContext(
759 SchXMLImportHelper& rImpHelper,
760 SvXMLImport& rImport,
761 sal_uInt16 nPrefix,
762 const OUString& rLocalName,
763 uno::Reference< chart::XDiagram >& xDiagram,
764 ContextType eContextType ) :
765 SvXMLImportContext( rImport, nPrefix, rLocalName ),
766 mrImportHelper( rImpHelper ),
767 mxWallFloorSupplier( xDiagram, uno::UNO_QUERY ),
768 meContextType( eContextType )
772 SchXMLWallFloorContext::~SchXMLWallFloorContext()
776 void SchXMLWallFloorContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
778 if( mxWallFloorSupplier.is())
780 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
781 OUString sAutoStyleName;
783 for( sal_Int16 i = 0; i < nAttrCount; i++ )
785 OUString sAttrName = xAttrList->getNameByIndex( i );
786 OUString aLocalName;
787 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
789 if( nPrefix == XML_NAMESPACE_CHART &&
790 IsXMLToken( aLocalName, XML_STYLE_NAME ) )
792 sAutoStyleName = xAttrList->getValueByIndex( i );
796 // set properties
797 uno::Reference< beans::XPropertySet > xProp( ( meContextType == CONTEXT_TYPE_WALL )
798 ? mxWallFloorSupplier->getWall()
799 : mxWallFloorSupplier->getFloor(),
800 uno::UNO_QUERY );
801 if( xProp.is())
803 if( !sAutoStyleName.isEmpty())
805 const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
806 if( pStylesCtxt )
808 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
809 SchXMLImportHelper::GetChartFamilyID(), sAutoStyleName );
811 if( pStyle && dynamic_cast< const XMLPropStyleContext*>(pStyle) != nullptr)
812 const_cast<XMLPropStyleContext*>( static_cast<const XMLPropStyleContext*>( pStyle ) )->FillPropertySet( xProp );
819 SchXMLStockContext::SchXMLStockContext(
820 SchXMLImportHelper& rImpHelper,
821 SvXMLImport& rImport,
822 sal_uInt16 nPrefix,
823 const OUString& rLocalName,
824 uno::Reference< chart::XDiagram >& xDiagram,
825 ContextType eContextType ) :
826 SvXMLImportContext( rImport, nPrefix, rLocalName ),
827 mrImportHelper( rImpHelper ),
828 mxStockPropProvider( xDiagram, uno::UNO_QUERY ),
829 meContextType( eContextType )
833 SchXMLStockContext::~SchXMLStockContext()
837 void SchXMLStockContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
839 if( mxStockPropProvider.is())
841 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
842 OUString sAutoStyleName;
844 for( sal_Int16 i = 0; i < nAttrCount; i++ )
846 OUString sAttrName = xAttrList->getNameByIndex( i );
847 OUString aLocalName;
848 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
850 if( nPrefix == XML_NAMESPACE_CHART &&
851 IsXMLToken( aLocalName, XML_STYLE_NAME ) )
853 sAutoStyleName = xAttrList->getValueByIndex( i );
857 if( !sAutoStyleName.isEmpty())
859 // set properties
860 uno::Reference< beans::XPropertySet > xProp;
861 switch( meContextType )
863 case CONTEXT_TYPE_GAIN:
864 xProp = mxStockPropProvider->getUpBar();
865 break;
866 case CONTEXT_TYPE_LOSS:
867 xProp = mxStockPropProvider->getDownBar();
868 break;
869 case CONTEXT_TYPE_RANGE:
870 xProp = mxStockPropProvider->getMinMaxLine();
871 break;
873 if( xProp.is())
875 const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
876 if( pStylesCtxt )
878 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
879 SchXMLImportHelper::GetChartFamilyID(), sAutoStyleName );
881 if( pStyle && dynamic_cast< const XMLPropStyleContext*>(pStyle) != nullptr)
882 const_cast<XMLPropStyleContext*>( static_cast<const XMLPropStyleContext*>( pStyle ) )->FillPropertySet( xProp );
889 static void lcl_setErrorBarSequence ( const uno::Reference< chart2::XChartDocument > &xDoc,
890 const uno::Reference< beans::XPropertySet > &xBarProp,
891 const OUString &aXMLRange,
892 bool bPositiveValue, bool bYError,
893 tSchXMLLSequencesPerIndex& rSequences)
895 uno::Reference< css::chart2::data::XDataProvider > xDataProvider(xDoc->getDataProvider());
896 uno::Reference< css::chart2::data::XDataSource > xDataSource( xBarProp, uno::UNO_QUERY );
897 uno::Reference< css::chart2::data::XDataSink > xDataSink( xDataSource, uno::UNO_QUERY );
899 assert( xDataSink.is() && xDataSource.is() && xDataProvider.is() );
901 OUString aRange(lcl_ConvertRange(aXMLRange,xDoc));
903 uno::Reference< chart2::data::XDataSequence > xNewSequence(
904 xDataProvider->createDataSequenceByRangeRepresentation( aRange ));
906 if( xNewSequence.is())
908 SchXMLTools::setXMLRangePropertyAtDataSequence(xNewSequence,aXMLRange);
910 OUStringBuffer aRoleBuffer("error-bars-");
911 if( bYError )
912 aRoleBuffer.append( 'y' );
913 else
914 aRoleBuffer.append( 'x');
916 aRoleBuffer.append( '-' );
918 if( bPositiveValue )
919 aRoleBuffer = aRoleBuffer.append( "positive" );
920 else
921 aRoleBuffer = aRoleBuffer.append( "negative" );
923 OUString aRole = aRoleBuffer.makeStringAndClear();
925 Reference< beans::XPropertySet > xSeqProp( xNewSequence, uno::UNO_QUERY );
927 xSeqProp->setPropertyValue("Role", uno::makeAny( aRole ));
929 Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
931 Reference< chart2::data::XLabeledDataSequence > xLabelSeq( chart2::data::LabeledDataSequence::create(xContext),
932 uno::UNO_QUERY_THROW );
934 rSequences.insert( tSchXMLLSequencesPerIndex::value_type(
935 tSchXMLIndexWithPart( -2, SCH_XML_PART_ERROR_BARS ), xLabelSeq ) );
937 xLabelSeq->setValues( xNewSequence );
939 uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
940 xDataSource->getDataSequences());
942 aSequences.realloc( aSequences.getLength() + 1 );
943 aSequences[ aSequences.getLength() - 1 ] = xLabelSeq;
944 xDataSink->setData( aSequences );
948 SchXMLStatisticsObjectContext::SchXMLStatisticsObjectContext(
949 SchXMLImportHelper& rImpHelper,
950 SvXMLImport& rImport,
951 sal_uInt16 nPrefix,
952 const OUString& rLocalName,
953 const OUString &rSeriesStyleName,
954 ::std::list< DataRowPointStyle >& rStyleList,
955 const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
956 ContextType eContextType,
957 tSchXMLLSequencesPerIndex & rLSequencesPerIndex) :
959 SvXMLImportContext( rImport, nPrefix, rLocalName ),
960 mrImportHelper( rImpHelper ),
961 mrStyleList( rStyleList ),
962 m_xSeries( xSeries ),
963 meContextType( eContextType ),
964 maSeriesStyleName( rSeriesStyleName),
965 mrLSequencesPerIndex(rLSequencesPerIndex)
968 SchXMLStatisticsObjectContext::~SchXMLStatisticsObjectContext()
972 namespace {
974 void SetErrorBarStyleProperties( const OUString& rStyleName, const uno::Reference< beans::XPropertySet >& xBarProp,
975 SchXMLImportHelper& rImportHelper )
977 const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
978 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(SchXMLImportHelper::GetChartFamilyID(),
979 rStyleName);
981 XMLPropStyleContext &rSeriesStyleContext =
982 const_cast< XMLPropStyleContext& >( dynamic_cast< const XMLPropStyleContext& >( *pStyle ));
984 rSeriesStyleContext.FillPropertySet( xBarProp );
987 void SetErrorBarPropertiesFromStyleName( const OUString& aStyleName, const uno::Reference< beans::XPropertySet>& xBarProp,
988 SchXMLImportHelper& rImportHelper, OUString& aPosRange, OUString& aNegRange)
990 const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
991 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(SchXMLImportHelper::GetChartFamilyID(),
992 aStyleName);
994 XMLPropStyleContext * pSeriesStyleContext =
995 const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
997 uno::Any aAny = SchXMLTools::getPropertyFromContext("ErrorBarStyle",
998 pSeriesStyleContext,pStylesCtxt);
1000 if ( aAny.hasValue() )
1002 sal_Int32 aBarStyle = css::chart::ErrorBarStyle::NONE;
1003 aAny >>= aBarStyle;
1004 xBarProp->setPropertyValue("ErrorBarStyle", aAny);
1006 aAny = SchXMLTools::getPropertyFromContext("ShowPositiveError",
1007 pSeriesStyleContext,pStylesCtxt);
1009 if(aAny.hasValue())
1010 xBarProp->setPropertyValue("ShowPositiveError",aAny);
1012 aAny = SchXMLTools::getPropertyFromContext("ShowNegativeError",
1013 pSeriesStyleContext,pStylesCtxt);
1015 if(aAny.hasValue())
1016 xBarProp->setPropertyValue("ShowNegativeError",aAny);
1018 aAny = SchXMLTools::getPropertyFromContext("PositiveError",
1019 pSeriesStyleContext, pStylesCtxt);
1021 if(aAny.hasValue())
1022 xBarProp->setPropertyValue("PositiveError", aAny);
1023 else
1025 aAny = SchXMLTools::getPropertyFromContext("ConstantErrorHigh",
1026 pSeriesStyleContext, pStylesCtxt);
1028 if(aAny.hasValue())
1029 xBarProp->setPropertyValue("PositiveError", aAny);
1032 aAny = SchXMLTools::getPropertyFromContext("NegativeError",
1033 pSeriesStyleContext, pStylesCtxt);
1035 if(aAny.hasValue())
1036 xBarProp->setPropertyValue("NegativeError", aAny);
1037 else
1039 aAny = SchXMLTools::getPropertyFromContext("ConstantErrorLow",
1040 pSeriesStyleContext, pStylesCtxt);
1042 if(aAny.hasValue())
1043 xBarProp->setPropertyValue("NegativeError", aAny);
1046 aAny = SchXMLTools::getPropertyFromContext("ErrorBarRangePositive",
1047 pSeriesStyleContext, pStylesCtxt);
1048 if( aAny.hasValue() )
1050 aAny >>= aPosRange;
1053 aAny = SchXMLTools::getPropertyFromContext("ErrorBarRangeNegative",
1054 pSeriesStyleContext, pStylesCtxt);
1055 if( aAny.hasValue() )
1057 aAny >>= aNegRange;
1060 aAny = SchXMLTools::getPropertyFromContext("Weight",
1061 pSeriesStyleContext, pStylesCtxt);
1062 if( aAny.hasValue() )
1064 xBarProp->setPropertyValue("Weight", aAny);
1067 aAny = SchXMLTools::getPropertyFromContext("PercentageError",
1068 pSeriesStyleContext, pStylesCtxt);
1069 if( aAny.hasValue() && aBarStyle == css::chart::ErrorBarStyle::RELATIVE )
1071 xBarProp->setPropertyValue("PositiveError", aAny);
1072 xBarProp->setPropertyValue("NegativeError", aAny);
1075 switch(aBarStyle)
1077 case css::chart::ErrorBarStyle::ERROR_MARGIN:
1079 aAny = SchXMLTools::getPropertyFromContext("NegativeError",
1080 pSeriesStyleContext,pStylesCtxt);
1082 xBarProp->setPropertyValue("NegativeError",aAny);
1084 aAny = SchXMLTools::getPropertyFromContext("PositiveError",
1085 pSeriesStyleContext,pStylesCtxt);
1087 xBarProp->setPropertyValue("PositiveError",aAny);
1089 break;
1090 default:
1091 break;
1098 void SchXMLStatisticsObjectContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1100 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
1101 OUString sAutoStyleName;
1102 OUString aPosRange;
1103 OUString aNegRange;
1104 bool bYError = true; /// Default errorbar, to be backward compatible with older files!
1106 for( sal_Int16 i = 0; i < nAttrCount; i++ )
1108 OUString sAttrName = xAttrList->getNameByIndex( i );
1109 OUString aLocalName;
1111 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
1113 if( nPrefix == XML_NAMESPACE_CHART )
1115 if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1116 sAutoStyleName = xAttrList->getValueByIndex( i );
1117 else if( IsXMLToken( aLocalName, XML_DIMENSION ) )
1118 bYError = xAttrList->getValueByIndex(i) == "y";
1119 else if( IsXMLToken( aLocalName, XML_ERROR_UPPER_RANGE) )
1120 aPosRange = xAttrList->getValueByIndex(i);
1121 else if( IsXMLToken( aLocalName, XML_ERROR_LOWER_RANGE) )
1122 aNegRange = xAttrList->getValueByIndex(i);
1126 if( !sAutoStyleName.isEmpty() )
1128 DataRowPointStyle aStyle( DataRowPointStyle::MEAN_VALUE, m_xSeries, -1, 1, sAutoStyleName );
1130 switch( meContextType )
1132 case CONTEXT_TYPE_MEAN_VALUE_LINE:
1133 aStyle.meType = DataRowPointStyle::MEAN_VALUE;
1134 break;
1135 case CONTEXT_TYPE_ERROR_INDICATOR:
1137 aStyle.meType = DataRowPointStyle::ERROR_INDICATOR;
1139 uno::Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(),
1140 uno::UNO_QUERY );
1142 uno::Reference< beans::XPropertySet > xBarProp( xFact->createInstance("com.sun.star.chart2.ErrorBar" ),
1143 uno::UNO_QUERY );
1145 xBarProp->setPropertyValue("ErrorBarStyle",uno::makeAny(css::chart::ErrorBarStyle::NONE));
1146 xBarProp->setPropertyValue("PositiveError",uno::makeAny(static_cast<double>(0.0)));
1147 xBarProp->setPropertyValue("NegativeError",uno::makeAny(static_cast<double>(0.0)));
1148 xBarProp->setPropertyValue("Weight",uno::makeAny(static_cast<double>(1.0)));
1149 xBarProp->setPropertyValue("ShowPositiveError",uno::makeAny(true));
1150 xBarProp->setPropertyValue("ShowNegativeError",uno::makeAny(true));
1152 // first import defaults from parent style
1153 SetErrorBarStyleProperties( maSeriesStyleName, xBarProp, mrImportHelper );
1154 SetErrorBarStyleProperties( sAutoStyleName, xBarProp, mrImportHelper );
1155 SetErrorBarPropertiesFromStyleName( maSeriesStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1156 SetErrorBarPropertiesFromStyleName( sAutoStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1158 uno::Reference< chart2::XChartDocument > xDoc(GetImport().GetModel(),uno::UNO_QUERY);
1160 if (!aPosRange.isEmpty())
1161 lcl_setErrorBarSequence(xDoc,xBarProp,aPosRange,true,bYError, mrLSequencesPerIndex);
1163 if (!aNegRange.isEmpty())
1164 lcl_setErrorBarSequence(xDoc,xBarProp,aNegRange,false,bYError, mrLSequencesPerIndex);
1166 if ( !bYError )
1168 aStyle.m_xErrorXProperties.set( xBarProp );
1170 else
1172 aStyle.m_xErrorYProperties.set( xBarProp );
1175 break;
1178 mrStyleList.push_back( aStyle );
1182 SvXMLImportContext* SchXMLStatisticsObjectContext::CreateChildContext(
1183 sal_uInt16 nPrefix,
1184 const OUString& rLocalName,
1185 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1187 SvXMLImportContext* pContext = nullptr;
1188 pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
1189 return pContext;
1192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */