diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-09-24 15:48:01 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-09-24 16:09:44 +0200 |
commit | ae992dbe6c2ae729fe69f1b48d4fade7be90e849 (patch) | |
tree | 701de8fc03afa874514d9eb3d9c4e1916079a17c /sc | |
parent | handle local range names from name box/navigator correctly (diff) | |
download | core-ae992dbe6c2ae729fe69f1b48d4fade7be90e849.tar.gz core-ae992dbe6c2ae729fe69f1b48d4fade7be90e849.zip |
add local range names to "Name Box"/ScPosWnd
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/rangeutl.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 56 |
2 files changed, 38 insertions, 19 deletions
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx index d5af7ec99b0a..2a0ceb0f9b59 100644 --- a/sc/source/core/tool/rangeutl.cxx +++ b/sc/source/core/tool/rangeutl.cxx @@ -293,7 +293,6 @@ sal_Bool ScRangeUtil::MakeRangeFromName ( sal_Int32 nEndPos = aName.lastIndexOf(')'); sal_Int32 nStartPos = aName.lastIndexOfAsciiL(" (",2); SCTAB nTable = nCurTab; - std::cout << "nStartPos: " << nStartPos << " nEndPos: " << nEndPos << std::endl; if (nEndPos != -1 && nStartPos != -1) { rtl::OUString aSheetName = aName.copy(nStartPos+2, nEndPos-nStartPos-2); diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index c0b09799410b..6c26f3d3b952 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1810,6 +1810,19 @@ void ScPosWnd::SetPos( const String& rPosStr ) } } +namespace { + +rtl::OUString createLocalRangeName(const rtl::OUString& rName, const rtl::OUString& rTableName) +{ + rtl::OUStringBuffer aString (rName); + aString.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ("))); + aString.append(rTableName); + aString.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"))); + return aString.makeStringAndClear(); +} + +} + void ScPosWnd::FillRangeNames() { Clear(); @@ -1819,32 +1832,39 @@ void ScPosWnd::FillRangeNames() { ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument(); - // per Hand sortieren, weil Funktionen nicht sortiert werden: - + ScRange aDummy; + std::set<rtl::OUString> aSet; ScRangeName* pRangeNames = pDoc->GetRangeName(); if (!pRangeNames->empty()) { - ScRange aDummy; - std::vector<const ScRangeData*> aSortArray; - ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end(); - for (; itr != itrEnd; ++itr) + ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end(); + for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr) { if (itr->IsValidReference(aDummy)) - aSortArray.push_back(&(*itr)); + aSet.insert(itr->GetName()); } + } + for (SCTAB i = 0; i < pDoc->GetTableCount(); ++i) + { + ScRangeName* pLocalRangeName = pDoc->GetRangeName(i); + if (pLocalRangeName && !pLocalRangeName->empty()) + { + rtl::OUString aTableName; + 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 (!aSortArray.empty()) + if (!aSet.empty()) + { + for (std::set<rtl::OUString>::iterator itr = aSet.begin(); + itr != aSet.end(); ++itr) { -#ifndef ICC - size_t n = aSortArray.size(); - qsort( (void*)&aSortArray[0], n, sizeof(ScRangeData*), - &ScRangeData_QsortNameCompare ); -#else - qsort( (void*)&aSortArray[0], n, sizeof(ScRangeData*), - ICCQsortNameCompare ); -#endif - for (size_t i = 0; i < n; ++i) - InsertEntry(aSortArray[i]->GetName()); + InsertEntry(*itr); } } } |