28#include <com/sun/star/util/XCloneable.hpp>
34using ::com::sun::star::uno::Reference;
35using ::com::sun::star::uno::Sequence;
60 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aYValuesVector;
61 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSizeValuesVector;
67 sal_Int32 nDataSeqCount =
aData.size();
69 bool bSetXValues = bHasCategories ? ( (nDataSeqCount-1) > 2 && (nDataSeqCount-1) % 2 != 0 )
70 :( nDataSeqCount > 2 && nDataSeqCount % 2 != 0 );
72 bool bCategoriesUsed =
false;
73 bool bNextIsYValues = bHasCategories ? nDataSeqCount>2 : nDataSeqCount>1;
74 for( sal_Int32 nDataIdx = 0; nDataIdx < nDataSeqCount; ++nDataIdx )
78 if( bHasCategories && !bCategoriesUsed )
80 xCategories =
aData[nDataIdx];
83 SetRole( xCategories->getValues(),
"categories");
84 if( bUseCategoriesAsX )
87 bNextIsYValues = nDataSeqCount > 2;
90 bCategoriesUsed =
true;
92 else if( !xValuesX.is() && bSetXValues )
94 xValuesX =
aData[nDataIdx];
96 SetRole( xValuesX->getValues(),
"values-x");
98 else if( bNextIsYValues )
100 aYValuesVector.push_back(
aData[nDataIdx] );
101 if(
aData[nDataIdx].is())
103 bNextIsYValues =
false;
105 else if( !bNextIsYValues )
107 aSizeValuesVector.push_back(
aData[nDataIdx] );
108 if(
aData[nDataIdx].is())
110 bNextIsYValues = (nDataSeqCount-(nDataIdx+1)) >= 2;
113 catch(
const uno::Exception & )
120 std::size_t nSeriesIndex = 0;
121 std::vector< rtl::Reference< DataSeries > > aSeriesVec;
122 aSeriesVec.reserve( aSizeValuesVector.size());
127 for(
size_t nN = 0; nN < aSizeValuesVector.size(); ++nN, ++nSeriesIndex )
129 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData;
132 if( nN > 0 && xCloneableX.is() )
133 xClonedXValues.set( xCloneableX->createClone(), uno::UNO_QUERY );
134 aNewData.push_back( xClonedXValues );
136 if( aYValuesVector.size() > nN )
137 aNewData.push_back( aYValuesVector[nN] );
138 aNewData.push_back(aSizeValuesVector[nN]);
141 if( nSeriesIndex < aSeriesToReUse.size())
142 xSeries = aSeriesToReUse[nSeriesIndex];
145 assert( xSeries.is() );
146 xSeries->setData( aNewData );
148 aSeriesVec.push_back( xSeries );
151 return { { aSeriesVec }, xCategories };
161 const sal_Int32
nCount = aSeries.size();
166 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewSequences;
175 if( ! xValuesX.is() ||
179 std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValueSeqVec(
181 aSeries[
i]->getDataSequences2(),
"values" ));
183 aValueSeqVec.erase(
find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX ));
185 aValueSeqVec.erase(
find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesY ));
186 if( xValuesSize.is())
187 aValueSeqVec.erase(
find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesSize ));
191 if( ! xValuesSize.is() &&
192 aValueSeqVec.size() >
nIndex )
194 xValuesSize = aValueSeqVec[
nIndex++];
195 if( xValuesSize.is())
196 SetRole( xValuesSize->getValues(),
"values-size");
199 if( ! xValuesY.is() &&
200 aValueSeqVec.size() >
nIndex )
202 xValuesY = aValueSeqVec[
nIndex++];
204 SetRole( xValuesY->getValues(),
"values-y");
207 if( ! xValuesX.is() &&
208 aValueSeqVec.size() >
nIndex )
210 xValuesX = aValueSeqVec[
nIndex++];
212 SetRole( xValuesY->getValues(),
"values-x");
215 if( xValuesSize.is())
221 aNewSequences = { xValuesX, xValuesY, xValuesSize };
225 aNewSequences = { xValuesY, xValuesSize };
230 aNewSequences = { xValuesSize };
234 const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[
i]->getDataSequences2();
235 if( aSeqs.size() != aNewSequences.size() )
237#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
238 for(
auto const & j : aSeqs )
240 assert( (j == xValuesY || j == xValuesX || j == xValuesSize) &&
"All sequences should be used" );
243 aSeries[
i]->setData( aNewSequences );
246 catch(
const uno::Exception & )
258 const std::vector< rtl::Reference< DataSeries > > aSeries(
FlattenSequence( aInterpretedData.
Series ));
263 if( dataSeries->getDataSequences2().size() != 3 )
266 catch(
const uno::Exception & )
virtual bool isDataCompatible(const InterpretedData &aInterpretedData) override
parses the given data and states, if a reinterpretDataSeries() call can be done without data loss.
virtual ~BubbleDataInterpreter() override
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 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.
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)
#define DBG_UNHANDLED_EXCEPTION(...)
Sequence< PropertyValue > aArguments
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