pyuno/source/loader/pythonloader.py |    3 
 sc/source/core/tool/interpr1.cxx    |  130 ++++++++++++++++++------------------
 2 files changed, 68 insertions(+), 65 deletions(-)

New commits:
commit 312704298ebff67db4a747014b8a0c5a306b665a
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Sep 16 10:53:21 2022 +0300
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Sep 19 17:22:45 2022 +0200

    tdf#150982: properly unquote (URL-decode) vnd.sun.star.expand payload
    
    Similar to what is done in bootstrap_expandUri, expandUnoRcUrl,
    UrlReference::expand, JavaLoader.expand_url, and is documented
    in XVndSunStarExpandUrl interface.
    
    Change-Id: I92917adb38e42c3926494427e4df2451298033e0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140042
    Reviewed-by: Stephan Bergmann <[email protected]>
    Tested-by: Mike Kaganski <[email protected]>
    (cherry picked from commit 2875d11939679ec319e5b098a9b85da629781d5c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139992
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/pyuno/source/loader/pythonloader.py 
b/pyuno/source/loader/pythonloader.py
index 9a7114aea210..02f901942cbb 100644
--- a/pyuno/source/loader/pythonloader.py
+++ b/pyuno/source/loader/pythonloader.py
@@ -21,6 +21,7 @@ import unohelper
 import sys
 import types
 import os
+from urllib.parse import unquote
 from com.sun.star.uno import Exception,RuntimeException
 from com.sun.star.loader import XImplementationLoader
 from com.sun.star.lang import XServiceInfo
@@ -68,7 +69,7 @@ class Loader( XImplementationLoader, XServiceInfo, 
unohelper.Base ):
         protocol, dependent = splitUrl( url )
         if "vnd.sun.star.expand" == protocol:
             exp = self.ctx.getValueByName( 
"/singletons/com.sun.star.util.theMacroExpander" )
-            url = exp.expandMacros(dependent)
+            url = exp.expandMacros(unquote(dependent))
             protocol,dependent = splitUrl( url )
 
         if DEBUG:
commit 4f66fada43cf50767066c756def7eb39654e376b
Author:     Eike Rathke <[email protected]>
AuthorDate: Mon Sep 19 12:29:34 2022 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Sep 19 17:22:31 2022 +0200

    Resolves: tdf#151046 INDIRECT() try named expressions and DB range names 
first
    
    ... as older 1K columns allowed names that would now match a 16k
    columns cell address, which ConvertSingleRef() would already
    resolve.
    
    Change-Id: I9322732e554da20c81856c0a30c41a246356f65b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140147
    Reviewed-by: Eike Rathke <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit cc28ea4c4483df1643154adc50bd537e35fabb05)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140154
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 25f334d6835d..e09620605d35 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8190,6 +8190,72 @@ void ScInterpreter::ScIndirect()
     const ScAddress::Details aDetailsXlA1( FormulaGrammar::CONV_XL_A1, aPos );
     SCTAB nTab = aPos.Tab();
 
+    // Named expressions and DB range names need to be tried first, as older 1K
+    // columns allowed names that would now match a 16k columns cell address.
+    do
+    {
+        ScRangeData* pData = ScRangeStringConverter::GetRangeDataFromString( 
sRefStr, nTab, mrDoc, eConv);
+        if (!pData)
+            break;
+
+        // We need this in order to obtain a good range.
+        pData->ValidateTabRefs();
+
+        ScRange aRange;
+
+        // This is the usual way to treat named ranges containing
+        // relative references.
+        if (!pData->IsReference( aRange, aPos))
+            break;
+
+        if (aRange.aStart == aRange.aEnd)
+            PushSingleRef( aRange.aStart.Col(), aRange.aStart.Row(),
+                    aRange.aStart.Tab());
+        else
+            PushDoubleRef( aRange.aStart.Col(), aRange.aStart.Row(),
+                    aRange.aStart.Tab(), aRange.aEnd.Col(),
+                    aRange.aEnd.Row(), aRange.aEnd.Tab());
+
+        // success!
+        return;
+    }
+    while (false);
+
+    do
+    {
+        OUString aName( ScGlobal::getCharClass().uppercase( sRefStr));
+        ScDBCollection::NamedDBs& rDBs = 
mrDoc.GetDBCollection()->getNamedDBs();
+        const ScDBData* pData = rDBs.findByUpperName( aName);
+        if (!pData)
+            break;
+
+        ScRange aRange;
+        pData->GetArea( aRange);
+
+        // In Excel, specifying a table name without [] resolves to the
+        // same as with [], a range that excludes header and totals
+        // rows and contains only data rows. Do the same.
+        if (pData->HasHeader())
+            aRange.aStart.IncRow();
+        if (pData->HasTotals())
+            aRange.aEnd.IncRow(-1);
+
+        if (aRange.aStart.Row() > aRange.aEnd.Row())
+            break;
+
+        if (aRange.aStart == aRange.aEnd)
+            PushSingleRef( aRange.aStart.Col(), aRange.aStart.Row(),
+                    aRange.aStart.Tab());
+        else
+            PushDoubleRef( aRange.aStart.Col(), aRange.aStart.Row(),
+                    aRange.aStart.Tab(), aRange.aEnd.Col(),
+                    aRange.aEnd.Row(), aRange.aEnd.Tab());
+
+        // success!
+        return;
+    }
+    while (false);
+
     ScRefAddress aRefAd, aRefAd2;
     ScAddress::ExternalInfo aExtInfo;
     if ( ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd, aRefAd2, aDetails, 
&aExtInfo) ||
@@ -8220,70 +8286,6 @@ void ScInterpreter::ScIndirect()
     }
     else
     {
-        do
-        {
-            ScRangeData* pData = 
ScRangeStringConverter::GetRangeDataFromString( sRefStr, nTab, mrDoc, eConv);
-            if (!pData)
-                break;
-
-            // We need this in order to obtain a good range.
-            pData->ValidateTabRefs();
-
-            ScRange aRange;
-
-            // This is the usual way to treat named ranges containing
-            // relative references.
-            if (!pData->IsReference( aRange, aPos))
-                break;
-
-            if (aRange.aStart == aRange.aEnd)
-                PushSingleRef( aRange.aStart.Col(), aRange.aStart.Row(),
-                        aRange.aStart.Tab());
-            else
-                PushDoubleRef( aRange.aStart.Col(), aRange.aStart.Row(),
-                        aRange.aStart.Tab(), aRange.aEnd.Col(),
-                        aRange.aEnd.Row(), aRange.aEnd.Tab());
-
-            // success!
-            return;
-        }
-        while (false);
-
-        do
-        {
-            OUString aName( ScGlobal::getCharClass().uppercase( sRefStr));
-            ScDBCollection::NamedDBs& rDBs = 
mrDoc.GetDBCollection()->getNamedDBs();
-            const ScDBData* pData = rDBs.findByUpperName( aName);
-            if (!pData)
-                break;
-
-            ScRange aRange;
-            pData->GetArea( aRange);
-
-            // In Excel, specifying a table name without [] resolves to the
-            // same as with [], a range that excludes header and totals
-            // rows and contains only data rows. Do the same.
-            if (pData->HasHeader())
-                aRange.aStart.IncRow();
-            if (pData->HasTotals())
-                aRange.aEnd.IncRow(-1);
-
-            if (aRange.aStart.Row() > aRange.aEnd.Row())
-                break;
-
-            if (aRange.aStart == aRange.aEnd)
-                PushSingleRef( aRange.aStart.Col(), aRange.aStart.Row(),
-                        aRange.aStart.Tab());
-            else
-                PushDoubleRef( aRange.aStart.Col(), aRange.aStart.Row(),
-                        aRange.aStart.Tab(), aRange.aEnd.Col(),
-                        aRange.aEnd.Row(), aRange.aEnd.Tab());
-
-            // success!
-            return;
-        }
-        while (false);
-
         // It may be even a TableRef or an external name.
         // Anything else that resolves to one reference could be added
         // here, but we don't want to compile every arbitrary string. This

Reply via email to