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 ,
  OH_NO_WE_ARE_GOING_TO_DIE
}
 
typedef std::set< ScFormulaCell * > RefCellSet
 
typedef std::unordered_map< sal_uInt16, RefCellSetRefCellMap
 

Public Member Functions

 ScExternalRefManager (ScDocument &rDoc)
 
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 (std::u16string_view 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...
 
sal_uInt16 convertFileIdToUsedFileId (sal_uInt16 nFileId)
 Reindex external file references to skip unused files, if skipping is enabled. More...
 
void setSkipUnusedFileIds (std::vector< sal_uInt16 > &pExternFileIds)
 
void disableSkipUnusedFileIds ()
 
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...
 
virtual OUString getCacheTableName (sal_uInt16 nFileId, size_t nTabIndex) const=0
 
- 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
 
virtual void Notify (SfxBroadcaster &rBC, const SfxHint &rHint)
 
void RemoveBroadcaster_Impl (SfxBroadcaster &rBC)
 
virtual bool IsSdrView () const
 

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 &rSrcDoc, 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 &rSrcDoc)
 
void transformUnsavedRefToSavedRef (SfxObjectShell *pShell)
 If in maUnsavedDocShells move it to maDocShells and create a correct external reference entry. More...
 
 DECL_DLLPRIVATE_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

ScDocumentmrDoc
 
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 mbSkipUnusedFileIds = false
 
std::vector< sal_uInt16 > maConvertFileIdToUsedFileId
 
bool mbDocTimerEnabled:1
 
AutoTimer maSrcDocTimer
 

Additional Inherited Members

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

Detailed Description

Definition at line 372 of file externalrefmgr.hxx.

Member Typedef Documentation

◆ DocShellMap

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

Definition at line 419 of file externalrefmgr.hxx.

◆ LinkedDocMap

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

Definition at line 420 of file externalrefmgr.hxx.

◆ LinkListenerMap

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

Definition at line 425 of file externalrefmgr.hxx.

◆ LinkListeners

Definition at line 424 of file externalrefmgr.hxx.

◆ NumFmtMap

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

Definition at line 422 of file externalrefmgr.hxx.

◆ RefCellMap

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

Definition at line 377 of file externalrefmgr.hxx.

◆ RefCellSet

Definition at line 376 of file externalrefmgr.hxx.

Member Enumeration Documentation

◆ LinkUpdateType

Enumerator
LINK_MODIFIED 
LINK_BROKEN 
OH_NO_WE_ARE_GOING_TO_DIE 

Definition at line 379 of file externalrefmgr.hxx.

Constructor & Destructor Documentation

◆ ScExternalRefManager() [1/2]

ScExternalRefManager::ScExternalRefManager ( ScDocument rDoc)
explicit

◆ ~ScExternalRefManager()

ScExternalRefManager::~ScExternalRefManager ( )
overridevirtual

Definition at line 1686 of file externalrefmgr.cxx.

References clear().

◆ ScExternalRefManager() [2/2]

ScExternalRefManager::ScExternalRefManager ( const ScExternalRefManager )
privatedelete

Member Function Documentation

◆ addFilesToLinkManager()

void ScExternalRefManager::addFilesToLinkManager ( )

Add all known external files to the LinkManager.

Definition at line 2718 of file externalrefmgr.cxx.

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

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

◆ addLinkListener()

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 3173 of file externalrefmgr.cxx.

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

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

◆ breakLink()

void ScExternalRefManager::breakLink ( sal_uInt16  nFileId)

◆ cacheNewDocShell()

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

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

Definition at line 2636 of file externalrefmgr.cxx.

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

Referenced by getSrcDocument(), and refreshSrcDocument().

◆ clear()

void ScExternalRefManager::clear ( )

◆ clearCache()

void ScExternalRefManager::clearCache ( sal_uInt16  nFileId)

Definition at line 2903 of file externalrefmgr.cxx.

References ScExternalRefCache::clearCache(), and maRefCache.

Referenced by breakLink().

◆ containsUnsavedReferences()

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 713 of file externalrefmgr.hxx.

◆ convertFileIdToUsedFileId()

sal_uInt16 ScExternalRefManager::convertFileIdToUsedFileId ( sal_uInt16  nFileId)

Reindex external file references to skip unused files, if skipping is enabled.

Definition at line 2826 of file externalrefmgr.cxx.

References maConvertFileIdToUsedFileId, and mbSkipUnusedFileIds.

Referenced by ScCompiler::CreateStringFromExternal().

◆ convertToAbsName()

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 2778 of file externalrefmgr.cxx.

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

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

◆ DECL_DLLPRIVATE_LINK()

ScExternalRefManager::DECL_DLLPRIVATE_LINK ( TimeOutHdl  ,
Timer ,
void   
)
private

◆ disableSkipUnusedFileIds()

void ScExternalRefManager::disableSkipUnusedFileIds ( )

Definition at line 2846 of file externalrefmgr.cxx.

References mbSkipUnusedFileIds.

Referenced by XclExpXmlStream::exportDocument().

◆ enableDocTimer()

void ScExternalRefManager::enableDocTimer ( bool  bEnable)

◆ fillCellFormat()

void ScExternalRefManager::fillCellFormat ( sal_uLong  nFmtIndex,
ScExternalRefCache::CellFormat pFmt 
) const
private

◆ getAllCachedExternalFileNames()

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 2851 of file externalrefmgr.cxx.

References maSrcFiles.

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

◆ getAllCachedNumberFormats()

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 1739 of file externalrefmgr.cxx.

References ScExternalRefCache::getAllNumberFormats(), and maRefCache.

Referenced by ScXMLExport::ExportExternalRefCacheStyles().

◆ getAllCachedTableNames()

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 1729 of file externalrefmgr.cxx.

References ScExternalRefCache::getAllTableNames(), and maRefCache.

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

◆ getCachedTabSpan()

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 1734 of file externalrefmgr.cxx.

References ScExternalRefCache::getTabSpan(), and maRefCache.

Referenced by lcl_ScRange_External_TabSpan().

◆ getCacheTable() [1/2]

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 1701 of file externalrefmgr.cxx.

References ScExternalRefCache::getCacheTable(), and maRefCache.

◆ getCacheTable() [2/2]

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 1696 of file externalrefmgr.cxx.

References ScExternalRefCache::getCacheTable(), and maRefCache.

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

◆ getCacheTableName()

OUString ScExternalRefManager::getCacheTableName ( sal_uInt16  nFileId,
size_t  nTabIndex 
) const
overridevirtual

◆ getDoubleRefTokens()

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 2058 of file externalrefmgr.cxx.

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

Referenced by ScChart2DataSequence::FillCacheFromExternalRef(), and ScInterpreter::GetExternalDoubleRef().

◆ getDoubleRefTokensFromSrcDoc()

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 2324 of file externalrefmgr.cxx.

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

Referenced by getDoubleRefTokens().

◆ getExternalFileCount()

sal_uInt16 ScExternalRefManager::getExternalFileCount ( ) const

◆ getExternalFileData()

const ScExternalRefManager::SrcFileData * ScExternalRefManager::getExternalFileData ( sal_uInt16  nFileId) const

◆ getExternalFileId()

sal_uInt16 ScExternalRefManager::getExternalFileId ( const OUString &  rFile)

◆ getExternalFileName()

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 2810 of file externalrefmgr.cxx.

References maSrcFiles, and maybeCreateRealFileName().

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

◆ getInMemorySrcDocument()

ScDocument * ScExternalRefManager::getInMemorySrcDocument ( sal_uInt16  nFileId)
private

◆ getMappedNumberFormat()

sal_uInt32 ScExternalRefManager::getMappedNumberFormat ( sal_uInt16  nFileId,
sal_uInt32  nNumFmt,
const ScDocument rSrcDoc 
)
private

◆ getOwnDocumentName()

OUString ScExternalRefManager::getOwnDocumentName ( ) const

◆ getRangeNameTokens()

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 2104 of file externalrefmgr.cxx.

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

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

◆ getRangeNameTokensFromSrcDoc()

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 2368 of file externalrefmgr.cxx.

References ScRangeName::findByUpperName(), formula::FormulaTokenArrayPlainIterator::First(), ScGlobal::getCharClass(), ScRangeData::GetCode(), ScRangeData::GetName(), ScDocument::GetName(), ScDocument::GetRangeName(), formula::FormulaTokenArrayPlainIterator::Next(), svDoubleRef, svSingleRef, ScSingleRefData::Tab(), and CharClass::uppercase().

Referenced by getRangeNameTokens().

◆ getRealRangeName()

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

◆ getRealTableName()

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

◆ getSingleRefToken()

ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken ( sal_uInt16  nFileId,
const OUString &  rTabName,
const ScAddress rCell,
const ScAddress pCurPos,
SCTAB pTab,
ScExternalRefCache::CellFormat pFmt = nullptr 
)

◆ getSingleRefTokenFromSrcDoc()

ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefTokenFromSrcDoc ( sal_uInt16  nFileId,
ScDocument rSrcDoc,
const ScAddress rPos,
ScExternalRefCache::CellFormat pFmt 
)
private

◆ getSrcDocTable()

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

Definition at line 1950 of file externalrefmgr.cxx.

References ScExternalRefCache::getSrcDocTable(), and maRefCache.

Referenced by getSingleRefToken().

◆ getSrcDocument()

ScDocument * ScExternalRefManager::getSrcDocument ( sal_uInt16  nFileId)
private

◆ hasCellExternalReference()

bool ScExternalRefManager::hasCellExternalReference ( const ScAddress rCell)

Definition at line 2258 of file externalrefmgr.cxx.

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

◆ hasExternalData()

bool ScExternalRefManager::hasExternalData ( ) const

◆ hasExternalFile() [1/2]

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

Definition at line 2868 of file externalrefmgr.cxx.

References maSrcFiles.

◆ hasExternalFile() [2/2]

bool ScExternalRefManager::hasExternalFile ( sal_uInt16  nFileId) const

◆ insertRefCell()

void ScExternalRefManager::insertRefCell ( sal_uInt16  nFileId,
const ScAddress rCell 
)

◆ insertRefCellFromTemplate()

void ScExternalRefManager::insertRefCellFromTemplate ( ScFormulaCell pTemplateCell,
ScFormulaCell pCell 
)

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

Definition at line 2246 of file externalrefmgr.cxx.

References maRefCells.

Referenced by ScFormulaCell::CompileXML().

◆ isFileLoadable()

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 2649 of file externalrefmgr.cxx.

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

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

◆ isInReferenceMarking()

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

Definition at line 540 of file externalrefmgr.hxx.

◆ isOwnDocument()

bool ScExternalRefManager::isOwnDocument ( std::u16string_view  rFile) const

◆ isValidRangeName()

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

◆ loadSrcDocument()

SfxObjectShellRef ScExternalRefManager::loadSrcDocument ( sal_uInt16  nFileId,
OUString &  rFilter 
)
private

◆ markUsedByLinkListeners()

void ScExternalRefManager::markUsedByLinkListeners ( )

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

Definition at line 1749 of file externalrefmgr.cxx.

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

◆ markUsedExternalRefCells()

void ScExternalRefManager::markUsedExternalRefCells ( )

Definition at line 1765 of file externalrefmgr.cxx.

References maRefCells, and ScFormulaCell::MarkUsedExternalReferences().

◆ maybeCreateRealFileName()

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 2748 of file externalrefmgr.cxx.

References getOwnDocumentName(), and maSrcFiles.

Referenced by getExternalFileName(), and loadSrcDocument().

◆ maybeLinkExternalFile()

void ScExternalRefManager::maybeLinkExternalFile ( sal_uInt16  nFileId,
bool  bDeferFilterDetection = false 
)
private

◆ Notify()

void ScExternalRefManager::Notify ( SfxBroadcaster rBC,
const SfxHint rHint 
)
overridevirtual

◆ notifyAllLinkListeners()

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 3214 of file externalrefmgr.cxx.

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

Referenced by breakLink(), and refreshSrcDocument().

◆ purgeStaleSrcDocument()

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 3225 of file externalrefmgr.cxx.

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

Referenced by IMPL_LINK().

◆ refreshAllRefCells()

void ScExternalRefManager::refreshAllRefCells ( sal_uInt16  nFileId)
private

◆ refreshSrcDocument()

bool ScExternalRefManager::refreshSrcDocument ( sal_uInt16  nFileId)

◆ removeLinkListener() [1/2]

void ScExternalRefManager::removeLinkListener ( LinkListener pListener)

Definition at line 3208 of file externalrefmgr.cxx.

References maLinkListeners.

◆ removeLinkListener() [2/2]

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

◆ removeRefCell()

void ScExternalRefManager::removeRefCell ( ScFormulaCell pCell)

Stop tracking a specific formula cell.

Parameters
pCellpointer to cell that formerly contained external reference.

Definition at line 3168 of file externalrefmgr.cxx.

References maRefCells.

Referenced by ScFormulaCell::~ScFormulaCell().

◆ resetSrcFileData()

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 3139 of file externalrefmgr.cxx.

References maSrcFiles, and URIHelper::simpleNormalizedMakeRelative().

Referenced by ScXMLExport::WriteExternalRefCaches().

◆ setAllCacheTableReferencedStati()

void ScExternalRefManager::setAllCacheTableReferencedStati ( bool  bReferenced)

◆ setCacheTableReferenced()

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 1779 of file externalrefmgr.cxx.

References maRefCache, and ScExternalRefCache::setCacheTableReferenced().

◆ setFilterData()

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 3109 of file externalrefmgr.cxx.

References maSrcFiles.

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

◆ setRelativeFileName()

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 3102 of file externalrefmgr.cxx.

References maSrcFiles.

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

◆ setSkipUnusedFileIds()

void ScExternalRefManager::setSkipUnusedFileIds ( std::vector< sal_uInt16 > &  pExternFileIds)

Definition at line 2834 of file externalrefmgr.cxx.

References maConvertFileIdToUsedFileId, maSrcFiles, and mbSkipUnusedFileIds.

◆ storeRangeNameTokens()

void ScExternalRefManager::storeRangeNameTokens ( sal_uInt16  nFileId,
const OUString &  rName,
const ScTokenArray rArray 
)

◆ switchSrcFile()

void ScExternalRefManager::switchSrcFile ( sal_uInt16  nFileId,
const OUString &  rNewFile,
const OUString &  rNewFilter 
)

◆ transformUnsavedRefToSavedRef()

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 3272 of file externalrefmgr.cxx.

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

Referenced by Notify().

◆ updateAbsAfterLoad()

void ScExternalRefManager::updateAbsAfterLoad ( )

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

Definition at line 3153 of file externalrefmgr.cxx.

References getOwnDocumentName(), and maSrcFiles.

Referenced by ScXMLImport::endDocument().

Member Data Documentation

◆ maConvertFileIdToUsedFileId

std::vector<sal_uInt16> ScExternalRefManager::maConvertFileIdToUsedFileId
private

Definition at line 863 of file externalrefmgr.hxx.

Referenced by convertFileIdToUsedFileId(), and setSkipUnusedFileIds().

◆ maDocShells

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 826 of file externalrefmgr.hxx.

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

◆ maLinkedDocs

LinkedDocMap ScExternalRefManager::maLinkedDocs
private

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

Definition at line 835 of file externalrefmgr.hxx.

Referenced by breakLink(), and maybeLinkExternalFile().

◆ maLinkListeners

LinkListenerMap ScExternalRefManager::maLinkListeners
private

◆ maNumFormatMap

NumFmtMap ScExternalRefManager::maNumFormatMap
private

Definition at line 845 of file externalrefmgr.hxx.

Referenced by getMappedNumberFormat().

◆ maRefCache

ScExternalRefCache ScExternalRefManager::maRefCache
private

◆ maRefCells

RefCellMap ScExternalRefManager::maRefCells
private

List of referencing cells that may contain external names.

There is one list per source document.

Definition at line 841 of file externalrefmgr.hxx.

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

◆ maSrcDocTimer

AutoTimer ScExternalRefManager::maSrcDocTimer
private

◆ maSrcFiles

std::vector<SrcFileData> ScExternalRefManager::maSrcFiles
private

◆ maUnsavedDocShells

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 832 of file externalrefmgr.hxx.

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

◆ mbDocTimerEnabled

bool ScExternalRefManager::mbDocTimerEnabled
private

Definition at line 865 of file externalrefmgr.hxx.

Referenced by cacheNewDocShell(), and enableDocTimer().

◆ mbInReferenceMarking

bool ScExternalRefManager::mbInReferenceMarking
private

Status whether in reference marking state.

See isInReferenceMarking().

Definition at line 854 of file externalrefmgr.hxx.

Referenced by setAllCacheTableReferencedStati().

◆ mbSkipUnusedFileIds

bool ScExternalRefManager::mbSkipUnusedFileIds = false
private

◆ mbUserInteractionEnabled

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 860 of file externalrefmgr.hxx.

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

◆ mrDoc

ScDocument& ScExternalRefManager::mrDoc
private

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