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" );
1593 Reference< drawing::XShape > xShape;
1595 for( sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++ )
1598 SAL_WARN_IF( !xShape.is(),
"xmloff.chart",
"Shape without an XShape?" );
1602 rShapeExport->collectShapeAutoStyles( xShape, aAutoStylePropNames );
1610 if( bExportContent )
1619 sal_Int32
nLength = rComplexLabel.getLength();
1623 for(
const auto& rElem : rComplexLabel)
1627 if( !(rElem >>= aString) )
1632 aString = OUString::number(aNum);
1646 bool bProtected =
false;
1647 Reference< beans::XPropertySet > xProps(
mrExport.
GetModel(), uno::UNO_QUERY_THROW );
1648 if ( ( xProps->getPropertyValue(
"DisableDataTableDialog") >>= bProtected ) &&
1654 catch (
const uno::Exception& )
1660 bool bHasOwnData =
false;
1661 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
1662 Reference< chart2::data::XRangeXMLConversion > xRangeConversion;
1665 bHasOwnData = xNewDoc->hasInternalDataProvider();
1666 xRangeConversion.set( xNewDoc->getDataProvider(), uno::UNO_QUERY );
1669 Reference< chart2::XAnyDescriptionAccess > xAnyDescriptionAccess;
1671 Reference< chart::XChartDocument > xChartDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
1672 if( xChartDoc.is() )
1673 xAnyDescriptionAccess.set( xChartDoc->getData(), uno::UNO_QUERY );
1682 tStringVector::const_iterator aDataRangeIter(
aData.aDataRangeRepresentations.begin());
1683 const tStringVector::const_iterator aDataRangeEndIter(
aData.aDataRangeRepresentations.end());
1685 tStringVector::const_iterator aRowDescriptions_RangeIter(
aData.aRowDescriptions_Ranges.begin());
1686 const tStringVector::const_iterator aRowDescriptions_RangeEnd(
aData.aRowDescriptions_Ranges.end());
1696 sal_Int32 nNextIndex = 0;
1697 for(sal_Int32 nHiddenIndex :
aData.aHiddenColumns)
1700 if( nHiddenIndex > nNextIndex )
1702 sal_Int64 nRepeat =
static_cast< sal_Int64
>( nHiddenIndex - nNextIndex );
1705 OUString::number( nRepeat ));
1710 nNextIndex = nHiddenIndex+1;
1713 sal_Int32 nEndIndex =
aData.aColumnDescriptions.size()-1;
1714 if( nEndIndex >= nNextIndex )
1716 sal_Int64 nRepeat =
static_cast< sal_Int64
>( nEndIndex - nNextIndex + 1 );
1719 OUString::number( nRepeat ));
1737 tStringVector::const_iterator aColumnDescriptions_RangeIter(
aData.aColumnDescriptions_Ranges.begin());
1738 const tStringVector::const_iterator aColumnDescriptions_RangeEnd(
aData.aColumnDescriptions_Ranges.end());
1739 const Sequence< Sequence< uno::Any > >& rComplexColumnDescriptions =
aData.aComplexColumnDescriptions;
1740 sal_Int32 nComplexCount = rComplexColumnDescriptions.getLength();
1742 for(
const auto& rDesc :
aData.aColumnDescriptions )
1744 bool bExportString =
true;
1745 if( nC < nComplexCount )
1747 const Sequence< uno::Any >& rComplexLabel = rComplexColumnDescriptions[nC];
1748 if( rComplexLabel.hasElements() )
1751 if( rComplexLabel[0] >>=fValue )
1753 bExportString =
false;
1770 if( nC < nComplexCount )
1772 if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd )
1775 if (!(*aColumnDescriptions_RangeIter).isEmpty())
1777 ++aColumnDescriptions_RangeIter;
1782 SAL_WARN_IF( !bHasOwnData && (aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd),
"xmloff.chart",
"bHasOwnData == false && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd" );
1788 tStringVector::const_iterator aRowDescriptionsIter(
aData.aRowDescriptions.begin());
1789 const Sequence< Sequence< uno::Any > >& rComplexRowDescriptions =
aData.aComplexRowDescriptions;
1790 sal_Int32 nComplexCount = rComplexRowDescriptions.getLength();
1793 for(
const auto& rRow :
aData.aDataInRows )
1799 bool bExportString =
true;
1800 if( nC < nComplexCount )
1802 const Sequence< uno::Any >& rComplexLabel = rComplexRowDescriptions[nC];
1803 if( rComplexLabel.hasElements() )
1806 if( rComplexLabel[0] >>=fValue )
1808 bExportString =
false;
1823 if( aRowDescriptionsIter !=
aData.aRowDescriptions.end())
1826 if( nC < nComplexCount )
1828 if( !bHasOwnData && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd )
1832 ++aRowDescriptions_RangeIter;
1834 ++aRowDescriptionsIter;
1839 for( t2DNumberContainer::value_type::const_iterator aColIt( rRow.begin());
1840 aColIt != rRow.end(); ++aColIt )
1848 if( ( !bHasOwnData && aDataRangeIter != aDataRangeEndIter ) &&
1852 if (!(*aDataRangeIter).isEmpty())
1863 SAL_WARN_IF( !bHasOwnData && (aDataRangeIter != aDataRangeEndIter),
"xmloff.chart",
"bHasOwnData == false && aDataRangeIter != aDataRangeEndIter" );
1864 SAL_WARN_IF( !bHasOwnData && (aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd),
"xmloff.chart",
"bHasOwnData == false && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd" );
1870Reference< chart2::XCoordinateSystem > lcl_getCooSys(
const Reference< chart2::XDiagram > & xNewDiagram )
1872 Reference< chart2::XCoordinateSystem > xCooSys;
1873 Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDiagram, uno::UNO_QUERY );
1876 Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
1877 if(aCooSysSeq.hasElements())
1878 xCooSys = aCooSysSeq[0];
1883Reference< chart2::XAxis > lcl_getAxis(
const Reference< chart2::XCoordinateSystem >& xCooSys,
1886 Reference< chart2::XAxis > xNewAxis;
1891 sal_Int32 nDimensionIndex=0;
1892 switch( eDimension )
1907 xNewAxis = xCooSys->getAxisByDimension( nDimensionIndex, bPrimary ? 0 : 1 );
1910 catch(
const uno::Exception & )
1919 const Reference< chart::XDiagram >& xDiagram,
1920 const Reference< chart2::XDiagram >& xNewDiagram,
1921 const awt::Size & rPageSize,
1922 bool bExportContent,
1923 bool bIncludeTable )
1925 SAL_WARN_IF( !xDiagram.is(),
"xmloff.chart",
"Invalid XDiagram as parameter" );
1926 if( ! xDiagram.is())
1930 Reference< beans::XPropertySet > xPropSet;
1931 std::vector< XMLPropertyState > aPropertyStates;
1937 std::unique_ptr<SvXMLElementExport> xElPlotArea;
1939 xPropSet.set( xDiagram, uno::UNO_QUERY );
1945 if( bExportContent )
1954 if( !bIncludeTable )
1957 Reference< chart::XChartDocument > xDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
1960 Reference< beans::XPropertySet > xDocProp( xDoc, uno::UNO_QUERY );
1967 bool bFirstCol =
false, bFirstRow =
false;
1969 aAny = xDocProp->getPropertyValue(
"DataSourceLabelsInFirstColumn" );
1971 aAny = xDocProp->getPropertyValue(
"DataSourceLabelsInFirstRow" );
1974 if( bFirstCol || bFirstRow )
1985 catch(
const beans::UnknownPropertyException & )
1987 SAL_WARN(
"xmloff.chart",
"Properties missing" );
2000 bool bIs3DChart =
false;
2009 aAny = xPropSet->getPropertyValue(
"Dim3D");
2010 aAny >>= bIs3DChart;
2015 if( rShapeExport.is())
2016 rShapeExport->export3DSceneAttributes( xPropSet );
2019 catch(
const uno::Exception & )
2034 rShapeExport->export3DLamps( xPropSet );
2041 aPropertyStates.clear();
2044 exportAxes( xDiagram, xNewDiagram, bExportContent );
2047 Reference< chart2::XAxis > xSecondYAxis = lcl_getAxis( lcl_getCooSys( xNewDiagram ),
XML_Y,
false );
2048 exportSeries( xNewDiagram, rPageSize, bExportContent, xSecondYAxis.is() );
2051 OUString sChartType ( xDiagram->getDiagramType());
2052 if( sChartType ==
"com.sun.star.chart.StockDiagram" )
2054 Reference< chart::XStatisticDisplay > xStockPropProvider( xDiagram, uno::UNO_QUERY );
2055 if( xStockPropProvider.is())
2058 Reference< beans::XPropertySet > xStockPropSet = xStockPropProvider->getUpBar();
2059 if( xStockPropSet.is())
2061 aPropertyStates.clear();
2064 if( !aPropertyStates.empty() )
2066 if( bExportContent )
2080 xStockPropSet = xStockPropProvider->getDownBar();
2081 if( xStockPropSet.is())
2083 aPropertyStates.clear();
2086 if( !aPropertyStates.empty() )
2088 if( bExportContent )
2102 xStockPropSet = xStockPropProvider->getMinMaxLine();
2103 if( xStockPropSet.is())
2105 aPropertyStates.clear();
2108 if( !aPropertyStates.empty() )
2110 if( bExportContent )
2126 Reference< chart::X3DDisplay > xWallFloorSupplier( xDiagram, uno::UNO_QUERY );
2128 xWallFloorSupplier.is()))
2132 aPropertyStates.clear();
2134 Reference< beans::XPropertySet > xWallPropSet = xWallFloorSupplier->getWall();
2135 if( xWallPropSet.is())
2139 if( !aPropertyStates.empty() )
2142 if( bExportContent )
2158 aPropertyStates.clear();
2160 Reference< beans::XPropertySet > xFloorPropSet = xWallFloorSupplier->getFloor();
2161 if( !xFloorPropSet.is())
2166 if( aPropertyStates.empty() )
2170 if( bExportContent )
2190 Reference< chart::XDiagramPositioning > xDiaPos( xDiagram, uno::UNO_QUERY );
2191 SAL_WARN_IF( !xDiaPos.is(),
"xmloff.chart",
"Invalid xDiaPos as parameter" );
2195 awt::Rectangle aRect( xDiaPos->calculateDiagramPositionExcludingAxes() );
2197 addSize( awt::Size(aRect.Width,aRect.Height) );
2207 XMLTokenEnum lcl_getTimeUnitToken( sal_Int32 nTimeUnit )
2212 case css::chart::TimeUnit::YEAR:
2215 case css::chart::TimeUnit::MONTH:
2227 if( !rAxisProps.is() )
2230 chart::TimeIncrement aIncrement;
2231 if( !(rAxisProps->getPropertyValue(
"TimeIncrement") >>= aIncrement) )
2234 sal_Int32 nTimeResolution = css::chart::TimeUnit::DAY;
2235 if( aIncrement.TimeResolution >>= nTimeResolution )
2238 chart::TimeInterval aInterval;
2239 if( aIncrement.MajorTimeInterval >>= aInterval )
2244 if( aIncrement.MinorTimeInterval >>= aInterval )
2255 if( !rTitleProps.is() )
2258 if( bExportContent )
2261 Any aAny( rTitleProps->getPropertyValue(
"String" ));
2264 Reference< drawing::XShape > xShape( rTitleProps, uno::UNO_QUERY );
2278 aPropertyStates.clear();
2283 if( !rGridProperties.is() )
2286 if( bExportContent )
2296 aPropertyStates.clear();
2303bool lcl_exportAxisType(
const Reference< chart2::XAxis >& rChart2Axis,
SvXMLExport& rExport)
2305 bool bExportDateScale =
false;
2306 if( !rChart2Axis.is() )
2307 return bExportDateScale;
2312 return bExportDateScale;
2314 chart2::ScaleData aScale( rChart2Axis->getScaleData() );
2318 switch(aScale.AxisType)
2320 case chart2::AxisType::CATEGORY:
2321 if( aScale.AutoDateAxis )
2324 bExportDateScale =
true;
2329 case chart2::AxisType::DATE:
2331 bExportDateScale =
true;
2338 return bExportDateScale;
2341void disableLinkedNumberFormat(
2346 if (rState.mnIndex < 0 || rMapper->GetEntryCount() <= rState.mnIndex)
2349 OUString aXMLName = rMapper->GetEntryXMLName(rState.mnIndex);
2351 if (aXMLName !=
"link-data-style-to-source")
2355 rState.maValue <<=
false;
2362 aState.maValue <<=
false;
2363 rPropStates.push_back(aState);
2371 const Reference< beans::XPropertySet >& rAxisProps,
2372 const Reference< chart2::XAxis >& rChart2Axis,
2373 const OUString& rCategoriesRange,
2374 bool bHasTitle,
bool bHasMajorGrid,
bool bHasMinorGrid,
2375 bool bExportContent, std::u16string_view sChartType )
2377 std::vector< XMLPropertyState > aPropertyStates;
2378 std::unique_ptr<SvXMLElementExport> pAxis;
2386 && eDimension ==
XML_X)
2388 chart2::ScaleData aScaleData(rChart2Axis->getScaleData());
2389 bool bShiftedCatPos = aScaleData.ShiftedCategoryPosition;
2390 if (sChartType ==
u"com.sun.star.chart.BarDiagram" || sChartType ==
u"com.sun.star.chart.StockDiagram")
2392 if (!bShiftedCatPos)
2393 rAxisProps->setPropertyValue(
"MajorOrigin",
uno::Any(0.0));
2395 else if (bShiftedCatPos)
2396 rAxisProps->setPropertyValue(
"MajorOrigin",
uno::Any(0.5));
2399 lcl_exportNumberFormat(
"NumberFormat", rAxisProps,
mrExport );
2407 disableLinkedNumberFormat(aPropertyStates,
mxExpPropMapper->getPropertySetMapper());
2411 bool bExportDateScale =
false;
2412 if( bExportContent )
2417 if( !rCategoriesRange.isEmpty() )
2418 bExportDateScale = lcl_exportAxisType( rChart2Axis,
mrExport );
2427 aPropertyStates.clear();
2430 if( bExportDateScale )
2433 Reference< beans::XPropertySet > xTitleProps;
2434 Reference< beans::XPropertySet > xMajorGridProps;
2435 Reference< beans::XPropertySet > xMinorGridProps;
2436 Reference< chart::XAxis > xAxis( rAxisProps, uno::UNO_QUERY );
2439 xTitleProps = bHasTitle ? xAxis->getAxisTitle() :
nullptr;
2440 xMajorGridProps = bHasMajorGrid ? xAxis->getMajorGrid() :
nullptr;
2441 xMinorGridProps = bHasMinorGrid ? xAxis->getMinorGrid() :
nullptr;
2448 if( bExportContent && !rCategoriesRange.isEmpty() )
2455 exportGrid( xMajorGridProps,
true, bExportContent );
2456 exportGrid( xMinorGridProps,
false, bExportContent );
2460 const Reference< chart::XDiagram > & xDiagram,
2461 const Reference< chart2::XDiagram > & xNewDiagram,
2462 bool bExportContent )
2464 SAL_WARN_IF( !xDiagram.is(),
"xmloff.chart",
"Invalid XDiagram as parameter" );
2465 if( ! xDiagram.is())
2469 bool bHasXAxis =
false,
2472 bHasSecondaryXAxis =
false,
2473 bHasSecondaryYAxis =
false;
2474 bool bHasXAxisTitle =
false,
2475 bHasYAxisTitle =
false,
2476 bHasZAxisTitle =
false,
2477 bHasSecondaryXAxisTitle =
false,
2478 bHasSecondaryYAxisTitle =
false;
2479 bool bHasXAxisMajorGrid =
false,
2480 bHasXAxisMinorGrid =
false,
2481 bHasYAxisMajorGrid =
false,
2482 bHasYAxisMinorGrid =
false,
2483 bHasZAxisMajorGrid =
false,
2484 bHasZAxisMinorGrid =
false;
2489 aDiagramProperties.
Add (
"HasXAxis", bHasXAxis);
2490 aDiagramProperties.
Add (
"HasYAxis", bHasYAxis);
2491 aDiagramProperties.
Add (
"HasZAxis", bHasZAxis);
2492 aDiagramProperties.
Add (
"HasSecondaryXAxis", bHasSecondaryXAxis);
2493 aDiagramProperties.
Add (
"HasSecondaryYAxis", bHasSecondaryYAxis);
2495 aDiagramProperties.
Add (
"HasXAxisTitle", bHasXAxisTitle);
2496 aDiagramProperties.
Add (
"HasYAxisTitle", bHasYAxisTitle);
2497 aDiagramProperties.
Add (
"HasZAxisTitle", bHasZAxisTitle);
2498 aDiagramProperties.
Add (
"HasSecondaryXAxisTitle", bHasSecondaryXAxisTitle);
2499 aDiagramProperties.
Add (
"HasSecondaryYAxisTitle", bHasSecondaryYAxisTitle);
2501 aDiagramProperties.
Add (
"HasXAxisGrid", bHasXAxisMajorGrid);
2502 aDiagramProperties.
Add (
"HasYAxisGrid", bHasYAxisMajorGrid);
2503 aDiagramProperties.
Add (
"HasZAxisGrid", bHasZAxisMajorGrid);
2505 aDiagramProperties.
Add (
"HasXAxisHelpGrid", bHasXAxisMinorGrid);
2506 aDiagramProperties.
Add (
"HasYAxisHelpGrid", bHasYAxisMinorGrid);
2507 aDiagramProperties.
Add (
"HasZAxisHelpGrid", bHasZAxisMinorGrid);
2511 SAL_INFO(
"xmloff.chart",
"Required properties not found in Chart diagram");
2514 Reference< chart2::XCoordinateSystem > xCooSys( lcl_getCooSys(xNewDiagram) );
2518 OUString aCategoriesRange;
2519 Reference< chart::XAxisSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY );
2520 OUString sChartType = xDiagram->getDiagramType();
2524 Reference< css::chart2::XAxis > xNewAxis = lcl_getAxis( xCooSys,
XML_X );
2527 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(0) :
nullptr, uno::UNO_QUERY );
2530 Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) );
2531 if( xCategories.is() )
2533 Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() );
2536 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
2542 exportAxis(
XML_X,
XML_PRIMARY_X, xAxisProps, xNewAxis, aCategoriesRange, bHasXAxisTitle, bHasXAxisMajorGrid, bHasXAxisMinorGrid, bExportContent, sChartType );
2543 aCategoriesRange.clear();
2548 xNewAxis = lcl_getAxis( xCooSys,
XML_X,
false );
2551 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(0) :
nullptr, uno::UNO_QUERY );
2557 xNewAxis = lcl_getAxis( xCooSys,
XML_Y );
2560 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(1) :
nullptr, uno::UNO_QUERY );
2561 exportAxis(
XML_Y,
XML_PRIMARY_Y, xAxisProps, xNewAxis, aCategoriesRange, bHasYAxisTitle, bHasYAxisMajorGrid, bHasYAxisMinorGrid, bExportContent, sChartType );
2566 xNewAxis = lcl_getAxis( xCooSys,
XML_Y,
false );
2569 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(1) :
nullptr, uno::UNO_QUERY );
2575 xNewAxis = lcl_getAxis( xCooSys,
XML_Z );
2578 Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(2) :
nullptr, uno::UNO_QUERY );
2579 exportAxis(
XML_Z,
XML_PRIMARY_Z, xAxisProps, xNewAxis, aCategoriesRange, bHasZAxisTitle, bHasZAxisMajorGrid, bHasZAxisMinorGrid, bExportContent, sChartType );
2585 bool lcl_hasNoValuesButText(
const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
2587 if( !xDataSequence.is() )
2590 Sequence< uno::Any >
aData;
2591 Reference< chart2::data::XNumericalDataSequence > xNumericalDataSequence( xDataSequence, uno::UNO_QUERY );
2592 if( xNumericalDataSequence.is() )
2594 const Sequence< double > aDoubles( xNumericalDataSequence->getNumericalData() );
2595 if (std::any_of(aDoubles.begin(), aDoubles.end(), [](
double fDouble) { return !std::isnan( fDouble ); }))
2600 aData = xDataSequence->getData();
2601 double fDouble = 0.0;
2602 bool bHaveDouble = std::any_of(std::cbegin(aData), std::cend(aData),
2603 [&fDouble](
const uno::Any& rData) {
return (rData >>= fDouble) && !std::isnan( fDouble ); });
2609 Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY );
2610 if( xTextualDataSequence.is() )
2612 const uno::Sequence< OUString > aStrings( xTextualDataSequence->getTextualData() );
2613 if (std::any_of(aStrings.begin(), aStrings.end(), [](
const OUString& rString) { return !rString.isEmpty(); }))
2618 if( !
aData.hasElements() )
2619 aData = xDataSequence->getData();
2621 bool bHaveText = std::any_of(std::cbegin(aData), std::cend(aData),
2622 [&aString](
const uno::Any& rData) {
return (rData >>= aString) && !aString.isEmpty(); });
2633void lcl_createDataLabelProperties(
2634 std::vector<XMLPropertyState>& rDataLabelPropertyStates,
2635 const Reference<beans::XPropertySet>& xPropSet,
2638 if (!xExpPropMapper.is() || !xPropSet.is())
2641 const uno::Reference<beans::XPropertySetInfo> xInfo(xPropSet->getPropertySetInfo());
2642 const uno::Reference<beans::XPropertyState> xPropState(xPropSet, uno::UNO_QUERY);
2644 xExpPropMapper->getPropertySetMapper());
2645 if (!xInfo.is() || !xPropState.is() || !rPropertySetMapper.is())
2648 struct API2ODFMapItem
2651 sal_uInt16 nNameSpace;
2652 OUString sLocalName;
2653 API2ODFMapItem(OUString sAPI,
const sal_uInt16 nNS, OUString sLocal)
2654 : sAPIName(
std::move(sAPI))
2656 , sLocalName(
std::move(sLocal))
2661 const API2ODFMapItem aLabelFoo2ODFArray[]
2672 for (
const auto& rIt : aLabelFoo2ODFArray)
2674 if (!xInfo->hasPropertyByName(rIt.sAPIName)
2675 || xPropState->getPropertyState(rIt.sAPIName) != beans::PropertyState_DIRECT_VALUE)
2677 sal_Int32 nTargetIndex
2678 = rPropertySetMapper->GetEntryIndex(rIt.nNameSpace, rIt.sLocalName, 0);
2679 if (nTargetIndex < 0)
2682 xPropSet->getPropertyValue(rIt.sAPIName));
2683 rDataLabelPropertyStates.emplace_back(aDataLabelStateItem);
2689 const Reference< chart2::XDiagram > & xNewDiagram,
2690 const awt::Size & rPageSize,
2691 bool bExportContent,
2694 Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xNewDiagram, uno::UNO_QUERY );
2695 if( ! xBCooSysCnt.is())
2697 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
2699 OUString aFirstXDomainRange;
2700 OUString aFirstYDomainRange;
2702 std::vector< XMLPropertyState > aPropertyStates;
2703 std::vector< XMLPropertyState > aDataLabelPropertyStates;
2705 const Sequence< Reference< chart2::XCoordinateSystem > >
2706 aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
2707 for(
const auto& rCooSys : aCooSysSeq )
2709 Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY );
2712 const Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
2713 for(
const auto& rChartType : aCTSeq )
2715 Reference< chart2::XDataSeriesContainer > xDSCnt( rChartType, uno::UNO_QUERY );
2719 OUString aChartType( rChartType->getChartType());
2720 OUString aLabelRole = rChartType->getRoleOfSequenceForSeriesLabel();
2723 if ( aChartType ==
"com.sun.star.chart2.CandleStickChartType" )
2725 bool bJapaneseCandleSticks =
false;
2726 Reference< beans::XPropertySet > xCTProp( rChartType, uno::UNO_QUERY );
2728 xCTProp->getPropertyValue(
"Japanese") >>= bJapaneseCandleSticks;
2730 xDSCnt->getDataSeries(), xNewDiagram, bJapaneseCandleSticks, bExportContent );
2735 Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
2736 for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
2739 Reference< chart2::data::XDataSource > xSource( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY );
2742 std::unique_ptr<SvXMLElementExport> pSeries;
2743 Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
2744 xSource->getDataSequences());
2745 sal_Int32 nMainSequenceIndex = -1;
2746 sal_Int32 nSeriesLength = 0;
2747 bool bHasMeanValueLine =
false;
2748 Reference< beans::XPropertySet > xPropSet;
2753 Reference< chart2::data::XDataSequence > xValuesSeq;
2754 Reference< chart2::data::XDataSequence > xLabelSeq;
2755 sal_Int32 nSeqIdx=0;
2756 for( ; nSeqIdx<aSeqCnt.getLength(); ++nSeqIdx )
2758 Reference< chart2::data::XDataSequence > xTempValueSeq( aSeqCnt[nSeqIdx]->getValues() );
2759 if( nMainSequenceIndex==-1 )
2762 Reference< beans::XPropertySet > xSeqProp( xTempValueSeq, uno::UNO_QUERY );
2764 xSeqProp->getPropertyValue(
"Role") >>= aRole;
2766 if( aRole == aLabelRole )
2768 xValuesSeq.set( xTempValueSeq );
2769 xLabelSeq.set( aSeqCnt[nSeqIdx]->getLabel());
2770 nMainSequenceIndex = nSeqIdx;
2773 sal_Int32 nSequenceLength = (xTempValueSeq.is()? xTempValueSeq->getData().getLength() : sal_Int32(0));
2774 if( nSeriesLength < nSequenceLength )
2775 nSeriesLength = nSequenceLength;
2781 sal_Int32 nAttachedAxis = chart::ChartAxisAssign::PRIMARY_Y;
2788 catch(
const uno::Exception & )
2798 Any aAny( xPropSet->getPropertyValue(
"Axis" ));
2799 aAny >>= nAttachedAxis;
2801 aAny = xPropSet->getPropertyValue(
"MeanValue" );
2802 aAny >>= bHasMeanValueLine;
2804 catch(
const beans::UnknownPropertyException & )
2813 lcl_exportNumberFormat(
"NumberFormat", xPropSet,
mrExport );
2814 lcl_exportNumberFormat(
"PercentageNumberFormat", xPropSet,
mrExport );
2821 if( bExportContent )
2825 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
2834 if( xValuesSeq.is())
2837 xValuesSeq->getSourceRangeRepresentation(),
2849 Any aAny = xPropSet->getPropertyValue(
"ShowLegendEntry");
2850 if (!aAny.get<
bool>())
2860 bool bHasString =
false;
2861 uno::Reference<beans::XPropertySet> xLSProp(xLabelSeq, uno::UNO_QUERY);
2866 xLSProp->getPropertyValue(
"HasStringLabel") >>= bHasString;
2868 catch (
const beans::UnknownPropertyException&) {}
2871 OUString aRange = xLabelSeq->getSourceRangeRepresentation();
2883 xLabelSeq->getSourceRangeRepresentation(), xNewDoc));
2887 if( xLabelSeq.is() || xValuesSeq.is() )
2906 aPropertyStates.clear();
2914 if( bExportContent )
2916 bool bIsScatterChart = aChartType ==
"com.sun.star.chart2.ScatterChartType";
2917 bool bIsBubbleChart = aChartType ==
"com.sun.star.chart2.BubbleChartType";
2918 Reference< chart2::data::XDataSequence > xYValuesForBubbleChart;
2919 if( bIsBubbleChart )
2921 Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt,
"values-y" ) );
2922 if( xSequence.is() )
2924 xYValuesForBubbleChart = xSequence->getValues();
2925 if( !lcl_exportDomainForThisSequence( xYValuesForBubbleChart, aFirstYDomainRange,
mrExport ) )
2926 xYValuesForBubbleChart =
nullptr;
2929 if( bIsScatterChart || bIsBubbleChart )
2931 Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt,
"values-x" ) );
2932 if( xSequence.is() )
2934 Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
2935 if( lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange,
mrExport ) )
2937 uno::Reference< chart2::data::XDataSequence >(), xValues );
2939 else if( nSeriesIdx==0 )
2942 Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) );
2943 if( xCategories.is() )
2945 Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() );
2946 if( !lcl_hasNoValuesButText( xValues ) )
2947 lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange,
mrExport );
2951 if( xYValuesForBubbleChart.is() )
2953 uno::Reference< chart2::data::XDataSequence >(), xYValuesForBubbleChart );
2959 if( bExportContent &&
2960 (aSeriesLabelValuesPair.first.is() || aSeriesLabelValuesPair.second.is()))
2965 if( bHasMeanValueLine &&
2969 Reference< beans::XPropertySet > xStatProp;
2972 Any aPropAny( xPropSet->getPropertyValue(
"DataMeanValueProperties" ));
2973 aPropAny >>= xStatProp;
2975 catch(
const uno::Exception & )
2977 TOOLS_INFO_EXCEPTION(
"xmloff.chart",
"Exception caught during Export of series - optional DataMeanValueProperties not available" );
2980 if( xStatProp.is() )
2984 if( !aPropertyStates.empty() )
2987 if( bExportContent )
3002 if( xPropSet.is() &&
3012 uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ),
3013 nSeriesLength, xNewDiagram, bExportContent );
3024 lcl_createDataLabelProperties(aDataLabelPropertyStates, xPropSet,
3030 if (!aDataLabelPropertyStates.empty())
3043 if (!aDataLabelPropertyStates.empty())
3046 aDataLabelPropertyStates.clear();
3050 Sequence< OUString > aSupportedMappings = rChartType->getSupportedPropertyRoles();
3058 aPropertyStates.clear();
3059 aDataLabelPropertyStates.clear();
3065 const Reference< chart2::data::XDataSource > & xSource,
const Sequence< OUString >& rSupportedMappings )
3067 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
3068 Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
3069 xSource->getDataSequences());
3071 for(
const auto& rSupportedMapping : rSupportedMappings)
3073 Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, rSupportedMapping ) );
3076 Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
3082 xValues->getSourceRangeRepresentation(),
3088 uno::Reference< chart2::data::XDataSequence >(), xValues );
3095 const Reference< chart2::XDataSeries >& xSeries,
3096 const awt::Size& rPageSize,
3097 bool bExportContent )
3101 Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeries, uno::UNO_QUERY );
3102 if( !xRegressionCurveContainer.is() )
3105 const Sequence< Reference< chart2::XRegressionCurve > > aRegCurveSeq = xRegressionCurveContainer->getRegressionCurves();
3107 for(
const auto& xRegCurve : aRegCurveSeq )
3109 std::vector< XMLPropertyState > aEquationPropertyStates;
3110 if (!xRegCurve.is())
3113 Reference< beans::XPropertySet > xProperties( xRegCurve , uno::UNO_QUERY );
3114 if( !xProperties.is() )
3117 Reference< lang::XServiceName > xServiceName( xProperties, uno::UNO_QUERY );
3118 if( !xServiceName.is() )
3121 bool bShowEquation =
false;
3122 bool bShowRSquared =
false;
3123 bool bExportEquation =
false;
3125 OUString aService = xServiceName->getServiceName();
3132 aPropertyStates.push_back(
property);
3134 Reference< beans::XPropertySet > xEquationProperties;
3135 xEquationProperties.set( xRegCurve->getEquationProperties() );
3136 if( xEquationProperties.is())
3138 xEquationProperties->getPropertyValue(
"ShowEquation") >>= bShowEquation;
3139 xEquationProperties->getPropertyValue(
"ShowCorrelationCoefficient") >>= bShowRSquared;
3141 bExportEquation = ( bShowEquation || bShowRSquared );
3146 bExportEquation=
false;
3148 if( bExportEquation )
3151 sal_Int32 nNumberFormat = 0;
3152 if( (xEquationProperties->getPropertyValue(
"NumberFormat") >>= nNumberFormat ) &&
3153 nNumberFormat != -1 )
3161 if( !aPropertyStates.empty() || bExportEquation )
3164 if( bExportContent )
3167 if( !aPropertyStates.empty())
3173 if( bExportEquation )
3179 chart2::RelativePosition aRelativePosition;
3180 if( xEquationProperties->getPropertyValue(
"RelativePosition" ) >>= aRelativePosition )
3182 double fX = aRelativePosition.Primary * rPageSize.Width;
3183 double fY = aRelativePosition.Secondary * rPageSize.Height;
3185 aPos.X =
static_cast< sal_Int32
>( ::rtl::math::round( fX ));
3186 aPos.Y =
static_cast< sal_Int32
>( ::rtl::math::round( fY ));
3190 if( !aEquationPropertyStates.empty())
3200 if( !aPropertyStates.empty())
3204 if( bExportEquation && !aEquationPropertyStates.empty())
3214 bool bYError,
bool bExportContent )
3225 if (!xSeriesProp.is())
3228 bool bNegative =
false, bPositive =
false;
3229 sal_Int32 nErrorBarStyle = chart::ErrorBarStyle::NONE;
3230 Reference< beans::XPropertySet > xErrorBarProp;
3234 Any aAny = xSeriesProp->getPropertyValue( bYError ? OUString(
"ErrorBarY") : OUString(
"ErrorBarX") );
3235 aAny >>= xErrorBarProp;
3237 if ( xErrorBarProp.is() )
3239 aAny = xErrorBarProp->getPropertyValue(
"ShowNegativeError" );
3242 aAny = xErrorBarProp->getPropertyValue(
"ShowPositiveError" );
3245 aAny = xErrorBarProp->getPropertyValue(
"ErrorBarStyle" );
3246 aAny >>= nErrorBarStyle;
3249 catch(
const beans::UnknownPropertyException & )
3254 if( !(nErrorBarStyle != chart::ErrorBarStyle::NONE && (bNegative || bPositive)))
3257 if( bExportContent && nErrorBarStyle == chart::ErrorBarStyle::FROM_DATA )
3260 ::std::vector< Reference< chart2::data::XDataSequence > > aErrorBarSequences(
3261 lcl_getErrorBarSequences( xErrorBarProp ));
3262 for(
const auto& rErrorBarSequence : aErrorBarSequences )
3265 uno::Reference< chart2::data::XDataSequence >(), rErrorBarSequence );
3271 if( aPropertyStates.empty() )
3275 if( bExportContent )
3291 const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
3292 const Reference< chart2::XDiagram > & xDiagram,
3293 bool bJapaneseCandleSticks,
3294 bool bExportContent )
3297 for(
const auto& xSeries : aSeriesSeq )
3299 sal_Int32 nAttachedAxis = lcl_isSeriesAttachedToFirstAxis( xSeries )
3300 ? chart::ChartAxisAssign::PRIMARY_Y
3301 : chart::ChartAxisAssign::SECONDARY_Y;
3303 Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
3309 Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
3310 xSource->getDataSequences());
3312 sal_Int32 nSeriesLength =
3313 lcl_getSequenceLengthByRole( aSeqCnt,
"values-last");
3315 if( bExportContent )
3317 Reference< chart2::XChartDocument > xNewDoc(
mrExport.
GetModel(), uno::UNO_QUERY );
3322 if( bJapaneseCandleSticks )
3324 tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3326 if( !aRanges.second.isEmpty())
3328 if( !aRanges.first.isEmpty())
3330 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3341 tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3343 if( !aRanges.second.isEmpty())
3345 if( !aRanges.first.isEmpty())
3347 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3358 tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3360 if( !aRanges.second.isEmpty())
3362 if( !aRanges.first.isEmpty())
3364 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3375 tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
3377 if( !aRanges.second.isEmpty())
3379 if( !aRanges.first.isEmpty())
3381 if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
3400 const uno::Reference< beans::XPropertySet > & xSeriesProperties,
3401 sal_Int32 nSeriesLength,
3402 const uno::Reference< chart2::XDiagram > & xDiagram,
3403 bool bExportContent )
3421 uno::Reference< chart2::XDataSeries > xSeries( xSeriesProperties, uno::UNO_QUERY );
3423 std::vector< XMLPropertyState > aPropertyStates;
3424 std::vector<XMLPropertyState> aDataLabelPropertyStates;
3426 bool bVaryColorsByPoint =
false;
3427 Sequence< sal_Int32 > aDataPointSeq;
3428 Sequence<sal_Int32> deletedLegendEntriesSeq;
3429 if( xSeriesProperties.is())
3431 xSeriesProperties->getPropertyValue(
"AttributedDataPoints") >>= aDataPointSeq;
3432 xSeriesProperties->getPropertyValue(
"VaryColorsByPoint") >>= bVaryColorsByPoint;
3437 xSeriesProperties->getPropertyValue(
"DeletedLegendEntries") >>= deletedLegendEntriesSeq;
3440 sal_Int32 nSize = aDataPointSeq.getLength();
3441 SAL_WARN_IF( nSize > nSeriesLength,
"xmloff.chart",
"Too many point attributes" );
3443 const sal_Int32 * pPoints = aDataPointSeq.getConstArray();
3445 Reference< chart2::XColorScheme > xColorScheme;
3447 xColorScheme.set( xDiagram->getDefaultColorScheme());
3449 ::std::vector< SchXMLDataPointStruct > aDataPointVector;
3451 sal_Int32 nLastIndex = -1;
3454 if( bVaryColorsByPoint && xColorScheme.is() )
3457 aAttrPointSet.
reserve(aDataPointSeq.getLength());
3458 for (
auto p = pPoints;
p < pPoints + aDataPointSeq.getLength(); ++
p)
3460 const auto aEndIt = aAttrPointSet.
end();
3461 for( nElement = 0; nElement < nSeriesLength; ++nElement )
3463 aPropertyStates.clear();
3464 aDataLabelPropertyStates.clear();
3465 uno::Reference< beans::XPropertySet > xPropSet;
3466 bool bExportNumFmt =
false;
3467 if( aAttrPointSet.
find( nElement ) != aEndIt )
3473 bExportNumFmt =
true;
3475 catch(
const uno::Exception & )
3483 xPropSet.set( new ::xmloff::chart::ColorPropertySet(
3486 SAL_WARN_IF( !xPropSet.is(),
"xmloff.chart",
"Pie Segments should have properties" );
3493 lcl_exportNumberFormat(
"NumberFormat", xPropSet,
mrExport );
3494 lcl_exportNumberFormat(
"PercentageNumberFormat", xPropSet,
mrExport );
3500 lcl_createDataLabelProperties(aDataLabelPropertyStates, xPropSet,
3506 sal_Int32 nPlacement = 0;
3507 xPropSet->getPropertyValue(
"LabelPlacement") >>= nPlacement;
3508 if (nPlacement == chart::DataLabelPlacement::CUSTOM)
3510 xPropSet->setPropertyValue(
"LabelPlacement",
3511 uno::Any(chart::DataLabelPlacement::OUTSIDE));
3516 if (!aPropertyStates.empty() || !aDataLabelPropertyStates.empty())
3521 SchXMLDataPointStruct aPoint;
3522 if (!aPropertyStates.empty())
3525 "Autostyle queue empty!");
3529 if (!aDataLabelPropertyStates.empty())
3532 "Autostyle queue empty!");
3537 aPoint.mCustomLabel = lcl_getCustomLabelField(
mrExport, nElement, xSeries);
3538 aPoint.mCustomLabelPos = lcl_getCustomLabelPosition(
mrExport, nElement, xSeries);
3540 aDataPointVector.push_back( aPoint );
3544 if (!aPropertyStates.empty())
3546 if (!aDataLabelPropertyStates.empty())
3552 SAL_WARN_IF( bExportContent && (
static_cast<sal_Int32
>(aDataPointVector.size()) != nSeriesLength),
"xmloff.chart",
"not enough data points on content export" );
3556 for( sal_Int32 nCurrIndex : std::as_const(aDataPointSeq) )
3558 aPropertyStates.clear();
3559 aDataLabelPropertyStates.clear();
3562 if( nCurrIndex<0 || nCurrIndex>=nSeriesLength )
3566 if( nCurrIndex - nLastIndex > 1 )
3568 SchXMLDataPointStruct aPoint;
3569 aPoint.mnRepeat = nCurrIndex - nLastIndex - 1;
3570 aDataPointVector.push_back( aPoint );
3573 uno::Reference< beans::XPropertySet > xPropSet;
3580 catch(
const uno::Exception & )
3590 lcl_exportNumberFormat(
"NumberFormat", xPropSet,
mrExport );
3591 lcl_exportNumberFormat(
"PercentageNumberFormat", xPropSet,
mrExport );
3597 lcl_createDataLabelProperties(aDataLabelPropertyStates, xPropSet,
3603 if (!aPropertyStates.empty() || !aDataLabelPropertyStates.empty())
3605 if( bExportContent )
3608 SchXMLDataPointStruct aPoint;
3609 if (!aPropertyStates.empty())
3612 "Autostyle queue empty!");
3616 aPoint.mCustomLabel = lcl_getCustomLabelField(
mrExport, nCurrIndex, xSeries);
3617 aPoint.mCustomLabelPos = lcl_getCustomLabelPosition(
mrExport, nCurrIndex, xSeries);
3618 if (!aDataLabelPropertyStates.empty())
3621 "Autostyle queue empty!");
3626 aDataPointVector.push_back( aPoint );
3627 nLastIndex = nCurrIndex;
3631 if (!aPropertyStates.empty())
3633 if (!aDataLabelPropertyStates.empty())
3641 SchXMLDataPointStruct aPoint;
3642 aDataPointVector.push_back( aPoint );
3644 nLastIndex = nCurrIndex;
3647 sal_Int32 nRepeat = nSeriesLength - nLastIndex - 1;
3650 SchXMLDataPointStruct aPoint;
3651 aPoint.mnRepeat = nRepeat;
3652 aDataPointVector.push_back( aPoint );
3656 if (!bExportContent)
3660 SchXMLDataPointStruct aPoint;
3661 SchXMLDataPointStruct aLastPoint;
3665 aLastPoint.mnRepeat = 0;
3667 for(
const auto& rPoint : aDataPointVector )
3671 if (aPoint.maStyleName == aLastPoint.maStyleName
3672 && aLastPoint.mCustomLabel.maFields.getLength() < 1
3673 && aLastPoint.mCustomLabelPos.Primary == 0.0
3674 && aLastPoint.mCustomLabelPos.Secondary == 0.0
3675 && aPoint.msDataLabelStyleName == aLastPoint.msDataLabelStyleName)
3676 aPoint.mnRepeat += aLastPoint.mnRepeat;
3677 else if( aLastPoint.mnRepeat > 0 )
3680 if( !aLastPoint.maStyleName.isEmpty() )
3683 if( aLastPoint.mnRepeat > 1 )
3685 OUString::number( aLastPoint.mnRepeat ));
3687 for (
const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
3689 if (
nIndex == deletedLegendEntry)
3700 aLastPoint = aPoint;
3703 if( aPoint.maStyleName != aLastPoint.maStyleName )
3706 if( !aLastPoint.maStyleName.isEmpty() )
3709 if( aLastPoint.mnRepeat > 1 )
3711 OUString::number( aLastPoint.mnRepeat ));
3713 for (
const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
3715 if (
nIndex == deletedLegendEntry)
3729 if (rPoint.mCustomLabel.maFields.getLength() < 1 && rPoint.msDataLabelStyleName.isEmpty())
3732 if (!rPoint.msDataLabelStyleName.isEmpty())
3735 if (rPoint.mCustomLabel.mbDataLabelsRange)
3744 for (
const Reference<chart2::XDataPointCustomLabelField>&
label : rPoint.mCustomLabel.maFields)
3754 if( xCustomLabelPosition.Primary == 0.0 && xCustomLabelPosition.Secondary == 0.0 )
3757 OUStringBuffer aCustomLabelPosString;
3805 awt::Size aSize( 8000, 7000 );
3806 uno::Reference< embed::XVisualObject > xVisualObject( xChartDoc, uno::UNO_QUERY );
3807 SAL_WARN_IF( !xVisualObject.is(),
"xmloff.chart",
"need XVisualObject for page size" );
3808 if( xVisualObject.is() )
3809 aSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
3816 if( !aStates.empty() )
3822 if( !aStates.empty() )
3857 Reference< chart2::XChartDocument > xChartDoc(
GetModel(), uno::UNO_QUERY );
3858 maExportHelper->m_pImpl->InitRangeSegmentationProperties( xChartDoc );
3865 SAL_INFO(
"xmloff.chart",
"Master Style Export requested. Not available for Chart" );
3878 Reference< chart::XChartDocument > xChartDoc(
GetModel(), uno::UNO_QUERY );
3885 SAL_WARN(
"xmloff.chart",
"Couldn't export chart due to wrong XModel (must be XChartDocument)" );
3897 Reference< chart::XChartDocument > xChartDoc(
GetModel(), uno::UNO_QUERY );
3904 SAL_WARN(
"xmloff.chart",
"Couldn't export chart due to wrong XModel (must be XChartDocument)" );
3911 Reference< chart::XChartDocument > xChartDoc(
GetModel(), uno::UNO_QUERY );
3915 bool bIncludeTable =
true;
3917 Reference< chart2::XChartDocument > xNewDoc( xChartDoc, uno::UNO_QUERY );
3923 Reference< lang::XServiceInfo > xDPServiceInfo( xNewDoc->getDataProvider(), uno::UNO_QUERY );
3924 if( ! (xDPServiceInfo.is() && xDPServiceInfo->getImplementationName() ==
"com.sun.star.comp.chart.InternalDataProvider" ))
3926 bIncludeTable =
false;
3931 Reference< lang::XServiceInfo > xServ( xChartDoc, uno::UNO_QUERY );
3934 if( xServ->supportsService(
"com.sun.star.chart.ChartTableAddressSupplier" ))
3936 Reference< beans::XPropertySet > xProp( xServ, uno::UNO_QUERY );
3942 OUString sChartAddress;
3943 aAny = xProp->getPropertyValue(
"ChartRangeAddress" );
3944 aAny >>= sChartAddress;
3948 bIncludeTable = sChartAddress.isEmpty();
3950 catch(
const beans::UnknownPropertyException & )
3952 SAL_WARN(
"xmloff.chart",
"Property ChartRangeAddress not supported by ChartDocument" );
3958 maExportHelper->m_pImpl->exportChart( xChartDoc, bIncludeTable );
3962 SAL_WARN(
"xmloff.chart",
"Couldn't export chart due to wrong XModel" );
3973 if( !xChartDoc.is())
3978 Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
3979 SAL_WARN_IF( !xDataProvider.is(),
"xmloff.chart",
"No DataProvider" );
3980 if( xDataProvider.is())
3982 Reference< chart2::data::XDataSource > xDataSource( lcl_pressUsedDataIntoRectangularFormat( xChartDoc,
mbHasCategoryLabels ));
3983 const Sequence< beans::PropertyValue > aArgs( xDataProvider->detectArguments( xDataSource ));
3984 OUString sCellRange, sBrokenRange;
3985 bool bBrokenRangeAvailable =
false;
3986 for(
const auto& rArg : aArgs )
3988 if ( rArg.Name ==
"CellRangeRepresentation" )
3989 rArg.Value >>= sCellRange;
3990 else if ( rArg.Name ==
"BrokenCellRangeForExport" )
3992 if( rArg.Value >>= sBrokenRange )
3993 bBrokenRangeAvailable =
true;
3995 else if ( rArg.Name ==
"DataRowSource" )
3997 chart::ChartDataRowSource eRowSource;
3998 rArg.Value >>= eRowSource;
4001 else if ( rArg.Name ==
"SequenceMapping" )
4008 msChartAddress = (bBrokenRangeAvailable ? sBrokenRange : sCellRange);
4012 Reference< chart2::data::XRangeXMLConversion > xConversion( xDataProvider, uno::UNO_QUERY );
4013 if( xConversion.is())
4018 catch(
const uno::Exception & )
4026extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4028 uno::Sequence<uno::Any>
const& )
4030 return cppu::acquire(
4038extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4040 uno::Sequence<uno::Any>
const& )
4042 return cppu::acquire(
4052extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4054 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4060extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4062 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4064 return cppu::acquire(
new SchXMLExport(pCtx,
"SchXMLExport.Oasis.Styles",
4068extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4070 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4072 return cppu::acquire(
new SchXMLExport(pCtx,
"SchXMLExport.Content",
4077extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4079 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4081 return cppu::acquire(
new SchXMLExport(pCtx,
"SchXMLExport.Oasis.Content",
4089extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
4091 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
4093 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.
css::uno::Sequence< OUString > GetPropertyNames()
retrieve the names of the properties used in the styles
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