sc/source/filter/oox/excelfilter.cxx |8 ++-
sc/source/filter/xml/xmlimprt.cxx|3 +
sc/source/ui/docshell/arealink.cxx |3 +
sc/source/ui/docshell/docsh.cxx | 25 +
sc/source/ui/docshell/docsh4.cxx | 90 +--
sc/source/ui/inc/docsh.hxx |1
6 files changed, 71 insertions(+), 59 deletions(-)
New commits:
commit 1663fd0f85a523bfbd46e836436e979344f009d3
Author: Eike Rathke
AuthorDate: Sun Aug 1 21:40:15 2021 +0200
Commit: Caolán McNamara
CommitDate: Tue Aug 3 12:40:30 2021 +0200
Consolidate link update handling
Have it at one central place and identical for all document
loading paths.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119835
Reviewed-by: Eike Rathke
Tested-by: Jenkins
(cherry picked from commit 55abc3eb93fb8314b413453e384261cb00fde087)
Conflicts:
sc/source/ui/docshell/docsh4.cxx
Change-Id: Ib00153a9f5831e223d0129df0538353a7e20961e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119852
Tested-by: Mike Kaganski
Reviewed-by: Mike Kaganski
Reviewed-by: Caolán McNamara
diff --git a/sc/source/filter/oox/excelfilter.cxx
b/sc/source/filter/oox/excelfilter.cxx
index b5d01215baf8..e5815200e063 100644
--- a/sc/source/filter/oox/excelfilter.cxx
+++ b/sc/source/filter/oox/excelfilter.cxx
@@ -109,14 +109,18 @@ bool ExcelFilter::importDocument()
if (xBookGlob)
{
rtl::Reference xWorkbookFragment( new
WorkbookFragment(*xBookGlob, aWorkbookPath));
+
+const WorkbookFragment* pWF = static_cast(xWorkbookFragment.get());
+const ScDocument& rDoc = pWF->getScDocument();
+if (ScDocShell* pDocSh =
static_cast(rDoc.GetDocumentShell()))
+pDocSh->SetInitialLinkUpdate( pDocSh->GetMedium());
+
bool bRet = importFragment( xWorkbookFragment);
if (bRet)
{
-const WorkbookFragment* pWF = static_cast(xWorkbookFragment.get());
const AddressConverter& rAC = pWF->getAddressConverter();
if (rAC.isTabOverflow() || rAC.isColOverflow() ||
rAC.isRowOverflow())
{
-const ScDocument& rDoc = pWF->getScDocument();
if (rDoc.IsUserInteractionEnabled())
{
// Show data loss warning.
diff --git a/sc/source/filter/xml/xmlimprt.cxx
b/sc/source/filter/xml/xmlimprt.cxx
index 968ebb0cdbfe..99d33d2416db 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1138,6 +1138,9 @@ void SAL_CALL ScXMLImport::setTargetDocument( const
css::uno::Reference< css::la
if (!pDoc)
throw lang::IllegalArgumentException();
+if (ScDocShell* pDocSh =
static_cast(pDoc->GetDocumentShell()))
+pDocSh->SetInitialLinkUpdate( pDocSh->GetMedium());
+
mpDocImport.reset(new ScDocumentImport(*pDoc));
mpComp.reset(new ScCompiler(*pDoc, ScAddress(),
formula::FormulaGrammar::GRAM_ODFF));
diff --git a/sc/source/ui/docshell/arealink.cxx
b/sc/source/ui/docshell/arealink.cxx
index 2b66e13e2327..e44e364c461a 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -226,6 +226,9 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const
OUString& rNewFilter,
if (rNewFile.isEmpty() || rNewFilter.isEmpty())
return false;
+if (!m_pDocSh->GetEmbeddedObjectContainer().getUserAllowsLinkUpdate())
+return false;
+
OUString aNewUrl( ScGlobal::GetAbsDocName( rNewFile, m_pDocSh ) );
bool bNewUrlName = (aNewUrl != aFileName);
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 29435d90a2f4..8e2c3c45218f 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -586,21 +586,7 @@ bool ScDocShell::Load( SfxMedium& rMedium )
bool bRet = SfxObjectShell::Load(rMedium);
if (bRet)
{
-if (GetMedium())
-{
-const SfxUInt16Item* pUpdateDocItem =
SfxItemSet::GetItem(rMedium.GetItemSet(), SID_UPDATEDOCMODE,
false);
-m_nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() :
css::document::UpdateDocMode::NO_UPDATE;
-}
-
-// GetLinkUpdateModeState() evaluates m_nCanUpdate so that must have
-// been set first. Do not override an already forbidden LinkUpdate (the
-// default is allow).
-comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer =
getEmbeddedObjectContainer();
-if (rEmbeddedObjectContainer.getUserAllowsLinkUpdate())
-{
-// For anything else than LM_ALWAYS we need user confirmation.
-rEmbeddedObjectContainer.setUserAllowsLinkUpdate(
GetLinkUpdateModeState() == LM_ALWAYS);
-}
+SetInitialLinkUpdate(&rMedium);
{
// prepare a valid document for XML