[Libreoffice-commits] .: 5 commits - sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Mon Nov 14 21:34:56 PST 2011
sc/source/core/data/dptablecache.cxx | 38 +++++++----------------------------
sc/source/core/data/dptabres.cxx | 4 +++
2 files changed, 12 insertions(+), 30 deletions(-)
New commits:
commit 1d4971d77afa492bfdbfd18113eff4f77b3100e3
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Nov 15 00:19:54 2011 -0500
Beware that the sequence can be empty.
And when it's empty, it causes an invalid array access later on.
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 84ce258..c1a1824 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -1369,6 +1369,10 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
// IsVisible() test is in ScDPResultDimension::FillMemberResults
// (not on data layout dimension)
+ if (!pSequences->getLength())
+ // empty sequence. Bail out.
+ return;
+
long nSize = GetSize(nMeasure);
sheet::MemberResult* pArray = pSequences->getArray();
OSL_ENSURE( rPos+nSize <= pSequences->getLength(), "bumm" );
commit 690e14ad035e642f4382d20b8b7b792762338126
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Mon Nov 14 23:21:02 2011 -0500
Unused local var.
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index ecfab69..5bbef8f 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -607,7 +607,6 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
const ScDPItemData* pCellData = GetItemDataById( nSourceField, nId );
bool bOk = false;
- bool bTestEqual = false;
if (rEntry.GetQueryItem().meType == ScQueryEntry::ByEmpty)
{
@@ -670,8 +669,6 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
bMatch = false; // RegExp must match entire cell string
if (bRealRegExp)
bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch);
- else
- bTestEqual = bMatch;
}
if (!bRealRegExp)
{
commit 10afa30240edec37a052ee87ff5b5e36c615abcd
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Mon Nov 14 23:19:21 2011 -0500
Used std::vector instead of C-style array.
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index cbf9065..ecfab69 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -582,12 +582,8 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
return true;
bool bMatchWholeCell = mpDoc->GetDocOptions().IsMatchWholeCell();
- //---------------------------------------------------------------
-
- const SCSIZE nFixedBools = 32;
- bool aBool[nFixedBools];
SCSIZE nEntryCount = rParam.GetEntryCount();
- bool* pPasst = ( nEntryCount <= nFixedBools ? &aBool[0] : new bool[nEntryCount] );
+ std::vector<bool> aPassed(nEntryCount, false);
long nPos = -1;
CollatorWrapper* pCollator = (rParam.bCaseSens ? ScGlobal::GetCaseCollator() :
@@ -753,31 +749,26 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
if (nPos == -1)
{
nPos++;
- pPasst[nPos] = bOk;
+ aPassed[nPos] = bOk;
}
else
{
if (rEntry.eConnect == SC_AND)
{
- pPasst[nPos] = pPasst[nPos] && bOk;
+ aPassed[nPos] = aPassed[nPos] && bOk;
}
else
{
nPos++;
- pPasst[nPos] = bOk;
+ aPassed[nPos] = bOk;
}
}
}
for (long j=1; j <= nPos; j++)
- {
- pPasst[0] = pPasst[0] || pPasst[j];
- }
-
- bool bRet = pPasst[0];
- if (pPasst != &aBool[0])
- delete [] pPasst;
+ aPassed[0] = aPassed[0] || aPassed[j];
+ bool bRet = aPassed[0];
return bRet;
}
commit 011878812eac685b76a925fa9ffb17a152c27e6a
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Mon Nov 14 23:13:26 2011 -0500
This can be for loop instead.
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 2810b51..cbf9065 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -589,14 +589,13 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
SCSIZE nEntryCount = rParam.GetEntryCount();
bool* pPasst = ( nEntryCount <= nFixedBools ? &aBool[0] : new bool[nEntryCount] );
- long nPos = -1;
- SCSIZE i = 0;
+ long nPos = -1;
CollatorWrapper* pCollator = (rParam.bCaseSens ? ScGlobal::GetCaseCollator() :
ScGlobal::GetCollator() );
::utl::TransliterationWrapper* pTransliteration = (rParam.bCaseSens ?
ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration());
- while ((i < nEntryCount) && rParam.GetEntry(i).bDoQuery)
+ for (size_t i = 0; i < nEntryCount && rParam.GetEntry(i).bDoQuery; ++i)
{
const ScQueryEntry& rEntry = rParam.GetEntry(i);
const ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
@@ -768,7 +767,6 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
pPasst[nPos] = bOk;
}
}
- i++;
}
for (long j=1; j <= nPos; j++)
commit 1d8a5ef0a69549b30045c7785e077c2fc7ce52db
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Mon Nov 14 23:10:03 2011 -0500
This bool array is not used here.
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 0ab7334..2810b51 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -586,10 +586,8 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
const SCSIZE nFixedBools = 32;
bool aBool[nFixedBools];
- bool aTest[nFixedBools];
SCSIZE nEntryCount = rParam.GetEntryCount();
bool* pPasst = ( nEntryCount <= nFixedBools ? &aBool[0] : new bool[nEntryCount] );
- bool* pTest = ( nEntryCount <= nFixedBools ? &aTest[0] : new bool[nEntryCount] );
long nPos = -1;
SCSIZE i = 0;
@@ -757,20 +755,17 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
{
nPos++;
pPasst[nPos] = bOk;
- pTest[nPos] = bTestEqual;
}
else
{
if (rEntry.eConnect == SC_AND)
{
pPasst[nPos] = pPasst[nPos] && bOk;
- pTest[nPos] = pTest[nPos] && bTestEqual;
}
else
{
nPos++;
pPasst[nPos] = bOk;
- pTest[nPos] = bTestEqual;
}
}
i++;
@@ -779,14 +774,11 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
for (long j=1; j <= nPos; j++)
{
pPasst[0] = pPasst[0] || pPasst[j];
- pTest[0] = pTest[0] || pTest[j];
}
bool bRet = pPasst[0];
if (pPasst != &aBool[0])
delete [] pPasst;
- if (pTest != &aTest[0])
- delete [] pTest;
return bRet;
}
More information about the Libreoffice-commits
mailing list