21#include <rtl/math.hxx>
23#include <osl/diagnose.h>
24#include <osl/thread.h>
26#include <com/sun/star/uno/Any.hxx>
27#include <com/sun/star/uno/Sequence.hxx>
30#include <document.hxx>
41 for (
bool bHas = aIter.
first(); bHas; bHas = aIter.
next())
55 double fInt = (fVal >= 0.0) ? ::rtl::math::approxFloor( fVal ) :
56 ::rtl::math::approxCeil( fVal );
71 uno::Sequence< uno::Sequence<sal_Int32> > aRowSeq( nRowCount );
72 uno::Sequence<sal_Int32>* pRowAry = aRowSeq.getArray();
73 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
75 uno::Sequence<sal_Int32> aColSeq( nColCount );
76 sal_Int32* pColAry = aColSeq.getArray();
77 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
79 ScAddress(
static_cast<SCCOL>(nStartCol+nCol),
static_cast<SCROW>(nStartRow+nRow), nTab ) ) );
81 pRowAry[nRow] = aColSeq;
97 uno::Sequence< uno::Sequence<sal_Int32> > aRowSeq(
static_cast<sal_Int32
>(nRowCount) );
98 uno::Sequence<sal_Int32>* pRowAry = aRowSeq.getArray();
99 for (
SCSIZE nRow = 0; nRow < nRowCount; nRow++)
101 uno::Sequence<sal_Int32> aColSeq(
static_cast<sal_Int32
>(nColCount) );
102 sal_Int32* pColAry = aColSeq.getArray();
103 for (
SCSIZE nCol = 0; nCol < nColCount; nCol++)
109 pRowAry[nRow] = aColSeq;
124 uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
125 uno::Sequence<double>* pRowAry = aRowSeq.getArray();
126 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
128 uno::Sequence<double> aColSeq( nColCount );
129 double* pColAry = aColSeq.getArray();
130 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
132 ScAddress(
static_cast<SCCOL>(nStartCol+nCol),
static_cast<SCROW>(nStartRow+nRow), nTab ) );
134 pRowAry[nRow] = aColSeq;
150 uno::Sequence< uno::Sequence<double> > aRowSeq(
static_cast<sal_Int32
>(nRowCount) );
151 uno::Sequence<double>* pRowAry = aRowSeq.getArray();
152 for (
SCSIZE nRow = 0; nRow < nRowCount; nRow++)
154 uno::Sequence<double> aColSeq(
static_cast<sal_Int32
>(nColCount) );
155 double* pColAry = aColSeq.getArray();
156 for (
SCSIZE nCol = 0; nCol < nColCount; nCol++)
160 pColAry[nCol] = pMatrix->
GetDouble( nCol, nRow );
162 pRowAry[nRow] = aColSeq;
177 bool bHasErrors =
false;
179 uno::Sequence< uno::Sequence<OUString> > aRowSeq( nRowCount );
180 uno::Sequence<OUString>* pRowAry = aRowSeq.getArray();
181 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
183 uno::Sequence<OUString> aColSeq( nColCount );
184 OUString* pColAry = aColSeq.getArray();
185 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
190 if ( nErrCode != FormulaError::NONE )
193 pRowAry[nRow] = aColSeq;
210 uno::Sequence< uno::Sequence<OUString> > aRowSeq(
static_cast<sal_Int32
>(nRowCount) );
211 uno::Sequence<OUString>* pRowAry = aRowSeq.getArray();
212 for (
SCSIZE nRow = 0; nRow < nRowCount; nRow++)
214 uno::Sequence<OUString> aColSeq(
static_cast<sal_Int32
>(nColCount) );
215 OUString* pColAry = aColSeq.getArray();
216 for (
SCSIZE nCol = 0; nCol < nColCount; nCol++)
221 if ( !pMatrix->
IsEmpty( nCol, nRow ) )
224 else if ( pFormatter )
226 double fVal = pMatrix->
GetDouble( nCol, nRow );
230 pColAry[nCol] =
aStr;
233 pRowAry[nRow] = aColSeq;
249 bool bHasErrors =
false;
251 uno::Sequence< uno::Sequence<uno::Any> > aRowSeq( nRowCount );
252 uno::Sequence<uno::Any>* pRowAry = aRowSeq.getArray();
253 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
255 uno::Sequence<uno::Any> aColSeq( nColCount );
256 uno::Any* pColAry = aColSeq.getArray();
257 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
261 ScAddress aPos(
static_cast<SCCOL>(nStartCol+nCol),
static_cast<SCROW>(nStartRow+nRow), nTab );
266 rElement <<= OUString();
270 if (aCell.getType() ==
CELLTYPE_FORMULA && aCell.getFormula()->GetErrCode() != FormulaError::NONE)
275 else if (aCell.hasNumeric())
276 rElement <<= aCell.getValue();
278 rElement <<= aCell.getString(&rDoc);
280 pRowAry[nRow] = aColSeq;
284 return bAllowNV || !bHasErrors;
296 uno::Sequence< uno::Sequence<uno::Any> > aRowSeq(
static_cast<sal_Int32
>(nRowCount) );
297 uno::Sequence<uno::Any>* pRowAry = aRowSeq.getArray();
298 for (
SCSIZE nRow = 0; nRow < nRowCount; nRow++)
300 uno::Sequence<uno::Any> aColSeq(
static_cast<sal_Int32
>(nColCount) );
301 uno::Any* pColAry = aColSeq.getArray();
302 for (
SCSIZE nCol = 0; nCol < nColCount; nCol++)
307 if ( !pMatrix->
IsEmpty( nCol, nRow ) )
309 pColAry[nCol] <<=
aStr;
313 double fVal = pMatrix->
GetDouble( nCol, nRow );
314 if (bDataTypes && pMatrix->
IsBoolean( nCol, nRow ))
315 pColAry[nCol] <<= fVal != 0.0;
317 pColAry[nCol] <<= fVal;
321 pRowAry[nRow] = aColSeq;
329 css::uno::TypeClass & o_eClass,
330 const css::uno::Any & rAny )
333 o_eClass = rAny.getValueTypeClass();
337 case uno::TypeClass_ENUM:
338 case uno::TypeClass_BOOLEAN:
339 case uno::TypeClass_CHAR:
340 case uno::TypeClass_BYTE:
341 case uno::TypeClass_SHORT:
342 case uno::TypeClass_UNSIGNED_SHORT:
343 case uno::TypeClass_LONG:
344 case uno::TypeClass_UNSIGNED_LONG:
345 case uno::TypeClass_FLOAT:
346 case uno::TypeClass_DOUBLE:
361 uno::Sequence< uno::Sequence< uno::Any > > aSequence;
362 if ( rAny >>= aSequence )
364 sal_Int32 nRowCount = aSequence.getLength();
365 sal_Int32 nMaxColCount = 0;
368 auto pRow = std::max_element(std::cbegin(aSequence), std::cend(aSequence),
369 [](
const uno::Sequence<uno::Any>&
a,
const uno::Sequence<uno::Any>& b) {
370 return a.getLength() < b.getLength(); });
371 nMaxColCount = pRow->getLength();
373 if ( nMaxColCount && nRowCount )
375 const uno::Sequence<uno::Any>* pRowArr = aSequence.getConstArray();
378 static_cast<SCSIZE>(nMaxColCount),
379 static_cast<SCSIZE>(nRowCount), 0.0);
381 xMatrix->GetDimensions( nCols, nRows);
382 if (nCols !=
static_cast<SCSIZE>(nMaxColCount) || nRows !=
static_cast<SCSIZE>(nRowCount))
384 OSL_FAIL(
"ScSequenceToMatrix::CreateMixedMatrix: matrix exceeded max size, returning NULL matrix");
387 for (sal_Int32 nRow=0; nRow<nRowCount; nRow++)
389 sal_Int32 nColCount = pRowArr[nRow].getLength();
390 const uno::Any* pColArr = pRowArr[nRow].getConstArray();
391 for (sal_Int32 nCol=0; nCol<nColCount; nCol++)
394 uno::TypeClass eClass;
397 if (eClass == uno::TypeClass_BOOLEAN)
398 xMatrix->PutBoolean( fVal != 0.0,
399 static_cast<SCSIZE>(nCol),
400 static_cast<SCSIZE>(nRow) );
402 xMatrix->PutDouble( fVal,
403 static_cast<SCSIZE>(nCol),
404 static_cast<SCSIZE>(nRow) );
410 if ( pColArr[nCol] >>= aUStr )
417 static_cast<SCSIZE>(nCol),
418 static_cast<SCSIZE>(nRow) );
421 for (sal_Int32 nCol=nColCount; nCol<nMaxColCount; nCol++)
424 static_cast<SCSIZE>(nCol),
425 static_cast<SCSIZE>(nRow) );
435 bool bResult =
false;
436 if (rAny >>= rString)
440 else if (uno::Sequence<sal_Int8>
aSeq; rAny >>=
aSeq)
442 rString = OUString(
reinterpret_cast<const char*
>(
aSeq.getConstArray()),
443 aSeq.getLength(), osl_getThreadTextEncoding() );
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
static bool ConvertAnyToDouble(double &o_fVal, css::uno::TypeClass &o_eClass, const css::uno::Any &rAny)
Convert a uno::Any to double if possible, including integer types.
static bool GetString(OUString &rString, const css::uno::Any &rAny)
Walk through all cells in an area.
ScFormulaCell * getFormulaCell()
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
FormulaError GetStringForFormula(const ScAddress &rPos, OUString &rString)
Matrix data type that can store values of mixed types.
svl::SharedString GetString(SCSIZE nC, SCSIZE nR) const
bool IsStringOrEmpty(SCSIZE nIndex) const
bool IsEmpty(SCSIZE nC, SCSIZE nR) const
bool IsBoolean(SCSIZE nC, SCSIZE nR) const
double GetDouble(SCSIZE nC, SCSIZE nR) const
void GetDimensions(SCSIZE &rC, SCSIZE &rR) const
static bool FillMixedArray(css::uno::Any &rAny, ScDocument &rDoc, const ScRange &rRange, bool bAllowNV=false)
static bool FillDoubleArray(css::uno::Any &rAny, ScDocument &rDoc, const ScRange &rRange)
static bool FillLongArray(css::uno::Any &rAny, ScDocument &rDoc, const ScRange &rRange)
static bool FillStringArray(css::uno::Any &rAny, ScDocument &rDoc, const ScRange &rRange)
static ScMatrixRef CreateMixedMatrix(const css::uno::Any &rAny)
Convert a sequence of mixed elements to ScMatrix.
const OUString & getString() const
Sequence< sal_Int8 > aSeq
OString stripEnd(const OString &rIn, char c)
constexpr std::enable_if_t< std::is_floating_point_v< F > &&std::is_integral_v< I >, bool > convertsToAtLeast(F value, I min)
constexpr std::enable_if_t< std::is_floating_point_v< F > &&std::is_integral_v< I >, bool > convertsToAtMost(F value, I max)
static tools::Long lcl_DoubleToLong(double fVal)
static bool lcl_HasErrors(ScDocument &rDoc, const ScRange &rRange)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
::boost::intrusive_ptr< ScMatrix > ScMatrixRef