CompareOptions::CompareOptions( const ScDocument& rDoc, const ScQueryEntry& rEntry, utl::SearchParam::SearchType eSrchTyp ) :
aQueryEntry(rEntry),
eSearchType(eSrchTyp),
bMatchWholeCell(rDoc.GetDocOptions().IsMatchWholeCell())
{ // Wildcard and Regex search work only with equal or not equal. if (eSearchType != utl::SearchParam::SearchType::Normal &&
aQueryEntry.eOp != SC_EQUAL && aQueryEntry.eOp != SC_NOT_EQUAL)
eSearchType = utl::SearchParam::SearchType::Normal;
// Interpreter functions usually are case insensitive, except the simple // comparison operators, for which these options aren't used. Override in // struct if needed.
}
// Keep DoubleError if encountered // #i40539# if bEmpty is set, bVal/nVal are uninitialized if (!rCell1.mbEmpty && rCell1.mbValue && !std::isfinite(rCell1.mfValue)) return rCell1.mfValue; if (!rCell2.mbEmpty && rCell2.mbValue && !std::isfinite(rCell2.mfValue)) return rCell2.mfValue;
if (nStringQuery && pOptions)
{ const ScQueryEntry& rEntry = pOptions->aQueryEntry; const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems(); if (!rItems.empty())
{ const ScQueryEntry::Item& rItem = rItems[0]; if (rItem.meType != ScQueryEntry::ByString && !rItem.maString.isEmpty() &&
(rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL))
{ // As in ScTable::ValidQuery() match a numeric string for a // number query that originated from a string, e.g. in SUMIF // and COUNTIF. Transliteration is not needed here. bool bEqual = false; if (nStringQuery == 1)
bEqual = rCell1.maStr == rItem.maString; else
bEqual = rCell2.maStr == rItem.maString;
double CompareFunc( const Compare::Cell& rCell1, double fCell2, const CompareOptions* pOptions )
{ // Keep DoubleError if encountered // #i40539# if bEmpty is set, bVal/nVal are uninitialized if (!rCell1.mbEmpty && rCell1.mbValue && !std::isfinite(rCell1.mfValue)) return rCell1.mfValue; if (!std::isfinite(fCell2)) return fCell2;
bool bStringQuery = false; double fRes = 0; if (rCell1.mbEmpty)
{ if (fCell2 != 0.0)
{ if (fCell2 < 0.0)
fRes = 1; // empty cell > -x else
fRes = -1; // empty cell < x
} // else: empty cell == 0.0
} elseif (rCell1.mbValue)
{ if (!rtl::math::approxEqual(rCell1.mfValue, fCell2))
{ if (rCell1.mfValue - fCell2 < 0)
fRes = -1; else
fRes = 1;
}
} else
{
fRes = 1; // string is greater than number
bStringQuery = true;
}
if (bStringQuery && pOptions)
{ const ScQueryEntry& rEntry = pOptions->aQueryEntry; const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems(); if (!rItems.empty())
{ const ScQueryEntry::Item& rItem = rItems[0]; if (rItem.meType != ScQueryEntry::ByString && !rItem.maString.isEmpty() &&
(rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL))
{ // As in ScTable::ValidQuery() match a numeric string for a // number query that originated from a string, e.g. in SUMIF // and COUNTIF. Transliteration is not needed here. bool bEqual = rCell1.maStr == rItem.maString;
double CompareFunc( double fCell1, double fCell2 )
{ // Keep DoubleError if encountered // #i40539# if bEmpty is set, bVal/nVal are uninitialized if (!std::isfinite(fCell1)) return fCell1; if (!std::isfinite(fCell2)) return fCell2;
double fRes = 0.0;
if (!rtl::math::approxEqual(fCell1, fCell2))
{ if (fCell1 - fCell2 < 0.0)
fRes = -1; else
fRes = 1;
}
return fRes;
}
double CompareEmptyToNumericFunc( double fCell2 )
{ // Keep DoubleError if encountered // #i40539# if bEmpty is set, bVal/nVal are uninitialized if (!std::isfinite(fCell2)) return fCell2;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.