28 #include <osl/diagnose.h>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/chart/XChartDocument.hpp>
42 #include <com/sun/star/chart/XDiagram.hpp>
43 #include <com/sun/star/xml/sax/XAttributeList.hpp>
44 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
45 #include <com/sun/star/drawing/XDrawPage.hpp>
46 #include <com/sun/star/chart/ChartDataRowSource.hpp>
47 #include <com/sun/star/embed/Aspects.hpp>
48 #include <com/sun/star/embed/XVisualObject.hpp>
50 #include <com/sun/star/chart2/XChartDocument.hpp>
51 #include <com/sun/star/chart2/data/XDataSink.hpp>
52 #include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
53 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
54 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
55 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
56 #include <com/sun/star/chart2/XTitled.hpp>
58 #include <com/sun/star/container/XChild.hpp>
59 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
69 void lcl_setRoleAtLabeledSequence(
70 const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq,
71 const OUString &rRole )
74 uno::Reference< chart2::data::XDataSequence > xValues( xLSeq->getValues());
77 uno::Reference< beans::XPropertySet > xProp( xValues, uno::UNO_QUERY );
83 void lcl_MoveDataToCandleStickSeries(
84 const uno::Reference< chart2::data::XDataSource > & xDataSource,
85 const uno::Reference< chart2::XDataSeries > & xDestination,
86 const OUString & rRole )
90 uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledSeq(
91 xDataSource->getDataSequences());
92 if( aLabeledSeq.hasElements())
94 lcl_setRoleAtLabeledSequence( aLabeledSeq[0], rRole );
97 uno::Reference< chart2::data::XDataSource > xSource( xDestination, uno::UNO_QUERY_THROW );
99 uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > >
aData( xSource->getDataSequences());
101 aData[
aData.getLength() - 1 ] = aLabeledSeq[0];
102 uno::Reference< chart2::data::XDataSink >
xSink( xDestination, uno::UNO_QUERY_THROW );
103 xSink->setData( aData );
106 catch(
const uno::Exception&)
108 TOOLS_WARN_EXCEPTION(
"xmloff.chart",
"Exception caught while moving data to candlestick series" );
112 void lcl_setRoleAtFirstSequence(
113 const uno::Reference< chart2::XDataSeries > & xSeries,
114 const OUString & rRole )
116 uno::Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
119 uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > >
aSeq( xSource->getDataSequences());
120 if(
aSeq.hasElements())
121 lcl_setRoleAtLabeledSequence( aSeq[0], rRole );
125 void lcl_removeEmptyChartTypeGroups(
const uno::Reference< chart2::XChartDocument > & xDoc )
130 uno::Reference< chart2::XDiagram > xDia( xDoc->getFirstDiagram());
137 sal_Int32 nRemainingGroups = 0;
138 uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDia, uno::UNO_QUERY_THROW );
139 const uno::Sequence< uno::Reference< chart2::XCoordinateSystem > >
140 aCooSysSeq( xCooSysCnt->getCoordinateSystems());
141 for(
auto const & i : aCooSysSeq )
143 uno::Reference< chart2::XChartTypeContainer > xCTCnt( i, uno::UNO_QUERY_THROW );
144 nRemainingGroups += xCTCnt->getChartTypes().getLength();
148 for( sal_Int32 nI = aCooSysSeq.getLength(); nI-- && (nRemainingGroups > 1); )
150 uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nI], uno::UNO_QUERY_THROW );
151 uno::Sequence< uno::Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
152 for( sal_Int32 nJ=aCTSeq.getLength(); nJ-- && (nRemainingGroups > 1); )
154 uno::Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nJ], uno::UNO_QUERY_THROW );
155 if( !xDSCnt->getDataSeries().hasElements() )
158 xCTCnt->removeChartType( aCTSeq[nJ] );
164 catch(
const uno::Exception&)
170 uno::Sequence< sal_Int32 > lcl_getNumberSequenceFromString(
const OUString& rStr,
bool bAddOneToEachOldIndex )
175 ::std::vector< sal_Int32 > aVec;
176 sal_Int32 nLastPos = 0;
180 nPos = rStr.indexOf( aSpace, nLastPos );
181 if( nPos > nLastPos )
183 aVec.push_back( rStr.copy( nLastPos, (nPos - nLastPos) ).toInt32() );
190 rStr.getLength() > nLastPos )
192 aVec.push_back( rStr.copy( nLastPos ).toInt32() );
195 const sal_Int32 nVecSize = aVec.size();
196 uno::Sequence< sal_Int32 >
aSeq( nVecSize );
198 if(!bAddOneToEachOldIndex)
200 sal_Int32* pSeqArr =
aSeq.getArray();
201 for( nPos = 0; nPos < nVecSize; ++nPos )
203 pSeqArr[ nPos ] = aVec[ nPos ];
206 else if( bAddOneToEachOldIndex )
208 aSeq.realloc( nVecSize+1 );
211 sal_Int32* pSeqArr =
aSeq.getArray();
212 for( nPos = 0; nPos < nVecSize; ++nPos )
214 pSeqArr[ nPos+1 ] = aVec[ nPos ]+1;
226 mrImportHelper( rImpHelper ),
227 m_bHasRangeAtPlotArea( false ),
228 m_bHasTableElement( false ),
229 mbAllRangeAddressesAvailable( true ),
230 mbColHasLabels( false ),
231 mbRowHasLabels( false ),
232 meDataRowSource(
chart::ChartDataRowSource_COLUMNS ),
233 mbIsStockChart( false )
242 const uno::Sequence<OUString>
aServiceNames(xFactory->getAvailableServiceNames());
247 static void lcl_setDataProvider(uno::Reference<chart2::XChartDocument>
const & xChartDoc, OUString
const & sDataPilotSource)
254 uno::Reference<container::XChild> xChild(xChartDoc, uno::UNO_QUERY);
255 uno::Reference<chart2::data::XDataReceiver> xDataReceiver(xChartDoc, uno::UNO_QUERY);
256 if (xChild.is() && xDataReceiver.is())
258 bool bHasOwnData =
true;
263 if (!xChartDoc->getDataProvider().is())
265 bool bHasDataPilotSource = !sDataPilotSource.isEmpty();
266 OUString aDataProviderServiceName(
"com.sun.star.chart2.data.DataProvider");
267 if (bHasDataPilotSource)
268 aDataProviderServiceName =
"com.sun.star.chart2.data.PivotTableDataProvider";
276 if (bHasDataPilotSource)
279 xPivotTableDataProvider->setPivotTableName(sDataPilotSource);
280 xDataReceiver->attachDataProvider(xProvider);
281 bHasOwnData = !xPivotTableDataProvider->hasPivotTable();
285 xDataReceiver->attachDataProvider(xProvider);
296 if (bHasOwnData && ! xChartDoc->hasInternalDataProvider())
297 xChartDoc->createInternalDataProvider(
false);
300 catch (
const uno::Exception &)
307 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
312 SAL_WARN_IF(!xVisualObject.is(),
"xmloff.chart",
"need xVisualObject for page size");
313 if( xVisualObject.is() )
314 maChartSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
316 OUString sAutoStyleName;
317 OUString aOldChartTypeName;
318 bool bHasAddin =
false;
322 switch( aIter.getToken() )
332 OUString aValue = aIter.toString();
334 sal_uInt16 nClassPrefix =
336 aValue, &sClassName );
344 switch( eChartTypeEnum )
359 aOldChartTypeName = sClassName;
378 sAutoStyleName = aIter.toString();
393 uno::Reference<chart2::XChartDocument> xNewDoc(xDoc, uno::UNO_QUERY);
397 if( aOldChartTypeName.isEmpty() )
399 SAL_WARN(
"xmloff.chart",
"need a charttype to create a diagram" );
407 if( xVisualObject.is() )
408 xVisualObject->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT,
maChartSize );
421 xDocProp->getPropertyValue(
"BaseDiagram") >>= aOldChartTypeName;
423 xDocProp->setPropertyValue(
"RefreshAddInAllowed", uno::makeAny(
false) );
425 catch(
const uno::Exception&)
427 TOOLS_WARN_EXCEPTION(
"xmloff.chart",
"Exception during import SchXMLChartContext::StartElement" );
440 struct NewDonutSeries
442 css::uno::Reference< css::chart2::XDataSeries >
m_xSeries;
444 sal_Int32 mnAttachedAxis;
446 ::std::vector< OUString > m_aSeriesStyles;
447 ::std::vector< OUString > m_aPointStyles;
449 NewDonutSeries(
const css::uno::Reference< css::chart2::XDataSeries >& xSeries, sal_Int32 nPointCount )
450 : m_xSeries( xSeries )
451 , mnAttachedAxis( 1 )
453 m_aPointStyles.resize(nPointCount);
454 m_aSeriesStyles.resize(nPointCount);
457 void setSeriesStyleNameToPoint(
const OUString& rStyleName, sal_Int32 nPointIndex )
459 SAL_WARN_IF(nPointIndex >= static_cast<sal_Int32>(m_aSeriesStyles.size()),
"xmloff.chart",
"donut point <-> series count mismatch");
460 if( nPointIndex < static_cast<sal_Int32>(m_aSeriesStyles.size()) )
461 m_aSeriesStyles[nPointIndex]=rStyleName;
464 void setPointStyleNameToPoint(
const OUString& rStyleName, sal_Int32 nPointIndex )
466 SAL_WARN_IF(nPointIndex >= static_cast<sal_Int32>(m_aPointStyles.size()),
"xmloff.chart",
"donut point <-> series count mismatch");
467 if( nPointIndex < static_cast<sal_Int32>(m_aPointStyles.size()) )
468 m_aPointStyles[nPointIndex]=rStyleName;
471 ::std::vector< DataRowPointStyle > creatStyleVector()
473 ::std::vector< DataRowPointStyle > aRet;
476 , m_xSeries, -1, 1, msStyleName, mnAttachedAxis );
477 aRet.push_back( aSeriesStyle );
479 sal_Int32 nPointIndex=0;
480 for (
auto const& pointStyle : m_aPointStyles)
483 , m_xSeries, nPointIndex, 1, pointStyle, mnAttachedAxis );
484 if( nPointIndex < static_cast<sal_Int32>(m_aSeriesStyles.size()) )
486 aPointStyle.msSeriesStyleNameForDonuts = m_aSeriesStyles[nPointIndex];
488 if( !aPointStyle.msSeriesStyleNameForDonuts.isEmpty()
489 || !aPointStyle.msStyleName.isEmpty() )
490 aRet.push_back( aPointStyle );
498 void lcl_swapPointAndSeriesStylesForDonutCharts( ::std::vector< DataRowPointStyle >& rStyleVector
499 , const ::std::map< css::uno::Reference< css::chart2::XDataSeries> , sal_Int32 >& rSeriesMap )
503 ::std::map< css::uno::Reference<
504 css::chart2::XDataSeries >, sal_Int32 > aSeriesMap(rSeriesMap);
505 sal_Int32 nOldSeriesCount = 0;
507 sal_Int32 nMaxOldSeriesIndex = 0;
508 sal_Int32 nOldSeriesIndex = 0;
509 for (
auto const& style : rStyleVector)
513 aStyle.m_xSeries.is() )
515 nMaxOldSeriesIndex = nOldSeriesIndex;
517 if( aSeriesMap.end() == aSeriesMap.find(aStyle.m_xSeries) )
518 aSeriesMap[aStyle.m_xSeries] = nOldSeriesIndex;
523 nOldSeriesCount = nMaxOldSeriesIndex+1;
527 ::std::map< Reference< chart2::XDataSeries >, sal_Int32 >::const_iterator aSeriesMapEnd( aSeriesMap.end() );
530 ::std::vector< NewDonutSeries > aNewSeriesVector;
532 ::std::map< sal_Int32, Reference< chart2::XDataSeries > > aIndexSeriesMap;
533 for (
auto const& series : aSeriesMap)
534 aIndexSeriesMap[series.second] = series.first;
536 for (
auto const& indexSeries : aIndexSeriesMap)
537 aNewSeriesVector.emplace_back(indexSeries.second,nOldSeriesCount );
541 for (
auto const& style : rStyleVector)
546 auto aSeriesMapIt = aSeriesMap.find( aStyle.m_xSeries );
547 if( aSeriesMapIt != aSeriesMapEnd && aSeriesMapIt->second < static_cast<sal_Int32>(aNewSeriesVector.size()) )
548 aNewSeriesVector[aSeriesMapIt->second].mnAttachedAxis = aStyle.mnAttachedAxis;
553 for (
auto const& style : rStyleVector)
558 auto aSeriesMapIt = aSeriesMap.find(aStyle.m_xSeries);
559 if( aSeriesMapEnd != aSeriesMapIt )
561 sal_Int32 nNewPointIndex = aSeriesMapIt->second;
563 for (
auto & newSeries : aNewSeriesVector)
564 newSeries.setSeriesStyleNameToPoint( aStyle.msStyleName, nNewPointIndex );
570 for (
auto const& style : rStyleVector)
575 auto aSeriesMapIt = aSeriesMap.find(aStyle.m_xSeries);
576 if( aSeriesMapEnd != aSeriesMapIt )
578 sal_Int32 nNewPointIndex = aSeriesMapIt->second;
579 sal_Int32 nNewSeriesIndex = aStyle.m_nPointIndex;
580 sal_Int32 nRepeatCount = aStyle.m_nPointRepeat;
582 while( nRepeatCount && (nNewSeriesIndex>=0) && (nNewSeriesIndex< static_cast<sal_Int32>(aNewSeriesVector.size()) ) )
584 NewDonutSeries& rNewSeries( aNewSeriesVector[nNewSeriesIndex] );
585 rNewSeries.setPointStyleNameToPoint( aStyle.msStyleName, nNewPointIndex );
595 rStyleVector.clear();
597 for (
auto & newSeries : aNewSeriesVector)
599 ::std::vector< DataRowPointStyle > aVector( newSeries.creatStyleVector() );
600 rStyleVector.insert(rStyleVector.end(),aVector.begin(),aVector.end());
604 bool lcl_SpecialHandlingForDonutChartNeeded(
605 std::u16string_view rServiceName,
608 bool bResult =
false;
609 if( rServiceName == u
"com.sun.star.chart2.DonutChartType" )
619 const uno::Reference< chart2::XChartDocument >& xNewDoc
620 ,
const OUString& rRectangularRange
621 , css::chart::ChartDataRowSource eDataRowSource
622 ,
bool bRowHasLabels,
bool bColHasLabels
623 ,
bool bSwitchOnLabelsAndCategoriesForOwnData
624 ,
const OUString& sColTrans
625 ,
const OUString& sRowTrans )
630 uno::Reference< chart2::XDiagram > xNewDia( xNewDoc->getFirstDiagram());
631 uno::Reference< chart2::data::XDataProvider > xDataProvider( xNewDoc->getDataProvider() );
632 if( !xNewDia.is() || !xDataProvider.is() )
635 bool bFirstCellAsLabel =
636 (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bRowHasLabels : bColHasLabels;
638 (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bColHasLabels : bRowHasLabels;
640 if( bSwitchOnLabelsAndCategoriesForOwnData )
642 bFirstCellAsLabel =
true;
643 bHasCateories =
true;
646 uno::Sequence< beans::PropertyValue > aArgs( 3 );
647 aArgs[0] = beans::PropertyValue(
648 "CellRangeRepresentation",
649 -1, uno::makeAny( rRectangularRange ),
650 beans::PropertyState_DIRECT_VALUE );
651 aArgs[1] = beans::PropertyValue(
653 -1, uno::makeAny( eDataRowSource ),
654 beans::PropertyState_DIRECT_VALUE );
655 aArgs[2] = beans::PropertyValue(
657 -1, uno::makeAny( bFirstCellAsLabel ),
658 beans::PropertyState_DIRECT_VALUE );
660 if( !sColTrans.isEmpty() || !sRowTrans.isEmpty() )
662 aArgs.realloc( aArgs.getLength() + 1 );
663 aArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
665 -1, uno::makeAny( !sColTrans.isEmpty()
666 ? lcl_getNumberSequenceFromString( sColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() )
667 : lcl_getNumberSequenceFromString( sRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ),
668 beans::PropertyState_DIRECT_VALUE );
673 OUString aChartOleObjectName;
678 utl::MediaDescriptor::const_iterator aIt(
679 aMediaDescriptor.find( OUString(
"HierarchicalDocumentName" )));
680 if( aIt != aMediaDescriptor.end() )
682 aChartOleObjectName = (*aIt).second.get< OUString >();
685 if( !aChartOleObjectName.isEmpty() )
687 aArgs.realloc( aArgs.getLength() + 1 );
688 aArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
689 "ChartOleObjectName",
690 -1, uno::makeAny( aChartOleObjectName ),
691 beans::PropertyState_DIRECT_VALUE );
695 uno::Reference< chart2::data::XDataSource > xDataSource(
696 xDataProvider->createDataSource( aArgs ));
698 aArgs.realloc( aArgs.getLength() + 2 );
699 aArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 2 ] = beans::PropertyValue(
701 -1, uno::makeAny( bHasCateories ),
702 beans::PropertyState_DIRECT_VALUE );
703 aArgs[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
705 -1, uno::makeAny(
false ),
706 beans::PropertyState_DIRECT_VALUE );
708 xNewDia->setDiagramData( xDataSource, aArgs );
714 uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
715 uno::Reference< chart2::XChartDocument > xNewDoc( xDoc, uno::UNO_QUERY );
721 uno::Reference< beans::XPropertySet > xTitleProp( xDoc->getTitle(), uno::UNO_QUERY );
728 catch(
const beans::UnknownPropertyException&)
730 SAL_WARN(
"xmloff.chart",
"Property String for Title not available" );
736 uno::Reference< beans::XPropertySet > xTitleProp( xDoc->getSubTitle(), uno::UNO_QUERY );
743 catch(
const beans::UnknownPropertyException&)
745 SAL_WARN(
"xmloff.chart",
"Property String for Title not available" );
752 lcl_removeEmptyChartTypeGroups( xNewDoc );
755 uno::Reference< chart::XDiagram > xDiagram( xDoc->getDiagram() );
756 uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
770 bool bSpecialHandlingForDonutChart = lcl_SpecialHandlingForDonutChartNeeded(
777 bool bHasOwnData =
false;
787 if( xNewDoc->hasInternalDataProvider())
793 bHasOwnData = !bSwitchSuccessful;
798 else if( bHasOwnData )
800 xNewDoc->createInternalDataProvider(
false );
805 bool bSwitchRangesFromOuterToInternalIfNecessary =
false;
816 if( xNewDoc->hasInternalDataProvider() )
820 bool bOldFileWithOwnDataFromRows = (bOlderThan2_3 && bHasOwnData && (
meDataRowSource==chart::ChartDataRowSource_ROWS));
823 !bOldFileWithOwnDataFromRows )
827 bSwitchRangesFromOuterToInternalIfNecessary =
true;
836 if( bOlderThan2_3 && xDiaProp.is() )
837 xDiaProp->setPropertyValue(
"IncludeHiddenCells",uno::makeAny(
false));
843 catch(
const uno::Exception&)
846 TOOLS_WARN_EXCEPTION(
"xmloff.chart",
"Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram try to fallback to internal data" );
851 if( !xNewDoc->hasInternalDataProvider() )
853 xNewDoc->createInternalDataProvider(
false );
859 catch(
const uno::Exception&)
861 TOOLS_WARN_EXCEPTION(
"xmloff.chart",
"Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram fallback to internal data failed also" );
870 SAL_WARN(
"xmloff.chart",
"Must not get here" );
875 if( bSpecialHandlingForDonutChart )
877 uno::Reference< chart2::XDiagram > xNewDiagram( xNewDoc->getFirstDiagram() );
886 bool bSwitchOffLinesForScatter =
false;
888 bool bLinesOn =
true;
893 bSwitchOffLinesForScatter =
true;
903 OUString sCurrStyleName;
909 if( !bSpecialHandlingForDonutChart )
918 pStyle, sCurrStyleName );
922 pStyle, sCurrStyleName );
927 if( bSwitchRangesFromOuterToInternalIfNecessary )
929 if( xNewDoc->hasInternalDataProvider() )
942 xProp->setPropertyValue(
"RefreshAddInAllowed", uno::makeAny(
true) );
951 uno::Reference< chart2::XChartDocument > xDoc( xOldDoc, uno::UNO_QUERY_THROW );
952 uno::Reference< chart2::XDiagram > xDiagram( xDoc->getFirstDiagram());
956 bool bHasJapaneseCandlestick =
true;
957 uno::Reference< chart2::XDataSeriesContainer > xDSContainer;
958 uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
959 const uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
960 for(
const auto& rCooSys : aCooSysSeq )
962 uno::Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY_THROW );
963 uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
964 auto pChartType = std::find_if(aChartTypes.begin(), aChartTypes.end(),
965 [](
const auto& rChartType) {
return rChartType->getChartType() ==
"com.sun.star.chart2.CandleStickChartType"; });
966 if (pChartType != aChartTypes.end())
968 xDSContainer.set( *pChartType, uno::UNO_QUERY_THROW );
969 uno::Reference< beans::XPropertySet > xCTProp( *pChartType, uno::UNO_QUERY_THROW );
970 xCTProp->getPropertyValue(
"Japanese") >>= bHasJapaneseCandlestick;
974 if( xDSContainer.is())
978 uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSContainer->getDataSeries());
979 const sal_Int32 nSeriesCount( aSeriesSeq.getLength());
980 const sal_Int32 nSeriesPerCandleStick = bHasJapaneseCandlestick ? 4: 3;
981 sal_Int32 nCandleStickCount = nSeriesCount / nSeriesPerCandleStick;
982 OSL_ASSERT( nSeriesPerCandleStick * nCandleStickCount == nSeriesCount );
983 uno::Sequence< uno::Reference< chart2::XDataSeries > > aNewSeries( nCandleStickCount );
984 for( sal_Int32
i=0;
i<nCandleStickCount; ++
i )
986 sal_Int32 nSeriesIndex =
i*nSeriesPerCandleStick;
987 if( bHasJapaneseCandlestick )
990 lcl_setRoleAtFirstSequence( aSeriesSeq[ nSeriesIndex ],
"values-first");
991 aNewSeries[
i] = aSeriesSeq[ nSeriesIndex ];
993 lcl_MoveDataToCandleStickSeries(
994 uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
995 aNewSeries[
i],
"values-min");
1000 lcl_setRoleAtFirstSequence( aSeriesSeq[ nSeriesIndex ],
"values-min");
1001 aNewSeries[
i] = aSeriesSeq[ nSeriesIndex ];
1004 lcl_MoveDataToCandleStickSeries(
1005 uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
1006 aNewSeries[
i],
"values-max");
1008 lcl_MoveDataToCandleStickSeries(
1009 uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
1010 aNewSeries[i],
"values-last");
1012 xDSContainer->setDataSeries( aNewSeries );
1015 catch(
const uno::Exception&)
1023 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1027 uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
1047 xProp->setPropertyValue(
"HasMainTitle", uno::makeAny(
true) );
1049 uno::Reference< drawing::XShape > xTitleShape = xDoc->getTitle();
1059 xProp->setPropertyValue(
"HasSubTitle", uno::makeAny(
true) );
1061 uno::Reference< drawing::XShape > xTitleShape = xDoc->getSubTitle();
1082 !lcl_SpecialHandlingForDonutChartNeeded(
1097 pContext = pTableContext;
1105 uno::Reference< drawing::XDrawPageSupplier > xSupp( xDoc, uno::UNO_QUERY );
1128 const OUString & rChartTypeServiceName
1132 SAL_WARN_IF( !xDoc.is(),
"xmloff.chart",
"No valid document!" );
1138 xNewDoc->setFirstDiagram(
nullptr );
1139 uno::Reference< chart2::XTitled > xTitled( xNewDoc, uno::UNO_QUERY );
1141 xTitled->setTitleObject(
nullptr );
1145 if( !rChartTypeServiceName.isEmpty() && xDoc.is())
1147 uno::Reference< lang::XMultiServiceFactory > xFact( xDoc, uno::UNO_QUERY );
1150 uno::Reference< chart::XDiagram > xDia( xFact->createInstance( rChartTypeServiceName ), uno::UNO_QUERY );
1152 xDoc->setDiagram( xDia );
1159 uno::Reference< drawing::XShape >
const & xTitleShape ) :
1161 mrImportHelper( rImpHelper ),
1163 mxTitleShape( xTitleShape )
1171 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1173 css::awt::Point aPosition;
1174 bool bHasXPosition=
false;
1175 bool bHasYPosition=
false;
1179 switch (aIter.getToken())
1185 aPosition.X, aIter.toView() );
1186 bHasXPosition =
true;
1193 aPosition.Y, aIter.toView() );
1194 bHasYPosition =
true;
1207 if( bHasXPosition && bHasYPosition )
1210 uno::Reference<beans::XPropertySet> xProp(
mxTitleShape, uno::UNO_QUERY);
1217 const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
tools::SvRef< SvBaseLink > xSink
bool convertMeasureToCore(sal_Int32 &rValue, std::u16string_view rString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32) const
convert string to measure with meCoreMeasureUnit, using optional min and max values ...
OUString m_aXLinkHRefAttributeToIndicateDataProvider
constexpr sal_uInt16 XML_NAMESPACE_CHART
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
static void switchSeriesLinesOff(::std::vector< DataRowPointStyle > &rSeriesStyleVector)
SvXMLStylesContext * GetAutoStylesContext() const
SchXMLImportHelper & mrImportHelper
css::chart::ChartDataRowSource meDataRowSource
SvXMLImport & GetImport()
constexpr sal_uInt16 XML_NAMESPACE_OOO
SvXMLNamespaceMap & GetNamespaceMap()
Sequence< OUString > aServiceNames
void setRowPermutation(const css::uno::Sequence< sal_Int32 > &rPermutation)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void FillAutoStyle(const OUString &rAutoStyleName, const css::uno::Reference< css::beans::XPropertySet > &rProp)
Fill in the autostyle.
css::uno::Any maStackedDefault
static void setDefaultsToSeries(SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles)
css::awt::Size maChartSize
virtual ~SchXMLTitleContext() override
void InitChart(const OUString &rChartTypeServiceName)
This method bundles some settings to the chart model and executes them with a locked controller...
tSchXMLLSequencesPerIndex maLSequencesPerIndex
static void setStylesToStatisticsObjects(SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles, const SvXMLStylesContext *pStylesCtxt, const SvXMLStyleContext *&rpStyle, OUString &rCurrStyleName)
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 ...
#define XMLOFF_WARN_UNKNOWN(area, rIter)
sal_uInt16 GetKeyByAttrValueQName(const OUString &rAttrName, OUString *pLocalName) const
SchXMLImportHelper & mrImportHelper
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
css::uno::Any maStackedBarsConnectedDefault
constexpr OUStringLiteral aData
#define TOOLS_WARN_EXCEPTION(area, stream)
SchXMLChartContext(SchXMLImportHelper &rImpHelper, SvXMLImport &rImport)
static void initSeriesPropertySets(SeriesDefaultsAndStyles &rSeriesDefaultsAndStyles, const css::uno::Reference< css::frame::XModel > &xChartModel)
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)
css::uno::Any maLinesOnProperty
static bool lcl_hasServiceName(Reference< lang::XMultiServiceFactory > const &xFactory, OUString const &rServiceName)
bool m_bHasRangeAtPlotArea
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)
With this class you can import a
element containing its data as element o...
css::uno::Reference< css::drawing::XShape > mxTitleShape
This class deliberately does not support XWeak, to improve performance when loading large documents...
#define TOOLS_INFO_EXCEPTION(area, stream)
const css::uno::Reference< css::chart::XChartDocument > & GetChartDocument() const
static::std::map< css::uno::Reference< css::chart2::XDataSeries >, sal_Int32 > getDataSeriesIndexMapFromDiagram(const css::uno::Reference< css::chart2::XDiagram > &xDiagram)
::std::vector< DataRowPointStyle > maSeriesStyleVector
Any makeAny(Color const &value)
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.
#define SAL_WARN_IF(condition, area, stream)
css::uno::Any maPercentDefault
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Handling of tokens in XML:
css::uno::Any maDeepDefault
#define XML_ELEMENT(prefix, name)
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 maChartTypeServiceName
const SvXMLUnitConverter & GetMM100UnitConverter() const
const css::uno::Reference< css::frame::XModel > & GetModel() const
Sequence< sal_Int8 > aSeq
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
css::uno::Reference< css::drawing::XShapes > mxDrawPage
OUString msCategoriesAddress
bool mbAllRangeAddressesAvailable
SeriesDefaultsAndStyles maSeriesDefaultsAndStyles
#define SAL_WARN(area, stream)
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
virtual ~SchXMLChartContext() override
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)
static void lcl_setDataProvider(uno::Reference< chart2::XChartDocument > const &xChartDoc, OUString const &sDataPilotSource)
void MergeSeriesForStockChart()
void setColumnPermutation(const css::uno::Sequence< sal_Int32 > &rPermutation)
static void applyTableToInternalDataProvider(const SchXMLTable &rTable, const css::uno::Reference< css::chart2::XChartDocument > &xChartDoc)
OUString msDataPilotSource
Reference< chart2::XDataSeries > m_xSeries
static void lcl_ApplyDataFromRectangularRangeToDiagram(const uno::Reference< chart2::XChartDocument > &xNewDoc, const OUString &rRectangularRange, css::chart::ChartDataRowSource eDataRowSource, bool bRowHasLabels, bool bColHasLabels, bool bSwitchOnLabelsAndCategoriesForOwnData, const OUString &sColTrans, const OUString &sRowTrans)
SchXMLTitleContext(SchXMLImportHelper &rImpHelper, SvXMLImport &rImport, OUString &rTitle, css::uno::Reference< css::drawing::XShape > const &xTitleShape)