32using ::com::sun::star::uno::Reference;
33using ::com::sun::star::uno::Sequence;
41 m_eStockVariant( eVariant )
58 const sal_Int32 nDataCount(
aData.size());
70 sal_Int32 nNumberOfNecessarySequences( 3 );
72 ++nNumberOfNecessarySequences;
74 ++nNumberOfNecessarySequences;
78 sal_Int32 nNumOfFullSeries( 0 );
79 sal_Int32 nRemaining( 0 );
81 sal_Int32 nAvailableSequences( nDataCount );
83 --nAvailableSequences;
84 nNumOfFullSeries = nAvailableSequences / nNumberOfNecessarySequences;
85 nRemaining = nAvailableSequences % nNumberOfNecessarySequences;
87 sal_Int32 nCandleStickSeries = nNumOfFullSeries;
88 sal_Int32 nVolumeSeries = nNumOfFullSeries;
90 sal_Int32 nNumberOfGroups( bHasVolume ? 2 : 1 );
92 std::vector< std::vector< std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > > > aSequences( nNumberOfGroups );
93 const sal_Int32 nBarGroupIndex( 0 );
94 const sal_Int32 nCandleStickGroupIndex( nNumberOfGroups - 1 );
99 aSequences[nCandleStickGroupIndex].resize( nCandleStickSeries );
100 auto & pCandleStickGroup = aSequences[nCandleStickGroupIndex];
108 aSequences[nBarGroupIndex].resize( nVolumeSeries );
110 auto & pBarGroup = aSequences[nBarGroupIndex];
113 sal_Int32 nSourceIndex = 0;
118 xCategories =
aData[nSourceIndex];
123 for( sal_Int32 nLabeledSeqIdx=0; nLabeledSeqIdx<nNumOfFullSeries; ++nLabeledSeqIdx )
128 pBarGroup[nLabeledSeqIdx].resize( 1 );
129 pBarGroup[nLabeledSeqIdx][0] =
aData[nSourceIndex];
130 if(
aData[nSourceIndex].is())
135 sal_Int32 nSeqIdx = 0;
138 pCandleStickGroup[nLabeledSeqIdx].resize( 4 );
139 pCandleStickGroup[nLabeledSeqIdx][nSeqIdx] =
aData[nSourceIndex];
140 if(
aData[nSourceIndex].is())
141 SetRole(
aData[nSourceIndex]->getValues(),
"values-first");
146 pCandleStickGroup[nLabeledSeqIdx].resize( 3 );
147 auto & pLabeledSeq = pCandleStickGroup[nLabeledSeqIdx];
149 pLabeledSeq[nSeqIdx] =
aData[nSourceIndex];
150 if(
aData[nSourceIndex].is())
151 SetRole(
aData[nSourceIndex]->getValues(),
"values-min");
155 pLabeledSeq[nSeqIdx] =
aData[nSourceIndex];
156 if(
aData[nSourceIndex].is())
157 SetRole(
aData[nSourceIndex]->getValues(),
"values-max");
161 pLabeledSeq[nSeqIdx] =
aData[nSourceIndex];
162 if(
aData[nSourceIndex].is())
163 SetRole(
aData[nSourceIndex]->getValues(),
"values-last");
169 if( bHasVolume && nRemaining > 1 )
171 OSL_ASSERT( nVolumeSeries > nNumOfFullSeries );
172 pBarGroup[nVolumeSeries - 1].resize( 1 );
173 OSL_ASSERT( nDataCount > nSourceIndex );
174 if(
aData[nSourceIndex].is())
176 pBarGroup[nVolumeSeries - 1][0] =
aData[nSourceIndex];
179 OSL_ENSURE( nRemaining,
"additional bar should only be used if there is at least one more sequence for a candle stick" );
185 OSL_ASSERT( nCandleStickSeries > nNumOfFullSeries );
186 const sal_Int32 nSeriesIndex = nCandleStickSeries - 1;
187 pCandleStickGroup[nSeriesIndex].resize( nRemaining );
188 auto & pLabeledSeq = pCandleStickGroup[nSeriesIndex];
189 OSL_ASSERT( nDataCount > nSourceIndex );
192 sal_Int32 nSeqIdx( 0 );
193 pLabeledSeq[nSeqIdx] =
aData[nSourceIndex];
194 if(
aData[nSourceIndex].is())
195 SetRole(
aData[nSourceIndex]->getValues(),
"values-min");
200 if( nSeqIdx < nRemaining )
202 pLabeledSeq[nSeqIdx] =
aData[nSourceIndex];
203 if(
aData[nSourceIndex].is())
204 SetRole(
aData[nSourceIndex]->getValues(),
"values-max");
210 OSL_ENSURE( bHasOpenValues || nSeqIdx >= nRemaining,
"could have created full series" );
211 if( nSeqIdx < nRemaining )
213 pLabeledSeq[nSeqIdx] =
aData[nSourceIndex];
214 if(
aData[nSourceIndex].is())
215 SetRole(
aData[nSourceIndex]->getValues(),
"values-last");
221 OSL_ENSURE( nSeqIdx >= nRemaining,
"could have created full series" );
225 std::vector< std::vector< rtl::Reference< DataSeries > > > aResultSeries( nNumberOfGroups );
226 sal_Int32 nGroupIndex;
227 std::size_t nReUsedSeriesIdx = 0;
228 for( nGroupIndex=0; nGroupIndex<nNumberOfGroups; ++nGroupIndex )
230 const sal_Int32 nNumSeriesData = aSequences[nGroupIndex].size();
231 aResultSeries[nGroupIndex].resize( nNumSeriesData );
232 auto & pResultSerie = aResultSeries[nGroupIndex];
233 for( sal_Int32 nSeriesIdx = 0; nSeriesIdx < nNumSeriesData; ++nSeriesIdx, ++nReUsedSeriesIdx )
238 if( nReUsedSeriesIdx < rSeriesToReUse.size())
239 xSeries = rSeriesToReUse[nReUsedSeriesIdx];
242 assert( xSeries.is() );
243 xSeries->setData( aSequences[nGroupIndex][nSeriesIdx] );
244 pResultSerie[nSeriesIdx] = xSeries;
246 catch(
const uno::Exception & )
253 return { aResultSeries, xCategories };
265 std::size_t nNumberOfNecessarySequences = 3;
270 ++nNumberOfNecessarySequences;
276 if( aInterpretedData.
Series.size() < (bHasVolume ? 2U : 1U ))
283 { std::vector< std::vector< rtl::Reference< DataSeries > > >{
284 aInterpretedData.
Series[0] },
291 OSL_ASSERT( aInterpretedData.
Series.size() > (bHasVolume ? 1U : 0
U));
292 const std::vector< rtl::Reference< DataSeries > > & aSeries = aInterpretedData.
Series[(bHasVolume ? 1 : 0)];
299 if( dataSeries->getDataSequences2().size() != nNumberOfNecessarySequences )
302 catch(
const uno::Exception & )
319 return aInterpretedData;
323 const OUString& sKey )
325 if( sKey ==
"stock variant" )
328 std::map< StockChartTypeTemplate::StockVariant, sal_Int32 > aTranslation {
334 return uno::Any( aTranslation[eStockVariant] );
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)
virtual bool isDataCompatible(const InterpretedData &aInterpretedData)
parses the given data and states, if a reinterpretDataSeries() call can be done without data loss.
virtual InterpretedData reinterpretDataSeries(const InterpretedData &aInterpretedData) override
Re-interprets the data given in aInterpretedData while keeping the number of data series and the cate...
StockDataInterpreter(StockChartTypeTemplate::StockVariant eVariant)
virtual bool isDataCompatible(const InterpretedData &aInterpretedData) override
parses the given data and states, if a reinterpretDataSeries() call can be done without data loss.
virtual ~StockDataInterpreter() override
virtual css::uno::Any getChartTypeSpecificData(const OUString &sKey) override
Get chart information that is specific to a particular chart type, by key.
StockChartTypeTemplate::StockVariant GetStockVariant() const
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.
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral aData
offers tooling to interpret different data sources in a structural and chart-type-dependent way.
std::vector< std::vector< rtl::Reference<::chart::DataSeries > > > Series
css::uno::Reference< css::chart2::data::XLabeledDataSequence > Categories