Related: tdf#113541 use reference syntax of the document being edited
When creating a formula referencing an external document by
travelling (clicking in) to that document, the reference was
created using the reference syntax of the referenced document,
which may be different if the syntax was changed for only one of
the documents after being opened. Use the reference syntax of the
document being edited instead so the created reference is correct
and can be compiled.
Change-Id: I07d0ce9cd911ac8e62576b4cdabdfd2569336fbf
Reviewed-on: https://gerrit.libreoffice.org/73983
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index cadf157..eb8142a 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3046,15 +3046,16 @@ void ScInputHandler::SetReference( const ScRange& rRef, const ScDocument* pDoc )
{
HideTip();
bool bOtherDoc = ( pRefViewSh &&
pRefViewSh->GetViewData().GetDocument() != pDoc );
if (bOtherDoc)
if (!pDoc->GetDocumentShell()->HasName())
{
// References to unnamed document; that doesn't work
// SetReference should not be called, then
return;
}
const ScDocument* pThisDoc = nullptr;
bool bOtherDoc = (pRefViewSh && ((pThisDoc = pRefViewSh->GetViewData().GetDocument()) != pDoc));
if (bOtherDoc && !pDoc->GetDocumentShell()->HasName())
{
// References to unnamed document; that doesn't work
// SetReference should not be called, then
return;
}
if (!pThisDoc)
pThisDoc = pDoc;
UpdateActiveView();
if (!pTableView && !pTopView)
@@ -3089,9 +3090,9 @@ void ScInputHandler::SetReference( const ScRange& rRef, const ScDocument* pDoc )
}
}
// Create string from reference
// Create string from reference, in the syntax of the document being edited.
OUString aRefStr;
const ScAddress::Details aAddrDetails( pDoc, aCursorPos );
const ScAddress::Details aAddrDetails( pThisDoc, aCursorPos );
if (bOtherDoc)
{
// Reference to other document