29#include <osl/diagnose.h>
42#include <com/sun/star/lang/XMultiServiceFactory.hpp>
43#include <com/sun/star/chart/XChartDocument.hpp>
44#include <com/sun/star/chart/XDiagram.hpp>
45#include <com/sun/star/xml/sax/XAttributeList.hpp>
46#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
47#include <com/sun/star/drawing/XDrawPage.hpp>
48#include <com/sun/star/chart/ChartDataRowSource.hpp>
49#include <com/sun/star/embed/Aspects.hpp>
50#include <com/sun/star/embed/XVisualObject.hpp>
52#include <com/sun/star/chart2/XChartDocument.hpp>
53#include <com/sun/star/chart2/data/XDataSink.hpp>
54#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
55#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
56#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
57#include <com/sun/star/chart2/XChartTypeContainer.hpp>
58#include <com/sun/star/chart2/XTitled.hpp>
60#include <com/sun/star/container/XChild.hpp>
61#include <com/sun/star/chart2/data/XDataReceiver.hpp>
73void lcl_setRoleAtLabeledSequence(
74 const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq,
75 const OUString &rRole )
78 uno::Reference< chart2::data::XDataSequence > xValues( xLSeq->getValues());
81 uno::Reference< beans::XPropertySet > xProp( xValues, uno::UNO_QUERY );
83 xProp->setPropertyValue(
"Role",
uno::Any( rRole ));
87void lcl_MoveDataToCandleStickSeries(
88 const uno::Reference< chart2::data::XDataSource > & xDataSource,
89 const uno::Reference< chart2::XDataSeries > & xDestination,
90 const OUString & rRole )
94 uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledSeq(
95 xDataSource->getDataSequences());
96 if( aLabeledSeq.hasElements())
98 lcl_setRoleAtLabeledSequence( aLabeledSeq[0], rRole );
101 uno::Reference< chart2::data::XDataSource > xSource( xDestination, uno::UNO_QUERY_THROW );
103 uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > >
aData( xSource->getDataSequences());
105 aData.getArray()[
aData.getLength() - 1 ] = aLabeledSeq[0];
106 uno::Reference< chart2::data::XDataSink >
xSink( xDestination, uno::UNO_QUERY_THROW );
107 xSink->setData( aData );
110 catch(
const uno::Exception&)
112 TOOLS_WARN_EXCEPTION(
"xmloff.chart",
"Exception caught while moving data to candlestick series" );
116void lcl_setRoleAtFirstSequence(
117 const uno::Reference< chart2::XDataSeries > & xSeries,
118 const OUString & rRole )
120 uno::Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
123 uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > >
aSeq( xSource->getDataSequences());
124 if(
aSeq.hasElements())
125 lcl_setRoleAtLabeledSequence( aSeq[0], rRole );
129void lcl_removeEmptyChartTypeGroups(
const uno::Reference< chart2::XChartDocument > & xDoc )
134 uno::Reference< chart2::XDiagram > xDia( xDoc->getFirstDiagram());
141 sal_Int32 nRemainingGroups = 0;
142 uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDia, uno::UNO_QUERY_THROW );
143 const uno::Sequence< uno::Reference< chart2::XCoordinateSystem > >
144 aCooSysSeq( xCooSysCnt->getCoordinateSystems());
145 for(
auto const & i : aCooSysSeq )
147 uno::Reference< chart2::XChartTypeContainer > xCTCnt( i, uno::UNO_QUERY_THROW );
148 nRemainingGroups += xCTCnt->getChartTypes().getLength();
152 for( sal_Int32 nI = aCooSysSeq.getLength(); nI-- && (nRemainingGroups > 1); )
154 uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nI], uno::UNO_QUERY_THROW );
155 uno::Sequence< uno::Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
156 for( sal_Int32 nJ=aCTSeq.getLength(); nJ-- && (nRemainingGroups > 1); )
158 uno::Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nJ], uno::UNO_QUERY_THROW );
159 if( !xDSCnt->getDataSeries().hasElements() )
162 xCTCnt->removeChartType( aCTSeq[nJ] );
168 catch(
const uno::Exception&)
174uno::Sequence< sal_Int32 > lcl_getNumberSequenceFromString( std::u16string_view rStr,
bool bAddOneToEachOldIndex )
179 ::std::vector< sal_Int32 > aVec;
182 while( nPos != std::u16string_view::npos )
184 nPos = rStr.find( aSpace, nLastPos );
185 if( nPos != std::u16string_view::npos )
187 if( nPos > nLastPos )
188 aVec.push_back(
o3tl::toInt32(rStr.substr( nLastPos, (nPos - nLastPos) )) );
194 rStr.size() > nLastPos )
199 const size_t nVecSize = aVec.size();
200 uno::Sequence< sal_Int32 >
aSeq( nVecSize );
202 if(!bAddOneToEachOldIndex)
204 sal_Int32* pSeqArr =
aSeq.getArray();
205 for( nPos = 0;
nPos < nVecSize; ++
nPos )
210 else if( bAddOneToEachOldIndex )
212 aSeq.realloc( nVecSize+1 );
213 auto pSeqArr =
aSeq.getArray();
216 for( nPos = 0;
nPos < nVecSize; ++
nPos )
228 SvXMLImport& rImport ) :
230 mrImportHelper( rImpHelper ),
231 m_bHasRangeAtPlotArea( false ),
232 m_bHasTableElement( false ),
233 mbAllRangeAddressesAvailable( true ),
234 mbColHasLabels( false ),
235 mbRowHasLabels( false ),
236 meDataRowSource(
chart::ChartDataRowSource_COLUMNS ),
237 mbIsStockChart( false )
251void setDataProvider(uno::Reference<chart2::XChartDocument>
const & xChartDoc, OUString
const & sDataPilotSource)
258 uno::Reference<container::XChild> xChild(xChartDoc, uno::UNO_QUERY);
259 uno::Reference<chart2::data::XDataReceiver> xDataReceiver(xChartDoc, uno::UNO_QUERY);
260 if (xChild.is() && xDataReceiver.is())
262 bool bHasOwnData =
true;
267 if (!xChartDoc->getDataProvider().is())
269 bool bHasDataPilotSource = !sDataPilotSource.isEmpty();
270 OUString aDataProviderServiceName(
"com.sun.star.chart2.data.DataProvider");
271 if (bHasDataPilotSource)
272 aDataProviderServiceName =
"com.sun.star.chart2.data.PivotTableDataProvider";
280 if (bHasDataPilotSource)
283 xPivotTableDataProvider->setPivotTableName(sDataPilotSource);
284 xDataReceiver->attachDataProvider(xProvider);
285 bHasOwnData = !xPivotTableDataProvider->hasPivotTable();
289 xDataReceiver->attachDataProvider(xProvider);
300 if (bHasOwnData && ! xChartDoc->hasInternalDataProvider())
301 xChartDoc->createInternalDataProvider(
false);
304 catch (
const uno::Exception &)
311 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
316 SAL_WARN_IF(!xVisualObject.is(),
"xmloff.chart",
"need xVisualObject for page size");
317 if( xVisualObject.is() )
318 maChartSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
320 OUString sAutoStyleName;
321 OUString aOldChartTypeName;
322 bool bHasAddin =
false;
326 switch( aIter.getToken() )
336 OUString aValue = aIter.toString();
338 sal_uInt16 nClassPrefix =
339 GetImport().GetNamespaceMap().GetKeyByAttrValueQName(
340 aValue, &sClassName );
348 switch( eChartTypeEnum )
363 aOldChartTypeName = sClassName;
371 GetImport().GetMM100UnitConverter().convertMeasureToCore(
377 GetImport().GetMM100UnitConverter().convertMeasureToCore(
382 sAutoStyleName = aIter.toString();
397 uno::Reference<chart2::XChartDocument> xNewDoc(xDoc, uno::UNO_QUERY);
401 if( aOldChartTypeName.isEmpty() )
403 SAL_WARN(
"xmloff.chart",
"need a charttype to create a diagram" );
411 if( xVisualObject.is() )
412 xVisualObject->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT,
maChartSize );
425 xDocProp->getPropertyValue(
"BaseDiagram") >>= aOldChartTypeName;
427 xDocProp->setPropertyValue(
"RefreshAddInAllowed",
uno::Any(
false) );
429 catch(
const uno::Exception&)
431 TOOLS_WARN_EXCEPTION(
"xmloff.chart",
"Exception during import SchXMLChartContext::StartElement" );
446 css::uno::Reference< css::chart2::XDataSeries >
m_xSeries;
448 sal_Int32 mnAttachedAxis;
450 ::std::vector< OUString > m_aSeriesStyles;
451 ::std::vector< OUString > m_aPointStyles;
453 NewDonutSeries( css::uno::Reference< css::chart2::XDataSeries > xSeries, sal_Int32 nPointCount )
455 , mnAttachedAxis( 1 )
457 m_aPointStyles.resize(nPointCount);
458 m_aSeriesStyles.resize(nPointCount);
461 void setSeriesStyleNameToPoint(
const OUString& rStyleName, sal_Int32 nPointIndex )
463 SAL_WARN_IF(nPointIndex >=
static_cast<sal_Int32
>(m_aSeriesStyles.size()),
"xmloff.chart",
"donut point <-> series count mismatch");
464 if( nPointIndex <
static_cast<sal_Int32
>(m_aSeriesStyles.size()) )
465 m_aSeriesStyles[nPointIndex]=rStyleName;
468 void setPointStyleNameToPoint(
const OUString& rStyleName, sal_Int32 nPointIndex )
470 SAL_WARN_IF(nPointIndex >=
static_cast<sal_Int32
>(m_aPointStyles.size()),
"xmloff.chart",
"donut point <-> series count mismatch");
471 if( nPointIndex <
static_cast<sal_Int32
>(m_aPointStyles.size()) )
472 m_aPointStyles[nPointIndex]=rStyleName;
475 ::std::vector< DataRowPointStyle > creatStyleVector()
477 ::std::vector< DataRowPointStyle > aRet;
480 , m_xSeries, -1, 1, msStyleName, mnAttachedAxis );
481 aRet.push_back( aSeriesStyle );
483 sal_Int32 nPointIndex=0;
484 for (
auto const& pointStyle : m_aPointStyles)
487 , m_xSeries, nPointIndex, 1, pointStyle, mnAttachedAxis );
488 if( nPointIndex <
static_cast<sal_Int32
>(m_aSeriesStyles.size()) )
490 aPointStyle.msSeriesStyleNameForDonuts = m_aSeriesStyles[nPointIndex];
492 if( !aPointStyle.msSeriesStyleNameForDonuts.isEmpty()
493 || !aPointStyle.msStyleName.isEmpty() )
494 aRet.push_back( aPointStyle );
502void lcl_swapPointAndSeriesStylesForDonutCharts( ::std::vector< DataRowPointStyle >& rStyleVector
503 , ::std::map< css::uno::Reference< css::chart2::XDataSeries> , sal_Int32 >&& aSeriesMap )
507 sal_Int32 nOldSeriesCount = 0;
509 sal_Int32 nMaxOldSeriesIndex = 0;
510 sal_Int32 nOldSeriesIndex = 0;
511 for (
auto const& style : rStyleVector)
515 aStyle.m_xSeries.is() )
517 nMaxOldSeriesIndex = nOldSeriesIndex;
519 if( aSeriesMap.end() == aSeriesMap.find(aStyle.m_xSeries) )
520 aSeriesMap[aStyle.m_xSeries] = nOldSeriesIndex;
525 nOldSeriesCount = nMaxOldSeriesIndex+1;
529 ::std::map< Reference< chart2::XDataSeries >, sal_Int32 >::const_iterator aSeriesMapEnd( aSeriesMap.end() );
532 ::std::vector< NewDonutSeries > aNewSeriesVector;
534 ::std::map< sal_Int32, Reference< chart2::XDataSeries > > aIndexSeriesMap;
535 for (
auto const& series : aSeriesMap)
536 aIndexSeriesMap[series.second] = series.first;
538 for (
auto const& indexSeries : aIndexSeriesMap)
539 aNewSeriesVector.emplace_back(indexSeries.second,nOldSeriesCount );
543 for (
auto const& style : rStyleVector)
548 auto aSeriesMapIt = aSeriesMap.find( aStyle.m_xSeries );
549 if( aSeriesMapIt != aSeriesMapEnd && aSeriesMapIt->second <
static_cast<sal_Int32
>(aNewSeriesVector.size()) )
550 aNewSeriesVector[aSeriesMapIt->second].mnAttachedAxis = aStyle.mnAttachedAxis;
555 for (
auto const& style : rStyleVector)
560 auto aSeriesMapIt = aSeriesMap.find(aStyle.m_xSeries);
561 if( aSeriesMapEnd != aSeriesMapIt )
563 sal_Int32 nNewPointIndex = aSeriesMapIt->second;
565 for (
auto & newSeries : aNewSeriesVector)
566 newSeries.setSeriesStyleNameToPoint( aStyle.msStyleName, nNewPointIndex );
572 for (
auto const& style : rStyleVector)
577 auto aSeriesMapIt = aSeriesMap.find(aStyle.m_xSeries);
578 if( aSeriesMapEnd != aSeriesMapIt )
580 sal_Int32 nNewPointIndex = aSeriesMapIt->second;
581 sal_Int32 nNewSeriesIndex = aStyle.m_nPointIndex;
582 sal_Int32 nRepeatCount = aStyle.m_nPointRepeat;
584 while( nRepeatCount && (nNewSeriesIndex>=0) && (
o3tl::make_unsigned(nNewSeriesIndex)< aNewSeriesVector.size() ) )
586 NewDonutSeries& rNewSeries( aNewSeriesVector[nNewSeriesIndex] );
587 rNewSeries.setPointStyleNameToPoint( aStyle.msStyleName, nNewPointIndex );
597 rStyleVector.clear();
599 for (
auto & newSeries : aNewSeriesVector)
601 ::std::vector< DataRowPointStyle > aVector( newSeries.creatStyleVector() );
602 rStyleVector.insert(rStyleVector.end(),aVector.begin(),aVector.end());
606bool lcl_SpecialHandlingForDonutChartNeeded(
607 std::u16string_view rServiceName,
608 const SvXMLImport & rImport )
610 bool bResult =
false;
611 if( rServiceName == u
"com.sun.star.chart2.DonutChartType" )
621 const uno::Reference< chart2::XChartDocument >& xNewDoc
622 ,
const OUString& rRectangularRange
623 , css::chart::ChartDataRowSource eDataRowSource
624 ,
bool bRowHasLabels,
bool bColHasLabels
625 ,
bool bSwitchOnLabelsAndCategoriesForOwnData
626 , std::u16string_view sColTrans
627 , std::u16string_view sRowTrans )
632 uno::Reference< chart2::XDiagram > xNewDia( xNewDoc->getFirstDiagram());
633 uno::Reference< chart2::data::XDataProvider > xDataProvider( xNewDoc->getDataProvider() );
634 if( !xNewDia.is() || !xDataProvider.is() )
637 bool bFirstCellAsLabel =
638 (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bRowHasLabels : bColHasLabels;
640 (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bColHasLabels : bRowHasLabels;
642 if( bSwitchOnLabelsAndCategoriesForOwnData )
644 bFirstCellAsLabel =
true;
645 bHasCateories =
true;
648 uno::Sequence< beans::PropertyValue > aArgs{
649 beans::PropertyValue(
650 "CellRangeRepresentation",
652 beans::PropertyState_DIRECT_VALUE ),
653 beans::PropertyValue(
656 beans::PropertyState_DIRECT_VALUE ),
657 beans::PropertyValue(
660 beans::PropertyState_DIRECT_VALUE )
663 if( !sColTrans.empty() || !sRowTrans.empty() )
665 aArgs.realloc( aArgs.getLength() + 1 );
666 aArgs.getArray()[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
669 ? lcl_getNumberSequenceFromString( sColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() )
670 : lcl_getNumberSequenceFromString( sRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ),
671 beans::PropertyState_DIRECT_VALUE );
676 OUString aChartOleObjectName;
681 utl::MediaDescriptor::const_iterator aIt(
682 aMediaDescriptor.find( OUString(
"HierarchicalDocumentName" )));
683 if( aIt != aMediaDescriptor.end() )
685 aChartOleObjectName = (*aIt).second.get< OUString >();
688 if( !aChartOleObjectName.isEmpty() )
690 aArgs.realloc( aArgs.getLength() + 1 );
691 aArgs.getArray()[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
692 "ChartOleObjectName",
693 -1,
uno::Any( aChartOleObjectName ),
694 beans::PropertyState_DIRECT_VALUE );
698 uno::Reference< chart2::data::XDataSource > xDataSource(
699 xDataProvider->createDataSource( aArgs ));
701 aArgs.realloc( aArgs.getLength() + 2 );
702 auto pArgs = aArgs.getArray();
703 pArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 2 ] = beans::PropertyValue(
706 beans::PropertyState_DIRECT_VALUE );
707 pArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
710 beans::PropertyState_DIRECT_VALUE );
712 xNewDia->setDiagramData( xDataSource, aArgs );
718 uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
719 uno::Reference< chart2::XChartDocument > xNewDoc( xDoc, uno::UNO_QUERY );
725 uno::Reference< beans::XPropertySet > xTitleProp( xDoc->getTitle(), uno::UNO_QUERY );
732 catch(
const beans::UnknownPropertyException&)
734 SAL_WARN(
"xmloff.chart",
"Property String for Title not available" );
740 uno::Reference< beans::XPropertySet > xTitleProp( xDoc->getSubTitle(), uno::UNO_QUERY );
747 catch(
const beans::UnknownPropertyException&)
749 SAL_WARN(
"xmloff.chart",
"Property String for Title not available" );
756 lcl_removeEmptyChartTypeGroups( xNewDoc );
759 uno::Reference< chart::XDiagram > xDiagram( xDoc->getDiagram() );
760 uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
774 bool bSpecialHandlingForDonutChart = lcl_SpecialHandlingForDonutChartNeeded(
781 bool bHasOwnData =
false;
791 if( xNewDoc->hasInternalDataProvider())
797 bHasOwnData = !bSwitchSuccessful;
802 else if( bHasOwnData )
804 xNewDoc->createInternalDataProvider(
false );
809 bool bSwitchRangesFromOuterToInternalIfNecessary =
false;
820 if( xNewDoc->hasInternalDataProvider() )
824 bool bOldFileWithOwnDataFromRows = (bOlderThan2_3 && bHasOwnData && (
meDataRowSource==chart::ChartDataRowSource_ROWS));
827 !bOldFileWithOwnDataFromRows )
831 bSwitchRangesFromOuterToInternalIfNecessary =
true;
840 if( bOlderThan2_3 && xDiaProp.is() )
841 xDiaProp->setPropertyValue(
"IncludeHiddenCells",
uno::Any(
false));
847 catch(
const uno::Exception&)
850 TOOLS_WARN_EXCEPTION(
"xmloff.chart",
"Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram try to fallback to internal data" );
855 if( !xNewDoc->hasInternalDataProvider() )
857 xNewDoc->createInternalDataProvider(
false );
863 catch(
const uno::Exception&)
865 TOOLS_WARN_EXCEPTION(
"xmloff.chart",
"Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram fallback to internal data failed also" );
874 SAL_WARN(
"xmloff.chart",
"Must not get here" );
879 if( bSpecialHandlingForDonutChart )
881 uno::Reference< chart2::XDiagram > xNewDiagram( xNewDoc->getFirstDiagram() );
890 bool bSwitchOffLinesForScatter =
false;
892 bool bLinesOn =
true;
897 bSwitchOffLinesForScatter =
true;
907 OUString sCurrStyleName;
913 if( !bSpecialHandlingForDonutChart )
922 pStyle, sCurrStyleName );
926 pStyle, sCurrStyleName );
931 if( bSwitchRangesFromOuterToInternalIfNecessary )
933 if( xNewDoc->hasInternalDataProvider() )
946 xProp->setPropertyValue(
"RefreshAddInAllowed",
uno::Any(
true) );
955 uno::Reference< chart2::XChartDocument > xDoc( xOldDoc, uno::UNO_QUERY_THROW );
956 uno::Reference< chart2::XDiagram > xDiagram( xDoc->getFirstDiagram());
960 bool bHasJapaneseCandlestick =
true;
961 uno::Reference< chart2::XDataSeriesContainer > xDSContainer;
962 uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
963 const uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
964 for(
const auto& rCooSys : aCooSysSeq )
966 uno::Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY_THROW );
967 const uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
968 auto pChartType = std::find_if(aChartTypes.begin(), aChartTypes.end(),
969 [](
const auto& rChartType) { return rChartType->getChartType() ==
"com.sun.star.chart2.CandleStickChartType"; });
970 if (pChartType != aChartTypes.end())
972 xDSContainer.set( *pChartType, uno::UNO_QUERY_THROW );
973 uno::Reference< beans::XPropertySet > xCTProp( *pChartType, uno::UNO_QUERY_THROW );
974 xCTProp->getPropertyValue(
"Japanese") >>= bHasJapaneseCandlestick;
978 if( xDSContainer.is())
982 uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSContainer->getDataSeries());
983 const sal_Int32 nSeriesCount( aSeriesSeq.getLength());
984 const sal_Int32 nSeriesPerCandleStick = bHasJapaneseCandlestick ? 4: 3;
985 sal_Int32 nCandleStickCount = nSeriesCount / nSeriesPerCandleStick;
986 OSL_ASSERT( nSeriesPerCandleStick * nCandleStickCount == nSeriesCount );
987 uno::Sequence< uno::Reference< chart2::XDataSeries > > aNewSeries( nCandleStickCount );
988 auto aNewSeriesRange = asNonConstRange(aNewSeries);
989 for( sal_Int32
i=0;
i<nCandleStickCount; ++
i )
991 sal_Int32 nSeriesIndex =
i*nSeriesPerCandleStick;
992 if( bHasJapaneseCandlestick )
995 lcl_setRoleAtFirstSequence( aSeriesSeq[ nSeriesIndex ],
"values-first");
996 aNewSeriesRange[
i] = aSeriesSeq[ nSeriesIndex ];
998 lcl_MoveDataToCandleStickSeries(
999 uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
1000 aNewSeries[
i],
"values-min");
1005 lcl_setRoleAtFirstSequence( aSeriesSeq[ nSeriesIndex ],
"values-min");
1006 aNewSeriesRange[
i] = aSeriesSeq[ nSeriesIndex ];
1009 lcl_MoveDataToCandleStickSeries(
1010 uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
1011 aNewSeries[
i],
"values-max");
1013 lcl_MoveDataToCandleStickSeries(
1014 uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
1015 aNewSeries[
i],
"values-last");
1017 xDSContainer->setDataSeries( aNewSeries );
1020 catch(
const uno::Exception&)
1028 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1032 uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
1052 xProp->setPropertyValue(
"HasMainTitle",
uno::Any(
true) );
1054 uno::Reference< drawing::XShape > xTitleShape = xDoc->getTitle();
1064 xProp->setPropertyValue(
"HasSubTitle",
uno::Any(
true) );
1066 uno::Reference< drawing::XShape > xTitleShape = xDoc->getSubTitle();
1090 !lcl_SpecialHandlingForDonutChartNeeded(
1105 pContext = pTableContext;
1113 uno::Reference< drawing::XDrawPageSupplier > xSupp( xDoc, uno::UNO_QUERY );
1136 const OUString & rChartTypeServiceName
1140 SAL_WARN_IF( !xDoc.is(),
"xmloff.chart",
"No valid document!" );
1146 xNewDoc->setFirstDiagram(
nullptr );
1147 uno::Reference< chart2::XTitled > xTitled( xNewDoc, uno::UNO_QUERY );
1149 xTitled->setTitleObject(
nullptr );
1153 if( !rChartTypeServiceName.isEmpty() && xDoc.is())
1155 uno::Reference< lang::XMultiServiceFactory > xFact( xDoc, uno::UNO_QUERY );
1158 uno::Reference< chart::XDiagram > xDia( xFact->createInstance( rChartTypeServiceName ), uno::UNO_QUERY );
1160 xDoc->setDiagram( xDia );
1167 uno::Reference< drawing::XShape > xTitleShape ) :
1169 mrImportHelper( rImpHelper ),
1171 mxTitleShape(
std::move( xTitleShape ))
1179 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1181 css::awt::Point aPosition;
1182 bool bHasXPosition=
false;
1183 bool bHasYPosition=
false;
1187 switch (aIter.getToken())
1192 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1193 aPosition.X, aIter.toView() );
1194 bHasXPosition =
true;
1200 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1201 aPosition.Y, aIter.toView() );
1202 bHasYPosition =
true;
1215 if( bHasXPosition && bHasYPosition )
1218 uno::Reference<beans::XPropertySet> xProp(
mxTitleShape, uno::UNO_QUERY);
1225 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
rtl::Reference< ::chart::DataSeries > m_xSeries
void setDataProvider(uno::Reference< chart2::XChartDocument > const &xChartDoc, OUString const &sDataPilotSource)
static void lcl_ApplyDataFromRectangularRangeToDiagram(const uno::Reference< chart2::XChartDocument > &xNewDoc, const OUString &rRectangularRange, css::chart::ChartDataRowSource eDataRowSource, bool bRowHasLabels, bool bColHasLabels, bool bSwitchOnLabelsAndCategoriesForOwnData, std::u16string_view sColTrans, std::u16string_view sRowTrans)
static bool lcl_hasServiceName(Reference< lang::XMultiServiceFactory > const &xFactory, OUString const &rServiceName)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
OUString msDataPilotSource
void MergeSeriesForStockChart()
OUString maChartTypeServiceName
css::uno::Reference< css::drawing::XShapes > mxDrawPage
css::awt::Size maChartSize
bool m_bHasRangeAtPlotArea
css::chart::ChartDataRowSource meDataRowSource
OUString msCategoriesAddress
void InitChart(const OUString &rChartTypeServiceName)
@descr This method bundles some settings to the chart model and executes them with a locked controlle...
bool mbAllRangeAddressesAvailable
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
SchXMLChartContext(SchXMLImportHelper &rImpHelper, SvXMLImport &rImport)
OUString m_aXLinkHRefAttributeToIndicateDataProvider
tSchXMLLSequencesPerIndex maLSequencesPerIndex
SchXMLImportHelper & mrImportHelper
virtual ~SchXMLChartContext() override
SeriesDefaultsAndStyles maSeriesDefaultsAndStyles
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Import the content of the data-table (XML_DATA_TABLE) element.
With this class you can import a <chart:chart> element containing its data as <table:table> element o...
const css::uno::Reference< css::chart::XChartDocument > & GetChartDocument() const
SvXMLStylesContext * GetAutoStylesContext() const
void FillAutoStyle(const OUString &rAutoStyleName, const css::uno::Reference< css::beans::XPropertySet > &rProp)
Fill in the autostyle.
static void initSeriesPropertySets(SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles, const css::uno::Reference< css::frame::XModel > &xChartModel)
static void setDefaultsToSeries(SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles)
static void switchSeriesLinesOff(::std::vector< DataRowPointStyle > &rSeriesStyleVector)
static void setStylesToSeries(SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles, const SvXMLStylesContext *pStylesCtxt, const SvXMLStyleContext *&rpStyle, OUString &rCurrStyleName, const SchXMLImportHelper &rImportHelper, const SvXMLImport &rImport, bool bIsStockChart, tSchXMLLSequencesPerIndex &rInOutLSequencesPerIndex)
static void setStylesToRegressionCurves(SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles, const SvXMLStylesContext *pStylesCtxt, const SvXMLStyleContext *&rpStyle, OUString const &rCurrStyleName)
static void setStylesToStatisticsObjects(SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles, const SvXMLStylesContext *pStylesCtxt, const SvXMLStyleContext *&rpStyle, OUString &rCurrStyleName)
static void setStylesToDataPoints(SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles, const SvXMLStylesContext *pStylesCtxt, const SvXMLStyleContext *&rpStyle, OUString &rCurrStyleName, const SchXMLImportHelper &rImportHelper, const SvXMLImport &rImport, bool bIsStockChart, bool bIsDonutChart, bool bSwitchOffLinesForScatter)
static ::std::map< css::uno::Reference< css::chart2::XDataSeries >, sal_Int32 > getDataSeriesIndexMapFromDiagram(const css::uno::Reference< css::chart2::XDiagram > &xDiagram)
void setRowPermutation(const css::uno::Sequence< sal_Int32 > &rPermutation)
void setColumnPermutation(const css::uno::Sequence< sal_Int32 > &rPermutation)
static void applyTableToInternalDataProvider(const SchXMLTable &rTable, const css::uno::Reference< css::chart2::XChartDocument > &xChartDoc)
static void switchRangesFromOuterToInternalIfNecessary(const SchXMLTable &rTable, const tSchXMLLSequencesPerIndex &rLSequencesPerIndex, const css::uno::Reference< css::chart2::XChartDocument > &xChartDoc, css::chart::ChartDataRowSource eDataRowSource)
This function reorders local data to fit the correct data structure.
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
SchXMLTitleContext(SchXMLImportHelper &rImpHelper, SvXMLImport &rImport, OUString &rTitle, css::uno::Reference< css::drawing::XShape > xTitleShape)
css::uno::Reference< css::drawing::XShape > mxTitleShape
SchXMLImportHelper & mrImportHelper
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual ~SchXMLTitleContext() override
This class deliberately does not support XWeak, to improve performance when loading large documents.
SvXMLImport & GetImport()
static SvXMLShapeContext * CreateGroupChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape=false)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
Reference< XSingleServiceFactory > xFactory
Sequence< OUString > aServiceNames
tools::SvRef< SvBaseLink > xSink
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
constexpr OUStringLiteral aData
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
css::uno::Any maStackedDefault
css::uno::Any maLinesOnProperty
::std::vector< DataRowPointStyle > maSeriesStyleVector
css::uno::Any maDeepDefault
css::uno::Any maStackedBarsConnectedDefault
css::uno::Any maPercentDefault
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)
constexpr sal_uInt16 XML_NAMESPACE_CHART
constexpr sal_uInt16 XML_NAMESPACE_OOO