47#include <rtl/math.hxx>
58#include <com/sun/star/lang/XServiceInfo.hpp>
59#include <com/sun/star/lang/XServiceName.hpp>
60#include <com/sun/star/beans/XPropertySet.hpp>
61#include <com/sun/star/uno/XComponentContext.hpp>
62#include <com/sun/star/util/XRefreshable.hpp>
64#include <com/sun/star/chart/XAxis.hpp>
65#include <com/sun/star/chart/XAxisSupplier.hpp>
66#include <com/sun/star/chart/XChartDocument.hpp>
67#include <com/sun/star/chart/ChartLegendExpansion.hpp>
68#include <com/sun/star/chart/ChartDataRowSource.hpp>
69#include <com/sun/star/chart/ChartAxisAssign.hpp>
70#include <com/sun/star/chart/DataLabelPlacement.hpp>
71#include <com/sun/star/chart/TimeIncrement.hpp>
72#include <com/sun/star/chart/TimeInterval.hpp>
73#include <com/sun/star/chart/TimeUnit.hpp>
74#include <com/sun/star/chart/X3DDisplay.hpp>
75#include <com/sun/star/chart/XStatisticDisplay.hpp>
76#include <com/sun/star/chart/XDiagramPositioning.hpp>
78#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
79#include <com/sun/star/chart2/AxisType.hpp>
80#include <com/sun/star/chart2/XChartDocument.hpp>
81#include <com/sun/star/chart2/XDiagram.hpp>
82#include <com/sun/star/chart2/RelativePosition.hpp>
83#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
84#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
85#include <com/sun/star/chart2/XChartTypeContainer.hpp>
86#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
87#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
88#include <com/sun/star/chart2/data/XDataSource.hpp>
89#include <com/sun/star/chart2/data/XDataSink.hpp>
90#include <com/sun/star/chart2/data/XDataProvider.hpp>
91#include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp>
92#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
93#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
94#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
95#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
97#include <com/sun/star/util/MeasureUnit.hpp>
98#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
99#include <com/sun/star/drawing/XShapes.hpp>
100#include <com/sun/star/embed/Aspects.hpp>
101#include <com/sun/star/embed/XVisualObject.hpp>
102#include <com/sun/star/container/XChild.hpp>
111using ::com::sun::star::uno::Sequence;
112using ::com::sun::star::uno::Reference;
113using ::com::sun::star::uno::Any;
124 struct CustomLabelData
127 mbDataLabelsRange( false )
132 Sequence<Reference<chart2::XDataPointCustomLabelField>> maFields;
134 bool mbDataLabelsRange;
141 struct SchXMLDataPointStruct
143 OUString maStyleName;
145 chart2::RelativePosition mCustomLabelPos;
149 CustomLabelData mCustomLabel;
150 OUString msDataLabelStyleName;
152 SchXMLDataPointStruct() : mnRepeat( 1 ) {}
161 typedef ::std::pair< css::uno::Reference< css::chart2::data::XDataSequence >,
174 void collectAutoStyles( css::uno::Reference< css::chart::XChartDocument >
const & rChartDoc );
190 void exportChart( css::uno::Reference< css::chart::XChartDocument >
const & rChartDoc,
191 bool bIncludeTable );
199 const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc );
202 const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc );
209 std::vector< XMLPropertyState >&& aStates );
211 const std::vector< XMLPropertyState >& aStates );
214 void parseDocument( css::uno::Reference< css::chart::XChartDocument >
const & rChartDoc,
216 bool bIncludeTable =
false );
219 const css::uno::Reference< css::chart::XDiagram >& xDiagram,
220 const css::uno::Reference< css::chart2::XDiagram >& xNewDiagram,
221 const css::awt::Size & rPageSize,
223 bool bIncludeTable );
225 void exportAxes(
const css::uno::Reference< css::chart::XDiagram > & xDiagram,
226 const css::uno::Reference< css::chart2::XDiagram > & xNewDiagram,
227 bool bExportContent );
229 const Reference< beans::XPropertySet >& rAxisProps,
const Reference< chart2::XAxis >& rChart2Axis,
230 const OUString& rCategoriesRanges,
231 bool bHasTitle,
bool bHasMajorGrid,
bool bHasMinorGrid,
bool bExportContent, std::u16string_view sChartType );
232 void exportGrid(
const Reference< beans::XPropertySet >& rGridProperties,
bool bMajor,
bool bExportContent );
233 void exportDateScale(
const Reference< beans::XPropertySet >& rAxisProps );
234 void exportAxisTitle(
const Reference< beans::XPropertySet >& rTitleProps,
bool bExportContent );
237 const css::uno::Reference< css::chart2::XDiagram > & xNewDiagram,
238 const css::awt::Size & rPageSize,
243 const css::uno::Reference< css::chart2::data::XDataSource > & xSource,
244 const Sequence< OUString >& rSupportedMappings );
247 const css::uno::Sequence<
248 css::uno::Reference< css::chart2::XDataSeries > > & aSeriesSeq,
249 const css::uno::Reference< css::chart2::XDiagram > & xDiagram,
250 bool bJapaneseCandleSticks,
251 bool bExportContent );
253 const css::uno::Reference< css::beans::XPropertySet > & xSeriesProperties,
254 sal_Int32 nSeriesLength,
255 const css::uno::Reference< css::chart2::XDiagram > & xDiagram,
256 bool bExportContent );
262 const css::uno::Reference<css::chart2::XDataSeries>& xSeries,
263 const css::awt::Size& rPageSize,
264 bool bExportContent );
267 const css::uno::Reference<beans::XPropertySet> &xSeriesProp,
bool bYError,
268 bool bExportContent );
272 void addPosition(
const css::uno::Reference< css::drawing::XShape >& xShape );
274 void addSize(
const css::awt::Size & rSize,
bool bIsOOoNamespace =
false );
275 void addSize(
const css::uno::Reference< css::drawing::XShape >& xShape );
308CustomLabelData lcl_getCustomLabelField(
SvXMLExport const& rExport,
309 sal_Int32 nDataPointIndex,
310 const uno::Reference< chart2::XDataSeries >& rSeries)
313 return CustomLabelData();
320 return CustomLabelData();
322 if(Reference<beans::XPropertySet> xLabels = rSeries->getDataPointByIndex(nDataPointIndex); xLabels.is())
324 if(
Any aAny = xLabels->getPropertyValue(
"CustomLabelFields"); aAny.hasValue())
326 CustomLabelData
aData;
327 Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aCustomLabels;
328 aAny >>= aCustomLabels;
329 for (
const auto& rField: std::as_const(aCustomLabels))
331 if (rField->getFieldType() == chart2::DataPointCustomLabelFieldType_CELLRANGE)
333 if (rField->getDataLabelsRange())
334 aData.mbDataLabelsRange =
true;
335 aData.maRange = rField->getCellRange();
336 aData.maGuid = rField->getGuid();
340 aData.maFields = aCustomLabels;
344 return CustomLabelData();
347css::chart2::RelativePosition lcl_getCustomLabelPosition(
349 sal_Int32
const nDataPointIndex,
350 const uno::Reference< chart2::XDataSeries >& rSeries)
353 return chart2::RelativePosition();
359 return chart2::RelativePosition();
361 if (Reference<beans::XPropertySet> xLabels = rSeries->getDataPointByIndex(nDataPointIndex); xLabels.is())
363 if (Any aAny = xLabels->getPropertyValue(
"CustomLabelPosition"); aAny.hasValue())
365 chart2::RelativePosition aCustomLabelPos;
366 aAny >>= aCustomLabelPos;
367 return aCustomLabelPos;
370 return chart2::RelativePosition();
376 explicit lcl_MatchesRole( OUString aRole ) :
380 bool operator () (
const Reference< chart2::data::XLabeledDataSequence > & xSeq )
const
384 Reference< beans::XPropertySet > xProp( xSeq->getValues(), uno::UNO_QUERY );
387 return ( xProp.is() &&
388 (xProp->getPropertyValue(
"Role" ) >>= aRole ) &&
396Reference< chart2::data::XLabeledDataSequence > lcl_getCategories(
const Reference< chart2::XDiagram > & xDiagram )
398 Reference< chart2::data::XLabeledDataSequence > xResult;
401 Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
402 xDiagram, uno::UNO_QUERY_THROW );
403 const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
404 xCooSysCnt->getCoordinateSystems());
405 for(
const auto& rCooSys : aCooSysSeq )
407 Reference< chart2::XCoordinateSystem > xCooSys( rCooSys );
408 SAL_WARN_IF( !xCooSys.is(),
"xmloff.chart",
"xCooSys is NULL" );
409 for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
411 const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
412 for(sal_Int32 nI=0; nI<=nMaxAxisIndex; ++nI)
414 Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( nN, nI );
415 SAL_WARN_IF( !xAxis.is(),
"xmloff.chart",
"xAxis is NULL");
418 chart2::ScaleData aScaleData = xAxis->getScaleData();
419 if( aScaleData.Categories.is())
421 xResult.set( aScaleData.Categories );
429 catch(
const uno::Exception & )
437Reference< chart2::data::XDataSource > lcl_createDataSource(
438 const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aData )
440 Reference< uno::XComponentContext > xContext(
442 Reference< chart2::data::XDataSink >
xSink(
443 xContext->getServiceManager()->createInstanceWithContext(
444 "com.sun.star.chart2.data.DataSource", xContext ),
445 uno::UNO_QUERY_THROW );
446 xSink->setData( aData );
448 return Reference< chart2::data::XDataSource >( xSink, uno::UNO_QUERY );
451Sequence< Reference< chart2::data::XLabeledDataSequence > > lcl_getAllSeriesSequences(
const Reference< chart2::XChartDocument >& xChartDoc )
453 ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aContainer;
456 Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
458 for(
const auto& rSeries : aSeriesVector )
460 Reference< chart2::data::XDataSource > xDataSource( rSeries, uno::UNO_QUERY );
461 if( !xDataSource.is() )
463 const uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
464 aContainer.insert( aContainer.end(), aDataSequences.begin(), aDataSequences.end() );
471Reference< chart2::data::XLabeledDataSequence >
472 lcl_getDataSequenceByRole(
473 const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aLabeledSeq,
474 const OUString & rRole )
476 Reference< chart2::data::XLabeledDataSequence > aNoResult;
478 const Reference< chart2::data::XLabeledDataSequence > * pBegin = aLabeledSeq.getConstArray();
479 const Reference< chart2::data::XLabeledDataSequence > * pEnd = pBegin + aLabeledSeq.getLength();
480 const Reference< chart2::data::XLabeledDataSequence > * pMatch =
481 ::std::find_if( pBegin, pEnd, lcl_MatchesRole( rRole ));
489Reference< chart2::data::XDataSource > lcl_pressUsedDataIntoRectangularFormat(
const Reference< chart2::XChartDocument >& xChartDoc,
bool& rOutSourceHasCategoryLabels )
491 ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aLabeledSeqVector;
494 Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
495 Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xDiagram ) );
496 if( xCategories.is() )
497 aLabeledSeqVector.push_back( xCategories );
498 rOutSourceHasCategoryLabels = xCategories.is();
500 const Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeriesSeqVector(
501 lcl_getAllSeriesSequences( xChartDoc ) );
504 Reference< chart2::data::XLabeledDataSequence > xXValues(
505 lcl_getDataSequenceByRole( aSeriesSeqVector,
"values-x" ) );
507 aLabeledSeqVector.push_back( xXValues );
510 lcl_MatchesRole aHasXValues(
"values-x" );
511 std::copy_if(aSeriesSeqVector.begin(), aSeriesSeqVector.end(), std::back_inserter(aLabeledSeqVector),
512 [&aHasXValues](
const auto& rSeriesSeq) { return !aHasXValues( rSeriesSeq ); });
516 return lcl_createDataSource( aSeq );
519bool lcl_isSeriesAttachedToFirstAxis(
520 const Reference< chart2::XDataSeries > & xDataSeries )
526 sal_Int32 nAxisIndex = 0;
527 Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW );
528 xProp->getPropertyValue(
"AttachedAxisIndex") >>= nAxisIndex;
529 bResult = (0==nAxisIndex);
531 catch(
const uno::Exception & )
539OUString lcl_ConvertRange(
const OUString & rRange,
const Reference< chart2::XChartDocument > & xDoc )
541 OUString aResult = rRange;
544 Reference< chart2::data::XRangeXMLConversion > xConversion(
545 xDoc->getDataProvider(), uno::UNO_QUERY );
546 if( xConversion.is())
547 aResult = xConversion->convertRangeToXML( rRange );
551typedef ::std::pair< OUString, OUString > tLabelAndValueRange;
553tLabelAndValueRange lcl_getLabelAndValueRangeByRole(
554 const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aSeqCnt,
555 const OUString & rRole,
556 const Reference< chart2::XChartDocument > & xDoc,
559 tLabelAndValueRange aResult;
561 Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
562 lcl_getDataSequenceByRole( aSeqCnt, rRole ));
563 if( xLabeledSeq.is())
565 Reference< chart2::data::XDataSequence > xLabelSeq( xLabeledSeq->getLabel());
567 aResult.first = lcl_ConvertRange( xLabelSeq->getSourceRangeRepresentation(), xDoc );
569 Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues());
571 aResult.second = lcl_ConvertRange( xValueSeq->getSourceRangeRepresentation(), xDoc );
573 if( xLabelSeq.is() || xValueSeq.is())
574 rOutSequencesToExport.emplace_back( xLabelSeq, xValueSeq );
580sal_Int32 lcl_getSequenceLengthByRole(
581 const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aSeqCnt,
582 const OUString & rRole )
584 Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
585 lcl_getDataSequenceByRole( aSeqCnt, rRole ));
586 if( xLabeledSeq.is())
588 Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getValues());
589 return xSeq->getData().getLength();
594OUString lcl_flattenStringSequence(
const Sequence< OUString > & rSequence )
596 OUStringBuffer aResult;
597 bool bPrecedeWithSpace =
false;
598 for(
const auto& rString : rSequence )
600 if( !rString.isEmpty())
602 if( bPrecedeWithSpace )
603 aResult.append(
' ' );
604 aResult.append( rString );
605 bPrecedeWithSpace =
true;
608 return aResult.makeStringAndClear();
611void lcl_getLabelStringSequence( Sequence< OUString >& rOutLabels,
const Reference< chart2::data::XDataSequence > & xLabelSeq )
613 uno::Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xLabelSeq, uno::UNO_QUERY );
614 if( xTextualDataSequence.is())
616 rOutLabels = xTextualDataSequence->getTextualData();
618 else if( xLabelSeq.is())
620 Sequence< uno::Any > aAnies( xLabelSeq->getData());
621 rOutLabels.realloc( aAnies.getLength());
622 auto pOutLabels = rOutLabels.getArray();
623 for( sal_Int32 i=0;
i<aAnies.getLength(); ++
i )
624 aAnies[i] >>= pOutLabels[i];
628sal_Int32 lcl_getMaxSequenceLength(
631 sal_Int32 nResult = 0;
632 for(
const auto& rDataSequence : rContainer )
634 if( rDataSequence.second.is())
636 sal_Int32 nSeqLength = rDataSequence.second->getData().getLength();
637 if( nSeqLength > nResult )
638 nResult = nSeqLength;
644uno::Sequence< OUString > lcl_DataSequenceToStringSequence(
645 const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
647 uno::Sequence< OUString > aResult;
648 if(!xDataSequence.is())
651 uno::Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY );
652 if( xTextualDataSequence.is() )
654 aResult = xTextualDataSequence->getTextualData();
658 uno::Sequence< uno::Any > aValues = xDataSequence->getData();
659 aResult.realloc(aValues.getLength());
660 auto pResult = aResult.getArray();
662 for(sal_Int32 nN=aValues.getLength();nN--;)
663 aValues[nN] >>= pResult[nN];
670 ::std::vector< double > aResult;
674 uno::Sequence< double > aValuesSequence;
675 Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY );
678 aValuesSequence = xNumSeq->getNumericalData();
682 Sequence< uno::Any > aAnies( xSeq->getData() );
683 aValuesSequence.realloc( aAnies.getLength() );
684 auto pValuesSequence = aValuesSequence.getArray();
685 for( sal_Int32 i=0;
i<aAnies.getLength(); ++
i )
686 aAnies[i] >>= pValuesSequence[i];
690 Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY );
694 xProp->getPropertyValue(
"Role") >>= aRole;
695 if( aRole.match(
"values-x") )
698 bool bHasValue = std::any_of(std::cbegin(aValuesSequence), std::cend(aValuesSequence),
699 [](
double fValue) {
return !std::isnan( fValue ); });
704 const uno::Sequence< OUString > aStrings( lcl_DataSequenceToStringSequence( xSeq ) );
705 bool bHasText = std::any_of(aStrings.begin(), aStrings.end(),
706 [](
const OUString& rString) { return !rString.isEmpty(); });
709 auto [
begin,
end] = asNonConstRange(aValuesSequence);
710 std::iota(begin, end, 1);
716 aResult.insert( aResult.end(), std::cbegin(aValuesSequence), std::cend(aValuesSequence) );
720bool lcl_SequenceHasUnhiddenData(
const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
722 if( !xDataSequence.is() )
724 uno::Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY );
727 uno::Sequence< sal_Int32 > aHiddenValues;
730 xProp->getPropertyValue(
"HiddenValues") >>= aHiddenValues;
731 if( !aHiddenValues.hasElements() )
734 catch(
const uno::Exception& )
739 return xDataSequence->getData().hasElements();
742typedef vector< OUString > tStringVector;
743typedef vector< vector< double > > t2DNumberContainer;
747 t2DNumberContainer aDataInRows;
748 tStringVector aDataRangeRepresentations;
750 tStringVector aColumnDescriptions;
751 tStringVector aColumnDescriptions_Ranges;
753 tStringVector aRowDescriptions;
754 tStringVector aRowDescriptions_Ranges;
756 Sequence< Sequence< uno::Any > > aComplexColumnDescriptions;
757 Sequence< Sequence< uno::Any > > aComplexRowDescriptions;
759 ::std::vector< sal_Int32 > aHiddenColumns;
762typedef ::std::map< sal_Int32, SchXMLExportHelper_Impl::tLabelValuesDataPair >
765struct lcl_SequenceToMapElement
767 std::pair<const sal_Int32, SchXMLExportHelper_Impl::tLabelValuesDataPair>
771 if( rContent.second.is())
773 OUString aRangeRep( rContent.second->getSourceRangeRepresentation());
774 nIndex = aRangeRep.toInt32();
776 else if( rContent.first.is())
777 nIndex =
o3tl::toInt32(rContent.first->getSourceRangeRepresentation().subView(
sizeof(
"label ")));
778 return std::make_pair(nIndex, rContent);
782void lcl_ReorderInternalSequencesAccordingToTheirRangeName(
785 lcl_DataSequenceMap aIndexSequenceMap;
786 ::std::transform( rInOutSequences.begin(), rInOutSequences.end(),
787 ::std::inserter( aIndexSequenceMap, aIndexSequenceMap.begin()),
788 lcl_SequenceToMapElement());
790 rInOutSequences.clear();
792 for(
const auto& rEntry : aIndexSequenceMap )
794 if( rEntry.first >= 0 )
797 rInOutSequences.insert(
798 rInOutSequences.end(),
799 rEntry.first - nIndex,
800 SchXMLExportHelper_Impl::tDataSequenceCont::value_type(
801 uno::Reference< chart2::data::XDataSequence >(),
802 uno::Reference< chart2::data::XDataSequence >() ));
804 rInOutSequences.push_back( rEntry.second );
811lcl_TableData lcl_getDataForLocalTable(
813 const Reference< chart2::XAnyDescriptionAccess >& xAnyDescriptionAccess,
814 const OUString& rCategoriesRange,
815 bool bSeriesFromColumns,
816 const Reference< chart2::data::XRangeXMLConversion > & xRangeConversion )
818 lcl_TableData aResult;
822 Sequence< OUString > aSimpleCategories;
823 if( xAnyDescriptionAccess.is() )
826 if( bSeriesFromColumns )
828 aSimpleCategories = xAnyDescriptionAccess->getRowDescriptions();
829 aResult.aComplexRowDescriptions = xAnyDescriptionAccess->getAnyRowDescriptions();
833 aSimpleCategories = xAnyDescriptionAccess->getColumnDescriptions();
834 aResult.aComplexColumnDescriptions = xAnyDescriptionAccess->getAnyColumnDescriptions();
839 SchXMLExportHelper_Impl::tDataSequenceCont::size_type nNumSequences = aSequencesToExport.size();
841 auto nMaxSequenceLength( lcl_getMaxSequenceLength( aSequencesToExport ));
842 if( aSimpleCategories.getLength() > nMaxSequenceLength )
844 aSimpleCategories.realloc(nMaxSequenceLength);
846 size_t nNumColumns( bSeriesFromColumns ? nNumSequences : nMaxSequenceLength );
847 size_t nNumRows( bSeriesFromColumns ? nMaxSequenceLength : nNumSequences );
850 aResult.aDataInRows.resize( nNumRows );
852 for (
auto& aData: aResult.aDataInRows)
853 aData.resize(nNumColumns, std::numeric_limits<double>::quiet_NaN());
854 aResult.aColumnDescriptions.resize( nNumColumns );
855 aResult.aComplexColumnDescriptions.realloc( nNumColumns );
856 aResult.aRowDescriptions.resize( nNumRows );
857 aResult.aComplexRowDescriptions.realloc( nNumRows );
859 tStringVector& rCategories = bSeriesFromColumns ? aResult.aRowDescriptions : aResult.aColumnDescriptions;
860 tStringVector& rLabels = bSeriesFromColumns ? aResult.aColumnDescriptions : aResult.aRowDescriptions;
864 rCategories.insert( rCategories.begin(), std::cbegin(aSimpleCategories), std::cend(aSimpleCategories) );
865 if( !rCategoriesRange.isEmpty() )
867 OUString aRange(rCategoriesRange);
868 if( xRangeConversion.is())
869 aRange = xRangeConversion->convertRangeToXML( aRange );
870 if( bSeriesFromColumns )
871 aResult.aRowDescriptions_Ranges.push_back( aRange );
873 aResult.aColumnDescriptions_Ranges.push_back( aRange );
878 Sequence< Sequence< OUString > > aComplexLabels(nNumSequences);
879 auto aComplexLabelsRange = asNonConstRange(aComplexLabels);
880 for(
const auto& rDataSequence : aSequencesToExport )
883 Sequence< OUString >& rCurrentComplexLabel = aComplexLabelsRange[nSeqIdx];
884 if( rDataSequence.first.is())
886 lcl_getLabelStringSequence( rCurrentComplexLabel, rDataSequence.first );
887 rLabels[nSeqIdx] = lcl_flattenStringSequence( rCurrentComplexLabel );
888 aRange = rDataSequence.first->getSourceRangeRepresentation();
889 if( xRangeConversion.is())
890 aRange = xRangeConversion->convertRangeToXML( aRange );
892 else if( rDataSequence.second.is())
894 rCurrentComplexLabel.realloc(1);
895 rLabels[nSeqIdx] = rCurrentComplexLabel.getArray()[0] = lcl_flattenStringSequence(
896 rDataSequence.second->generateLabel( chart2::data::LabelOrigin_SHORT_SIDE ));
898 if( bSeriesFromColumns )
899 aResult.aColumnDescriptions_Ranges.push_back( aRange );
901 aResult.aRowDescriptions_Ranges.push_back( aRange );
904 if( bSeriesFromColumns )
906 const sal_Int32 nSize(
static_cast< sal_Int32
>( aNumbers.size()));
907 for( sal_Int32 nIdx=0; nIdx<nSize; ++nIdx )
908 aResult.aDataInRows[nIdx][nSeqIdx] = aNumbers[nIdx];
911 aResult.aDataInRows[nSeqIdx] = aNumbers;
913 if( rDataSequence.second.is())
915 aRange = rDataSequence.second->getSourceRangeRepresentation();
916 if( xRangeConversion.is())
917 aRange = xRangeConversion->convertRangeToXML( aRange );
919 aResult.aDataRangeRepresentations.push_back( aRange );
922 if( !lcl_SequenceHasUnhiddenData(rDataSequence.first) && !lcl_SequenceHasUnhiddenData(rDataSequence.second) )
923 aResult.aHiddenColumns.push_back(nSeqIdx);
927 Sequence< Sequence< Any > >& rComplexAnyLabels = bSeriesFromColumns ? aResult.aComplexColumnDescriptions : aResult.aComplexRowDescriptions;
928 rComplexAnyLabels.realloc(aComplexLabels.getLength());
929 auto pComplexAnyLabels = rComplexAnyLabels.getArray();
930 for( sal_Int32 nN=0; nN<aComplexLabels.getLength();nN++ )
932 Sequence< OUString >& rSource = aComplexLabelsRange[nN];
933 Sequence< Any >&
rTarget = pComplexAnyLabels[nN];
934 rTarget.realloc( rSource.getLength() );
935 auto pTarget =
rTarget.getArray();
936 for( sal_Int32 i=0;
i<rSource.getLength();
i++ )
937 pTarget[i] <<= rSource[i];
940 catch(
const uno::Exception & )
948void lcl_exportNumberFormat(
const OUString& rPropertyName,
const Reference< beans::XPropertySet >& xPropSet,
953 sal_Int32 nNumberFormat = 0;
954 Any aNumAny = xPropSet->getPropertyValue( rPropertyName );
955 if( (aNumAny >>= nNumberFormat) && (nNumberFormat != -1) )
960::std::vector< Reference< chart2::data::XDataSequence > >
961 lcl_getErrorBarSequences(
const Reference< beans::XPropertySet > & xErrorBarProp )
963 ::std::vector< Reference< chart2::data::XDataSequence > > aResult;
964 Reference< chart2::data::XDataSource > xErrorBarDataSource( xErrorBarProp, uno::UNO_QUERY );
965 if( !xErrorBarDataSource.is())
968 const Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
969 xErrorBarDataSource->getDataSequences());
970 for(
const auto& rSequence : aSequences )
976 Reference< chart2::data::XDataSequence > xSequence( rSequence->getValues());
977 Reference< beans::XPropertySet > xSeqProp( xSequence, uno::UNO_QUERY_THROW );
979 if( ( xSeqProp->getPropertyValue(
"Role" ) >>= aRole ) &&
980 aRole.match(
"error-bars-" ))
982 aResult.push_back( xSequence );
986 catch(
const uno::Exception & )
995bool lcl_exportDomainForThisSequence(
const Reference< chart2::data::XDataSequence >& rValues, OUString& rFirstRangeForThisDomainIndex,
SvXMLExport& rExport )
997 bool bDomainExported =
false;
1000 Reference< chart2::XChartDocument > xNewDoc( rExport.
GetModel(), uno::UNO_QUERY );
1001 OUString aRange( lcl_ConvertRange( rValues->getSourceRangeRepresentation(), xNewDoc ) );
1004 if( rFirstRangeForThisDomainIndex.isEmpty() || aRange != rFirstRangeForThisDomainIndex )
1008 bDomainExported =
true;
1011 if( rFirstRangeForThisDomainIndex.isEmpty() )
1012 rFirstRangeForThisDomainIndex = aRange;
1014 return bDomainExported;
1036 m_pImpl->maSrcShellID = rShellID;
1041 m_pImpl->maDestShellID = rShellID;
1072 mrExport( rExport ),
1073 mrAutoStylePool( rASPool ),
1076 mbHasCategoryLabels( false ),
1077 mbRowSourceColumns( true ),
1113 bool bIncludeTable )
1121 OUStringBuffer
aBuf;
1122 bool bHasPredecessor =
false;
1123 for( sal_Int32
nIndex : rSequenceMapping )
1125 if( bRemoveOneFromEachIndex )
1132 bHasPredecessor =
true;
1135 return aBuf.makeStringAndClear();
1140 bool bExportContent,
1141 bool bIncludeTable )
1143 Reference< chart2::XChartDocument > xNewDoc( rChartDoc, uno::UNO_QUERY );
1144 if( !rChartDoc.is() || !xNewDoc.is() )
1146 SAL_WARN(
"xmloff.chart",
"No XChartDocument was given for export." );
1155 if( bExportContent )
1157 Reference< chart::XDiagram > xDiagram = rChartDoc->getDiagram();
1158 Reference< chart2::XDiagram > xNewDiagram;
1160 xNewDiagram.set( xNewDoc->getFirstDiagram());
1163 if( bExportContent )
1165 Reference< util::XRefreshable > xRefreshable( xNewDoc, uno::UNO_QUERY );
1166 if( xRefreshable.is() )
1167 xRefreshable->refresh();
1171 bool bHasMainTitle =
false;
1172 bool bHasSubTitle =
false;
1173 bool bHasLegend =
false;
1174 util::DateTime aNullDate(0,0,0,0,30,12,1899,
false);
1176 std::vector< XMLPropertyState > aPropertyStates;
1178 Reference< beans::XPropertySet > xDocPropSet( rChartDoc, uno::UNO_QUERY );
1179 if( xDocPropSet.is())
1183 Any aAny = xDocPropSet->getPropertyValue(
"HasMainTitle");
1184 aAny >>= bHasMainTitle;
1185 aAny = xDocPropSet->getPropertyValue(
"HasSubTitle");
1186 aAny >>= bHasSubTitle;
1187 aAny = xDocPropSet->getPropertyValue(
"HasLegend");
1188 aAny >>= bHasLegend;
1189 if ( bIncludeTable )
1191 aAny = xDocPropSet->getPropertyValue(
"NullDate");
1192 if ( !aAny.hasValue() )
1194 Reference<container::XChild> xChild(rChartDoc, uno::UNO_QUERY );
1197 Reference< beans::XPropertySet > xParentDoc( xChild->getParent(),uno::UNO_QUERY);
1198 if ( xParentDoc.is() && xParentDoc->getPropertySetInfo()->hasPropertyByName(
"NullDate") )
1199 aAny = xParentDoc->getPropertyValue(
"NullDate");
1206 catch(
const beans::UnknownPropertyException & )
1208 SAL_WARN(
"xmloff.chart",
"Required property not found in ChartDocument" );
1212 if ( bIncludeTable && (aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 ) )
1216 OUStringBuffer sBuffer;
1224 std::unique_ptr<SvXMLElementExport> xElChart;
1229 Reference< beans::XPropertySet > xPropSet = rChartDoc->getArea();
1234 if( bExportContent )
1240 OUString aDataProviderURL(
".." );
1241 if( xNewDoc->hasInternalDataProvider() )
1242 aDataProviderURL =
".";
1245 Reference< chart2::data::XDatabaseDataProvider > xDBDataProvider( xNewDoc->getDataProvider(), uno::UNO_QUERY );
1246 if( xDBDataProvider.is() )
1247 aDataProviderURL =
".";
1253 Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(xNewDoc->getDataProvider(), uno::UNO_QUERY);
1256 OUString sPivotTableName = xPivotTableDataProvider->getPivotTableName();
1260 OUString sChartType( xDiagram->getDiagramType() );
1264 if( !sChartType.isEmpty())
1297 aSequenceMappingStr );
1311 aPropertyStates.clear();
1319 Reference< beans::XPropertySet > xPropSet( rChartDoc->getTitle(), uno::UNO_QUERY );
1323 if( bExportContent )
1325 Reference< drawing::XShape > xShape = rChartDoc->getTitle();
1336 Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
1339 Any aAny( xPropSet->getPropertyValue(
"String" ));
1350 aPropertyStates.clear();
1359 Reference< beans::XPropertySet > xPropSet( rChartDoc->getSubTitle(), uno::UNO_QUERY );
1364 if( bExportContent )
1366 Reference< drawing::XShape > xShape = rChartDoc->getSubTitle();
1377 Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
1380 Any aAny( xPropSet->getPropertyValue(
"String" ));
1391 aPropertyStates.clear();
1400 Reference< beans::XPropertySet > xPropSet( rChartDoc->getLegend(), uno::UNO_QUERY );
1405 if( bExportContent )
1407 Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY );
1413 Any aAny( xProp->getPropertyValue(
"Alignment"));
1417 catch(
const beans::UnknownPropertyException & )
1419 SAL_WARN(
"xmloff.chart",
"Property Align not found in ChartLegend" );
1427 Any aAny( xProp->getPropertyValue(
"Overlay"));
1428 if(aAny.get<
bool>())
1432 catch(
const beans::UnknownPropertyException & )
1434 SAL_WARN(
"xmloff.chart",
"Property Overlay not found in ChartLegend" );
1438 Reference< drawing::XShape > xLegendShape( xProp, uno::UNO_QUERY );
1446 chart::ChartLegendExpansion nLegendExpansion = chart::ChartLegendExpansion_HIGH;
1447 OUString aExpansionString;
1448 Any aAny( xProp->getPropertyValue(
"Expansion"));
1449 bool bHasExpansion = (aAny >>= nLegendExpansion);
1453 if( nLegendExpansion == chart::ChartLegendExpansion_CUSTOM)
1455 awt::Size aSize( xLegendShape->getSize() );
1465 OUStringBuffer aAspectRatioString;
1470 :
double(aSize.Width)/
double(aSize.Height)));
1475 catch(
const beans::UnknownPropertyException & )
1477 SAL_WARN(
"xmloff.chart",
"Property Expansion not found in ChartLegend" );
1493 aPropertyStates.clear();
1499 auto xDataTable = xNewDiagram->getDataTable();
1501 if (xDataTable.is())
1506 uno::Reference<beans::XPropertySet> xPropSet(xDataTable, uno::UNO_QUERY);
1524 aPropertyStates.clear();
1529 exportPlotArea( xDiagram, xNewDiagram, aPageSize, bExportContent, bIncludeTable );
1532 if( xDocPropSet.is() )
1534 if( bExportContent )
1543 Reference< drawing::XShape > xShape;
1545 for( sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++ )
1548 SAL_WARN_IF( !xShape.is(),
"xmloff.chart",
"Shape without an XShape?" );
1552 rShapeExport->exportShape( xShape );
1563 Any aShapesAny = xDocPropSet->getPropertyValue(
"AdditionalShapes");
1566 catch(
const uno::Exception & )
1577 Reference< drawing::XDrawPageSupplier > xSupplier( rChartDoc, uno::UNO_QUERY );
1578 SAL_WARN_IF( !xSupplier.is(),
"xmloff.chart",
"Cannot retrieve draw page to initialize shape export" );
1579 if( xSupplier.is() )
1581 Reference< drawing::XShapes > xDrawPage = xSupplier->getDrawPage();
1582 SAL_WARN_IF( !xDrawPage.is(),
"xmloff.chart",
"Invalid draw page for initializing shape export" );
1592 Reference< drawing::XShape > xShape;
1594 for( sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++ )
1597 SAL_WARN_IF( !xShape.is(),
"xmloff.chart",
"Shape without an XShape?" );
1601 rShapeExport->collectShapeAutoStyles( xShape );
1609 if( bExportContent )
1618 sal_Int32
nLength = rComplexLabel.getLength();
1622 for(
const auto& rElem : rComplexLabel)
1626 if( !(rElem >>= aString) )
1631 aString = OUString::number(aNum);
1645 bool bProtected =
false;
1646 Reference< beans::XPropertySet > xProps(
mrExport.
GetModel(), uno::UNO_QUERY_THROW );
1647 if ( ( xProps->getPropertyValue(
"DisableDataTableDialog") >>= bProtected ) &&
1653 catch (
const uno::Exception& )
1659 bool bHasOwnData =
false;
1660 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
1661 Reference< chart2::data::XRangeXMLConversion > xRangeConversion;
1664 bHasOwnData = xNewDoc->hasInternalDataProvider();
1665 xRangeConversion.set( xNewDoc->getDataProvider(), uno::UNO_QUERY );
1668 Reference< chart2::XAnyDescriptionAccess > xAnyDescriptionAccess;
1670 Reference< chart::XChartDocument > xChartDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
1671 if( xChartDoc.is() )
1672 xAnyDescriptionAccess.set( xChartDoc->getData(), uno::UNO_QUERY );
1681 tStringVector::const_iterator aDataRangeIter(
aData.aDataRangeRepresentations.begin());
1682 const tStringVector::const_iterator aDataRangeEndIter(
aData.aDataRangeRepresentations.end());
1684 tStringVector::const_iterator aRowDescriptions_RangeIter(
aData.aRowDescriptions_Ranges.begin());
1685 const tStringVector::const_iterator aRowDescriptions_RangeEnd(
aData.aRowDescriptions_Ranges.end());
1695 sal_Int32 nNextIndex = 0;
1696 for(sal_Int32 nHiddenIndex :
aData.aHiddenColumns)
1699 if( nHiddenIndex > nNextIndex )
1701 sal_Int64 nRepeat =
static_cast< sal_Int64
>( nHiddenIndex - nNextIndex );
1704 OUString::number( nRepeat ));
1709 nNextIndex = nHiddenIndex+1;
1712 sal_Int32 nEndIndex =
aData.aColumnDescriptions.size()-1;
1713 if( nEndIndex >= nNextIndex )
1715 sal_Int64 nRepeat =
static_cast< sal_Int64
>( nEndIndex - nNextIndex + 1 );
1718 OUString::number( nRepeat ));
1736 tStringVector::const_iterator aColumnDescriptions_RangeIter(
aData.aColumnDescriptions_Ranges.begin());
1737 const tStringVector::const_iterator aColumnDescriptions_RangeEnd(
aData.aColumnDescriptions_Ranges.end());
1738 const Sequence< Sequence< uno::Any > >& rComplexColumnDescriptions =
aData.aComplexColumnDescriptions;
1739 sal_Int32 nComplexCount = rComplexColumnDescriptions.getLength();
1741 for(
const auto& rDesc :
aData.aColumnDescriptions )
1743 bool bExportString =
true;
1744 if( nC < nComplexCount )
1746 const Sequence< uno::Any >& rComplexLabel = rComplexColumnDescriptions[nC];
1747 if( rComplexLabel.hasElements() )
1750 if( rComplexLabel[0] >>=fValue )
1752 bExportString =
false;
1769 if( nC < nComplexCount )
1771 if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd )
1774 if (!(*aColumnDescriptions_RangeIter).isEmpty())
1776 ++aColumnDescriptions_RangeIter;
1781 SAL_WARN_IF( !bHasOwnData && (aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd),
"xmloff.chart",
"bHasOwnData == false && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd" );
1787 tStringVector::const_iterator aRowDescriptionsIter(
aData.aRowDescriptions.begin());
1788 const Sequence< Sequence< uno::Any > >& rComplexRowDescriptions =
aData.aComplexRowDescriptions;
1789 sal_Int32 nComplexCount = rComplexRowDescriptions.getLength();
1792 for(
const auto& rRow :
aData.aDataInRows )
1798 bool bExportString =
true;
1799 if( nC < nComplexCount )
1801 const Sequence< uno::Any >& rComplexLabel = rComplexRowDescriptions[nC];
1802 if( rComplexLabel.hasElements() )
1805 if( rComplexLabel[0] >>=fValue )
1807 bExportString =
false;
1822 if( aRowDescriptionsIter !=
aData.aRowDescriptions.end())
1825 if( nC < nComplexCount )
1827 if( !bHasOwnData && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd )
1831 ++aRowDescriptions_RangeIter;
1833 ++aRowDescriptionsIter;
1838 for( t2DNumberContainer::value_type::const_iterator aColIt( rRow.begin());
1839 aColIt != rRow.end(); ++aColIt )
1847 if( ( !bHasOwnData && aDataRangeIter != aDataRangeEndIter ) &&
1851 if (!(*aDataRangeIter).isEmpty())
1862 SAL_WARN_IF( !bHasOwnData && (aDataRangeIter != aDataRangeEndIter),
"xmloff.chart",
"bHasOwnData == false && aDataRangeIter != aDataRangeEndIter" );
1863 SAL_WARN_IF( !bHasOwnData && (aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd),
"xmloff.chart",
"bHasOwnData == false && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd" );
1869Reference< chart2::XCoordinateSystem > lcl_getCooSys(
const Reference< chart2::XDiagram > & xNewDiagram )
1871 Reference< chart2::XCoordinateSystem > xCooSys;
1872 Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDiagram, uno::UNO_QUERY );
1875 Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
1876 if(aCooSysSeq.hasElements())
1877 xCooSys = aCooSysSeq[0];
1882Reference< chart2::XAxis > lcl_getAxis(
const Reference< chart2::XCoordinateSystem >& xCooSys,
1885 Reference< chart2::XAxis > xNewAxis;
1890 sal_Int32 nDimensionIndex=0;
1891 switch( eDimension )
1906 xNewAxis = xCooSys->getAxisByDimension( nDimensionIndex, bPrimary ? 0 : 1 );
1909 catch(
const uno::Exception & )
1918 const Reference< chart::XDiagram >& xDiagram,
1919 const Reference< chart2::XDiagram >& xNewDiagram,
1920 const awt::Size & rPageSize,
1921 bool bExportContent,
1922 bool bIncludeTable )
1924 SAL_WARN_IF( !xDiagram.is(),
"xmloff.chart",
"Invalid XDiagram as parameter" );
1925 if( ! xDiagram.is())
1929 Reference< beans::XPropertySet > xPropSet;
1930 std::vector< XMLPropertyState > aPropertyStates;
1936 std::unique_ptr<SvXMLElementExport> xElPlotArea;
1938 xPropSet.set( xDiagram, uno::UNO_QUERY );
1944 if( bExportContent )
1953 if( !bIncludeTable )
1956 Reference< chart::XChartDocument > xDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
1959 Reference< beans::XPropertySet > xDocProp( xDoc, uno::UNO_QUERY );
1966 bool bFirstCol =
false, bFirstRow =
false;
1968 aAny = xDocProp->getPropertyValue(
"DataSourceLabelsInFirstColumn" );
1970 aAny = xDocProp->getPropertyValue(
"DataSourceLabelsInFirstRow" );
1973 if( bFirstCol || bFirstRow )
1984 catch(
const beans::UnknownPropertyException & )
1986 SAL_WARN(
"xmloff.chart",
"Properties missing" );
1999 bool bIs3DChart =
false;
2008 aAny = xPropSet->getPropertyValue(
"Dim3D");
2009 aAny >>= bIs3DChart;
2014 if( rShapeExport.is())
2015 rShapeExport->export3DSceneAttributes( xPropSet );
2018 catch(
const uno::Exception & )
2033 rShapeExport->export3DLamps( xPropSet );
2040 aPropertyStates.clear();
2043 exportAxes( xDiagram, xNewDiagram, bExportContent );
2046 Reference< chart2::XAxis > xSecondYAxis = lcl_getAxis( lcl_getCooSys( xNewDiagram ),
XML_Y,
false );
2047 exportSeries( xNewDiagram, rPageSize, bExportContent, xSecondYAxis.is() );
2050 OUString sChartType ( xDiagram->getDiagramType());
2051 if( sChartType ==
"com.sun.star.chart.StockDiagram" )
2053 Reference< chart::XStatisticDisplay > xStockPropProvider( xDiagram, uno::UNO_QUERY );
2054 if( xStockPropProvider.is())
2057 Reference< beans::XPropertySet > xStockPropSet = xStockPropProvider->getUpBar();
2058 if( xStockPropSet.is())
2060 aPropertyStates.clear();
2063 if( !aPropertyStates.empty() )
2065 if( bExportContent )
2079 xStockPropSet = xStockPropProvider->getDownBar();
2080 if( xStockPropSet.is())
2082 aPropertyStates.clear();
2085 if( !aPropertyStates.empty() )
2087 if( bExportContent )
2101 xStockPropSet = xStockPropProvider->getMinMaxLine();
2102 if( xStockPropSet.is())
2104 aPropertyStates.clear();
2107 if( !aPropertyStates.empty() )
2109 if( bExportContent )
2125 Reference< chart::X3DDisplay > xWallFloorSupplier( xDiagram, uno::UNO_QUERY );
2127 xWallFloorSupplier.is()))
2131 aPropertyStates.clear();
2133 Reference< beans::XPropertySet > xWallPropSet = xWallFloorSupplier->getWall();
2134 if( xWallPropSet.is())
2138 if( !aPropertyStates.empty() )
2141 if( bExportContent )
2157 aPropertyStates.clear();
2159 Reference< beans::XPropertySet > xFloorPropSet = xWallFloorSupplier->getFloor();
2160 if( !xFloorPropSet.is())
2165 if( aPropertyStates.empty() )
2169 if( bExportContent )
2189 Reference< chart::XDiagramPositioning > xDiaPos( xDiagram, uno::UNO_QUERY );
2190 SAL_WARN_IF( !xDiaPos.is(),
"xmloff.chart",
"Invalid xDiaPos as parameter" );
2194 awt::Rectangle aRect( xDiaPos->calculateDiagramPositionExcludingAxes() );
2196 addSize( awt::Size(aRect.Width,aRect.Height) );
2206 XMLTokenEnum lcl_getTimeUnitToken( sal_Int32 nTimeUnit )
2211 case css::chart::TimeUnit::YEAR:
2214 case css::chart::TimeUnit::MONTH:
2226 if( !rAxisProps.is() )
2229 chart::TimeIncrement aIncrement;
2230 if( !(rAxisProps->getPropertyValue(
"TimeIncrement") >>= aIncrement) )
2233 sal_Int32 nTimeResolution = css::chart::TimeUnit::DAY;
2234 if( aIncrement.TimeResolution >>= nTimeResolution )
2237 chart::TimeInterval aInterval;
2238 if( aIncrement.MajorTimeInterval >>= aInterval )
2243 if( aIncrement.MinorTimeInterval >>= aInterval )
2254 if( !rTitleProps.is() )
2257 if( bExportContent )
2260 Any aAny( rTitleProps->getPropertyValue(
"String" ));
2263 Reference< drawing::XShape > xShape( rTitleProps, uno::UNO_QUERY );
2277 aPropertyStates.clear();
2282 if( !rGridProperties.is() )
2285 if( bExportContent )
2295 aPropertyStates.clear();
2302bool lcl_exportAxisType(
const Reference< chart2::XAxis >& rChart2Axis,
SvXMLExport& rExport)
2304 bool bExportDateScale =
false;
2305 if( !rChart2Axis.is() )
2306 return bExportDateScale;
2311 return bExportDateScale;
2313 chart2::ScaleData aScale( rChart2Axis->getScaleData() );
2317 switch(aScale.AxisType)
2319 case chart2::AxisType::CATEGORY:
2320 if( aScale.AutoDateAxis )
2323 bExportDateScale =
true;
2328 case chart2::AxisType::DATE:
2330 bExportDateScale =
true;
2337 return bExportDateScale;
2340void disableLinkedNumberFormat(
2345 if (rState.mnIndex < 0 || rMapper->GetEntryCount() <= rState.mnIndex)
2348 OUString aXMLName = rMapper->GetEntryXMLName(rState.mnIndex);
2350 if (aXMLName !=
"link-data-style-to-source")
2354 rState.maValue <<=
false;
2361 aState.maValue <<=
false;
2362 rPropStates.push_back(aState);
2370 const Reference< beans::XPropertySet >& rAxisProps,
2371 const Reference< chart2::XAxis >& rChart2Axis,
2372 const OUString& rCategoriesRange,
2373 bool bHasTitle,
bool bHasMajorGrid,
bool bHasMinorGrid,
2374 bool bExportContent, std::u16string_view sChartType )
2376 std::vector< XMLPropertyState > aPropertyStates;
2377 std::unique_ptr<SvXMLElementExport> pAxis;
2385 && eDimension ==
XML_X)
2387 chart2::ScaleData aScaleData(rChart2Axis->getScaleData());
2388 bool bShiftedCatPos = aScaleData.ShiftedCategoryPosition;
2389 if (sChartType ==
u"com.sun.star.chart.BarDiagram" || sChartType ==
u"com.sun.star.chart.StockDiagram")
2391 if (!bShiftedCatPos)
2392 rAxisProps->setPropertyValue(
"MajorOrigin",
uno::Any(0.0));
2394 else if (bShiftedCatPos)
2395 rAxisProps->setPropertyValue(
"MajorOrigin",
uno::Any(0.5));
2398 lcl_exportNumberFormat(
"NumberFormat", rAxisProps,
mrExport );
2406 disableLinkedNumberFormat(aPropertyStates,
mxExpPropMapper->getPropertySetMapper());
2410 bool bExportDateScale =
false;
2411 if( bExportContent )
2416 if( !rCategoriesRange.isEmpty() )
2417 bExportDateScale = lcl_exportAxisType( rChart2Axis,
mrExport );
2426 aPropertyStates.clear();
2429 if( bExportDateScale )
2432 Reference< beans::XPropertySet > xTitleProps;
2433 Reference< beans::XPropertySet > xMajorGridProps;
2434 Reference< beans::XPropertySet > xMinorGridProps;
2435 Reference< chart::XAxis > xAxis( rAxisProps, uno::UNO_QUERY );
2438 xTitleProps = bHasTitle ? xAxis->getAxisTitle() :
nullptr;
2439 xMajorGridProps = bHasMajorGrid ? xAxis->getMajorGrid() :
nullptr;
2440 xMinorGridProps = bHasMinorGrid ? xAxis->getMinorGrid() :
nullptr;
2447 if( bExportContent && !rCategoriesRange.isEmpty() )
2454 exportGrid( xMajorGridProps,
true, bExportContent );
2455 exportGrid( xMinorGridProps,
false, bExportContent );
2459 const Reference< chart::XDiagram > & xDiagram,
2460 const Reference< chart2::XDiagram > & xNewDiagram,
2461 bool bExportContent )
2463 SAL_WARN_IF( !xDiagram.is(),
"xmloff.chart",
"Invalid XDiagram as parameter" );
2464 if( ! xDiagram.is())
2468 bool bHasXAxis =
false,
2471 bHasSecondaryXAxis =
false,
2472 bHasSecondaryYAxis =
false;
2473 bool bHasXAxisTitle =
false,
2474 bHasYAxisTitle =
false,
2475 bHasZAxisTitle =
false,
2476 bHasSecondaryXAxisTitle =
false,
2477 bHasSecondaryYAxisTitle =
false;
2478 bool bHasXAxisMajorGrid =
false,
2479 bHasXAxisMinorGrid =
false,
2480 bHasYAxisMajorGrid =
false,
2481 bHasYAxisMinorGrid =
false,
2482 bHasZAxisMajorGrid =
false,
2483 bHasZAxisMinorGrid =
false;
2488 aDiagramProperties.
Add (
"HasXAxis", bHasXAxis);
2489 aDiagramProperties.
Add (
"HasYAxis", bHasYAxis);
2490 aDiagramProperties.
Add (
"HasZAxis", bHasZAxis);
2491 aDiagramProperties.
Add (
"HasSecondaryXAxis", bHasSecondaryXAxis);
2492 aDiagramProperties.
Add (
"HasSecondaryYAxis", bHasSecondaryYAxis);
2494 aDiagramProperties.
Add (
"HasXAxisTitle", bHasXAxisTitle);
2495 aDiagramProperties.
Add (
"HasYAxisTitle", bHasYAxisTitle);
2496 aDiagramProperties.
Add (
"HasZAxisTitle", bHasZAxisTitle);
2497 aDiagramProperties.
Add (
"HasSecondaryXAxisTitle", bHasSecondaryXAxisTitle);
2498 aDiagramProperties.
Add (
"HasSecondaryYAxisTitle", bHasSecondaryYAxisTitle);
2500 aDiagramProperties.
Add (
"HasXAxisGrid", bHasXAxisMajorGrid);
2501 aDiagramProperties.
Add (
"HasYAxisGrid", bHasYAxisMajorGrid);
2502 aDiagramProperties.
Add (
"HasZAxisGrid", bHasZAxisMajorGrid);
2504 aDiagramProperties.
Add (
"HasXAxisHelpGrid", bHasXAxisMinorGrid);
2505 aDiagramProperties.
Add (
"HasYAxisHelpGrid", bHasYAxisMinorGrid);
2506 aDiagramProperties.
Add (
"HasZAxisHelpGrid", bHasZAxisMinorGrid);
2510 SAL_INFO(
"xmloff.chart",
"Required properties not found in Chart diagram");
2513 Reference< chart2::XCoordinateSystem > xCooSys( lcl_getCooSys(xNewDiagram) );
2517 OUString aCategoriesRange;
2518 Reference< chart::XAxisSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY );
2519 OUString sChartType = xDiagram->getDiagramType();
2523 Reference< css::chart2::XAxis > xNewAxis = lcl_getAxis( xCooSys,
XML_X );
2526 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(0) :
nullptr, uno::UNO_QUERY );
2529 Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) );
2530 if( xCategories.is() )
2532 Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() );
2535 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
2541 exportAxis(
XML_X,
XML_PRIMARY_X, xAxisProps, xNewAxis, aCategoriesRange, bHasXAxisTitle, bHasXAxisMajorGrid, bHasXAxisMinorGrid, bExportContent, sChartType );
2542 aCategoriesRange.clear();
2547 xNewAxis = lcl_getAxis( xCooSys,
XML_X,
false );
2550 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(0) :
nullptr, uno::UNO_QUERY );
2556 xNewAxis = lcl_getAxis( xCooSys,
XML_Y );
2559 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(1) :
nullptr, uno::UNO_QUERY );
2560 exportAxis(
XML_Y,
XML_PRIMARY_Y, xAxisProps, xNewAxis, aCategoriesRange, bHasYAxisTitle, bHasYAxisMajorGrid, bHasYAxisMinorGrid, bExportContent, sChartType );
2565 xNewAxis = lcl_getAxis( xCooSys,
XML_Y,
false );
2568 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(1) :
nullptr, uno::UNO_QUERY );
2574 xNewAxis = lcl_getAxis( xCooSys,
XML_Z );
2577 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(2) :
nullptr, uno::UNO_QUERY );
2578 exportAxis(
XML_Z,
XML_PRIMARY_Z, xAxisProps, xNewAxis, aCategoriesRange, bHasZAxisTitle, bHasZAxisMajorGrid, bHasZAxisMinorGrid, bExportContent, sChartType );
2584 bool lcl_hasNoValuesButText(
const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
2586 if( !xDataSequence.is() )
2589 Sequence< uno::Any >
aData;
2590 Reference< chart2::data::XNumericalDataSequence > xNumericalDataSequence( xDataSequence, uno::UNO_QUERY );
2591 if( xNumericalDataSequence.is() )
2593 const Sequence< double > aDoubles( xNumericalDataSequence->getNumericalData() );
2594 if (std::any_of(aDoubles.begin(), aDoubles.end(), [](
double fDouble) { return !std::isnan( fDouble ); }))
2599 aData = xDataSequence->getData();
2600 double fDouble = 0.0;
2601 bool bHaveDouble = std::any_of(std::cbegin(aData), std::cend(aData),
2602 [&fDouble](
const uno::Any& rData) {
return (rData >>= fDouble) && !std::isnan( fDouble ); });
2608 Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY );
2609 if( xTextualDataSequence.is() )
2611 const uno::Sequence< OUString > aStrings( xTextualDataSequence->getTextualData() );
2612 if (std::any_of(aStrings.begin(), aStrings.end(), [](
const OUString& rString) { return !rString.isEmpty(); }))
2617 if( !
aData.hasElements() )
2618 aData = xDataSequence->getData();
2620 bool bHaveText = std::any_of(std::cbegin(aData), std::cend(aData),
2621 [&aString](
const uno::Any& rData) {
return (rData >>= aString) && !aString.isEmpty(); });
2632void lcl_createDataLabelProperties(
2633 std::vector<XMLPropertyState>& rDataLabelPropertyStates,
2634 const Reference<beans::XPropertySet>& xPropSet,
2637 if (!xExpPropMapper.is() || !xPropSet.is())
2640 const uno::Reference<beans::XPropertySetInfo> xInfo(xPropSet->getPropertySetInfo());
2641 const uno::Reference<beans::XPropertyState> xPropState(xPropSet, uno::UNO_QUERY);
2643 xExpPropMapper->getPropertySetMapper());
2644 if (!xInfo.is() || !xPropState.is() || !rPropertySetMapper.is())
2647 struct API2ODFMapItem
2650 sal_uInt16 nNameSpace;
2651 OUString sLocalName;
2652 API2ODFMapItem(OUString sAPI,
const sal_uInt16 nNS, OUString sLocal)
2653 : sAPIName(
std::move(sAPI))
2655 , sLocalName(
std::move(sLocal))
2660 const API2ODFMapItem aLabelFoo2ODFArray[]
2671 for (
const auto& rIt : aLabelFoo2ODFArray)
2673 if (!xInfo->hasPropertyByName(rIt.sAPIName)
2674 || xPropState->getPropertyState(rIt.sAPIName) != beans::PropertyState_DIRECT_VALUE)
2676 sal_Int32 nTargetIndex
2677 = rPropertySetMapper->GetEntryIndex(rIt.nNameSpace, rIt.sLocalName, 0);
2678 if (nTargetIndex < 0)
2681 xPropSet->getPropertyValue(rIt.sAPIName));
2682 rDataLabelPropertyStates.emplace_back(aDataLabelStateItem);
2688 const Reference< chart2::XDiagram > & xNewDiagram,
2689 const awt::Size & rPageSize,
2690 bool bExportContent,
2693 Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xNewDiagram, uno::UNO_QUERY );
2694 if( ! xBCooSysCnt.is())
2696 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
2698 OUString aFirstXDomainRange;
2699 OUString aFirstYDomainRange;
2701 std::vector< XMLPropertyState > aPropertyStates;
2702 std::vector< XMLPropertyState > aDataLabelPropertyStates;
2704 const Sequence< Reference< chart2::XCoordinateSystem > >
2705 aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
2706 for(
const auto& rCooSys : aCooSysSeq )
2708 Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY );
2711 const Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
2712 for(
const auto& rChartType : aCTSeq )
2714 Reference< chart2::XDataSeriesContainer > xDSCnt( rChartType, uno::UNO_QUERY );
2718 OUString aChartType( rChartType->getChartType());
2719 OUString aLabelRole = rChartType->getRoleOfSequenceForSeriesLabel();
2722 if ( aChartType ==
"com.sun.star.chart2.CandleStickChartType" )
2724 bool bJapaneseCandleSticks =
false;
2725 Reference< beans::XPropertySet > xCTProp( rChartType, uno::UNO_QUERY );
2727 xCTProp->getPropertyValue(
"Japanese") >>= bJapaneseCandleSticks;
2729 xDSCnt->getDataSeries(), xNewDiagram, bJapaneseCandleSticks, bExportContent );
2734 Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
2735 for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
2738 Reference< chart2::data::XDataSource > xSource( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY );
2741 std::unique_ptr<SvXMLElementExport> pSeries;
2742 Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
2743 xSource->getDataSequences());
2744 sal_Int32 nMainSequenceIndex = -1;
2745 sal_Int32 nSeriesLength = 0;
2746 bool bHasMeanValueLine =
false;
2747 Reference< beans::XPropertySet > xPropSet;
2752 Reference< chart2::data::XDataSequence > xValuesSeq;
2753 Reference< chart2::data::XDataSequence > xLabelSeq;
2754 sal_Int32 nSeqIdx=0;
2755 for( ; nSeqIdx<aSeqCnt.getLength(); ++nSeqIdx )
2757 Reference< chart2::data::XDataSequence > xTempValueSeq( aSeqCnt[nSeqIdx]->getValues() );
2758 if( nMainSequenceIndex==-1 )
2761 Reference< beans::XPropertySet > xSeqProp( xTempValueSeq, uno::UNO_QUERY );
2763 xSeqProp->getPropertyValue(
"Role") >>= aRole;
2765 if( aRole == aLabelRole )
2767 xValuesSeq.set( xTempValueSeq );
2768 xLabelSeq.set( aSeqCnt[nSeqIdx]->getLabel());
2769 nMainSequenceIndex = nSeqIdx;
2772 sal_Int32 nSequenceLength = (xTempValueSeq.is()? xTempValueSeq->getData().getLength() : sal_Int32(0));
2773 if( nSeriesLength < nSequenceLength )
2774 nSeriesLength = nSequenceLength;
2780 sal_Int32 nAttachedAxis = chart::ChartAxisAssign::PRIMARY_Y;
2787 catch(
const uno::Exception & )
2797 Any aAny( xPropSet->getPropertyValue(
"Axis" ));
2798 aAny >>= nAttachedAxis;
2800 aAny = xPropSet->getPropertyValue(
"MeanValue" );
2801 aAny >>= bHasMeanValueLine;
2803 catch(
const beans::UnknownPropertyException & )
2812 lcl_exportNumberFormat(
"NumberFormat", xPropSet,
mrExport );
2813 lcl_exportNumberFormat(
"PercentageNumberFormat", xPropSet,
mrExport );
2820 if( bExportContent )
2824 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
2833 if( xValuesSeq.is())
2836 xValuesSeq->getSourceRangeRepresentation(),
2848 Any aAny = xPropSet->getPropertyValue(
"ShowLegendEntry");
2849 if (!aAny.get<
bool>())
2859 bool bHasString =
false;
2860 uno::Reference<beans::XPropertySet> xLSProp(xLabelSeq, uno::UNO_QUERY);
2865 xLSProp->getPropertyValue(
"HasStringLabel") >>= bHasString;
2867 catch (
const beans::UnknownPropertyException&) {}
2870 OUString aRange = xLabelSeq->getSourceRangeRepresentation();
2882 xLabelSeq->getSourceRangeRepresentation(), xNewDoc));
2886 if( xLabelSeq.is() || xValuesSeq.is() )
2905 aPropertyStates.clear();
2913 if( bExportContent )
2915 bool bIsScatterChart = aChartType ==
"com.sun.star.chart2.ScatterChartType";
2916 bool bIsBubbleChart = aChartType ==
"com.sun.star.chart2.BubbleChartType";
2917 Reference< chart2::data::XDataSequence > xYValuesForBubbleChart;
2918 if( bIsBubbleChart )
2920 Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt,
"values-y" ) );
2921 if( xSequence.is() )
2923 xYValuesForBubbleChart = xSequence->getValues();
2924 if( !lcl_exportDomainForThisSequence( xYValuesForBubbleChart, aFirstYDomainRange,
mrExport ) )
2925 xYValuesForBubbleChart =
nullptr;
2928 if( bIsScatterChart || bIsBubbleChart )
2930 Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt,
"values-x" ) );
2931 if( xSequence.is() )
2933 Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
2934 if( lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange,
mrExport ) )
2936 uno::Reference< chart2::data::XDataSequence >(), xValues );
2938 else if( nSeriesIdx==0 )
2941 Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) );
2942 if( xCategories.is() )
2944 Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() );
2945 if( !lcl_hasNoValuesButText( xValues ) )
2946 lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange,
mrExport );
2950 if( xYValuesForBubbleChart.is() )
2952 uno::Reference< chart2::data::XDataSequence >(), xYValuesForBubbleChart );
2958 if( bExportContent &&
2959 (aSeriesLabelValuesPair.first.is() || aSeriesLabelValuesPair.second.is()))
2964 if( bHasMeanValueLine &&
2968 Reference< beans::XPropertySet > xStatProp;
2971 Any aPropAny( xPropSet->getPropertyValue(
"DataMeanValueProperties" ));
2972 aPropAny >>= xStatProp;
2974 catch(
const uno::Exception & )
2976 TOOLS_INFO_EXCEPTION(
"xmloff.chart",
"Exception caught during Export of series - optional DataMeanValueProperties not available" );
2979 if( xStatProp.is() )
2983 if( !aPropertyStates.empty() )
2986 if( bExportContent )
3001 if( xPropSet.is() &&
3011 uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ),
3012 nSeriesLength, xNewDiagram, bExportContent );
3023 lcl_createDataLabelProperties(aDataLabelPropertyStates, xPropSet,
3029 if (!aDataLabelPropertyStates.empty())
3042 if (!aDataLabelPropertyStates.empty())
3045 aDataLabelPropertyStates.clear();
3049 Sequence< OUString > aSupportedMappings = rChartType->getSupportedPropertyRoles();
3057 aPropertyStates.clear();
3058 aDataLabelPropertyStates.clear();
3064 const Reference< chart2::data::XDataSource > & xSource,
const Sequence< OUString >& rSupportedMappings )
3066 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
3067 Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
3068 xSource->getDataSequences());
3070 for(
const auto& rSupportedMapping : rSupportedMappings)
3072 Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, rSupportedMapping ) );
3075 Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
3081 xValues->getSourceRangeRepresentation(),
3087 uno::Reference< chart2::data::XDataSequence >(), xValues );
3094 const Reference< chart2::XDataSeries >& xSeries,
3095 const awt::Size& rPageSize,
3096 bool bExportContent )
3100 Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeries, uno::UNO_QUERY );
3101 if( !xRegressionCurveContainer.is() )
3104 const Sequence< Reference< chart2::XRegressionCurve > > aRegCurveSeq = xRegressionCurveContainer->getRegressionCurves();
3106 for(
const auto& xRegCurve : aRegCurveSeq )
3108 std::vector< XMLPropertyState > aEquationPropertyStates;
3109 if (!xRegCurve.is())
3112 Reference< beans::XPropertySet > xProperties( xRegCurve , uno::UNO_QUERY );
3113 if( !xProperties.is() )
3116 Reference< lang::XServiceName > xServiceName( xProperties, uno::UNO_QUERY );
3117 if( !xServiceName.is() )
3120 bool bShowEquation =
false;
3121 bool bShowRSquared =
false;
3122 bool bExportEquation =
false;
3124 OUString aService = xServiceName->getServiceName();
3131 aPropertyStates.push_back(
property);
3133 Reference< beans::XPropertySet > xEquationProperties;
3134 xEquationProperties.set( xRegCurve->getEquationProperties() );
3135 if( xEquationProperties.is())
3137 xEquationProperties->getPropertyValue(
"ShowEquation") >>= bShowEquation;
3138 xEquationProperties->getPropertyValue(
"ShowCorrelationCoefficient") >>= bShowRSquared;
3140 bExportEquation = ( bShowEquation || bShowRSquared );
3145 bExportEquation=
false;
3147 if( bExportEquation )
3150 sal_Int32 nNumberFormat = 0;
3151 if( (xEquationProperties->getPropertyValue(
"NumberFormat") >>= nNumberFormat ) &&
3152 nNumberFormat != -1 )
3160 if( !aPropertyStates.empty() || bExportEquation )
3163 if( bExportContent )
3166 if( !aPropertyStates.empty())
3172 if( bExportEquation )
3178 chart2::RelativePosition aRelativePosition;
3179 if( xEquationProperties->getPropertyValue(
"RelativePosition" ) >>= aRelativePosition )
3181 double fX = aRelativePosition.Primary * rPageSize.Width;
3182 double fY = aRelativePosition.Secondary * rPageSize.Height;
3184 aPos.X =
static_cast< sal_Int32
>( ::rtl::math::round( fX ));
3185 aPos.Y =
static_cast< sal_Int32
>( ::rtl::math::round( fY ));
3189 if( !aEquationPropertyStates.empty())
3199 if( !aPropertyStates.empty())
3203 if( bExportEquation && !aEquationPropertyStates.empty())
3213 bool bYError,
bool bExportContent )
3224 if (!xSeriesProp.is())
3227 bool bNegative =
false, bPositive =
false;
3228 sal_Int32 nErrorBarStyle = chart::ErrorBarStyle::NONE;
3229 Reference< beans::XPropertySet > xErrorBarProp;
3233 Any aAny = xSeriesProp->getPropertyValue( bYError ? OUString(
"ErrorBarY") : OUString(
"ErrorBarX") );
3234 aAny >>= xErrorBarProp;
3236 if ( xErrorBarProp.is() )
3238 aAny = xErrorBarProp->getPropertyValue(
"ShowNegativeError" );
3241 aAny = xErrorBarProp->getPropertyValue(
"ShowPositiveError" );
3244 aAny = xErrorBarProp->getPropertyValue(
"ErrorBarStyle" );
3245 aAny >>= nErrorBarStyle;
3248 catch(
const beans::UnknownPropertyException & )
3253 if( !(nErrorBarStyle != chart::ErrorBarStyle::NONE && (bNegative || bPositive)))
3256 if( bExportContent && nErrorBarStyle == chart::ErrorBarStyle::FROM_DATA )
3259 ::std::vector< Reference< chart2::data::XDataSequence > > aErrorBarSequences(
3260 lcl_getErrorBarSequences( xErrorBarProp ));
3261 for(
const auto& rErrorBarSequence : aErrorBarSequences )
3264 uno::Reference< chart2::data::XDataSequence >(), rErrorBarSequence );
3270 if( aPropertyStates.empty() )
3274 if( bExportContent )
3290 const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
3291 const Reference< chart2::XDiagram > & xDiagram,
3292 bool bJapaneseCandleSticks,
3293 bool bExportContent )
3296 for(
const auto& xSeries : aSeriesSeq )
3298 sal_Int32 nAttachedAxis = lcl_isSeriesAttachedToFirstAxis( xSeries )
3299 ? chart::ChartAxisAssign::PRIMARY_Y
3300 : chart::ChartAxisAssign::SECONDARY_Y;
3302 Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
3308 Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
3309 xSource->getDataSequences());
3311 sal_Int32 nSeriesLength =
3312 lcl_getSequenceLengthByRole( aSeqCnt,
"values-last");
3314 if( bExportContent )
3316 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
3321 if( bJapaneseCandleSticks )
3323 tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3325 if( !aRanges.second.isEmpty())
3327 if( !aRanges.first.isEmpty())
3329 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3340 tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3342 if( !aRanges.second.isEmpty())
3344 if( !aRanges.first.isEmpty())
3346 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3357 tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3359 if( !aRanges.second.isEmpty())
3361 if( !aRanges.first.isEmpty())
3363 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3374 tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3376 if( !aRanges.second.isEmpty())
3378 if( !aRanges.first.isEmpty())
3380 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3399 const uno::Reference< beans::XPropertySet > & xSeriesProperties,
3400 sal_Int32 nSeriesLength,
3401 const uno::Reference< chart2::XDiagram > & xDiagram,
3402 bool bExportContent )
3420 uno::Reference< chart2::XDataSeries > xSeries( xSeriesProperties, uno::UNO_QUERY );
3422 std::vector< XMLPropertyState > aPropertyStates;
3423 std::vector<XMLPropertyState> aDataLabelPropertyStates;
3425 bool bVaryColorsByPoint =
false;
3426 Sequence< sal_Int32 > aDataPointSeq;
3427 Sequence<sal_Int32> deletedLegendEntriesSeq;
3428 if( xSeriesProperties.is())
3430 xSeriesProperties->getPropertyValue(
"AttributedDataPoints") >>= aDataPointSeq;
3431 xSeriesProperties->getPropertyValue(
"VaryColorsByPoint") >>= bVaryColorsByPoint;
3436 xSeriesProperties->getPropertyValue(
"DeletedLegendEntries") >>= deletedLegendEntriesSeq;
3439 sal_Int32 nSize = aDataPointSeq.getLength();
3440 SAL_WARN_IF( nSize > nSeriesLength,
"xmloff.chart",
"Too many point attributes" );
3442 const sal_Int32 * pPoints = aDataPointSeq.getConstArray();
3444 Reference< chart2::XColorScheme > xColorScheme;
3446 xColorScheme.set( xDiagram->getDefaultColorScheme());
3448 ::std::vector< SchXMLDataPointStruct > aDataPointVector;
3450 sal_Int32 nLastIndex = -1;
3453 if( bVaryColorsByPoint && xColorScheme.is() )
3456 aAttrPointSet.
reserve(aDataPointSeq.getLength());
3457 for (
auto p = pPoints;
p < pPoints + aDataPointSeq.getLength(); ++
p)
3459 const auto aEndIt = aAttrPointSet.
end();
3460 for( nElement = 0; nElement < nSeriesLength; ++nElement )
3462 aPropertyStates.clear();
3463 aDataLabelPropertyStates.clear();
3464 uno::Reference< beans::XPropertySet > xPropSet;
3465 bool bExportNumFmt =
false;
3466 if( aAttrPointSet.
find( nElement ) != aEndIt )
3472 bExportNumFmt =
true;
3474 catch(
const uno::Exception & )
3482 xPropSet.set( new ::xmloff::chart::ColorPropertySet(
3485 SAL_WARN_IF( !xPropSet.is(),
"xmloff.chart",
"Pie Segments should have properties" );
3492 lcl_exportNumberFormat(
"NumberFormat", xPropSet,
mrExport );
3493 lcl_exportNumberFormat(
"PercentageNumberFormat", xPropSet,
mrExport );
3499 lcl_createDataLabelProperties(aDataLabelPropertyStates, xPropSet,
3505 sal_Int32 nPlacement = 0;
3506 xPropSet->getPropertyValue(
"LabelPlacement") >>= nPlacement;
3507 if (nPlacement == chart::DataLabelPlacement::CUSTOM)
3509 xPropSet->setPropertyValue(
"LabelPlacement",
3510 uno::Any(chart::DataLabelPlacement::OUTSIDE));
3515 if (!aPropertyStates.empty() || !aDataLabelPropertyStates.empty())
3520 SchXMLDataPointStruct aPoint;
3521 if (!aPropertyStates.empty())
3524 "Autostyle queue empty!");
3528 if (!aDataLabelPropertyStates.empty())
3531 "Autostyle queue empty!");
3536 aPoint.mCustomLabel = lcl_getCustomLabelField(
mrExport, nElement, xSeries);
3537 aPoint.mCustomLabelPos = lcl_getCustomLabelPosition(
mrExport, nElement, xSeries);
3539 aDataPointVector.push_back( aPoint );
3543 if (!aPropertyStates.empty())
3545 if (!aDataLabelPropertyStates.empty())
3551 SAL_WARN_IF( bExportContent && (
static_cast<sal_Int32
>(aDataPointVector.size()) != nSeriesLength),
"xmloff.chart",
"not enough data points on content export" );
3555 for( sal_Int32 nCurrIndex : std::as_const(aDataPointSeq) )
3557 aPropertyStates.clear();
3558 aDataLabelPropertyStates.clear();
3561 if( nCurrIndex<0 || nCurrIndex>=nSeriesLength )
3565 if( nCurrIndex - nLastIndex > 1 )
3567 SchXMLDataPointStruct aPoint;
3568 aPoint.mnRepeat = nCurrIndex - nLastIndex - 1;
3569 aDataPointVector.push_back( aPoint );
3572 uno::Reference< beans::XPropertySet > xPropSet;
3579 catch(
const uno::Exception & )
3589 lcl_exportNumberFormat(
"NumberFormat", xPropSet,
mrExport );
3590 lcl_exportNumberFormat(
"PercentageNumberFormat", xPropSet,
mrExport );
3596 lcl_createDataLabelProperties(aDataLabelPropertyStates, xPropSet,
3602 if (!aPropertyStates.empty() || !aDataLabelPropertyStates.empty())
3604 if( bExportContent )
3607 SchXMLDataPointStruct aPoint;
3608 if (!aPropertyStates.empty())
3611 "Autostyle queue empty!");
3615 aPoint.mCustomLabel = lcl_getCustomLabelField(
mrExport, nCurrIndex, xSeries);
3616 aPoint.mCustomLabelPos = lcl_getCustomLabelPosition(
mrExport, nCurrIndex, xSeries);
3617 if (!aDataLabelPropertyStates.empty())
3620 "Autostyle queue empty!");
3625 aDataPointVector.push_back( aPoint );
3626 nLastIndex = nCurrIndex;
3630 if (!aPropertyStates.empty())
3632 if (!aDataLabelPropertyStates.empty())
3640 SchXMLDataPointStruct aPoint;
3641 aDataPointVector.push_back( aPoint );
3643 nLastIndex = nCurrIndex;
3646 sal_Int32 nRepeat = nSeriesLength - nLastIndex - 1;
3649 SchXMLDataPointStruct aPoint;
3650 aPoint.mnRepeat = nRepeat;
3651 aDataPointVector.push_back( aPoint );
3655 if (!bExportContent)
3659 SchXMLDataPointStruct aPoint;
3660 SchXMLDataPointStruct aLastPoint;
3664 aLastPoint.mnRepeat = 0;
3666 for(
const auto& rPoint : aDataPointVector )
3670 if (aPoint.maStyleName == aLastPoint.maStyleName
3671 && aLastPoint.mCustomLabel.maFields.getLength() < 1
3672 && aLastPoint.mCustomLabelPos.Primary == 0.0
3673 && aLastPoint.mCustomLabelPos.Secondary == 0.0
3674 && aPoint.msDataLabelStyleName == aLastPoint.msDataLabelStyleName)
3675 aPoint.mnRepeat += aLastPoint.mnRepeat;
3676 else if( aLastPoint.mnRepeat > 0 )
3679 if( !aLastPoint.maStyleName.isEmpty() )
3682 if( aLastPoint.mnRepeat > 1 )
3684 OUString::number( aLastPoint.mnRepeat ));
3686 for (
const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
3688 if (
nIndex == deletedLegendEntry)
3699 aLastPoint = aPoint;
3702 if( aPoint.maStyleName != aLastPoint.maStyleName )
3705 if( !aLastPoint.maStyleName.isEmpty() )
3708 if( aLastPoint.mnRepeat > 1 )
3710 OUString::number( aLastPoint.mnRepeat ));
3712 for (
const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
3714 if (
nIndex == deletedLegendEntry)
3728 if (rPoint.mCustomLabel.maFields.getLength() < 1 && rPoint.msDataLabelStyleName.isEmpty())
3731 if (!rPoint.msDataLabelStyleName.isEmpty())
3734 if (rPoint.mCustomLabel.mbDataLabelsRange)
3743 for (
const Reference<chart2::XDataPointCustomLabelField>&
label : rPoint.mCustomLabel.maFields)
3753 if( xCustomLabelPosition.Primary == 0.0 && xCustomLabelPosition.Secondary == 0.0 )
3756 OUStringBuffer aCustomLabelPosString;
3804 awt::Size aSize( 8000, 7000 );
3805 uno::Reference< embed::XVisualObject > xVisualObject( xChartDoc, uno::UNO_QUERY );
3806 SAL_WARN_IF( !xVisualObject.is(),
"xmloff.chart",
"need XVisualObject for page size" );
3807 if( xVisualObject.is() )
3808 aSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
3815 if( !aStates.empty() )
3821 if( !aStates.empty() )
3856 Reference< chart2::XChartDocument > xChartDoc(
GetModel(), uno::UNO_QUERY );
3857 maExportHelper->m_pImpl->InitRangeSegmentationProperties( xChartDoc );
3864 SAL_INFO(
"xmloff.chart",
"Master Style Export requested. Not available for Chart" );
3877 Reference< chart::XChartDocument > xChartDoc(
GetModel(), uno::UNO_QUERY );
3884 SAL_WARN(
"xmloff.chart",
"Couldn't export chart due to wrong XModel (must be XChartDocument)" );
3896 Reference< chart::XChartDocument > xChartDoc(
GetModel(), uno::UNO_QUERY );
3903 SAL_WARN(
"xmloff.chart",
"Couldn't export chart due to wrong XModel (must be XChartDocument)" );
3910 Reference< chart::XChartDocument > xChartDoc(
GetModel(), uno::UNO_QUERY );
3914 bool bIncludeTable =
true;
3916 Reference< chart2::XChartDocument > xNewDoc( xChartDoc, uno::UNO_QUERY );
3922 Reference< lang::XServiceInfo > xDPServiceInfo( xNewDoc->getDataProvider(), uno::UNO_QUERY );
3923 if( ! (xDPServiceInfo.is() && xDPServiceInfo->getImplementationName() ==
"com.sun.star.comp.chart.InternalDataProvider" ))
3925 bIncludeTable =
false;
3930 Reference< lang::XServiceInfo > xServ( xChartDoc, uno::UNO_QUERY );
3933 if( xServ->supportsService(
"com.sun.star.chart.ChartTableAddressSupplier" ))
3935 Reference< beans::XPropertySet > xProp( xServ, uno::UNO_QUERY );
3941 OUString sChartAddress;
3942 aAny = xProp->getPropertyValue(
"ChartRangeAddress" );
3943 aAny >>= sChartAddress;
3947 bIncludeTable = sChartAddress.isEmpty();
3949 catch(
const beans::UnknownPropertyException & )
3951 SAL_WARN(
"xmloff.chart",
"Property ChartRangeAddress not supported by ChartDocument" );
3957 maExportHelper->m_pImpl->exportChart( xChartDoc, bIncludeTable );
3961 SAL_WARN(
"xmloff.chart",
"Couldn't export chart due to wrong XModel" );
3972 if( !xChartDoc.is())
3977 Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
3978 SAL_WARN_IF( !xDataProvider.is(),
"xmloff.chart",
"No DataProvider" );
3979 if( xDataProvider.is())
3981 Reference< chart2::data::XDataSource > xDataSource( lcl_pressUsedDataIntoRectangularFormat( xChartDoc,
mbHasCategoryLabels ));
3982 const Sequence< beans::PropertyValue > aArgs( xDataProvider->detectArguments( xDataSource ));
3983 OUString sCellRange, sBrokenRange;
3984 bool bBrokenRangeAvailable =
false;
3985 for(
const auto& rArg : aArgs )
3987 if ( rArg.Name ==
"CellRangeRepresentation" )
3988 rArg.Value >>= sCellRange;
3989 else if ( rArg.Name ==
"BrokenCellRangeForExport" )
3991 if( rArg.Value >>= sBrokenRange )
3992 bBrokenRangeAvailable =
true;
3994 else if ( rArg.Name ==
"DataRowSource" )
3996 chart::ChartDataRowSource eRowSource;
3997 rArg.Value >>= eRowSource;
4000 else if ( rArg.Name ==
"SequenceMapping" )
4007 msChartAddress = (bBrokenRangeAvailable ? sBrokenRange : sCellRange);
4011 Reference< chart2::data::XRangeXMLConversion > xConversion( xDataProvider, uno::UNO_QUERY );
4012 if( xConversion.is())
4017 catch(
const uno::Exception & )
4025extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4027 uno::Sequence<uno::Any>
const& )
4029 return cppu::acquire(
4037extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4039 uno::Sequence<uno::Any>
const& )
4041 return cppu::acquire(
4051extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4053 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4059extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4061 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4063 return cppu::acquire(
new SchXMLExport(pCtx,
"SchXMLExport.Oasis.Styles",
4067extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4069 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4071 return cppu::acquire(
new SchXMLExport(pCtx,
"SchXMLExport.Content",
4076extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4078 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4080 return cppu::acquire(
new SchXMLExport(pCtx,
"SchXMLExport.Oasis.Content",
4088extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4090 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4092 return cppu::acquire(
new SchXMLExport(pCtx,
"SchXMLExport.Oasis.Meta",
#define XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Chart_XMLStylesExporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Chart_XMLOasisContentExporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Chart_XMLContentExporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Chart_XMLOasisExporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Chart_XMLOasisMetaExporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
static void lcl_exportComplexLabel(const Sequence< uno::Any > &rComplexLabel, SvXMLExport &rExport)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Chart_XMLOasisStylesExporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Chart_XMLExporter_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
static OUString lcl_GetStringFromNumberSequence(const css::uno::Sequence< sal_Int32 > &rSequenceMapping, bool bRemoveOneFromEachIndex)
@descr This class lets you get the values from an object that either supports the interface XProperty...
void Add(const OUString &sName, T &rValue)
@descr Add a property to handle.
bool GetProperties()
@descr Try to get the values for all properties added with the Add method.
static XMLEnumPropertyHdl & getLegendPositionConverter()
static XMLEnumPropertyHdl & getLegendExpansionConverter()
void exportPropertyMapping(const css::uno::Reference< css::chart2::data::XDataSource > &xSource, const Sequence< OUString > &rSupportedMappings)
void exportCandleStickSeries(const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > > &aSeriesSeq, const css::uno::Reference< css::chart2::XDiagram > &xDiagram, bool bJapaneseCandleSticks, bool bExportContent)
void exportAxisTitle(const Reference< beans::XPropertySet > &rTitleProps, bool bExportContent)
void exportText(const OUString &rText)
exports a string as a paragraph element
void exportCustomLabelPosition(const chart2::RelativePosition &xCustomLabelPosition)
void exportChart(css::uno::Reference< css::chart::XChartDocument > const &rChartDoc, bool bIncludeTable)
export the <chart:chart> element corresponding to rChartDoc if bIncludeTable is true,...
void exportPlotArea(const css::uno::Reference< css::chart::XDiagram > &xDiagram, const css::uno::Reference< css::chart2::XDiagram > &xNewDiagram, const css::awt::Size &rPageSize, bool bExportContent, bool bIncludeTable)
OUStringBuffer msStringBuffer
void exportCustomLabel(const SchXMLDataPointStruct &rPoint)
void exportGrid(const Reference< beans::XPropertySet > &rGridProperties, bool bMajor, bool bExportContent)
SchXMLExportHelper_Impl(const SchXMLExportHelper_Impl &)=delete
::std::pair< css::uno::Reference< css::chart2::data::XDataSequence >, css::uno::Reference< css::chart2::data::XDataSequence > > tLabelValuesDataPair
void exportAutoStyles()
write the styles collected into the current pool as <style:style> elements
void exportAxes(const css::uno::Reference< css::chart::XDiagram > &xDiagram, const css::uno::Reference< css::chart2::XDiagram > &xNewDiagram, bool bExportContent)
SchXMLExportHelper_Impl & operator=(const SchXMLExportHelper_Impl &)=delete
tDataSequenceCont m_aDataSequencesToExport
static css::awt::Size getPageSize(const css::uno::Reference< css::chart2::XChartDocument > &xChartDoc)
::std::vector< tLabelValuesDataPair > tDataSequenceCont
void collectAutoStyles(css::uno::Reference< css::chart::XChartDocument > const &rChartDoc)
parse chart and collect all auto-styles used in current pool
void InitRangeSegmentationProperties(const css::uno::Reference< css::chart2::XChartDocument > &xChartDoc)
void CollectAutoStyle(std::vector< XMLPropertyState > &&aStates)
SvXMLAutoStylePoolP & mrAutoStylePool
::std::queue< OUString > maAutoStyleNameQueue
first parseDocument: collect autostyles and store names in this queue second parseDocument: export co...
void exportSeries(const css::uno::Reference< css::chart2::XDiagram > &xNewDiagram, const css::awt::Size &rPageSize, bool bExportContent, bool bHasTwoYAxes)
void AddAutoStyleAttribute(const std::vector< XMLPropertyState > &aStates)
const rtl::Reference< XMLPropertySetMapper > & GetPropertySetMapper() const
void addPosition(const css::uno::Reference< css::drawing::XShape > &xShape)
rtl::Reference< XMLChartExportPropertyMapper > mxExpPropMapper
void exportDataPoints(const css::uno::Reference< css::beans::XPropertySet > &xSeriesProperties, sal_Int32 nSeriesLength, const css::uno::Reference< css::chart2::XDiagram > &xDiagram, bool bExportContent)
void exportCoordinateRegion(const css::uno::Reference< css::chart::XDiagram > &xDiagram)
void exportAxis(enum XMLTokenEnum eDimension, enum XMLTokenEnum eAxisName, const Reference< beans::XPropertySet > &rAxisProps, const Reference< chart2::XAxis > &rChart2Axis, const OUString &rCategoriesRanges, bool bHasTitle, bool bHasMajorGrid, bool bHasMinorGrid, bool bExportContent, std::u16string_view sChartType)
OUString maCategoriesRange
void SetChartRangeAddress(const OUString &rAddress)
void addSize(const css::awt::Size &rSize, bool bIsOOoNamespace=false)
add svg size as attribute for current element
css::uno::Sequence< sal_Int32 > maSequenceMapping
void exportErrorBar(const css::uno::Reference< beans::XPropertySet > &xSeriesProp, bool bYError, bool bExportContent)
SchXMLExportHelper_Impl(SvXMLExport &rExport, SvXMLAutoStylePoolP &rASPool)
void addSize(const css::uno::Reference< css::drawing::XShape > &xShape)
void exportDateScale(const Reference< beans::XPropertySet > &rAxisProps)
void parseDocument(css::uno::Reference< css::chart::XChartDocument > const &rChartDoc, bool bExportContent, bool bIncludeTable=false)
if bExportContent is false the auto-styles are collected
void exportRegressionCurve(const css::uno::Reference< css::chart2::XDataSeries > &xSeries, const css::awt::Size &rPageSize, bool bExportContent)
static constexpr OUStringLiteral gsTableName
rtl::Reference< XMLPropertySetMapper > mxPropertySetMapper
css::uno::Reference< css::drawing::XShapes > mxAdditionalShapes
void addPosition(const css::awt::Point &rPosition)
add svg position as attribute for current element
With this class you can export a <chart:chart> element containing its data as <table:table> element o...
void SetDestinationShellID(const OUString &rShellID)
const OUString & getChartCLSID() const
returns the string corresponding to the current FileFormat CLSID for Chart
void SetSourceShellID(const OUString &rShellID)
std::unique_ptr< SchXMLExportHelper_Impl > m_pImpl
virtual ~SchXMLExportHelper() override
SchXMLExportHelper(SvXMLExport &rExport, SvXMLAutoStylePoolP &rASPool)
SchXMLExport(const css::uno::Reference< css::uno::XComponentContext > &xContext, OUString const &implementationName, SvXMLExportFlags nExportFlags)
virtual void ExportAutoStyles_() override
Override this method to export the contents of <style:auto-styles>.
virtual ~SchXMLExport() override
virtual void ExportContent_() override
Override this method to export the content of <office:body>.
virtual void ExportMasterStyles_() override
Override this method to export the contents of <style:master-styles>.
virtual ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass=::xmloff::token::XML_TOKEN_INVALID) override
rtl::Reference< SchXMLExportHelper > maExportHelper
void collectAutoStyles() override
rtl::Reference< XMLPropertySetMapper > const & GetPropertySetMapper() const
static css::uno::Reference< css::beans::XPropertySet > createOldAPIDataPointPropertySet(const css::uno::Reference< css::chart2::XDataSeries > &xSeries, sal_Int32 nPointIndex, const css::uno::Reference< css::frame::XModel > &xChartModel)
static ::std::vector< css::uno::Reference< css::chart2::XDataSeries > > getDataSeriesFromDiagram(const css::uno::Reference< css::chart2::XDiagram > &xDiagram)
static css::uno::Reference< css::beans::XPropertySet > createOldAPISeriesPropertySet(const css::uno::Reference< css::chart2::XDataSeries > &xSeries, const css::uno::Reference< css::frame::XModel > &xChartModel)
void AddFamily(XmlStyleFamily nFamily, const OUString &rStrName, SvXMLExportPropertyMapper *pMapper, const OUString &aStrPrefix)
register a new family with its appropriate instance of a derivation of XMLPropertySetMapper for famil...
OUString Add(XmlStyleFamily nFamily, ::std::vector< XMLPropertyState > &&rProperties)
Add an item set to the pool and return its generated name.
void exportXML(XmlStyleFamily nFamily) const
Export all item sets ofs a certain class in the order in that they have been added.
const SvXMLNamespaceMap & GetNamespaceMap() const
OUString const & GetDestinationShellID() const
OUString const & GetSourceShellID() const
virtual ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass=::xmloff::token::XML_TOKEN_INVALID)
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
bool mbAutoStylesCollected
SvXMLExportFlags getExportFlags() const
SvXMLNamespaceMap & GetNamespaceMap_()
const css::uno::Reference< css::frame::XModel > & GetModel() const
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
virtual void exportAutoDataStyles()
const css::uno::Reference< css::xml::sax::XDocumentHandler > & GetDocHandler() const
rtl::Reference< XMLShapeExport > const & GetShapeExport()
virtual void addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat=false)
virtual void collectAutoStyles()
const SvXMLUnitConverter & GetMM100UnitConverter() const
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
sal_uInt16 Add(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey=XML_NAMESPACE_UNKNOWN)
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
void reserve(size_type amount)
const_iterator find(const Value &x) const
const_iterator end() const
std::pair< const_iterator, bool > insert(Value &&x)
static void convertDateTime(OUStringBuffer &rBuffer, const css::util::DateTime &rDateTime, sal_Int16 const *pTimeZoneOffset, bool bAddTimeIf0AM=false)
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
#define TOOLS_INFO_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral XML_STYLE_FAMILY_SD_GRAPHICS_NAME
constexpr OUStringLiteral XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX
constexpr OUStringLiteral XML_STYLE_FAMILY_SCH_CHART_PREFIX
constexpr OUStringLiteral XML_STYLE_FAMILY_SCH_CHART_NAME
tools::SvRef< SvBaseLink > xSink
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral aData
XMLOFF_DLLPUBLIC void exportXML(OUString const &rStrName, css::uno::Any const &rValue, SvXMLExport &rExport)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Reference< XComponentContext > getProcessComponentContext()
constexpr OUStringLiteral implementationName
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
enumrange< T >::Iterator begin(enumrange< T >)
static ::std::vector< double > lcl_getAllValuesFromSequence(const Reference< chart2::data::XDataSequence > &xSeq)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
@ XML_MINOR_INTERVAL_VALUE
@ XML_MAJOR_INTERVAL_UNIT
@ XML_MAJOR_INTERVAL_VALUE
@ XML_DATA_SOURCE_HAS_LABELS
@ XML_LEGEND_EXPANSION_ASPECT_RATIO
@ XML_TABLE_HEADER_COLUMNS
@ XML_MINOR_INTERVAL_UNIT
@ XML_NUMBER_COLUMNS_REPEATED
@ XML_DATA_LABELS_CELL_RANGE
@ XML_CALCULATION_SETTINGS
@ XML_VALUES_CELL_RANGE_ADDRESS
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Smart struct to transport an Any with an index to the appropriate property-name.
constexpr sal_uInt16 XML_NAMESPACE_DRAW
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_SVG
constexpr sal_uInt16 XML_NAMESPACE_TEXT
constexpr sal_uInt16 XML_NAMESPACE_CHART_EXT
constexpr sal_uInt16 XML_NAMESPACE_CHART
constexpr sal_uInt16 XML_NAMESPACE_TABLE
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
constexpr sal_uInt16 XML_NAMESPACE_OOO
constexpr sal_uInt16 XML_NAMESPACE_STYLE