[Libreoffice-commits] .: 4 commits - sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Sat Sep 24 07:09:56 PDT 2011
sc/source/core/tool/rangeutl.cxx | 29 ++++++++++++++++----
sc/source/ui/app/inputwin.cxx | 56 ++++++++++++++++++++++++++-------------
sc/source/ui/namedlg/namedlg.cxx | 4 ++
sc/source/ui/navipi/content.cxx | 49 ++++++++++++++++++++++++----------
4 files changed, 100 insertions(+), 38 deletions(-)
New commits:
commit 7a195b81bee5c84e01186463b44ad3c551046f33
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Sep 24 16:03:49 2011 +0200
Manage Names: braodcast change in range names now directly
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 494a6d0..47ff629 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -45,6 +45,8 @@
#include "namedlg.hxx"
#include "viewdata.hxx"
+#include "sfx2/app.hxx"
+
#include <vcl/msgbox.hxx>
#include <map>
@@ -472,6 +474,7 @@ bool ScNameDlg::AddPushed()
maBtnAdd.Disable();
maUndoStack.push( new ScNameManagerUndoAdd( pRangeName, new ScRangeData(*pNewEntry) ));
UpdateNames();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
}
}
else
@@ -506,6 +509,7 @@ void ScNameDlg::RemovePushed()
maUndoStack.push( new ScNameManagerUndoDelete( pRangeName, new ScRangeData(*pData) ));
pRangeName->erase(*pData);
UpdateNames();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
}
}
}
commit ae992dbe6c2ae729fe69f1b48d4fade7be90e849
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Sep 24 15:48:01 2011 +0200
add local range names to "Name Box"/ScPosWnd
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index d5af7ec..2a0ceb0 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 c0b0979..6c26f3d 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);
}
}
}
commit e9159d142a4f25bff88da3dd90e163135ae0bdfa
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Sep 24 15:11:02 2011 +0200
handle local range names from name box/navigator correctly
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index e0a00dc..d5af7ec 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -44,6 +44,8 @@
#include "externalrefmgr.hxx"
#include "compiler.hxx"
+#include <iostream>
+
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
using ::formula::FormulaGrammar;
@@ -286,13 +288,29 @@ sal_Bool ScRangeUtil::MakeRangeFromName (
if( eScope==RUTL_NAMES )
{
- //first check for local range names
- ScRangeName* pRangeNames = pDoc->GetRangeName( nCurTab );
+ //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;
+ std::cout << "nStartPos: " << nStartPos << " nEndPos: " << nEndPos << std::endl;
+ 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->findByName(rName);
+ pData = pRangeNames->findByName(aName);
if (!pData)
- pData = pDoc->GetRangeName()->findByName(rName);
+ pData = pDoc->GetRangeName()->findByName(aName);
if (pData)
{
String aStrArea;
@@ -301,7 +319,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();
@@ -315,7 +333,7 @@ sal_Bool ScRangeUtil::MakeRangeFromName (
{
CutPosString( aStrArea, aStrArea );
- if ( IsAbsPos( aStrArea, pDoc, nCurTab,
+ if ( IsAbsPos( aStrArea, pDoc, nTable,
NULL, &aStartPos, rDetails ) )
{
nTab = aStartPos.Tab();
commit 3b6fc983f4c29dbe59f19a3451b12ac17b88286f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Sep 24 04:29:37 2011 +0200
show local range names in navigator
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 5c07de0..25330e7 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -653,6 +653,18 @@ void ScContentTree::GetTableNames()
}
}
+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 ScContentTree::GetAreaNames()
{
if ( nRootType && nRootType != SC_CONTENT_RANGENAME ) // ausgeblendet ?
@@ -662,30 +674,39 @@ void ScContentTree::GetAreaNames()
if (!pDoc)
return;
+ ScRange aDummy;
+ std::set<rtl::OUString> aSet;
ScRangeName* pRangeNames = pDoc->GetRangeName();
if (!pRangeNames->empty())
{
- ScRange aDummy;
ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
- std::vector<const ScRangeData*> aSortArray;
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)
- InsertContent(SC_CONTENT_RANGENAME, aSortArray[i]->GetName());
+ InsertContent(SC_CONTENT_RANGENAME, *itr);
}
}
}
More information about the Libreoffice-commits
mailing list