LibreOffice Module sc (master) 1
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ScLookupCache Class Referencefinal

Lookup cache for one range used with interpreter functions such as VLOOKUP and MATCH. More...

#include <lookupcache.hxx>

Inheritance diagram for ScLookupCache:
[legend]
Collaboration diagram for ScLookupCache:
[legend]

Classes

struct  Hash
 
class  QueryCriteria
 
struct  QueryCriteriaAndResult
 
struct  QueryKey
 

Public Types

enum  Result {
  NOT_CACHED ,
  CRITERIA_DIFFERENT ,
  NOT_AVAILABLE ,
  FOUND
}
 
enum  QueryOp {
  UNKNOWN ,
  EQUAL ,
  LESS_EQUAL ,
  GREATER_EQUAL
}
 

Public Member Functions

 ScLookupCache (ScDocument *pDoc, const ScRange &rRange, ScLookupCacheMap &cacheMap)
 MUST be new'd because Notify() deletes. More...
 
virtual void Notify (const SfxHint &rHint) override
 Remove from document structure and delete (!) cache on modify hint. More...
 
Result lookup (ScAddress &o_rResultAddress, const QueryCriteria &rCriteria, const ScAddress &rQueryAddress) const
 
SCROW lookup (const QueryCriteria &rCriteria) const
 
bool insert (const ScAddress &rResultAddress, const QueryCriteria &rCriteria, const ScAddress &rQueryAddress, const bool bAvailable)
 Insert query and result. More...
 
const ScRangegetRange () const
 
ScLookupCacheMapgetCacheMap () const
 
- Public Member Functions inherited from SvtListener
 SvtListener ()=default
 
 SvtListener (const SvtListener &r)=default
 
virtual ~SvtListener () COVERITY_NOEXCEPT_FALSE
 
bool StartListening (SvtBroadcaster &rBroadcaster)
 
void EndListening (SvtBroadcaster &rBroadcaster)
 
void EndListeningAll ()
 
void CopyAllBroadcasters (const SvtListener &r)
 
bool HasBroadcaster () const
 
virtual void Notify (const SfxHint &rHint)
 
virtual void Query (QueryBase &rQuery) const
 

Private Member Functions

 ScLookupCache (const ScLookupCache &)=delete
 
ScLookupCacheoperator= (const ScLookupCache &)=delete
 

Private Attributes

std::unordered_map< QueryKey, QueryCriteriaAndResult, QueryKey::HashmaQueryMap
 
ScRange maRange
 
ScDocumentmpDoc
 
ScLookupCacheMapmCacheMap
 

Detailed Description

Lookup cache for one range used with interpreter functions such as VLOOKUP and MATCH.

Caches query for a specific row and the resulting address looked up, in case other lookups of the same query in the same row are to be performed, which usually occur to obtain a different offset column of the same query.

Definition at line 39 of file lookupcache.hxx.

Member Enumeration Documentation

◆ QueryOp

Enumerator
UNKNOWN 
EQUAL 
LESS_EQUAL 
GREATER_EQUAL 

Definition at line 51 of file lookupcache.hxx.

◆ Result

Enumerator
NOT_CACHED 
CRITERIA_DIFFERENT 

Query not found in cache.

NOT_AVAILABLE 

Different criteria for same query position exists.

FOUND 

Criteria not available in lookup range.

Criteria found.

Definition at line 43 of file lookupcache.hxx.

Constructor & Destructor Documentation

◆ ScLookupCache() [1/2]

ScLookupCache::ScLookupCache ( ScDocument pDoc,
const ScRange rRange,
ScLookupCacheMap cacheMap 
)
inline

MUST be new'd because Notify() deletes.

Definition at line 113 of file lookupcache.hxx.

◆ ScLookupCache() [2/2]

ScLookupCache::ScLookupCache ( const ScLookupCache )
privatedelete

Member Function Documentation

◆ getCacheMap()

ScLookupCacheMap & ScLookupCache::getCacheMap ( ) const
inline

Definition at line 138 of file lookupcache.hxx.

References mCacheMap.

Referenced by ScDocument::RemoveLookupCache().

◆ getRange()

const ScRange & ScLookupCache::getRange ( ) const
inline

Definition at line 136 of file lookupcache.hxx.

References maRange.

Referenced by ScDocument::RemoveLookupCache().

◆ insert()

bool ScLookupCache::insert ( const ScAddress rResultAddress,
const QueryCriteria rCriteria,
const ScAddress rQueryAddress,
const bool  bAvailable 
)

Insert query and result.

Parameters
bAvailablePass sal_False if the search didn't deliver a result. A subsequent lookup() then will return Result::NOT_AVAILABLE.
Returns
successful insertion.

Definition at line 101 of file lookupcache.cxx.

References ScLookupCache::QueryCriteria::getQueryOp(), ScLookupCache::QueryCriteriaAndResult::maAddress, maQueryMap, and ScAddress::SetRow().

Referenced by ScInterpreter::LookupQueryWithCache().

◆ lookup() [1/2]

SCROW ScLookupCache::lookup ( const QueryCriteria rCriteria) const

Definition at line 87 of file lookupcache.cxx.

References maQueryMap.

◆ lookup() [2/2]

ScLookupCache::Result ScLookupCache::lookup ( ScAddress o_rResultAddress,
const QueryCriteria rCriteria,
const ScAddress rQueryAddress 
) const

◆ Notify()

void ScLookupCache::Notify ( const SfxHint rHint)
overridevirtual

Remove from document structure and delete (!) cache on modify hint.

Reimplemented from SvtListener.

Definition at line 115 of file lookupcache.cxx.

References SfxHint::GetId(), ScDocument::IsInDtorClear(), mpDoc, and ScDocument::RemoveLookupCache().

◆ operator=()

ScLookupCache & ScLookupCache::operator= ( const ScLookupCache )
privatedelete

Member Data Documentation

◆ maQueryMap

std::unordered_map< QueryKey, QueryCriteriaAndResult, QueryKey::Hash > ScLookupCache::maQueryMap
private

Definition at line 192 of file lookupcache.hxx.

Referenced by insert(), and lookup().

◆ maRange

ScRange ScLookupCache::maRange
private

Definition at line 193 of file lookupcache.hxx.

Referenced by getRange().

◆ mCacheMap

ScLookupCacheMap& ScLookupCache::mCacheMap
private

Definition at line 195 of file lookupcache.hxx.

Referenced by getCacheMap().

◆ mpDoc

ScDocument* ScLookupCache::mpDoc
private

Definition at line 194 of file lookupcache.hxx.

Referenced by Notify().


The documentation for this class was generated from the following files: