[Libreoffice-commits] .: 5 commits - sc/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Fri Sep 23 18:52:55 PDT 2011


 sc/source/ui/inc/namedlg.hxx     |   39 +++---
 sc/source/ui/namedlg/namedlg.cxx |  228 +++++++++++++++++++--------------------
 2 files changed, 135 insertions(+), 132 deletions(-)

New commits:
commit 176b9ee183fdaa5837d0d436720ecb199e80f480
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Sep 24 01:43:07 2011 +0200

    Manage Names: add comments and remove dead code

diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index 713a129..8a55623 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -57,6 +57,10 @@ struct ScRangeNameLine
     rtl::OUString aScope;
 };
 
+//Implements the table for the manage names dialog
+//TODO: cache the lines for performance improvements
+//otherwise handling of a large set of range names might get extremely slow
+//Need some sort of a filter to handle several range names
 class ScRangeManagerTable : public SvTabListBox
 {
 private:
@@ -127,6 +131,7 @@ public:
 
 //==================================================================
 
+//logic behind the manage names dialog
 class ScNameDlg : public ScAnyRefDlg
 {
 private:
@@ -192,7 +197,6 @@ private:
     DECL_LINK( ModifyBtnHdl, void * );
     DECL_LINK( RemoveBtnHdl, void * );
     DECL_LINK( EdModifyHdl, void * );
-    DECL_LINK( NameSelectHdl, void * );
     DECL_LINK( AssignGetFocusHdl, void * );
     DECL_LINK( SelectionChangedHdl_Impl, void* );
     DECL_LINK( BackBtnHdl, void * );
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index e8bd6f4..494a6d0 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -384,6 +384,7 @@ void ScNameDlg::UpdateChecks(ScRangeData* pData)
     maBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) );
 }
 
+//updates the table and the buttons
 void ScNameDlg::UpdateNames()
 {
     mpRangeManagerTable->UpdateEntries();
@@ -505,16 +506,10 @@ void ScNameDlg::RemovePushed()
             maUndoStack.push( new ScNameManagerUndoDelete( pRangeName, new ScRangeData(*pData) ));
             pRangeName->erase(*pData);
             UpdateNames();
-            maBtnAdd.Disable();
         }
     }
 }
 
-void ScNameDlg::NameSelected()
-{
-
-}
-
 void ScNameDlg::NameModified()
 {
     rtl::OUString aName = maEdName.GetText();
@@ -669,12 +664,6 @@ IMPL_LINK( ScNameDlg, RemoveBtnHdl, void *, EMPTYARG )
     return 0;
 }
 
-IMPL_LINK( ScNameDlg, NameSelectHdl, void *, EMPTYARG )
-{
-    NameSelected();
-    return 0;
-}
-
 IMPL_LINK( ScNameDlg, EdModifyHdl, void *, EMPTYARG )
 {
     NameModified();
commit 87e3d71ca68ca8dbe50dbabf6628b5f002e4b46d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Sep 24 01:34:12 2011 +0200

    Manage Names: refactoring in namedlg.cxx

diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index 49c69c2..713a129 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -130,7 +130,6 @@ public:
 class ScNameDlg : public ScAnyRefDlg
 {
 private:
-    typedef ::boost::ptr_map<SCTAB, ScRangeName> TabNameMapType;
     FixedText       maFtScope;
     FixedText       maFtRange;
     FixedText       maFtName;
@@ -140,31 +139,31 @@ private:
     Edit            maEdName;
     formula::RefButton      aRbAssign;
 
-    FixedLine       aFlDiv;
-    CheckBox        aBtnPrintArea;
-    CheckBox        aBtnColHeader;
-    CheckBox        aBtnCriteria;
-    CheckBox        aBtnRowHeader;
+    FixedLine       maFlDiv;
+    CheckBox        maBtnPrintArea;
+    CheckBox        maBtnColHeader;
+    CheckBox        maBtnCriteria;
+    CheckBox        maBtnRowHeader;
 
     ScRangeManagerCtrl maNameMgrCtrl;
     ScRangeManagerTable* mpRangeManagerTable;
 
-    HelpButton      aBtnHelp;
-    PushButton      aBtnAdd;
-    PushButton      aBtnModify;
-    PushButton      aBtnBack;
-    PushButton      aBtnDelete;
-    PushButton      aBtnClose;
-    MoreButton      aBtnMore;
+    HelpButton      maBtnHelp;
+    PushButton      maBtnAdd;
+    PushButton      maBtnModify;
+    PushButton      maBtnBack;
+    PushButton      maBtnDelete;
+    PushButton      maBtnClose;
+    MoreButton      maBtnMore;
 
-    const String    errMsgInvalidSym;
+    const String    mErrMsgInvalidSym;
     const rtl::OUString maErrMsgModifiedFailed;
     const ::rtl::OUString maGlobalNameStr;
 
-    ScViewData*     pViewData;
+    ScViewData*     mpViewData;
     ScDocument*     mpDoc;
     const ScAddress maCursorPos;
-    Selection       theCurSel;
+    Selection       maCurSel;
 
     std::stack<ScNameManagerUndo*> maUndoStack;
 
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 3cf7027..e8bd6f4 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -165,7 +165,7 @@ void ScRangeManagerTable::UpdateEntries()
         for (ScRangeName::iterator it = pLocalRangeName->begin();
                 it != pLocalRangeName->end(); ++it)
         {
-            if (!it->HasType(RT_DAZABASE) && !it->HasType(RT_SHARED))
+            if (!it->HasType(RT_DATABASE) && !it->HasType(RT_SHARED))
             {
                 aLine.aName = it->GetName();
                 it->GetSymbol(aLine.aExpression);
@@ -223,28 +223,6 @@ void ScNameManagerUndoModify::Undo()
 
 //logic
 
-struct ScNameDlgImpl
-{
-    ScNameDlgImpl() :
-        bCriteria(false), bPrintArea(false),
-        bColHeader(false), bRowHeader(false),
-        bDirty(false) {}
-
-    void Clear()
-    {
-        aStrSymbol = ::rtl::OUString();
-        bCriteria  = bPrintArea = bColHeader = bRowHeader = false;
-        bDirty = true;
-    }
-
-    ::rtl::OUString aStrSymbol;
-    bool bCriteria:1;
-    bool bPrintArea:1;
-    bool bColHeader:1;
-    bool bRowHeader:1;
-    bool bDirty:1;
-};
-
 #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
 
 ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
@@ -262,41 +240,32 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
     maEdName         ( this, ScResId( ED_NAME2 ) ),
     aRbAssign       ( this, ScResId( RB_ASSIGN ), &maEdAssign, this ),
     //
-    aFlDiv          ( this, ScResId( FL_DIV ) ),
-    aBtnPrintArea   ( this, ScResId( BTN_PRINTAREA ) ),
-    aBtnColHeader   ( this, ScResId( BTN_COLHEADER ) ),
-    aBtnCriteria    ( this, ScResId( BTN_CRITERIA ) ),
-    aBtnRowHeader   ( this, ScResId( BTN_ROWHEADER ) ),
+    maFlDiv          ( this, ScResId( FL_DIV ) ),
+    maBtnPrintArea   ( this, ScResId( BTN_PRINTAREA ) ),
+    maBtnColHeader   ( this, ScResId( BTN_COLHEADER ) ),
+    maBtnCriteria    ( this, ScResId( BTN_CRITERIA ) ),
+    maBtnRowHeader   ( this, ScResId( BTN_ROWHEADER ) ),
     //
     maNameMgrCtrl   ( this, ScResId( CTRL_MANAGENAMES ) ),
     //
-    aBtnHelp        ( this, ScResId( BTN_HELP ) ),
-    aBtnAdd         ( this, ScResId( BTN_ADD ) ),
-    aBtnModify      ( this, ScResId( BTN_MODIFY ) ),
-    aBtnBack        ( this, ScResId( BTN_BACK ) ),
-    aBtnDelete      ( this, ScResId( BTN_DELETE ) ),
-    aBtnClose       ( this, ScResId( BTN_CLOSE ) ),
-    aBtnMore        ( this, ScResId( BTN_MORE ) ),
+    maBtnHelp        ( this, ScResId( BTN_HELP ) ),
+    maBtnAdd         ( this, ScResId( BTN_ADD ) ),
+    maBtnModify      ( this, ScResId( BTN_MODIFY ) ),
+    maBtnBack        ( this, ScResId( BTN_BACK ) ),
+    maBtnDelete      ( this, ScResId( BTN_DELETE ) ),
+    maBtnClose       ( this, ScResId( BTN_CLOSE ) ),
+    maBtnMore        ( this, ScResId( BTN_MORE ) ),
     //
-    errMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
+    mErrMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
     maErrMsgModifiedFailed( ResId::toString(ScResId( STR_MODIFYFAILED ) ) ),
     maGlobalNameStr( ResId::toString(ScResId(STR_GLOBAL_SCOPE)) ),
     //
-    pViewData       ( ptrViewData ),
+    mpViewData       ( ptrViewData ),
     mpDoc            ( ptrViewData->GetDocument() ),
-    maCursorPos    ( aCursorPos )
+    maCursorPos      ( aCursorPos )
 {
-    //init UI
-    std::map<rtl::OUString,ScRangeName*> aTabRangeNameMap;
-    mpDoc->GetTabRangeNameMap(aTabRangeNameMap);
-    mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, mpDoc->GetRangeName(), aTabRangeNameMap);
-    mpRangeManagerTable->SetSelectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
-    mpRangeManagerTable->SetDeselectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
-
     Init();
     FreeResource();
-
-    //aRbAssign.SetAccessibleRelationMemberOf(&aFlAssign);
 }
 
 ScNameDlg::~ScNameDlg()
@@ -315,29 +284,36 @@ void ScNameDlg::Init()
     String  aAreaStr;
     ScRange aRange;
 
-    OSL_ENSURE( pViewData && mpDoc, "ViewData oder Document nicht gefunden!" );
+    OSL_ENSURE( mpViewData && mpDoc, "ViewData oder Document nicht gefunden!" );
+
+    //init UI
+    std::map<rtl::OUString,ScRangeName*> aTabRangeNameMap;
+    mpDoc->GetTabRangeNameMap(aTabRangeNameMap);
+    mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, mpDoc->GetRangeName(), aTabRangeNameMap);
+    mpRangeManagerTable->SetSelectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
+    mpRangeManagerTable->SetDeselectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
 
-    aBtnClose.SetClickHdl  ( LINK( this, ScNameDlg, CloseBtnHdl ) );
-    aBtnAdd.SetClickHdl     ( LINK( this, ScNameDlg, AddBtnHdl ) );
-    aBtnBack.SetClickHdl ( LINK( this, ScNameDlg, BackBtnHdl ) );
+    maBtnClose.SetClickHdl  ( LINK( this, ScNameDlg, CloseBtnHdl ) );
+    maBtnAdd.SetClickHdl     ( LINK( this, ScNameDlg, AddBtnHdl ) );
+    maBtnBack.SetClickHdl ( LINK( this, ScNameDlg, BackBtnHdl ) );
     maEdAssign.SetGetFocusHdl( LINK( this, ScNameDlg, AssignGetFocusHdl ) );
     maEdAssign.SetModifyHdl  ( LINK( this, ScNameDlg, EdModifyHdl ) );
     maEdName.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) );
     maLbScope.SetSelectHdl( LINK(this, ScNameDlg, ScopeChangedHdl) );
-    aBtnDelete.SetClickHdl ( LINK( this, ScNameDlg, RemoveBtnHdl ) );
-    aBtnModify.SetClickHdl ( LINK( this, ScNameDlg, ModifyBtnHdl ) );
+    maBtnDelete.SetClickHdl ( LINK( this, ScNameDlg, RemoveBtnHdl ) );
+    maBtnModify.SetClickHdl ( LINK( this, ScNameDlg, ModifyBtnHdl ) );
 
-    aBtnBack.Disable();
+    maBtnBack.Disable();
 
-    aBtnCriteria .Hide();
-    aBtnPrintArea.Hide();
-    aBtnColHeader.Hide();
-    aBtnRowHeader.Hide();
+    maBtnCriteria .Hide();
+    maBtnPrintArea.Hide();
+    maBtnColHeader.Hide();
+    maBtnRowHeader.Hide();
 
-    aBtnMore.AddWindow( &aBtnCriteria );
-    aBtnMore.AddWindow( &aBtnPrintArea );
-    aBtnMore.AddWindow( &aBtnColHeader );
-    aBtnMore.AddWindow( &aBtnRowHeader );
+    maBtnMore.AddWindow( &maBtnCriteria );
+    maBtnMore.AddWindow( &maBtnPrintArea );
+    maBtnMore.AddWindow( &maBtnColHeader );
+    maBtnMore.AddWindow( &maBtnRowHeader );
 
     // Initialize scope list.
     maLbScope.InsertEntry(maGlobalNameStr);
@@ -352,14 +328,14 @@ void ScNameDlg::Init()
 
     UpdateNames();
 
-    pViewData->GetSimpleArea( aRange );
+    mpViewData->GetSimpleArea( aRange );
     aRange.Format( aAreaStr, ABS_DREF3D, mpDoc,
             ScAddress::Details(mpDoc->GetAddressConvention(), 0, 0) );
 
-    theCurSel = Selection( 0, SELECTION_MAX );
+    maCurSel = Selection( 0, SELECTION_MAX );
     maEdAssign.GrabFocus();
     maEdAssign.SetText( aAreaStr );
-    maEdAssign.SetSelection( theCurSel );
+    maEdAssign.SetSelection( maCurSel );
 
     EdModifyHdl( 0 );
 
@@ -402,31 +378,31 @@ void ScNameDlg::SetActive()
 
 void ScNameDlg::UpdateChecks(ScRangeData* pData)
 {
-    aBtnCriteria .Check( pData->HasType( RT_CRITERIA ) );
-    aBtnPrintArea.Check( pData->HasType( RT_PRINTAREA ) );
-    aBtnColHeader.Check( pData->HasType( RT_COLHEADER ) );
-    aBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) );
+    maBtnCriteria .Check( pData->HasType( RT_CRITERIA ) );
+    maBtnPrintArea.Check( pData->HasType( RT_PRINTAREA ) );
+    maBtnColHeader.Check( pData->HasType( RT_COLHEADER ) );
+    maBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) );
 }
 
 void ScNameDlg::UpdateNames()
 {
     mpRangeManagerTable->UpdateEntries();
     if (!maUndoStack.empty())
-        aBtnBack.Enable();
+        maBtnBack.Enable();
     else
-        aBtnBack.Disable();
+        maBtnBack.Disable();
 
     ScRangeNameLine aLine;
     mpRangeManagerTable->GetCurrentLine(aLine);
     if (aLine.aName.getLength())
     {
-        aBtnDelete.Enable();
-        aBtnModify.Enable();
+        maBtnDelete.Enable();
+        maBtnModify.Enable();
     }
     else
     {
-        aBtnDelete.Disable();
-        aBtnModify.Disable();
+        maBtnDelete.Disable();
+        maBtnModify.Disable();
     }
 }
 
@@ -476,10 +452,10 @@ bool ScNameDlg::AddPushed()
     ScRangeName* pRangeName = GetRangeName(aScope, mpDoc);
 
     RangeType nType = RT_NAME |
-         (aBtnRowHeader.IsChecked() ? RT_ROWHEADER : RangeType(0))
-        |(aBtnColHeader.IsChecked() ? RT_COLHEADER : RangeType(0))
-        |(aBtnPrintArea.IsChecked() ? RT_PRINTAREA : RangeType(0))
-        |(aBtnCriteria.IsChecked()  ? RT_CRITERIA  : RangeType(0));
+         (maBtnRowHeader.IsChecked() ? RT_ROWHEADER : RangeType(0))
+        |(maBtnColHeader.IsChecked() ? RT_COLHEADER : RangeType(0))
+        |(maBtnPrintArea.IsChecked() ? RT_PRINTAREA : RangeType(0))
+        |(maBtnCriteria.IsChecked()  ? RT_CRITERIA  : RangeType(0));
 
     ScRangeData* pNewEntry = new ScRangeData( mpDoc, aName, aExpr,
                                             maCursorPos, nType);
@@ -492,7 +468,7 @@ bool ScNameDlg::AddPushed()
         else
         {
             maEdName.SetText(EMPTY_STRING);
-            aBtnAdd.Disable();
+            maBtnAdd.Disable();
             maUndoStack.push( new ScNameManagerUndoAdd( pRangeName, new ScRangeData(*pNewEntry) ));
             UpdateNames();
         }
@@ -500,7 +476,7 @@ bool ScNameDlg::AddPushed()
     else
     {
         delete pNewEntry;
-        ERRORBOX( errMsgInvalidSym );
+        ERRORBOX( mErrMsgInvalidSym );
     }
     return true;
 }
@@ -529,7 +505,7 @@ void ScNameDlg::RemovePushed()
             maUndoStack.push( new ScNameManagerUndoDelete( pRangeName, new ScRangeData(*pData) ));
             pRangeName->erase(*pData);
             UpdateNames();
-            aBtnAdd.Disable();
+            maBtnAdd.Disable();
         }
     }
 }
@@ -548,26 +524,26 @@ void ScNameDlg::NameModified()
 
     if (!aName.getLength() || !ScRangeData::IsNameValid(aName, mpDoc))
     {
-        aBtnAdd.Disable();
-        aBtnModify.Disable();
+        maBtnAdd.Disable();
+        maBtnModify.Disable();
     }
     else
     {
         ScRangeName* pRangeName = GetRangeName(aScope, mpDoc);
         if (pRangeName->findByName(aName))
         {
-            aBtnAdd.Disable();
+            maBtnAdd.Disable();
         }
         else
         {
-            aBtnAdd.Enable();
+            maBtnAdd.Enable();
         }
         ScRangeNameLine aLine;
         mpRangeManagerTable->GetCurrentLine(aLine);
         if (aLine.aName.getLength())
-            aBtnModify.Enable();
+            maBtnModify.Enable();
         else
-            aBtnModify.Disable();
+            maBtnModify.Disable();
     }
 }
 
@@ -579,7 +555,7 @@ void ScNameDlg::SelectionChanged()
     maEdName.SetText(aLine.aName);
     maLbScope.SelectEntry(aLine.aScope);
     ShowOptions(aLine);
-    aBtnDelete.Enable();
+    maBtnDelete.Enable();
 }
 
 void ScNameDlg::BackPushed()
@@ -590,7 +566,7 @@ void ScNameDlg::BackPushed()
     maUndoStack.pop();
     if (maUndoStack.empty())
     {
-        aBtnBack.Disable();
+        maBtnBack.Disable();
     }
     UpdateNames();
     NameModified();
@@ -633,10 +609,10 @@ void ScNameDlg::ModifiedPushed()
     rtl::OUString aExpr = maEdAssign.GetText();
 
     RangeType nType = RT_NAME |
-         (aBtnRowHeader.IsChecked() ? RT_ROWHEADER : RangeType(0))
-        |(aBtnColHeader.IsChecked() ? RT_COLHEADER : RangeType(0))
-        |(aBtnPrintArea.IsChecked() ? RT_PRINTAREA : RangeType(0))
-        |(aBtnCriteria.IsChecked()  ? RT_CRITERIA  : RangeType(0));
+         (maBtnRowHeader.IsChecked() ? RT_ROWHEADER : RangeType(0))
+        |(maBtnColHeader.IsChecked() ? RT_COLHEADER : RangeType(0))
+        |(maBtnPrintArea.IsChecked() ? RT_PRINTAREA : RangeType(0))
+        |(maBtnCriteria.IsChecked()  ? RT_CRITERIA  : RangeType(0));
 
     ScRangeData* pNewEntry = new ScRangeData( mpDoc, aName, aExpr,
                                             maCursorPos, nType);
@@ -655,8 +631,8 @@ void ScNameDlg::ModifiedPushed()
         else
         {
             maEdName.SetText(EMPTY_STRING);
-            aBtnAdd.Disable();
-            aBtnDelete.Disable();
+            maBtnAdd.Disable();
+            maBtnDelete.Disable();
             maUndoStack.push( new ScNameManagerUndoModify( pOldRangeName, new ScRangeData(*pTemp), pNewRangeName, new ScRangeData(*pNewEntry) ));
             UpdateNames();
         }
@@ -665,7 +641,7 @@ void ScNameDlg::ModifiedPushed()
     else
     {
         delete pNewEntry;
-        ERRORBOX( errMsgInvalidSym );
+        ERRORBOX( mErrMsgInvalidSym );
     }
 }
 
commit 4e83a42e431c1ab640703afec356e791af35d830
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Sep 24 01:18:57 2011 +0200

    show only relevant range names

diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index e2ab133..3cf7027 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -147,24 +147,30 @@ void ScRangeManagerTable::UpdateEntries()
     for (ScRangeName::iterator itr = mpGlobalRangeName->begin();
             itr != mpGlobalRangeName->end(); ++itr)
     {
-        ScRangeNameLine aLine;
-        aLine.aName = itr->GetName();
-        aLine.aScope = maGlobalString;
-        itr->GetSymbol(aLine.aExpression);
-        addEntry(aLine);
+        if (!itr->HasType(RT_DATABASE) && !itr->HasType(RT_SHARED))
+        {
+            ScRangeNameLine aLine;
+            aLine.aName = itr->GetName();
+            aLine.aScope = maGlobalString;
+            itr->GetSymbol(aLine.aExpression);
+            addEntry(aLine);
+        }
     }
     for (std::map<rtl::OUString, ScRangeName*>::iterator itr = maTabRangeNames.begin();
             itr != maTabRangeNames.end(); ++itr)
     {
         ScRangeName* pLocalRangeName = itr->second;
+        ScRangeNameLine aLine;
+        aLine.aScope = itr->first;
         for (ScRangeName::iterator it = pLocalRangeName->begin();
                 it != pLocalRangeName->end(); ++it)
         {
-            ScRangeNameLine aLine;
-            aLine.aName = it->GetName();
-            aLine.aScope = itr->first;
-            it->GetSymbol(aLine.aExpression);
-            addEntry(aLine);
+            if (!it->HasType(RT_DAZABASE) && !it->HasType(RT_SHARED))
+            {
+                aLine.aName = it->GetName();
+                it->GetSymbol(aLine.aExpression);
+                addEntry(aLine);
+            }
         }
     }
 }
commit b7b14465204efe248cdf1e4657813e1a1192cca0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Sep 23 22:49:52 2011 +0200

    fix crash, various button problems, memory leak

diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 4bbb90b..e2ab133 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -297,6 +297,11 @@ ScNameDlg::~ScNameDlg()
 {
     delete mpRangeManagerTable;
     //need to delete undo stack here
+    while (!maUndoStack.empty())
+    {
+        delete maUndoStack.top();
+        maUndoStack.pop();
+    }
 }
 
 void ScNameDlg::Init()
@@ -404,6 +409,19 @@ void ScNameDlg::UpdateNames()
         aBtnBack.Enable();
     else
         aBtnBack.Disable();
+
+    ScRangeNameLine aLine;
+    mpRangeManagerTable->GetCurrentLine(aLine);
+    if (aLine.aName.getLength())
+    {
+        aBtnDelete.Enable();
+        aBtnModify.Enable();
+    }
+    else
+    {
+        aBtnDelete.Disable();
+        aBtnModify.Disable();
+    }
 }
 
 void ScNameDlg::CalcCurTableAssign( String& aAssign, ScRangeData* pRangeData )
@@ -469,7 +487,6 @@ bool ScNameDlg::AddPushed()
         {
             maEdName.SetText(EMPTY_STRING);
             aBtnAdd.Disable();
-            aBtnDelete.Disable();
             maUndoStack.push( new ScNameManagerUndoAdd( pRangeName, new ScRangeData(*pNewEntry) ));
             UpdateNames();
         }
@@ -536,8 +553,15 @@ void ScNameDlg::NameModified()
             aBtnAdd.Disable();
         }
         else
+        {
             aBtnAdd.Enable();
-        aBtnModify.Enable();
+        }
+        ScRangeNameLine aLine;
+        mpRangeManagerTable->GetCurrentLine(aLine);
+        if (aLine.aName.getLength())
+            aBtnModify.Enable();
+        else
+            aBtnModify.Disable();
     }
 }
 
@@ -549,12 +573,14 @@ void ScNameDlg::SelectionChanged()
     maEdName.SetText(aLine.aName);
     maLbScope.SelectEntry(aLine.aScope);
     ShowOptions(aLine);
+    aBtnDelete.Enable();
 }
 
 void ScNameDlg::BackPushed()
 {
     ScNameManagerUndo* aUndo = maUndoStack.top();
     aUndo->Undo();
+    delete aUndo;
     maUndoStack.pop();
     if (maUndoStack.empty())
     {
@@ -591,6 +617,8 @@ void ScNameDlg::ModifiedPushed()
 
     ScRangeNameLine aLine;
     mpRangeManagerTable->GetCurrentLine(aLine);
+    if (!aLine.aName.getLength()) //no line selected
+        return;
     ScRangeName* pOldRangeName = GetRangeName(aLine.aScope, mpDoc);
 
 
commit 24f4f5bc7a68a3375f655ec3f4b9f3313c4609b2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Sep 23 21:49:01 2011 +0200

    Manage Names: set new entry as selected

diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index bb6dd07..49c69c2 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -68,7 +68,7 @@ public:
     ScRangeManagerTable( Window* pParent, ScRangeName* pGlobalRangeName, std::map<rtl::OUString, ScRangeName*> aTabRangeNames );
     ~ScRangeManagerTable() {};
 
-    SvLBoxEntry* addEntry( const ScRangeNameLine& rLine );
+    void addEntry( const ScRangeNameLine& rLine );
 
     void GetCurrentLine(ScRangeNameLine& rLine);
     void UpdateEntries();
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 4f6febf..4bbb90b 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -127,9 +127,10 @@ ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, ScRangeName* pGlobalR
     maHeaderBar.Show();
 }
 
-SvLBoxEntry* ScRangeManagerTable::addEntry(const ScRangeNameLine& rLine)
+void ScRangeManagerTable::addEntry(const ScRangeNameLine& rLine)
 {
-    return InsertEntryToColumn( createEntryString(rLine), LIST_APPEND, 0xffff);
+    SvLBoxEntry* pEntry = InsertEntryToColumn( createEntryString(rLine), LIST_APPEND, 0xffff);
+    SetCurEntry(pEntry);
 }
 
 void ScRangeManagerTable::GetCurrentLine(ScRangeNameLine& rLine)


More information about the Libreoffice-commits mailing list