Hi Guys,
We have a bug here in the suse system that highlights a regression
attempting to resolve a range by name. Note: this is not a problem on
master.
the failing macro code is something like so;
Sub test
ProjectPlanSheet = ThisComponent.Sheets.getByName( ProjectPlan )
chkCellControl = ProjectPlanSheet.getCellRangeByName( TASK3_ON )
End Sub
where TASK3_ON is a document global rangename
after some digging the commits on master that seem to be involved are
e9159d142a4f25bff88da3dd90e163135ae0bdfa
9e8ae1d56076474e4673a953d8ebd726cb5daa18
I attach a backport of these patches ( in so far as I could backport
them with at times quite different code base )
Note: for this bug the patch to rangeutl.cxx seems sufficient, I
backported the rest for completeness. I want to sound you both out about
applying the patch either partially ( e.g. just the rangeutl.cxx part )
or even completely to 3.4 or... even find out if ye considered either
version too risky.
thanks,
Noel
diff --git sc/inc/rangenam.hxx sc/inc/rangenam.hxx
index fdff278..7417094 100644
--- sc/inc/rangenam.hxx
+++ sc/inc/rangenam.hxx
@@ -202,8 +202,8 @@ public:
SC_DLLPUBLIC const ScRangeData* findByRange(const ScRange rRange) const;
SC_DLLPUBLIC ScRangeData* findByName(const rtl::OUString rName);
SC_DLLPUBLIC const ScRangeData* findByName(const rtl::OUString rName) const;
-ScRangeData* findByUpperName(const rtl::OUString rName);
-const ScRangeData* findByUpperName(const rtl::OUString rName) const;
+SC_DLLPUBLIC ScRangeData* findByUpperName(const rtl::OUString rName);
+SC_DLLPUBLIC const ScRangeData* findByUpperName(const rtl::OUString rName) const;
SC_DLLPUBLIC ScRangeData* findByIndex(sal_uInt16 i);
void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange rRange,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
diff --git sc/source/core/data/documen2.cxx sc/source/core/data/documen2.cxx
index 97292ca..5720e63 100644
--- sc/source/core/data/documen2.cxx
+++ sc/source/core/data/documen2.cxx
@@ -991,7 +991,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
bool bInUse = ( aUsedNames.find(nOldIndex) != aUsedNames.end() );
if (bInUse)
{
-const ScRangeData* pExistingData = GetRangeName()-findByName(itr-GetName());
+const ScRangeData* pExistingData = GetRangeName()-findByUpperName(itr-GetUpperName());
if (pExistingData)
{
// the name exists already in the destination document
diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
index 48cf99b..e85ba1f 100644
--- sc/source/core/data/document.cxx
+++ sc/source/core/data/document.cxx
@@ -1867,7 +1867,7 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
A proper solution would ask the user how to proceed.
The adjustment of the indices in the formulas is done later.
*/
-const ScRangeData* pExistingData = GetRangeName()-findByName(itr-GetName());
+const ScRangeData* pExistingData = GetRangeName()-findByUpperName(itr-GetUpperName());
if (pExistingData)
{
sal_uInt16 nOldIndex = itr-GetIndex();
diff --git sc/source/core/tool/interpr1.cxx sc/source/core/tool/interpr1.cxx
index 3614896..eb5ab56 100644
--- sc/source/core/tool/interpr1.cxx
+++ sc/source/core/tool/interpr1.cxx
@@ -6628,7 +6628,7 @@ void ScInterpreter::ScIndirect()
if (!pNames)
break;
-ScRangeData* pData = pNames-findByName(sRefStr);
+ScRangeData* pData = pNames-findByUpperName(ScGlobal::pCharClass-upper(sRefStr));
if (!pData)
break;
diff --git sc/source/core/tool/rangenam.cxx sc/source/core/tool/rangenam.cxx
index 35c00dc..b648d1a 100644
--- sc/source/core/tool/rangenam.cxx
+++ sc/source/core/tool/rangenam.cxx
@@ -682,17 +682,6 @@ public:
}
};
-class MatchByName : public unary_functionScRangeData, bool
-{
-const OUString mrName;
-public:
-MatchByName(const OUString rName) : mrName(rName) {}
-bool operator() (const ScRangeData r) const
-{
-return mrName.equals(r.GetName());
-}
-};
-
class MatchByUpperName : public unary_functionScRangeData, bool
{
const OUString mrName;
@@ -760,20 +749,6 @@ const ScRangeData* ScRangeName::findByRange(const ScRange rRange) const
return itr == maData.end() ? NULL : (*itr);
}
-ScRangeData* ScRangeName::findByName(const OUString rName)
-{
-DataType::iterator itr = std::find_if(
-maData.begin(), maData.end(), MatchByName(rName));
-return itr == maData.end() ? NULL : (*itr);
-}
-
-const ScRangeData* ScRangeName::findByName(const OUString rName) const
-{
-DataType::const_iterator itr = std::find_if(
-