Teach symstore more duplicated DLLs
[LibreOffice.git] / xmloff / source / chart / SchXMLPlotAreaContext.cxx
blobf488244e142fc4c890752b9e8ae8c663a696ac69
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 "SchXMLPlotAreaContext.hxx"
21 #include <SchXMLImport.hxx>
22 #include "SchXMLAxisContext.hxx"
23 #include "SchXMLSeries2Context.hxx"
24 #include "SchXMLTools.hxx"
26 #include <comphelper/processfactory.hxx>
27 #include <sal/log.hxx>
28 #include <tools/diagnose_ex.h>
29 #include <xmloff/xmlnmspe.hxx>
30 #include <xmloff/nmspmap.hxx>
31 #include <xmloff/xmluconv.hxx>
32 #include <xmloff/prstylei.hxx>
33 #include <xmloff/xmlstyle.hxx>
35 #include <com/sun/star/awt/Point.hpp>
36 #include <com/sun/star/awt/Size.hpp>
37 #include <com/sun/star/chart/ChartDataRowSource.hpp>
38 #include <com/sun/star/chart/ErrorBarStyle.hpp>
39 #include <com/sun/star/chart/X3DDisplay.hpp>
40 #include <com/sun/star/chart/XStatisticDisplay.hpp>
41 #include <com/sun/star/chart/XDiagramPositioning.hpp>
42 #include <com/sun/star/chart/XChartDocument.hpp>
43 #include <com/sun/star/chart2/XChartDocument.hpp>
44 #include <com/sun/star/chart2/data/XDataSink.hpp>
45 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
46 #include <com/sun/star/chart2/data/LabeledDataSequence.hpp>
47 #include <com/sun/star/drawing/CameraGeometry.hpp>
48 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 #include <com/sun/star/lang/XServiceInfo.hpp>
50 #include <com/sun/star/xml/sax/XAttributeList.hpp>
52 using namespace com::sun::star;
53 using namespace ::xmloff::token;
55 using com::sun::star::uno::Reference;
57 namespace
60 struct lcl_AxisHasCategories
62 bool operator() ( const SchXMLAxis & rAxis )
64 return rAxis.bHasCategories;
68 OUString lcl_ConvertRange( const OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
70 OUString aResult = rRange;
71 if(!xDoc.is())
72 return aResult;
73 uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
74 xDoc->getDataProvider(), uno::UNO_QUERY );
75 if( xConversion.is())
76 aResult = xConversion->convertRangeFromXML( rRange );
77 return aResult;
80 } // anonymous namespace
82 SchXML3DSceneAttributesHelper::SchXML3DSceneAttributesHelper( SvXMLImport& rImporter )
83 : SdXML3DSceneAttributesHelper( rImporter )
87 void SchXML3DSceneAttributesHelper::getCameraDefaultFromDiagram( const uno::Reference< chart::XDiagram >& xDiagram )
89 //different defaults for camera geometry necessary to workaround wrong behaviour in old chart
90 //in future make this version dependent if we have versioning (metastream) for ole objects
92 try
94 uno::Reference< beans::XPropertySet > xProp( xDiagram, uno::UNO_QUERY );
95 if( xProp.is() )
97 drawing::CameraGeometry aCamGeo;
98 xProp->getPropertyValue("D3DCameraGeometry") >>= aCamGeo;
99 maVRP.setX( aCamGeo.vrp.PositionX );
100 maVRP.setY( aCamGeo.vrp.PositionY );
101 maVRP.setZ( aCamGeo.vrp.PositionZ );
102 maVPN.setX( aCamGeo.vpn.DirectionX );
103 maVPN.setY( aCamGeo.vpn.DirectionY );
104 maVPN.setZ( aCamGeo.vpn.DirectionZ );
105 maVUP.setX( aCamGeo.vup.DirectionX );
106 maVUP.setY( aCamGeo.vup.DirectionY );
107 maVUP.setZ( aCamGeo.vup.DirectionZ );
110 catch( const uno::Exception & )
112 TOOLS_INFO_EXCEPTION("xmloff.chart", "Exception caught for property NumberOfLines");
116 SchXML3DSceneAttributesHelper::~SchXML3DSceneAttributesHelper()
120 SchXMLPlotAreaContext::SchXMLPlotAreaContext(
121 SchXMLImportHelper& rImpHelper,
122 SvXMLImport& rImport, const OUString& rLocalName,
123 const OUString& rXLinkHRefAttributeToIndicateDataProvider,
124 OUString& rCategoriesAddress,
125 OUString& rChartAddress,
126 bool & rbHasRangeAtPlotArea,
127 bool & rAllRangeAddressesAvailable,
128 bool & rColHasLabels,
129 bool & rRowHasLabels,
130 chart::ChartDataRowSource & rDataRowSource,
131 SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles,
132 const OUString& aChartTypeServiceName,
133 tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
134 const awt::Size & rChartSize ) :
135 SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
136 mrImportHelper( rImpHelper ),
137 mrCategoriesAddress( rCategoriesAddress ),
138 mrSeriesDefaultsAndStyles( rSeriesDefaultsAndStyles ),
139 mnNumOfLinesProp( 0 ),
140 mbStockHasVolume( false ),
141 mnSeries( 0 ),
142 m_aGlobalSeriesImportInfo( rAllRangeAddressesAvailable ),
143 maSceneImportHelper( rImport ),
144 m_aOuterPositioning( rImport ),
145 m_aInnerPositioning( rImport ),
146 mbPercentStacked(false),
147 m_bAxisPositionAttributeImported(false),
148 m_rXLinkHRefAttributeToIndicateDataProvider(rXLinkHRefAttributeToIndicateDataProvider),
149 mrChartAddress( rChartAddress ),
150 m_rbHasRangeAtPlotArea( rbHasRangeAtPlotArea ),
151 mrColHasLabels( rColHasLabels ),
152 mrRowHasLabels( rRowHasLabels ),
153 mrDataRowSource( rDataRowSource ),
154 maChartTypeServiceName( aChartTypeServiceName ),
155 mrLSequencesPerIndex( rLSequencesPerIndex ),
156 mbGlobalChartTypeUsedBySeries( false ),
157 maChartSize( rChartSize )
159 m_rbHasRangeAtPlotArea = false;
161 // get Diagram
162 uno::Reference< chart::XChartDocument > xDoc = rImpHelper.GetChartDocument();
163 if( xDoc.is())
165 mxDiagram = xDoc->getDiagram();
166 mxNewDoc.set( xDoc, uno::UNO_QUERY );
168 maSceneImportHelper.getCameraDefaultFromDiagram( mxDiagram );
170 SAL_WARN_IF( !mxDiagram.is(),"xmloff.chart", "Couldn't get XDiagram" );
172 // turn off all axes initially
173 uno::Any aFalseBool;
174 aFalseBool <<= false;
176 uno::Reference< lang::XServiceInfo > xInfo( mxDiagram, uno::UNO_QUERY );
177 uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
178 if( xInfo.is() &&
179 xProp.is())
183 xProp->setPropertyValue("HasXAxis", aFalseBool );
184 xProp->setPropertyValue("HasXAxisGrid", aFalseBool );
185 xProp->setPropertyValue("HasXAxisDescription", aFalseBool );
186 xProp->setPropertyValue("HasSecondaryXAxis", aFalseBool );
187 xProp->setPropertyValue("HasSecondaryXAxisDescription", aFalseBool );
189 xProp->setPropertyValue("HasYAxis", aFalseBool );
190 xProp->setPropertyValue("HasYAxisGrid", aFalseBool );
191 xProp->setPropertyValue("HasYAxisDescription", aFalseBool );
192 xProp->setPropertyValue("HasSecondaryYAxis", aFalseBool );
193 xProp->setPropertyValue("HasSecondaryYAxisDescription", aFalseBool );
195 xProp->setPropertyValue("HasZAxis", aFalseBool );
196 xProp->setPropertyValue("HasZAxisDescription", aFalseBool );
198 xProp->setPropertyValue("DataRowSource", uno::Any(chart::ChartDataRowSource_COLUMNS) );
200 catch( const beans::UnknownPropertyException & )
202 SAL_WARN("xmloff.chart", "Property required by service not supported" );
207 SchXMLPlotAreaContext::~SchXMLPlotAreaContext()
210 void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
212 // parse attributes
213 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
214 const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetPlotAreaAttrTokenMap();
215 uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
217 for( sal_Int16 i = 0; i < nAttrCount; i++ )
219 OUString sAttrName = xAttrList->getNameByIndex( i );
220 OUString aLocalName;
221 OUString aValue = xAttrList->getValueByIndex( i );
222 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
224 switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
226 case XML_TOK_PA_X:
227 case XML_TOK_PA_Y:
228 case XML_TOK_PA_WIDTH:
229 case XML_TOK_PA_HEIGHT:
230 m_aOuterPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
231 break;
232 case XML_TOK_PA_STYLE_NAME:
233 msAutoStyleName = aValue;
234 break;
235 case XML_TOK_PA_CHART_ADDRESS:
236 mrChartAddress = lcl_ConvertRange( aValue, xNewDoc );
237 // indicator for getting data from the outside
238 m_rbHasRangeAtPlotArea = true;
239 break;
240 case XML_TOK_PA_DS_HAS_LABELS:
242 if( aValue == ::xmloff::token::GetXMLToken( ::xmloff::token::XML_BOTH ))
243 mrColHasLabels = mrRowHasLabels = true;
244 else if( aValue == ::xmloff::token::GetXMLToken( ::xmloff::token::XML_ROW ))
245 mrRowHasLabels = true;
246 else if( aValue == ::xmloff::token::GetXMLToken( ::xmloff::token::XML_COLUMN ))
247 mrColHasLabels = true;
249 break;
250 case XML_TOK_PA_TRANSFORM:
251 case XML_TOK_PA_VRP:
252 case XML_TOK_PA_VPN:
253 case XML_TOK_PA_VUP:
254 case XML_TOK_PA_PROJECTION:
255 case XML_TOK_PA_DISTANCE:
256 case XML_TOK_PA_FOCAL_LENGTH:
257 case XML_TOK_PA_SHADOW_SLANT:
258 case XML_TOK_PA_SHADE_MODE:
259 case XML_TOK_PA_AMBIENT_COLOR:
260 case XML_TOK_PA_LIGHTING_MODE:
261 maSceneImportHelper.processSceneAttribute( nPrefix, aLocalName, aValue );
262 break;
266 if( ! mxNewDoc.is())
268 uno::Reference< beans::XPropertySet > xDocProp( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
269 if( xDocProp.is())
273 xDocProp->setPropertyValue("DataSourceLabelsInFirstColumn", uno::Any(mrColHasLabels) );
274 xDocProp->setPropertyValue("DataSourceLabelsInFirstRow", uno::Any(mrRowHasLabels) );
276 catch( const beans::UnknownPropertyException & )
278 SAL_WARN("xmloff.chart", "Properties missing" );
283 // set properties
284 uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
285 if( !msAutoStyleName.isEmpty())
287 if( xProp.is())
289 const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
290 if( pStylesCtxt )
292 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
293 SchXMLImportHelper::GetChartFamilyID(), msAutoStyleName );
295 XMLPropStyleContext* pPropStyleContext =
296 const_cast< XMLPropStyleContext * >(
297 dynamic_cast< const XMLPropStyleContext * >( pStyle ) );
298 if( pPropStyleContext )
300 pPropStyleContext->FillPropertySet( xProp );
302 // get the data row source that was set without having data
303 xProp->getPropertyValue("DataRowSource")
304 >>= mrDataRowSource;
306 //lines on/off
307 //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
308 mrSeriesDefaultsAndStyles.maLinesOnProperty = SchXMLTools::getPropertyFromContext(
309 "Lines", pPropStyleContext, pStylesCtxt );
311 //handle automatic position and size
312 m_aOuterPositioning.readAutomaticPositioningProperties( pPropStyleContext, pStylesCtxt );
314 //correct default starting angle for old 3D pies
315 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_0( GetImport().GetModel() ) )
317 bool bIs3d = false;
318 if( xProp.is() && ( xProp->getPropertyValue("Dim3D") >>= bIs3d ) &&
319 bIs3d )
321 if( maChartTypeServiceName == "com.sun.star.chart2.PieChartType" || maChartTypeServiceName == "com.sun.star.chart2.DonutChartType" )
323 OUString aPropName( "StartingAngle" );
324 uno::Any aAStartingAngle( SchXMLTools::getPropertyFromContext( aPropName, pPropStyleContext, pStylesCtxt ) );
325 if( !aAStartingAngle.hasValue() )
326 xProp->setPropertyValue( aPropName, uno::makeAny(sal_Int32(0)) ) ;
335 //remember default values for dataseries
336 if(xProp.is())
340 mrSeriesDefaultsAndStyles.maSymbolTypeDefault = xProp->getPropertyValue("SymbolType");
341 mrSeriesDefaultsAndStyles.maDataCaptionDefault = xProp->getPropertyValue("DataCaption");
343 mrSeriesDefaultsAndStyles.maMeanValueDefault = xProp->getPropertyValue("MeanValue");
344 mrSeriesDefaultsAndStyles.maRegressionCurvesDefault = xProp->getPropertyValue("RegressionCurves");
346 bool bStacked = false;
347 mrSeriesDefaultsAndStyles.maStackedDefault = xProp->getPropertyValue("Stacked");
348 mrSeriesDefaultsAndStyles.maStackedDefault >>= bStacked;
349 mrSeriesDefaultsAndStyles.maPercentDefault = xProp->getPropertyValue("Percent");
350 mrSeriesDefaultsAndStyles.maPercentDefault >>= mbPercentStacked;
351 mrSeriesDefaultsAndStyles.maStackedBarsConnectedDefault = xProp->getPropertyValue("StackedBarsConnected");
353 // deep
354 uno::Any aDeepProperty( xProp->getPropertyValue("Deep"));
355 // #124488# old versions store a 3d area and 3D line deep chart with Deep==false => workaround for this
356 if( ! (bStacked || mbPercentStacked ))
358 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
360 bool bIs3d = false;
361 if( ( xProp->getPropertyValue("Dim3D") >>= bIs3d ) &&
362 bIs3d )
364 if( maChartTypeServiceName == "com.sun.star.chart2.AreaChartType" || maChartTypeServiceName == "com.sun.star.chart2.LineChartType" )
366 aDeepProperty <<= true;
371 mrSeriesDefaultsAndStyles.maDeepDefault = aDeepProperty;
373 xProp->getPropertyValue("NumberOfLines") >>= mnNumOfLinesProp;
374 xProp->getPropertyValue("Volume") >>= mbStockHasVolume;
376 catch( const uno::Exception & )
378 TOOLS_INFO_EXCEPTION("xmloff.chart", "PlotAreaContext:EndElement(): Exception caught");
380 } // if
382 bool bCreateInternalDataProvider = false;
383 if( m_rXLinkHRefAttributeToIndicateDataProvider == "." ) //data comes from the chart itself
384 bCreateInternalDataProvider = true;
385 else if( m_rXLinkHRefAttributeToIndicateDataProvider == ".." ) //data comes from the parent application
386 bCreateInternalDataProvider = false;
387 else if( !m_rXLinkHRefAttributeToIndicateDataProvider.isEmpty() ) //not supported so far to get the data by sibling objects -> fall back to chart itself
388 bCreateInternalDataProvider = true;
389 else if( !m_rbHasRangeAtPlotArea )
390 bCreateInternalDataProvider = true;
392 if( bCreateInternalDataProvider && mxNewDoc.is() )
394 // we have no complete range => we have own data, so switch the data
395 // provider to internal. Clone is not necessary, as we don't have any
396 // data yet.
397 mxNewDoc->createInternalDataProvider( false /* bCloneExistingData */ );
398 if( xProp.is() && mrDataRowSource!=chart::ChartDataRowSource_COLUMNS )
399 xProp->setPropertyValue("DataRowSource", uno::makeAny(mrDataRowSource) );
403 SvXMLImportContextRef SchXMLPlotAreaContext::CreateChildContext(
404 sal_uInt16 nPrefix,
405 const OUString& rLocalName,
406 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
408 SvXMLImportContext* pContext = nullptr;
409 const SvXMLTokenMap& rTokenMap = mrImportHelper.GetPlotAreaElemTokenMap();
411 switch( rTokenMap.Get( nPrefix, rLocalName ))
413 case XML_TOK_PA_COORDINATE_REGION_EXT:
414 case XML_TOK_PA_COORDINATE_REGION:
416 pContext = new SchXMLCoordinateRegionContext( GetImport(), nPrefix, rLocalName, m_aInnerPositioning );
418 break;
420 case XML_TOK_PA_AXIS:
422 bool bAddMissingXAxisForNetCharts = false;
423 bool bAdaptWrongPercentScaleValues = false;
424 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
426 //correct errors from older versions
428 // for NetCharts there were no xAxis exported to older files
429 // so we need to add the x axis here for those old NetChart files
430 if ( maChartTypeServiceName == "com.sun.star.chart2.NetChartType" )
431 bAddMissingXAxisForNetCharts = true;
433 //Issue 59288
434 if( mbPercentStacked )
435 bAdaptWrongPercentScaleValues = true;
438 bool bAdaptXAxisOrientationForOld2DBarCharts = false;
439 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_4( GetImport().GetModel() ) )
441 //issue74660
442 if ( maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
443 bAdaptXAxisOrientationForOld2DBarCharts = true;
446 pContext = new SchXMLAxisContext( mrImportHelper, GetImport(), rLocalName, mxDiagram, maAxes, mrCategoriesAddress,
447 bAddMissingXAxisForNetCharts, bAdaptWrongPercentScaleValues, bAdaptXAxisOrientationForOld2DBarCharts, m_bAxisPositionAttributeImported );
449 break;
451 case XML_TOK_PA_SERIES:
453 if( mxNewDoc.is())
455 pContext = new SchXMLSeries2Context(
456 mrImportHelper, GetImport(), rLocalName,
457 mxNewDoc, maAxes,
458 mrSeriesDefaultsAndStyles.maSeriesStyleVector,
459 mrSeriesDefaultsAndStyles.maRegressionStyleVector,
460 mnSeries,
461 mbStockHasVolume,
462 m_aGlobalSeriesImportInfo,
463 maChartTypeServiceName,
464 mrLSequencesPerIndex,
465 mbGlobalChartTypeUsedBySeries, maChartSize );
467 mnSeries++;
469 break;
471 case XML_TOK_PA_WALL:
472 pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
473 SchXMLWallFloorContext::CONTEXT_TYPE_WALL );
474 break;
475 case XML_TOK_PA_FLOOR:
476 pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
477 SchXMLWallFloorContext::CONTEXT_TYPE_FLOOR );
478 break;
480 case XML_TOK_PA_LIGHT_SOURCE:
481 pContext = maSceneImportHelper.create3DLightContext( nPrefix, rLocalName, xAttrList );
482 break;
484 // elements for stock charts
485 case XML_TOK_PA_STOCK_GAIN:
486 pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
487 SchXMLStockContext::CONTEXT_TYPE_GAIN );
488 break;
489 case XML_TOK_PA_STOCK_LOSS:
490 pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
491 SchXMLStockContext::CONTEXT_TYPE_LOSS );
492 break;
493 case XML_TOK_PA_STOCK_RANGE:
494 pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
495 SchXMLStockContext::CONTEXT_TYPE_RANGE );
496 break;
498 default:
499 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
502 return pContext;
505 void SchXMLPlotAreaContext::EndElement()
507 // set categories
508 if( !mrCategoriesAddress.isEmpty() && mxNewDoc.is())
510 uno::Reference< chart2::data::XDataProvider > xDataProvider(
511 mxNewDoc->getDataProvider() );
512 // @todo: correct coordinate system index
513 sal_Int32 nDimension( 0 );
514 ::std::vector< SchXMLAxis >::const_iterator aIt(
515 ::std::find_if( maAxes.begin(), maAxes.end(), lcl_AxisHasCategories()));
516 if( aIt != maAxes.end())
517 nDimension = static_cast< sal_Int32 >( (*aIt).eDimension );
518 SchXMLTools::CreateCategories(
519 xDataProvider, mxNewDoc, mrCategoriesAddress,
520 0 /* nCooSysIndex */,
521 nDimension, &mrLSequencesPerIndex );
524 uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY );
525 if( xDiaProp.is())
527 bool bIsThreeDim = false;
528 uno::Any aAny = xDiaProp->getPropertyValue("Dim3D");
529 aAny >>= bIsThreeDim;
531 // set 3d scene attributes
532 if( bIsThreeDim )
534 // set scene attributes at diagram
535 maSceneImportHelper.setSceneAttributes( xDiaProp );
538 // set correct number of lines at series
539 if( ! m_aGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && mnNumOfLinesProp > 0 && maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
543 xDiaProp->setPropertyValue("NumberOfLines",
544 uno::makeAny( mnNumOfLinesProp ));
546 catch( const uno::Exception & )
548 TOOLS_INFO_EXCEPTION("xmloff.chart", "Exception caught for property NumberOfLines");
552 // #i32366# stock has volume
553 if( mxDiagram->getDiagramType() == "com.sun.star.chart.StockDiagram" &&
554 mbStockHasVolume )
558 xDiaProp->setPropertyValue("Volume",
559 uno::makeAny( true ));
561 catch( const uno::Exception & )
563 TOOLS_INFO_EXCEPTION("xmloff.chart", "Exception caught for property Volume");
568 // set changed size and position after properties (esp. 3d)
570 uno::Reference< chart::XDiagramPositioning > xDiaPos( mxDiagram, uno::UNO_QUERY );
571 if( xDiaPos.is())
573 if( !m_aOuterPositioning.isAutomatic() )
575 if( m_aInnerPositioning.hasPosSize() )
576 xDiaPos->setDiagramPositionExcludingAxes( m_aInnerPositioning.getRectangle() );
577 else if( m_aOuterPositioning.hasPosSize() )
579 if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_3( GetImport().GetModel() ) ) //old version of OOo did write a wrong rectangle for the diagram size
580 xDiaPos->setDiagramPositionIncludingAxesAndAxisTitles( m_aOuterPositioning.getRectangle() );
581 else
582 xDiaPos->setDiagramPositionIncludingAxes( m_aOuterPositioning.getRectangle() );
587 SchXMLAxisContext::CorrectAxisPositions( uno::Reference< chart2::XChartDocument >( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ), maChartTypeServiceName, GetImport().GetODFVersion(), m_bAxisPositionAttributeImported );
590 SchXMLDataLabelSpanContext::SchXMLDataLabelSpanContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels):
591 SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName),
592 mrLabels(rLabels)
596 void SchXMLDataLabelSpanContext::Characters(const OUString& sChars)
598 mrLabels.push_back(sChars);
601 SchXMLDataLabelParaContext::SchXMLDataLabelParaContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels):
602 SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName),
603 mrLabels(rLabels)
607 SvXMLImportContextRef SchXMLDataLabelParaContext::CreateChildContext(
608 sal_uInt16 nPrefix,
609 const OUString& rLocalName,
610 const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
612 SvXMLImportContextRef xContext;
613 if ( IsXMLToken( rLocalName, XML_SPAN ) && nPrefix == XML_NAMESPACE_TEXT )
614 xContext = new SchXMLDataLabelSpanContext(GetImport(), rLocalName, mrLabels);
615 return xContext;
618 SchXMLDataLabelContext::SchXMLDataLabelContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels):
619 SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName),
620 mrLabels(rLabels)
624 SvXMLImportContextRef SchXMLDataLabelContext::CreateChildContext(
625 sal_uInt16 nPrefix,
626 const OUString& rLocalName,
627 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
629 SvXMLImportContextRef xContext;
630 if ( IsXMLToken( rLocalName, XML_P ) && nPrefix == XML_NAMESPACE_TEXT )
631 xContext = new SchXMLDataLabelParaContext(GetImport(), rLocalName, mrLabels);
633 if (!xContext)
634 xContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
636 return xContext;
640 SchXMLDataPointContext::SchXMLDataPointContext( SchXMLImportHelper& rImportHelper,
641 SvXMLImport& rImport, const OUString& rLocalName,
642 ::std::vector< DataRowPointStyle >& rStyleVector,
643 const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
644 sal_Int32& rIndex,
645 bool bSymbolSizeForSeriesIsMissingInFile ) :
646 SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
647 mrImportHelper( rImportHelper ),
648 mrStyleVector( rStyleVector ),
649 mrIndex( rIndex ),
650 mDataPoint(DataRowPointStyle::DATA_POINT, xSeries, rIndex, 1, OUString{})
652 mDataPoint.mbSymbolSizeForSeriesIsMissingInFile = bSymbolSizeForSeriesIsMissingInFile;
655 SvXMLImportContextRef SchXMLDataPointContext::CreateChildContext(
656 sal_uInt16 nPrefix,
657 const OUString& rLocalName,
658 const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
660 SvXMLImportContext* pContext = nullptr;
661 const SvXMLTokenMap& rTokenMap = mrImportHelper.GetSeriesElemTokenMap();
663 switch( rTokenMap.Get( nPrefix, rLocalName ))
665 case XML_TOK_SERIES_DATA_LABEL:
666 mbHasLabelParagraph = true;
667 pContext = new SchXMLDataLabelContext( GetImport(), rLocalName, mDataPoint.mCustomLabels);
668 break;
670 return pContext;
673 SchXMLDataPointContext::~SchXMLDataPointContext()
677 void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
679 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
680 OUString sAutoStyleName;
681 sal_Int32 nRepeat = 1;
682 OUString sCustomLabelField;
684 for( sal_Int16 i = 0; i < nAttrCount; i++ )
686 OUString sAttrName = xAttrList->getNameByIndex( i );
687 OUString aLocalName;
688 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
690 if( nPrefix == XML_NAMESPACE_CHART )
692 if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
694 sAutoStyleName = xAttrList->getValueByIndex( i );
695 mDataPoint.msStyleName = sAutoStyleName;
697 else if( IsXMLToken( aLocalName, XML_REPEATED ) )
699 nRepeat = xAttrList->getValueByIndex( i ).toInt32();
700 mDataPoint.m_nPointRepeat = nRepeat;
703 else if( nPrefix == XML_NAMESPACE_LO_EXT)
705 // Deprecated. New documents use the chart:data-label element
706 // instead in order to store custom label text.
707 if( IsXMLToken( aLocalName, XML_CUSTOM_LABEL_FIELD) && !mbHasLabelParagraph)
709 sCustomLabelField = xAttrList->getValueByIndex( i );
710 mDataPoint.mCustomLabels.push_back(sCustomLabelField);
715 mrIndex += nRepeat;
718 void SchXMLDataPointContext::EndElement()
720 if( !mDataPoint.msStyleName.isEmpty() || mDataPoint.mCustomLabels.size() > 0)
722 mrStyleVector.push_back( mDataPoint );
726 SchXMLPositionAttributesHelper::SchXMLPositionAttributesHelper( SvXMLImport& rImporter )
727 : m_rImport( rImporter )
728 , m_aPosition(0,0)
729 , m_aSize(0,0)
730 , m_bHasSizeWidth( false )
731 , m_bHasSizeHeight( false )
732 , m_bHasPositionX( false )
733 , m_bHasPositionY( false )
734 , m_bAutoSize( false )
735 , m_bAutoPosition( false )
739 SchXMLPositionAttributesHelper::~SchXMLPositionAttributesHelper()
743 bool SchXMLPositionAttributesHelper::hasPosSize() const
745 return (m_bHasPositionX && m_bHasPositionY) && (m_bHasSizeWidth && m_bHasSizeHeight);
748 bool SchXMLPositionAttributesHelper::isAutomatic() const
750 return m_bAutoSize || m_bAutoPosition;
753 void SchXMLPositionAttributesHelper::readPositioningAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
755 if( XML_NAMESPACE_SVG == nPrefix )
757 if( IsXMLToken( rLocalName, XML_X ) )
759 m_rImport.GetMM100UnitConverter().convertMeasureToCore(
760 m_aPosition.X, rValue );
761 m_bHasPositionX = true;
763 else if( IsXMLToken( rLocalName, XML_Y ) )
765 m_rImport.GetMM100UnitConverter().convertMeasureToCore(
766 m_aPosition.Y, rValue );
767 m_bHasPositionY = true;
769 else if( IsXMLToken( rLocalName, XML_WIDTH ) )
771 m_rImport.GetMM100UnitConverter().convertMeasureToCore(
772 m_aSize.Width, rValue );
773 m_bHasSizeWidth = true;
775 else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
777 m_rImport.GetMM100UnitConverter().convertMeasureToCore(
778 m_aSize.Height, rValue );
779 m_bHasSizeHeight = true;
784 void SchXMLPositionAttributesHelper::readAutomaticPositioningProperties( XMLPropStyleContext const * pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
786 if( pPropStyleContext && pStylesCtxt )
788 //handle automatic position and size
789 SchXMLTools::getPropertyFromContext(
790 "AutomaticSize", pPropStyleContext, pStylesCtxt ) >>= m_bAutoSize;
791 SchXMLTools::getPropertyFromContext(
792 "AutomaticPosition", pPropStyleContext, pStylesCtxt ) >>= m_bAutoPosition;
796 SchXMLCoordinateRegionContext::SchXMLCoordinateRegionContext(
797 SvXMLImport& rImport
798 , sal_uInt16 nPrefix
799 , const OUString& rLocalName
800 , SchXMLPositionAttributesHelper& rPositioning )
801 : SvXMLImportContext( rImport, nPrefix, rLocalName )
802 , m_rPositioning( rPositioning )
806 SchXMLCoordinateRegionContext::~SchXMLCoordinateRegionContext()
810 void SchXMLCoordinateRegionContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
812 // parse attributes
813 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
815 for( sal_Int16 i = 0; i < nAttrCount; i++ )
817 OUString sAttrName = xAttrList->getNameByIndex( i );
818 OUString aLocalName;
819 OUString aValue = xAttrList->getValueByIndex( i );
820 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
821 m_rPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
825 SchXMLWallFloorContext::SchXMLWallFloorContext(
826 SchXMLImportHelper& rImpHelper,
827 SvXMLImport& rImport,
828 sal_uInt16 nPrefix,
829 const OUString& rLocalName,
830 uno::Reference< chart::XDiagram > const & xDiagram,
831 ContextType eContextType ) :
832 SvXMLImportContext( rImport, nPrefix, rLocalName ),
833 mrImportHelper( rImpHelper ),
834 mxWallFloorSupplier( xDiagram, uno::UNO_QUERY ),
835 meContextType( eContextType )
839 SchXMLWallFloorContext::~SchXMLWallFloorContext()
843 void SchXMLWallFloorContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
845 if( mxWallFloorSupplier.is())
847 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
848 OUString sAutoStyleName;
850 for( sal_Int16 i = 0; i < nAttrCount; i++ )
852 OUString sAttrName = xAttrList->getNameByIndex( i );
853 OUString aLocalName;
854 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
856 if( nPrefix == XML_NAMESPACE_CHART &&
857 IsXMLToken( aLocalName, XML_STYLE_NAME ) )
859 sAutoStyleName = xAttrList->getValueByIndex( i );
863 // set properties
864 uno::Reference< beans::XPropertySet > xProp = ( meContextType == CONTEXT_TYPE_WALL )
865 ? mxWallFloorSupplier->getWall()
866 : mxWallFloorSupplier->getFloor();
868 if (!sAutoStyleName.isEmpty())
869 mrImportHelper.FillAutoStyle(sAutoStyleName, xProp);
873 SchXMLStockContext::SchXMLStockContext(
874 SchXMLImportHelper& rImpHelper,
875 SvXMLImport& rImport,
876 sal_uInt16 nPrefix,
877 const OUString& rLocalName,
878 uno::Reference< chart::XDiagram > const & xDiagram,
879 ContextType eContextType ) :
880 SvXMLImportContext( rImport, nPrefix, rLocalName ),
881 mrImportHelper( rImpHelper ),
882 mxStockPropProvider( xDiagram, uno::UNO_QUERY ),
883 meContextType( eContextType )
887 SchXMLStockContext::~SchXMLStockContext()
891 void SchXMLStockContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
893 if( mxStockPropProvider.is())
895 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
896 OUString sAutoStyleName;
898 for( sal_Int16 i = 0; i < nAttrCount; i++ )
900 OUString sAttrName = xAttrList->getNameByIndex( i );
901 OUString aLocalName;
902 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
904 if( nPrefix == XML_NAMESPACE_CHART &&
905 IsXMLToken( aLocalName, XML_STYLE_NAME ) )
907 sAutoStyleName = xAttrList->getValueByIndex( i );
911 if( !sAutoStyleName.isEmpty())
913 // set properties
914 uno::Reference< beans::XPropertySet > xProp;
915 switch( meContextType )
917 case CONTEXT_TYPE_GAIN:
918 xProp = mxStockPropProvider->getUpBar();
919 break;
920 case CONTEXT_TYPE_LOSS:
921 xProp = mxStockPropProvider->getDownBar();
922 break;
923 case CONTEXT_TYPE_RANGE:
924 xProp = mxStockPropProvider->getMinMaxLine();
925 break;
928 mrImportHelper.FillAutoStyle(sAutoStyleName, xProp);
933 static void lcl_setErrorBarSequence ( const uno::Reference< chart2::XChartDocument > &xDoc,
934 const uno::Reference< beans::XPropertySet > &xBarProp,
935 const OUString &aXMLRange,
936 bool bPositiveValue, bool bYError,
937 tSchXMLLSequencesPerIndex& rSequences)
939 uno::Reference< css::chart2::data::XDataProvider > xDataProvider(xDoc->getDataProvider());
940 uno::Reference< css::chart2::data::XDataSource > xDataSource( xBarProp, uno::UNO_QUERY );
941 uno::Reference< css::chart2::data::XDataSink > xDataSink( xDataSource, uno::UNO_QUERY );
943 assert( xDataSink.is() && xDataSource.is() && xDataProvider.is() );
945 OUString aRange(lcl_ConvertRange(aXMLRange,xDoc));
947 uno::Reference< chart2::data::XDataSequence > xNewSequence(
948 xDataProvider->createDataSequenceByRangeRepresentation( aRange ));
950 if( !xNewSequence.is())
951 return;
953 SchXMLTools::setXMLRangePropertyAtDataSequence(xNewSequence,aXMLRange);
955 OUStringBuffer aRoleBuffer("error-bars-");
956 if( bYError )
957 aRoleBuffer.append( 'y' );
958 else
959 aRoleBuffer.append( 'x');
961 aRoleBuffer.append( '-' );
963 if( bPositiveValue )
964 aRoleBuffer = aRoleBuffer.append( "positive" );
965 else
966 aRoleBuffer = aRoleBuffer.append( "negative" );
968 OUString aRole = aRoleBuffer.makeStringAndClear();
970 Reference< beans::XPropertySet > xSeqProp( xNewSequence, uno::UNO_QUERY );
972 xSeqProp->setPropertyValue("Role", uno::makeAny( aRole ));
974 Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
976 Reference< chart2::data::XLabeledDataSequence > xLabelSeq( chart2::data::LabeledDataSequence::create(xContext),
977 uno::UNO_QUERY_THROW );
979 rSequences.emplace( tSchXMLIndexWithPart( -2, SCH_XML_PART_ERROR_BARS ), xLabelSeq );
981 xLabelSeq->setValues( xNewSequence );
983 uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
984 xDataSource->getDataSequences());
986 aSequences.realloc( aSequences.getLength() + 1 );
987 aSequences[ aSequences.getLength() - 1 ] = xLabelSeq;
988 xDataSink->setData( aSequences );
992 SchXMLStatisticsObjectContext::SchXMLStatisticsObjectContext(
993 SchXMLImportHelper& rImpHelper,
994 SvXMLImport& rImport,
995 sal_uInt16 nPrefix,
996 const OUString& rLocalName,
997 const OUString &rSeriesStyleName,
998 ::std::vector< DataRowPointStyle >& rStyleVector,
999 const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
1000 ContextType eContextType,
1001 tSchXMLLSequencesPerIndex & rLSequencesPerIndex) :
1003 SvXMLImportContext( rImport, nPrefix, rLocalName ),
1004 mrImportHelper( rImpHelper ),
1005 mrStyleVector( rStyleVector ),
1006 m_xSeries( xSeries ),
1007 meContextType( eContextType ),
1008 maSeriesStyleName( rSeriesStyleName),
1009 mrLSequencesPerIndex(rLSequencesPerIndex)
1012 SchXMLStatisticsObjectContext::~SchXMLStatisticsObjectContext()
1016 namespace {
1018 void SetErrorBarStyleProperties( const OUString& rStyleName, const uno::Reference< beans::XPropertySet >& xBarProp,
1019 SchXMLImportHelper const & rImportHelper )
1021 const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
1022 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(SchXMLImportHelper::GetChartFamilyID(),
1023 rStyleName);
1025 XMLPropStyleContext &rSeriesStyleContext =
1026 const_cast< XMLPropStyleContext& >( dynamic_cast< const XMLPropStyleContext& >( *pStyle ));
1028 rSeriesStyleContext.FillPropertySet( xBarProp );
1031 void SetErrorBarPropertiesFromStyleName( const OUString& aStyleName, const uno::Reference< beans::XPropertySet>& xBarProp,
1032 SchXMLImportHelper const & rImportHelper, OUString& aPosRange, OUString& aNegRange)
1034 const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
1035 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(SchXMLImportHelper::GetChartFamilyID(),
1036 aStyleName);
1038 XMLPropStyleContext * pSeriesStyleContext =
1039 const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
1041 uno::Any aAny = SchXMLTools::getPropertyFromContext("ErrorBarStyle",
1042 pSeriesStyleContext,pStylesCtxt);
1044 if ( !aAny.hasValue() )
1045 return;
1047 sal_Int32 aBarStyle = css::chart::ErrorBarStyle::NONE;
1048 aAny >>= aBarStyle;
1049 xBarProp->setPropertyValue("ErrorBarStyle", aAny);
1051 aAny = SchXMLTools::getPropertyFromContext("ShowPositiveError",
1052 pSeriesStyleContext,pStylesCtxt);
1054 if(aAny.hasValue())
1055 xBarProp->setPropertyValue("ShowPositiveError",aAny);
1057 aAny = SchXMLTools::getPropertyFromContext("ShowNegativeError",
1058 pSeriesStyleContext,pStylesCtxt);
1060 if(aAny.hasValue())
1061 xBarProp->setPropertyValue("ShowNegativeError",aAny);
1063 aAny = SchXMLTools::getPropertyFromContext("PositiveError",
1064 pSeriesStyleContext, pStylesCtxt);
1066 if(aAny.hasValue())
1067 xBarProp->setPropertyValue("PositiveError", aAny);
1068 else
1070 aAny = SchXMLTools::getPropertyFromContext("ConstantErrorHigh",
1071 pSeriesStyleContext, pStylesCtxt);
1073 if(aAny.hasValue())
1074 xBarProp->setPropertyValue("PositiveError", aAny);
1077 aAny = SchXMLTools::getPropertyFromContext("NegativeError",
1078 pSeriesStyleContext, pStylesCtxt);
1080 if(aAny.hasValue())
1081 xBarProp->setPropertyValue("NegativeError", aAny);
1082 else
1084 aAny = SchXMLTools::getPropertyFromContext("ConstantErrorLow",
1085 pSeriesStyleContext, pStylesCtxt);
1087 if(aAny.hasValue())
1088 xBarProp->setPropertyValue("NegativeError", aAny);
1091 aAny = SchXMLTools::getPropertyFromContext("ErrorBarRangePositive",
1092 pSeriesStyleContext, pStylesCtxt);
1093 if( aAny.hasValue() )
1095 aAny >>= aPosRange;
1098 aAny = SchXMLTools::getPropertyFromContext("ErrorBarRangeNegative",
1099 pSeriesStyleContext, pStylesCtxt);
1100 if( aAny.hasValue() )
1102 aAny >>= aNegRange;
1105 aAny = SchXMLTools::getPropertyFromContext("Weight",
1106 pSeriesStyleContext, pStylesCtxt);
1107 if( aAny.hasValue() )
1109 xBarProp->setPropertyValue("Weight", aAny);
1112 aAny = SchXMLTools::getPropertyFromContext("PercentageError",
1113 pSeriesStyleContext, pStylesCtxt);
1114 if( aAny.hasValue() && aBarStyle == css::chart::ErrorBarStyle::RELATIVE )
1116 xBarProp->setPropertyValue("PositiveError", aAny);
1117 xBarProp->setPropertyValue("NegativeError", aAny);
1120 switch(aBarStyle)
1122 case css::chart::ErrorBarStyle::ERROR_MARGIN:
1124 aAny = SchXMLTools::getPropertyFromContext("NegativeError",
1125 pSeriesStyleContext,pStylesCtxt);
1127 xBarProp->setPropertyValue("NegativeError",aAny);
1129 aAny = SchXMLTools::getPropertyFromContext("PositiveError",
1130 pSeriesStyleContext,pStylesCtxt);
1132 xBarProp->setPropertyValue("PositiveError",aAny);
1134 break;
1135 default:
1136 break;
1143 void SchXMLStatisticsObjectContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1145 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
1146 OUString sAutoStyleName;
1147 OUString aPosRange;
1148 OUString aNegRange;
1149 bool bYError = true; /// Default errorbar, to be backward compatible with older files!
1151 for( sal_Int16 i = 0; i < nAttrCount; i++ )
1153 OUString sAttrName = xAttrList->getNameByIndex( i );
1154 OUString aLocalName;
1156 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
1158 if( nPrefix == XML_NAMESPACE_CHART )
1160 if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1161 sAutoStyleName = xAttrList->getValueByIndex( i );
1162 else if( IsXMLToken( aLocalName, XML_DIMENSION ) )
1163 bYError = xAttrList->getValueByIndex(i) == "y";
1164 else if( IsXMLToken( aLocalName, XML_ERROR_UPPER_RANGE) )
1165 aPosRange = xAttrList->getValueByIndex(i);
1166 else if( IsXMLToken( aLocalName, XML_ERROR_LOWER_RANGE) )
1167 aNegRange = xAttrList->getValueByIndex(i);
1171 if( !sAutoStyleName.isEmpty() )
1173 DataRowPointStyle aStyle( DataRowPointStyle::MEAN_VALUE, m_xSeries, -1, 1, sAutoStyleName );
1175 switch( meContextType )
1177 case CONTEXT_TYPE_MEAN_VALUE_LINE:
1178 aStyle.meType = DataRowPointStyle::MEAN_VALUE;
1179 break;
1180 case CONTEXT_TYPE_ERROR_INDICATOR:
1182 aStyle.meType = DataRowPointStyle::ERROR_INDICATOR;
1184 uno::Reference< lang::XMultiServiceFactory > xFact = comphelper::getProcessServiceFactory();
1186 uno::Reference< beans::XPropertySet > xBarProp( xFact->createInstance("com.sun.star.chart2.ErrorBar" ),
1187 uno::UNO_QUERY );
1189 xBarProp->setPropertyValue("ErrorBarStyle",uno::makeAny(css::chart::ErrorBarStyle::NONE));
1190 xBarProp->setPropertyValue("PositiveError",uno::makeAny(0.0));
1191 xBarProp->setPropertyValue("NegativeError",uno::makeAny(0.0));
1192 xBarProp->setPropertyValue("Weight",uno::makeAny(1.0));
1193 xBarProp->setPropertyValue("ShowPositiveError",uno::makeAny(true));
1194 xBarProp->setPropertyValue("ShowNegativeError",uno::makeAny(true));
1196 // first import defaults from parent style
1197 SetErrorBarStyleProperties( maSeriesStyleName, xBarProp, mrImportHelper );
1198 SetErrorBarStyleProperties( sAutoStyleName, xBarProp, mrImportHelper );
1199 SetErrorBarPropertiesFromStyleName( maSeriesStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1200 SetErrorBarPropertiesFromStyleName( sAutoStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1202 uno::Reference< chart2::XChartDocument > xDoc(GetImport().GetModel(),uno::UNO_QUERY);
1204 if (!aPosRange.isEmpty())
1205 lcl_setErrorBarSequence(xDoc,xBarProp,aPosRange,true,bYError, mrLSequencesPerIndex);
1207 if (!aNegRange.isEmpty())
1208 lcl_setErrorBarSequence(xDoc,xBarProp,aNegRange,false,bYError, mrLSequencesPerIndex);
1210 if ( !bYError )
1212 aStyle.m_xErrorXProperties.set( xBarProp );
1214 else
1216 aStyle.m_xErrorYProperties.set( xBarProp );
1219 break;
1222 mrStyleVector.push_back( aStyle );
1226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */