LibreOffice Module xmloff (master)  1
SchXMLPlotAreaContext.cxx
Go to the documentation of this file.
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 
21 #include <SchXMLImport.hxx>
22 #include "SchXMLAxisContext.hxx"
23 #include "SchXMLSeries2Context.hxx"
24 #include "SchXMLTools.hxx"
25 
27 #include <sal/log.hxx>
28 #include <tools/diagnose_ex.h>
29 #include <xmloff/xmlnamespace.hxx>
30 #include <xmloff/namespacemap.hxx>
31 #include <xmloff/xmluconv.hxx>
32 #include <xmloff/prstylei.hxx>
33 #include <xmloff/xmlstyle.hxx>
35 
36 #include <com/sun/star/awt/Point.hpp>
37 #include <com/sun/star/awt/Size.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>
51 
52 using namespace com::sun::star;
53 using namespace ::xmloff::token;
54 
56 
57 namespace
58 {
59 
60 struct lcl_AxisHasCategories
61 {
62  bool operator() ( const SchXMLAxis & rAxis )
63  {
64  return rAxis.bHasCategories;
65  }
66 };
67 
68 OUString lcl_ConvertRange( const OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
69 {
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;
78 }
79 
80 } // anonymous namespace
81 
83  : SdXML3DSceneAttributesHelper( rImporter )
84 {
85 }
86 
87 void SchXML3DSceneAttributesHelper::getCameraDefaultFromDiagram( const uno::Reference< chart::XDiagram >& xDiagram )
88 {
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
91 
92  try
93  {
94  uno::Reference< beans::XPropertySet > xProp( xDiagram, uno::UNO_QUERY );
95  if( xProp.is() )
96  {
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 );
108  }
109  }
110  catch( const uno::Exception & )
111  {
112  TOOLS_INFO_EXCEPTION("xmloff.chart", "Exception caught for property NumberOfLines");
113  }
114 }
115 
117 {
118 }
119 
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 )
158 {
159  m_rbHasRangeAtPlotArea = false;
160 
161  // get Diagram
162  uno::Reference< chart::XChartDocument > xDoc = rImpHelper.GetChartDocument();
163  if( xDoc.is())
164  {
165  mxDiagram = xDoc->getDiagram();
166  mxNewDoc.set( xDoc, uno::UNO_QUERY );
167 
169  }
170  SAL_WARN_IF( !mxDiagram.is(),"xmloff.chart", "Couldn't get XDiagram" );
171 
172  // turn off all axes initially
173  uno::Any aFalseBool;
174  aFalseBool <<= false;
175 
176  uno::Reference< lang::XServiceInfo > xInfo( mxDiagram, uno::UNO_QUERY );
177  uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
178  if( !xInfo.is() || !xProp.is() )
179  return;
180 
181  try
182  {
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 );
188 
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 );
194 
195  xProp->setPropertyValue("HasZAxis", aFalseBool );
196  xProp->setPropertyValue("HasZAxisDescription", aFalseBool );
197 
198  xProp->setPropertyValue("DataRowSource", uno::Any(chart::ChartDataRowSource_COLUMNS) );
199  }
200  catch( const beans::UnknownPropertyException & )
201  {
202  SAL_WARN("xmloff.chart", "Property required by service not supported" );
203  }
204 }
205 
207 {}
208 
209 void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
210 {
211  // parse attributes
212  sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
213  const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetPlotAreaAttrTokenMap();
214  uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
215 
216  for( sal_Int16 i = 0; i < nAttrCount; i++ )
217  {
218  OUString sAttrName = xAttrList->getNameByIndex( i );
219  OUString aLocalName;
220  OUString aValue = xAttrList->getValueByIndex( i );
221  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
222 
223  switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
224  {
225  case XML_TOK_PA_X:
226  case XML_TOK_PA_Y:
227  case XML_TOK_PA_WIDTH:
228  case XML_TOK_PA_HEIGHT:
229  m_aOuterPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
230  break;
232  msAutoStyleName = aValue;
233  break;
235  mrChartAddress = lcl_ConvertRange( aValue, xNewDoc );
236  // indicator for getting data from the outside
237  m_rbHasRangeAtPlotArea = true;
238  break;
240  {
243  else if( aValue == ::xmloff::token::GetXMLToken( ::xmloff::token::XML_ROW ))
244  mrRowHasLabels = true;
245  else if( aValue == ::xmloff::token::GetXMLToken( ::xmloff::token::XML_COLUMN ))
246  mrColHasLabels = true;
247  }
248  break;
250  case XML_TOK_PA_VRP:
251  case XML_TOK_PA_VPN:
252  case XML_TOK_PA_VUP:
254  case XML_TOK_PA_DISTANCE:
260  maSceneImportHelper.processSceneAttribute( nPrefix, aLocalName, aValue );
261  break;
262  }
263  }
264 
265  if( ! mxNewDoc.is())
266  {
267  uno::Reference< beans::XPropertySet > xDocProp( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
268  if( xDocProp.is())
269  {
270  try
271  {
272  xDocProp->setPropertyValue("DataSourceLabelsInFirstColumn", uno::Any(mrColHasLabels) );
273  xDocProp->setPropertyValue("DataSourceLabelsInFirstRow", uno::Any(mrRowHasLabels) );
274  }
275  catch( const beans::UnknownPropertyException & )
276  {
277  SAL_WARN("xmloff.chart", "Properties missing" );
278  }
279  }
280  }
281 
282  // set properties
283  uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
284  if( !msAutoStyleName.isEmpty())
285  {
286  if( xProp.is())
287  {
289  if( pStylesCtxt )
290  {
291  const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
293 
294  XMLPropStyleContext* pPropStyleContext =
295  const_cast< XMLPropStyleContext * >(
296  dynamic_cast< const XMLPropStyleContext * >( pStyle ) );
297  if( pPropStyleContext )
298  {
299  pPropStyleContext->FillPropertySet( xProp );
300 
301  // get the data row source that was set without having data
302  xProp->getPropertyValue("DataRowSource")
303  >>= mrDataRowSource;
304 
305  //lines on/off
306  //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  "Lines", pPropStyleContext, pStylesCtxt );
309 
310  //handle automatic position and size
311  m_aOuterPositioning.readAutomaticPositioningProperties( pPropStyleContext, pStylesCtxt );
312 
313  //correct default starting angle for old 3D pies
315  {
316  bool bIs3d = false;
317  if( xProp.is() && ( xProp->getPropertyValue("Dim3D") >>= bIs3d ) &&
318  bIs3d )
319  {
320  if( maChartTypeServiceName == "com.sun.star.chart2.PieChartType" || maChartTypeServiceName == "com.sun.star.chart2.DonutChartType" )
321  {
322  OUString aPropName( "StartingAngle" );
323  uno::Any aAStartingAngle( SchXMLTools::getPropertyFromContext( aPropName, pPropStyleContext, pStylesCtxt ) );
324  if( !aAStartingAngle.hasValue() )
325  xProp->setPropertyValue( aPropName, uno::makeAny(sal_Int32(0)) ) ;
326  }
327  }
328  }
329  }
330  }
331  }
332  }
333 
334  //remember default values for dataseries
335  if(xProp.is())
336  {
337  try
338  {
339  mrSeriesDefaultsAndStyles.maSymbolTypeDefault = xProp->getPropertyValue("SymbolType");
340  mrSeriesDefaultsAndStyles.maDataCaptionDefault = xProp->getPropertyValue("DataCaption");
341 
342  mrSeriesDefaultsAndStyles.maMeanValueDefault = xProp->getPropertyValue("MeanValue");
343  mrSeriesDefaultsAndStyles.maRegressionCurvesDefault = xProp->getPropertyValue("RegressionCurves");
344 
345  bool bStacked = false;
346  mrSeriesDefaultsAndStyles.maStackedDefault = xProp->getPropertyValue("Stacked");
348  mrSeriesDefaultsAndStyles.maPercentDefault = xProp->getPropertyValue("Percent");
350  mrSeriesDefaultsAndStyles.maStackedBarsConnectedDefault = xProp->getPropertyValue("StackedBarsConnected");
351 
352  // deep
353  uno::Any aDeepProperty( xProp->getPropertyValue("Deep"));
354  // #124488# old versions store a 3d area and 3D line deep chart with Deep==false => workaround for this
355  if( ! (bStacked || mbPercentStacked ))
356  {
358  {
359  bool bIs3d = false;
360  if( ( xProp->getPropertyValue("Dim3D") >>= bIs3d ) &&
361  bIs3d )
362  {
363  if( maChartTypeServiceName == "com.sun.star.chart2.AreaChartType" || maChartTypeServiceName == "com.sun.star.chart2.LineChartType" )
364  {
365  aDeepProperty <<= true;
366  }
367  }
368  }
369  }
371 
372  xProp->getPropertyValue("NumberOfLines") >>= mnNumOfLinesProp;
373  xProp->getPropertyValue("Volume") >>= mbStockHasVolume;
374  }
375  catch( const uno::Exception & )
376  {
377  TOOLS_INFO_EXCEPTION("xmloff.chart", "PlotAreaContext:EndElement(): Exception caught");
378  }
379  } // if
380 
381  bool bCreateInternalDataProvider = false;
382  if( m_rXLinkHRefAttributeToIndicateDataProvider == "." ) //data comes from the chart itself
383  bCreateInternalDataProvider = true;
384  else if( m_rXLinkHRefAttributeToIndicateDataProvider == ".." ) //data comes from the parent application
385  bCreateInternalDataProvider = false;
386  else if( !m_rXLinkHRefAttributeToIndicateDataProvider.isEmpty() ) //not supported so far to get the data by sibling objects -> fall back to chart itself
387  bCreateInternalDataProvider = true;
388  else if( !m_rbHasRangeAtPlotArea )
389  bCreateInternalDataProvider = true;
390 
391  if( bCreateInternalDataProvider && mxNewDoc.is() )
392  {
393  // we have no complete range => we have own data, so switch the data
394  // provider to internal. Clone is not necessary, as we don't have any
395  // data yet.
396  mxNewDoc->createInternalDataProvider( false /* bCloneExistingData */ );
397  if( xProp.is() && mrDataRowSource!=chart::ChartDataRowSource_COLUMNS )
398  xProp->setPropertyValue("DataRowSource", uno::makeAny(mrDataRowSource) );
399  }
400 }
401 
403  sal_uInt16 nPrefix,
404  const OUString& rLocalName,
405  const uno::Reference< xml::sax::XAttributeList >& xAttrList )
406 {
407  SvXMLImportContext* pContext = nullptr;
409 
410  switch( rTokenMap.Get( nPrefix, rLocalName ))
411  {
414  {
415  pContext = new SchXMLCoordinateRegionContext( GetImport(), nPrefix, rLocalName, m_aInnerPositioning );
416  }
417  break;
418 
419  case XML_TOK_PA_AXIS:
420  {
421  bool bAddMissingXAxisForNetCharts = false;
422  bool bAdaptWrongPercentScaleValues = false;
424  {
425  //correct errors from older versions
426 
427  // for NetCharts there were no xAxis exported to older files
428  // so we need to add the x axis here for those old NetChart files
429  if ( maChartTypeServiceName == "com.sun.star.chart2.NetChartType" )
430  bAddMissingXAxisForNetCharts = true;
431 
432  //Issue 59288
433  if( mbPercentStacked )
434  bAdaptWrongPercentScaleValues = true;
435  }
436 
437  bool bAdaptXAxisOrientationForOld2DBarCharts = false;
439  {
440  //issue74660
441  if ( maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
442  bAdaptXAxisOrientationForOld2DBarCharts = true;
443  }
444 
446  bAddMissingXAxisForNetCharts, bAdaptWrongPercentScaleValues, bAdaptXAxisOrientationForOld2DBarCharts, m_bAxisPositionAttributeImported );
447  }
448  break;
449 
450  case XML_TOK_PA_SERIES:
451  {
452  if( mxNewDoc.is())
453  {
454  pContext = new SchXMLSeries2Context(
455  mrImportHelper, GetImport(), rLocalName,
456  mxNewDoc, maAxes,
459  mnSeries,
465  }
466  mnSeries++;
467  }
468  break;
469 
470  case XML_TOK_PA_WALL:
471  pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
473  break;
474  case XML_TOK_PA_FLOOR:
475  pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
477  break;
478 
480  pContext = maSceneImportHelper.create3DLightContext( nPrefix, rLocalName, xAttrList );
481  break;
482 
483  // elements for stock charts
485  pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
487  break;
489  pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
491  break;
493  pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
495  break;
496  }
497 
498  return pContext;
499 }
500 
502 {
503  // set categories
504  if( !mrCategoriesAddress.isEmpty() && mxNewDoc.is())
505  {
506  uno::Reference< chart2::data::XDataProvider > xDataProvider(
507  mxNewDoc->getDataProvider() );
508  // @todo: correct coordinate system index
509  sal_Int32 nDimension( 0 );
510  ::std::vector< SchXMLAxis >::const_iterator aIt(
511  ::std::find_if( maAxes.begin(), maAxes.end(), lcl_AxisHasCategories()));
512  if( aIt != maAxes.end())
513  nDimension = static_cast< sal_Int32 >( (*aIt).eDimension );
515  xDataProvider, mxNewDoc, mrCategoriesAddress,
516  0 /* nCooSysIndex */,
517  nDimension, &mrLSequencesPerIndex );
518  }
519 
520  uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY );
521  if( xDiaProp.is())
522  {
523  bool bIsThreeDim = false;
524  uno::Any aAny = xDiaProp->getPropertyValue("Dim3D");
525  aAny >>= bIsThreeDim;
526 
527  // set 3d scene attributes
528  if( bIsThreeDim )
529  {
530  // set scene attributes at diagram
532  }
533 
534  // set correct number of lines at series
535  if( ! m_aGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && mnNumOfLinesProp > 0 && maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
536  {
537  try
538  {
539  xDiaProp->setPropertyValue("NumberOfLines",
540  uno::makeAny( mnNumOfLinesProp ));
541  }
542  catch( const uno::Exception & )
543  {
544  TOOLS_INFO_EXCEPTION("xmloff.chart", "Exception caught for property NumberOfLines");
545  }
546  }
547 
548  // #i32366# stock has volume
549  if( mxDiagram->getDiagramType() == "com.sun.star.chart.StockDiagram" &&
551  {
552  try
553  {
554  xDiaProp->setPropertyValue("Volume",
555  uno::makeAny( true ));
556  }
557  catch( const uno::Exception & )
558  {
559  TOOLS_INFO_EXCEPTION("xmloff.chart", "Exception caught for property Volume");
560  }
561  }
562  }
563 
564  // set changed size and position after properties (esp. 3d)
565 
566  uno::Reference< chart::XDiagramPositioning > xDiaPos( mxDiagram, uno::UNO_QUERY );
567  if( xDiaPos.is())
568  {
570  {
572  xDiaPos->setDiagramPositionExcludingAxes( m_aInnerPositioning.getRectangle() );
573  else if( m_aOuterPositioning.hasPosSize() )
574  {
575  if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_3( GetImport().GetModel() ) ) //old version of OOo did write a wrong rectangle for the diagram size
576  xDiaPos->setDiagramPositionIncludingAxesAndAxisTitles( m_aOuterPositioning.getRectangle() );
577  else
578  xDiaPos->setDiagramPositionIncludingAxes( m_aOuterPositioning.getRectangle() );
579  }
580  }
581  }
582 
584 }
585 
586 SchXMLDataLabelSpanContext::SchXMLDataLabelSpanContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels):
587  SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName),
588  mrLabels(rLabels)
589 {
590 }
591 
592 void SchXMLDataLabelSpanContext::Characters(const OUString& rChars)
593 {
594  maCharBuffer.append(rChars);
595 }
596 
598 {
599  mrLabels.push_back(maCharBuffer.makeStringAndClear());
600 }
601 
602 SchXMLDataLabelParaContext::SchXMLDataLabelParaContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels):
603  SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName),
604  mrLabels(rLabels)
605 {
606 }
607 
609  sal_uInt16 nPrefix,
610  const OUString& rLocalName,
611  const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
612 {
613  SvXMLImportContextRef xContext;
614  if ( IsXMLToken( rLocalName, XML_SPAN ) && nPrefix == XML_NAMESPACE_TEXT )
615  xContext = new SchXMLDataLabelSpanContext(GetImport(), rLocalName, mrLabels);
616  return xContext;
617 }
618 
619 SchXMLDataLabelContext::SchXMLDataLabelContext(SvXMLImport& rImport, const OUString& rLocalName,
620  ::std::vector<OUString>& rLabels,
621  DataRowPointStyle& rDataLabelStyle)
622  : SvXMLImportContext(rImport, XML_NAMESPACE_CHART, rLocalName)
623  , mrLabels(rLabels)
624  , mrDataLabelStyle(rDataLabelStyle)
625 {
626 }
627 
629  sal_uInt16 nPrefix,
630  const OUString& rLocalName,
631  const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
632 {
633  SvXMLImportContextRef xContext;
634  if ( IsXMLToken( rLocalName, XML_P ) && nPrefix == XML_NAMESPACE_TEXT )
635  xContext = new SchXMLDataLabelParaContext(GetImport(), rLocalName, mrLabels);
636 
637  return xContext;
638 }
639 
640 void SchXMLDataLabelContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& xAttrList)
641 {
642  const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
643  const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
644  for (sal_Int16 i = 0; i < nAttrCount; i++)
645  {
646  const OUString& rAttrName = xAttrList->getNameByIndex(i);
647  OUString aLocalName;
648  sal_uInt16 nPrefix = rMap.GetKeyByAttrName(rAttrName, &aLocalName);
649  const OUString sValue(xAttrList->getValueByIndex(i));
650 
651  if (nPrefix == XML_NAMESPACE_SVG)
652  {
653  if (IsXMLToken(aLocalName, XML_X))
654  {
655  sal_Int32 nResultValue;
656  GetImport().GetMM100UnitConverter().convertMeasureToCore(nResultValue, sValue);
658  }
659  else if (IsXMLToken(aLocalName, XML_Y))
660  {
661  sal_Int32 nResultValue;
662  GetImport().GetMM100UnitConverter().convertMeasureToCore(nResultValue, sValue);
664  }
665  }
666  else if (nPrefix == XML_NAMESPACE_CHART)
667  {
668  if (IsXMLToken(aLocalName, XML_STYLE_NAME))
669  {
670  mrDataLabelStyle.msStyleName = sValue;
671  }
672  }
673  }
674 }
675 
676 
678  SvXMLImport& rImport, const OUString& rLocalName,
679  ::std::vector< DataRowPointStyle >& rStyleVector,
680  const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
681  sal_Int32& rIndex,
682  bool bSymbolSizeForSeriesIsMissingInFile ) :
683  SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
684  mrImportHelper( rImportHelper ),
685  mrStyleVector( rStyleVector ),
686  mrIndex( rIndex ),
687  mDataPoint(DataRowPointStyle::DATA_POINT, xSeries, rIndex, 1, OUString{}),
688  mDataLabel(DataRowPointStyle::DATA_LABEL_POINT, xSeries, rIndex, 1, OUString{})
689 {
690  mDataPoint.mbSymbolSizeForSeriesIsMissingInFile = bSymbolSizeForSeriesIsMissingInFile;
691 }
692 
694  sal_uInt16 nPrefix,
695  const OUString& rLocalName,
696  const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
697 {
698  SvXMLImportContext* pContext = nullptr;
700 
701  switch( rTokenMap.Get( nPrefix, rLocalName ))
702  {
704  mbHasLabelParagraph = true;
705  pContext = new SchXMLDataLabelContext(GetImport(), rLocalName, mDataPoint.mCustomLabels,
706  mDataLabel);
707  break;
708  }
709  return pContext;
710 }
711 
713 {
714 }
715 
716 void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
717 {
718  sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
719  OUString sAutoStyleName;
720  sal_Int32 nRepeat = 1;
721  OUString sCustomLabelField;
722 
723  for( sal_Int16 i = 0; i < nAttrCount; i++ )
724  {
725  OUString sAttrName = xAttrList->getNameByIndex( i );
726  OUString aLocalName;
727  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
728 
729  if( nPrefix == XML_NAMESPACE_CHART )
730  {
731  if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
732  {
733  sAutoStyleName = xAttrList->getValueByIndex( i );
734  mDataPoint.msStyleName = sAutoStyleName;
735  mDataLabel.msStyleNameOfParent = sAutoStyleName;
736  }
737  else if( IsXMLToken( aLocalName, XML_REPEATED ) )
738  {
739  nRepeat = xAttrList->getValueByIndex( i ).toInt32();
740  mDataPoint.m_nPointRepeat = nRepeat;
741  mDataLabel.m_nPointRepeat = nRepeat;
742  }
743  }
744  else if( nPrefix == XML_NAMESPACE_LO_EXT)
745  {
746  // Deprecated. New documents use the chart:data-label element
747  // instead in order to store custom label text.
749  {
750  sCustomLabelField = xAttrList->getValueByIndex( i );
751  mDataPoint.mCustomLabels.push_back(sCustomLabelField);
752  }
753  else if (IsXMLToken(aLocalName, XML_HIDE_LEGEND))
754  {
755  bool bHideLegend = xAttrList->getValueByIndex(i).toBoolean();
756  if (bHideLegend)
757  {
758  uno::Sequence<sal_Int32> deletedLegendEntriesSeq;
759  Reference<beans::XPropertySet> xSeriesProp(mDataPoint.m_xSeries, uno::UNO_QUERY);
760  xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq;
761  std::vector<sal_Int32> deletedLegendEntries;
762  for (auto& deletedLegendEntry : deletedLegendEntriesSeq)
763  {
764  deletedLegendEntries.push_back(deletedLegendEntry);
765  }
766  deletedLegendEntries.push_back(mDataPoint.m_nPointIndex);
767  xSeriesProp->setPropertyValue("DeletedLegendEntries", uno::makeAny(::oox::ContainerHelper::vectorToSequence(deletedLegendEntries)));
768  }
769  }
770  else if( IsXMLToken(aLocalName, XML_CUSTOM_LABEL_POS_X ) )
771  {
772  mDataPoint.mCustomLabelPos[0] = xAttrList->getValueByIndex(i).toDouble();
773  }
774  else if( IsXMLToken(aLocalName, XML_CUSTOM_LABEL_POS_Y) )
775  {
776  mDataPoint.mCustomLabelPos[1] = xAttrList->getValueByIndex(i).toDouble();
777  }
778  }
779  }
780 
781  mrIndex += nRepeat;
782 }
783 
785 {
786  if(!mDataPoint.msStyleName.isEmpty() || mDataPoint.mCustomLabels.size() > 0)
787  {
788  mrStyleVector.push_back(mDataPoint);
789  }
790  if (!mDataLabel.msStyleName.isEmpty() || mDataLabel.mo_nLabelAbsolutePosX.has_value()
791  || mDataLabel.mo_nLabelAbsolutePosY.has_value())
792  {
793  mrStyleVector.push_back(mDataLabel);
794  }
795 }
796 
798  : m_rImport( rImporter )
799  , m_aPosition(0,0)
800  , m_aSize(0,0)
801  , m_bHasSizeWidth( false )
802  , m_bHasSizeHeight( false )
803  , m_bHasPositionX( false )
804  , m_bHasPositionY( false )
805  , m_bAutoSize( false )
806  , m_bAutoPosition( false )
807 {
808 }
809 
811 {
812 }
813 
815 {
817 }
818 
820 {
821  return m_bAutoSize || m_bAutoPosition;
822 }
823 
824 void SchXMLPositionAttributesHelper::readPositioningAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
825 {
826  if( XML_NAMESPACE_SVG != nPrefix )
827  return;
828 
829  if( IsXMLToken( rLocalName, XML_X ) )
830  {
832  m_aPosition.X, rValue );
833  m_bHasPositionX = true;
834  }
835  else if( IsXMLToken( rLocalName, XML_Y ) )
836  {
838  m_aPosition.Y, rValue );
839  m_bHasPositionY = true;
840  }
841  else if( IsXMLToken( rLocalName, XML_WIDTH ) )
842  {
844  m_aSize.Width, rValue );
845  m_bHasSizeWidth = true;
846  }
847  else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
848  {
850  m_aSize.Height, rValue );
851  m_bHasSizeHeight = true;
852  }
853 }
854 
856 {
857  if( pPropStyleContext && pStylesCtxt )
858  {
859  //handle automatic position and size
861  "AutomaticSize", pPropStyleContext, pStylesCtxt ) >>= m_bAutoSize;
863  "AutomaticPosition", pPropStyleContext, pStylesCtxt ) >>= m_bAutoPosition;
864  }
865 }
866 
868  SvXMLImport& rImport
869  , sal_uInt16 nPrefix
870  , const OUString& rLocalName
871  , SchXMLPositionAttributesHelper& rPositioning )
872  : SvXMLImportContext( rImport, nPrefix, rLocalName )
873  , m_rPositioning( rPositioning )
874 {
875 }
876 
878 {
879 }
880 
881 void SchXMLCoordinateRegionContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
882 {
883  // parse attributes
884  sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
885 
886  for( sal_Int16 i = 0; i < nAttrCount; i++ )
887  {
888  OUString sAttrName = xAttrList->getNameByIndex( i );
889  OUString aLocalName;
890  OUString aValue = xAttrList->getValueByIndex( i );
891  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
892  m_rPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
893  }
894 }
895 
897  SchXMLImportHelper& rImpHelper,
898  SvXMLImport& rImport,
899  sal_uInt16 nPrefix,
900  const OUString& rLocalName,
901  uno::Reference< chart::XDiagram > const & xDiagram,
902  ContextType eContextType ) :
903  SvXMLImportContext( rImport, nPrefix, rLocalName ),
904  mrImportHelper( rImpHelper ),
905  mxWallFloorSupplier( xDiagram, uno::UNO_QUERY ),
906  meContextType( eContextType )
907 {
908 }
909 
911 {
912 }
913 
914 void SchXMLWallFloorContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
915 {
916  if( !mxWallFloorSupplier.is())
917  return;
918 
919  sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
920  OUString sAutoStyleName;
921 
922  for( sal_Int16 i = 0; i < nAttrCount; i++ )
923  {
924  OUString sAttrName = xAttrList->getNameByIndex( i );
925  OUString aLocalName;
926  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
927 
928  if( nPrefix == XML_NAMESPACE_CHART &&
929  IsXMLToken( aLocalName, XML_STYLE_NAME ) )
930  {
931  sAutoStyleName = xAttrList->getValueByIndex( i );
932  }
933  }
934 
935  // set properties
936  uno::Reference< beans::XPropertySet > xProp = ( meContextType == CONTEXT_TYPE_WALL )
937  ? mxWallFloorSupplier->getWall()
938  : mxWallFloorSupplier->getFloor();
939 
940  if (!sAutoStyleName.isEmpty())
941  mrImportHelper.FillAutoStyle(sAutoStyleName, xProp);
942 }
943 
945  SchXMLImportHelper& rImpHelper,
946  SvXMLImport& rImport,
947  sal_uInt16 nPrefix,
948  const OUString& rLocalName,
949  uno::Reference< chart::XDiagram > const & xDiagram,
950  ContextType eContextType ) :
951  SvXMLImportContext( rImport, nPrefix, rLocalName ),
952  mrImportHelper( rImpHelper ),
953  mxStockPropProvider( xDiagram, uno::UNO_QUERY ),
954  meContextType( eContextType )
955 {
956 }
957 
959 {
960 }
961 
962 void SchXMLStockContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
963 {
964  if( !mxStockPropProvider.is())
965  return;
966 
967  sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
968  OUString sAutoStyleName;
969 
970  for( sal_Int16 i = 0; i < nAttrCount; i++ )
971  {
972  OUString sAttrName = xAttrList->getNameByIndex( i );
973  OUString aLocalName;
974  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
975 
976  if( nPrefix == XML_NAMESPACE_CHART &&
977  IsXMLToken( aLocalName, XML_STYLE_NAME ) )
978  {
979  sAutoStyleName = xAttrList->getValueByIndex( i );
980  }
981  }
982 
983  if( sAutoStyleName.isEmpty())
984  return;
985 
986  // set properties
987  uno::Reference< beans::XPropertySet > xProp;
988  switch( meContextType )
989  {
990  case CONTEXT_TYPE_GAIN:
991  xProp = mxStockPropProvider->getUpBar();
992  break;
993  case CONTEXT_TYPE_LOSS:
994  xProp = mxStockPropProvider->getDownBar();
995  break;
996  case CONTEXT_TYPE_RANGE:
997  xProp = mxStockPropProvider->getMinMaxLine();
998  break;
999  }
1000 
1001  mrImportHelper.FillAutoStyle(sAutoStyleName, xProp);
1002 }
1003 
1004 static void lcl_setErrorBarSequence ( const uno::Reference< chart2::XChartDocument > &xDoc,
1005  const uno::Reference< beans::XPropertySet > &xBarProp,
1006  const OUString &aXMLRange,
1007  bool bPositiveValue, bool bYError,
1008  tSchXMLLSequencesPerIndex& rSequences)
1009 {
1010  uno::Reference< css::chart2::data::XDataProvider > xDataProvider(xDoc->getDataProvider());
1011  uno::Reference< css::chart2::data::XDataSource > xDataSource( xBarProp, uno::UNO_QUERY );
1012  uno::Reference< css::chart2::data::XDataSink > xDataSink( xDataSource, uno::UNO_QUERY );
1013 
1014  assert( xDataSink.is() && xDataSource.is() && xDataProvider.is() );
1015 
1016  OUString aRange(lcl_ConvertRange(aXMLRange,xDoc));
1017 
1018  uno::Reference< chart2::data::XDataSequence > xNewSequence(
1019  xDataProvider->createDataSequenceByRangeRepresentation( aRange ));
1020 
1021  if( !xNewSequence.is())
1022  return;
1023 
1024  SchXMLTools::setXMLRangePropertyAtDataSequence(xNewSequence,aXMLRange);
1025 
1026  OUStringBuffer aRoleBuffer("error-bars-");
1027  if( bYError )
1028  aRoleBuffer.append( 'y' );
1029  else
1030  aRoleBuffer.append( 'x');
1031 
1032  aRoleBuffer.append( '-' );
1033 
1034  if( bPositiveValue )
1035  aRoleBuffer = aRoleBuffer.append( "positive" );
1036  else
1037  aRoleBuffer = aRoleBuffer.append( "negative" );
1038 
1039  OUString aRole = aRoleBuffer.makeStringAndClear();
1040 
1041  Reference< beans::XPropertySet > xSeqProp( xNewSequence, uno::UNO_QUERY );
1042 
1043  xSeqProp->setPropertyValue("Role", uno::makeAny( aRole ));
1044 
1046 
1047  Reference< chart2::data::XLabeledDataSequence > xLabelSeq( chart2::data::LabeledDataSequence::create(xContext),
1048  uno::UNO_QUERY_THROW );
1049 
1050  rSequences.emplace( tSchXMLIndexWithPart( -2, SCH_XML_PART_ERROR_BARS ), xLabelSeq );
1051 
1052  xLabelSeq->setValues( xNewSequence );
1053 
1054  uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
1055  xDataSource->getDataSequences());
1056 
1057  aSequences.realloc( aSequences.getLength() + 1 );
1058  aSequences[ aSequences.getLength() - 1 ] = xLabelSeq;
1059  xDataSink->setData( aSequences );
1060 
1061 }
1062 
1064  SchXMLImportHelper& rImpHelper,
1065  SvXMLImport& rImport,
1066  sal_uInt16 nPrefix,
1067  const OUString& rLocalName,
1068  const OUString &rSeriesStyleName,
1069  ::std::vector< DataRowPointStyle >& rStyleVector,
1070  const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
1071  ContextType eContextType,
1072  tSchXMLLSequencesPerIndex & rLSequencesPerIndex) :
1073 
1074  SvXMLImportContext( rImport, nPrefix, rLocalName ),
1075  mrImportHelper( rImpHelper ),
1076  mrStyleVector( rStyleVector ),
1077  m_xSeries( xSeries ),
1078  meContextType( eContextType ),
1079  maSeriesStyleName( rSeriesStyleName),
1080  mrLSequencesPerIndex(rLSequencesPerIndex)
1081 {}
1082 
1084 {
1085 }
1086 
1087 namespace {
1088 
1089 void SetErrorBarStyleProperties( const OUString& rStyleName, const uno::Reference< beans::XPropertySet >& xBarProp,
1090  SchXMLImportHelper const & rImportHelper )
1091 {
1092  const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
1094  rStyleName);
1095 
1096  XMLPropStyleContext &rSeriesStyleContext =
1097  const_cast< XMLPropStyleContext& >( dynamic_cast< const XMLPropStyleContext& >( *pStyle ));
1098 
1099  rSeriesStyleContext.FillPropertySet( xBarProp );
1100 }
1101 
1102 void SetErrorBarPropertiesFromStyleName( const OUString& aStyleName, const uno::Reference< beans::XPropertySet>& xBarProp,
1103  SchXMLImportHelper const & rImportHelper, OUString& aPosRange, OUString& aNegRange)
1104 {
1105  const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
1107  aStyleName);
1108 
1109  XMLPropStyleContext * pSeriesStyleContext =
1110  const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
1111 
1112  uno::Any aAny = SchXMLTools::getPropertyFromContext("ErrorBarStyle",
1113  pSeriesStyleContext,pStylesCtxt);
1114 
1115  if ( !aAny.hasValue() )
1116  return;
1117 
1118  sal_Int32 aBarStyle = css::chart::ErrorBarStyle::NONE;
1119  aAny >>= aBarStyle;
1120  xBarProp->setPropertyValue("ErrorBarStyle", aAny);
1121 
1122  aAny = SchXMLTools::getPropertyFromContext("ShowPositiveError",
1123  pSeriesStyleContext,pStylesCtxt);
1124 
1125  if(aAny.hasValue())
1126  xBarProp->setPropertyValue("ShowPositiveError",aAny);
1127 
1128  aAny = SchXMLTools::getPropertyFromContext("ShowNegativeError",
1129  pSeriesStyleContext,pStylesCtxt);
1130 
1131  if(aAny.hasValue())
1132  xBarProp->setPropertyValue("ShowNegativeError",aAny);
1133 
1134  aAny = SchXMLTools::getPropertyFromContext("PositiveError",
1135  pSeriesStyleContext, pStylesCtxt);
1136 
1137  if(aAny.hasValue())
1138  xBarProp->setPropertyValue("PositiveError", aAny);
1139  else
1140  {
1141  aAny = SchXMLTools::getPropertyFromContext("ConstantErrorHigh",
1142  pSeriesStyleContext, pStylesCtxt);
1143 
1144  if(aAny.hasValue())
1145  xBarProp->setPropertyValue("PositiveError", aAny);
1146  }
1147 
1148  aAny = SchXMLTools::getPropertyFromContext("NegativeError",
1149  pSeriesStyleContext, pStylesCtxt);
1150 
1151  if(aAny.hasValue())
1152  xBarProp->setPropertyValue("NegativeError", aAny);
1153  else
1154  {
1155  aAny = SchXMLTools::getPropertyFromContext("ConstantErrorLow",
1156  pSeriesStyleContext, pStylesCtxt);
1157 
1158  if(aAny.hasValue())
1159  xBarProp->setPropertyValue("NegativeError", aAny);
1160  }
1161 
1162  aAny = SchXMLTools::getPropertyFromContext("ErrorBarRangePositive",
1163  pSeriesStyleContext, pStylesCtxt);
1164  if( aAny.hasValue() )
1165  {
1166  aAny >>= aPosRange;
1167  }
1168 
1169  aAny = SchXMLTools::getPropertyFromContext("ErrorBarRangeNegative",
1170  pSeriesStyleContext, pStylesCtxt);
1171  if( aAny.hasValue() )
1172  {
1173  aAny >>= aNegRange;
1174  }
1175 
1176  aAny = SchXMLTools::getPropertyFromContext("Weight",
1177  pSeriesStyleContext, pStylesCtxt);
1178  if( aAny.hasValue() )
1179  {
1180  xBarProp->setPropertyValue("Weight", aAny);
1181  }
1182 
1183  aAny = SchXMLTools::getPropertyFromContext("PercentageError",
1184  pSeriesStyleContext, pStylesCtxt);
1185  if( aAny.hasValue() && aBarStyle == css::chart::ErrorBarStyle::RELATIVE )
1186  {
1187  xBarProp->setPropertyValue("PositiveError", aAny);
1188  xBarProp->setPropertyValue("NegativeError", aAny);
1189  }
1190 
1191  switch(aBarStyle)
1192  {
1193  case css::chart::ErrorBarStyle::ERROR_MARGIN:
1194  {
1195  aAny = SchXMLTools::getPropertyFromContext("NegativeError",
1196  pSeriesStyleContext,pStylesCtxt);
1197 
1198  xBarProp->setPropertyValue("NegativeError",aAny);
1199 
1200  aAny = SchXMLTools::getPropertyFromContext("PositiveError",
1201  pSeriesStyleContext,pStylesCtxt);
1202 
1203  xBarProp->setPropertyValue("PositiveError",aAny);
1204  }
1205  break;
1206  default:
1207  break;
1208  }
1209 
1210 }
1211 
1212 }
1213 
1214 void SchXMLStatisticsObjectContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1215 {
1216  sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
1217  OUString sAutoStyleName;
1218  OUString aPosRange;
1219  OUString aNegRange;
1220  bool bYError = true;
1221 
1222  for( sal_Int16 i = 0; i < nAttrCount; i++ )
1223  {
1224  OUString sAttrName = xAttrList->getNameByIndex( i );
1225  OUString aLocalName;
1226 
1227  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
1228 
1229  if( nPrefix == XML_NAMESPACE_CHART )
1230  {
1231  if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1232  sAutoStyleName = xAttrList->getValueByIndex( i );
1233  else if( IsXMLToken( aLocalName, XML_DIMENSION ) )
1234  bYError = xAttrList->getValueByIndex(i) == "y";
1235  else if( IsXMLToken( aLocalName, XML_ERROR_UPPER_RANGE) )
1236  aPosRange = xAttrList->getValueByIndex(i);
1237  else if( IsXMLToken( aLocalName, XML_ERROR_LOWER_RANGE) )
1238  aNegRange = xAttrList->getValueByIndex(i);
1239  }
1240  }
1241 
1242  if( sAutoStyleName.isEmpty() )
1243  return;
1244 
1245  DataRowPointStyle aStyle( DataRowPointStyle::MEAN_VALUE, m_xSeries, -1, 1, sAutoStyleName );
1246 
1247  switch( meContextType )
1248  {
1251  break;
1253  {
1255 
1256  uno::Reference< lang::XMultiServiceFactory > xFact = comphelper::getProcessServiceFactory();
1257 
1258  uno::Reference< beans::XPropertySet > xBarProp( xFact->createInstance("com.sun.star.chart2.ErrorBar" ),
1259  uno::UNO_QUERY );
1260 
1261  xBarProp->setPropertyValue("ErrorBarStyle",uno::makeAny(css::chart::ErrorBarStyle::NONE));
1262  xBarProp->setPropertyValue("PositiveError",uno::makeAny(0.0));
1263  xBarProp->setPropertyValue("NegativeError",uno::makeAny(0.0));
1264  xBarProp->setPropertyValue("Weight",uno::makeAny(1.0));
1265  xBarProp->setPropertyValue("ShowPositiveError",uno::makeAny(true));
1266  xBarProp->setPropertyValue("ShowNegativeError",uno::makeAny(true));
1267 
1268  // first import defaults from parent style
1269  SetErrorBarStyleProperties( maSeriesStyleName, xBarProp, mrImportHelper );
1270  SetErrorBarStyleProperties( sAutoStyleName, xBarProp, mrImportHelper );
1271  SetErrorBarPropertiesFromStyleName( maSeriesStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1272  SetErrorBarPropertiesFromStyleName( sAutoStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1273 
1274  uno::Reference< chart2::XChartDocument > xDoc(GetImport().GetModel(),uno::UNO_QUERY);
1275 
1276  if (!aPosRange.isEmpty())
1277  lcl_setErrorBarSequence(xDoc,xBarProp,aPosRange,true,bYError, mrLSequencesPerIndex);
1278 
1279  if (!aNegRange.isEmpty())
1280  lcl_setErrorBarSequence(xDoc,xBarProp,aNegRange,false,bYError, mrLSequencesPerIndex);
1281 
1282  if ( !bYError )
1283  {
1284  aStyle.m_xErrorXProperties.set( xBarProp );
1285  }
1286  else
1287  {
1288  aStyle.m_xErrorYProperties.set( xBarProp );
1289  }
1290  }
1291  break;
1292  }
1293 
1294  mrStyleVector.push_back( aStyle );
1295 }
1296 
1297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
css::uno::Reference< css::chart::XStatisticDisplay > mxStockPropProvider
css::chart::ChartDataRowSource & mrDataRowSource
css::uno::Reference< css::chart2::XDataSeries > m_xSeries
std::optional< sal_Int32 > mo_nLabelAbsolutePosX
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3434
bool hasValue()
css::uno::Reference< css::chart::X3DDisplay > mxWallFloorSupplier
SchXMLImportHelper & mrImportHelper
constexpr sal_uInt16 XML_NAMESPACE_CHART
css::uno::Reference< css::chart2::XChartDocument > mxNewDoc
void setSceneAttributes(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
this sets the scene attributes at this propertyset
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
SvXMLStylesContext * GetAutoStylesContext() const
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:394
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
SchXMLCoordinateRegionContext(SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &rLocalName, SchXMLPositionAttributesHelper &rPositioning)
void FillAutoStyle(const OUString &rAutoStyleName, const css::uno::Reference< css::beans::XPropertySet > &rProp)
Fill in the autostyle.
virtual ~SchXMLDataPointContext() override
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
SchXMLPlotAreaContext(SchXMLImportHelper &rImpHelper, SvXMLImport &rImport, const OUString &rLocalName, const OUString &rXLinkHRefAttributeToIndicateDataProvider, OUString &rCategoriesAddress, OUString &rChartAddress, bool &bHasRangeAtPlotArea, bool &rAllRangeAddressesAvailable, bool &rColHasLabels, bool &rRowHasLabels, css::chart::ChartDataRowSource &rDataRowSource, SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles, const OUString &aChartTypeServiceName, tSchXMLLSequencesPerIndex &rLSequencesPerIndex, const css::awt::Size &rChartSize)
bool isDocumentGeneratedWithOpenOfficeOlderThan3_3(const uno::Reference< frame::XModel > &xChartModel)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
::std::vector< DataRowPointStyle > & mrStyleVector
SchXMLImportHelper & mrImportHelper
SchXMLPositionAttributesHelper(SvXMLImport &rImporter)
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
bool convertMeasureToCore(sal_Int32 &rValue, const OUString &rString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32) const
convert string to measure with meCoreMeasureUnit, using optional min and max values ...
Definition: xmluconv.cxx:171
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
void setXMLRangePropertyAtDataSequence(const Reference< chart2::data::XDataSequence > &xDataSequence, const OUString &rXMLRange)
virtual ~SchXMLWallFloorContext() override
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
virtual ~SchXMLStatisticsObjectContext() override
::std::vector< SchXMLAxis > maAxes
const SvXMLTokenMap & GetPlotAreaElemTokenMap()
SchXMLStatisticsObjectContext(SchXMLImportHelper &rImportHelper, SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rSeriesStyleName,::std::vector< DataRowPointStyle > &rStyleVector, const css::uno::Reference< css::chart2::XDataSeries > &xSeries, ContextType eContextType, tSchXMLLSequencesPerIndex &rLSequencesPerIndex)
SchXML3DSceneAttributesHelper(SvXMLImport &rImporter)
SchXMLWallFloorContext(SchXMLImportHelper &rImportHelper, SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &rLocalName, css::uno::Reference< css::chart::XDiagram > const &xDiagram, ContextType eContextType)
const SvXMLTokenMap & GetPlotAreaAttrTokenMap()
::std::pair< tSchXMLIndex, SchXMLLabeledSequencePart > tSchXMLIndexWithPart
SchXMLImportHelper & mrImportHelper
css::uno::Any maStackedBarsConnectedDefault
::std::vector< OUString > & mrLabels
void getCameraDefaultFromDiagram(const css::uno::Reference< css::chart::XDiagram > &xDiagram)
const OUString & m_rXLinkHRefAttributeToIndicateDataProvider
tSchXMLLSequencesPerIndex & mrLSequencesPerIndex
SchXMLStockContext(SchXMLImportHelper &rImportHelper, SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &rLocalName, css::uno::Reference< css::chart::XDiagram > const &xDiagram, ContextType eContextType)
constexpr sal_uInt16 XML_NAMESPACE_SVG
::std::vector< OUString > & mrLabels
::basegfx::B3DVector maVUP
void readAutomaticPositioningProperties(XMLPropStyleContext const *pPropStyleContext, const SvXMLStylesContext *pStylesCtxt)
int i
SchXMLPositionAttributesHelper m_aInnerPositioning
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
Definition: prstylei.cxx:223
::basegfx::B3DVector maVPN
constexpr sal_uInt16 XML_NAMESPACE_TEXT
::std::vector< DataRowPointStyle > & mrStyleVector
virtual ~SchXMLPlotAreaContext() override
css::uno::Reference< css::beans::XPropertySet > m_xErrorXProperties
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
sal_uInt16 Get(sal_uInt16 nPrefix, const OUString &rLName) const
Definition: xmltkmap.cxx:99
SchXMLDataPointContext(SchXMLImportHelper &rImportHelper, SvXMLImport &rImport, const OUString &rLocalName,::std::vector< DataRowPointStyle > &rStyleVector, const css::uno::Reference< css::chart2::XDataSeries > &xSeries, sal_Int32 &rIndex, bool bSymbolSizeForSeriesIsMissingInFile)
static void CorrectAxisPositions(const css::uno::Reference< css::chart2::XChartDocument > &xNewDoc, const OUString &rChartTypeServiceName, const OUString &rODFVersionOfFile, bool bAxisPositionAttributeImported)
SvXMLImportContext * create3DLightContext(sal_uInt16 nPrfx, const OUString &rLName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
creates a 3d light context and adds it to the internal list for later processing
void processSceneAttribute(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rValue)
this should be called for each scene attribute
css::uno::Any maRegressionCurvesDefault
static XmlStyleFamily GetChartFamilyID()
::std::vector< RegressionStyle > maRegressionStyleVector
With this class you can import a element containing its data as element o...
css::uno::Reference< css::chart2::XDataSeries > m_xSeries
SchXMLPositionAttributesHelper & m_rPositioning
OUString msStyleNameOfParent
void readPositioningAttribute(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rValue)
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
#define TOOLS_INFO_EXCEPTION(area, stream)
SchXMLDataLabelSpanContext(SvXMLImport &rImport, const OUString &rLocalName,::std::vector< OUString > &rLabels)
SchXMLPositionAttributesHelper m_aOuterPositioning
SchXML3DSceneAttributesHelper maSceneImportHelper
::std::vector< OUString > & mrLabels
const SvXMLTokenMap & GetSeriesElemTokenMap()
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
void CreateCategories(const uno::Reference< chart2::data::XDataProvider > &xDataProvider, const uno::Reference< chart2::XChartDocument > &xNewDoc, const OUString &rRangeAddress, sal_Int32 nCooSysIndex, sal_Int32 nDimensionIndex, tSchXMLLSequencesPerIndex *pLSequencesPerIndex)
Reference< XMultiServiceFactory > getProcessServiceFactory()
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
const css::uno::Reference< css::chart::XChartDocument > & GetChartDocument() const
::std::vector< DataRowPointStyle > maSeriesStyleVector
SeriesDefaultsAndStyles & mrSeriesDefaultsAndStyles
OUString GetODFVersion() const
Definition: xmlimp.cxx:1928
#define SAL_WARN_IF(condition, area, stream)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3378
css::awt::Rectangle getRectangle() const
Handling of tokens in XML:
SchXMLDataLabelParaContext(SvXMLImport &rImport, const OUString &rLocalName,::std::vector< OUString > &rLabels)
const SvXMLImport & m_rImport
GlobalSeriesImportInfo m_aGlobalSeriesImportInfo
bool isDocumentGeneratedWithOpenOfficeOlderThan3_0(const uno::Reference< frame::XModel > &xChartModel)
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:396
virtual ~SchXMLStockContext() override
Reference< XComponentContext > getProcessComponentContext()
DataRowPointStyle & mrDataLabelStyle
virtual void Characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
awt::Size m_aSize
tSchXMLLSequencesPerIndex & mrLSequencesPerIndex
static css::uno::Sequence< typename VectorType::value_type > vectorToSequence(const VectorType &rVector)
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
Definition: xmlstyle.cxx:808
::std::vector< OUString > mCustomLabels
#define SAL_WARN(area, stream)
SchXMLImportHelper & mrImportHelper
bool isDocumentGeneratedWithOpenOfficeOlderThan2_3(const uno::Reference< frame::XModel > &xChartModel)
bool isDocumentGeneratedWithOpenOfficeOlderThan2_4(const uno::Reference< frame::XModel > &xChartModel)
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
::basegfx::B3DVector maVRP
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
static void lcl_setErrorBarSequence(const uno::Reference< chart2::XChartDocument > &xDoc, const uno::Reference< beans::XPropertySet > &xBarProp, const OUString &aXMLRange, bool bPositiveValue, bool bYError, tSchXMLLSequencesPerIndex &rSequences)
css::uno::Reference< css::beans::XPropertySet > m_xErrorYProperties
uno::Any getPropertyFromContext(const OUString &rPropertyName, const XMLPropStyleContext *pPropStyleContext, const SvXMLStylesContext *pStylesCtxt)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
::std::multimap< tSchXMLIndexWithPart, css::uno::Reference< css::chart2::data::XLabeledDataSequence > > tSchXMLLSequencesPerIndex
std::optional< sal_Int32 > mo_nLabelAbsolutePosY
virtual ~SchXMLCoordinateRegionContext() override
SchXMLDataLabelContext(SvXMLImport &rImport, const OUString &rLocalName,::std::vector< OUString > &rLabels, DataRowPointStyle &rDataLabel)
css::uno::Reference< css::chart::XDiagram > mxDiagram
Reference< chart2::XDataSeries > m_xSeries