[Libreoffice-commits] .: sc/inc sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Wed Jun 15 14:07:31 PDT 2011
sc/inc/scabstdlg.hxx | 2 +-
sc/source/ui/attrdlg/scdlgfact.cxx | 4 ++--
sc/source/ui/attrdlg/scdlgfact.hxx | 2 +-
sc/source/ui/docshell/docfunc.cxx | 24 +++++++++++++++++++-----
sc/source/ui/inc/namepast.hxx | 2 +-
sc/source/ui/miscdlgs/namepast.cxx | 11 +++++++++--
sc/source/ui/view/cellsh1.cxx | 3 ++-
sc/source/ui/view/editsh.cxx | 3 ++-
8 files changed, 37 insertions(+), 14 deletions(-)
New commits:
commit e4c2915b26d26c4d8ed5e7ad6999fa7d1244c56e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 15 23:04:51 2011 +0200
add local range names to ScNamePasteDlg
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 01d8d31..874a130 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -417,7 +417,7 @@ public:
virtual AbstractScNameCreateDlg * CreateScNameCreateDlg ( Window * pParent, sal_uInt16 nFlags, int nId ) = 0; //add for ScNameCreateDlg
virtual AbstractScNamePasteDlg * CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList, //add for ScNamePasteDlg
- int nId , sal_Bool bInsList=sal_True ) = 0;
+ const ScRangeName* pLocalList, int nId , bool bInsList=true ) = 0;
virtual AbstractScPivotFilterDlg * CreateScPivotFilterDlg ( Window* pParent, //add for ScPivotFilterDlg
const SfxItemSet& rArgSet, sal_uInt16 nSourceTab , int nId ) = 0;
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 9937e35..4af933d 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -1180,13 +1180,13 @@ AbstractScNameCreateDlg * ScAbstractDialogFactory_Impl::CreateScNameCreateDlg (
AbstractScNamePasteDlg * ScAbstractDialogFactory_Impl::CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList,
- int nId , sal_Bool bInsList )
+ const ScRangeName* pLocalList, int nId , bool bInsList )
{
ScNamePasteDlg * pDlg=NULL;
switch ( nId )
{
case RID_SCDLG_NAMES_PASTE :
- pDlg = new ScNamePasteDlg( pParent, pList, bInsList );
+ pDlg = new ScNamePasteDlg( pParent, pList, pLocalList, bInsList );
break;
default:
break;
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index b8090b4..812f65f 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -501,7 +501,7 @@ public:
virtual AbstractScNameCreateDlg * CreateScNameCreateDlg ( Window * pParent, sal_uInt16 nFlags, int nId ); //add for ScNameCreateDlg
virtual AbstractScNamePasteDlg * CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList, //add for ScNamePasteDlg
- int nId , sal_Bool bInsList=sal_True );
+ const ScRangeName* pLocalList, int nId , bool bInsList=true );
virtual AbstractScPivotFilterDlg * CreateScPivotFilterDlg ( Window* pParent, //add for ScPivotFilterDlg
const SfxItemSet& rArgSet, sal_uInt16 nSourceTab , int nId );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index dc4040a..462d3d4 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4708,20 +4708,28 @@ sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi )
{
ScDocShellModificator aModificator( rDocShell );
-
sal_Bool bDone = false;
ScDocument* pDoc = rDocShell.GetDocument();
- const sal_Bool bRecord = pDoc->IsUndoEnabled();
+ const bool bRecord = pDoc->IsUndoEnabled();
SCTAB nTab = rStartPos.Tab();
ScDocument* pUndoDoc = NULL;
- ScRangeName* pList = pDoc->GetRangeName();
+ //local names have higher priority than global names
+ ScRangeName* pLocalList = pDoc->GetRangeName(nTab);
sal_uInt16 nValidCount = 0;
+ ScRangeName::iterator itrLocalBeg = pLocalList->begin(), itrLocalEnd = pLocalList->end();
+ for (ScRangeName::iterator itr = itrLocalBeg; itr != itrLocalEnd; ++itr)
+ {
+ const ScRangeData& r = *itr;
+ if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED))
+ ++nValidCount;
+ }
+ ScRangeName* pList = pDoc->GetRangeName();
ScRangeName::iterator itrBeg = pList->begin(), itrEnd = pList->end();
for (ScRangeName::iterator itr = itrBeg; itr != itrEnd; ++itr)
{
const ScRangeData& r = *itr;
- if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED))
+ if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByName(r.GetName()))
++nValidCount;
}
@@ -4747,12 +4755,18 @@ sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi )
ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
sal_uInt16 j = 0;
- for (ScRangeName::iterator itr = itrBeg; itr != itrEnd; ++itr)
+ for (ScRangeName::iterator itr = itrLocalBeg; itr != itrLocalEnd; ++itr)
{
ScRangeData& r = *itr;
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->findByName(r.GetName()))
+ ppSortArray[j++] = &r;
+ }
#ifndef ICC
qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
&ScRangeData_QsortNameCompare );
diff --git a/sc/source/ui/inc/namepast.hxx b/sc/source/ui/inc/namepast.hxx
index 03c0cfd..6d1333a 100644
--- a/sc/source/ui/inc/namepast.hxx
+++ b/sc/source/ui/inc/namepast.hxx
@@ -51,7 +51,7 @@ protected:
HelpButton aHelpButton;
PushButton aInsListButton;
public:
- ScNamePasteDlg( Window * pParent, const ScRangeName* pList, sal_Bool bInsList=sal_True );
+ ScNamePasteDlg( Window * pParent, const ScRangeName* pList, const ScRangeName* pLocalList, bool bInsList=true );
String GetSelectedName() const;
};
diff --git a/sc/source/ui/miscdlgs/namepast.cxx b/sc/source/ui/miscdlgs/namepast.cxx
index f976a08..0495dea 100644
--- a/sc/source/ui/miscdlgs/namepast.cxx
+++ b/sc/source/ui/miscdlgs/namepast.cxx
@@ -43,7 +43,7 @@
//==================================================================
-ScNamePasteDlg::ScNamePasteDlg( Window * pParent, const ScRangeName* pList, sal_Bool bInsList )
+ScNamePasteDlg::ScNamePasteDlg( Window * pParent, const ScRangeName* pList, const ScRangeName* pLocalList, bool bInsList )
: ModalDialog( pParent, ScResId( RID_SCDLG_NAMES_PASTE ) ),
aLabelText ( this, ScResId( FT_LABEL ) ),
aNameList ( this, ScResId( LB_ENTRYLIST ) ),
@@ -60,13 +60,20 @@ ScNamePasteDlg::ScNamePasteDlg( Window * pParent, const ScRangeName* pList, sal_
aNameList.SetSelectHdl( LINK( this,ScNamePasteDlg,ListSelHdl) );
aNameList.SetDoubleClickHdl( LINK( this,ScNamePasteDlg,ListDblClickHdl) );
- ScRangeName::const_iterator itr = pList->begin(), itrEnd = pList->end();
+ ScRangeName::const_iterator itr = pLocalList->begin(), itrEnd = pLocalList->end();
for (; itr != itrEnd; ++itr)
{
if (!itr->HasType(RT_DATABASE) && !itr->HasType(RT_SHARED))
aNameList.InsertEntry(itr->GetName());
}
+ itr = pList->begin(), itrEnd = pList->end();
+ for (; itr != itrEnd; ++itr)
+ {
+ if (!itr->HasType(RT_DATABASE) && !itr->HasType(RT_SHARED) && !pLocalList->findByName(itr->GetName()))
+ aNameList.InsertEntry(itr->GetName());
+ }
+
ListSelHdl( &aNameList );
FreeResource();
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index cb8b641..d0d6c3a 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1807,10 +1807,11 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case FID_INSERT_NAME:
{
ScDocument* pDoc = GetViewData()->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
- AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE );
+ AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName(), pDoc->GetRangeName(nTab), RID_SCDLG_NAMES_PASTE );
OSL_ENSURE(pDlg, "Dialog create fail!");
switch( pDlg->Execute() )
{
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index c3e5bbc..8d679be 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -420,10 +420,11 @@ void ScEditShell::Execute( SfxRequest& rReq )
case FID_INSERT_NAME:
{
ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
- AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pViewData->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE, false );
+ AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pViewData->GetDialogParent(), pDoc->GetRangeName(), pDoc->GetRangeName(nTab), RID_SCDLG_NAMES_PASTE, false );
OSL_ENSURE(pDlg, "Dialog create fail!");
short nRet = pDlg->Execute();
// pDlg is needed below
More information about the Libreoffice-commits
mailing list