sc/inc/externalrefmgr.hxx | 8 ++++---- sc/source/ui/docshell/externalrefmgr.cxx | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-)
New commits: commit b01e7dec34e92a46add83de503c086ba12a3ab51 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Dec 2 14:40:27 2021 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Dec 3 10:01:40 2021 +0100 Related: ofz#41376 reuse ScExternalRefManager ScDocument in ScExternalRefCache Change-Id: Iaed5b7929411dc938fe19df02905a9c9faa52051 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126256 Tested-by: Jenkins Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx index 0317e89a4538..1064910ad975 100644 --- a/sc/inc/externalrefmgr.hxx +++ b/sc/inc/externalrefmgr.hxx @@ -182,7 +182,7 @@ public: typedef std::unordered_map< OUString, size_t> TableNameIndexMap; - ScExternalRefCache(); + ScExternalRefCache(const ScDocument& rDoc); ~ScExternalRefCache(); const OUString* getRealTableName(sal_uInt16 nFileId, const OUString& rTabName) const; @@ -298,8 +298,8 @@ public: */ void clearCacheTables(sal_uInt16 nFileId); - // Get the fake doc used to pass to methods that need an ScDocument in order to do row/col validation - const ScDocument* getFakeDoc() const { return mxFakeDoc.get(); } + // Get the doc used to pass to methods that need an ScDocument in order to do row/col validation + const ScDocument& getDoc() const { return mrDoc; } private: struct RangeHash @@ -358,7 +358,7 @@ private: private: mutable osl::Mutex maMtxDocs; mutable DocDataType maDocs; - ScDocumentUniquePtr mxFakeDoc; // just to have something to pass to the methods that need to validate columns/rows + const ScDocument& mrDoc; }; class SC_DLLPUBLIC ScExternalRefManager final : public formula::ExternalReferenceHelper, public SfxListener diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 472872db7359..6ebb6bd7b9fb 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -457,9 +457,10 @@ ScExternalRefCache::CellFormat::CellFormat() : { } -ScExternalRefCache::ScExternalRefCache() - : mxFakeDoc(new ScDocument()) -{} +ScExternalRefCache::ScExternalRefCache(const ScDocument& rDoc) + : mrDoc(rDoc) +{ +} ScExternalRefCache::~ScExternalRefCache() {} @@ -688,7 +689,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData( ScMatrixToken aToken(xMat); if (!pArray) - pArray = std::make_shared<ScTokenArray>(*mxFakeDoc); + pArray = std::make_shared<ScTokenArray>(mrDoc); pArray->AddToken(aToken); bFirstTab = false; @@ -1638,6 +1639,7 @@ bool isLinkUpdateAllowedInDoc(const ScDocument& rDoc) ScExternalRefManager::ScExternalRefManager(ScDocument& rDoc) : mrDoc(rDoc), + maRefCache(rDoc), mbInReferenceMarking(false), mbUserInteractionEnabled(true), mbDocTimerEnabled(true), @@ -1849,7 +1851,7 @@ void putRangeDataIntoCache( else { // Array is empty. Fill it with an empty matrix of the required size. - pArray = lcl_fillEmptyMatrix(*rRefCache.getFakeDoc(), rCacheRange); + pArray = lcl_fillEmptyMatrix(rRefCache.getDoc(), rCacheRange); // Make sure to set this range 'cached', to prevent unnecessarily // accessing the src document time and time again. @@ -2052,7 +2054,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokens( if (!pSrcDoc) { // Source document is not reachable. Throw a reference error. - pArray = std::make_shared<ScTokenArray>(*maRefCache.getFakeDoc()); + pArray = std::make_shared<ScTokenArray>(maRefCache.getDoc()); pArray->AddToken(FormulaErrorToken(FormulaError::NoRef)); return pArray; }