Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


HI,

You will find the patch with the correct license statement attached.

Regards,
Mat'

On 10/29/2012 07:22 PM, Markus Mohrhard wrote:
Hey Mathieu,

2012/10/26 Mathieu D.<call.protected@gmail.com>:
Hi,

I submitted a patch for the bug 51309 - Names of DatabaseRanges should not
be case sensitive :
https://bugs.freedesktop.org/show_bug.cgi?id=51309

You will the diff file attached and on the bug's page.
https://bugs.freedesktop.org/page.cgi?id=splinter.html&bug=51309&attachment=69115

Changes :

- ScDBData::less::operator() is modified to compare upper strings

- All the calls to NamedDBs::findByName() are now
NamedDBs::findByUpperName().

- In case of a call to findByUpperName by an argument, the function
ScGlobal::pCharClass->uppercase(aName) was used to ensure upper case.

- The definitions of FindByName() are deleted.


The patch looks good. Could you please create the patch with git
commit -a&&  git format-patch HEAD~1 so that it includes you correctly
as author.

And please could you send a licence statement like:

All of my past and future contributions to LibreOffice may be licensed
under the MPL/LGPLv3+
dual license.

to the Mailing so list so that we can keep track of it at
http://wiki.documentfoundation.org/Development/Developers

Thanks a lot for your great contribution. Are there any areas that
interest you? Are you interested in more calc hacking?

Regards,
Markus


--
Mathieu D.

From 34f1ab3baaf4c7cccf96a00a16998828933fcb4c Mon Sep 17 00:00:00 2001
From: Mathieu D. <anarazel@mint>
Date: Tue, 30 Oct 2012 11:58:44 -0400
Subject: [PATCH] Patch for bug 51309, Names of DatabaseRanges should not be case-sensitive. All of 
my past and future contributions to LibreOffice may be licensed
under the MPL/LGPLv3+
dual license..
 case sensitive

---
 sc/inc/dbdata.hxx                      |    1 -
 sc/qa/unit/subsequent_filters-test.cxx |    4 ++--
 sc/source/core/data/cell.cxx           |    4 ++--
 sc/source/core/data/documen3.cxx       |    2 +-
 sc/source/core/tool/dbdata.cxx         |   20 +-------------------
 sc/source/core/tool/rangeutl.cxx       |    2 +-
 sc/source/ui/dbgui/dbnamdlg.cxx        |    4 ++--
 sc/source/ui/docshell/arealink.cxx     |    4 ++--
 sc/source/ui/docshell/dbdocfun.cxx     |   12 ++++++------
 sc/source/ui/docshell/docsh4.cxx       |    2 +-
 sc/source/ui/docshell/docsh5.cxx       |    2 +-
 sc/source/ui/navipi/content.cxx        |    2 +-
 sc/source/ui/undo/undodat.cxx          |    4 ++--
 sc/source/ui/unoobj/datauno.cxx        |    4 ++--
 sc/source/ui/view/dbfunc.cxx           |    2 +-
 15 files changed, 25 insertions(+), 44 deletions(-)

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index d607b4e..5f7133f 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -185,7 +185,6 @@ public:
         const_iterator begin() const;
         const_iterator end() const;
         ScDBData* findByIndex(sal_uInt16 nIndex);
-        ScDBData* findByName(const ::rtl::OUString& rName);
         ScDBData* findByUpperName(const ::rtl::OUString& rName);
         bool insert(ScDBData* p);
         void erase(iterator itr);
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 10db9ae..89e5d0b 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -948,11 +948,11 @@ void ScFiltersTest::testBugFixesODS()
 
     {
         // fdo#40426
-        ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByName("DBRange1");
+        ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByUpperName("DBRANGE1");
         CPPUNIT_ASSERT(pDBData);
         CPPUNIT_ASSERT(pDBData->HasHeader());
         // no header
-        pDBData = pDoc->GetDBCollection()->getNamedDBs().findByName("DBRange2");
+        pDBData = pDoc->GetDBCollection()->getNamedDBs().findByUpperName("DBRANGE2");
         CPPUNIT_ASSERT(pDBData);
         CPPUNIT_ASSERT(!pDBData->HasHeader());
     }
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index e27339e..4c0bd4b 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -203,7 +203,7 @@ void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldD
     ScDBData* pDBData = aOldNamedDBs.findByIndex(pToken->GetIndex());
     if (!pDBData)
         return; //invalid index
-    rtl::OUString aDBName = pDBData->GetName();
+    rtl::OUString aDBName = pDBData->GetUpperName();
 
     //search in new document
     ScDBCollection* pNewDBCollection = rNewDoc.GetDBCollection();
@@ -212,7 +212,7 @@ void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldD
         pNewDBCollection = new ScDBCollection(&rNewDoc);
     }
     ScDBCollection::NamedDBs& aNewNamedDBs = pNewDBCollection->getNamedDBs();
-    ScDBData* pNewDBData = aNewNamedDBs.findByName(aDBName);
+    ScDBData* pNewDBData = aNewNamedDBs.findByUpperName(aDBName);
     if (!pNewDBData)
     {
         pNewDBData = new ScDBData(*pDBData);
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 54ce14f..7ed637c 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -250,7 +250,7 @@ void ScDocument::SetDBCollection( ScDBCollection* pNewDBCollection, bool bRemove
             bool bFound = false;
             if (pNewDBCollection)
             {
-                ScDBData* pNewData = 
pNewDBCollection->getNamedDBs().findByName(rOldData.GetName());
+                ScDBData* pNewData = 
pNewDBCollection->getNamedDBs().findByUpperName(rOldData.GetUpperName());
                 if (pNewData)
                 {
                     if (pNewData->HasAutoFilter())
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 7b142cc..3290f18 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -53,7 +53,7 @@ using ::std::pair;
 
 bool ScDBData::less::operator() (const ScDBData& left, const ScDBData& right) const
 {
-    return ScGlobal::GetpTransliteration()->compareString(left.GetName(), right.GetName()) < 0;
+    return ScGlobal::GetpTransliteration()->compareString(left.GetUpperName(), 
right.GetUpperName()) < 0;
 }
 
 ScDBData::ScDBData( const ::rtl::OUString& rName,
@@ -643,17 +643,6 @@ public:
     }
 };
 
-class FindByName : public unary_function<ScDBData, bool>
-{
-    const ::rtl::OUString& mrName;
-public:
-    FindByName(const ::rtl::OUString& rName) : mrName(rName) {}
-    bool operator() (const ScDBData& r) const
-    {
-        return r.GetName() == mrName;
-    }
-};
-
 class FindByUpperName : public unary_function<ScDBData, bool>
 {
     const ::rtl::OUString& mrName;
@@ -700,13 +689,6 @@ ScDBData* ScDBCollection::NamedDBs::findByIndex(sal_uInt16 nIndex)
     return itr == maDBs.end() ? NULL : &(*itr);
 }
 
-ScDBData* ScDBCollection::NamedDBs::findByName(const ::rtl::OUString& rName)
-{
-    DBsType::iterator itr = find_if(
-        maDBs.begin(), maDBs.end(), FindByName(rName));
-    return itr == maDBs.end() ? NULL : &(*itr);
-}
-
 ScDBData* ScDBCollection::NamedDBs::findByUpperName(const ::rtl::OUString& rName)
 {
     DBsType::iterator itr = find_if(
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index 1001410..5b5c814 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -335,7 +335,7 @@ sal_Bool ScRangeUtil::MakeRangeFromName (
     else if( eScope==RUTL_DBASE )
     {
         ScDBCollection::NamedDBs& rDbNames = pDoc->GetDBCollection()->getNamedDBs();
-        ScDBData* pData = rDbNames.findByName(rName);
+        ScDBData* pData = rDbNames.findByUpperName(ScGlobal::pCharClass->uppercase(rName));
         if (pData)
         {
             pData->GetArea(nTab, nColStart, nRowStart, nColEnd, nRowEnd);
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
index d380c59..ed8d981 100644
--- a/sc/source/ui/dbgui/dbnamdlg.cxx
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -380,7 +380,7 @@ void ScDbNameDlg::UpdateNames()
 void ScDbNameDlg::UpdateDBData( const String& rStrName )
 {
 
-    const ScDBData* pData = aLocalDbCol.getNamedDBs().findByName(rStrName);
+    const ScDBData* pData = 
aLocalDbCol.getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rStrName));
 
     if ( pData )
     {
@@ -471,7 +471,7 @@ IMPL_LINK_NOARG(ScDbNameDlg, AddBtnHdl)
                 ScAddress aStart = theCurArea.aStart;
                 ScAddress aEnd   = theCurArea.aEnd;
 
-                ScDBData* pOldEntry = aLocalDbCol.getNamedDBs().findByName(aNewName);
+                ScDBData* pOldEntry = 
aLocalDbCol.getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(aNewName));
                 if (pOldEntry)
                 {
                     //  Bereich veraendern
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index 2c08572..2c11441 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -205,7 +205,7 @@ bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const Strin
     ScRangeName* pNames = pSrcDoc->GetRangeName();
     if (pNames)         // benannte Bereiche
     {
-        const ScRangeData* p = pNames->findByUpperName(ScGlobal::pCharClass->uppercase(rAreaName));
+        const ScRangeData* p = pNames->findByUpperName(rAreaName);
         if (p && p->IsValidReference(rRange))
             bFound = true;
     }
@@ -214,7 +214,7 @@ bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const Strin
         ScDBCollection* pDBColl = pSrcDoc->GetDBCollection();
         if (pDBColl)
         {
-            const ScDBData* pDB = pDBColl->getNamedDBs().findByName(rAreaName);
+            const ScDBData* pDB = 
pDBColl->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rAreaName));
             if (pDB)
             {
                 SCTAB nTab;
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 07049a0..7e9115f 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -127,7 +127,7 @@ bool ScDBDocFunc::DeleteDBRange(const ::rtl::OUString& rName)
     bool bUndo = pDoc->IsUndoEnabled();
 
     ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs();
-    const ScDBData* p = rDBs.findByName(rName);
+    const ScDBData* p = rDBs.findByUpperName(ScGlobal::pCharClass->uppercase(rName));
     if (p)
     {
         ScDocShellModificator aModificator( rDocShell );
@@ -162,8 +162,8 @@ bool ScDBDocFunc::RenameDBRange( const String& rOld, const String& rNew )
     ScDBCollection* pDocColl = pDoc->GetDBCollection();
     bool bUndo = pDoc->IsUndoEnabled();
     ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs();
-    const ScDBData* pOld = rDBs.findByName(rOld);
-    const ScDBData* pNew = rDBs.findByName(rNew);
+    const ScDBData* pOld = rDBs.findByUpperName(ScGlobal::pCharClass->uppercase(rOld));
+    const ScDBData* pNew = rDBs.findByUpperName(ScGlobal::pCharClass->uppercase(rNew));
     if (pOld && !pNew)
     {
         ScDocShellModificator aModificator( rDocShell );
@@ -216,7 +216,7 @@ bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData )
         pData = pDoc->GetAnonymousDBData(nTab);
     }
     else
-        pData = pDocColl->getNamedDBs().findByName(rNewData.GetName());
+        pData = pDocColl->getNamedDBs().findByUpperName(rNewData.GetUpperName());
 
     if (pData)
     {
@@ -267,7 +267,7 @@ bool ScDBDocFunc::RepeatDB( const ::rtl::OUString& rDBName, bool bRecord, bool b
     {
         ScDBCollection* pColl = pDoc->GetDBCollection();
         if (pColl)
-            pDBData = pColl->getNamedDBs().findByName(rDBName);
+            pDBData = 
pColl->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rDBName));
     }
 
     if ( pDBData )
@@ -1525,7 +1525,7 @@ void ScDBDocFunc::UpdateImport( const String& rTarget, const 
svx::ODataAccessDes
 
     ScDocument* pDoc = rDocShell.GetDocument();
     ScDBCollection& rDBColl = *pDoc->GetDBCollection();
-    const ScDBData* pData = rDBColl.getNamedDBs().findByName(rTarget);
+    const ScDBData* pData = 
rDBColl.getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rTarget));
     if (!pData)
     {
         InfoBox aInfoBox(rDocShell.GetActiveDialogParent(),
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index babda0d..f55a204 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -207,7 +207,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
                 if (bIsNewArea)
                 {
                     ScDBCollection* pDBColl = aDocument.GetDBCollection();
-                    if ( !pDBColl || !pDBColl->getNamedDBs().findByName(sTarget) )
+                    if ( !pDBColl || 
!pDBColl->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(sTarget)) )
                     {
                         ScAddress aPos;
                         if ( aPos.Parse( sTarget, &aDocument, aDocument.GetAddressConvention() ) & 
SCA_VALID )
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 5beb522..63ade6d 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -276,7 +276,7 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe
                     ++nCount;
                     aNewName = aImport;
                     aNewName += String::CreateFromInt32( nCount );
-                    pDummy = rDBs.findByName(aNewName);
+                    pDummy = rDBs.findByUpperName(ScGlobal::pCharClass->uppercase(aNewName));
                 }
                 while (pDummy);
                 pNoNameData = new ScDBData( aNewName, nTab,
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 14a2d47..ab42837 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -264,7 +264,7 @@ static String lcl_GetDBAreaRange( ScDocument* pDoc, const String& rDBName )
     if (pDoc)
     {
         ScDBCollection* pDbNames = pDoc->GetDBCollection();
-        const ScDBData* pData = pDbNames->getNamedDBs().findByName(rDBName);
+        const ScDBData* pData = 
pDbNames->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rDBName));
         if (pData)
         {
             ScRange aRange;
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 62e10b8..199617c 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -1068,7 +1068,7 @@ void ScUndoAutoFilter::DoChange( bool bUndo )
     else
     {
         ScDBCollection* pColl = pDoc->GetDBCollection();
-        pDBData = pColl->getNamedDBs().findByName(aDBName);
+        pDBData = pColl->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(aDBName));
     }
 
     if ( pDBData )
@@ -1812,7 +1812,7 @@ void ScUndoConsolidate::Undo()
         ScDBCollection* pColl = pDoc->GetDBCollection();
         if (pColl)
         {
-            ScDBData* pDocData = pColl->getNamedDBs().findByName(pUndoData->GetName());
+            ScDBData* pDocData = pColl->getNamedDBs().findByUpperName(pUndoData->GetUpperName());
             if (pDocData)
                 *pDocData = *pUndoData;
         }
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index cbff0b4..d902c97 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -1734,7 +1734,7 @@ ScDBData* ScDatabaseRangeObj::GetDBData_Impl() const
             ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
             if (pNames)
             {
-                ScDBData* p = pNames->getNamedDBs().findByName(aName);
+                ScDBData* p = 
pNames->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(aName));
                 if (p)
                     pRet = p;
             }
@@ -2441,7 +2441,7 @@ sal_Bool SAL_CALL ScDatabaseRangesObj::hasByName( const rtl::OUString& aName )
     {
         ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
         if (pNames)
-            return pNames->getNamedDBs().findByName(aName) != NULL;
+            return pNames->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(aName)) 
!= NULL;
     }
     return false;
 }
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index 0416b42..ad4d102 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -65,7 +65,7 @@ void ScDBFunc::GotoDBArea( const ::rtl::OUString& rDBName )
 {
     ScDocument* pDoc = GetViewData()->GetDocument();
     ScDBCollection* pDBCol = pDoc->GetDBCollection();
-    ScDBData* pData = pDBCol->getNamedDBs().findByName(rDBName);
+    ScDBData* pData = 
pDBCol->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rDBName));
     if (pData)
     {
         SCTAB nTab = 0;
-- 
1.7.10.4


Context


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.