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

#include <externalrefmgr.hxx>

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

Classes

class  ApiGuard
 Use this guard when performing something from the API that might query values from external references. More...
 
class  LinkListener
 Base class for objects that need to listen to link updates. More...
 
struct  SrcFileData
 Source document meta-data container. More...
 
struct  SrcShell
 Shell instance for a source document. More...
 

Public Types

enum  LinkUpdateType {
  LINK_MODIFIED,
  LINK_BROKEN
}
 
typedef std::set< ScFormulaCell * > RefCellSet
 
typedef std::unordered_map< sal_uInt16, RefCellSetRefCellMap
 

Public Member Functions

 ScExternalRefManager (ScDocument *pDoc)
 
virtual ~ScExternalRefManager () override
 
virtual OUString getCacheTableName (sal_uInt16 nFileId, size_t nTabIndex) const override
 
ScExternalRefCache::TableTypeRef getCacheTable (sal_uInt16 nFileId, size_t nTabIndex) const
 Get a cache table instance for specified table and table index. More...
 
ScExternalRefCache::TableTypeRef getCacheTable (sal_uInt16 nFileId, const OUString &rTabName, bool bCreateNew, size_t *pnIndex=nullptr, const OUString *pExtUrl=nullptr)
 Get a cache table instance for specified file and table name. More...
 
void getAllCachedTableNames (sal_uInt16 nFileId,::std::vector< OUString > &rTabNames) const
 Returns a vector containing all (real) table names and cache tables of the specified file. More...
 
SCTAB getCachedTabSpan (sal_uInt16 nFileId, const OUString &rStartTabName, const OUString &rEndTabName) const
 Get the span (distance+sign(distance)) of two sheets of a specified file. More...
 
void getAllCachedNumberFormats (::std::vector< sal_uInt32 > &rNumFmts) const
 Get all unique number format indices that are used in the cache tables. More...
 
sal_uInt16 getExternalFileCount () const
 
void markUsedByLinkListeners ()
 Mark all tables as referenced that are used by any LinkListener, used only during store-to-file. More...
 
void markUsedExternalRefCells ()
 
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 isInReferenceMarking () const
 
void storeRangeNameTokens (sal_uInt16 nFileId, const OUString &rName, const ScTokenArray &rArray)
 
ScExternalRefCache::TokenRef getSingleRefToken (sal_uInt16 nFileId, const OUString &rTabName, const ScAddress &rCell, const ScAddress *pCurPos, SCTAB *pTab, ScExternalRefCache::CellFormat *pFmt=nullptr)
 
ScExternalRefCache::TokenArrayRef getDoubleRefTokens (sal_uInt16 nFileId, const OUString &rTabName, const ScRange &rRange, const ScAddress *pCurPos)
 Get an array of tokens that consist of the specified external cell range. More...
 
ScExternalRefCache::TokenArrayRef getRangeNameTokens (sal_uInt16 nFileId, const OUString &rName, const ScAddress *pCurPos=nullptr)
 Get an array of tokens corresponding with a specified name in a specified file. More...
 
bool isValidRangeName (sal_uInt16 nFileId, const OUString &rName)
 
OUString getOwnDocumentName () const
 
bool isOwnDocument (const OUString &rFile) const
 
void convertToAbsName (OUString &rFile) const
 Takes a flat file name, and convert it to an absolute URL path. More...
 
sal_uInt16 getExternalFileId (const OUString &rFile)
 
const OUString * getExternalFileName (sal_uInt16 nFileId, bool bForceOriginal=false)
 It returns a pointer to the name of the URI associated with a given external file ID. More...
 
std::vector< OUString > getAllCachedExternalFileNames () const
 Get all cached external file names as an array. More...
 
bool hasExternalFile (sal_uInt16 nFileId) const
 
bool hasExternalFile (const OUString &rFile) const
 
const SrcFileDatagetExternalFileData (sal_uInt16 nFileId) const
 
const OUString * getRealTableName (sal_uInt16 nFileId, const OUString &rTabName) const
 
const OUString * getRealRangeName (sal_uInt16 nFileId, const OUString &rRangeName) const
 
void clearCache (sal_uInt16 nFileId)
 
bool refreshSrcDocument (sal_uInt16 nFileId)
 
void breakLink (sal_uInt16 nFileId)
 
void switchSrcFile (sal_uInt16 nFileId, const OUString &rNewFile, const OUString &rNewFilter)
 
void setRelativeFileName (sal_uInt16 nFileId, const OUString &rRelUrl)
 Set a relative file path for the specified file ID. More...
 
void setFilterData (sal_uInt16 nFileId, const OUString &rFilterName, const OUString &rOptions)
 Set the filter name and options if any for a given source document. More...
 
void clear ()
 
bool hasExternalData () const
 
void resetSrcFileData (const OUString &rBaseFileUrl)
 Re-generates relative names for all stored source files. More...
 
void updateAbsAfterLoad ()
 Replace the original URL with the real URL that was generated from the relative URL. More...
 
void removeRefCell (ScFormulaCell *pCell)
 Stop tracking a specific formula cell. More...
 
void addLinkListener (sal_uInt16 nFileId, LinkListener *pListener)
 Register a new link listener to a specified external document. More...
 
void removeLinkListener (sal_uInt16 nFileId, LinkListener *pListener)
 Remove an existing link listener. More...
 
void removeLinkListener (LinkListener *pListener)
 
void notifyAllLinkListeners (sal_uInt16 nFileId, LinkUpdateType eType)
 Notify all listeners that are listening to a specified external document. More...
 
bool isFileLoadable (const OUString &rFile) const
 Check if the file specified by the path is a legitimate file that exists & can be loaded. More...
 
virtual void Notify (SfxBroadcaster &rBC, const SfxHint &rHint) override
 
bool containsUnsavedReferences () const
 If we still contain unsaved files we should warn the user before saving. More...
 
void insertRefCell (sal_uInt16 nFileId, const ScAddress &rCell)
 
void insertRefCellFromTemplate (ScFormulaCell *pTemplateCell, ScFormulaCell *pCell)
 Add a cell to reference the same files as the template cell. More...
 
bool hasCellExternalReference (const ScAddress &rCell)
 
void enableDocTimer (bool bEnable)
 
void addFilesToLinkManager ()
 Add all known external files to the LinkManager. More...
 
- Public Member Functions inherited from SfxListener
 SfxListener ()
 
 SfxListener (const SfxListener &rCopy)
 
virtual ~SfxListener () COVERITY_NOEXCEPT_FALSE
 
void StartListening (SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
 
void EndListening (SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
 
void EndListeningAll ()
 
bool IsListening (SfxBroadcaster &rBroadcaster) const
 
sal_uInt16 GetBroadcasterCount () const
 
SfxBroadcasterGetBroadcasterJOE (sal_uInt16 nNo) const
 
void RemoveBroadcaster_Impl (SfxBroadcaster &rBC)
 

Private Types

typedef std::unordered_map< sal_uInt16, SrcShellDocShellMap
 
typedef std::unordered_map< sal_uInt16, bool > LinkedDocMap
 
typedef std::unordered_map< sal_uInt16, SvNumberFormatterMergeMapNumFmtMap
 
typedef o3tl::sorted_vector< LinkListener * > LinkListeners
 
typedef std::unordered_map< sal_uInt16, LinkListenersLinkListenerMap
 

Private Member Functions

 ScExternalRefManager (const ScExternalRefManager &)=delete
 
void refreshAllRefCells (sal_uInt16 nFileId)
 
void fillCellFormat (sal_uLong nFmtIndex, ScExternalRefCache::CellFormat *pFmt) const
 
bool getSrcDocTable (const ScDocument &rSrcDoc, const OUString &rTabName, SCTAB &rTab, sal_uInt16 nFileId) const
 
ScExternalRefCache::TokenRef getSingleRefTokenFromSrcDoc (sal_uInt16 nFileId, ScDocument *pSrcDoc, const ScAddress &rPos, ScExternalRefCache::CellFormat *pFmt)
 
ScExternalRefCache::TokenArrayRef getDoubleRefTokensFromSrcDoc (const ScDocument &rSrcDoc, const OUString &rTabName, ScRange &rRange,::std::vector< ScExternalRefCache::SingleRangeData > &rCacheData)
 Retrieve a range token array from a source document instance. More...
 
ScDocumentgetInMemorySrcDocument (sal_uInt16 nFileId)
 
ScDocumentgetSrcDocument (sal_uInt16 nFileId)
 
SfxObjectShellRef loadSrcDocument (sal_uInt16 nFileId, OUString &rFilter)
 
ScDocumentcacheNewDocShell (sal_uInt16 nFileId, SrcShell &rSrcShell)
 Caller must ensure that the passed shell is not already stored. More...
 
void maybeLinkExternalFile (sal_uInt16 nFileId, bool bDeferFilterDetection=false)
 
void maybeCreateRealFileName (sal_uInt16 nFileId)
 Try to create a "real" file name from the relative path. More...
 
void purgeStaleSrcDocument (sal_Int32 nTimeOut)
 Purge those source document instances that have not been accessed for the specified duration. More...
 
sal_uInt32 getMappedNumberFormat (sal_uInt16 nFileId, sal_uInt32 nNumFmt, const ScDocument *pSrcDoc)
 
void transformUnsavedRefToSavedRef (SfxObjectShell *pShell)
 If in maUnsavedDocShells move it to maDocShells and create a correct external reference entry. More...
 
 DECL_LINK (TimeOutHdl, Timer *, void)
 

Static Private Member Functions

static ScExternalRefCache::TokenArrayRef getRangeNameTokensFromSrcDoc (sal_uInt16 nFileId, const ScDocument &rSrcDoc, OUString &rName)
 Retrieve range name token array from a source document instance. More...
 

Private Attributes

ScDocumentmpDoc
 
ScExternalRefCache maRefCache
 cache of referenced ranges and names from source documents. More...
 
DocShellMap maDocShells
 Source document cache. More...
 
DocShellMap maUnsavedDocShells
 DocShells to unsaved but referenced documents. More...
 
LinkedDocMap maLinkedDocs
 list of source documents that are managed by the link manager. More...
 
RefCellMap maRefCells
 List of referencing cells that may contain external names. More...
 
LinkListenerMap maLinkListeners
 
NumFmtMap maNumFormatMap
 
std::vector< SrcFileDatamaSrcFiles
 List of external source document meta-data, used to keep track of external document identifiers. More...
 
bool mbInReferenceMarking:1
 Status whether in reference marking state. More...
 
bool mbUserInteractionEnabled:1
 Controls whether or not to allow user interaction. More...
 
bool mbDocTimerEnabled:1
 
AutoTimer maSrcDocTimer
 

Additional Inherited Members

- Protected Member Functions inherited from formula::ExternalReferenceHelper
 ~ExternalReferenceHelper ()
 

Detailed Description

Definition at line 365 of file externalrefmgr.hxx.

Member Typedef Documentation

typedef std::unordered_map<sal_uInt16, SrcShell> ScExternalRefManager::DocShellMap
private

Definition at line 412 of file externalrefmgr.hxx.

typedef std::unordered_map<sal_uInt16, bool> ScExternalRefManager::LinkedDocMap
private

Definition at line 413 of file externalrefmgr.hxx.

typedef std::unordered_map<sal_uInt16, LinkListeners> ScExternalRefManager::LinkListenerMap
private

Definition at line 418 of file externalrefmgr.hxx.

Definition at line 417 of file externalrefmgr.hxx.

typedef std::unordered_map<sal_uInt16, SvNumberFormatterMergeMap> ScExternalRefManager::NumFmtMap
private

Definition at line 415 of file externalrefmgr.hxx.

typedef std::unordered_map<sal_uInt16, RefCellSet> ScExternalRefManager::RefCellMap

Definition at line 370 of file externalrefmgr.hxx.

Definition at line 369 of file externalrefmgr.hxx.

Member Enumeration Documentation

Enumerator
LINK_MODIFIED 
LINK_BROKEN 

Definition at line 372 of file externalrefmgr.hxx.

Constructor & Destructor Documentation

ScExternalRefManager::ScExternalRefManager ( ScDocument pDoc)
explicit
ScExternalRefManager::~ScExternalRefManager ( )
overridevirtual

Definition at line 1648 of file externalrefmgr.cxx.

References clear().

ScExternalRefManager::ScExternalRefManager ( const ScExternalRefManager )
privatedelete

Member Function Documentation

void ScExternalRefManager::addFilesToLinkManager ( )

Add all known external files to the LinkManager.

Definition at line 2635 of file externalrefmgr.cxx.

References maSrcFiles, maybeLinkExternalFile(), SAL_MAX_UINT16, and SAL_WARN_IF.

Referenced by oox::xls::FormulaBuffer::finalizeImport().

void ScExternalRefManager::addLinkListener ( sal_uInt16  nFileId,
LinkListener pListener 
)

Register a new link listener to a specified external document.

Note that the caller is responsible for managing the life cycle of the listener object.

Definition at line 3057 of file externalrefmgr.cxx.

References o3tl::sorted_vector< Value, Compare, Find, class >::insert(), and maLinkListeners.

Referenced by ScChart2DataSequence::CopyData(), and ScChart2DataSequence::FillCacheFromExternalRef().

void ScExternalRefManager::breakLink ( sal_uInt16  nFileId)
ScDocument & ScExternalRefManager::cacheNewDocShell ( sal_uInt16  nFileId,
SrcShell rSrcShell 
)
private

Caller must ensure that the passed shell is not already stored.

Definition at line 2553 of file externalrefmgr.cxx.

References maDocShells, maRefCache, ScExternalRefManager::SrcShell::maShell, maSrcDocTimer, mbDocTimerEnabled, and Timer::Start().

Referenced by getSrcDocument(), and refreshSrcDocument().

void ScExternalRefManager::clear ( )

Definition at line 3009 of file externalrefmgr.cxx.

References maDocShells, maSrcDocTimer, and Task::Stop().

Referenced by ~ScExternalRefManager().

void ScExternalRefManager::clearCache ( sal_uInt16  nFileId)

Definition at line 2795 of file externalrefmgr.cxx.

References ScExternalRefCache::clearCache(), and maRefCache.

Referenced by breakLink().

bool ScExternalRefManager::containsUnsavedReferences ( ) const
inline

If we still contain unsaved files we should warn the user before saving.

Returns
true if the document still contains references to an unsaved file

Definition at line 699 of file externalrefmgr.hxx.

void ScExternalRefManager::convertToAbsName ( OUString &  rFile) const

Takes a flat file name, and convert it to an absolute URL path.

An absolute URL path begins with 'file:///.

Parameters
rFilefile name to convert

Definition at line 2695 of file externalrefmgr.cxx.

References ScGlobal::GetAbsDocName(), ScDocument::GetDocumentShell(), SfxObjectShell::GetFirst(), SfxShell::GetName(), SfxObjectShell::GetNext(), and mpDoc.

Referenced by ScCompiler::IsExternalNamedRange(), lcl_ScAddress_Parse_OOo(), ScRange::Parse_XL_Header(), and XclImpChangeTrack::Read3DTabRefInfo().

ScExternalRefManager::DECL_LINK ( TimeOutHdl  ,
Timer ,
void   
)
private
void ScExternalRefManager::enableDocTimer ( bool  bEnable)
void ScExternalRefManager::fillCellFormat ( sal_uLong  nFmtIndex,
ScExternalRefCache::CellFormat pFmt 
) const
private
std::vector< OUString > ScExternalRefManager::getAllCachedExternalFileNames ( ) const

Get all cached external file names as an array.

Array indices of the returned name array correspond with external file ID's.

Definition at line 2743 of file externalrefmgr.cxx.

References maSrcFiles, and rData.

Referenced by sc::TokenStringContext::TokenStringContext().

void ScExternalRefManager::getAllCachedNumberFormats ( ::std::vector< sal_uInt32 > &  rNumFmts) const

Get all unique number format indices that are used in the cache tables.

The retrieved indices are sorted in ascending order.

Parameters
rNumFmts(reference) all unique number format indices.

Definition at line 1701 of file externalrefmgr.cxx.

References ScExternalRefCache::getAllNumberFormats(), and maRefCache.

Referenced by ScXMLExport::ExportExternalRefCacheStyles().

void ScExternalRefManager::getAllCachedTableNames ( sal_uInt16  nFileId,
::std::vector< OUString > &  rTabNames 
) const

Returns a vector containing all (real) table names and cache tables of the specified file.

The index in the returned vector corresponds to the table index used to access the cache table, e.g. in getCacheTable().

Definition at line 1691 of file externalrefmgr.cxx.

References ScExternalRefCache::getAllTableNames(), and maRefCache.

Referenced by ScCompiler::CreateStringFromExternal(), ScExternalDocLinkObj::getElementNames(), sc::TokenStringContext::TokenStringContext(), and ScXMLExport::WriteExternalRefCaches().

SCTAB ScExternalRefManager::getCachedTabSpan ( sal_uInt16  nFileId,
const OUString &  rStartTabName,
const OUString &  rEndTabName 
) const

Get the span (distance+sign(distance)) of two sheets of a specified file.

Parameters
nFileIdfile ID
rStartTabNamename of first sheet (sheet1)
rEndTabNamename of second sheet (sheet2)
Returns
span 1 if sheet2 == sheet1 > 1 if sheet2 > sheet1 < -1 if sheet2 < sheet1 -1 if nFileId or rStartTabName not found 0 if rEndTabName not found

Definition at line 1696 of file externalrefmgr.cxx.

References ScExternalRefCache::getTabSpan(), and maRefCache.

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

Get a cache table instance for specified table and table index.

Unlike the other method that takes a table name, this method does not create a new table when a table is not available for specified index.

Parameters
nFileIdfile ID
nTabIndexcache table index
Returns
shared_ptr to the cache table instance

Definition at line 1658 of file externalrefmgr.cxx.

References ScExternalRefCache::getCacheTable(), and maRefCache.

Referenced by ScExternalDocLinkObj::addSheetCache(), ScTokenConversion::ConvertToTokenSequence(), XclImpExtName::CreateOleData(), ScChart2DataSequence::FillCacheFromExternalRef(), ScExternalDocLinkObj::getByIndex(), ScExternalDocLinkObj::getByName(), ScExternalDocLinkObj::getElementNames(), ScExternalDocLinkObj::hasByName(), XclImpSupbook::LoadCachedValues(), ScInterpreter::ScCellExternal(), ScXMLTableContext::ScXMLTableContext(), and ScXMLExport::WriteExternalRefCaches().

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

Get a cache table instance for specified file and table name.

If the table instance is not already present, it'll instantiate a new one and append it to the end of the table array. It's important to be aware of this fact especially for multi-table ranges for which table orders are critical.

Excel filter calls this method to populate the cache table from the XCT/CRN records. ODF import calls it for cached tables for external references.

Parameters
nFileIdfile ID
rTabNametable name
bCreateNewif true, create a new table instance if it's not already present. If false, it returns NULL if the specified table's cache doesn't exist.
pnIndexif non-NULL pointer is passed, it stores the internal index of a cache table instance.
pExtUrlif non-NULL and bCreateNew==true, the base name will be propagated as an alias for the first table (and removed later if further tables are created).
Returns
shared_ptr to the cache table instance

Definition at line 1663 of file externalrefmgr.cxx.

References ScExternalRefCache::getCacheTable(), and maRefCache.

OUString ScExternalRefManager::getCacheTableName ( sal_uInt16  nFileId,
size_t  nTabIndex 
) const
overridevirtual
ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokens ( sal_uInt16  nFileId,
const OUString &  rTabName,
const ScRange rRange,
const ScAddress pCurPos 
)

Get an array of tokens that consist of the specified external cell range.

Parameters
nFileIdfile ID for an external document
rTabNamereferenced sheet name
rRangereferenced cell range
pCurPoscurrent cursor position to keep track of cells that reference an external data.
Returns
shared_ptr to a token array instance. The caller must not delete the instance returned by this method.

Definition at line 1974 of file externalrefmgr.cxx.

References ScExternalRefCache::getCellRangeData(), getDoubleRefTokensFromSrcDoc(), ScExternalRefCache::getFakeDoc(), getInMemorySrcDocument(), getSrcDocument(), insertRefCell(), maRefCache, and maybeLinkExternalFile().

Referenced by ScChart2DataSequence::FillCacheFromExternalRef().

ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokensFromSrcDoc ( const ScDocument rSrcDoc,
const OUString &  rTabName,
ScRange rRange,
::std::vector< ScExternalRefCache::SingleRangeData > &  rCacheData 
)
private

Retrieve a range token array from a source document instance.

Parameters
rSrcDocreference to the source document instance.
rTabNamename of the first table.
rRangerange specified. Upon successful retrieval, this range gets modified to contain the correct table IDs, and in case the range is larger than the data area of the source document, it gets reduced to the data area.
rCacheDataan array of structs, with each struct containing the table name and the data in the specified range.
Returns
range token array

Definition at line 2241 of file externalrefmgr.cxx.

References ScRange::aEnd, ScRange::aStart, convertToTokenArray(), ScGlobal::getCharClassPtr(), ScDocument::GetName(), ScDocument::GetTable(), i, mpDoc, ScRange::PutInOrder(), ScAddress::SetTab(), ScAddress::Tab(), and CharClass::uppercase().

Referenced by getDoubleRefTokens().

sal_uInt16 ScExternalRefManager::getExternalFileCount ( ) const
const ScExternalRefManager::SrcFileData * ScExternalRefManager::getExternalFileData ( sal_uInt16  nFileId) const
sal_uInt16 ScExternalRefManager::getExternalFileId ( const OUString &  rFile)
const OUString * ScExternalRefManager::getExternalFileName ( sal_uInt16  nFileId,
bool  bForceOriginal = false 
)

It returns a pointer to the name of the URI associated with a given external file ID.

In case the original document has moved, it returns a URI adjusted for the relocation.

Parameters
nFileIdfile ID for an external document
bForceOriginalIf true, it always returns the original document URI even if the referring document has relocated. If false, it returns a URI adjusted for relocated document.
Returns
const OUString* external document URI.

Definition at line 2727 of file externalrefmgr.cxx.

References maSrcFiles, and maybeCreateRealFileName().

Referenced by ScCompiler::CreateStringFromExternal(), ScExternalRefLink::DataChanged(), ScViewFunc::DetectiveMarkPred(), ScExternalDocLinksObj::getElementNames(), getInMemorySrcDocument(), getSrcDocument(), ScCompiler::HandleExternalReference(), lcl_appendCellAddress(), lcl_appendCellRangeAddress(), lcl_ScAddress_Parse_OOo(), maybeLinkExternalFile(), ScGridWindow::MouseButtonUp(), XclExpFmlaCompImpl::ProcessExternalName(), ScInterpreter::ScCellExternal(), and ScXMLExport::WriteExternalRefCaches().

ScDocument * ScExternalRefManager::getInMemorySrcDocument ( sal_uInt16  nFileId)
private
sal_uInt32 ScExternalRefManager::getMappedNumberFormat ( sal_uInt16  nFileId,
sal_uInt32  nNumFmt,
const ScDocument pSrcDoc 
)
private
OUString ScExternalRefManager::getOwnDocumentName ( ) const
ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokens ( sal_uInt16  nFileId,
const OUString &  rName,
const ScAddress pCurPos = nullptr 
)

Get an array of tokens corresponding with a specified name in a specified file.

Parameters
pCurPoscurrent cell address where this name token is used. This is purely to keep track of all cells containing external names for refreshing purposes. If this is NULL, then the cell will not be added to the list.
Returns
shared_ptr to array of tokens composing the name

Definition at line 2020 of file externalrefmgr.cxx.

References getInMemorySrcDocument(), ScExternalRefCache::getRangeNameTokens(), getRangeNameTokensFromSrcDoc(), getSrcDocument(), insertRefCell(), maRefCache, maybeLinkExternalFile(), and ScExternalRefCache::setRangeNameTokens().

Referenced by ScCompiler::HandleExternalReference(), and XclExpFmlaCompImpl::ProcessExternalName().

ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSrcDoc ( sal_uInt16  nFileId,
const ScDocument rSrcDoc,
OUString &  rName 
)
staticprivate

Retrieve range name token array from a source document instance.

Parameters
nFileIdfile ID of the source document.
rSrcDocreference to the source document instance
rNamerange name to retrieve. Note that the range name lookup is case in-sensitive, and upon successful retrieval of the range name array, this name gets updated to the actual range name with the correct casing.
Returns
range name token array

Definition at line 2285 of file externalrefmgr.cxx.

References ScRangeName::findByUpperName(), ScGlobal::getCharClassPtr(), ScRangeData::GetCode(), ScRangeData::GetName(), ScDocument::GetName(), ScDocument::GetRangeName(), svDoubleRef, svSingleRef, ScSingleRefData::Tab(), and CharClass::uppercase().

Referenced by getRangeNameTokens().

const OUString * ScExternalRefManager::getRealRangeName ( sal_uInt16  nFileId,
const OUString &  rRangeName 
) const
const OUString * ScExternalRefManager::getRealTableName ( sal_uInt16  nFileId,
const OUString &  rTabName 
) const
ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken ( sal_uInt16  nFileId,
const OUString &  rTabName,
const ScAddress rCell,
const ScAddress pCurPos,
SCTAB pTab,
ScExternalRefCache::CellFormat pFmt = nullptr 
)
ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefTokenFromSrcDoc ( sal_uInt16  nFileId,
ScDocument pSrcDoc,
const ScAddress rPos,
ScExternalRefCache::CellFormat pFmt 
)
private
bool ScExternalRefManager::getSrcDocTable ( const ScDocument rSrcDoc,
const OUString &  rTabName,
SCTAB rTab,
sal_uInt16  nFileId 
) const
private

Definition at line 1866 of file externalrefmgr.cxx.

References ScExternalRefCache::getSrcDocTable(), and maRefCache.

Referenced by getSingleRefToken().

ScDocument * ScExternalRefManager::getSrcDocument ( sal_uInt16  nFileId)
private
bool ScExternalRefManager::hasCellExternalReference ( const ScAddress rCell)

Definition at line 2174 of file externalrefmgr.cxx.

References ScDocument::GetFormulaCell(), maRefCells, and mpDoc.

bool ScExternalRefManager::hasExternalData ( ) const
bool ScExternalRefManager::hasExternalFile ( sal_uInt16  nFileId) const
bool ScExternalRefManager::hasExternalFile ( const OUString &  rFile) const

Definition at line 2760 of file externalrefmgr.cxx.

References maSrcFiles.

void ScExternalRefManager::insertRefCell ( sal_uInt16  nFileId,
const ScAddress rCell 
)
void ScExternalRefManager::insertRefCellFromTemplate ( ScFormulaCell pTemplateCell,
ScFormulaCell pCell 
)

Add a cell to reference the same files as the template cell.

Definition at line 2162 of file externalrefmgr.cxx.

References maRefCells.

Referenced by ScFormulaCell::CompileXML().

bool ScExternalRefManager::isFileLoadable ( const OUString &  rFile) const

Check if the file specified by the path is a legitimate file that exists & can be loaded.

Definition at line 2566 of file externalrefmgr.cxx.

References utl::UCBContentHelper::Exists(), utl::UCBContentHelper::IsFolder(), and isOwnDocument().

Referenced by ScExternalRefLink::DataChanged(), and loadSrcDocument().

bool ScExternalRefManager::isInReferenceMarking ( ) const
inline
Returns
<TRUE> if setAllCacheTableReferencedStati(false) was called, <FALSE> if setAllCacheTableReferencedStati(true) was called.

Definition at line 533 of file externalrefmgr.hxx.

bool ScExternalRefManager::isOwnDocument ( const OUString &  rFile) const

Definition at line 2690 of file externalrefmgr.cxx.

References getOwnDocumentName().

Referenced by isFileLoadable(), and lcl_ScAddress_Parse_OOo().

bool ScExternalRefManager::isValidRangeName ( sal_uInt16  nFileId,
const OUString &  rName 
)
SfxObjectShellRef ScExternalRefManager::loadSrcDocument ( sal_uInt16  nFileId,
OUString &  rFilter 
)
private
void ScExternalRefManager::markUsedByLinkListeners ( )

Mark all tables as referenced that are used by any LinkListener, used only during store-to-file.

Definition at line 1711 of file externalrefmgr.cxx.

References maLinkListeners, maRefCache, and ScExternalRefCache::setCacheDocReferenced().

void ScExternalRefManager::markUsedExternalRefCells ( )

Definition at line 1727 of file externalrefmgr.cxx.

References maRefCells, and ScFormulaCell::MarkUsedExternalReferences().

void ScExternalRefManager::maybeCreateRealFileName ( sal_uInt16  nFileId)
private

Try to create a "real" file name from the relative path.

The original file name may not point to the real document when the referencing and referenced documents have been moved.

For the real file name to be created, the relative name should not be empty before calling this method, or the real file name will not be created.

Parameters
nFileIdfile ID for an external document

Definition at line 2665 of file externalrefmgr.cxx.

References getOwnDocumentName(), and maSrcFiles.

Referenced by getExternalFileName(), and loadSrcDocument().

void ScExternalRefManager::maybeLinkExternalFile ( sal_uInt16  nFileId,
bool  bDeferFilterDetection = false 
)
private
void ScExternalRefManager::Notify ( SfxBroadcaster rBC,
const SfxHint rHint 
)
overridevirtual
void ScExternalRefManager::notifyAllLinkListeners ( sal_uInt16  nFileId,
LinkUpdateType  eType 
)

Notify all listeners that are listening to a specified external document.

Parameters
nFileIdfile ID for an external document.

Definition at line 3098 of file externalrefmgr.cxx.

References o3tl::sorted_vector< Value, Compare, Find, class >::begin(), o3tl::sorted_vector< Value, Compare, Find, class >::end(), and maLinkListeners.

Referenced by breakLink(), and refreshSrcDocument().

void ScExternalRefManager::purgeStaleSrcDocument ( sal_Int32  nTimeOut)
private

Purge those source document instances that have not been accessed for the specified duration.

Parameters
nTimeOuttime out value in 100th of a second

Definition at line 3109 of file externalrefmgr.cxx.

References GetTime(), maDocShells, maSrcDocTimer, Task::Stop(), and tools::Time::SYSTEM.

Referenced by IMPL_LINK().

void ScExternalRefManager::refreshAllRefCells ( sal_uInt16  nFileId)
private
bool ScExternalRefManager::refreshSrcDocument ( sal_uInt16  nFileId)
void ScExternalRefManager::removeLinkListener ( sal_uInt16  nFileId,
LinkListener pListener 
)
void ScExternalRefManager::removeLinkListener ( LinkListener pListener)

Definition at line 3092 of file externalrefmgr.cxx.

References maLinkListeners.

void ScExternalRefManager::removeRefCell ( ScFormulaCell pCell)

Stop tracking a specific formula cell.

Parameters
pCellpointer to cell that formerly contained external reference.

Definition at line 3052 of file externalrefmgr.cxx.

References maRefCells.

Referenced by ScFormulaCell::~ScFormulaCell().

void ScExternalRefManager::resetSrcFileData ( const OUString &  rBaseFileUrl)

Re-generates relative names for all stored source files.

This is necessary when exporting to an ods document, to ensure that all source files have their respective relative names for xlink:href export.

Parameters
rBaseFileUrlAbsolute URL of the content.xml fragment of the document being exported.

Definition at line 3023 of file externalrefmgr.cxx.

References maSrcFiles, and URIHelper::simpleNormalizedMakeRelative().

Referenced by ScXMLExport::WriteExternalRefCaches().

void ScExternalRefManager::setAllCacheTableReferencedStati ( bool  bReferenced)
bool ScExternalRefManager::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 external documents are marked.

Definition at line 1741 of file externalrefmgr.cxx.

References maRefCache, and ScExternalRefCache::setCacheTableReferenced().

void ScExternalRefManager::setFilterData ( sal_uInt16  nFileId,
const OUString &  rFilterName,
const OUString &  rOptions 
)

Set the filter name and options if any for a given source document.

These values get reset when the source document ever gets reloaded.

Parameters
nFileId
rFilterName
rOptions

Definition at line 3001 of file externalrefmgr.cxx.

References maSrcFiles.

Referenced by ScXMLExternalRefTabSourceContext::endFastElement(), and loadSrcDocument().

void ScExternalRefManager::setRelativeFileName ( sal_uInt16  nFileId,
const OUString &  rRelUrl 
)

Set a relative file path for the specified file ID.

Note that the caller must ensure that the passed URL is a valid relative URL.

Parameters
nFileIdfile ID for an external document
rRelUrlrelative URL

Definition at line 2994 of file externalrefmgr.cxx.

References maSrcFiles.

Referenced by ScXMLExternalRefTabSourceContext::endFastElement(), and loadSrcDocument().

void ScExternalRefManager::storeRangeNameTokens ( sal_uInt16  nFileId,
const OUString &  rName,
const ScTokenArray rArray 
)
void ScExternalRefManager::switchSrcFile ( sal_uInt16  nFileId,
const OUString &  rNewFile,
const OUString &  rNewFilter 
)
void ScExternalRefManager::transformUnsavedRefToSavedRef ( SfxObjectShell pShell)
private

If in maUnsavedDocShells move it to maDocShells and create a correct external reference entry.

Parameters
Pointerto the newly saved DocumentShell

Definition at line 3156 of file externalrefmgr.cxx.

References SfxListener::EndListening(), INetURLObject::GetMainURL(), SfxObjectShell::GetMedium(), SfxMedium::GetURLObject(), maUnsavedDocShells, switchSrcFile(), and INetURLObject::ToIUri.

Referenced by Notify().

void ScExternalRefManager::updateAbsAfterLoad ( )

Replace the original URL with the real URL that was generated from the relative URL.

Definition at line 3037 of file externalrefmgr.cxx.

References getOwnDocumentName(), and maSrcFiles.

Referenced by ScXMLImport::endDocument().

Member Data Documentation

DocShellMap ScExternalRefManager::maDocShells
private

Source document cache.

This stores the original source document shell instances. They get purged after a certain period of time.

Definition at line 812 of file externalrefmgr.hxx.

Referenced by breakLink(), cacheNewDocShell(), clear(), enableDocTimer(), getSrcDocument(), purgeStaleSrcDocument(), and refreshSrcDocument().

LinkedDocMap ScExternalRefManager::maLinkedDocs
private

list of source documents that are managed by the link manager.

Definition at line 821 of file externalrefmgr.hxx.

Referenced by breakLink(), and maybeLinkExternalFile().

LinkListenerMap ScExternalRefManager::maLinkListeners
private
NumFmtMap ScExternalRefManager::maNumFormatMap
private

Definition at line 831 of file externalrefmgr.hxx.

Referenced by getMappedNumberFormat().

ScExternalRefCache ScExternalRefManager::maRefCache
private
RefCellMap ScExternalRefManager::maRefCells
private

List of referencing cells that may contain external names.

There is one list per source document.

Definition at line 827 of file externalrefmgr.hxx.

Referenced by breakLink(), hasCellExternalReference(), insertRefCell(), insertRefCellFromTemplate(), markUsedExternalRefCells(), refreshAllRefCells(), and removeRefCell().

AutoTimer ScExternalRefManager::maSrcDocTimer
private
std::vector<SrcFileData> ScExternalRefManager::maSrcFiles
private
DocShellMap ScExternalRefManager::maUnsavedDocShells
private

DocShells to unsaved but referenced documents.

If not empty ask before saving! Move to maDocShells if document referenced here is saved

Definition at line 818 of file externalrefmgr.hxx.

Referenced by getInMemorySrcDocument(), getSrcDocument(), and transformUnsavedRefToSavedRef().

bool ScExternalRefManager::mbDocTimerEnabled
private

Definition at line 848 of file externalrefmgr.hxx.

Referenced by cacheNewDocShell(), and enableDocTimer().

bool ScExternalRefManager::mbInReferenceMarking
private

Status whether in reference marking state.

See isInReferenceMarking().

Definition at line 840 of file externalrefmgr.hxx.

Referenced by setAllCacheTableReferencedStati().

bool ScExternalRefManager::mbUserInteractionEnabled
private

Controls whether or not to allow user interaction.

We don't want any user interaction when calling from the API.

Definition at line 846 of file externalrefmgr.hxx.

Referenced by ScExternalRefManager::ApiGuard::ApiGuard(), and loadSrcDocument().

ScDocument* ScExternalRefManager::mpDoc
private

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