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,
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 ),
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::startFastElement (sal_Int32 /*nElement*/,
210  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
211 {
212  // parse attributes
213  uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
214 
215  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
216  {
217  switch( aIter.getToken() )
218  {
219  case XML_ELEMENT(SVG, XML_X):
220  case XML_ELEMENT(SVG_COMPAT, XML_X):
221  case XML_ELEMENT(SVG, XML_Y):
222  case XML_ELEMENT(SVG_COMPAT, XML_Y):
223  case XML_ELEMENT(SVG, XML_WIDTH):
224  case XML_ELEMENT(SVG_COMPAT, XML_WIDTH):
225  case XML_ELEMENT(SVG, XML_HEIGHT):
226  case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT):
227  m_aOuterPositioning.readPositioningAttribute( aIter.getToken(), aIter.toView() );
228  break;
230  msAutoStyleName = aIter.toString();
231  break;
233  mrChartAddress = lcl_ConvertRange( aIter.toString(), xNewDoc );
234  // indicator for getting data from the outside
235  m_rbHasRangeAtPlotArea = true;
236  break;
238  {
239  if( IsXMLToken(aIter, XML_BOTH) )
241  else if( IsXMLToken(aIter, XML_ROW) )
242  mrRowHasLabels = true;
243  else if( IsXMLToken(aIter, XML_COLUMN) )
244  mrColHasLabels = true;
245  }
246  break;
247  case XML_ELEMENT(DR3D, XML_TRANSFORM):
248  case XML_ELEMENT(DR3D, XML_VRP):
249  case XML_ELEMENT(DR3D, XML_VPN):
250  case XML_ELEMENT(DR3D, XML_VUP):
251  case XML_ELEMENT(DR3D, XML_PROJECTION):
252  case XML_ELEMENT(DR3D, XML_DISTANCE):
253  case XML_ELEMENT(DR3D, XML_FOCAL_LENGTH):
254  case XML_ELEMENT(DR3D, XML_SHADOW_SLANT):
255  case XML_ELEMENT(DR3D, XML_SHADE_MODE):
256  case XML_ELEMENT(DR3D, XML_AMBIENT_COLOR):
257  case XML_ELEMENT(DR3D, XML_LIGHTING_MODE):
259  break;
260  default:
261  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
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  u"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 
402 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLPlotAreaContext::createFastChildContext(
403  sal_Int32 nElement,
404  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
405 {
406  SvXMLImportContext* pContext = nullptr;
407 
408  switch(nElement)
409  {
410  case XML_ELEMENT(CHART_EXT, XML_COORDINATE_REGION):
412  {
414  }
415  break;
416 
417  case XML_ELEMENT(CHART, XML_AXIS):
418  {
419  bool bAddMissingXAxisForNetCharts = false;
420  bool bAdaptWrongPercentScaleValues = false;
422  {
423  //correct errors from older versions
424 
425  // for NetCharts there were no xAxis exported to older files
426  // so we need to add the x axis here for those old NetChart files
427  if ( maChartTypeServiceName == "com.sun.star.chart2.NetChartType" )
428  bAddMissingXAxisForNetCharts = true;
429 
430  //Issue 59288
431  if( mbPercentStacked )
432  bAdaptWrongPercentScaleValues = true;
433  }
434 
435  bool bAdaptXAxisOrientationForOld2DBarCharts = false;
437  {
438  //issue74660
439  if ( maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
440  bAdaptXAxisOrientationForOld2DBarCharts = true;
441  }
442 
444  bAddMissingXAxisForNetCharts, bAdaptWrongPercentScaleValues, bAdaptXAxisOrientationForOld2DBarCharts, m_bAxisPositionAttributeImported );
445  }
446  break;
447 
449  {
450  if( mxNewDoc.is())
451  {
452  pContext = new SchXMLSeries2Context(
454  mxNewDoc, maAxes,
457  mnSeries,
463  }
464  mnSeries++;
465  }
466  break;
467 
468  case XML_ELEMENT(CHART, XML_WALL):
471  break;
472  case XML_ELEMENT(CHART, XML_FLOOR):
475  break;
476 
477  case XML_ELEMENT(DR3D, XML_LIGHT):
478  pContext = maSceneImportHelper.create3DLightContext( xAttrList );
479  break;
480 
481  // elements for stock charts
485  break;
489  break;
493  break;
494  default:
495  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
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, ::std::vector<OUString>& rLabels):
587  SvXMLImportContext( rImport ),
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, ::std::vector<OUString>& rLabels):
603  SvXMLImportContext( rImport ),
604  mrLabels(rLabels)
605 {
606 }
607 
608 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLDataLabelParaContext::createFastChildContext(
609  sal_Int32 nElement,
610  const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
611 {
612  if ( nElement == XML_ELEMENT(TEXT, XML_SPAN) )
614  else
615  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
616  return nullptr;
617 }
618 
620  CustomLabelsInfo& rLabels,
621  DataRowPointStyle& rDataLabelStyle)
622  : SvXMLImportContext(rImport)
623  , mrLabels(rLabels)
624  , mrDataLabelStyle(rDataLabelStyle)
625 {
626 }
627 
628 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLDataLabelContext::createFastChildContext(
629  sal_Int32 nElement,
630  const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
631 {
632  if ( nElement == XML_ELEMENT(TEXT, XML_P) )
634  else
635  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
636  return nullptr;
637 }
638 
640  sal_Int32 /*nElement*/,
641  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
642 {
643  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
644  {
645  switch(aIter.getToken())
646  {
647  case XML_ELEMENT(SVG, XML_X):
648  case XML_ELEMENT(SVG_COMPAT, XML_X):
649  {
650  sal_Int32 nResultValue;
651  GetImport().GetMM100UnitConverter().convertMeasureToCore(nResultValue, aIter.toView());
653  break;
654  }
655  case XML_ELEMENT(SVG, XML_Y):
656  case XML_ELEMENT(SVG_COMPAT, XML_Y):
657  {
658  sal_Int32 nResultValue;
659  GetImport().GetMM100UnitConverter().convertMeasureToCore(nResultValue, aIter.toView());
661  break;
662  }
664  mrDataLabelStyle.msStyleName = aIter.toString();
665  break;
666  case XML_ELEMENT(LO_EXT, XML_DATA_LABEL_GUID):
667  mrLabels.msLabelGuid = aIter.toString();
669  break;
671  mrLabels.msLabelsCellRange = aIter.toString();
673  break;
674  default:
675  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
676  }
677  }
678 }
679 
680 
682  ::std::vector< DataRowPointStyle >& rStyleVector,
683  const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
684  sal_Int32& rIndex,
685  bool bSymbolSizeForSeriesIsMissingInFile ) :
686  SvXMLImportContext( rImport ),
687  mrStyleVector( rStyleVector ),
688  mrIndex( rIndex ),
689  mDataPoint(DataRowPointStyle::DATA_POINT, xSeries, rIndex, 1, OUString{}),
690  mDataLabel(DataRowPointStyle::DATA_LABEL_POINT, xSeries, rIndex, 1, OUString{})
691 {
692  mDataPoint.mbSymbolSizeForSeriesIsMissingInFile = bSymbolSizeForSeriesIsMissingInFile;
693 }
694 
695 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLDataPointContext::createFastChildContext(
696  sal_Int32 nElement,
697  const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
698 {
699  SvXMLImportContext* pContext = nullptr;
700  switch(nElement)
701  {
703  mbHasLabelParagraph = true;
705  mDataLabel);
706  break;
707  default:
708  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
709  }
710  return pContext;
711 }
712 
714 {
715 }
716 
717 void SchXMLDataPointContext::startFastElement (sal_Int32 /*Element*/,
718  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
719 {
720  OUString sAutoStyleName;
721  sal_Int32 nRepeat = 1;
722  OUString sCustomLabelField;
723 
724  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
725  {
726  switch (aIter.getToken())
727  {
729  {
730  sAutoStyleName = aIter.toString();
731  mDataPoint.msStyleName = sAutoStyleName;
732  mDataLabel.msStyleNameOfParent = sAutoStyleName;
733  break;
734  }
736  {
737  nRepeat = aIter.toInt32();
738  mDataPoint.m_nPointRepeat = nRepeat;
739  mDataLabel.m_nPointRepeat = nRepeat;
740  break;
741  }
742  // Deprecated. New documents use the chart:data-label element
743  // instead in order to store custom label text.
744  case XML_ELEMENT(LO_EXT, XML_CUSTOM_LABEL_FIELD):
745  if (!mbHasLabelParagraph)
746  {
747  sCustomLabelField = aIter.toString();
748  mDataPoint.mCustomLabels.mLabels.push_back(sCustomLabelField);
749  }
750  break;
751  case XML_ELEMENT(LO_EXT, XML_HIDE_LEGEND):
752  {
753  bool bHideLegend = aIter.toBoolean();
754  if (bHideLegend)
755  {
756  uno::Sequence<sal_Int32> deletedLegendEntriesSeq;
757  Reference<beans::XPropertySet> xSeriesProp(mDataPoint.m_xSeries, uno::UNO_QUERY);
758  xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq;
759  std::vector<sal_Int32> deletedLegendEntries;
760  for (const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
761  {
762  deletedLegendEntries.push_back(deletedLegendEntry);
763  }
764  deletedLegendEntries.push_back(mDataPoint.m_nPointIndex);
765  xSeriesProp->setPropertyValue("DeletedLegendEntries", uno::makeAny(::oox::ContainerHelper::vectorToSequence(deletedLegendEntries)));
766  }
767  break;
768  }
769  case XML_ELEMENT(LO_EXT, XML_CUSTOM_LABEL_POS_X):
770  {
771  mDataPoint.mCustomLabelPos[0] = aIter.toDouble();
772  break;
773  }
774  case XML_ELEMENT(LO_EXT, XML_CUSTOM_LABEL_POS_Y):
775  {
776  mDataPoint.mCustomLabelPos[1] = aIter.toDouble();
777  break;
778  }
779  default:
780  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
781  }
782  }
783 
784  mrIndex += nRepeat;
785 }
786 
788 {
789  if(!mDataPoint.msStyleName.isEmpty() || mDataPoint.mCustomLabels.mLabels.size() > 0)
790  {
791  mrStyleVector.push_back(mDataPoint);
792  }
793  if (!mDataLabel.msStyleName.isEmpty() || mDataLabel.mo_nLabelAbsolutePosX.has_value()
794  || mDataLabel.mo_nLabelAbsolutePosY.has_value())
795  {
796  mrStyleVector.push_back(mDataLabel);
797  }
798 }
799 
801  : m_rImport( rImporter )
802  , m_aPosition(0,0)
803  , m_aSize(0,0)
804  , m_bHasSizeWidth( false )
805  , m_bHasSizeHeight( false )
806  , m_bHasPositionX( false )
807  , m_bHasPositionY( false )
808  , m_bAutoSize( false )
809  , m_bAutoPosition( false )
810 {
811 }
812 
814 {
815 }
816 
818 {
820 }
821 
823 {
824  return m_bAutoSize || m_bAutoPosition;
825 }
826 
827 void SchXMLPositionAttributesHelper::readPositioningAttribute( sal_Int32 nAttributeToken, std::string_view rValue )
828 {
829  if( !IsTokenInNamespace(nAttributeToken, XML_NAMESPACE_SVG) && !IsTokenInNamespace(nAttributeToken, XML_NAMESPACE_SVG_COMPAT) )
830  return;
831 
832  switch (nAttributeToken & TOKEN_MASK)
833  {
834  case XML_X:
835  {
837  m_aPosition.X, rValue );
838  m_bHasPositionX = true;
839  break;
840  }
841  case XML_Y:
842  {
844  m_aPosition.Y, rValue );
845  m_bHasPositionY = true;
846  break;
847  }
848  case XML_WIDTH:
849  {
851  m_aSize.Width, rValue );
852  m_bHasSizeWidth = true;
853  break;
854  }
855  case XML_HEIGHT:
856  {
858  m_aSize.Height, rValue );
859  m_bHasSizeHeight = true;
860  break;
861  }
862  default:
863  XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, OUString::fromUtf8(rValue));
864  }
865 }
866 
868 {
869  if( pPropStyleContext && pStylesCtxt )
870  {
871  //handle automatic position and size
873  u"AutomaticSize", pPropStyleContext, pStylesCtxt ) >>= m_bAutoSize;
875  u"AutomaticPosition", pPropStyleContext, pStylesCtxt ) >>= m_bAutoPosition;
876  }
877 }
878 
880  SvXMLImport& rImport
881  , SchXMLPositionAttributesHelper& rPositioning )
882  : SvXMLImportContext( rImport )
883  , m_rPositioning( rPositioning )
884 {
885 }
886 
888 {
889 }
890 
892  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
893 {
894  // parse attributes
895  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
896  m_rPositioning.readPositioningAttribute( aIter.getToken(), aIter.toView() );
897 }
898 
900  SchXMLImportHelper& rImpHelper,
901  SvXMLImport& rImport,
902  uno::Reference< chart::XDiagram > const & xDiagram,
903  ContextType eContextType ) :
904  SvXMLImportContext( rImport ),
905  mrImportHelper( rImpHelper ),
906  mxWallFloorSupplier( xDiagram, uno::UNO_QUERY ),
907  meContextType( eContextType )
908 {
909 }
910 
912 {
913 }
914 
915 void SchXMLWallFloorContext::startFastElement (sal_Int32 /*Element*/,
916  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
917 {
918  if( !mxWallFloorSupplier.is())
919  return;
920 
921  OUString sAutoStyleName;
922 
923  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
924  {
925  if( aIter.getToken() == XML_ELEMENT(CHART, XML_STYLE_NAME) )
926  sAutoStyleName = aIter.toString();
927  else
928  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
929  }
930 
931  // set properties
932  uno::Reference< beans::XPropertySet > xProp = ( meContextType == CONTEXT_TYPE_WALL )
933  ? mxWallFloorSupplier->getWall()
934  : mxWallFloorSupplier->getFloor();
935 
936  if (!sAutoStyleName.isEmpty())
937  mrImportHelper.FillAutoStyle(sAutoStyleName, xProp);
938 }
939 
941  SchXMLImportHelper& rImpHelper,
942  SvXMLImport& rImport,
943  uno::Reference< chart::XDiagram > const & xDiagram,
944  ContextType eContextType ) :
945  SvXMLImportContext( rImport ),
946  mrImportHelper( rImpHelper ),
947  mxStockPropProvider( xDiagram, uno::UNO_QUERY ),
948  meContextType( eContextType )
949 {
950 }
951 
953 {
954 }
955 
956 void SchXMLStockContext::startFastElement (sal_Int32 /*Element*/,
957  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
958 {
959  if( !mxStockPropProvider.is())
960  return;
961 
962  OUString sAutoStyleName;
963 
964  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
965  {
966  if( aIter.getToken() == XML_ELEMENT(CHART, XML_STYLE_NAME) )
967  sAutoStyleName = aIter.toString();
968  else
969  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
970  }
971 
972  if( sAutoStyleName.isEmpty())
973  return;
974 
975  // set properties
976  uno::Reference< beans::XPropertySet > xProp;
977  switch( meContextType )
978  {
979  case CONTEXT_TYPE_GAIN:
980  xProp = mxStockPropProvider->getUpBar();
981  break;
982  case CONTEXT_TYPE_LOSS:
983  xProp = mxStockPropProvider->getDownBar();
984  break;
985  case CONTEXT_TYPE_RANGE:
986  xProp = mxStockPropProvider->getMinMaxLine();
987  break;
988  }
989 
990  mrImportHelper.FillAutoStyle(sAutoStyleName, xProp);
991 }
992 
993 static void lcl_setErrorBarSequence ( const uno::Reference< chart2::XChartDocument > &xDoc,
994  const uno::Reference< beans::XPropertySet > &xBarProp,
995  const OUString &aXMLRange,
996  bool bPositiveValue, bool bYError,
997  tSchXMLLSequencesPerIndex& rSequences)
998 {
999  uno::Reference< css::chart2::data::XDataProvider > xDataProvider(xDoc->getDataProvider());
1000  uno::Reference< css::chart2::data::XDataSource > xDataSource( xBarProp, uno::UNO_QUERY );
1001  uno::Reference< css::chart2::data::XDataSink > xDataSink( xDataSource, uno::UNO_QUERY );
1002 
1003  assert( xDataSink.is() && xDataSource.is() && xDataProvider.is() );
1004 
1005  OUString aRange(lcl_ConvertRange(aXMLRange,xDoc));
1006 
1007  uno::Reference< chart2::data::XDataSequence > xNewSequence(
1008  xDataProvider->createDataSequenceByRangeRepresentation( aRange ));
1009 
1010  if( !xNewSequence.is())
1011  return;
1012 
1013  SchXMLTools::setXMLRangePropertyAtDataSequence(xNewSequence,aXMLRange);
1014 
1015  OUStringBuffer aRoleBuffer("error-bars-");
1016  if( bYError )
1017  aRoleBuffer.append( 'y' );
1018  else
1019  aRoleBuffer.append( 'x');
1020 
1021  aRoleBuffer.append( '-' );
1022 
1023  if( bPositiveValue )
1024  aRoleBuffer = aRoleBuffer.append( "positive" );
1025  else
1026  aRoleBuffer = aRoleBuffer.append( "negative" );
1027 
1028  OUString aRole = aRoleBuffer.makeStringAndClear();
1029 
1030  Reference< beans::XPropertySet > xSeqProp( xNewSequence, uno::UNO_QUERY );
1031 
1032  xSeqProp->setPropertyValue("Role", uno::makeAny( aRole ));
1033 
1035 
1036  Reference< chart2::data::XLabeledDataSequence > xLabelSeq( chart2::data::LabeledDataSequence::create(xContext),
1037  uno::UNO_QUERY_THROW );
1038 
1039  rSequences.emplace( tSchXMLIndexWithPart( -2, SCH_XML_PART_ERROR_BARS ), xLabelSeq );
1040 
1041  xLabelSeq->setValues( xNewSequence );
1042 
1043  uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
1044  xDataSource->getDataSequences());
1045 
1046  aSequences.realloc( aSequences.getLength() + 1 );
1047  aSequences[ aSequences.getLength() - 1 ] = xLabelSeq;
1048  xDataSink->setData( aSequences );
1049 
1050 }
1051 
1053  SchXMLImportHelper& rImpHelper,
1054  SvXMLImport& rImport,
1055  const OUString &rSeriesStyleName,
1056  ::std::vector< DataRowPointStyle >& rStyleVector,
1057  const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
1058  ContextType eContextType,
1059  tSchXMLLSequencesPerIndex & rLSequencesPerIndex) :
1060 
1061  SvXMLImportContext( rImport ),
1062  mrImportHelper( rImpHelper ),
1063  mrStyleVector( rStyleVector ),
1064  m_xSeries( xSeries ),
1065  meContextType( eContextType ),
1066  maSeriesStyleName( rSeriesStyleName),
1067  mrLSequencesPerIndex(rLSequencesPerIndex)
1068 {}
1069 
1071 {
1072 }
1073 
1074 namespace {
1075 
1076 void SetErrorBarStyleProperties( const OUString& rStyleName, const uno::Reference< beans::XPropertySet >& xBarProp,
1077  SchXMLImportHelper const & rImportHelper )
1078 {
1079  const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
1081  rStyleName);
1082 
1083  XMLPropStyleContext &rSeriesStyleContext =
1084  const_cast< XMLPropStyleContext& >( dynamic_cast< const XMLPropStyleContext& >( *pStyle ));
1085 
1086  rSeriesStyleContext.FillPropertySet( xBarProp );
1087 }
1088 
1089 void SetErrorBarPropertiesFromStyleName( const OUString& aStyleName, const uno::Reference< beans::XPropertySet>& xBarProp,
1090  SchXMLImportHelper const & rImportHelper, OUString& aPosRange, OUString& aNegRange)
1091 {
1092  const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
1094  aStyleName);
1095 
1096  XMLPropStyleContext * pSeriesStyleContext =
1097  const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
1098 
1099  uno::Any aAny = SchXMLTools::getPropertyFromContext(u"ErrorBarStyle",
1100  pSeriesStyleContext,pStylesCtxt);
1101 
1102  if ( !aAny.hasValue() )
1103  return;
1104 
1105  sal_Int32 aBarStyle = css::chart::ErrorBarStyle::NONE;
1106  aAny >>= aBarStyle;
1107  xBarProp->setPropertyValue("ErrorBarStyle", aAny);
1108 
1109  aAny = SchXMLTools::getPropertyFromContext(u"ShowPositiveError",
1110  pSeriesStyleContext,pStylesCtxt);
1111 
1112  if(aAny.hasValue())
1113  xBarProp->setPropertyValue("ShowPositiveError",aAny);
1114 
1115  aAny = SchXMLTools::getPropertyFromContext(u"ShowNegativeError",
1116  pSeriesStyleContext,pStylesCtxt);
1117 
1118  if(aAny.hasValue())
1119  xBarProp->setPropertyValue("ShowNegativeError",aAny);
1120 
1121  aAny = SchXMLTools::getPropertyFromContext(u"PositiveError",
1122  pSeriesStyleContext, pStylesCtxt);
1123 
1124  if(aAny.hasValue())
1125  xBarProp->setPropertyValue("PositiveError", aAny);
1126  else
1127  {
1128  aAny = SchXMLTools::getPropertyFromContext(u"ConstantErrorHigh",
1129  pSeriesStyleContext, pStylesCtxt);
1130 
1131  if(aAny.hasValue())
1132  xBarProp->setPropertyValue("PositiveError", aAny);
1133  }
1134 
1135  aAny = SchXMLTools::getPropertyFromContext(u"NegativeError",
1136  pSeriesStyleContext, pStylesCtxt);
1137 
1138  if(aAny.hasValue())
1139  xBarProp->setPropertyValue("NegativeError", aAny);
1140  else
1141  {
1142  aAny = SchXMLTools::getPropertyFromContext(u"ConstantErrorLow",
1143  pSeriesStyleContext, pStylesCtxt);
1144 
1145  if(aAny.hasValue())
1146  xBarProp->setPropertyValue("NegativeError", aAny);
1147  }
1148 
1149  aAny = SchXMLTools::getPropertyFromContext(u"ErrorBarRangePositive",
1150  pSeriesStyleContext, pStylesCtxt);
1151  if( aAny.hasValue() )
1152  {
1153  aAny >>= aPosRange;
1154  }
1155 
1156  aAny = SchXMLTools::getPropertyFromContext(u"ErrorBarRangeNegative",
1157  pSeriesStyleContext, pStylesCtxt);
1158  if( aAny.hasValue() )
1159  {
1160  aAny >>= aNegRange;
1161  }
1162 
1163  aAny = SchXMLTools::getPropertyFromContext(u"Weight",
1164  pSeriesStyleContext, pStylesCtxt);
1165  if( aAny.hasValue() )
1166  {
1167  xBarProp->setPropertyValue("Weight", aAny);
1168  }
1169 
1170  aAny = SchXMLTools::getPropertyFromContext(u"PercentageError",
1171  pSeriesStyleContext, pStylesCtxt);
1172  if( aAny.hasValue() && aBarStyle == css::chart::ErrorBarStyle::RELATIVE )
1173  {
1174  xBarProp->setPropertyValue("PositiveError", aAny);
1175  xBarProp->setPropertyValue("NegativeError", aAny);
1176  }
1177 
1178  switch(aBarStyle)
1179  {
1180  case css::chart::ErrorBarStyle::ERROR_MARGIN:
1181  {
1182  aAny = SchXMLTools::getPropertyFromContext(u"NegativeError",
1183  pSeriesStyleContext,pStylesCtxt);
1184 
1185  xBarProp->setPropertyValue("NegativeError",aAny);
1186 
1187  aAny = SchXMLTools::getPropertyFromContext(u"PositiveError",
1188  pSeriesStyleContext,pStylesCtxt);
1189 
1190  xBarProp->setPropertyValue("PositiveError",aAny);
1191  }
1192  break;
1193  default:
1194  break;
1195  }
1196 
1197 }
1198 
1199 }
1200 
1202  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1203 {
1204  OUString sAutoStyleName;
1205  OUString aPosRange;
1206  OUString aNegRange;
1207  bool bYError = true;
1208 
1209  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
1210  {
1211  switch (aIter.getToken())
1212  {
1214  sAutoStyleName = aIter.toString();
1215  break;
1217  bYError = aIter.toString() == "y";
1218  break;
1220  aPosRange = aIter.toString();
1221  break;
1223  aNegRange = aIter.toString();
1224  break;
1225  }
1226  }
1227 
1228  if( sAutoStyleName.isEmpty() )
1229  return;
1230 
1231  DataRowPointStyle aStyle( DataRowPointStyle::MEAN_VALUE, m_xSeries, -1, 1, sAutoStyleName );
1232 
1233  switch( meContextType )
1234  {
1237  break;
1239  {
1241 
1242  uno::Reference< lang::XMultiServiceFactory > xFact = comphelper::getProcessServiceFactory();
1243 
1244  uno::Reference< beans::XPropertySet > xBarProp( xFact->createInstance("com.sun.star.chart2.ErrorBar" ),
1245  uno::UNO_QUERY );
1246 
1247  xBarProp->setPropertyValue("ErrorBarStyle",uno::makeAny(css::chart::ErrorBarStyle::NONE));
1248  xBarProp->setPropertyValue("PositiveError",uno::makeAny(0.0));
1249  xBarProp->setPropertyValue("NegativeError",uno::makeAny(0.0));
1250  xBarProp->setPropertyValue("Weight",uno::makeAny(1.0));
1251  xBarProp->setPropertyValue("ShowPositiveError",uno::makeAny(true));
1252  xBarProp->setPropertyValue("ShowNegativeError",uno::makeAny(true));
1253 
1254  // first import defaults from parent style
1255  SetErrorBarStyleProperties( maSeriesStyleName, xBarProp, mrImportHelper );
1256  SetErrorBarStyleProperties( sAutoStyleName, xBarProp, mrImportHelper );
1257  SetErrorBarPropertiesFromStyleName( maSeriesStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1258  SetErrorBarPropertiesFromStyleName( sAutoStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1259 
1260  uno::Reference< chart2::XChartDocument > xDoc(GetImport().GetModel(),uno::UNO_QUERY);
1261 
1262  if (!aPosRange.isEmpty())
1263  lcl_setErrorBarSequence(xDoc,xBarProp,aPosRange,true,bYError, mrLSequencesPerIndex);
1264 
1265  if (!aNegRange.isEmpty())
1266  lcl_setErrorBarSequence(xDoc,xBarProp,aNegRange,false,bYError, mrLSequencesPerIndex);
1267 
1268  if ( !bYError )
1269  {
1270  aStyle.m_xErrorXProperties.set( xBarProp );
1271  }
1272  else
1273  {
1274  aStyle.m_xErrorYProperties.set( xBarProp );
1275  }
1276  }
1277  break;
1278  }
1279 
1280  mrStyleVector.push_back( aStyle );
1281 }
1282 
1283 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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 hasValue()
bool convertMeasureToCore(sal_Int32 &rValue, std::u16string_view 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:186
SchXMLDataPointContext(SvXMLImport &rImport,::std::vector< DataRowPointStyle > &rStyleVector, const css::uno::Reference< css::chart2::XDataSeries > &xSeries, sal_Int32 &rIndex, bool bSymbolSizeForSeriesIsMissingInFile)
css::uno::Reference< css::chart::X3DDisplay > mxWallFloorSupplier
SchXMLStockContext(SchXMLImportHelper &rImportHelper, SvXMLImport &rImport, css::uno::Reference< css::chart::XDiagram > const &xDiagram, ContextType eContextType)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
css::uno::Reference< css::chart2::XChartDocument > mxNewDoc
OUString msLabelGuid
GUID of the CELLRANGE field.
SchXMLDataLabelContext(SvXMLImport &rImport, CustomLabelsInfo &rLabels, DataRowPointStyle &rDataLabel)
void setSceneAttributes(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
this sets the scene attributes at this propertyset
SvXMLStylesContext * GetAutoStylesContext() const
SchXMLPlotAreaContext(SchXMLImportHelper &rImpHelper, SvXMLImport &rImport, 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)
uno::Any getPropertyFromContext(std::u16string_view rPropertyName, const XMLPropStyleContext *pPropStyleContext, const SvXMLStylesContext *pStylesCtxt)
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:59
#define XMLOFF_WARN_UNKNOWN_ATTR(area, token, value)
Definition: xmlictxt.hxx:116
void processSceneAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter)
this should be called for each scene attribute
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3508
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void FillAutoStyle(const OUString &rAutoStyleName, const css::uno::Reference< css::beans::XPropertySet > &rProp)
Fill in the autostyle.
virtual ~SchXMLDataPointContext() override
CustomLabelsInfo mCustomLabels
bool isDocumentGeneratedWithOpenOfficeOlderThan3_3(const uno::Reference< frame::XModel > &xChartModel)
::std::vector< DataRowPointStyle > & mrStyleVector
SchXMLStatisticsObjectContext(SchXMLImportHelper &rImportHelper, SvXMLImport &rImport, const OUString &rSeriesStyleName,::std::vector< DataRowPointStyle > &rStyleVector, const css::uno::Reference< css::chart2::XDataSeries > &xSeries, ContextType eContextType, tSchXMLLSequencesPerIndex &rLSequencesPerIndex)
SchXMLImportHelper & mrImportHelper
SchXMLPositionAttributesHelper(SvXMLImport &rImporter)
void setXMLRangePropertyAtDataSequence(const Reference< chart2::data::XDataSequence > &xDataSequence, const OUString &rXMLRange)
virtual ~SchXMLWallFloorContext() override
static void CorrectAxisPositions(const css::uno::Reference< css::chart2::XChartDocument > &xNewDoc, std::u16string_view rChartTypeServiceName, std::u16string_view rODFVersionOfFile, bool bAxisPositionAttributeImported)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
bool mbDataLabelsRange
Are label's contents sourced from a cell[range] ?
virtual ~SchXMLStatisticsObjectContext() override
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:113
::std::vector< SchXMLAxis > maAxes
void readPositioningAttribute(sal_Int32 nAttributeToken, std::string_view rValue)
SchXML3DSceneAttributesHelper(SvXMLImport &rImporter)
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
void setZ(double fZ)
::std::pair< tSchXMLIndex, SchXMLLabeledSequencePart > tSchXMLIndexWithPart
::std::vector< OUString > mLabels
Text content of each field.
SchXMLImportHelper & mrImportHelper
virtual void SAL_CALL characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
css::uno::Any maStackedBarsConnectedDefault
::std::vector< OUString > & mrLabels
void getCameraDefaultFromDiagram(const css::uno::Reference< css::chart::XDiagram > &xDiagram)
const OUString & m_rXLinkHRefAttributeToIndicateDataProvider
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
tSchXMLLSequencesPerIndex & mrLSequencesPerIndex
constexpr sal_uInt16 XML_NAMESPACE_SVG
SchXMLWallFloorContext(SchXMLImportHelper &rImportHelper, SvXMLImport &rImport, css::uno::Reference< css::chart::XDiagram > const &xDiagram, ContextType eContextType)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
::basegfx::B3DVector maVUP
Definition: shapeimport.hxx:94
SchXMLCoordinateRegionContext(SvXMLImport &rImport, SchXMLPositionAttributesHelper &rPositioning)
void readAutomaticPositioningProperties(XMLPropStyleContext const *pPropStyleContext, const SvXMLStylesContext *pStylesCtxt)
SchXMLPositionAttributesHelper m_aInnerPositioning
void setY(double fY)
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
Definition: prstylei.cxx:222
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
::basegfx::B3DVector maVPN
Definition: shapeimport.hxx:93
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
::std::vector< DataRowPointStyle > & mrStyleVector
SchXMLDataLabelSpanContext(SvXMLImport &rImport,::std::vector< OUString > &rLabels)
virtual ~SchXMLPlotAreaContext() override
css::uno::Reference< css::beans::XPropertySet > m_xErrorXProperties
float u
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
OUString aPropName
css::uno::Any maRegressionCurvesDefault
static XmlStyleFamily GetChartFamilyID()
::std::vector< RegressionStyle > maRegressionStyleVector
SvXMLImportContext * create3DLightContext(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
creates a 3d light context and adds it to the internal list for later processing
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
With this class you can import a element containing its data as element o...
css::uno::Reference< css::chart2::XDataSeries > m_xSeries
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
SchXMLPositionAttributesHelper & m_rPositioning
OUString msStyleNameOfParent
Used to store text content of a data point custom-label's fields and also the helper members that ind...
constexpr sal_uInt16 XML_NAMESPACE_SVG_COMPAT
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
#define TOOLS_INFO_EXCEPTION(area, stream)
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
SchXMLPositionAttributesHelper m_aOuterPositioning
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
SchXML3DSceneAttributesHelper maSceneImportHelper
::std::vector< OUString > & mrLabels
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()
const css::uno::Reference< css::chart::XChartDocument > & GetChartDocument() const
::std::vector< DataRowPointStyle > maSeriesStyleVector
SeriesDefaultsAndStyles & mrSeriesDefaultsAndStyles
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:104
OUString GetODFVersion() const
Definition: xmlimp.cxx:1853
#define SAL_WARN_IF(condition, area, stream)
css::awt::Rectangle getRectangle() const
Handling of tokens in XML:
const SvXMLImport & m_rImport
SchXMLDataLabelParaContext(SvXMLImport &rImport,::std::vector< OUString > &rLabels)
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97
GlobalSeriesImportInfo m_aGlobalSeriesImportInfo
bool isDocumentGeneratedWithOpenOfficeOlderThan3_0(const uno::Reference< frame::XModel > &xChartModel)
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:400
virtual ~SchXMLStockContext() override
OUString msLabelsCellRange
cell[range] from which label's contents are sourced.
Reference< XComponentContext > getProcessComponentContext()
DataRowPointStyle & mrDataLabelStyle
TABLE
void setX(double fX)
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:788
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
#define SAL_WARN(area, stream)
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:94
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:119
SchXMLImportHelper & mrImportHelper
bool isDocumentGeneratedWithOpenOfficeOlderThan2_3(const uno::Reference< frame::XModel > &xChartModel)
bool isDocumentGeneratedWithOpenOfficeOlderThan2_4(const uno::Reference< frame::XModel > &xChartModel)
::basegfx::B3DVector maVRP
Definition: shapeimport.hxx:92
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
::std::multimap< tSchXMLIndexWithPart, css::uno::Reference< css::chart2::data::XLabeledDataSequence > > tSchXMLLSequencesPerIndex
TEXT
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
std::optional< sal_Int32 > mo_nLabelAbsolutePosY
virtual ~SchXMLCoordinateRegionContext() override
css::uno::Reference< css::chart::XDiagram > mxDiagram
Reference< chart2::XDataSeries > m_xSeries