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

Cache table for external reference data. More...

#include <externalrefmgr.hxx>

Collaboration diagram for ScExternalRefCache:
[legend]

Classes

struct  Cell
 individual cell within cached external ref table. More...
 
struct  CellFormat
 
struct  DocItem
 Represents data cached for a single external document. More...
 
struct  RangeHash
 
struct  ReferencedStatus
 
struct  SingleRangeData
 
class  Table
 Represents a single cached table in an external document. More...
 
struct  TableName
 

Public Types

typedef ::formula::FormulaTokenRef TokenRef
 
typedef std::shared_ptr< ScTokenArrayTokenArrayRef
 
typedef std::shared_ptr< TableTableTypeRef
 
typedef std::unordered_map< OUString, size_t > TableNameIndexMap
 

Public Member Functions

 ScExternalRefCache (const ScDocument &rDoc)
 
 ~ScExternalRefCache ()
 
const OUString * getRealTableName (sal_uInt16 nFileId, const OUString &rTabName) const
 
const OUString * getRealRangeName (sal_uInt16 nFileId, const OUString &rRangeName) const
 
ScExternalRefCache::TokenRef getCellData (sal_uInt16 nFileId, const OUString &rTabName, SCCOL nCol, SCROW nRow, sal_uInt32 *pnFmtIndex)
 Get a cached cell data at specified cell location. More...
 
ScExternalRefCache::TokenArrayRef getCellRangeData (sal_uInt16 nFileId, const OUString &rTabName, const ScRange &rRange)
 Get a cached cell range data. More...
 
ScExternalRefCache::TokenArrayRef getRangeNameTokens (sal_uInt16 nFileId, const OUString &rName)
 
void setRangeNameTokens (sal_uInt16 nFileId, const OUString &rName, TokenArrayRef pArray)
 
bool isValidRangeName (sal_uInt16 nFileId, const OUString &rName) const
 
void setRangeName (sal_uInt16 nFileId, const OUString &rName)
 
void setCellData (sal_uInt16 nFileId, const OUString &rTabName, SCCOL nCol, SCROW nRow, TokenRef const &pToken, sal_uLong nFmtIndex)
 
void setCellRangeData (sal_uInt16 nFileId, const ScRange &rRange, const ::std::vector< SingleRangeData > &rData, const TokenArrayRef &pArray)
 
bool isDocInitialized (sal_uInt16 nFileId)
 
void initializeDoc (sal_uInt16 nFileId, const ::std::vector< OUString > &rTabNames, const OUString &rBaseName)
 
OUString getTableName (sal_uInt16 nFileId, size_t nCacheId) const
 
void getAllTableNames (sal_uInt16 nFileId, ::std::vector< OUString > &rTabNames) const
 
SCTAB getTabSpan (sal_uInt16 nFileId, const OUString &rStartTabName, const OUString &rEndTabName) const
 
void getAllNumberFormats (::std::vector< sal_uInt32 > &rNumFmts) const
 
bool setCacheDocReferenced (sal_uInt16 nFileId)
 Set all tables of a document as referenced, used only during store-to-file. More...
 
bool setCacheTableReferenced (sal_uInt16 nFileId, const OUString &rTabName, size_t nSheets)
 Set a table as referenced, used only during store-to-file. More...
 
void setAllCacheTableReferencedStati (bool bReferenced)
 
bool areAllCacheTablesReferenced () const
 
void getAllCachedDataSpans (const ScDocument &rSrcDoc, sal_uInt16 nFileId, sc::ColumnSpanSet &rSet) const
 Collect all cached non-empty cell positions, inferred directly from the cached data, not the cached range metadata stored separately in the Table. More...
 
bool getSrcDocTable (const ScDocument &rSrcDoc, const OUString &rTabName, SCTAB &rTab, sal_uInt16 nFileId) const
 
ScExternalRefCache::TableTypeRef getCacheTable (sal_uInt16 nFileId, size_t nTabIndex) const
 
ScExternalRefCache::TableTypeRef getCacheTable (sal_uInt16 nFileId, const OUString &rTabName, bool bCreateNew, size_t *pnIndex, const OUString *pExtUrl)
 
void clearCache (sal_uInt16 nFileId)
 Clear all caches including the cache tables. More...
 
void clearCacheTables (sal_uInt16 nFileId)
 Clear all caches but keep the tables. More...
 
const ScDocumentgetDoc () const
 

Private Types

typedef std::unordered_map< SCCOL, CellRowDataType
 
typedef std::unordered_map< SCROW, RowDataTypeRowsDataType
 
typedef std::unordered_map< OUString, TokenArrayRefRangeNameMap
 
typedef std::unordered_map< ScRange, TokenArrayRef, RangeHashRangeArrayMap
 
typedef std::unordered_map< OUString, OUString > NamePairMap
 
typedef std::unordered_map< sal_uInt16, DocItemDocDataType
 

Private Member Functions

void addCacheTableToReferenced (sal_uInt16 nFileId, size_t nIndex)
 
void addCacheDocToReferenced (sal_uInt16 nFileId)
 
DocItemgetDocItem (sal_uInt16 nFileId) const
 
DocItemgetDocItem (std::unique_lock< std::mutex > &rGuard, sal_uInt16 nFileId) const
 

Private Attributes

struct ScExternalRefCache::ReferencedStatus maReferenced
 
std::mutex maMtxDocs
 
DocDataType maDocs
 
const ScDocumentmrDoc
 

Detailed Description

Cache table for external reference data.

Definition at line 81 of file externalrefmgr.hxx.

Member Typedef Documentation

◆ DocDataType

typedef std::unordered_map<sal_uInt16, DocItem> ScExternalRefCache::DocDataType
private

Definition at line 362 of file externalrefmgr.hxx.

◆ NamePairMap

typedef std::unordered_map<OUString, OUString> ScExternalRefCache::NamePairMap
private

Definition at line 331 of file externalrefmgr.hxx.

◆ RangeArrayMap

typedef std::unordered_map<ScRange, TokenArrayRef, RangeHash> ScExternalRefCache::RangeArrayMap
private

Definition at line 330 of file externalrefmgr.hxx.

◆ RangeNameMap

typedef std::unordered_map<OUString, TokenArrayRef> ScExternalRefCache::RangeNameMap
private

Definition at line 329 of file externalrefmgr.hxx.

◆ RowDataType

typedef std::unordered_map<SCCOL, Cell> ScExternalRefCache::RowDataType
private

Definition at line 111 of file externalrefmgr.hxx.

◆ RowsDataType

typedef std::unordered_map<SCROW, RowDataType> ScExternalRefCache::RowsDataType
private

Definition at line 112 of file externalrefmgr.hxx.

◆ TableNameIndexMap

typedef std::unordered_map< OUString, size_t> ScExternalRefCache::TableNameIndexMap

Definition at line 190 of file externalrefmgr.hxx.

◆ TableTypeRef

typedef std::shared_ptr<Table> ScExternalRefCache::TableTypeRef

Definition at line 188 of file externalrefmgr.hxx.

◆ TokenArrayRef

Definition at line 85 of file externalrefmgr.hxx.

◆ TokenRef

Definition at line 84 of file externalrefmgr.hxx.

Constructor & Destructor Documentation

◆ ScExternalRefCache()

ScExternalRefCache::ScExternalRefCache ( const ScDocument rDoc)

Definition at line 485 of file externalrefmgr.cxx.

◆ ~ScExternalRefCache()

ScExternalRefCache::~ScExternalRefCache ( )

Definition at line 490 of file externalrefmgr.cxx.

Member Function Documentation

◆ addCacheDocToReferenced()

void ScExternalRefCache::addCacheDocToReferenced ( sal_uInt16  nFileId)
private

◆ addCacheTableToReferenced()

void ScExternalRefCache::addCacheTableToReferenced ( sal_uInt16  nFileId,
size_t  nIndex 
)
private

◆ areAllCacheTablesReferenced()

bool ScExternalRefCache::areAllCacheTablesReferenced ( ) const
inline

◆ clearCache()

void ScExternalRefCache::clearCache ( sal_uInt16  nFileId)

Clear all caches including the cache tables.

Definition at line 1390 of file externalrefmgr.cxx.

References maDocs, and maMtxDocs.

Referenced by ScExternalRefManager::clearCache().

◆ clearCacheTables()

void ScExternalRefCache::clearCacheTables ( sal_uInt16  nFileId)

Clear all caches but keep the tables.

All cache tables will be empty after the call, but the tables will not be removed.

Definition at line 1396 of file externalrefmgr.cxx.

References getDocItem(), maMtxDocs, ScExternalRefCache::DocItem::maRangeArrays, ScExternalRefCache::DocItem::maRangeNames, ScExternalRefCache::DocItem::maRealRangeNameMap, and ScExternalRefCache::DocItem::maTables.

Referenced by ScExternalRefManager::refreshSrcDocument().

◆ getAllCachedDataSpans()

void ScExternalRefCache::getAllCachedDataSpans ( const ScDocument rSrcDoc,
sal_uInt16  nFileId,
sc::ColumnSpanSet rSet 
) const

Collect all cached non-empty cell positions, inferred directly from the cached data, not the cached range metadata stored separately in the Table.

Definition at line 1260 of file externalrefmgr.cxx.

References getDocItem(), ScExternalRefCache::DocItem::maTables, and rSet.

Referenced by ScExternalRefManager::refreshSrcDocument().

◆ getAllNumberFormats()

void ScExternalRefCache::getAllNumberFormats ( ::std::vector< sal_uInt32 > &  rNumFmts) const

Definition at line 1104 of file externalrefmgr.cxx.

References maDocs, and maMtxDocs.

Referenced by ScExternalRefManager::getAllCachedNumberFormats().

◆ getAllTableNames()

void ScExternalRefCache::getAllTableNames ( sal_uInt16  nFileId,
::std::vector< OUString > &  rTabNames 
) const

◆ getCacheTable() [1/2]

ScExternalRefCache::TableTypeRef ScExternalRefCache::getCacheTable ( sal_uInt16  nFileId,
const OUString &  rTabName,
bool  bCreateNew,
size_t *  pnIndex,
const OUString *  pExtUrl 
)

◆ getCacheTable() [2/2]

ScExternalRefCache::TableTypeRef ScExternalRefCache::getCacheTable ( sal_uInt16  nFileId,
size_t  nTabIndex 
) const

◆ getCellData()

ScExternalRefCache::TokenRef ScExternalRefCache::getCellData ( sal_uInt16  nFileId,
const OUString &  rTabName,
SCCOL  nCol,
SCROW  nRow,
sal_uInt32 *  pnFmtIndex 
)

Get a cached cell data at specified cell location.

Parameters
nFileIdfile ID of an external document
rTabNamesheet name
nCol
nRow
Returns
pointer to the token instance in the cache.

Definition at line 535 of file externalrefmgr.cxx.

References ScExternalRefCache::DocItem::findTableNameIndex(), maDocs, maMtxDocs, ScExternalRefCache::DocItem::maTableNameIndex, and ScExternalRefCache::DocItem::maTables.

Referenced by ScExternalRefManager::getSingleRefToken().

◆ getCellRangeData()

ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData ( sal_uInt16  nFileId,
const OUString &  rTabName,
const ScRange rRange 
)

Get a cached cell range data.

Returns
a new token array instance. Note that the caller must manage the life cycle of the returned instance, which is guaranteed if the TokenArrayRef is properly used...

Definition at line 565 of file externalrefmgr.cxx.

References ScRange::aEnd, ScRange::aStart, ScAddress::Col(), ScExternalRefCache::DocItem::findTableNameIndex(), maDocs, o3tl::make_unsigned(), maMtxDocs, ScExternalRefCache::DocItem::maRangeArrays, ScExternalRefCache::DocItem::maTableNameIndex, ScExternalRefCache::DocItem::maTables, MAXCOL, MAXROW, mrDoc, ocSep, ScAddress::Row(), svDouble, svString, and ScAddress::Tab().

Referenced by ScExternalRefManager::getDoubleRefTokens().

◆ getDoc()

const ScDocument & ScExternalRefCache::getDoc ( ) const
inline

Definition at line 309 of file externalrefmgr.hxx.

References mrDoc.

Referenced by ScExternalRefManager::getDoubleRefTokens().

◆ getDocItem() [1/2]

ScExternalRefCache::DocItem * ScExternalRefCache::getDocItem ( sal_uInt16  nFileId) const
private

◆ getDocItem() [2/2]

ScExternalRefCache::DocItem * ScExternalRefCache::getDocItem ( std::unique_lock< std::mutex > &  rGuard,
sal_uInt16  nFileId 
) const
private

Definition at line 1426 of file externalrefmgr.cxx.

References maDocs.

◆ getRangeNameTokens()

ScExternalRefCache::TokenArrayRef ScExternalRefCache::getRangeNameTokens ( sal_uInt16  nFileId,
const OUString &  rName 
)

◆ getRealRangeName()

const OUString * ScExternalRefCache::getRealRangeName ( sal_uInt16  nFileId,
const OUString &  rRangeName 
) const

◆ getRealTableName()

const OUString * ScExternalRefCache::getRealTableName ( sal_uInt16  nFileId,
const OUString &  rTabName 
) const

◆ getSrcDocTable()

bool ScExternalRefCache::getSrcDocTable ( const ScDocument rSrcDoc,
const OUString &  rTabName,
SCTAB rTab,
sal_uInt16  nFileId 
) const

◆ getTableName()

OUString ScExternalRefCache::getTableName ( sal_uInt16  nFileId,
size_t  nCacheId 
) const

◆ getTabSpan()

SCTAB ScExternalRefCache::getTabSpan ( sal_uInt16  nFileId,
const OUString &  rStartTabName,
const OUString &  rEndTabName 
) const

◆ initializeDoc()

void ScExternalRefCache::initializeDoc ( sal_uInt16  nFileId,
const ::std::vector< OUString > &  rTabNames,
const OUString &  rBaseName 
)

◆ isDocInitialized()

bool ScExternalRefCache::isDocInitialized ( sal_uInt16  nFileId)

◆ isValidRangeName()

bool ScExternalRefCache::isValidRangeName ( sal_uInt16  nFileId,
const OUString &  rName 
) const

◆ setAllCacheTableReferencedStati()

void ScExternalRefCache::setAllCacheTableReferencedStati ( bool  bReferenced)

◆ setCacheDocReferenced()

bool ScExternalRefCache::setCacheDocReferenced ( sal_uInt16  nFileId)

Set all tables of a document as referenced, used only during store-to-file.

Returns
<TRUE> if ALL tables of ALL documents are marked.

Definition at line 1130 of file externalrefmgr.cxx.

References addCacheDocToReferenced(), areAllCacheTablesReferenced(), getDocItem(), and ScExternalRefCache::DocItem::maTables.

Referenced by ScExternalRefManager::markUsedByLinkListeners().

◆ setCacheTableReferenced()

bool ScExternalRefCache::setCacheTableReferenced ( sal_uInt16  nFileId,
const OUString &  rTabName,
size_t  nSheets 
)

Set a table as referenced, used only during store-to-file.

Returns
<TRUE> if ALL tables of ALL documents are marked.

Definition at line 1145 of file externalrefmgr.cxx.

References addCacheTableToReferenced(), areAllCacheTablesReferenced(), getDocItem(), ScExternalRefCache::DocItem::getTableDataIndex(), i, ScExternalRefCache::DocItem::maTables, and nIndex.

Referenced by ScExternalRefManager::setCacheTableReferenced().

◆ setCellData()

void ScExternalRefCache::setCellData ( sal_uInt16  nFileId,
const OUString &  rTabName,
SCCOL  nCol,
SCROW  nRow,
TokenRef const &  pToken,
sal_uLong  nFmtIndex 
)

◆ setCellRangeData()

void ScExternalRefCache::setCellRangeData ( sal_uInt16  nFileId,
const ScRange rRange,
const ::std::vector< SingleRangeData > &  rData,
const TokenArrayRef pArray 
)

◆ setRangeName()

void ScExternalRefCache::setRangeName ( sal_uInt16  nFileId,
const OUString &  rName 
)

◆ setRangeNameTokens()

void ScExternalRefCache::setRangeNameTokens ( sal_uInt16  nFileId,
const OUString &  rName,
TokenArrayRef  pArray 
)

Member Data Documentation

◆ maDocs

DocDataType ScExternalRefCache::maDocs
mutableprivate

◆ maMtxDocs

std::mutex ScExternalRefCache::maMtxDocs
mutableprivate

◆ maReferenced

struct ScExternalRefCache::ReferencedStatus ScExternalRefCache::maReferenced
private

◆ mrDoc

const ScDocument& ScExternalRefCache::mrDoc
private

Definition at line 369 of file externalrefmgr.hxx.

Referenced by getCellRangeData(), and getDoc().


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