summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-09-04 18:33:41 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-09-06 01:38:31 -0400
commite462eb1183c0e52c06786296b39c121ea3671199 (patch)
tree55efc399557f44b69267f2e3b33057989e693e91
parent69047ec117cd2e0885efec1824e9c00555da4800 (diff)
Allow storage of string arrays in vector ref tokens.
Change-Id: Id2bc5a0343afeae387d896a9c369586a13081cd5
-rw-r--r--formula/source/core/api/vectortoken.cxx19
-rw-r--r--include/formula/vectortoken.hxx25
-rw-r--r--sc/inc/column.hxx3
-rw-r--r--sc/inc/document.hxx5
-rw-r--r--sc/inc/formulagroup.hxx9
-rw-r--r--sc/inc/table.hxx3
-rw-r--r--sc/source/core/data/column2.cxx61
-rw-r--r--sc/source/core/data/document.cxx8
-rw-r--r--sc/source/core/data/formulacell.cxx14
-rw-r--r--sc/source/core/data/table1.cxx10
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx22
-rw-r--r--sc/source/core/tool/formulagroup.cxx25
12 files changed, 134 insertions, 70 deletions
diff --git a/formula/source/core/api/vectortoken.cxx b/formula/source/core/api/vectortoken.cxx
index 74339397448b..557e0c058595 100644
--- a/formula/source/core/api/vectortoken.cxx
+++ b/formula/source/core/api/vectortoken.cxx
@@ -11,17 +11,24 @@
namespace formula {
+VectorRefArray::VectorRefArray() : mpNumericArray(NULL), mbNumeric(true) {}
+VectorRefArray::VectorRefArray( const double* pArray ) : mpNumericArray(pArray), mbNumeric(true) {}
+VectorRefArray::VectorRefArray( const OUString* pArray ) : mpStringArray(pArray), mbNumeric(false) {}
+
SingleVectorRefToken::SingleVectorRefToken( const double* pArray, size_t nLength ) :
- FormulaToken(svSingleVectorRef, ocPush), mpArray(pArray), mnArrayLength(nLength) {}
+ FormulaToken(svSingleVectorRef, ocPush), maArray(pArray), mnArrayLength(nLength) {}
+
+SingleVectorRefToken::SingleVectorRefToken( const VectorRefArray& rArray, size_t nLength ) :
+ FormulaToken(svSingleVectorRef, ocPush), maArray(rArray), mnArrayLength(nLength) {}
FormulaToken* SingleVectorRefToken::Clone() const
{
- return new SingleVectorRefToken(mpArray, mnArrayLength);
+ return new SingleVectorRefToken(maArray, mnArrayLength);
}
-const double* SingleVectorRefToken::GetArray() const
+const VectorRefArray& SingleVectorRefToken::GetArray() const
{
- return mpArray;
+ return maArray;
}
size_t SingleVectorRefToken::GetArrayLength() const
@@ -30,7 +37,7 @@ size_t SingleVectorRefToken::GetArrayLength() const
}
DoubleVectorRefToken::DoubleVectorRefToken(
- const std::vector<const double*>& rArrays, size_t nArrayLength, size_t nRefRowSize, bool bStartFixed, bool bEndFixed ) :
+ const std::vector<VectorRefArray>& rArrays, size_t nArrayLength, size_t nRefRowSize, bool bStartFixed, bool bEndFixed ) :
FormulaToken(svDoubleVectorRef, ocPush),
maArrays(rArrays), mnArrayLength(nArrayLength), mnRefRowSize(nRefRowSize), mbStartFixed(bStartFixed), mbEndFixed(bEndFixed) {}
@@ -39,7 +46,7 @@ FormulaToken* DoubleVectorRefToken::Clone() const
return new DoubleVectorRefToken(maArrays, mnArrayLength, mnRefRowSize, mbStartFixed, mbEndFixed);
}
-const std::vector<const double*>& DoubleVectorRefToken::GetArrays() const
+const std::vector<VectorRefArray>& DoubleVectorRefToken::GetArrays() const
{
return maArrays;
}
diff --git a/include/formula/vectortoken.hxx b/include/formula/vectortoken.hxx
index d3d05111ccf4..5186ca526922 100644
--- a/include/formula/vectortoken.hxx
+++ b/include/formula/vectortoken.hxx
@@ -14,21 +14,36 @@
namespace formula {
+struct FORMULA_DLLPUBLIC VectorRefArray
+{
+ union {
+ const double* mpNumericArray;
+ const OUString* mpStringArray;
+ };
+
+ bool mbNumeric;
+
+ VectorRefArray();
+ VectorRefArray( const double* pArray );
+ VectorRefArray( const OUString* pArray );
+};
+
/**
* This token represents a single cell reference in a vectorized formula
* calculation context.
*/
class FORMULA_DLLPUBLIC SingleVectorRefToken : public FormulaToken
{
- const double* mpArray;
+ VectorRefArray maArray;
size_t mnArrayLength;
public:
SingleVectorRefToken( const double* pArray, size_t nLength );
+ SingleVectorRefToken( const VectorRefArray& rArray, size_t nLength );
virtual FormulaToken* Clone() const;
- const double* GetArray() const;
+ const VectorRefArray& GetArray() const;
size_t GetArrayLength() const;
};
@@ -38,7 +53,7 @@ public:
*/
class FORMULA_DLLPUBLIC DoubleVectorRefToken : public FormulaToken
{
- std::vector<const double*> maArrays;
+ std::vector<VectorRefArray> maArrays;
size_t mnArrayLength; /// length of all arrays.
size_t mnRefRowSize; /// original reference row size. The row size may
@@ -50,11 +65,11 @@ class FORMULA_DLLPUBLIC DoubleVectorRefToken : public FormulaToken
public:
DoubleVectorRefToken(
- const std::vector<const double*>& rArrays, size_t nArrayLength, size_t nRefRowSize, bool bStartFixed, bool bEndFixed );
+ const std::vector<VectorRefArray>& rArrays, size_t nArrayLength, size_t nRefRowSize, bool bStartFixed, bool bEndFixed );
virtual FormulaToken* Clone() const;
- const std::vector<const double*>& GetArrays() const;
+ const std::vector<VectorRefArray>& GetArrays() const;
size_t GetArrayLength() const;
size_t GetRefRowSize() const;
bool IsStartFixed() const;
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 7308d221d066..ba79c23fb83c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -35,6 +35,7 @@
#include <mdds/flat_segment_tree.hpp>
namespace editeng { class SvxBorderLine; }
+namespace formula { struct VectorRefArray; }
namespace sc {
struct FormulaGroupContext;
@@ -469,7 +470,7 @@ public:
formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, SCROW nRow2 );
void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 ) const;
- const double* FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW nRow1, SCROW nRow2 );
+ formula::VectorRefArray FetchVectorRefArray( sc::FormulaGroupContext& rCxt, SCROW nRow1, SCROW nRow2 );
void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index b91e8d3f5294..6949b6d686d3 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -49,6 +49,8 @@
#include "markdata.hxx"
namespace editeng { class SvxBorderLine; }
+namespace formula { struct VectorRefArray; }
+
namespace sc {
struct FormulaGroupContext;
class StartListeningContext;
@@ -59,6 +61,7 @@ namespace sc {
struct RefUpdateContext;
class EditTextIterator;
}
+
class SvxFontItem;
class KeyEvent;
@@ -1983,7 +1986,7 @@ public:
formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange );
- const double* FetchDoubleArray(
+ formula::VectorRefArray FetchVectorRefArray(
sc::FormulaGroupContext& rCxt, const ScAddress& rPos, SCROW nLength );
SvtBroadcaster* GetBroadcaster( const ScAddress& rPos );
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 9963fc96ad91..776b24d9b348 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -23,10 +23,13 @@ namespace sc {
struct FormulaGroupContext : boost::noncopyable
{
- typedef std::vector<double> DoubleArrayType;
- typedef boost::ptr_vector<DoubleArrayType> ArrayStoreType;
+ typedef std::vector<double> NumArrayType;
+ typedef std::vector<OUString> StrArrayType;
+ typedef boost::ptr_vector<NumArrayType> NumArrayStoreType;
+ typedef boost::ptr_vector<StrArrayType> StrArrayStoreType;
- ArrayStoreType maArrays;
+ NumArrayStoreType maNumArrays;
+ StrArrayStoreType maStrArrays;
};
/**
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 69d25205fe8b..88166427f4a1 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -49,6 +49,7 @@ namespace com { namespace sun { namespace star {
}
} } }
+namespace formula { struct VectorRefArray; }
namespace sc {
struct FormulaGroupContext;
class StartListeningContext;
@@ -850,7 +851,7 @@ public:
ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
- const double* FetchDoubleArray(
+ formula::VectorRefArray FetchVectorRefArray(
sc::FormulaGroupContext& rCxt, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 855be2e79f11..658a316301ea 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -63,6 +63,7 @@
#include <svl/listeneriter.hxx>
#include <vcl/outdev.hxx>
#include "formula/errorcodes.hxx"
+#include "formula/vectortoken.hxx"
#include <boost/scoped_ptr.hpp>
@@ -2039,7 +2040,7 @@ void ScColumn::FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nR
namespace {
bool appendDouble(
- sc::FormulaGroupContext::DoubleArrayType& rArray, size_t nLen,
+ sc::FormulaGroupContext::NumArrayType& rArray, size_t nLen,
sc::CellStoreType::iterator it, const sc::CellStoreType::iterator& itEnd )
{
size_t nLenRemain = nLen;
@@ -2135,10 +2136,10 @@ bool appendDouble(
}
-const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW nRow1, SCROW nRow2 )
+formula::VectorRefArray ScColumn::FetchVectorRefArray( sc::FormulaGroupContext& rCxt, SCROW nRow1, SCROW nRow2 )
{
if (nRow1 > nRow2)
- return NULL;
+ return formula::VectorRefArray();
size_t nLenRequested = nRow2 - nRow1 + 1;
sc::CellStoreType::position_type aPos = maCells.position(nRow1);
@@ -2149,23 +2150,26 @@ const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW n
{
// This is a numeric cell block.
if (nLenRequested <= nLen)
+ {
// Requested length fits a single block.
- return &sc::numeric_block::at(*aPos.first->data, aPos.second);
+ const double* p = &sc::numeric_block::at(*aPos.first->data, aPos.second);
+ return formula::VectorRefArray(p);
+ }
// Allocate a new array and copy the values to it.
sc::numeric_block::const_iterator it = sc::numeric_block::begin(*aPos.first->data);
sc::numeric_block::const_iterator itEnd = sc::numeric_block::end(*aPos.first->data);
std::advance(it, aPos.second);
- rCxt.maArrays.push_back(new sc::FormulaGroupContext::DoubleArrayType(it, itEnd));
- sc::FormulaGroupContext::DoubleArrayType& rArray = rCxt.maArrays.back();
+ rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType(it, itEnd));
+ sc::FormulaGroupContext::NumArrayType& rArray = rCxt.maNumArrays.back();
rArray.reserve(nLenRequested);
// Fill the remaining array with values from the following blocks.
++aPos.first;
if (!appendDouble(rArray, nLenRequested - nLen, aPos.first, maCells.end()))
- return NULL;
+ return formula::VectorRefArray();
- return &rArray[0];
+ return formula::VectorRefArray(&rArray[0]);
}
break;
case sc::element_type_formula:
@@ -2173,8 +2177,8 @@ const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW n
sal_uInt16 nErr;
double fVal;
- rCxt.maArrays.push_back(new sc::FormulaGroupContext::DoubleArrayType);
- sc::FormulaGroupContext::DoubleArrayType& rArray = rCxt.maArrays.back();
+ rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType);
+ sc::FormulaGroupContext::NumArrayType& rArray = rCxt.maNumArrays.back();
rArray.reserve(nLenRequested);
sc::formula_block::const_iterator it = sc::formula_block::begin(*aPos.first->data);
@@ -2196,13 +2200,13 @@ const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW n
rCell.SetErrCode(0);
rCell.SetDirtyVar();
}
- return NULL;
+ return formula::VectorRefArray();
}
rArray.push_back(fVal);
}
- return &rArray[0];
+ return formula::VectorRefArray(&rArray[0]);
}
// Requested length goes beyond a single block. Fill the array
@@ -2219,7 +2223,7 @@ const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW n
rCell.SetErrCode(0);
rCell.SetDirtyVar();
}
- return NULL;
+ return formula::VectorRefArray();
}
rArray.push_back(fVal);
@@ -2228,9 +2232,22 @@ const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW n
// Fill the remaining array with values from the following blocks.
++aPos.first;
if (!appendDouble(rArray, nLenRequested - nLen, aPos.first, maCells.end()))
- return NULL;
+ return formula::VectorRefArray();
+
+ return formula::VectorRefArray(&rArray[0]);
+ }
+ break;
+ case sc::element_type_string:
+ {
+ if (nLenRequested <= nLen)
+ {
+ // Requested length fits a single block.
+ const OUString* p = &sc::string_block::at(*aPos.first->data, aPos.second);
+ return formula::VectorRefArray(p);
+ }
- return &rArray[0];
+ // TODO: handle cases where the requested length goes beyond the
+ // current block just like we do with numeric array.
}
break;
case sc::element_type_empty:
@@ -2238,27 +2255,27 @@ const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW n
if (nLenRequested <= nLen)
{
// Fill the whole length with zero.
- rCxt.maArrays.push_back(new sc::FormulaGroupContext::DoubleArrayType(nLenRequested, 0.0));
- return &rCxt.maArrays.back()[0];
+ rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType(nLenRequested, 0.0));
+ return formula::VectorRefArray(&rCxt.maNumArrays.back()[0]);
}
// Fill the array with zero for the length of the empty block.
- rCxt.maArrays.push_back(new sc::FormulaGroupContext::DoubleArrayType(nLen, 0.0));
- sc::FormulaGroupContext::DoubleArrayType& rArray = rCxt.maArrays.back();
+ rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType(nLen, 0.0));
+ sc::FormulaGroupContext::NumArrayType& rArray = rCxt.maNumArrays.back();
rArray.reserve(nLenRequested);
// Fill the remaining array with values from the following blocks.
++aPos.first;
if (!appendDouble(rArray, nLenRequested - nLen, aPos.first, maCells.end()))
- return NULL;
+ return formula::VectorRefArray();
- return &rArray[0];
+ return formula::VectorRefArray(&rArray[0]);
}
default:
;
}
- return NULL;
+ return formula::VectorRefArray();
}
void ScColumn::SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen )
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f316581c7c23..c6d3c79ffbbc 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -95,6 +95,8 @@
#include "scopetools.hxx"
#include "refupdatecontext.hxx"
+#include "formula/vectortoken.hxx"
+
#include <map>
#include <limits>
#include <boost/scoped_ptr.hpp>
@@ -1662,14 +1664,14 @@ formula::FormulaTokenRef ScDocument::ResolveStaticReference( const ScRange& rRan
rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row());
}
-const double* ScDocument::FetchDoubleArray(
+formula::VectorRefArray ScDocument::FetchVectorRefArray(
sc::FormulaGroupContext& rCxt, const ScAddress& rPos, SCROW nLength )
{
SCTAB nTab = rPos.Tab();
if (!TableExists(nTab))
- return NULL;
+ return formula::VectorRefArray();
- return maTabs[nTab]->FetchDoubleArray(rCxt, rPos.Col(), rPos.Row(), rPos.Row()+nLength-1);
+ return maTabs[nTab]->FetchVectorRefArray(rCxt, rPos.Col(), rPos.Row(), rPos.Row()+nLength-1);
}
bool ScDocument::CanFitBlock( const ScRange& rOld, const ScRange& rNew )
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 4f0b90e03139..143351e8326e 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3387,11 +3387,11 @@ public:
// returned array equals or greater than the requested
// length.
- const double* pArray = mrDoc.FetchDoubleArray(mrCxt, aRefPos, nLen);
- if (!pArray)
+ formula::VectorRefArray aArray = mrDoc.FetchVectorRefArray(mrCxt, aRefPos, nLen);
+ if (!aArray.mpNumericArray)
return false;
- formula::SingleVectorRefToken aTok(pArray, nLen);
+ formula::SingleVectorRefToken aTok(aArray, nLen);
mrGroupTokens.AddToken(aTok);
}
else
@@ -3435,7 +3435,7 @@ public:
bool bAbsLast = !aRef.Ref2.IsRowRel();
ScAddress aRefPos = aAbs.aStart;
size_t nCols = aAbs.aEnd.Col() - aAbs.aStart.Col() + 1;
- std::vector<const double*> aArrays;
+ std::vector<formula::VectorRefArray> aArrays;
aArrays.reserve(nCols);
SCROW nArrayLength = nLen;
SCROW nRefRowSize = aAbs.aEnd.Row() - aAbs.aStart.Row() + 1;
@@ -3448,11 +3448,11 @@ public:
for (SCCOL i = aAbs.aStart.Col(); i <= aAbs.aEnd.Col(); ++i)
{
aRefPos.SetCol(i);
- const double* pArray = mrDoc.FetchDoubleArray(mrCxt, aRefPos, nArrayLength);
- if (!pArray)
+ formula::VectorRefArray aArray = mrDoc.FetchVectorRefArray(mrCxt, aRefPos, nArrayLength);
+ if (!aArray.mpNumericArray)
return false;
- aArrays.push_back(pArray);
+ aArrays.push_back(aArray);
}
formula::DoubleVectorRefToken aTok(aArrays, nArrayLength, nRefRowSize, bAbsFirst, bAbsLast);
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 5f409ba202f8..6391eeea3a8a 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -49,6 +49,8 @@
#include "scmatrix.hxx"
#include "refupdatecontext.hxx"
+#include "formula/vectortoken.hxx"
+
#include <vector>
using ::std::vector;
@@ -2148,16 +2150,16 @@ formula::FormulaTokenRef ScTable::ResolveStaticReference( SCCOL nCol1, SCROW nRo
return formula::FormulaTokenRef(new ScMatrixToken(pMat));
}
-const double* ScTable::FetchDoubleArray(
+formula::VectorRefArray ScTable::FetchVectorRefArray(
sc::FormulaGroupContext& rCxt, SCCOL nCol, SCROW nRow1, SCROW nRow2 )
{
if (nRow2 < nRow1)
- return NULL;
+ return formula::VectorRefArray();
if (!ValidCol(nCol) || !ValidRow(nRow1) || !ValidRow(nRow2))
- return NULL;
+ return formula::VectorRefArray();
- return aCol[nCol].FetchDoubleArray(rCxt, nRow1, nRow2);
+ return aCol[nCol].FetchVectorRefArray(rCxt, nRow1, nRow2);
}
ScRefCellValue ScTable::GetRefCellValue( SCCOL nCol, SCROW nRow )
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index c082391413f5..0ae58e808472 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -785,7 +785,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, const ScAddress
else if( ocPush == p->GetOpCode() && formula::svDoubleVectorRef == p->GetType())
{
const formula::DoubleVectorRefToken* pDvr = static_cast< const formula::DoubleVectorRefToken* >( p );
- const std::vector< const double* >& rArrays = pDvr->GetArrays();
+ const std::vector<formula::VectorRefArray>& rArrays = pDvr->GetArrays();
uint rArraysSize = rArrays.size();
int nMoreColSize = 0;
DoubleVectorFormula *SvDoubleTemp = new DoubleVectorFormula();
@@ -794,7 +794,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, const ScAddress
double *dpMoreColData = NULL;
for ( uint loop=0; loop < rArraysSize; loop++ )
{
- dpOclSrcData = rArrays[loop];
+ dpOclSrcData = rArrays[loop].mpNumericArray;
nSrcDataSize = pDvr->GetArrayLength();
nMoreColSize += nSrcDataSize;
dpMoreColData = (double *) realloc(dpMoreColData,nMoreColSize * sizeof(double));
@@ -808,7 +808,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, const ScAddress
}
else
{
- dpOclSrcData = rArrays[0];
+ dpOclSrcData = rArrays[0].mpNumericArray;
nSrcDataSize = pDvr->GetArrayLength();
SvDoubleTemp->mdpInputData = dpOclSrcData;
SvDoubleTemp->mnInputDataSize = nSrcDataSize;
@@ -823,7 +823,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, const ScAddress
else if( ocPush == p->GetOpCode() && formula::svSingleVectorRef == p->GetType() )
{
const formula::SingleVectorRefToken* pSvr = static_cast<const formula::SingleVectorRefToken*>( p );
- dpBinaryData = pSvr->GetArray();
+ dpBinaryData = pSvr->GetArray().mpNumericArray;
uint nArrayLen = pSvr->GetArrayLength();
SingleVectorFormula *SignleTemp = new SingleVectorFormula() ;
if(isSingle)
@@ -877,7 +877,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, const ScAddress
else if( ocPush == p->GetOpCode() && formula::svDoubleVectorRef == p->GetType())
{
const formula::DoubleVectorRefToken* pDvr = static_cast< const formula::DoubleVectorRefToken* >( p );
- const std::vector< const double* >& rArrays = pDvr->GetArrays();
+ const std::vector<formula::VectorRefArray>& rArrays = pDvr->GetArrays();
unsigned int rArraysSize = rArrays.size();
int nMoreColSize = 0;
if(rArraysSize > 1)
@@ -885,7 +885,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, const ScAddress
double *dpMoreColData = NULL;
for( uint loop=0; loop < rArraysSize; loop++ )
{
- dpOclSrcData = rArrays[loop];
+ dpOclSrcData = rArrays[loop].mpNumericArray;
nSrcDataSize = pDvr->GetArrayLength();
nMoreColSize += nSrcDataSize;
dpMoreColData = (double *) realloc(dpMoreColData,nMoreColSize * sizeof(double));
@@ -900,7 +900,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, const ScAddress
}
else
{
- dpOclSrcData = rArrays[0];
+ dpOclSrcData = rArrays[0].mpNumericArray;
nSrcDataSize = pDvr->GetArrayLength();
}
srdDataPush( new SourceData( dpOclSrcData,nSrcDataSize,rArraysSize ) );
@@ -908,7 +908,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, const ScAddress
else if( ocPush == p->GetOpCode() && formula::svSingleVectorRef == p->GetType() )
{
const formula::SingleVectorRefToken* pSvr = static_cast<const formula::SingleVectorRefToken*>( p );
- dpBinaryData = pSvr->GetArray();
+ dpBinaryData = pSvr->GetArray().mpNumericArray;
nSrcDataSize = pSvr->GetArrayLength();
srdDataPush( new SourceData( dpBinaryData, nSrcDataSize ) );
}
@@ -997,11 +997,11 @@ bool FormulaGroupInterpreterGroundwater::interpretCL(ScDocument& rDoc, const ScA
RETURN_IF_FAIL(p != NULL && p->GetOpCode() == ocPush && p->GetType() == formula::svDoubleVectorRef, "double vector ref expected");
// Get the range reference vector.
const formula::DoubleVectorRefToken* pDvr = static_cast<const formula::DoubleVectorRefToken*>(p);
- const std::vector<const double*>& rArrays = pDvr->GetArrays();
+ const std::vector<formula::VectorRefArray>& rArrays = pDvr->GetArrays();
RETURN_IF_FAIL(rArrays.size() == 1, "unexpectedly large double ref array");
RETURN_IF_FAIL(pDvr->GetArrayLength() == (size_t)xGroup->mnLength, "wrong double ref length");
RETURN_IF_FAIL(pDvr->IsStartFixed() && pDvr->IsEndFixed(), "non-fixed ranges )");
- pGroundWaterDataArray = rArrays[0];
+ pGroundWaterDataArray = rArrays[0].mpNumericArray;
// Function:
p = rCode.NextRPN();
@@ -1015,7 +1015,7 @@ bool FormulaGroupInterpreterGroundwater::interpretCL(ScDocument& rDoc, const ScA
// Get the single reference vector.
const formula::SingleVectorRefToken* pSvr = static_cast<const formula::SingleVectorRefToken*>(p);
- pArrayToSubtractOneElementFrom = pSvr->GetArray();
+ pArrayToSubtractOneElementFrom = pSvr->GetArray().mpNumericArray;
RETURN_IF_FAIL(pSvr->GetArrayLength() == (size_t)xGroup->mnLength, "wrong single ref length");
p = rCode.NextRPN();
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 40f4befe32d7..2ea09c4a54d8 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -68,14 +68,17 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
case formula::svSingleVectorRef:
{
const formula::SingleVectorRefToken* p2 = static_cast<const formula::SingleVectorRefToken*>(p);
- const double* pArray = p2->GetArray();
- aCode2.AddDouble(static_cast<size_t>(i) < p2->GetArrayLength() ? pArray[i] : 0.0);
+ const formula::VectorRefArray& rArray = p2->GetArray();
+ if (rArray.mbNumeric)
+ aCode2.AddDouble(static_cast<size_t>(i) < p2->GetArrayLength() ? rArray.mpNumericArray[i] : 0.0);
+ else
+ aCode2.AddString(static_cast<size_t>(i) < p2->GetArrayLength() ? rArray.mpStringArray[i] : OUString());
}
break;
case formula::svDoubleVectorRef:
{
const formula::DoubleVectorRefToken* p2 = static_cast<const formula::DoubleVectorRefToken*>(p);
- const std::vector<const double*>& rArrays = p2->GetArrays();
+ const std::vector<formula::VectorRefArray>& rArrays = p2->GetArrays();
size_t nColSize = rArrays.size();
size_t nRowStart = p2->IsStartFixed() ? 0 : i;
size_t nRowEnd = p2->GetRefRowSize() - 1;
@@ -85,9 +88,19 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
ScMatrixRef pMat(new ScMatrix(nColSize, nRowSize, 0.0));
for (size_t nCol = 0; nCol < nColSize; ++nCol)
{
- const double* pArray = rArrays[nCol];
- pArray += nRowStart;
- pMat->PutDouble(pArray, nRowSize, nCol, 0);
+ const formula::VectorRefArray& rArray = rArrays[nCol];
+ if (rArray.mbNumeric)
+ {
+ const double* pNums = rArray.mpNumericArray;
+ pNums += nRowStart;
+ pMat->PutDouble(pNums, nRowSize, nCol, 0);
+ }
+ else
+ {
+ const OUString* pStrs = rArray.mpStringArray;
+ pStrs += nRowStart;
+ pMat->PutString(pStrs, nRowSize, nCol, 0);
+ }
}
if (p2->IsStartFixed() && p2->IsEndFixed())