28#include <com/sun/star/util/XCloneable.hpp>
35using ::com::sun::star::uno::Reference;
36using ::com::sun::star::uno::Sequence;
61 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSequencesVec;
68 bool bCategoriesUsed =
false;
69 bool bSetXValues =
aData.size()>1;
74 if( bHasCategories && ! bCategoriesUsed )
76 xCategories = labelData;
79 SetRole( xCategories->getValues(),
"categories");
80 if( bUseCategoriesAsX )
83 bCategoriesUsed =
true;
85 else if( !xValuesX.is() && bSetXValues )
89 SetRole( xValuesX->getValues(),
"values-x");
93 aSequencesVec.push_back( labelData );
95 SetRole( labelData->getValues(),
"values-y");
98 catch(
const uno::Exception & )
105 std::vector< rtl::Reference< DataSeries > > aSeriesVec;
106 aSeriesVec.reserve( aSequencesVec.size());
111 std::size_t nSeriesIndex = 0;
112 for (
auto const& elem : aSequencesVec)
114 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData;
116 if( nSeriesIndex && xCloneable.is() )
117 xClonedXValues.set( xCloneable->createClone(), uno::UNO_QUERY );
119 aNewData.push_back( xClonedXValues );
121 aNewData.push_back(elem);
124 if( nSeriesIndex < aSeriesToReUse.size())
125 xSeries = aSeriesToReUse[nSeriesIndex];
128 assert( xSeries.is() );
129 xSeries->setData( aNewData );
131 aSeriesVec.push_back( xSeries );
135 return { { aSeriesVec }, xCategories };
145 const sal_Int32
nCount = aSeries.size();
150 std::vector< uno::Reference< data::XLabeledDataSequence > > aNewSequences;
158 if( ! xValuesX.is() ||
161 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValueSeqVec(
163 aSeries[
i]->getDataSequences2(),
"values" ));
165 aValueSeqVec.erase(
find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX ));
167 aValueSeqVec.erase(
find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesY ));
170 if( ! xValuesY.is() &&
171 aValueSeqVec.size() >
nIndex )
173 xValuesY = aValueSeqVec[
nIndex++];
175 SetRole( xValuesY->getValues(),
"values-y");
178 if( ! xValuesX.is() &&
179 aValueSeqVec.size() >
nIndex )
181 xValuesX = aValueSeqVec[
nIndex++];
183 SetRole( xValuesY->getValues(),
"values-x");
190 aNewSequences = { xValuesX, xValuesY };
194 aNewSequences = { xValuesY };
198 const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[
i]->getDataSequences2();
199 if( aSeqs.size() != aNewSequences.size() )
202 for(
auto const & j : aSeqs )
204 SAL_WARN_IF((j == xValuesY || j == xValuesX),
"chart2.template",
"All sequences should be used" );
207 aSeries[
i]->setData( aNewSequences );
210 catch(
const uno::Exception & )
223 const std::vector< rtl::Reference< DataSeries > > aSeries =
FlattenSequence( aInterpretedData.
Series );
228 if( dataSeries->getDataSequences2().size() != 2 )
231 catch(
const uno::Exception & )
static bool HasCategories(const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > &rData)
static std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > getDataSequences(const css::uno::Reference< css::chart2::data::XDataSource > &xSource)
static void SetRole(const css::uno::Reference< css::chart2::data::XDataSequence > &xSeq, const OUString &rRole)
static bool UseCategoriesAsX(const css::uno::Sequence< css::beans::PropertyValue > &rArguments)
virtual InterpretedData interpretDataSource(const css::uno::Reference< css::chart2::data::XDataSource > &xSource, const css::uno::Sequence< css::beans::PropertyValue > &aArguments, const std::vector< rtl::Reference< ::chart::DataSeries > > &aSeriesToReUse) override
Interprets the given data.
virtual InterpretedData reinterpretDataSeries(const InterpretedData &aInterpretedData) override
Re-interprets the data given in aInterpretedData while keeping the number of data series and the cate...
virtual ~XYDataInterpreter() override
virtual bool isDataCompatible(const InterpretedData &aInterpretedData) override
parses the given data and states, if a reinterpretDataSeries() call can be done without data loss.
#define DBG_UNHANDLED_EXCEPTION(...)
Sequence< PropertyValue > aArguments
#define SAL_WARN_IF(condition, area, stream)
constexpr OUStringLiteral aData
OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XLabeledDataSequence > getDataSequenceByRole(const css::uno::Reference< css::chart2::data::XDataSource > &xSource, const OUString &aRole, bool bMatchPrefix=false)
Retrieves the data sequence in the given data source that matches the given role.
OOO_DLLPUBLIC_CHARTTOOLS std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > getAllDataSequencesByRole(const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > &aDataSequences, const OUString &aRole)
Retrieves all data sequences in the given data source that match the given role prefix.
std::vector< T > FlattenSequence(const std::vector< std::vector< T > > &aSeqSeq)
std::vector< std::vector< T > > -> std::vector< T >
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
offers tooling to interpret different data sources in a structural and chart-type-dependent way.
std::vector< std::vector< rtl::Reference<::chart::DataSeries > > > Series