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 <comphelper/sequence.hxx>
28 #include <sal/log.hxx>
29 #include <tools/diagnose_ex.h>
30 #include <xmloff/xmlnamespace.hxx>
31 #include <xmloff/namespacemap.hxx>
32 #include <xmloff/xmluconv.hxx>
33 #include <xmloff/prstylei.hxx>
34 #include <xmloff/xmlstyle.hxx>
36 
37 #include <com/sun/star/awt/Point.hpp>
38 #include <com/sun/star/awt/Size.hpp>
39 #include <com/sun/star/chart/ErrorBarStyle.hpp>
40 #include <com/sun/star/chart/X3DDisplay.hpp>
41 #include <com/sun/star/chart/XStatisticDisplay.hpp>
42 #include <com/sun/star/chart/XDiagramPositioning.hpp>
43 #include <com/sun/star/chart/XChartDocument.hpp>
44 #include <com/sun/star/chart2/XChartDocument.hpp>
45 #include <com/sun/star/chart2/data/XDataSink.hpp>
46 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
47 #include <com/sun/star/chart2/data/LabeledDataSequence.hpp>
48 #include <com/sun/star/drawing/CameraGeometry.hpp>
49 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 #include <com/sun/star/lang/XServiceInfo.hpp>
51 #include <com/sun/star/xml/sax/XAttributeList.hpp>
52 
53 using namespace com::sun::star;
54 using namespace ::xmloff::token;
55 
57 
58 namespace
59 {
60 
61 struct lcl_AxisHasCategories
62 {
63  bool operator() ( const SchXMLAxis & rAxis )
64  {
65  return rAxis.bHasCategories;
66  }
67 };
68 
69 OUString lcl_ConvertRange( const OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
70 {
71  OUString aResult = rRange;
72  if(!xDoc.is())
73  return aResult;
74  uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
75  xDoc->getDataProvider(), uno::UNO_QUERY );
76  if( xConversion.is())
77  aResult = xConversion->convertRangeFromXML( rRange );
78  return aResult;
79 }
80 
81 } // anonymous namespace
82 
84  : SdXML3DSceneAttributesHelper( rImporter )
85 {
86 }
87 
88 void SchXML3DSceneAttributesHelper::getCameraDefaultFromDiagram( const uno::Reference< chart::XDiagram >& xDiagram )
89 {
90  //different defaults for camera geometry necessary to workaround wrong behaviour in old chart
91  //in future make this version dependent if we have versioning (metastream) for ole objects
92 
93  try
94  {
95  uno::Reference< beans::XPropertySet > xProp( xDiagram, uno::UNO_QUERY );
96  if( xProp.is() )
97  {
98  drawing::CameraGeometry aCamGeo;
99  xProp->getPropertyValue("D3DCameraGeometry") >>= aCamGeo;
100  maVRP.setX( aCamGeo.vrp.PositionX );
101  maVRP.setY( aCamGeo.vrp.PositionY );
102  maVRP.setZ( aCamGeo.vrp.PositionZ );
103  maVPN.setX( aCamGeo.vpn.DirectionX );
104  maVPN.setY( aCamGeo.vpn.DirectionY );
105  maVPN.setZ( aCamGeo.vpn.DirectionZ );
106  maVUP.setX( aCamGeo.vup.DirectionX );
107  maVUP.setY( aCamGeo.vup.DirectionY );
108  maVUP.setZ( aCamGeo.vup.DirectionZ );
109  }
110  }
111  catch( const uno::Exception & )
112  {
113  TOOLS_INFO_EXCEPTION("xmloff.chart", "Exception caught for property NumberOfLines");
114  }
115 }
116 
118 {
119 }
120 
122  SchXMLImportHelper& rImpHelper,
123  SvXMLImport& rImport,
124  const OUString& rXLinkHRefAttributeToIndicateDataProvider,
125  OUString& rCategoriesAddress,
126  OUString& rChartAddress,
127  bool & rbHasRangeAtPlotArea,
128  bool & rAllRangeAddressesAvailable,
129  bool & rColHasLabels,
130  bool & rRowHasLabels,
131  chart::ChartDataRowSource & rDataRowSource,
132  SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles,
133  const OUString& aChartTypeServiceName,
134  tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
135  const awt::Size & rChartSize ) :
136  SvXMLImportContext( rImport ),
137  mrImportHelper( rImpHelper ),
138  mrCategoriesAddress( rCategoriesAddress ),
139  mrSeriesDefaultsAndStyles( rSeriesDefaultsAndStyles ),
140  mnNumOfLinesProp( 0 ),
141  mbStockHasVolume( false ),
142  mnSeries( 0 ),
143  m_aGlobalSeriesImportInfo( rAllRangeAddressesAvailable ),
144  maSceneImportHelper( rImport ),
145  m_aOuterPositioning( rImport ),
146  m_aInnerPositioning( rImport ),
147  mbPercentStacked(false),
148  m_bAxisPositionAttributeImported(false),
149  m_rXLinkHRefAttributeToIndicateDataProvider(rXLinkHRefAttributeToIndicateDataProvider),
150  mrChartAddress( rChartAddress ),
151  m_rbHasRangeAtPlotArea( rbHasRangeAtPlotArea ),
152  mrColHasLabels( rColHasLabels ),
153  mrRowHasLabels( rRowHasLabels ),
154  mrDataRowSource( rDataRowSource ),
155  maChartTypeServiceName( aChartTypeServiceName ),
156  mrLSequencesPerIndex( rLSequencesPerIndex ),
157  mbGlobalChartTypeUsedBySeries( false ),
158  maChartSize( rChartSize )
159 {
160  m_rbHasRangeAtPlotArea = false;
161 
162  // get Diagram
163  uno::Reference< chart::XChartDocument > xDoc = rImpHelper.GetChartDocument();
164  if( xDoc.is())
165  {
166  mxDiagram = xDoc->getDiagram();
167  mxNewDoc.set( xDoc, uno::UNO_QUERY );
168 
170  }
171  SAL_WARN_IF( !mxDiagram.is(),"xmloff.chart", "Couldn't get XDiagram" );
172 
173  // turn off all axes initially
174  uno::Any aFalseBool;
175  aFalseBool <<= false;
176 
177  uno::Reference< lang::XServiceInfo > xInfo( mxDiagram, uno::UNO_QUERY );
178  uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
179  if( !xInfo.is() || !xProp.is() )
180  return;
181 
182  try
183  {
184  xProp->setPropertyValue("HasXAxis", aFalseBool );
185  xProp->setPropertyValue("HasXAxisGrid", aFalseBool );
186  xProp->setPropertyValue("HasXAxisDescription", aFalseBool );
187  xProp->setPropertyValue("HasSecondaryXAxis", aFalseBool );
188  xProp->setPropertyValue("HasSecondaryXAxisDescription", aFalseBool );
189 
190  xProp->setPropertyValue("HasYAxis", aFalseBool );
191  xProp->setPropertyValue("HasYAxisGrid", aFalseBool );
192  xProp->setPropertyValue("HasYAxisDescription", aFalseBool );
193  xProp->setPropertyValue("HasSecondaryYAxis", aFalseBool );
194  xProp->setPropertyValue("HasSecondaryYAxisDescription", aFalseBool );
195 
196  xProp->setPropertyValue("HasZAxis", aFalseBool );
197  xProp->setPropertyValue("HasZAxisDescription", aFalseBool );
198 
199  xProp->setPropertyValue("DataRowSource", uno::Any(chart::ChartDataRowSource_COLUMNS) );
200  }
201  catch( const beans::UnknownPropertyException & )
202  {
203  SAL_WARN("xmloff.chart", "Property required by service not supported" );
204  }
205 }
206 
208 {}
209 
210 void SchXMLPlotAreaContext::startFastElement (sal_Int32 /*nElement*/,
211  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
212 {
213  // parse attributes
214  uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
215 
216  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
217  {
218  switch( aIter.getToken() )
219  {
220  case XML_ELEMENT(SVG, XML_X):
221  case XML_ELEMENT(SVG_COMPAT, XML_X):
222  case XML_ELEMENT(SVG, XML_Y):
223  case XML_ELEMENT(SVG_COMPAT, XML_Y):
224  case XML_ELEMENT(SVG, XML_WIDTH):
225  case XML_ELEMENT(SVG_COMPAT, XML_WIDTH):
226  case XML_ELEMENT(SVG, XML_HEIGHT):
227  case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT):
228  m_aOuterPositioning.readPositioningAttribute( aIter.getToken(), aIter.toView() );
229  break;
231  msAutoStyleName = aIter.toString();
232  break;
234  mrChartAddress = lcl_ConvertRange( aIter.toString(), xNewDoc );
235  // indicator for getting data from the outside
236  m_rbHasRangeAtPlotArea = true;
237  break;
239  {
240  if( IsXMLToken(aIter, XML_BOTH) )
242  else if( IsXMLToken(aIter, XML_ROW) )
243  mrRowHasLabels = true;
244  else if( IsXMLToken(aIter, XML_COLUMN) )
245  mrColHasLabels = true;
246  }
247  break;
248  case XML_ELEMENT(DR3D, XML_TRANSFORM):
249  case XML_ELEMENT(DR3D, XML_VRP):
250  case XML_ELEMENT(DR3D, XML_VPN):
251  case XML_ELEMENT(DR3D, XML_VUP):
252  case XML_ELEMENT(DR3D, XML_PROJECTION):
253  case XML_ELEMENT(DR3D, XML_DISTANCE):
254  case XML_ELEMENT(DR3D, XML_FOCAL_LENGTH):
255  case XML_ELEMENT(DR3D, XML_SHADOW_SLANT):
256  case XML_ELEMENT(DR3D, XML_SHADE_MODE):
257  case XML_ELEMENT(DR3D, XML_AMBIENT_COLOR):
258  case XML_ELEMENT(DR3D, XML_LIGHTING_MODE):
260  break;
261  default:
262  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
263  }
264  }
265 
266  if( ! mxNewDoc.is())
267  {
268  uno::Reference< beans::XPropertySet > xDocProp( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
269  if( xDocProp.is())
270  {
271  try
272  {
273  xDocProp->setPropertyValue("DataSourceLabelsInFirstColumn", uno::Any(mrColHasLabels) );
274  xDocProp->setPropertyValue("DataSourceLabelsInFirstRow", uno::Any(mrRowHasLabels) );
275  }
276  catch( const beans::UnknownPropertyException & )
277  {
278  SAL_WARN("xmloff.chart", "Properties missing" );
279  }
280  }
281  }
282 
283  // set properties
284  uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
285  if( !msAutoStyleName.isEmpty())
286  {
287  if( xProp.is())
288  {
290  if( pStylesCtxt )
291  {
292  const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
294 
295  XMLPropStyleContext* pPropStyleContext =
296  const_cast< XMLPropStyleContext * >(
297  dynamic_cast< const XMLPropStyleContext * >( pStyle ) );
298  if( pPropStyleContext )
299  {
300  pPropStyleContext->FillPropertySet( xProp );
301 
302  // get the data row source that was set without having data
303  xProp->getPropertyValue("DataRowSource")
304  >>= mrDataRowSource;
305 
306  //lines on/off
307  //this old property is not supported fully anymore with the new chart, so we need to get the information a little bit different from similar properties
309  u"Lines", pPropStyleContext, pStylesCtxt );
310 
311  //handle automatic position and size
312  m_aOuterPositioning.readAutomaticPositioningProperties( pPropStyleContext, pStylesCtxt );
313 
314  //correct default starting angle for old 3D pies
316  {
317  bool bIs3d = false;
318  if( xProp.is() && ( xProp->getPropertyValue("Dim3D") >>= bIs3d ) &&
319  bIs3d )
320  {
321  if( maChartTypeServiceName == "com.sun.star.chart2.PieChartType" || maChartTypeServiceName == "com.sun.star.chart2.DonutChartType" )
322  {
323  OUString aPropName( "StartingAngle" );
324  uno::Any aAStartingAngle( SchXMLTools::getPropertyFromContext( aPropName, pPropStyleContext, pStylesCtxt ) );
325  if( !aAStartingAngle.hasValue() )
326  xProp->setPropertyValue( aPropName, uno::makeAny(sal_Int32(0)) ) ;
327  }
328  }
329  }
330  }
331  }
332  }
333  }
334 
335  //remember default values for dataseries
336  if(xProp.is())
337  {
338  try
339  {
340  mrSeriesDefaultsAndStyles.maSymbolTypeDefault = xProp->getPropertyValue("SymbolType");
341  mrSeriesDefaultsAndStyles.maDataCaptionDefault = xProp->getPropertyValue("DataCaption");
342 
343  mrSeriesDefaultsAndStyles.maMeanValueDefault = xProp->getPropertyValue("MeanValue");
344  mrSeriesDefaultsAndStyles.maRegressionCurvesDefault = xProp->getPropertyValue("RegressionCurves");
345 
346  bool bStacked = false;
347  mrSeriesDefaultsAndStyles.maStackedDefault = xProp->getPropertyValue("Stacked");
349  mrSeriesDefaultsAndStyles.maPercentDefault = xProp->getPropertyValue("Percent");
351  mrSeriesDefaultsAndStyles.maStackedBarsConnectedDefault = xProp->getPropertyValue("StackedBarsConnected");
352 
353  // deep
354  uno::Any aDeepProperty( xProp->getPropertyValue("Deep"));
355  // #124488# old versions store a 3d area and 3D line deep chart with Deep==false => workaround for this
356  if( ! (bStacked || mbPercentStacked ))
357  {
359  {
360  bool bIs3d = false;
361  if( ( xProp->getPropertyValue("Dim3D") >>= bIs3d ) &&
362  bIs3d )
363  {
364  if( maChartTypeServiceName == "com.sun.star.chart2.AreaChartType" || maChartTypeServiceName == "com.sun.star.chart2.LineChartType" )
365  {
366  aDeepProperty <<= true;
367  }
368  }
369  }
370  }
372 
373  xProp->getPropertyValue("NumberOfLines") >>= mnNumOfLinesProp;
374  xProp->getPropertyValue("Volume") >>= mbStockHasVolume;
375  }
376  catch( const uno::Exception & )
377  {
378  TOOLS_INFO_EXCEPTION("xmloff.chart", "PlotAreaContext:EndElement(): Exception caught");
379  }
380  } // if
381 
382  bool bCreateInternalDataProvider = false;
383  if( m_rXLinkHRefAttributeToIndicateDataProvider == "." ) //data comes from the chart itself
384  bCreateInternalDataProvider = true;
385  else if( m_rXLinkHRefAttributeToIndicateDataProvider == ".." ) //data comes from the parent application
386  bCreateInternalDataProvider = false;
387  else if( !m_rXLinkHRefAttributeToIndicateDataProvider.isEmpty() ) //not supported so far to get the data by sibling objects -> fall back to chart itself
388  bCreateInternalDataProvider = true;
389  else if( !m_rbHasRangeAtPlotArea )
390  bCreateInternalDataProvider = true;
391 
392  if( bCreateInternalDataProvider && mxNewDoc.is() )
393  {
394  // we have no complete range => we have own data, so switch the data
395  // provider to internal. Clone is not necessary, as we don't have any
396  // data yet.
397  mxNewDoc->createInternalDataProvider( false /* bCloneExistingData */ );
398  if( xProp.is() && mrDataRowSource!=chart::ChartDataRowSource_COLUMNS )
399  xProp->setPropertyValue("DataRowSource", uno::makeAny(mrDataRowSource) );
400  }
401 }
402 
403 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLPlotAreaContext::createFastChildContext(
404  sal_Int32 nElement,
405  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
406 {
407  SvXMLImportContext* pContext = nullptr;
408 
409  switch(nElement)
410  {
411  case XML_ELEMENT(CHART_EXT, XML_COORDINATE_REGION):
413  {
415  }
416  break;
417 
418  case XML_ELEMENT(CHART, XML_AXIS):
419  {
420  bool bAddMissingXAxisForNetCharts = false;
421  bool bAdaptWrongPercentScaleValues = false;
423  {
424  //correct errors from older versions
425 
426  // for NetCharts there were no xAxis exported to older files
427  // so we need to add the x axis here for those old NetChart files
428  if ( maChartTypeServiceName == "com.sun.star.chart2.NetChartType" )
429  bAddMissingXAxisForNetCharts = true;
430 
431  //Issue 59288
432  if( mbPercentStacked )
433  bAdaptWrongPercentScaleValues = true;
434  }
435 
436  bool bAdaptXAxisOrientationForOld2DBarCharts = false;
438  {
439  //issue74660
440  if ( maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
441  bAdaptXAxisOrientationForOld2DBarCharts = true;
442  }
443 
445  bAddMissingXAxisForNetCharts, bAdaptWrongPercentScaleValues, bAdaptXAxisOrientationForOld2DBarCharts, m_bAxisPositionAttributeImported );
446  }
447  break;
448 
450  {
451  if( mxNewDoc.is())
452  {
453  pContext = new SchXMLSeries2Context(
455  mxNewDoc, maAxes,
458  mnSeries,
464  }
465  mnSeries++;
466  }
467  break;
468 
469  case XML_ELEMENT(CHART, XML_WALL):
472  break;
473  case XML_ELEMENT(CHART, XML_FLOOR):
476  break;
477 
478  case XML_ELEMENT(DR3D, XML_LIGHT):
479  pContext = maSceneImportHelper.create3DLightContext( xAttrList );
480  break;
481 
482  // elements for stock charts
486  break;
490  break;
494  break;
495  default:
496  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
497  }
498 
499  return pContext;
500 }
501 
503 {
504  // set categories
505  if( !mrCategoriesAddress.isEmpty() && mxNewDoc.is())
506  {
507  uno::Reference< chart2::data::XDataProvider > xDataProvider(
508  mxNewDoc->getDataProvider() );
509  // @todo: correct coordinate system index
510  sal_Int32 nDimension( 0 );
511  ::std::vector< SchXMLAxis >::const_iterator aIt(
512  ::std::find_if( maAxes.begin(), maAxes.end(), lcl_AxisHasCategories()));
513  if( aIt != maAxes.end())
514  nDimension = static_cast< sal_Int32 >( (*aIt).eDimension );
516  xDataProvider, mxNewDoc, mrCategoriesAddress,
517  0 /* nCooSysIndex */,
518  nDimension, &mrLSequencesPerIndex );
519  }
520 
521  uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY );
522  if( xDiaProp.is())
523  {
524  bool bIsThreeDim = false;
525  uno::Any aAny = xDiaProp->getPropertyValue("Dim3D");
526  aAny >>= bIsThreeDim;
527 
528  // set 3d scene attributes
529  if( bIsThreeDim )
530  {
531  // set scene attributes at diagram
533  }
534 
535  // set correct number of lines at series
536  if( ! m_aGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && mnNumOfLinesProp > 0 && maChartTypeServiceName == "com.sun.star.chart2.ColumnChartType" )
537  {
538  try
539  {
540  xDiaProp->setPropertyValue("NumberOfLines",
541  uno::makeAny( mnNumOfLinesProp ));
542  }
543  catch( const uno::Exception & )
544  {
545  TOOLS_INFO_EXCEPTION("xmloff.chart", "Exception caught for property NumberOfLines");
546  }
547  }
548 
549  // #i32366# stock has volume
550  if( mxDiagram->getDiagramType() == "com.sun.star.chart.StockDiagram" &&
552  {
553  try
554  {
555  xDiaProp->setPropertyValue("Volume",
556  uno::makeAny( true ));
557  }
558  catch( const uno::Exception & )
559  {
560  TOOLS_INFO_EXCEPTION("xmloff.chart", "Exception caught for property Volume");
561  }
562  }
563  }
564 
565  // set changed size and position after properties (esp. 3d)
566 
567  uno::Reference< chart::XDiagramPositioning > xDiaPos( mxDiagram, uno::UNO_QUERY );
568  if( xDiaPos.is())
569  {
571  {
573  xDiaPos->setDiagramPositionExcludingAxes( m_aInnerPositioning.getRectangle() );
574  else if( m_aOuterPositioning.hasPosSize() )
575  {
576  if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_3( GetImport().GetModel() ) ) //old version of OOo did write a wrong rectangle for the diagram size
577  xDiaPos->setDiagramPositionIncludingAxesAndAxisTitles( m_aOuterPositioning.getRectangle() );
578  else
579  xDiaPos->setDiagramPositionIncludingAxes( m_aOuterPositioning.getRectangle() );
580  }
581  }
582  }
583 
585 }
586 
587 SchXMLDataLabelSpanContext::SchXMLDataLabelSpanContext( SvXMLImport& rImport, ::std::vector<OUString>& rLabels):
588  SvXMLImportContext( rImport ),
589  mrLabels(rLabels)
590 {
591 }
592 
593 void SchXMLDataLabelSpanContext::characters(const OUString& rChars)
594 {
595  maCharBuffer.append(rChars);
596 }
597 
599 {
600  mrLabels.push_back(maCharBuffer.makeStringAndClear());
601 }
602 
603 SchXMLDataLabelParaContext::SchXMLDataLabelParaContext( SvXMLImport& rImport, ::std::vector<OUString>& rLabels):
604  SvXMLImportContext( rImport ),
605  mrLabels(rLabels)
606 {
607 }
608 
609 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLDataLabelParaContext::createFastChildContext(
610  sal_Int32 nElement,
611  const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
612 {
613  if ( nElement == XML_ELEMENT(TEXT, XML_SPAN) )
615  else
616  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
617  return nullptr;
618 }
619 
621  CustomLabelsInfo& rLabels,
622  DataRowPointStyle& rDataLabelStyle)
623  : SvXMLImportContext(rImport)
624  , mrLabels(rLabels)
625  , mrDataLabelStyle(rDataLabelStyle)
626 {
627 }
628 
629 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLDataLabelContext::createFastChildContext(
630  sal_Int32 nElement,
631  const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
632 {
633  if ( nElement == XML_ELEMENT(TEXT, XML_P) )
635  else
636  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
637  return nullptr;
638 }
639 
641  sal_Int32 /*nElement*/,
642  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
643 {
644  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
645  {
646  switch(aIter.getToken())
647  {
648  case XML_ELEMENT(SVG, XML_X):
649  case XML_ELEMENT(SVG_COMPAT, XML_X):
650  {
651  sal_Int32 nResultValue;
652  GetImport().GetMM100UnitConverter().convertMeasureToCore(nResultValue, aIter.toView());
654  break;
655  }
656  case XML_ELEMENT(SVG, XML_Y):
657  case XML_ELEMENT(SVG_COMPAT, XML_Y):
658  {
659  sal_Int32 nResultValue;
660  GetImport().GetMM100UnitConverter().convertMeasureToCore(nResultValue, aIter.toView());
662  break;
663  }
665  mrDataLabelStyle.msStyleName = aIter.toString();
666  break;
667  case XML_ELEMENT(LO_EXT, XML_DATA_LABEL_GUID):
668  mrLabels.msLabelGuid = aIter.toString();
670  break;
672  mrLabels.msLabelsCellRange = aIter.toString();
674  break;
675  default:
676  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
677  }
678  }
679 }
680 
681 
683  ::std::vector< DataRowPointStyle >& rStyleVector,
684  const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
685  sal_Int32& rIndex,
686  bool bSymbolSizeForSeriesIsMissingInFile ) :
687  SvXMLImportContext( rImport ),
688  mrStyleVector( rStyleVector ),
689  mrIndex( rIndex ),
690  mDataPoint(DataRowPointStyle::DATA_POINT, xSeries, rIndex, 1, OUString{}),
691  mDataLabel(DataRowPointStyle::DATA_LABEL_POINT, xSeries, rIndex, 1, OUString{})
692 {
693  mDataPoint.mbSymbolSizeForSeriesIsMissingInFile = bSymbolSizeForSeriesIsMissingInFile;
694 }
695 
696 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLDataPointContext::createFastChildContext(
697  sal_Int32 nElement,
698  const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
699 {
700  SvXMLImportContext* pContext = nullptr;
701  switch(nElement)
702  {
704  mbHasLabelParagraph = true;
706  mDataLabel);
707  break;
708  default:
709  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
710  }
711  return pContext;
712 }
713 
715 {
716 }
717 
718 void SchXMLDataPointContext::startFastElement (sal_Int32 /*Element*/,
719  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
720 {
721  OUString sAutoStyleName;
722  sal_Int32 nRepeat = 1;
723  OUString sCustomLabelField;
724 
725  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
726  {
727  switch (aIter.getToken())
728  {
730  {
731  sAutoStyleName = aIter.toString();
732  mDataPoint.msStyleName = sAutoStyleName;
733  mDataLabel.msStyleNameOfParent = sAutoStyleName;
734  break;
735  }
737  {
738  nRepeat = aIter.toInt32();
739  mDataPoint.m_nPointRepeat = nRepeat;
740  mDataLabel.m_nPointRepeat = nRepeat;
741  break;
742  }
743  // Deprecated. New documents use the chart:data-label element
744  // instead in order to store custom label text.
745  case XML_ELEMENT(LO_EXT, XML_CUSTOM_LABEL_FIELD):
746  if (!mbHasLabelParagraph)
747  {
748  sCustomLabelField = aIter.toString();
749  mDataPoint.mCustomLabels.mLabels.push_back(sCustomLabelField);
750  }
751  break;
752  case XML_ELEMENT(LO_EXT, XML_HIDE_LEGEND):
753  {
754  bool bHideLegend = aIter.toBoolean();
755  if (bHideLegend)
756  {
757  uno::Sequence<sal_Int32> deletedLegendEntriesSeq;
758  Reference<beans::XPropertySet> xSeriesProp(mDataPoint.m_xSeries, uno::UNO_QUERY);
759  xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq;
760  std::vector<sal_Int32> deletedLegendEntries;
761  for (const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
762  {
763  deletedLegendEntries.push_back(deletedLegendEntry);
764  }
765  deletedLegendEntries.push_back(mDataPoint.m_nPointIndex);
766  xSeriesProp->setPropertyValue("DeletedLegendEntries", uno::makeAny(comphelper::containerToSequence(deletedLegendEntries)));
767  }
768  break;
769  }
770  case XML_ELEMENT(LO_EXT, XML_CUSTOM_LABEL_POS_X):
771  {
772  mDataPoint.mCustomLabelPos[0] = aIter.toDouble();
773  break;
774  }
775  case XML_ELEMENT(LO_EXT, XML_CUSTOM_LABEL_POS_Y):
776  {
777  mDataPoint.mCustomLabelPos[1] = aIter.toDouble();
778  break;
779  }
780  default:
781  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
782  }
783  }
784 
785  mrIndex += nRepeat;
786 }
787 
789 {
790  if(!mDataPoint.msStyleName.isEmpty() || mDataPoint.mCustomLabels.mLabels.size() > 0)
791  {
792  mrStyleVector.push_back(mDataPoint);
793  }
794  if (!mDataLabel.msStyleName.isEmpty() || mDataLabel.mo_nLabelAbsolutePosX.has_value()
795  || mDataLabel.mo_nLabelAbsolutePosY.has_value())
796  {
797  mrStyleVector.push_back(mDataLabel);
798  }
799 }
800 
802  : m_rImport( rImporter )
803  , m_aPosition(0,0)
804  , m_aSize(0,0)
805  , m_bHasSizeWidth( false )
806  , m_bHasSizeHeight( false )
807  , m_bHasPositionX( false )
808  , m_bHasPositionY( false )
809  , m_bAutoSize( false )
810  , m_bAutoPosition( false )
811 {
812 }
813 
815 {
816 }
817 
819 {
821 }
822 
824 {
825  return m_bAutoSize || m_bAutoPosition;
826 }
827 
828 void SchXMLPositionAttributesHelper::readPositioningAttribute( sal_Int32 nAttributeToken, std::string_view rValue )
829 {
830  if( !IsTokenInNamespace(nAttributeToken, XML_NAMESPACE_SVG) && !IsTokenInNamespace(nAttributeToken, XML_NAMESPACE_SVG_COMPAT) )
831  return;
832 
833  switch (nAttributeToken & TOKEN_MASK)
834  {
835  case XML_X:
836  {
838  m_aPosition.X, rValue );
839  m_bHasPositionX = true;
840  break;
841  }
842  case XML_Y:
843  {
845  m_aPosition.Y, rValue );
846  m_bHasPositionY = true;
847  break;
848  }
849  case XML_WIDTH:
850  {
852  m_aSize.Width, rValue );
853  m_bHasSizeWidth = true;
854  break;
855  }
856  case XML_HEIGHT:
857  {
859  m_aSize.Height, rValue );
860  m_bHasSizeHeight = true;
861  break;
862  }
863  default:
864  XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, OUString::fromUtf8(rValue));
865  }
866 }
867 
869 {
870  if( pPropStyleContext && pStylesCtxt )
871  {
872  //handle automatic position and size
874  u"AutomaticSize", pPropStyleContext, pStylesCtxt ) >>= m_bAutoSize;
876  u"AutomaticPosition", pPropStyleContext, pStylesCtxt ) >>= m_bAutoPosition;
877  }
878 }
879 
881  SvXMLImport& rImport
882  , SchXMLPositionAttributesHelper& rPositioning )
883  : SvXMLImportContext( rImport )
884  , m_rPositioning( rPositioning )
885 {
886 }
887 
889 {
890 }
891 
893  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
894 {
895  // parse attributes
896  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
897  m_rPositioning.readPositioningAttribute( aIter.getToken(), aIter.toView() );
898 }
899 
901  SchXMLImportHelper& rImpHelper,
902  SvXMLImport& rImport,
903  uno::Reference< chart::XDiagram > const & xDiagram,
904  ContextType eContextType ) :
905  SvXMLImportContext( rImport ),
906  mrImportHelper( rImpHelper ),
907  mxWallFloorSupplier( xDiagram, uno::UNO_QUERY ),
908  meContextType( eContextType )
909 {
910 }
911 
913 {
914 }
915 
916 void SchXMLWallFloorContext::startFastElement (sal_Int32 /*Element*/,
917  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
918 {
919  if( !mxWallFloorSupplier.is())
920  return;
921 
922  OUString sAutoStyleName;
923 
924  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
925  {
926  if( aIter.getToken() == XML_ELEMENT(CHART, XML_STYLE_NAME) )
927  sAutoStyleName = aIter.toString();
928  else
929  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
930  }
931 
932  // set properties
933  uno::Reference< beans::XPropertySet > xProp = ( meContextType == CONTEXT_TYPE_WALL )
934  ? mxWallFloorSupplier->getWall()
935  : mxWallFloorSupplier->getFloor();
936 
937  if (!sAutoStyleName.isEmpty())
938  mrImportHelper.FillAutoStyle(sAutoStyleName, xProp);
939 }
940 
942  SchXMLImportHelper& rImpHelper,
943  SvXMLImport& rImport,
944  uno::Reference< chart::XDiagram > const & xDiagram,
945  ContextType eContextType ) :
946  SvXMLImportContext( rImport ),
947  mrImportHelper( rImpHelper ),
948  mxStockPropProvider( xDiagram, uno::UNO_QUERY ),
949  meContextType( eContextType )
950 {
951 }
952 
954 {
955 }
956 
957 void SchXMLStockContext::startFastElement (sal_Int32 /*Element*/,
958  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
959 {
960  if( !mxStockPropProvider.is())
961  return;
962 
963  OUString sAutoStyleName;
964 
965  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
966  {
967  if( aIter.getToken() == XML_ELEMENT(CHART, XML_STYLE_NAME) )
968  sAutoStyleName = aIter.toString();
969  else
970  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
971  }
972 
973  if( sAutoStyleName.isEmpty())
974  return;
975 
976  // set properties
977  uno::Reference< beans::XPropertySet > xProp;
978  switch( meContextType )
979  {
980  case CONTEXT_TYPE_GAIN:
981  xProp = mxStockPropProvider->getUpBar();
982  break;
983  case CONTEXT_TYPE_LOSS:
984  xProp = mxStockPropProvider->getDownBar();
985  break;
986  case CONTEXT_TYPE_RANGE:
987  xProp = mxStockPropProvider->getMinMaxLine();
988  break;
989  }
990 
991  mrImportHelper.FillAutoStyle(sAutoStyleName, xProp);
992 }
993 
994 static void lcl_setErrorBarSequence ( const uno::Reference< chart2::XChartDocument > &xDoc,
995  const uno::Reference< beans::XPropertySet > &xBarProp,
996  const OUString &aXMLRange,
997  bool bPositiveValue, bool bYError,
998  tSchXMLLSequencesPerIndex& rSequences)
999 {
1000  uno::Reference< css::chart2::data::XDataProvider > xDataProvider(xDoc->getDataProvider());
1001  uno::Reference< css::chart2::data::XDataSource > xDataSource( xBarProp, uno::UNO_QUERY );
1002  uno::Reference< css::chart2::data::XDataSink > xDataSink( xDataSource, uno::UNO_QUERY );
1003 
1004  assert( xDataSink.is() && xDataSource.is() && xDataProvider.is() );
1005 
1006  OUString aRange(lcl_ConvertRange(aXMLRange,xDoc));
1007 
1008  uno::Reference< chart2::data::XDataSequence > xNewSequence(
1009  xDataProvider->createDataSequenceByRangeRepresentation( aRange ));
1010 
1011  if( !xNewSequence.is())
1012  return;
1013 
1014  SchXMLTools::setXMLRangePropertyAtDataSequence(xNewSequence,aXMLRange);
1015 
1016  OUStringBuffer aRoleBuffer("error-bars-");
1017  if( bYError )
1018  aRoleBuffer.append( 'y' );
1019  else
1020  aRoleBuffer.append( 'x');
1021 
1022  aRoleBuffer.append( '-' );
1023 
1024  if( bPositiveValue )
1025  aRoleBuffer = aRoleBuffer.append( "positive" );
1026  else
1027  aRoleBuffer = aRoleBuffer.append( "negative" );
1028 
1029  OUString aRole = aRoleBuffer.makeStringAndClear();
1030 
1031  Reference< beans::XPropertySet > xSeqProp( xNewSequence, uno::UNO_QUERY );
1032 
1033  xSeqProp->setPropertyValue("Role", uno::makeAny( aRole ));
1034 
1036 
1037  Reference< chart2::data::XLabeledDataSequence > xLabelSeq( chart2::data::LabeledDataSequence::create(xContext),
1038  uno::UNO_QUERY_THROW );
1039 
1040  rSequences.emplace( tSchXMLIndexWithPart( -2, SCH_XML_PART_ERROR_BARS ), xLabelSeq );
1041 
1042  xLabelSeq->setValues( xNewSequence );
1043 
1044  uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
1045  xDataSource->getDataSequences());
1046 
1047  aSequences.realloc( aSequences.getLength() + 1 );
1048  aSequences.getArray()[ aSequences.getLength() - 1 ] = xLabelSeq;
1049  xDataSink->setData( aSequences );
1050 
1051 }
1052 
1054  SchXMLImportHelper& rImpHelper,
1055  SvXMLImport& rImport,
1056  const OUString &rSeriesStyleName,
1057  ::std::vector< DataRowPointStyle >& rStyleVector,
1058  const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
1059  ContextType eContextType,
1060  tSchXMLLSequencesPerIndex & rLSequencesPerIndex) :
1061 
1062  SvXMLImportContext( rImport ),
1063  mrImportHelper( rImpHelper ),
1064  mrStyleVector( rStyleVector ),
1065  m_xSeries( xSeries ),
1066  meContextType( eContextType ),
1067  maSeriesStyleName( rSeriesStyleName),
1068  mrLSequencesPerIndex(rLSequencesPerIndex)
1069 {}
1070 
1072 {
1073 }
1074 
1075 namespace {
1076 
1077 void SetErrorBarStyleProperties( const OUString& rStyleName, const uno::Reference< beans::XPropertySet >& xBarProp,
1078  SchXMLImportHelper const & rImportHelper )
1079 {
1080  const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
1082  rStyleName);
1083 
1084  XMLPropStyleContext &rSeriesStyleContext =
1085  const_cast< XMLPropStyleContext& >( dynamic_cast< const XMLPropStyleContext& >( *pStyle ));
1086 
1087  rSeriesStyleContext.FillPropertySet( xBarProp );
1088 }
1089 
1090 void SetErrorBarPropertiesFromStyleName( const OUString& aStyleName, const uno::Reference< beans::XPropertySet>& xBarProp,
1091  SchXMLImportHelper const & rImportHelper, OUString& aPosRange, OUString& aNegRange)
1092 {
1093  const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext();
1095  aStyleName);
1096 
1097  XMLPropStyleContext * pSeriesStyleContext =
1098  const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
1099 
1100  uno::Any aAny = SchXMLTools::getPropertyFromContext(u"ErrorBarStyle",
1101  pSeriesStyleContext,pStylesCtxt);
1102 
1103  if ( !aAny.hasValue() )
1104  return;
1105 
1106  sal_Int32 aBarStyle = css::chart::ErrorBarStyle::NONE;
1107  aAny >>= aBarStyle;
1108  xBarProp->setPropertyValue("ErrorBarStyle", aAny);
1109 
1110  aAny = SchXMLTools::getPropertyFromContext(u"ShowPositiveError",
1111  pSeriesStyleContext,pStylesCtxt);
1112 
1113  if(aAny.hasValue())
1114  xBarProp->setPropertyValue("ShowPositiveError",aAny);
1115 
1116  aAny = SchXMLTools::getPropertyFromContext(u"ShowNegativeError",
1117  pSeriesStyleContext,pStylesCtxt);
1118 
1119  if(aAny.hasValue())
1120  xBarProp->setPropertyValue("ShowNegativeError",aAny);
1121 
1122  aAny = SchXMLTools::getPropertyFromContext(u"PositiveError",
1123  pSeriesStyleContext, pStylesCtxt);
1124 
1125  if(aAny.hasValue())
1126  xBarProp->setPropertyValue("PositiveError", aAny);
1127  else
1128  {
1129  aAny = SchXMLTools::getPropertyFromContext(u"ConstantErrorHigh",
1130  pSeriesStyleContext, pStylesCtxt);
1131 
1132  if(aAny.hasValue())
1133  xBarProp->setPropertyValue("PositiveError", aAny);
1134  }
1135 
1136  aAny = SchXMLTools::getPropertyFromContext(u"NegativeError",
1137  pSeriesStyleContext, pStylesCtxt);
1138 
1139  if(aAny.hasValue())
1140  xBarProp->setPropertyValue("NegativeError", aAny);
1141  else
1142  {
1143  aAny = SchXMLTools::getPropertyFromContext(u"ConstantErrorLow",
1144  pSeriesStyleContext, pStylesCtxt);
1145 
1146  if(aAny.hasValue())
1147  xBarProp->setPropertyValue("NegativeError", aAny);
1148  }
1149 
1150  aAny = SchXMLTools::getPropertyFromContext(u"ErrorBarRangePositive",
1151  pSeriesStyleContext, pStylesCtxt);
1152  if( aAny.hasValue() )
1153  {
1154  aAny >>= aPosRange;
1155  }
1156 
1157  aAny = SchXMLTools::getPropertyFromContext(u"ErrorBarRangeNegative",
1158  pSeriesStyleContext, pStylesCtxt);
1159  if( aAny.hasValue() )
1160  {
1161  aAny >>= aNegRange;
1162  }
1163 
1164  aAny = SchXMLTools::getPropertyFromContext(u"Weight",
1165  pSeriesStyleContext, pStylesCtxt);
1166  if( aAny.hasValue() )
1167  {
1168  xBarProp->setPropertyValue("Weight", aAny);
1169  }
1170 
1171  aAny = SchXMLTools::getPropertyFromContext(u"PercentageError",
1172  pSeriesStyleContext, pStylesCtxt);
1173  if( aAny.hasValue() && aBarStyle == css::chart::ErrorBarStyle::RELATIVE )
1174  {
1175  xBarProp->setPropertyValue("PositiveError", aAny);
1176  xBarProp->setPropertyValue("NegativeError", aAny);
1177  }
1178 
1179  switch(aBarStyle)
1180  {
1181  case css::chart::ErrorBarStyle::ERROR_MARGIN:
1182  {
1183  aAny = SchXMLTools::getPropertyFromContext(u"NegativeError",
1184  pSeriesStyleContext,pStylesCtxt);
1185 
1186  xBarProp->setPropertyValue("NegativeError",aAny);
1187 
1188  aAny = SchXMLTools::getPropertyFromContext(u"PositiveError",
1189  pSeriesStyleContext,pStylesCtxt);
1190 
1191  xBarProp->setPropertyValue("PositiveError",aAny);
1192  }
1193  break;
1194  default:
1195  break;
1196  }
1197 
1198 }
1199 
1200 }
1201 
1203  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
1204 {
1205  OUString sAutoStyleName;
1206  OUString aPosRange;
1207  OUString aNegRange;
1208  bool bYError = true;
1209 
1210  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
1211  {
1212  switch (aIter.getToken())
1213  {
1215  sAutoStyleName = aIter.toString();
1216  break;
1218  bYError = aIter.toString() == "y";
1219  break;
1221  aPosRange = aIter.toString();
1222  break;
1224  aNegRange = aIter.toString();
1225  break;
1226  }
1227  }
1228 
1229  if( sAutoStyleName.isEmpty() )
1230  return;
1231 
1232  DataRowPointStyle aStyle( DataRowPointStyle::MEAN_VALUE, m_xSeries, -1, 1, sAutoStyleName );
1233 
1234  switch( meContextType )
1235  {
1238  break;
1240  {
1242 
1243  uno::Reference< lang::XMultiServiceFactory > xFact = comphelper::getProcessServiceFactory();
1244 
1245  uno::Reference< beans::XPropertySet > xBarProp( xFact->createInstance("com.sun.star.chart2.ErrorBar" ),
1246  uno::UNO_QUERY );
1247 
1248  xBarProp->setPropertyValue("ErrorBarStyle",uno::makeAny(css::chart::ErrorBarStyle::NONE));
1249  xBarProp->setPropertyValue("PositiveError",uno::makeAny(0.0));
1250  xBarProp->setPropertyValue("NegativeError",uno::makeAny(0.0));
1251  xBarProp->setPropertyValue("Weight",uno::makeAny(1.0));
1252  xBarProp->setPropertyValue("ShowPositiveError",uno::makeAny(true));
1253  xBarProp->setPropertyValue("ShowNegativeError",uno::makeAny(true));
1254 
1255  // first import defaults from parent style
1256  SetErrorBarStyleProperties( maSeriesStyleName, xBarProp, mrImportHelper );
1257  SetErrorBarStyleProperties( sAutoStyleName, xBarProp, mrImportHelper );
1258  SetErrorBarPropertiesFromStyleName( maSeriesStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1259  SetErrorBarPropertiesFromStyleName( sAutoStyleName, xBarProp, mrImportHelper, aPosRange, aNegRange );
1260 
1261  uno::Reference< chart2::XChartDocument > xDoc(GetImport().GetModel(),uno::UNO_QUERY);
1262 
1263  if (!aPosRange.isEmpty())
1264  lcl_setErrorBarSequence(xDoc,xBarProp,aPosRange,true,bYError, mrLSequencesPerIndex);
1265 
1266  if (!aNegRange.isEmpty())
1267  lcl_setErrorBarSequence(xDoc,xBarProp,aNegRange,false,bYError, mrLSequencesPerIndex);
1268 
1269  if ( !bYError )
1270  {
1271  aStyle.m_xErrorXProperties.set( xBarProp );
1272  }
1273  else
1274  {
1275  aStyle.m_xErrorYProperties.set( xBarProp );
1276  }
1277  }
1278  break;
1279  }
1280 
1281  mrStyleVector.push_back( aStyle );
1282 }
1283 
1284 /* 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:60
#define XMLOFF_WARN_UNKNOWN_ATTR(area, token, value)
Definition: xmlictxt.hxx:117
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:3528
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:114
::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:45
#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:1844
#define SAL_WARN_IF(condition, area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
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
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
Definition: xmlstyle.cxx:791
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:120
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