sc/source/ui/view/tabvwsh3.cxx |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

New commits:
commit 364c807cf22de7898e918a9cd1fa7e5392ca7577
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Wed Dec 8 00:26:06 2021 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Tue Dec 14 23:10:18 2021 +0100

    Related: tdf#132466 Relative address parsing needs current position
    
    For the bug doc example the #C target lead to always column 1
    (A,0) being selected. Instead, the column of the current cell
    cursor position should be selected as C is the short notation for
    C[0] in R1C1 address syntax.
    
    This does not "fix" the alleged bug but would yield the desired
    behaviour if there was no sheet C where the intention was to jump
    to.
    
    Change-Id: Ibaed0250b9fb2cbc7f15a4b22404c48b39d41ff8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126496
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 155024040de888270bf90bdd200799cea7d73e4e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126825

diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index 2fa44e4233b4..d8c65f902a83 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -86,22 +86,24 @@ namespace
     };
 
     ScRefFlagsAndType lcl_ParseRangeOrAddress(ScRange& rScRange, ScAddress& 
rScAddress,
-                                              const OUString& aAddress, const 
ScDocument& rDoc)
+                                              const OUString& aAddress, const 
ScDocument& rDoc,
+                                              SCCOL nCurCol, SCROW nCurRow)
     {
         ScRefFlagsAndType aRet;
 
-        formula::FormulaGrammar::AddressConvention eConv;
+        // Relative address parsing needs current position.
+        // row,col parameters, not col,row!
+        ScAddress::Details aDetails( rDoc.GetAddressConvention(), nCurRow, 
nCurCol);
 
         // start with the address convention set in the document
-        eConv = rDoc.GetAddressConvention();
-        aRet.nResult = rScRange.Parse(aAddress, rDoc, eConv);
+        aRet.nResult = rScRange.Parse(aAddress, rDoc, aDetails);
         if (aRet.nResult & ScRefFlags::VALID)
         {
             aRet.eDetected = DetectFlags::RANGE;
             return aRet;
         }
 
-        aRet.nResult = rScAddress.Parse(aAddress, rDoc, eConv);
+        aRet.nResult = rScAddress.Parse(aAddress, rDoc, aDetails);
         if (aRet.nResult & ScRefFlags::VALID)
         {
             aRet.eDetected = DetectFlags::ADDRESS;
@@ -140,14 +142,15 @@ namespace
         }
 
         // try Excel R1C1 address convention
-        aRet.nResult = rScRange.Parse(aAddress, rDoc, 
formula::FormulaGrammar::CONV_XL_R1C1);
+        aDetails.eConv = formula::FormulaGrammar::CONV_XL_R1C1;
+        aRet.nResult = rScRange.Parse(aAddress, rDoc, aDetails);
         if (aRet.nResult & ScRefFlags::VALID)
         {
             aRet.eDetected = DetectFlags::RANGE;
             return aRet;
         }
 
-        aRet.nResult = rScAddress.Parse(aAddress, rDoc, 
formula::FormulaGrammar::CONV_XL_R1C1);
+        aRet.nResult = rScAddress.Parse(aAddress, rDoc, aDetails);
         if (aRet.nResult & ScRefFlags::VALID)
         {
             aRet.eDetected = DetectFlags::ADDRESS;
@@ -330,7 +333,8 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
                 ScMarkData& rMark     = rViewData.GetMarkData();
                 ScRange     aScRange;
                 ScAddress   aScAddress;
-                ScRefFlagsAndType aResult = lcl_ParseRangeOrAddress(aScRange, 
aScAddress, aAddress, rDoc);
+                ScRefFlagsAndType aResult = lcl_ParseRangeOrAddress(aScRange, 
aScAddress, aAddress, rDoc,
+                        rViewData.GetCurX(), rViewData.GetCurY());
                 ScRefFlags  nResult = aResult.nResult;
                 SCTAB       nTab = rViewData.GetTabNo();
                 bool        bMark = true;

Reply via email to