[Libreoffice-commits] .: 2 commits - sc/inc sc/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Thu Nov 24 09:38:37 PST 2011


 sc/inc/rangenam.hxx                      |    2 
 sc/source/core/data/documen2.cxx         |    6 +-
 sc/source/core/data/documen3.cxx         |    2 
 sc/source/core/data/document.cxx         |   18 +++----
 sc/source/core/tool/rangenam.cxx         |   49 ++++++++-------------
 sc/source/core/tool/rangeutl.cxx         |    2 
 sc/source/filter/excel/xename.cxx        |    8 +--
 sc/source/filter/xml/xmlexprt.cxx        |   10 ++--
 sc/source/ui/app/inputwin.cxx            |    8 +--
 sc/source/ui/dbgui/sfiltdlg.cxx          |    6 +-
 sc/source/ui/docshell/docfunc.cxx        |   10 ++--
 sc/source/ui/docshell/externalrefmgr.cxx |    2 
 sc/source/ui/inc/namemgrtable.hxx        |    2 
 sc/source/ui/namedlg/namemgrtable.cxx    |   70 +++++++++++++++++++++++++++++--
 sc/source/ui/navipi/content.cxx          |    8 +--
 sc/source/ui/pagedlg/areasdlg.cxx        |   12 ++---
 sc/source/ui/unoobj/nameuno.cxx          |   14 +++---
 sc/source/ui/vba/vbarange.cxx            |    4 -
 sc/source/ui/view/cellsh1.cxx            |    2 
 19 files changed, 145 insertions(+), 90 deletions(-)

New commits:
commit f47455e3cfde26f8acd6419be563c027c4755624
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Nov 24 07:48:41 2011 +0100

    change ScRangeName's container to boost::ptr_map

diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 608680e..4b4f8d9 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -183,7 +183,7 @@ class ScRangeName
 {
 private:
     typedef std::vector<ScRangeData*> IndexDataType;
-    typedef ::boost::ptr_set<ScRangeData> DataType;
+    typedef ::boost::ptr_map<rtl::OUString, ScRangeData> DataType;
     DataType maData;
     IndexDataType maIndexToData;
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 94754e7..ae68670 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -992,11 +992,11 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
                 ScRangeName::const_iterator itr = pSrcDoc->pRangeName->begin(), itrEnd = pSrcDoc->pRangeName->end();
                 for (; itr != itrEnd; ++itr)        //! DB-Bereiche Pivot-Bereiche auch !!!
                 {
-                    sal_uInt16 nOldIndex = itr->GetIndex();
+                    sal_uInt16 nOldIndex = itr->second->GetIndex();
                     bool bInUse = ( aUsedNames.find(nOldIndex) != aUsedNames.end() );
                     if (bInUse)
                     {
-                        const ScRangeData* pExistingData = GetRangeName()->findByUpperName(itr->GetUpperName());
+                        const ScRangeData* pExistingData = GetRangeName()->findByUpperName(itr->second->GetUpperName());
                         if (pExistingData)
                         {
                             // the name exists already in the destination document
@@ -1013,7 +1013,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
                         }
                         else
                         {
-                            ScRangeData* pData = new ScRangeData( *itr );
+                            ScRangeData* pData = new ScRangeData( *itr->second );
                             pData->SetDocument(this);
                             if ( pRangeName->findByIndex( pData->GetIndex() ) )
                                 pData->SetIndex(0);     // need new index, done in Insert
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index d225f11..49456a1 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1541,7 +1541,7 @@ bool ScDocument::GetFormulaEntries( TypedScStrCollection& rStrings )
         ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
         for (; itr != itrEnd; ++itr)
         {
-            TypedStrData* pNew = new TypedStrData(itr->GetName(), 0.0, SC_STRTYPE_NAMES);
+            TypedStrData* pNew = new TypedStrData(itr->second->GetName(), 0.0, SC_STRTYPE_NAMES);
             if (!rStrings.Insert(pNew))
                 delete pNew;
         }
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 8f277c6..28b2380 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1986,8 +1986,8 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, sal_uInt16 nFlags, bool
         ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
         for (; itr != itrEnd; ++itr)
         {
-            sal_uInt16 nIndex = itr->GetIndex();
-            ScRangeData* pData = new ScRangeData(*itr);
+            sal_uInt16 nIndex = itr->second->GetIndex();
+            ScRangeData* pData = new ScRangeData(*itr->second);
             if (pTransClip->pRangeName->insert(pData))
                 pData->SetIndex(nIndex);
         }
@@ -2045,12 +2045,12 @@ void copyUsedNamesToClip(ScRangeName* pClipRangeName, ScRangeName* pRangeName, c
     ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
     for (; itr != itrEnd; ++itr)        //! DB-Bereiche Pivot-Bereiche auch !!!
     {
-        sal_uInt16 nIndex = itr->GetIndex();
+        sal_uInt16 nIndex = itr->second->GetIndex();
         bool bInUse = (rUsedNames.count(nIndex) > 0);
         if (!bInUse)
             continue;
 
-        ScRangeData* pData = new ScRangeData(*itr);
+        ScRangeData* pData = new ScRangeData(*itr->second);
         if (pClipRangeName->insert(pData))
             pData->SetIndex(nIndex);
     }
@@ -2134,10 +2134,10 @@ 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()->findByUpperName(itr->GetUpperName());
+        const ScRangeData* pExistingData = GetRangeName()->findByUpperName(itr->first);
         if (pExistingData)
         {
-            sal_uInt16 nOldIndex = itr->GetIndex();
+            sal_uInt16 nOldIndex = itr->second->GetIndex();
             sal_uInt16 nNewIndex = pExistingData->GetIndex();
             aClipRangeNames.insert(nOldIndex, nNewIndex);
             if ( !aClipRangeNames.mbReplace )
@@ -2145,14 +2145,14 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
         }
         else
         {
-            ScRangeData* pData = new ScRangeData( *itr );
+            ScRangeData* pData = new ScRangeData( *itr->second );
             pData->SetDocument(this);
             if ( pRangeName->findByIndex( pData->GetIndex() ) )
                 pData->SetIndex(0);     // need new index, done in Insert
             if ( pRangeName->insert(pData) )
             {
                 aClipRangeNames.mpRangeNames.push_back(pData);
-                sal_uInt16 nOldIndex = itr->GetIndex();
+                sal_uInt16 nOldIndex = itr->second->GetIndex();
                 sal_uInt16 nNewIndex = pData->GetIndex();
                 aClipRangeNames.insert(nOldIndex, nNewIndex);
                 if ( !aClipRangeNames.mbReplace )
@@ -2161,7 +2161,7 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
             else
             {   // must be an overflow
                 pData = NULL;
-                aClipRangeNames.insert(itr->GetIndex(), 0);
+                aClipRangeNames.insert(itr->second->GetIndex(), 0);
                 aClipRangeNames.mbReplace = true;
             }
         }
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index a6398f8..e661eea 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -729,20 +729,10 @@ class MatchByRange : public unary_function<ScRangeData, bool>
     const ScRange& mrRange;
 public:
     MatchByRange(const ScRange& rRange) : mrRange(rRange) {}
-    bool operator() (const ScRangeData& r) const
+    template < typename Pair >
+    bool operator() ( Pair const& r) const
     {
-        return r.IsRangeAtBlock(mrRange);
-    }
-};
-
-class MatchByUpperName : public unary_function<ScRangeData, bool>
-{
-    const OUString& mrName;
-public:
-    MatchByUpperName(const OUString& rName) : mrName(rName) {}
-    bool operator() (const ScRangeData& r) const
-    {
-        return mrName.equals(r.GetUpperName());
+        return r.second->IsRangeAtBlock(mrRange);
     }
 };
 
@@ -770,13 +760,13 @@ ScRangeName::ScRangeName(const ScRangeName& r) :
     DataType::const_iterator itr = maData.begin(), itrEnd = maData.end();
     for (; itr != itrEnd; ++itr)
     {
-        size_t nPos = itr->GetIndex() - 1;
+        size_t nPos = itr->second->GetIndex() - 1;
         if (nPos >= maIndexToData.size())
         {
             OSL_FAIL( "ScRangeName copy-ctor: maIndexToData size doesn't fit");
             maIndexToData.resize(nPos+1, NULL);
         }
-        maIndexToData[nPos] = const_cast<ScRangeData*>(&(*itr));
+        maIndexToData[nPos] = const_cast<ScRangeData*>(itr->second);
     }
 }
 
@@ -784,21 +774,19 @@ const ScRangeData* ScRangeName::findByRange(const ScRange& rRange) const
 {
     DataType::const_iterator itr = std::find_if(
         maData.begin(), maData.end(), MatchByRange(rRange));
-    return itr == maData.end() ? NULL : &(*itr);
+    return itr == maData.end() ? NULL : itr->second;
 }
 
 ScRangeData* ScRangeName::findByUpperName(const OUString& rName)
 {
-    DataType::iterator itr = std::find_if(
-        maData.begin(), maData.end(), MatchByUpperName(rName));
-    return itr == maData.end() ? NULL : &(*itr);
+    DataType::iterator itr = maData.find(rName);
+    return itr == maData.end() ? NULL : itr->second;
 }
 
 const ScRangeData* ScRangeName::findByUpperName(const OUString& rName) const
 {
-    DataType::const_iterator itr = std::find_if(
-        maData.begin(), maData.end(), MatchByUpperName(rName));
-    return itr == maData.end() ? NULL : &(*itr);
+    DataType::const_iterator itr = maData.find(rName);
+    return itr == maData.end() ? NULL : itr->second;
 }
 
 ScRangeData* ScRangeName::findByIndex(sal_uInt16 i)
@@ -816,35 +804,35 @@ void ScRangeName::UpdateReference(
 {
     DataType::iterator itr = maData.begin(), itrEnd = maData.end();
     for (; itr != itrEnd; ++itr)
-        itr->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz);
+        itr->second->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz);
 }
 
 void ScRangeName::UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable, SCTAB nNewSheets)
 {
     DataType::iterator itr = maData.begin(), itrEnd = maData.end();
     for (; itr != itrEnd; ++itr)
-        itr->UpdateTabRef(nTable, nFlag, nNewTable, nNewSheets);
+        itr->second->UpdateTabRef(nTable, nFlag, nNewTable, nNewSheets);
 }
 
 void ScRangeName::UpdateTranspose(const ScRange& rSource, const ScAddress& rDest)
 {
     DataType::iterator itr = maData.begin(), itrEnd = maData.end();
     for (; itr != itrEnd; ++itr)
-        itr->UpdateTranspose(rSource, rDest);
+        itr->second->UpdateTranspose(rSource, rDest);
 }
 
 void ScRangeName::UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY)
 {
     DataType::iterator itr = maData.begin(), itrEnd = maData.end();
     for (; itr != itrEnd; ++itr)
-        itr->UpdateGrow(rArea, nGrowX, nGrowY);
+        itr->second->UpdateGrow(rArea, nGrowX, nGrowY);
 }
 
 void ScRangeName::CompileUnresolvedXML()
 {
     DataType::iterator itr = maData.begin(), itrEnd = maData.end();
     for (; itr != itrEnd; ++itr)
-        itr->CompileUnresolvedXML();
+        itr->second->CompileUnresolvedXML();
 }
 
 ScRangeName::const_iterator ScRangeName::begin() const
@@ -898,7 +886,8 @@ bool ScRangeName::insert(ScRangeData* p)
             p->SetIndex(maIndexToData.size() + 1);
     }
 
-    pair<DataType::iterator, bool> r = maData.insert(p);
+    rtl::OUString aName(p->GetUpperName());
+    pair<DataType::iterator, bool> r = maData.insert(aName, p);
     if (r.second)
     {
         // Data inserted.  Store its index for mapping.
@@ -912,14 +901,14 @@ bool ScRangeName::insert(ScRangeData* p)
 
 void ScRangeName::erase(const ScRangeData& r)
 {
-    DataType::iterator itr = maData.find(r);
+    DataType::iterator itr = maData.find(r.GetUpperName());
     if (itr != maData.end())
         erase(itr);
 }
 
 void ScRangeName::erase(const iterator& itr)
 {
-    sal_uInt16 nIndex = itr->GetIndex();
+    sal_uInt16 nIndex = itr->second->GetIndex();
     maData.erase(itr);
     OSL_ENSURE( 0 < nIndex && nIndex <= maIndexToData.size(), "ScRangeName::erase: bad index");
     if (0 < nIndex && nIndex <= maIndexToData.size())
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index ab9ebcf..88bdbb4 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -1112,7 +1112,7 @@ bool ScAreaNameIterator::Next( String& rName, ScRange& rRange )
         {
             if ( pRangeName && maRNPos != maRNEnd )
             {
-                const ScRangeData& rData = *maRNPos;
+                const ScRangeData& rData = *maRNPos->second;
                 ++maRNPos;
                 bool bValid = rData.IsValidReference(rRange);
                 if (bValid)
diff --git a/sc/source/filter/excel/xename.cxx b/sc/source/filter/excel/xename.cxx
index 18e38cb..77e4f32 100644
--- a/sc/source/filter/excel/xename.cxx
+++ b/sc/source/filter/excel/xename.cxx
@@ -674,8 +674,8 @@ void XclExpNameManagerImpl::CreateUserNames()
     for (; itr != itrEnd; ++itr)
     {
         // skip definitions of shared formulas
-        if (!itr->HasType(RT_SHARED) && !FindNamedExpIndex(SCTAB_GLOBAL, itr->GetIndex()))
-            CreateName(SCTAB_GLOBAL, *itr);
+        if (!itr->second->HasType(RT_SHARED) && !FindNamedExpIndex(SCTAB_GLOBAL, itr->second->GetIndex()))
+            CreateName(SCTAB_GLOBAL, *itr->second);
     }
     //look at every sheet for local range names
     ScRangeName::TabNameCopyMap rLocalNames;
@@ -687,8 +687,8 @@ void XclExpNameManagerImpl::CreateUserNames()
         for (; itr != itrEnd; ++itr)
         {
             // skip definitions of shared formulas
-            if (!itr->HasType(RT_SHARED) && !FindNamedExpIndex(tabIt->first, itr->GetIndex()))
-                CreateName(tabIt->first, *itr);
+            if (!itr->second->HasType(RT_SHARED) && !FindNamedExpIndex(tabIt->first, itr->second->GetIndex()))
+                CreateName(tabIt->first, *itr->second);
         }
     }
 }
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 378f1bf..0ff9466 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3758,24 +3758,24 @@ void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
     SvXMLElementExport aElemNEs(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, true, true);
     for (ScRangeName::iterator it = pRangeName->begin(); it != pRangeName->end(); ++it)
     {
-        AddAttribute(sAttrName, it->GetName());
+        AddAttribute(sAttrName, it->second->GetName());
 
         rtl::OUString sBaseCellAddress;
-        ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, it->GetPos(), pDoc,
+        ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, it->second->GetPos(), pDoc,
                             FormulaGrammar::CONV_OOO, ' ', false, SCA_ABS_3D);
         AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, sBaseCellAddress);
 
         String sSymbol;
-        it->GetSymbol(sSymbol, pDoc->GetStorageGrammar());
+        it->second->GetSymbol(sSymbol, pDoc->GetStorageGrammar());
         rtl::OUString sTempSymbol(sSymbol);
         ScRange aRange;
-        if (it->IsReference(aRange))
+        if (it->second->IsReference(aRange))
         {
 
             rtl::OUString sContent(sTempSymbol.copy(1, sTempSymbol.getLength() -2 ));
             AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sContent);
 
-            sal_Int32 nRangeType = it->GetUnoType();
+            sal_Int32 nRangeType = it->second->GetUnoType();
             rtl::OUStringBuffer sBufferRangeType;
             if ((nRangeType & sheet::NamedRangeFlag::COLUMN_HEADER) == sheet::NamedRangeFlag::COLUMN_HEADER)
                 sBufferRangeType.append(GetXMLToken(XML_REPEAT_COLUMN));
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index c379199..427c2d9 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -2056,8 +2056,8 @@ void ScPosWnd::FillRangeNames()
             ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
             for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
             {
-                if (itr->IsValidReference(aDummy))
-                    aSet.insert(itr->GetName());
+                if (itr->second->IsValidReference(aDummy))
+                    aSet.insert(itr->second->GetName());
             }
         }
         for (SCTAB i = 0; i < pDoc->GetTableCount(); ++i)
@@ -2069,8 +2069,8 @@ void ScPosWnd::FillRangeNames()
                 pDoc->GetName(i, aTableName);
                 for (ScRangeName::const_iterator itr = pLocalRangeName->begin(); itr != pLocalRangeName->end(); ++itr)
                 {
-                    if (itr->IsValidReference(aDummy))
-                        aSet.insert(createLocalRangeName(itr->GetName(), aTableName));
+                    if (itr->second->IsValidReference(aDummy))
+                        aSet.insert(createLocalRangeName(itr->second->GetName(), aTableName));
                 }
             }
         }
diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx
index 37d05b6..14b0372 100644
--- a/sc/source/ui/dbgui/sfiltdlg.cxx
+++ b/sc/source/ui/dbgui/sfiltdlg.cxx
@@ -176,12 +176,12 @@ void ScSpecialFilterDlg::Init( const SfxItemSet& rArgSet )
             sal_uInt16 nInsert = 0;
             for (; itr != itrEnd; ++itr)
             {
-                if (!itr->HasType(RT_CRITERIA))
+                if (!itr->second->HasType(RT_CRITERIA))
                     continue;
 
-                nInsert = aLbFilterArea.InsertEntry(itr->GetName());
+                nInsert = aLbFilterArea.InsertEntry(itr->second->GetName());
                 rtl::OUString aSymbol;
-                itr->GetSymbol(aSymbol);
+                itr->second->GetSymbol(aSymbol);
                 aLbFilterArea.SetEntryData(nInsert, new String(aSymbol));
             }
         }
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 0d8a406..a915eb9 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4729,7 +4729,7 @@ sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi )
     ScRangeName::iterator itrLocalBeg = pLocalList->begin(), itrLocalEnd = pLocalList->end();
     for (ScRangeName::iterator itr = itrLocalBeg; itr != itrLocalEnd; ++itr)
     {
-        const ScRangeData& r = *itr;
+        const ScRangeData& r = *itr->second;
         if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED))
             ++nValidCount;
     }
@@ -4737,7 +4737,7 @@ sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi )
     ScRangeName::iterator itrBeg = pList->begin(), itrEnd = pList->end();
     for (ScRangeName::iterator itr = itrBeg; itr != itrEnd; ++itr)
     {
-        const ScRangeData& r = *itr;
+        const ScRangeData& r = *itr->second;
         if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByUpperName(r.GetUpperName()))
             ++nValidCount;
     }
@@ -4766,14 +4766,14 @@ sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi )
             sal_uInt16 j = 0;
             for (ScRangeName::iterator itr = itrLocalBeg; itr != itrLocalEnd; ++itr)
             {
-                ScRangeData& r = *itr;
+                ScRangeData& r = *itr->second;
                 if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED))
                     ppSortArray[j++] = &r;
             }
             for (ScRangeName::iterator itr = itrBeg; itr != itrEnd; ++itr)
             {
-                ScRangeData& r = *itr;
-                if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByUpperName(r.GetUpperName()))
+                ScRangeData& r = *itr->second;
+                if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByUpperName(itr->first))
                     ppSortArray[j++] = &r;
             }
 #ifndef ICC
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index fe43efa..b3c1682 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -247,7 +247,7 @@ void removeRangeNamesBySrcDoc(ScRangeName& rRanges, sal_uInt16 nFileId)
     vector<ScRangeName::iterator> v;
     for (; itr != itrEnd; ++itr)
     {
-        if (hasRefsToSrcDoc(*itr, nFileId))
+        if (hasRefsToSrcDoc(*itr->second, nFileId))
             v.push_back(itr);
     }
     for_each(v.begin(), v.end(), EraseRangeByIterator(rRanges));
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index 28adc44..f2b03b1 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -131,10 +131,10 @@ void ScRangeManagerTable::Init(const boost::ptr_map<rtl::OUString, ScRangeName>&
         for (ScRangeName::const_iterator it = pLocalRangeName->begin();
                 it != pLocalRangeName->end(); ++it)
         {
-            if (!it->HasType(RT_DATABASE) && !it->HasType(RT_SHARED))
+            if (!it->second->HasType(RT_DATABASE) && !it->second->HasType(RT_SHARED))
             {
-                aLine.aName = it->GetName();
-                it->GetSymbol(aLine.aExpression);
+                aLine.aName = it->second->GetName();
+                it->second->GetSymbol(aLine.aExpression);
                 addEntry(aLine);
             }
         }
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 0090402..cb3b68c 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -683,8 +683,8 @@ void ScContentTree::GetAreaNames()
         ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
         for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
         {
-            if (itr->IsValidReference(aDummy))
-                aSet.insert(itr->GetName());
+            if (itr->second->IsValidReference(aDummy))
+                aSet.insert(itr->second->GetName());
         }
     }
     for (SCTAB i = 0; i < pDoc->GetTableCount(); ++i)
@@ -696,8 +696,8 @@ void ScContentTree::GetAreaNames()
             pDoc->GetName(i, aTableName);
             for (ScRangeName::const_iterator itr = pLocalRangeName->begin(); itr != pLocalRangeName->end(); ++itr)
             {
-                if (itr->IsValidReference(aDummy))
-                    aSet.insert(createLocalRangeName(itr->GetName(), aTableName));
+                if (itr->second->IsValidReference(aDummy))
+                    aSet.insert(createLocalRangeName(itr->second->GetName(), aTableName));
             }
         }
     }
diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx
index b239d52..6968699 100644
--- a/sc/source/ui/pagedlg/areasdlg.cxx
+++ b/sc/source/ui/pagedlg/areasdlg.cxx
@@ -484,15 +484,15 @@ void ScPrintAreasDlg::Impl_FillLists()
     ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
     for (; itr != itrEnd; ++itr)
     {
-        if (!itr->HasType(RT_ABSAREA) && !itr->HasType(RT_REFAREA) && !itr->HasType(RT_ABSPOS))
+        if (!itr->second->HasType(RT_ABSAREA) && !itr->second->HasType(RT_REFAREA) && !itr->second->HasType(RT_ABSPOS))
             continue;
 
-        OUString aName = itr->GetName();
+        OUString aName = itr->second->GetName();
         OUString aSymbol;
-        itr->GetSymbol(aSymbol);
+        itr->second->GetSymbol(aSymbol);
         if (aRange.ParseAny(aSymbol, pDoc, eConv) & SCA_VALID)
         {
-            if (itr->HasType(RT_PRINTAREA))
+            if (itr->second->HasType(RT_PRINTAREA))
             {
                 aRange.Format(aSymbol, SCR_ABS, pDoc, eConv);
                 aLbPrintArea.SetEntryData(
@@ -500,7 +500,7 @@ void ScPrintAreasDlg::Impl_FillLists()
                     new String(aSymbol) );
             }
 
-            if (itr->HasType(RT_ROWHEADER))
+            if (itr->second->HasType(RT_ROWHEADER))
             {
                 lcl_GetRepeatRangeString(&aRange, pDoc, true, aSymbol);
                 aLbRepeatRow.SetEntryData(
@@ -508,7 +508,7 @@ void ScPrintAreasDlg::Impl_FillLists()
                     new String(aSymbol) );
             }
 
-            if (itr->HasType(RT_COLHEADER))
+            if (itr->second->HasType(RT_COLHEADER))
             {
                 lcl_GetRepeatRangeString(&aRange, pDoc, false, aSymbol);
                 aLbRepeatCol.SetEntryData(
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index 3210c81..7de71d1 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -667,7 +667,7 @@ sal_Int32 SAL_CALL ScNamedRangesObj::getCount() throw(uno::RuntimeException)
         {
             ScRangeName::const_iterator itr = pNames->begin(), itrEnd = pNames->end();
             for (; itr != itrEnd; ++itr)
-                if (lcl_UserVisibleName(*itr))
+                if (lcl_UserVisibleName(*itr->second))
                     ++nRet;
         }
     }
@@ -761,8 +761,8 @@ uno::Sequence<rtl::OUString> SAL_CALL ScNamedRangesObj::getElementNames()
             ScRangeName::const_iterator itr = pNames->begin(), itrEnd = pNames->end();
             for (; itr != itrEnd; ++itr)
             {
-                if (lcl_UserVisibleName(*itr))
-                    pAry[nVisPos++] = itr->GetName();
+                if (lcl_UserVisibleName(*itr->second))
+                    pAry[nVisPos++] = itr->second->GetName();
             }
             return aSeq;
         }
@@ -894,10 +894,10 @@ ScNamedRangeObj* ScGlobalNamedRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex
     sal_uInt16 nPos = 0;
     for (; itr != itrEnd; ++itr)
     {
-        if (lcl_UserVisibleName(*itr))
+        if (lcl_UserVisibleName(*itr->second))
         {
             if (nPos == nIndex)
-                return new ScNamedRangeObj(this, pDocShell, itr->GetName());
+                return new ScNamedRangeObj(this, pDocShell, itr->second->GetName());
         }
         ++nPos;
     }
@@ -961,10 +961,10 @@ ScNamedRangeObj* ScLocalNamedRangesObj::GetObjectByIndex_Impl( sal_uInt16 nIndex
     sal_uInt16 nPos = 0;
     for (; itr != itrEnd; ++itr)
     {
-        if (lcl_UserVisibleName(*itr))
+        if (lcl_UserVisibleName(*itr->second))
         {
             if (nPos == nIndex)
-                return new ScNamedRangeObj(this, pDocShell, itr->GetName(), mxSheet);
+                return new ScNamedRangeObj(this, pDocShell, itr->second->GetName(), mxSheet);
         }
         ++nPos;
     }
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index f84f5b4..f969b8f 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -6125,9 +6125,9 @@ uno::Any SAL_CALL ScVbaRange::AdvancedFilter( sal_Int32 Action, const uno::Any&
             ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
             for (; itr != itrEnd; ++itr)
             {
-                if (itr->HasType(RT_CRITERIA))
+                if (itr->second->HasType(RT_CRITERIA))
                 {
-                    itr->GetSymbol( aBuiltInCriteria, formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );
+                    itr->second->GetSymbol( aBuiltInCriteria, formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );
                     break;
                 }
             }
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index fd86dbe..03738a9 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2218,7 +2218,7 @@ void ScCellShell::ExecuteDataPilotDialog()
         {
             ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
             for (; itr != itrEnd; ++itr)
-                pTypeDlg->AppendNamedRange(itr->GetName());
+                pTypeDlg->AppendNamedRange(itr->second->GetName());
         }
 
         OSL_ENSURE(pTypeDlg, "Dialog create fail!");
commit f2931c64d804bf63970bdb9fedf5e57f79a7a3a7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Nov 24 17:59:28 2011 +0100

    ManageNames: moving the header separator now updates the table too

diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx
index 2795a7e..b95002e 100644
--- a/sc/source/ui/inc/namemgrtable.hxx
+++ b/sc/source/ui/inc/namemgrtable.hxx
@@ -77,6 +77,8 @@ public:
     void GetCurrentLine(ScRangeNameLine& rLine);
     bool IsMultiSelection();
     std::vector<ScRangeNameLine> GetSelectedEntries();
+
+    DECL_LINK( HeaderEndDragHdl, void*);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index ad9ca9a..28adc44 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -44,6 +44,7 @@
 #define ITEMID_RANGE 2
 #define ITEMID_SCOPE 3
 
+#define MINSIZE 50
 
 
 String createEntryString(const ScRangeNameLine& rLine)
@@ -81,6 +82,8 @@ ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_map<rtl::O
     SetPosSizePixel( Point( 0, aHeadSize.Height() ), Size( aBoxSize.Width(), aBoxSize.Height() - aHeadSize.Height() ) );
     SetTabs( &nTabs[0], MAP_PIXEL );
 
+    maHeaderBar.SetEndDragHdl( LINK( this, ScRangeManagerTable, HeaderEndDragHdl ) );
+
     Show();
     maHeaderBar.Show();
     SetSelectionMode(MULTIPLE_SELECTION);
@@ -168,5 +171,66 @@ std::vector<ScRangeNameLine> ScRangeManagerTable::GetSelectedEntries()
     return aSelectedEntries;
 }
 
+namespace {
+
+void CalculateItemSize(const long& rTableSize, long& rItemNameSize, long& rItemRangeSize)
+{
+    long aItemScopeSize = rTableSize - rItemNameSize - rItemRangeSize;
+
+    if (rItemNameSize >= MINSIZE && rItemRangeSize >= MINSIZE && aItemScopeSize >= MINSIZE)
+        return;
+
+    if (rItemNameSize < MINSIZE)
+    {
+        long aDiffSize = MINSIZE - rItemNameSize;
+        if (rItemRangeSize > aItemScopeSize)
+            rItemRangeSize -= aDiffSize;
+        else
+            aItemScopeSize -= aDiffSize;
+        rItemNameSize = MINSIZE;
+    }
+
+    if (rItemRangeSize < MINSIZE)
+    {
+        long aDiffSize = MINSIZE - rItemRangeSize;
+        if (rItemNameSize > aItemScopeSize)
+            rItemNameSize -= aDiffSize;
+        else
+            aItemScopeSize -= aDiffSize;
+        rItemRangeSize = MINSIZE;
+    }
+
+    if (aItemScopeSize < MINSIZE)
+    {
+        long aDiffSize = MINSIZE - aItemScopeSize;
+        if (rItemNameSize > rItemRangeSize)
+            rItemNameSize -= aDiffSize;
+        else
+            rItemRangeSize -= aDiffSize;
+    }
+}
+
+}
+
+IMPL_LINK( ScRangeManagerTable, HeaderEndDragHdl, void*, EMPTYARG)
+{
+    long aTableSize = maHeaderBar.GetSizePixel().Width();
+    long aItemNameSize = maHeaderBar.GetItemSize(ITEMID_NAME);
+    long aItemRangeSize = maHeaderBar.GetItemSize(ITEMID_RANGE);
+
+    CalculateItemSize(aTableSize, aItemNameSize, aItemRangeSize);
+    long aItemScopeSize = aTableSize - aItemNameSize - aItemRangeSize;
+
+    Size aSz;
+    aSz.Width() = aItemNameSize;
+    SetTab( ITEMID_NAME, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT );
+    aSz.Width() += aItemRangeSize;
+    SetTab( ITEMID_RANGE, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT );
+    aSz.Width() += aItemScopeSize;
+    SetTab( ITEMID_SCOPE, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT );
+
+    return 0;
+}
+
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list