// Data and functionality for accessing cells in a specific way. // Needs specialization, see ScQueryCellIteratorAccess::Direct for what is needed. template< ScQueryCellIteratorAccess accessType > class ScQueryCellIteratorAccessSpecific
{
};
// The implementation using linear direct mdds access. template<> class ScQueryCellIteratorAccessSpecific< ScQueryCellIteratorAccess::Direct >
{ protected:
ScQueryCellIteratorAccessSpecific( ScDocument& rDocument, ScInterpreterContext& rContext, const ScQueryParam& rParam, bool bReverseSearch ); // Initialize position for new column. void InitPos(); // Increase position (next row). void IncPos(); // Next mdds block. If access is not direct/linear, then // should call IncPos(). void IncBlock();
// Decrease position (prev row). void DecPos(); // Prev mdds block. If access is not direct/linear, then // should call DecPos(). void DecBlock();
// These members needs to be available already in the base class. typedef sc::CellStoreType::const_position_type PositionType;
PositionType maCurPos;
ScQueryParam maParam;
ScDocument& rDoc;
ScInterpreterContext& mrContext; bool mbReverseSearch;
SCTAB nTab;
SCCOL nCol;
SCROW nRow;
// Initialize for backward search. (no need for SortedCache) staticvoid DecPos() {}; staticvoid DecBlock() {};
// These members needs to be available already in the base class. typedef sc::CellStoreType::const_position_type PositionType;
PositionType maCurPos;
ScQueryParam maParam;
ScDocument& rDoc;
ScInterpreterContext& mrContext; bool mbReverseSearch;
SCTAB nTab;
SCCOL nCol;
SCROW nRow; const ScColumn* pColumn; // matching nCol, set by InitPos()
// Data and functionality for specific types of query. template< ScQueryCellIteratorType iteratorType > class ScQueryCellIteratorTypeSpecific
{ protected: bool HandleItemFound(); // not implemented, needs specialization
};
// Shared code for query-based iterators. The main class. template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType > class ScQueryCellIteratorBase
: public ScQueryCellIteratorAccessSpecific< accessType >
, public ScQueryCellIteratorTypeSpecific< queryType >
{ typedef ScQueryCellIteratorAccessSpecific< accessType > AccessBase; typedef ScQueryCellIteratorTypeSpecific< queryType > TypeBase; protected: enum StopOnMismatchBits
{
nStopOnMismatchDisabled = 0x00,
nStopOnMismatchEnabled = 0x01,
nStopOnMismatchOccurred = 0x02,
nStopOnMismatchExecuted = nStopOnMismatchEnabled | nStopOnMismatchOccurred
};
// Make base members directly visible here (templated bases need 'this->'). using AccessBase::maCurPos; using AccessBase::maParam; using AccessBase::rDoc; using AccessBase::mrContext; using AccessBase::mbReverseSearch; using AccessBase::nTab; using AccessBase::nCol; using AccessBase::nRow; using AccessBase::IncPos; using AccessBase::IncBlock; using AccessBase::DecPos; using AccessBase::DecBlock; usingtypename AccessBase::BinarySearchCellType; using AccessBase::MakeBinarySearchIndexer; using TypeBase::HandleItemFound;
void InitPos();
// The actual query function. It will call HandleItemFound() for any matching type // and return if HandleItemFound() returns true. void PerformQuery();
/* Only works if no regular expression is involved, only searches for rows in one column or onlysearchesforcolsinonerow,andonlythefirstqueryentryisconsideredwithsimple conditionsSC_LESS,SC_LESS_EQUAL,SC_EQUAL(sortedascending)orSC_GREATER,SC_GREATER_EQUAL (sorteddescending).ItdeliversastartingpointsettonRow/nCol,i.e.thelastrow/colthat eithermatchesthesearchedforvalue,orthelastrow/colthatmatchesthecondition. Continuewithe.g.GetThis()andGetNext()afterwards.Returnsfalseifthesearchedforvalue isnotinthesearchrangeoriftherangeisnotproperlysorted,withnRow/nColinthatcase settothefirstroworafterthelastrow.InthatcaseuseGetFirst().
*/ bool BinarySearch( SCCOLROW col_row, bool forEqual = false );
/** If set, an additional test for SC_EQUAL condition is executedinScTable::ValidQuery()ifSC_LESS_EQUALor SC_GREATER_EQUALconditionsaretobetested.Maybe usedwhereacellrangeisassumedtobesortedtostop
if an equal match is found. */ void SetTestEqualCondition( bool bVal )
{
nTestEqualCondition = sal::static_int_cast<sal_uInt8>(bVal ?
nTestEqualConditionEnabled :
nTestEqualConditionDisabled);
} bool IsEqualConditionFulfilled() const
{ return nTestEqualCondition == nTestEqualConditionFulfilled; }
void HandleBestFitItemFound(SCCOL nBFitCol, SCROW nBFitRow)
{
nBestFitCol = nBFitCol;
nBestFitRow = nBFitRow;
} public:
ScQueryCellIteratorBase(ScDocument& rDocument, ScInterpreterContext& rContext, SCTAB nTable, const ScQueryParam& aParam, bool bMod, bool bReverse); // when !bMod, the QueryParam has to be filled // (bIsString)
// increments all Entry.nField, if column // changes, for ScInterpreter ScHLookup() void SetAdvanceQueryParamEntryField( bool bVal )
{ bAdvanceQuery = bVal; } void AdvanceQueryParamEntryField(); void AdvanceQueryParamEntryFieldForBinarySearch();
// The generic query iterator, used e.g. by VLOOKUP. template< ScQueryCellIteratorAccess accessType > class ScQueryCellIterator
: public ScQueryCellIteratorBase< accessType, ScQueryCellIteratorType::Generic >
{ typedef ScQueryCellIteratorBase< accessType, ScQueryCellIteratorType::Generic > Base; // Make base members directly visible here (templated bases need 'this->'). using Base::maParam; using Base::rDoc; using Base::mrContext; using Base::mbReverseSearch; using Base::nTab; using Base::nCol; using Base::nRow; using Base::InitPos; using Base::IncPos; using Base::DecPos; using Base::bIgnoreMismatchOnLeadingStrings; using Base::SetStopOnMismatch; using Base::SetTestEqualCondition; using Base::BinarySearch; usingtypename Base::PositionType; using Base::maCurPos; using Base::IsEqualConditionFulfilled; using Base::bAdvanceQuery; using Base::StoppedOnMismatch; using Base::nStopOnMismatch; using Base::nStopOnMismatchEnabled; using Base::nTestEqualCondition; using Base::nTestEqualConditionEnabled; using Base::nSortedBinarySearch; using Base::nBinarySearchDisabled; using Base::PerformQuery; using Base::getThisResult; using Base::nBestFitCol; using Base::nBestFitRow; using Base::nSearchOpCode;
/** In a range assumed to be sorted find either the last of asequenceofequalentriesorthelastbeinglessthan (orgreaterthan)thequeriedvalue.Usedbythe interpreterfor[HV]?LOOKUP()andMATCH().Columnand rowpositionofthefoundentryarereturned,otherwise invalid.
// Used by ScInterpreter::ScCountIf. template< ScQueryCellIteratorAccess accessType > class ScCountIfCellIterator
: public ScQueryCellIteratorBase< accessType, ScQueryCellIteratorType::CountIf >
{ protected: typedef ScQueryCellIteratorBase< accessType, ScQueryCellIteratorType::CountIf > Base; // Make base members directly visible here (templated bases need 'this->'). using Base::maParam; using Base::rDoc; using Base::nTab; using Base::nCol; using Base::nRow; using Base::InitPos; using Base::PerformQuery; using Base::SetAdvanceQueryParamEntryField; using Base::countIfCount;
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.