26#include <osl/diagnose.h>
28#ifdef DEBUG_CHART2_TOOLS
29#define DEBUG_INTERNAL_DATA 1
32#ifdef DEBUG_INTERNAL_DATA
40using ::com::sun::star::uno::Sequence;
49struct lcl_NumberedStringGenerator
51 lcl_NumberedStringGenerator(
const OUString & rStub, std::u16string_view rWildcard ) :
58 std::vector< uno::Any > operator()()
70 Sequence< T > lcl_ValarrayToSequence(
const std::valarray< T > & rValarray )
72#if defined __GLIBCXX__ && (!defined _GLIBCXX_RELEASE || _GLIBCXX_RELEASE < 12)
87 , m_aColumnLabels( 0 )
99 const sal_Int32 nRowCount = 4;
100 const sal_Int32 nColumnCount = 3;
104 const sal_Int32 nSize = nColumnCount * nRowCount;
106 const OUString aRowName(
SchResId(STR_ROW_LABEL));
107 const OUString aColName(
SchResId(STR_COLUMN_LABEL));
110 for( sal_Int32
i=0;
i<nSize; ++
i )
116 lcl_NumberedStringGenerator( aRowName,
u"%ROWNUMBER" ));
121 lcl_NumberedStringGenerator( aColName,
u"%COLUMNNUMBER" ));
136 m_aData = std::numeric_limits<double>::quiet_NaN();
142 for( sal_Int32 nCol=0; nCol < nMax; ++nCol )
144 m_aData[nDataIdx] = rDataInRows[nRow][nCol];
153 auto aResultRange = asNonConstRange(aResult);
156 aResultRange[
i] = lcl_ValarrayToSequence< tDataType::value_type >(
165 return lcl_ValarrayToSequence< tDataType::value_type >(
172 return lcl_ValarrayToSequence< tDataType::value_type >(
179 if( nColumnIndex < 0 )
184 for( std::vector< double >::size_type
i = 0;
i < rNewData.size(); ++
i )
185 aSlice[
i] = rNewData[
i];
196 for( std::vector< double >::size_type
i = 0;
i < rNewData.size(); ++
i )
197 aSlice[
i] = rNewData[
i];
203 if( nColumnIndex < 0 )
224 sal_Int32 nSize =
static_cast<sal_Int32
>(
m_aRowLabels[nRowIndex].size() );
225 if( nSize >= 1 && !rComplexLabel.empty() )
238 if( nColumnIndex <
static_cast< sal_Int32
>(
m_aColumnLabels.size() ) )
241 return std::vector< uno::Any >();
245 if( nRowIndex <
static_cast< sal_Int32
>(
m_aRowLabels.size() ) )
248 return std::vector< uno::Any >();
257 for( sal_Int32 nColIdx=0; nColIdx<nMax; ++nColIdx )
264 std::vector< uno::Any > aTemp(
m_aRowLabels[nRowIndex] );
275 for( sal_Int32 nRowIdx=0; nRowIdx<nMax; ++nRowIdx )
278 size_t nIndex2 = nIndex1 + 1;
289 sal_Int32 nNewColumnCount( std::max<sal_Int32>(
m_nColumnCount, nColumnCount ) );
290 sal_Int32 nNewRowCount( std::max<sal_Int32>(
m_nRowCount, nRowCount ) );
291 sal_Int32 nNewSize( nNewColumnCount*nNewRowCount );
297 tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
301 aNewData[ std::slice( nCol,
m_nRowCount, nNewColumnCount ) ] ) =
315 OSL_ASSERT( nAfterIndex < m_nColumnCount && nAfterIndex >= -1 );
319 sal_Int32 nNewSize( nNewColumnCount *
m_nRowCount );
321 tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
325 for( ; nCol<=nAfterIndex; ++nCol )
326 aNewData[ std::slice( nCol,
m_nRowCount, nNewColumnCount ) ] =
329 for( ++nCol; nCol<nNewColumnCount; ++nCol )
330 aNewData[ std::slice( nCol,
m_nRowCount, nNewColumnCount ) ] =
370 OSL_ASSERT( nAfterIndex < m_nRowCount && nAfterIndex >= -1 );
371 if( nAfterIndex >=
m_nRowCount || nAfterIndex < -1 )
376 tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
379 sal_Int32
nIndex = nAfterIndex + 1;
397 if( nAfterIndex <
static_cast< sal_Int32
>(
m_aRowLabels.size()))
405 OSL_ASSERT( nAtIndex < m_nColumnCount && nAtIndex >= 0 );
409 sal_Int32 nNewSize( nNewColumnCount *
m_nRowCount );
411 tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
415 for( ; nCol<nAtIndex; ++nCol )
416 aNewData[ std::slice( nCol,
m_nRowCount, nNewColumnCount ) ] =
419 for( ; nCol<nNewColumnCount; ++nCol )
420 aNewData[ std::slice( nCol,
m_nRowCount, nNewColumnCount ) ] =
437 OSL_ASSERT( nAtIndex < m_nRowCount && nAtIndex >= 0 );
443 tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize );
446 sal_Int32
nIndex = nAtIndex;
452 if(
nIndex < nNewRowCount )
465 if( nAtIndex <
static_cast< sal_Int32
>(
m_aRowLabels.size()))
474 sal_Int32 nNewRowCount =
static_cast< sal_Int32
>(
m_aRowLabels.size() );
489 sal_Int32 nNewColumnCount =
static_cast< sal_Int32
>(
m_aColumnLabels.size() );
501#ifdef DEBUG_INTERNAL_DATA
514 aPrinter.set(nRow, nCol, aStr);
517 aPrinter.print(
"Header");
523 for (
size_t nRow = 0; nRow <
m_aRowLabels.size(); ++nRow)
525 for (
size_t nCol = 0; nCol <
m_aRowLabels[nRow].size(); ++nCol)
529 aPrinter.set(nRow, nCol, aStr);
532 aPrinter.print(
"Row labels");
537 for (sal_Int32 nRow = 0; nRow <
m_nRowCount; ++nRow)
541 aPrinter.set(nRow, nCol, OUString::number(aSlice[nCol]));
544 aPrinter.print(
"Column data");
const sal_Int32 m_nStubStartIndex
const sal_Int32 m_nWildcardLength
sal_Int32 getColumnCount() const
std::valarray< double > tDataType
const tVecVecAny & getComplexColumnLabels() const
sal_Int32 getRowCount() const
void deleteColumn(sal_Int32 nAtIndex)
void setComplexRowLabel(sal_Int32 nRowIndex, std::vector< css::uno::Any > &&rComplexLabel)
css::uno::Sequence< double > getRowValues(sal_Int32 nRowIndex) const
void setComplexColumnLabel(sal_Int32 nColumnIndex, std::vector< css::uno::Any > &&rComplexLabel)
void insertColumn(sal_Int32 nAfterIndex)
css::uno::Sequence< css::uno::Sequence< double > > getData() const
const tVecVecAny & getComplexRowLabels() const
void setColumnValues(sal_Int32 nColumnIndex, const std::vector< double > &rNewData)
void insertRow(sal_Int32 nAfterIndex)
std::vector< std::vector< css::uno::Any > > tVecVecAny
void deleteRow(sal_Int32 nAtIndex)
void setComplexColumnLabels(tVecVecAny &&rNewColumnLabels)
tVecVecAny m_aColumnLabels
void swapColumnWithNext(sal_Int32 nColumnIndex)
bool enlargeData(sal_Int32 nColumnCount, sal_Int32 nRowCount)
resizes the data if at least one of the given dimensions is larger than before.
void setRowValues(sal_Int32 nRowIndex, const std::vector< double > &rNewData)
void swapRowWithNext(sal_Int32 nRowIndex)
std::vector< css::uno::Any > getComplexColumnLabel(sal_Int32 nColumnIndex) const
css::uno::Sequence< double > getColumnValues(sal_Int32 nColumnIndex) const
std::vector< css::uno::Any > getComplexRowLabel(sal_Int32 nRowIndex) const
void setData(const css::uno::Sequence< css::uno::Sequence< double > > &rDataInRows)
void setComplexRowLabels(tVecVecAny &&rNewRowLabels)
double getLength(const B2DPolygon &rCandidate)
const double fDefaultData[]
OUString OOO_DLLPUBLIC_CHARTTOOLS SchResId(TranslateId aId)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)