diff --git a/formula/source/core/api/vectortoken.cxx b/formula/source/core/api/vectortoken.cxx index 961eda6d60c9..57476f4fb512 100644 --- a/formula/source/core/api/vectortoken.cxx +++ b/formula/source/core/api/vectortoken.cxx @@ -22,15 +22,15 @@ bool VectorRefArray::isValid() const return mpNumericArray || mpStringArray; } -SingleVectorRefToken::SingleVectorRefToken( const double* pArray, size_t nLength ) : - FormulaToken(svSingleVectorRef, ocPush), maArray(pArray), mnArrayLength(nLength) {} +SingleVectorRefToken::SingleVectorRefToken( const double* pArray, size_t nReqLength, size_t nArrayLength ) : + FormulaToken(svSingleVectorRef, ocPush), maArray(pArray), mnRequestedLength(nReqLength), mnArrayLength(nArrayLength) {} -SingleVectorRefToken::SingleVectorRefToken( const VectorRefArray& rArray, size_t nLength ) : - FormulaToken(svSingleVectorRef, ocPush), maArray(rArray), mnArrayLength(nLength) {} +SingleVectorRefToken::SingleVectorRefToken( const VectorRefArray& rArray, size_t nReqLength, size_t nArrayLength ) : + FormulaToken(svSingleVectorRef, ocPush), maArray(rArray), mnRequestedLength(nReqLength), mnArrayLength(nArrayLength) {} FormulaToken* SingleVectorRefToken::Clone() const { - return new SingleVectorRefToken(maArray, mnArrayLength); + return new SingleVectorRefToken(maArray, mnRequestedLength, mnArrayLength); } const VectorRefArray& SingleVectorRefToken::GetArray() const @@ -38,19 +38,27 @@ const VectorRefArray& SingleVectorRefToken::GetArray() const return maArray; } +size_t SingleVectorRefToken::GetRequestedArrayLength() const +{ + return mnRequestedLength; +} + size_t SingleVectorRefToken::GetArrayLength() const { return mnArrayLength; } DoubleVectorRefToken::DoubleVectorRefToken( - const std::vector& rArrays, size_t nArrayLength, size_t nRefRowSize, bool bStartFixed, bool bEndFixed ) : + const std::vector& rArrays, size_t nReqLength, size_t nArrayLength, + size_t nRefRowSize, bool bStartFixed, bool bEndFixed ) : FormulaToken(svDoubleVectorRef, ocPush), - maArrays(rArrays), mnArrayLength(nArrayLength), mnRefRowSize(nRefRowSize), mbStartFixed(bStartFixed), mbEndFixed(bEndFixed) {} + maArrays(rArrays), mnRequestedLength(nReqLength), mnArrayLength(nArrayLength), + mnRefRowSize(nRefRowSize), mbStartFixed(bStartFixed), mbEndFixed(bEndFixed) {} FormulaToken* DoubleVectorRefToken::Clone() const { - return new DoubleVectorRefToken(maArrays, mnArrayLength, mnRefRowSize, mbStartFixed, mbEndFixed); + return new DoubleVectorRefToken( + maArrays, mnRequestedLength, mnArrayLength, mnRefRowSize, mbStartFixed, mbEndFixed); } const std::vector& DoubleVectorRefToken::GetArrays() const @@ -58,6 +66,11 @@ const std::vector& DoubleVectorRefToken::GetArrays() const return maArrays; } +size_t DoubleVectorRefToken::GetRequestedArrayLength() const +{ + return mnRequestedLength; +} + size_t DoubleVectorRefToken::GetArrayLength() const { return mnArrayLength; diff --git a/include/formula/vectortoken.hxx b/include/formula/vectortoken.hxx index f04fef4e1b72..5fa596b57c00 100644 --- a/include/formula/vectortoken.hxx +++ b/include/formula/vectortoken.hxx @@ -52,15 +52,17 @@ struct FORMULA_DLLPUBLIC VectorRefArray class FORMULA_DLLPUBLIC SingleVectorRefToken : public FormulaToken { VectorRefArray maArray; + size_t mnRequestedLength; size_t mnArrayLength; public: - SingleVectorRefToken( const double* pArray, size_t nLength ); - SingleVectorRefToken( const VectorRefArray& rArray, size_t nLength ); + SingleVectorRefToken( const double* pArray, size_t nReqLength, size_t nArrayLength ); + SingleVectorRefToken( const VectorRefArray& rArray, size_t nReqLength, size_t nArrayLength ); virtual FormulaToken* Clone() const; const VectorRefArray& GetArray() const; + size_t GetRequestedArrayLength() const; size_t GetArrayLength() const; }; @@ -72,7 +74,8 @@ class FORMULA_DLLPUBLIC DoubleVectorRefToken : public FormulaToken { std::vector maArrays; - size_t mnArrayLength; /// length of all arrays. + size_t mnRequestedLength; /// requested length of all arrays which include trailing empty region. + size_t mnArrayLength; /// length of all arrays which does not include trailing empty region. size_t mnRefRowSize; /// original reference row size. The row size may /// change as it goes down the array if either the /// stard or end position is fixed. @@ -82,11 +85,13 @@ class FORMULA_DLLPUBLIC DoubleVectorRefToken : public FormulaToken public: DoubleVectorRefToken( - const std::vector& rArrays, size_t nArrayLength, size_t nRefRowSize, bool bStartFixed, bool bEndFixed ); + const std::vector& rArrays, size_t nReqLength, size_t nArrayLength, + size_t nRefRowSize, bool bStartFixed, bool bEndFixed ); virtual FormulaToken* Clone() const; const std::vector& GetArrays() const; + size_t GetRequestedArrayLength() const; size_t GetArrayLength() const; size_t GetRefRowSize() const; bool IsStartFixed() const; diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx index b295fee100de..47585fd67619 100644 --- a/sc/source/core/data/grouptokenconverter.cxx +++ b/sc/source/core/data/grouptokenconverter.cxx @@ -110,17 +110,16 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode) return false; // Trim data array length to actual data range. - nLen = trimLength(aRefPos.Tab(), aRefPos.Col(), aRefPos.Col(), aRefPos.Row(), nLen); - + SCROW nTrimLen = trimLength(aRefPos.Tab(), aRefPos.Col(), aRefPos.Col(), aRefPos.Row(), nLen); // Fetch double array guarantees that the length of the // returned array equals or greater than the requested // length. formula::VectorRefArray aArray; - if (nLen) - aArray = mrDoc.FetchVectorRefArray(aRefPos, nLen); + if (nTrimLen) + aArray = mrDoc.FetchVectorRefArray(aRefPos, nTrimLen); - formula::SingleVectorRefToken aTok(aArray, nLen); + formula::SingleVectorRefToken aTok(aArray, nLen, nTrimLen); mrGroupTokens.AddToken(aTok); } else @@ -179,6 +178,7 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode) } // Trim trailing empty rows. + SCROW nRequestedLength = nArrayLength; // keep the original length. nArrayLength = trimLength(aRefPos.Tab(), aAbs.aStart.Col(), aAbs.aEnd.Col(), aRefPos.Row(), nArrayLength); for (SCCOL i = aAbs.aStart.Col(); i <= aAbs.aEnd.Col(); ++i) @@ -191,7 +191,7 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode) aArrays.push_back(aArray); } - formula::DoubleVectorRefToken aTok(aArrays, nArrayLength, nRefRowSize, bAbsFirst, bAbsLast); + formula::DoubleVectorRefToken aTok(aArrays, nRequestedLength, nArrayLength, nRefRowSize, bAbsFirst, bAbsLast); mrGroupTokens.AddToken(aTok); } break;