summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/clipparam.cxx2
-rw-r--r--sc/source/core/data/dpcachetable.cxx11
-rw-r--r--sc/source/core/data/dpobject.cxx12
-rw-r--r--sc/source/core/data/dpsave.cxx5
-rw-r--r--sc/source/core/data/dpsdbtab.cxx10
-rw-r--r--sc/source/core/data/table1.cxx14
-rw-r--r--sc/source/core/tool/dbcolect.cxx11
-rw-r--r--sc/source/core/tool/interpr1.cxx58
-rw-r--r--sc/source/core/tool/interpr4.cxx20
-rw-r--r--sc/source/core/tool/interpr5.cxx15
-rw-r--r--sc/source/core/tool/rangelst.cxx4
-rw-r--r--sc/source/core/tool/rangenam.cxx3
12 files changed, 128 insertions, 37 deletions
diff --git a/sc/source/core/data/clipparam.cxx b/sc/source/core/data/clipparam.cxx
index c39b69c3385a..0ed26abbde82 100644
--- a/sc/source/core/data/clipparam.cxx
+++ b/sc/source/core/data/clipparam.cxx
@@ -175,7 +175,7 @@ void ScClipParam::transpose()
SCCOL nColOrigin = p->aStart.Col();
SCROW nRowOrigin = p->aStart.Row();
- for ( size_t i = 1, n = maRanges.size(); i < n; ++i )
+ for ( size_t i = 0, n = maRanges.size(); i < n; ++i )
{
p = maRanges[ i ];
SCCOL nColDelta = p->aStart.Col() - nColOrigin;
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index b177acff7be7..8d599d2d08d4 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -180,12 +180,12 @@ ScDPCacheTable::~ScDPCacheTable()
sal_Int32 ScDPCacheTable::getRowSize() const
{
- return getCache()->GetRowCount();
+ return mpCache ? getCache()->GetRowCount() : 0;
}
sal_Int32 ScDPCacheTable::getColSize() const
{
- return getCache()->GetColumnCount();
+ return mpCache ? getCache()->GetColumnCount() : 0;
}
void ScDPCacheTable::fillTable(
@@ -313,6 +313,9 @@ void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, c
const ScDPItemData* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
{
+ if (!mpCache)
+ return NULL;
+
SCROW nId= getCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
return getCache()->GetItemDataById( nCol, nId );
}
@@ -331,6 +334,8 @@ void ScDPCacheTable::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, boo
}
String ScDPCacheTable::getFieldName(SCCOL nIndex) const
{
+ if (!mpCache)
+ return String();
return getCache()->GetDimensionName( nIndex );
}
@@ -410,7 +415,7 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
SCROW ScDPCacheTable::getOrder(long nDim, SCROW nIndex) const
{
- return getCache()->GetOrder(nDim, nIndex);
+ return mpCache ? getCache()->GetOrder(nDim, nIndex) : 0;
}
void ScDPCacheTable::clear()
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 7f5abef802ea..25864796da44 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -469,8 +469,11 @@ void ScDPObject::CreateObjects()
{
DBG_ASSERT( !pServDesc, "DPSource could not be created" );
ScDPTableData* pData = GetTableData();
- ScDPSource* pSource = new ScDPSource( pData );
- xSource = pSource;
+ if (pData)
+ {
+ ScDPSource* pSource = new ScDPSource( pData );
+ xSource = pSource;
+ }
}
if (pSaveData)
@@ -1848,6 +1851,9 @@ sal_Bool ScDPObject::FillOldParam(ScPivotParam& rParam) const
{
((ScDPObject*)this)->CreateObjects(); // xSource is needed for field numbers
+ if (!xSource.is())
+ return false;
+
rParam.nCol = aOutRange.aStart.Col();
rParam.nRow = aOutRange.aStart.Row();
rParam.nTab = aOutRange.aStart.Tab();
@@ -1941,6 +1947,8 @@ sal_Bool ScDPObject::FillLabelData(ScPivotParam& rParam)
rParam.maLabelArray.clear();
((ScDPObject*)this)->CreateObjects();
+ if (!xSource.is())
+ return false;
uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
uno::Reference<container::XIndexAccess> xDims = new ScNameToIndexAccess( xDimsName );
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 85316828d15f..9278ffadd87e 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -967,7 +967,10 @@ void ScDPSaveData::SetPosition( ScDPSaveDimension* pDim, long nNew )
{
if (pDim == &(*it))
{
- aDimList.erase(it);
+ // Tell ptr_vector to give up ownership of this element. Don't
+ // delete this instance as it is re-inserted into the container
+ // later.
+ aDimList.release(it).release();
break;
}
}
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index 72c0f06911b1..194cc412762a 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -136,10 +136,18 @@ void ScDatabaseDPData::SetEmptyFlags( sal_Bool /* bIgnoreEmptyRows */, sal_Bool
void ScDatabaseDPData::CreateCacheTable()
{
if (!aCacheTable.empty())
+ // cache table already created.
return;
if (!aCacheTable.hasCache())
- aCacheTable.setCache(mrImport.CreateCache());
+ {
+ const ScDPCache* pCache = mrImport.CreateCache();
+ if (!pCache)
+ // Cache creation failed. Perhaps invalid database connection.
+ return;
+
+ aCacheTable.setCache(pCache);
+ }
aCacheTable.fillTable();
}
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 554a22773dd6..3130ee05ba8d 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1402,7 +1402,12 @@ void ScTable::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
void ScTable::UpdateInsertTab(SCTAB nTable)
{
- if (nTab >= nTable) nTab++;
+ if (nTab >= nTable)
+ {
+ nTab++;
+ if (pDBDataNoName)
+ pDBDataNoName->UpdateMoveTab(nTab - 1 ,nTab);
+ }
for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].UpdateInsertTab(nTable);
if (IsStreamValid())
@@ -1411,7 +1416,12 @@ void ScTable::UpdateInsertTab(SCTAB nTable)
void ScTable::UpdateDeleteTab( SCTAB nTable, sal_Bool bIsMove, ScTable* pRefUndo )
{
- if (nTab > nTable) nTab--;
+ if (nTab > nTable)
+ {
+ nTab--;
+ if (pDBDataNoName)
+ pDBDataNoName->UpdateMoveTab(nTab + 1,nTab);
+ }
SCCOL i;
if (pRefUndo)
diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx
index 4118f9dcd7f9..d5fe2701f459 100644
--- a/sc/source/core/tool/dbcolect.cxx
+++ b/sc/source/core/tool/dbcolect.cxx
@@ -827,7 +827,8 @@ ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCO
ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const
{
- ScDBData* pDataEmpty = NULL;
+ ScDBData* pAnonData = pDoc->GetAnonymousDBData(nTab);
+
if (pItems)
{
for (sal_uInt16 i = 0; i < nCount; i++)
@@ -843,7 +844,13 @@ ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const
}
}
- return pDataEmpty;
+ if (pAnonData)
+ {
+ if ( pAnonData->HasAutoFilter() || pAnonData->HasQueryParam())
+ return pAnonData;
+ }
+
+ return NULL;
}
sal_Bool ScDBCollection::SearchName( const String& rName, sal_uInt16& rIndex ) const
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index c4a8cdd346cd..c72f35402f2c 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1661,9 +1661,11 @@ void ScInterpreter::ScIsEmpty()
nRes = 1;
}
break;
+ case svExternalSingleRef:
+ case svExternalDoubleRef:
case svMatrix:
{
- ScMatrixRef pMat = PopMatrix();
+ ScMatrixRef pMat = GetMatrix();
if ( !pMat )
; // nothing
else if ( !pJumpMatrix )
@@ -2509,26 +2511,44 @@ void ScInterpreter::ScIsOdd()
PushInt( !IsEven() );
}
-
void ScInterpreter::ScN()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScN" );
- sal_uInt16 nErr = nGlobalError;
- nGlobalError = 0;
- // Temporarily override the ConvertStringToValue() error for
- // GetCellValue() / GetCellValueOrZero()
- sal_uInt16 nSErr = mnStringNoValueError;
- mnStringNoValueError = errCellNoValue;
+ switch (GetRawStackType())
+ {
+ case svSingleRef:
+ case svDoubleRef:
+ case svMatrix:
+ case svExternalSingleRef:
+ case svExternalDoubleRef:
+ {
+ ScMatrixRef pMat = GetMatrix();
+ SCSIZE nC, nR;
+ pMat->GetDimensions(nC, nR);
+ if (!nC || !nR)
+ PushDouble(0);
+ else
+ PushDouble(pMat->GetDouble(0, 0));
+ return;
+ }
+ case svString:
+ PushDouble(0);
+ return;
+ default:
+ ;
+ }
+
+ // Default action
double fVal = GetDouble();
- mnStringNoValueError = nSErr;
- if ( nGlobalError == NOTAVAILABLE || nGlobalError == errCellNoValue )
- nGlobalError = 0; // N(#NA) and N("text") are ok
- if ( !nGlobalError && nErr != NOTAVAILABLE )
- nGlobalError = nErr;
- PushDouble( fVal );
+ if (nGlobalError)
+ {
+ // Don't propagate the error. Push 0 instead.
+ nGlobalError = 0;
+ PushDouble(0);
+ return;
+ }
+ PushDouble(fVal);
}
-
void ScInterpreter::ScTrim()
{ // Doesn't only trim but writes out twice!
String aVal( GetString() );
@@ -5785,6 +5805,12 @@ void ScInterpreter::CalculateLookup(sal_Bool HLookup)
return;
}
}
+ else if (eType == svSingleRef)
+ {
+ PopSingleRef(nCol1, nRow1, nTab1);
+ nCol2 = nCol1;
+ nRow2 = nRow1;
+ }
else if (eType == svMatrix || eType == svExternalDoubleRef || eType == svExternalSingleRef)
{
pMat = GetMatrix();
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index bfe5b6b632ac..8de2e386c77f 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3397,6 +3397,20 @@ sal_Bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos
return bOk;
}
+namespace {
+
+class FindByPointer : ::std::unary_function<ScInterpreterTableOpParams, bool>
+{
+ const ScInterpreterTableOpParams* mpTableOp;
+public:
+ FindByPointer(const ScInterpreterTableOpParams* p) : mpTableOp(p) {}
+ bool operator() (const ScInterpreterTableOpParams& val) const
+ {
+ return &val == mpTableOp;
+ }
+};
+
+}
void ScInterpreter::ScTableOp()
{
@@ -3456,7 +3470,11 @@ void ScInterpreter::ScTableOp()
PushString( aCellString );
}
- pTableOp = pDok->aTableOpList.release( pDok->aTableOpList.end() ).release();
+ boost::ptr_vector< ScInterpreterTableOpParams >::iterator itr =
+ ::std::find_if(pDok->aTableOpList.begin(), pDok->aTableOpList.end(), FindByPointer(pTableOp));
+ if (itr != pDok->aTableOpList.end())
+ pTableOp = pDok->aTableOpList.release(itr).release();
+
// set dirty again once more to be able to recalculate original
for ( ::std::vector< ScFormulaCell* >::const_iterator iBroadcast(
pTableOp->aNotifiedFormulaCells.begin() );
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 3d764e44319b..e5e5c8a0968a 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -572,11 +572,16 @@ ScMatrixRef ScInterpreter::GetMatrix()
pMat = new ScMatrix(1, 1);
pMat->PutDouble(pToken->GetDouble(), 0, 0);
}
- else
+ else if (pToken->GetType() == svString)
{
pMat = new ScMatrix(1, 1);
pMat->PutString(pToken->GetString(), 0, 0);
}
+ else
+ {
+ pMat = new ScMatrix(1, 1);
+ pMat->PutEmpty(0, 0);
+ }
}
break;
case svExternalDoubleRef:
@@ -1978,14 +1983,10 @@ double lcl_TGetColumnSumProduct(ScMatrixRef pMatA, SCSIZE nRa,
return fResult;
}
+// no mathematical signum, but used to switch between adding and subtracting
double lcl_GetSign(double fValue)
{
- if (fValue < 0.0)
- return -1.0;
- else if (fValue > 0.0)
- return 1.0;
- else
- return 0.0;
+ return (fValue >= 0.0 ? 1.0 : -1.0 );
}
/* Calculates a QR decomposition with Householder reflection.
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 7395da73d33e..9b43b635823e 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -260,7 +260,9 @@ void ScRangeList::Join( const ScRange& r, bool bIsInList )
}
bool bJoinedInput = false;
- for ( size_t i = 0, nRanges = maRanges.size(); i < nRanges && pOver; ++i )
+ // We need to query the size of the container dynamically since its size
+ // may change during the loop.
+ for ( size_t i = 0; i < maRanges.size() && pOver; ++i )
{
ScRange* p = maRanges[i];
if ( p == pOver )
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index df5f43617ae1..7d2972cadc5b 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -476,6 +476,9 @@ sal_Bool ScRangeData::IsNameValid( const String& rName, ScDocument* pDoc )
{
/* XXX If changed, sc/source/filter/ftools/ftools.cxx
* ScfTools::ConvertToScDefinedName needs to be changed too. */
+ sal_Char a('.');
+ if (rName.Search(a, 0) != STRING_NOTFOUND)
+ return false;
xub_StrLen nPos = 0;
xub_StrLen nLen = rName.Len();
if ( !nLen || !ScCompiler::IsCharFlagAllConventions( rName, nPos++, SC_COMPILER_C_CHAR_NAME ) )