From 7f8deb4f90b129183778f977da2d22a147b5eb3f Mon Sep 17 00:00:00 2001
From: Markus Mohrhard <markus.mohrhard@googlemail.com>
Date: Thu, 17 Nov 2011 01:18:49 +0100
Subject: ManageNames: improve AddNames UI, no logic yet

---
 sc/source/ui/attrdlg/scdlgfact.cxx  |   4 +-
 sc/source/ui/attrdlg/scdlgfact.hxx  |   2 +-
 sc/source/ui/inc/namedefdlg.hrc     |  16 +++++-
 sc/source/ui/inc/namedefdlg.hxx     |  26 ++++++++-
 sc/source/ui/namedlg/namedefdlg.cxx |  37 ++++++++++++-
 sc/source/ui/src/namedefdlg.src     | 105 ++++++++++++++++++++++++++++++++++--
 sc/source/ui/view/cellsh1.cxx       |   5 +-
 sc/source/ui/view/editsh.cxx        |   3 +-
 8 files changed, 184 insertions(+), 14 deletions(-)

(limited to 'sc/source/ui')

diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index cac850ff7080..b0052cc806dd 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -1152,13 +1152,13 @@ AbstractScNamePasteDlg * ScAbstractDialogFactory_Impl::CreateScNamePasteDlg ( Wi
 }
 
 
-AbstractScNameAddDlg* ScAbstractDialogFactory_Impl::CreateScNameAddDlg( Window* pParent, int nId)
+AbstractScNameAddDlg* ScAbstractDialogFactory_Impl::CreateScNameAddDlg( Window* pParent, ScDocument* pDoc, int nId)
 {
     ScNameDefDlg* pDlg = NULL;
     switch ( nId )
     {
         case RID_SCDLG_NAMES_DEFINE :
-            pDlg = new ScNameDefDlg( pParent );
+            pDlg = new ScNameDefDlg( pParent, pDoc );
             break;
         default:
             break;
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 08b8ccaec472..66fd48064f8c 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -492,7 +492,7 @@ public:
     virtual AbstractScNamePasteDlg * CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList, //add for ScNamePasteDlg
                                                             const ScRangeName* pLocalList, int nId , bool bInsList=true );
 
-    virtual AbstractScNameAddDlg* CreateScNameAddDlg ( Window* pParent, int nId);
+    virtual AbstractScNameAddDlg* CreateScNameAddDlg ( Window* pParent, ScDocument* pDoc, int nId);
 
     virtual AbstractScPivotFilterDlg * CreateScPivotFilterDlg ( Window* pParent, //add for ScPivotFilterDlg
                                                                 const SfxItemSet&   rArgSet, sal_uInt16 nSourceTab , int nId );
diff --git a/sc/source/ui/inc/namedefdlg.hrc b/sc/source/ui/inc/namedefdlg.hrc
index 1360a70e9a3a..e87ef62bdd5c 100644
--- a/sc/source/ui/inc/namedefdlg.hrc
+++ b/sc/source/ui/inc/namedefdlg.hrc
@@ -1,3 +1,17 @@
 #include "sc.hrc"
 
-#define BTN_OK 1
+#define BTN_ADD 1
+#define BTN_CANCEL 2
+#define FT_NAME 3
+#define FT_RANGE 4
+#define FT_SCOPE 5
+#define FT_INFO 6
+#define ED_NAME 7
+#define ED_RANGE 8
+#define LB_SCOPE 9
+#define BTN_PRINTAREA 10
+#define BTN_CRITERIA 11
+#define BTN_ROWHEADER 12
+#define BTN_COLHEADER 13
+#define STR_GLOBAL_SCOPE 14
+#define FL_DIV 15
diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx
index 2dd03c6d070b..52af90620020 100644
--- a/sc/source/ui/inc/namedefdlg.hxx
+++ b/sc/source/ui/inc/namedefdlg.hxx
@@ -29,13 +29,35 @@
 #include "anyrefdg.hxx"
 #include "namedefdlg.hrc"
 #include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/lstbox.hxx>
+
+class ScDocument;
 
 class ScNameDefDlg : public ModalDialog
 {
 private:
-    OKButton maBtnOk;
+    PushButton maBtnAdd;
+    PushButton maBtnCancel;
+    FixedText maFtInfo;
+    FixedText maFtName;
+    FixedText maFtRange;
+    FixedText maFtScope;
+    FixedLine maFlDiv;
+
+    Edit maEdName;
+    Edit maEdRange;
+
+    ListBox maLbScope;
+
+    rtl::OUString maGlobalNameStr;
+
+    void CancelPushed();
+
+    DECL_LINK( CancelBtnHdl, void * );
 public:
-    ScNameDefDlg(Window* pParent);
+    ScNameDefDlg(Window* pParent, ScDocument* pDoc);
 
 };
 
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 89e1764ffba2..32c331839d3c 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -1,9 +1,42 @@
 #include "namedefdlg.hxx"
 
+#include "document.hxx"
 
-ScNameDefDlg::ScNameDefDlg( Window* pParent ) :
+
+ScNameDefDlg::ScNameDefDlg( Window* pParent, ScDocument* pDoc ) :
     ModalDialog( pParent, ScResId( RID_SCDLG_NAMES_DEFINE) ),
-    maBtnOk( this, ScResId( BTN_OK ) )
+    maBtnAdd( this, ScResId( BTN_ADD ) ),
+    maBtnCancel( this, ScResId( BTN_CANCEL ) ),
+    maFtInfo( this, ScResId( FT_INFO ) ),
+    maFtName( this, ScResId( FT_NAME ) ),
+    maFtRange( this, ScResId( FT_RANGE ) ),
+    maFtScope( this, ScResId( FT_SCOPE ) ),
+    maFlDiv( this, ScResId( FL_DIV ) ),
+    maEdName( this, ScResId( ED_NAME ) ),
+    maEdRange( this, ScResId( ED_RANGE ) ),
+    maLbScope( this, ScResId( LB_SCOPE ) ),
+    maGlobalNameStr( ResId::toString( ScResId( STR_GLOBAL_SCOPE ) ) )
+{
+    // Initialize scope list.
+    maLbScope.InsertEntry(maGlobalNameStr);
+    maLbScope.SelectEntryPos(0);
+    SCTAB n = pDoc->GetTableCount();
+    for (SCTAB i = 0; i < n; ++i)
+    {
+        rtl::OUString aTabName;
+        pDoc->GetName(i, aTabName);
+        maLbScope.InsertEntry(aTabName);
+    }
+    maBtnCancel.SetClickHdl(LINK( this, ScNameDefDlg, CancelBtnHdl));
+}
+
+void ScNameDefDlg::CancelPushed()
 {
+    Close();
+}
 
+IMPL_LINK( ScNameDefDlg, CancelBtnHdl, void*, EMPTYARG)
+{
+    CancelPushed();
+    return 0;
 }
diff --git a/sc/source/ui/src/namedefdlg.src b/sc/source/ui/src/namedefdlg.src
index b6ce245cdd98..26ce3425be9e 100644
--- a/sc/source/ui/src/namedefdlg.src
+++ b/sc/source/ui/src/namedefdlg.src
@@ -7,15 +7,112 @@ ModalDialog RID_SCDLG_NAMES_DEFINE
     HelpId = CMD_FID_ADD_NAME ;
     Hide = TRUE ;
     SVLook = TRUE ;
-    Size = MAP_APPFONT ( 100 , 200 ) ;
-    Text [ en-US ] = "Define Names" ;
+    Size = MAP_APPFONT ( 200 , 100 ) ;
+    Text [ en-US ] = "Define Name" ;
     Moveable = TRUE ;
     Closeable = TRUE;
-    OkButton BTN_OK
+    PushButton BTN_ADD
     {
-        Pos = MAP_APPFONT( 50, 50 );
+        Pos = MAP_APPFONT( 110, 80 );
         Size = MAP_APPFONT( 40, 14 );
         TabStop = TRUE;
+        Text [en-US] = "Add";
+    };
+    PushButton BTN_CANCEL
+    {
+        Pos = MAP_APPFONT( 155, 80 );
+        Size = MAP_APPFONT ( 40, 14 );
+        TabStop = TRUE;
+        Text [en-US] = "Cancel";
+    };
+    FixedText FT_INFO
+    {
+        Pos = MAP_APPFONT( 6, 6 );
+        Size = MAP_APPFONT( 180, 14 );
+        Text [en-US] = "Define the name and range or formula expression.";
+    };
+    FixedText FT_NAME
+    {
+        Pos = MAP_APPFONT( 6, 25 );
+        Size = MAP_APPFONT( 30, 14 );
+        Text [en-US] = "Name";
+    };
+    FixedText FT_RANGE
+    {
+        Pos = MAP_APPFONT( 6, 44 );
+        Size = MAP_APPFONT( 30, 14 );
+        Text [en-US] = "Range";
+    };
+    FixedText FT_SCOPE
+    {
+        Pos = MAP_APPFONT( 6, 63 );
+        Size = MAP_APPFONT( 30, 14 );
+        Text [en-US] = "Scope";
+    };
+    Edit ED_NAME
+    {
+        Border = TRUE;
+        Pos = MAP_APPFONT( 40, 25 );
+        Size = MAP_APPFONT( 150, 14 );
+        TabStop = TRUE;
+    };
+    Edit ED_RANGE
+    {
+        Border = TRUE;
+        Pos = MAP_APPFONT( 40, 44 );
+        Size = MAP_APPFONT( 150, 14 );
+        TabStop = TRUE;
+    };
+    CheckBox BTN_PRINTAREA
+    {
+        HelpID = "sc:CheckBox:RID_SCDLG_NAMES:BTN_PRINTAREA";
+        Pos = MAP_APPFONT ( 6 , 208 ) ;
+        Size = MAP_APPFONT ( 80 , 14 ) ;
+        Text [ en-US ] = "~Print range" ;
+        TabStop = TRUE ;
+    };
+    CheckBox BTN_CRITERIA
+    {
+        HelpID = "sc:CheckBox:RID_SCDLG_NAMES:BTN_CRITERIA";
+        Pos = MAP_APPFONT ( 6 , 223 ) ;
+        Size = MAP_APPFONT ( 60 , 14 ) ;
+        Text [ en-US ] = "~Filter" ;
+        TabStop = TRUE ;
+    };
+    CheckBox BTN_ROWHEADER
+    {
+        HelpID = "sc:CheckBox:RID_SCDLG_NAMES:BTN_ROWHEADER";
+        Pos = MAP_APPFONT ( 110, 223 ) ;
+        Size = MAP_APPFONT ( 82 , 14 ) ;
+        Text [ en-US ] = "Repeat ~row" ;
+        TabStop = TRUE ;
+    };
+    CheckBox BTN_COLHEADER
+    {
+        HelpID = "sc:CheckBox:RID_SCDLG_NAMES:BTN_COLHEADER";
+        Pos = MAP_APPFONT ( 110 , 208 ) ;
+        Size = MAP_APPFONT ( 82 , 14 ) ;
+        Text [ en-US ] = "Repeat ~column" ;
+        TabStop = TRUE ;
+    };
+    ListBox LB_SCOPE
+    {
+        Border = TRUE;
+        Pos = MAP_APPFONT ( 40 , 63 );
+        Size = MAP_APPFONT ( 150 , 80 );
+        TabStop = TRUE;
+        DropDown = TRUE;
+    };
+    FixedLine FL_DIV
+    {
+        Pos = MAP_APPFONT( 0, 75 );
+        Size = MAP_APPFONT(200, 3 );
+    };
 
+    String STR_GLOBAL_SCOPE
+    {
+        Text [ en-US ] = "Document (Global)" ;
     };
+
+
 };
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 0790e987abed..15ff79084aa3 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -119,6 +119,7 @@
 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
 
 #include <boost/scoped_ptr.hpp>
+#include <iostream>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::beans;
@@ -1841,7 +1842,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
             {
                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
 
-                AbstractScNameAddDlg* pDlg = pFact->CreateScNameAddDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_NAMES_DEFINE );
+                std::cout << "Create Dialog in cellsh1.cxx" << std::endl;
+                ScDocument* pDoc = GetViewData()->GetDocument();
+                AbstractScNameAddDlg* pDlg = pFact->CreateScNameAddDlg( pTabViewShell->GetDialogParent(), pDoc, RID_SCDLG_NAMES_DEFINE );
                 pDlg->Execute();
                 delete pDlg;
             }
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 8f69b3d5c302..5146ab7eb502 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -455,7 +455,8 @@ void ScEditShell::Execute( SfxRequest& rReq )
             {
                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
 
-                AbstractScNameAddDlg* pDlg = pFact->CreateScNameAddDlg( pViewData->GetDialogParent(), RID_SCDLG_NAMES_DEFINE );
+                ScDocument* pDoc = pViewData->GetDocument();
+                AbstractScNameAddDlg* pDlg = pFact->CreateScNameAddDlg( pViewData->GetDialogParent(), pDoc, RID_SCDLG_NAMES_DEFINE );
                 pDlg->Execute();
                 delete pDlg;
             }
-- 
cgit