21#include <com/sun/star/chart2/XChartDocument.hpp>
22#include <com/sun/star/chart2/XChartTypeContainer.hpp>
23#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
24#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
25#include <com/sun/star/lang/XInitialization.hpp>
26#include <com/sun/star/lang/XMultiServiceFactory.hpp>
33using ::com::sun::star::uno::Reference;
34using ::com::sun::star::uno::Sequence;
36::std::vector< Reference< chart2::XDataSeries > >
38 const Reference< chart2::XDiagram > & xDiagram )
40 ::std::vector< Reference< chart2::XDataSeries > > aResult;
44 Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
45 xDiagram, uno::UNO_QUERY_THROW );
46 const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
47 xCooSysCnt->getCoordinateSystems());
48 for(
const auto& rCooSys : aCooSysSeq )
50 Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY_THROW );
51 const Sequence< Reference< chart2::XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
52 for(
const auto& rChartType : aChartTypeSeq )
54 Reference< chart2::XDataSeriesContainer > xDSCnt( rChartType, uno::UNO_QUERY_THROW );
55 const Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() );
56 aResult.insert( aResult.end(), aSeriesSeq.begin(), aSeriesSeq.end() );
60 catch(
const uno::Exception & )
69 const Reference< chart2::XDiagram > & xDiagram )
71 ::std::map< Reference< chart2::XDataSeries >, sal_Int32 > aRet;
76 for(
const Reference< chart2::XDataSeries >& xSeries : aSeriesVector )
80 if( aRet.end() == aRet.find(xSeries) )
89uno::Reference< chart2::XChartType > lcl_getChartTypeOfSeries(
90 const uno::Reference< chart2::XDiagram >& xDiagram
91 ,
const Reference< chart2::XDataSeries >& xSeries )
100 uno::Reference< chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
101 if( !xCooSysContainer.is())
104 const uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
105 for(
const auto& xCooSys : aCooSysList )
108 uno::Reference< chart2::XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
109 SAL_WARN_IF( !xChartTypeContainer.is(),
"xmloff.chart",
"xChartTypeContainer is NULL");
110 if( !xChartTypeContainer.is() )
112 const uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
113 for(
const auto& xChartType : aChartTypeList )
116 uno::Reference< chart2::XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
117 SAL_WARN_IF( !xDataSeriesContainer.is(),
"xmloff.chart",
"xDataSeriesContainer is NULL");
118 if( !xDataSeriesContainer.is() )
121 const uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
122 if (std::find(aSeriesList.begin(), aSeriesList.end(), xSeries) != aSeriesList.end())
131 const Reference< chart2::XDataSeries >& xSeries
132 ,
const Reference< frame::XModel >& xChartModel )
136 uno::Reference< chart2::XChartDocument > xNewDoc( xChartModel, uno::UNO_QUERY );
139 uno::Reference< chart2::XDiagram > xNewDiagram( xNewDoc->getFirstDiagram() );
140 if( xNewDiagram.is() )
142 uno::Reference< chart2::XChartType > xChartType( lcl_getChartTypeOfSeries(
143 xNewDiagram, xSeries ) );
144 if( xChartType.is() )
146 OUString aServiceName( xChartType->getChartType() );
147 if( aServiceName ==
"com.sun.star.chart2.CandleStickChartType" )
157 const uno::Reference< chart2::XDataSeries >& xSeries
158 ,
const uno::Reference< frame::XModel >& xChartModel )
160 uno::Reference< beans::XPropertySet > xRet;
166 uno::Reference< lang::XMultiServiceFactory >
xFactory( xChartModel, uno::UNO_QUERY );
169 xRet.set(
xFactory->createInstance(
"com.sun.star.comp.chart2.DataSeriesWrapper" ), uno::UNO_QUERY );
170 Reference< lang::XInitialization > xInit( xRet, uno::UNO_QUERY );
173 xInit->initialize( {
uno::Any(xSeries) });
177 catch(
const uno::Exception & )
179 TOOLS_INFO_EXCEPTION(
"xmloff.chart",
"Exception caught SchXMLSeriesHelper::createOldAPISeriesPropertySet" );
188 const uno::Reference< chart2::XDataSeries >& xSeries
189 , sal_Int32 nPointIndex
190 ,
const uno::Reference< frame::XModel >& xChartModel )
192 uno::Reference< beans::XPropertySet > xRet;
198 uno::Reference< lang::XMultiServiceFactory >
xFactory( xChartModel, uno::UNO_QUERY );
201 xRet.set(
xFactory->createInstance(
"com.sun.star.comp.chart2.DataSeriesWrapper" ), uno::UNO_QUERY );
202 Reference< lang::XInitialization > xInit( xRet, uno::UNO_QUERY );
209 catch(
const uno::Exception & )
211 TOOLS_INFO_EXCEPTION(
"xmloff.chart",
"Exception caught SchXMLSeriesHelper::createOldAPIDataPointPropertySet" );
static ::std::map< css::uno::Reference< css::chart2::XDataSeries >, sal_Int32 > getDataSeriesIndexMapFromDiagram(const css::uno::Reference< css::chart2::XDiagram > &xDiagram)
static bool isCandleStickSeries(const css::uno::Reference< css::chart2::XDataSeries > &xSeries, const css::uno::Reference< css::frame::XModel > &xChartModel)
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)
#define TOOLS_INFO_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN_IF(condition, area, stream)