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_function<ScRangeData, 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_function<ScRangeData, 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(
- maData.begin(), maData.end(), MatchByName(rName));
- return itr == maData.end() ? NULL : &(*itr);
-}
-
ScRangeData* ScRangeName::findByUpperName(const OUString& rName)
{
DataType::iterator itr = std::find_if(
diff --git sc/source/core/tool/rangeutl.cxx sc/source/core/tool/rangeutl.cxx
index 72bd8d6..f012f5f 100644
--- sc/source/core/tool/rangeutl.cxx
+++ sc/source/core/tool/rangeutl.cxx
@@ -288,8 +288,28 @@ sal_Bool ScRangeUtil::MakeRangeFromName (
if( eScope==RUTL_NAMES )
{
- const ScRangeName& rRangeNames = *pDoc->GetRangeName();
- const ScRangeData* pData = rRangeNames.findByName(rName);
+ //first handle ui names like local1 (Sheet1), which point to a local range name
+ rtl::OUString aName(rName);
+ sal_Int32 nEndPos = aName.lastIndexOf(')');
+ sal_Int32 nStartPos = aName.lastIndexOfAsciiL(" (",2);
+ SCTAB nTable = nCurTab;
+ if (nEndPos != -1 && nStartPos != -1)
+ {
+ rtl::OUString aSheetName = aName.copy(nStartPos+2, nEndPos-nStartPos-2);
+ if (pDoc->GetTable(aSheetName, nTable))
+ {
+ aName = aName.copy(0, nStartPos);
+ }
+ else
+ nTable = nCurTab;
+ }
+ //then check for local range names
+ ScRangeName* pRangeNames = pDoc->GetRangeName( nTable );
+ ScRangeData* pData = NULL;
+ if ( pRangeNames )
+ pData = pRangeNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
+ if (!pData)
+ pData = pDoc->GetRangeName()->findByUpperName(ScGlobal::pCharClass->upper(aName));
if (pData)
{
String aStrArea;
@@ -298,7 +318,7 @@ sal_Bool ScRangeUtil::MakeRangeFromName (
pData->GetSymbol( aStrArea );
- if ( IsAbsArea( aStrArea, pDoc, nCurTab,
+ if ( IsAbsArea( aStrArea, pDoc, nTable,
NULL, &aStartPos, &aEndPos, rDetails ) )
{
nTab = aStartPos.Tab();
@@ -312,7 +332,7 @@ sal_Bool ScRangeUtil::MakeRangeFromName (
{
CutPosString( aStrArea, aStrArea );
- if ( IsAbsPos( aStrArea, pDoc, nCurTab,
+ if ( IsAbsPos( aStrArea, pDoc, nTable,
NULL, &aStartPos, rDetails ) )
{
nTab = aStartPos.Tab();
diff --git sc/source/filter/html/htmlimp.cxx sc/source/filter/html/htmlimp.cxx
index 7ebe5e1..b0e15d3 100644
--- sc/source/filter/html/htmlimp.cxx
+++ sc/source/filter/html/htmlimp.cxx
@@ -209,7 +209,7 @@ void ScHTMLImport::WriteToDocument(
if( pTable->GetTableName().Len() )
{
String aName( ScfTools::GetNameFromHTMLName( pTable->GetTableName() ) );
- if (!mpDoc->GetRangeName()->findByName(aName))
+ if (!mpDoc->GetRangeName()->findByUpperName(ScGlobal::pCharClass->upper(aName)))
InsertRangeName( mpDoc, aName, aNewRange );
}
}
@@ -239,7 +239,7 @@ String ScHTMLImport::GetHTMLRangeNameList( ScDocument* pDoc, const String& rOrig
while( bLoop )
{
aToken = ScfTools::GetNameFromHTMLIndex( nIndex++ );
- const ScRangeData* pRangeData = pRangeNames->findByName(aToken);
+ const ScRangeData* pRangeData =
pRangeNames->findByUpperName(ScGlobal::pCharClass->upper(aToken));
if (pRangeData)
{
ScRange aRange;
diff --git sc/source/filter/rtf/eeimpars.cxx sc/source/filter/rtf/eeimpars.cxx
index f2baf3d..9b652b6 100644
--- sc/source/filter/rtf/eeimpars.cxx
+++ sc/source/filter/rtf/eeimpars.cxx
@@ -404,7 +404,7 @@ void ScEEImport::WriteToDocument( sal_Bool bSizeColsRows, double nOutputFactor,
bHasGraphics |= GraphicSize( nCol, nRow, nTab, pE );
if ( pE->pName )
{ // Anchor Name => RangeName
- if (!pRangeNames->findByName(*pE->pName))
+ if (!pRangeNames->findByUpperName(ScGlobal::pCharClass->upper(*pE->pName)))
{
ScRangeData* pData = new ScRangeData( mpDoc, *pE->pName,
ScAddress( nCol, nRow, nTab ) );
diff --git sc/source/filter/xml/xmlexprt.cxx sc/source/filter/xml/xmlexprt.cxx
index 514e27a..90955d3 100644
--- sc/source/filter/xml/xmlexprt.cxx
+++ sc/source/filter/xml/xmlexprt.cxx
@@ -3771,7 +3771,7 @@ void ScXMLExport::WriteNamedExpressions(const com::sun::star::uno::Reference
<co
xNamedRange->getReferencePosition(), pDoc, FormulaGrammar::CONV_OOO, ' ', sal_False,
SCA_ABS_3D );
AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, sOUBaseCellAddress);
- const ScRangeData* pNamedRange = pNamedRanges->findByName(sOUName);
+ const ScRangeData* pNamedRange =
pNamedRanges->findByUpperName(ScGlobal::pCharClass->upper(sOUName) );
String sContent;
pNamedRange->GetSymbol(sContent, pDoc->GetStorageGrammar());
rtl::OUString sOUTempContent(sContent);
diff --git sc/source/filter/xml/xmlimprt.cxx sc/source/filter/xml/xmlimprt.cxx
index 6d043fc..6d8cbbe 100644
--- sc/source/filter/xml/xmlimprt.cxx
+++ sc/source/filter/xml/xmlimprt.cxx
@@ -2796,7 +2796,7 @@ public:
if ( nUnoType & sheet::NamedRangeFlag::ROW_HEADER ) nNewType |= RT_ROWHEADER;
- if (mpDoc && !mrRangeName.findByName(r.sName))
+ if (mpDoc && !mrRangeName.findByUpperName(ScGlobal::pCharClass->upper(r.sName)))
{
// Insert a new name.
ScAddress aPos;
diff --git sc/source/ui/app/inputwin.cxx sc/source/ui/app/inputwin.cxx
index 4f377ef..c516dc4 100644
--- sc/source/ui/app/inputwin.cxx
+++ sc/source/ui/app/inputwin.cxx
@@ -1676,7 +1676,7 @@ void ScPosWnd::DoEnter()
{
ScRangeName* pNames = pDoc->GetRangeName();
ScRange aSelection;
- if ( pNames && !pNames->findByName(aText) &&
+ if ( pNames && !pNames->findByUpperName(ScGlobal::pCharClass->upper(aText)) &&
(pViewData->GetSimpleArea( aSelection ) == SC_MARK_SIMPLE) )
{
ScRangeName aNewRanges( *pNames );
diff --git sc/source/ui/docshell/arealink.cxx sc/source/ui/docshell/arealink.cxx
index e2be816..398a674 100644
--- sc/source/ui/docshell/arealink.cxx
+++ sc/source/ui/docshell/arealink.cxx
@@ -210,7 +210,7 @@ sal_Bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const S
sal_uInt16 nPos;
if (pNames) // benannte Bereiche
{
- const ScRangeData* p = pNames->findByName(rAreaName);
+ const ScRangeData* p = pNames->findByUpperName(ScGlobal::pCharClass->upper(rAreaName));
if (p && p->IsValidReference(rRange))
bFound = true;
}
diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
index 24e4517..c4df591 100644
--- sc/source/ui/docshell/docfunc.cxx
+++ sc/source/ui/docshell/docfunc.cxx
@@ -4570,7 +4570,7 @@ void ScDocFunc::CreateOneName( ScRangeName& rList,
ScRange( nX1, nY1, nTab, nX2, nY2, nTab ).Format( aContent, SCR_ABS_3D, pDoc );
bool bInsert = false;
- ScRangeData* pOld = rList.findByName(aName);
+ ScRangeData* pOld = rList.findByUpperName(ScGlobal::pCharClass->upper(aName));
if (pOld)
{
String aOldStr;
diff --git sc/source/ui/docshell/docsh4.cxx sc/source/ui/docshell/docsh4.cxx
index 0d8ea68..c25b1d7 100644
--- sc/source/ui/docshell/docsh4.cxx
+++ sc/source/ui/docshell/docsh4.cxx
@@ -2106,7 +2106,7 @@ long ScDocShell::DdeSetData( const String& rItem,
ScRangeName* pRange = aDocument.GetRangeName();
if( pRange )
{
- const ScRangeData* pData = pRange->findByName(aPos);
+ const ScRangeData* pData = pRange->findByUpperName(ScGlobal::pCharClass->upper(aPos));
if (pData)
{
if( pData->HasType( RT_REFAREA )
diff --git sc/source/ui/docshell/impex.cxx sc/source/ui/docshell/impex.cxx
index 901810b..f6a51a9 100644
--- sc/source/ui/docshell/impex.cxx
+++ sc/source/ui/docshell/impex.cxx
@@ -175,7 +175,7 @@ ScImportExport::ScImportExport( ScDocument* p, const String& rPos )
ScRangeName* pRange = pDoc->GetRangeName();
if( pRange )
{
- const ScRangeData* pData = pRange->findByName(aPos);
+ const ScRangeData* pData = pRange->findByUpperName(ScGlobal::pCharClass->upper(aPos));
if (pData)
{
if( pData->HasType( RT_REFAREA )
diff --git sc/source/ui/docshell/servobj.cxx sc/source/ui/docshell/servobj.cxx
index 066d8dc..4dd0771 100644
--- sc/source/ui/docshell/servobj.cxx
+++ sc/source/ui/docshell/servobj.cxx
@@ -54,7 +54,7 @@ sal_Bool lcl_FillRangeFromName( ScRange& rRange, ScDocShell* pDocSh, const Strin
ScRangeName* pNames = pDoc->GetRangeName();
if (pNames)
{
- const ScRangeData* pData = pNames->findByName(rName);
+ const ScRangeData* pData = pNames->findByUpperName(ScGlobal::pCharClass->upper(rName));
if (pData)
{
if ( pData->IsValidReference( rRange ) )
diff --git sc/source/ui/namedlg/namedlg.cxx sc/source/ui/namedlg/namedlg.cxx
index 157c316..9bd5436 100644
--- sc/source/ui/namedlg/namedlg.cxx
+++ sc/source/ui/namedlg/namedlg.cxx
@@ -246,7 +246,7 @@ void ScNameDlg::SetActive()
void ScNameDlg::UpdateChecks()
{
- const ScRangeData* pData = mpCurRangeName->findByName(aEdName.GetText());
+ const ScRangeData* pData =
mpCurRangeName->findByUpperName(ScGlobal::pCharClass->upper(aEdName.GetText()));
if (pData)
{
aBtnCriteria .Check( pData->HasType( RT_CRITERIA ) );
@@ -437,7 +437,7 @@ bool ScNameDlg::AddPushed()
void ScNameDlg::RemovePushed()
{
const String aStrEntry = aEdName.GetText();
- ScRangeData* pData = mpCurRangeName->findByName(aStrEntry);
+ ScRangeData* pData = mpCurRangeName->findByUpperName(ScGlobal::pCharClass->upper(aStrEntry));
if (pData)
{
String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
@@ -482,7 +482,7 @@ void ScNameDlg::OKPushed()
void ScNameDlg::NameSelected()
{
- ScRangeData* pData = mpCurRangeName->findByName(aEdName.GetText());
+ ScRangeData* pData =
mpCurRangeName->findByUpperName(ScGlobal::pCharClass->upper(aEdName.GetText()));
if (pData)
{
String aSymbol;
diff --git sc/source/ui/navipi/content.cxx sc/source/ui/navipi/content.cxx
index 8fc3dca..5b8ee82 100644
--- sc/source/ui/navipi/content.cxx
+++ sc/source/ui/navipi/content.cxx
@@ -1005,7 +1005,7 @@ sal_Bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String&
rName,
ScRangeName* pList = pDoc->GetRangeName();
if (pList)
{
- const ScRangeData* p = pList->findByName(rName);
+ const ScRangeData* p = pList->findByUpperName(ScGlobal::pCharClass->upper(rName));
if (p && p->IsValidReference(rRange))
bFound = true;
}
diff --git sc/source/ui/unoobj/nameuno.cxx sc/source/ui/unoobj/nameuno.cxx
index baae085..aede0ad 100644
--- sc/source/ui/unoobj/nameuno.cxx
+++ sc/source/ui/unoobj/nameuno.cxx
@@ -129,7 +129,7 @@ ScRangeData* ScNamedRangeObj::GetRangeData_Impl()
ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
if (pNames)
{
- pRet = pNames->findByName(aName);
+ pRet = pNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
if (pRet)
pRet->ValidateTabRefs(); // adjust relative tab refs to valid tables
}
@@ -151,7 +151,7 @@ void ScNamedRangeObj::Modify_Impl( const String* pNewName, const ScTokenArray* p
if (!pNames)
return;
- const ScRangeData* pOld = pNames->findByName(aName);
+ const ScRangeData* pOld = pNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
if (!pOld)
return;
@@ -563,7 +563,7 @@ void SAL_CALL ScNamedRangesObj::addNewByName( const rtl::OUString& aName,
{
ScDocument* pDoc = pDocShell->GetDocument();
ScRangeName* pNames = pDoc->GetRangeName();
- if (pNames && !pNames->findByName(aName))
+ if (pNames && !pNames->findByUpperName(ScGlobal::pCharClass->upper(aName)))
{
ScRangeName* pNewRanges = new ScRangeName( *pNames );
// GRAM_PODF_A1 for API compatibility.
@@ -624,7 +624,7 @@ void SAL_CALL ScNamedRangesObj::removeByName( const rtl::OUString& aName )
ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
if (pNames)
{
- const ScRangeData* pData = pNames->findByName(aName);
+ const ScRangeData* pData = pNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
if (pData && lcl_UserVisibleName(*pData))
{
ScRangeName* pNewRanges = new ScRangeName(*pNames);
@@ -786,7 +786,7 @@ sal_Bool SAL_CALL ScNamedRangesObj::hasByName( const rtl::OUString& aName )
ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
if (pNames)
{
- const ScRangeData* pData = pNames->findByName(aName);
+ const ScRangeData* pData = pNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
if (pData && lcl_UserVisibleName(*pData))
return sal_True;
}
diff --git sc/source/ui/vba/vbarange.cxx sc/source/ui/vba/vbarange.cxx
index a5670d7..191f620 100644
--- sc/source/ui/vba/vbarange.cxx
+++ sc/source/ui/vba/vbarange.cxx
@@ -1184,7 +1184,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell*
pDocSh, S
ScRangeName* pRangeName = pDoc->GetRangeName(nCurTab);
if (pRangeName)
{
- bLocalName = pRangeName->findByName(sAddress) != NULL;
+ bLocalName =
pRangeName->findByUpperName(ScGlobal::pCharClass->upper(sAddress)) != NULL;
// TODO: Handle local names correctly.
(void)bLocalName;
}
diff --git sc/source/ui/view/viewfunc.cxx sc/source/ui/view/viewfunc.cxx
index 9a8587c..f0f05b1 100644
--- sc/source/ui/view/viewfunc.cxx
+++ sc/source/ui/view/viewfunc.cxx
@@ -2937,7 +2937,7 @@ sal_Bool ScViewFunc::InsertName( const String& rName, const String& rSymbol,
pDoc->CompileNameFormula( sal_True ); // CreateFormulaString
// Eintrag bereits vorhanden? Dann vorher entfernen (=Aendern)
- ScRangeData* pData = pList->findByName(rName);
+ ScRangeData* pData = pList->findByUpperName(ScGlobal::pCharClass->upper(rName));
if (pData)
{ // alten Index
uebernehmen
pNewEntry->SetIndex(pData->GetIndex());
Context
- [Libreoffice] Advice needed about some 3.4 named range related problem · Noel Power
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.