[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-4-1-6+backports' - 2 commits - sc/inc sc/source
Martin Nathansen
marsianer at gmail.com
Mon Jun 25 09:43:21 UTC 2018
sc/inc/dociter.hxx | 6 +--
sc/inc/queryentry.hxx | 3 -
sc/inc/queryparam.hxx | 5 --
sc/source/core/data/dociter.cxx | 69 +++++++------------------------------
sc/source/core/data/table3.cxx | 2 -
sc/source/core/tool/doubleref.cxx | 2 -
sc/source/core/tool/interpr1.cxx | 18 ++++++++-
sc/source/core/tool/interpr4.cxx | 5 --
sc/source/core/tool/queryentry.cxx | 2 -
sc/source/core/tool/queryparam.cxx | 31 +++-------------
10 files changed, 44 insertions(+), 99 deletions(-)
New commits:
commit 97f01dcc8a7fa2a1840ec4c5c456b62d89e56e85
Author: Martin Nathansen <marsianer at gmail.com>
Date: Thu Mar 1 17:04:47 2018 +0000
Revert "tdf#35636: Match also empty cells (backport of the idea)"
This reverts commit 86a9cf80c88d380dbee5111c587bf09ea9b424d6.
Revertion 2/2 to fix regression trac#23641.
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index ac19951e50dc..cfffb7ef2f56 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -284,7 +284,7 @@ private:
bool bAdvanceQuery;
bool bIgnoreMismatchOnLeadingStrings;
- bool GetThis();
+ ScBaseCell* GetThis();
/* Only works if no regular expression is involved, only
searches for rows in one column, and only the first
@@ -302,8 +302,8 @@ public:
const ScQueryParam& aParam, bool bMod = true);
// for bMod = FALSE the QueryParam has to be filled
// (bIsString)
- bool GetFirst();
- bool GetNext();
+ ScBaseCell* GetFirst();
+ ScBaseCell* GetNext();
SCCOL GetCol() { return nCol; }
SCROW GetRow() { return nRow; }
diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx
index 7c67aa19558f..08a2f811fd77 100644
--- a/sc/inc/queryentry.hxx
+++ b/sc/inc/queryentry.hxx
@@ -42,9 +42,8 @@ struct SC_DLLPUBLIC ScQueryEntry
QueryType meType;
double mfVal;
OUString maString;
- bool mbMatchEmpty;
- Item() : meType(ByValue), mfVal(0.0), mbMatchEmpty(false) {}
+ Item() : meType(ByValue), mfVal(0.0) {}
bool operator== (const Item& r) const;
};
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 6fb95b03b1b3..445c23c06aac 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -25,8 +25,6 @@
#include <boost/ptr_container/ptr_vector.hpp>
-class SvNumberFormatter;
-
struct ScDBQueryParamInternal;
struct ScQueryEntry;
@@ -51,8 +49,7 @@ struct ScQueryParamBase
ScQueryEntry* FindEntryByField(SCCOLROW nField, bool bNew);
SC_DLLPUBLIC void RemoveEntryByField(SCCOLROW nField);
void Resize(size_t nNew);
- void FillInExcelSyntax(const OUString& aCellStr, SCSIZE nIndex,
- SvNumberFormatter* pFormatter);
+ void FillInExcelSyntax(const OUString& aCellStr, SCSIZE nIndex);
protected:
typedef boost::ptr_vector<ScQueryEntry> EntriesType;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 16c6d1fee94f..e050e5816c5a 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -56,31 +56,6 @@ namespace
{
rStr = ScGlobal::pCharClass->uppercase(rStr.trim());
}
-
- void lcl_FillBlankCells( std::vector<ColEntry> &rSrcCols, std::vector<ColEntry> &rDestCols, SCROW nLastRow, bool bMatchEmpty )
- {
- rDestCols.clear();
-
- if (!bMatchEmpty)
- {
- rDestCols = rSrcCols;
- return;
- }
-
- for( SCROW i = 0, n = 0; i <= nLastRow; ++i )
- {
- rDestCols.push_back(ColEntry());
- rDestCols.back().nRow = i;
-
- if ( rSrcCols[n].nRow == i )
- {
- rDestCols.back().pCell = rSrcCols[n].pCell;
- ++n;
- }
- else
- rDestCols.back().pCell = NULL;
- }
- }
}
ScDocumentIterator::ScDocumentIterator( ScDocument* pDocument,
@@ -1203,7 +1178,7 @@ ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, SCTAB nTable,
nAttrEndRow = 0;
}
-bool ScQueryCellIterator::GetThis()
+ScBaseCell* ScQueryCellIterator::GetThis()
{
if (nTab >= pDoc->GetTableCount())
OSL_FAIL("try to access index out of bounds, FIX IT");
@@ -1218,13 +1193,6 @@ bool ScQueryCellIterator::GetThis()
!mpParam->bHasHeader && rItem.meType == ScQueryEntry::ByString &&
((mpParam->bByRow && nRow == mpParam->nRow1) ||
(!mpParam->bByRow && nCol == mpParam->nCol1));
-
- bool bMatchEmpty = ( rItem.mbMatchEmpty && rEntry.GetQueryItems().size() == 1 );
-
- std::vector<ColEntry> rColItems;
- SCROW nLastRow = pCol->GetLastDataPos();
- lcl_FillBlankCells( pCol->maItems, rColItems, std::max(nLastRow, mpParam->nRow2), bMatchEmpty );
-
for ( ;; )
{
if ( nRow > mpParam->nRow2 )
@@ -1235,16 +1203,13 @@ bool ScQueryCellIterator::GetThis()
do
{
if ( ++nCol > mpParam->nCol2 )
- return false; // Over and out
+ return NULL; // Over and out
if ( bAdvanceQuery )
{
AdvanceQueryParamEntryField();
nFirstQueryField = rEntry.nField;
}
-
pCol = &(pDoc->maTabs[nTab])->aCol[nCol];
- nLastRow = pCol->GetLastDataPos();
- lcl_FillBlankCells( pCol->maItems, rColItems, std::max(nLastRow, mpParam->nRow2), bMatchEmpty );
} while ( pCol->maItems.empty() );
pCol->Search( nRow, nColRow );
bFirstStringIgnore = bIgnoreMismatchOnLeadingStrings &&
@@ -1252,19 +1217,13 @@ bool ScQueryCellIterator::GetThis()
mpParam->bByRow;
}
- while ( nColRow < rColItems.size() && rColItems[nColRow].nRow < nRow )
+ while ( nColRow < pCol->maItems.size() && pCol->maItems[nColRow].nRow < nRow )
nColRow++;
- if ( nColRow < rColItems.size() &&
- (nRow = rColItems[nColRow].nRow) <= mpParam->nRow2 )
+ if ( nColRow < pCol->maItems.size() &&
+ (nRow = pCol->maItems[nColRow].nRow) <= mpParam->nRow2 )
{
- ScBaseCell* pCell = rColItems[nColRow].pCell;
-
- // empty cell when empty cells should be matched
- if ( bMatchEmpty && ( pCell == NULL ) )
- return true;
-
-
+ ScBaseCell* pCell = pCol->maItems[nColRow].pCell;
if (bAllStringIgnore && pCell->HasStringData())
++nRow;
else
@@ -1276,7 +1235,7 @@ bool ScQueryCellIterator::GetThis()
{
if ( nTestEqualCondition && bTestEqualCondition )
nTestEqualCondition |= nTestEqualConditionMatched;
- return true; // Found it!
+ return pCell; // Found it!
}
else if ( nStopOnMismatch )
{
@@ -1287,7 +1246,7 @@ bool ScQueryCellIterator::GetThis()
{
nTestEqualCondition |= nTestEqualConditionMatched;
nStopOnMismatch |= nStopOnMismatchOccurred;
- return false;
+ return NULL;
}
bool bStop;
if (bFirstStringIgnore)
@@ -1305,7 +1264,7 @@ bool ScQueryCellIterator::GetThis()
if (bStop)
{
nStopOnMismatch |= nStopOnMismatchOccurred;
- return false;
+ return NULL;
}
}
else
@@ -1318,7 +1277,7 @@ bool ScQueryCellIterator::GetThis()
}
}
-bool ScQueryCellIterator::GetFirst()
+ScBaseCell* ScQueryCellIterator::GetFirst()
{
if (nTab >= pDoc->GetTableCount())
OSL_FAIL("try to access index out of bounds, FIX IT");
@@ -1331,7 +1290,7 @@ bool ScQueryCellIterator::GetFirst()
return GetThis();
}
-bool ScQueryCellIterator::GetNext()
+ScBaseCell* ScQueryCellIterator::GetNext()
{
++nRow;
if ( nStopOnMismatch )
@@ -1404,17 +1363,17 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
{
// First equal entry or last smaller than (greater than) entry.
SCSIZE nColRowSave;
- bool bNext = false;
+ ScBaseCell* pNext = 0;
do
{
nFoundCol = GetCol();
nFoundRow = GetRow();
nColRowSave = nColRow;
- } while ( !IsEqualConditionFulfilled() && (bNext = GetNext() ) );
+ } while ( !IsEqualConditionFulfilled() && (pNext = GetNext()) != NULL );
// There may be no pNext but equal condition fulfilled if regular
// expressions are involved. Keep the found entry and proceed.
- if (!bNext && !IsEqualConditionFulfilled())
+ if (!pNext && !IsEqualConditionFulfilled())
{
// Step back to last in range and adjust position markers for
// GetNumberFormat() or similar.
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index d13992d5f7aa..73f952ddc9e0 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2041,7 +2041,7 @@ bool ScTable::CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow
if (nIndex < nNewEntries)
{
rQueryParam.GetEntry(nIndex).nField = pFields[nCol - nCol1];
- rQueryParam.FillInExcelSyntax(aCellStr, nIndex, NULL);
+ rQueryParam.FillInExcelSyntax(aCellStr, nIndex);
nIndex++;
if (nIndex < nNewEntries)
rQueryParam.GetEntry(nIndex).eConnect = SC_AND;
diff --git a/sc/source/core/tool/doubleref.cxx b/sc/source/core/tool/doubleref.cxx
index 94976d488845..f7d873cb61a8 100644
--- a/sc/source/core/tool/doubleref.cxx
+++ b/sc/source/core/tool/doubleref.cxx
@@ -185,7 +185,7 @@ bool lcl_createExcelQuery(
if (nIndex < nNewEntries)
{
pParam->GetEntry(nIndex).nField = aFields[nCol];
- pParam->FillInExcelSyntax(OUString(aCellStr), nIndex, NULL);
+ pParam->FillInExcelSyntax(OUString(aCellStr), nIndex);
nIndex++;
if (nIndex < nNewEntries)
pParam->GetEntry(nIndex).eConnect = SC_AND;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 0ab4657aeac0..c90f07d22c81 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5701,7 +5701,11 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc )
}
else
{
- rParam.FillInExcelSyntax(aString, 0, pFormatter);
+ rParam.FillInExcelSyntax(aString, 0);
+ sal_uInt32 nIndex = 0;
+ bool bNumber = pFormatter->IsNumberFormat(
+ rItem.maString, nIndex, rItem.mfVal);
+ rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
if (rItem.meType == ScQueryEntry::ByString)
rParam.bRegExp = MayBeRegExp(rItem.maString, pDok);
}
@@ -6000,7 +6004,11 @@ void ScInterpreter::ScCountIf()
}
else
{
- rParam.FillInExcelSyntax(aString, 0, pFormatter);
+ rParam.FillInExcelSyntax(aString, 0);
+ sal_uInt32 nIndex = 0;
+ bool bNumber = pFormatter->IsNumberFormat(
+ rItem.maString, nIndex, rItem.mfVal);
+ rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
if (rItem.meType == ScQueryEntry::ByString)
rParam.bRegExp = MayBeRegExp(rItem.maString, pDok);
}
@@ -6248,7 +6256,11 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc )
}
else
{
- rParam.FillInExcelSyntax(aString, 0, pFormatter);
+ rParam.FillInExcelSyntax(aString, 0);
+ sal_uInt32 nIndex = 0;
+ bool bNumber = pFormatter->IsNumberFormat(
+ rItem.maString, nIndex, rItem.mfVal);
+ rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
if (rItem.meType == ScQueryEntry::ByString)
rParam.bRegExp = MayBeRegExp(rItem.maString, pDok);
}
diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx
index 53ffb5d80aba..1ac1a899327b 100644
--- a/sc/source/core/tool/queryentry.cxx
+++ b/sc/source/core/tool/queryentry.cxx
@@ -32,7 +32,7 @@
bool ScQueryEntry::Item::operator== (const Item& r) const
{
- return meType == r.meType && mfVal == r.mfVal && maString.equals(r.maString) && mbMatchEmpty == r.mbMatchEmpty;
+ return meType == r.meType && mfVal == r.mfVal && maString.equals(r.maString);
}
ScQueryEntry::ScQueryEntry() :
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 8ebf5e974d55..781816a3d9e5 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -20,8 +20,6 @@
#include "queryparam.hxx"
#include "queryentry.hxx"
-#include <svl/zforlist.hxx>
-
namespace {
const size_t MAXQUERY = 8;
@@ -168,17 +166,17 @@ void ScQueryParamBase::Resize(size_t nNew)
}
}
-void ScQueryParamBase::FillInExcelSyntax(const OUString& rStr, SCSIZE nIndex, SvNumberFormatter *pFormatter)
+void ScQueryParamBase::FillInExcelSyntax(const OUString& rStr, SCSIZE nIndex)
{
const String aCellStr = rStr;
- if ( nIndex >= maEntries.size() )
- Resize( nIndex+1 );
-
- ScQueryEntry& rEntry = GetEntry(nIndex);
- ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
-
if (aCellStr.Len() > 0)
{
+ if ( nIndex >= maEntries.size() )
+ Resize( nIndex+1 );
+
+ ScQueryEntry& rEntry = GetEntry(nIndex);
+ ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+
rEntry.bDoQuery = sal_True;
// Operatoren herausfiltern
if (aCellStr.GetChar(0) == '<')
@@ -220,21 +218,6 @@ void ScQueryParamBase::FillInExcelSyntax(const OUString& rStr, SCSIZE nIndex, Sv
rItem.maString = aCellStr;
rEntry.eOp = SC_EQUAL;
}
-
- }
-
- if (pFormatter)
- {
- sal_uInt32 nFormat = 0;
- bool bNumber = pFormatter->IsNumberFormat( rItem.maString, nFormat, rItem.mfVal);
- rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
-
- /* TODO: pFormatter currently is also used as a flag whether matching
- * empty cells with an empty string is triggered from the interpreter.
- * This could be handled independently if all queries should support
- * it, needs to be evaluated if that actually is desired. */
- if (rItem.meType == ScQueryEntry::ByString)
- rItem.mbMatchEmpty = (rEntry.eOp == SC_EQUAL && rItem.maString.isEmpty());
}
}
commit 430c267a0fcdd7b501c7aa7734249168d00a0c4b
Author: Martin Nathansen <marsianer at gmail.com>
Date: Thu Mar 1 17:03:09 2018 +0000
Revert "Resolves: tdf#39316 add matrix empty cells to ScInterpreter::QueryMatrixType()"
This reverts commit fdfda3fba4267a9b52e62b20bc94983091398f7a.
Revertion 1/2 to fix regression trac#23641.
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 399b0246c7fb..9057166af3d2 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1849,11 +1849,6 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_
PushTempToken( new ScMatrixCellResultToken( xMat, xRes.get()));
rRetTypeExpr = NUMBERFORMAT_LOGICAL;
}
- else if ( xMat->IsEmpty( 0, 0))
- { // empty or empty cell
- FormulaTokenRef xRes = new ScEmptyCellToken( false, true); // not inherited, display empty
- PushTempToken( new ScMatrixCellResultToken( xMat, xRes.get()));
- }
else
{
String aStr( nMatVal.GetString());
More information about the Libreoffice-commits
mailing list