sc/source/ui/formdlg/formula.cxx |   24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

New commits:
commit 3b5fccb308b9554d024e1d576abbf3ebec26b7a5
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Thu Aug 6 19:40:58 2020 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Sun Aug 9 21:46:00 2020 +0200

    Resolves: tdf#134876 Absolute range references when selecting in Wizard
    
    Not doing the same for ScInputHandler::SetReference() now because
    selecting by keyboard is more likely to keep the existing
    behaviour and is easily edited to change.
    
    Change-Id: I368aa21c7f1099d175805493c92070da280cafa4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100267
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index de2c41cfed0b..c21a8d859cbc 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -406,6 +406,16 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, 
ScDocument& rRefDoc )
         RefInputStart(GetActiveEdit());
     }
 
+    // Pointer-selected => absolute range references for the non-single
+    // dimensions, so in the other dimension (if any) it's still
+    // copy-adjustable.
+    constexpr ScRefFlags eColFlags = ScRefFlags::COL_ABS | 
ScRefFlags::COL2_ABS;
+    constexpr ScRefFlags eRowFlags = ScRefFlags::ROW_ABS | 
ScRefFlags::ROW2_ABS;
+    ScRefFlags eRangeFlags = ScRefFlags::ZERO;
+    if (rRef.aStart.Col() != rRef.aEnd.Col())
+        eRangeFlags |= eColFlags;
+    if (rRef.aStart.Row() != rRef.aEnd.Row())
+        eRangeFlags |= eRowFlags;
     OUString      aRefStr;
     bool bOtherDoc = (&rRefDoc != m_pDoc && 
rRefDoc.GetDocumentShell()->HasName());
     if ( bOtherDoc )
@@ -414,8 +424,8 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, 
ScDocument& rRefDoc )
 
         OSL_ENSURE(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
 
-        // Always 3D and absolute.
-        OUString aTmp( rRef.Format(rRefDoc, ScRefFlags::VALID | 
ScRefFlags::TAB_ABS_3D));
+        // Sheet always 3D and absolute.
+        OUString aTmp( rRef.Format(rRefDoc, ScRefFlags::VALID | 
ScRefFlags::TAB_ABS_3D | eRangeFlags));
 
         SfxObjectShell* pObjSh = rRefDoc.GetDocumentShell();
 
@@ -433,6 +443,16 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, 
ScDocument& rRefDoc )
         ScTokenArray aArray(&rRefDoc);
         ScComplexRefData aRefData;
         aRefData.InitRangeRel(&rRefDoc, rRef, m_CursorPos);
+        if ((eRangeFlags & eColFlags) == eColFlags)
+        {
+            aRefData.Ref1.SetAbsCol( rRef.aStart.Col() );
+            aRefData.Ref2.SetAbsCol( rRef.aEnd.Col() );
+        }
+        if ((eRangeFlags & eRowFlags) == eRowFlags)
+        {
+            aRefData.Ref1.SetAbsRow( rRef.aStart.Row() );
+            aRefData.Ref2.SetAbsRow( rRef.aEnd.Row() );
+        }
         bool bSingle = aRefData.Ref1 == aRefData.Ref2;
         if (m_CursorPos.Tab() != rRef.aStart.Tab())
         {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to