summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/docshell/docsh.cxx13
-rw-r--r--sc/source/ui/docshell/docsh4.cxx67
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx8
-rw-r--r--sc/source/ui/inc/docsh.hxx2
4 files changed, 56 insertions, 34 deletions
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index ad8d664dd690..6859942b79d4 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -582,15 +582,22 @@ bool ScDocShell::Load( SfxMedium& rMedium )
bool bRet = SfxObjectShell::Load(rMedium);
if (bRet)
{
- comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer();
- rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
-
if (GetMedium())
{
const SfxUInt16Item* pUpdateDocItem = SfxItemSet::GetItem<SfxUInt16Item>(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);
+ }
+
{
// prepare a valid document for XML filter
// (for ConvertFrom, InitNew is called before)
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index a46aac7147ba..c83a3f154f72 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -144,6 +144,41 @@ IMPL_LINK_NOARG( ScDocShell, ReloadAllLinksHdl, Button*, void )
SAL_WARN_IF(!pViewFrame, "sc", "expected there to be a ViewFrame");
}
+ScLkUpdMode ScDocShell::GetLinkUpdateModeState() const
+{
+ const ScDocument& rDoc = GetDocument();
+
+ ScLkUpdMode nSet = rDoc.GetLinkMode();
+
+ if (nSet == LM_UNKNOWN)
+ {
+ ScAppOptions aAppOptions = SC_MOD()->GetAppOptions();
+ nSet = aAppOptions.GetLinkMode();
+ }
+
+ if (m_nCanUpdate == css::document::UpdateDocMode::NO_UPDATE)
+ nSet = LM_NEVER;
+ else if (m_nCanUpdate == css::document::UpdateDocMode::FULL_UPDATE)
+ nSet = LM_ALWAYS;
+
+ if (nSet == LM_ALWAYS
+ && !(SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
+ GetMedium() == nullptr ? OUString() : GetMedium()->GetName())
+ || (IsDocShared()
+ && SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
+ GetSharedFileURL()))))
+ {
+ nSet = LM_ON_DEMAND;
+ }
+ if (m_nCanUpdate == css::document::UpdateDocMode::QUIET_UPDATE
+ && nSet == LM_ON_DEMAND)
+ {
+ nSet = LM_NEVER;
+ }
+
+ return nSet;
+}
+
void ScDocShell::Execute( SfxRequest& rReq )
{
const SfxItemSet* pReqArgs = rReq.GetArgs();
@@ -441,37 +476,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
break;
case SID_UPDATETABLINKS:
{
- ScDocument& rDoc = GetDocument();
-
- ScLkUpdMode nSet = rDoc.GetLinkMode();
-
- if(nSet==LM_UNKNOWN)
- {
- ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
- nSet=aAppOptions.GetLinkMode();
- }
-
- if (m_nCanUpdate == css::document::UpdateDocMode::NO_UPDATE)
- nSet = LM_NEVER;
- else if (m_nCanUpdate == css::document::UpdateDocMode::FULL_UPDATE)
- nSet = LM_ALWAYS;
-
- if (nSet == LM_ALWAYS
- && !(SvtSecurityOptions()
- .isTrustedLocationUriForUpdatingLinks(
- GetMedium() == nullptr
- ? OUString() : GetMedium()->GetName())
- || (IsDocShared()
- && SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
- GetSharedFileURL()))))
- {
- nSet = LM_ON_DEMAND;
- }
- if (m_nCanUpdate == css::document::UpdateDocMode::QUIET_UPDATE
- && nSet == LM_ON_DEMAND)
- {
- nSet = LM_NEVER;
- }
+ ScLkUpdMode nSet = GetLinkUpdateModeState();
if (nSet == LM_ALWAYS)
{
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index df5f1a86920c..dc1148536414 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -58,6 +58,7 @@
#include <columnspanset.hxx>
#include <column.hxx>
#include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/document/UpdateDocMode.hpp>
#include <sal/log.hxx>
#include <memory>
@@ -2484,6 +2485,11 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
// If the current document is allowed to execute macros then the referenced
// document may execute macros according to the security configuration.
+ // Similar for UpdateDocMode to update links, just that if we reach here
+ // the user already allowed updates and intermediate documents are expected
+ // to update as well. When loading the document ScDocShell::Load() will
+ // check through ScDocShell::GetLinkUpdateModeState() if its location is
+ // trusted.
SfxObjectShell* pShell = mpDoc->GetDocumentShell();
if (pShell)
{
@@ -2495,6 +2501,8 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
static_cast<const SfxUInt16Item*>(pItem)->GetValue() != css::document::MacroExecMode::NEVER_EXECUTE)
pSet->Put( SfxUInt16Item( SID_MACROEXECMODE, css::document::MacroExecMode::USE_CONFIG));
}
+
+ pSet->Put( SfxUInt16Item( SID_UPDATEDOCMODE, css::document::UpdateDocMode::FULL_UPDATE));
}
unique_ptr<SfxMedium> pMedium(new SfxMedium(aFile, StreamMode::STD_READ, pFilter, std::move(pSet)));
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index c3e8b850d8ab..0e430172e9cf 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -218,6 +218,7 @@ public:
void GetDocStat( ScDocStat& rDocStat );
+ const ScDocument& GetDocument() const { return m_aDocument; }
ScDocument& GetDocument() { return m_aDocument; }
ScDocFunc& GetDocFunc() { return *m_pDocFunc; }
@@ -300,6 +301,7 @@ public:
void UpdateLinks() override;
void ReloadAllLinks();
void ReloadTabLinks();
+ ScLkUpdMode GetLinkUpdateModeState() const;
void SetFormulaOptions( const ScFormulaOptions& rOpt, bool bForLoading = false );
/**