Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


Hoi Kohei and all,

I hope you enjoy the lovely weather.

Hereby a patch to give a better user experience to the "Move/Copy sheet"
dialog.

The changes are:
-   Removed the "Rename"checkbox.
    The "New name" textfield is always available, when one sheet is
selected.
    It is disabled, when multiple sheets are selected.
-   "OK", "Cancel" and "Help" buttons placed at the bottom of the dialog.
-   "Copy" checkbox replaced by "Copy" and "Move" option buttons.
-   Added 3 section headers: "Action", "Location" and "Name".
-   Placed the text "(Current document)" behind the name
    of the of the current document in the list "To document".
-   Display the yellow warning " ! This name is already used", when
applicable.

I did not know a better way to display the warning (I searched several
hours.)

I did not changed the "Insert before" listbox.

I do not display the current sheet name.

MPL 1.1 / GPLv3+ / LGPLv3+, Joost Wezenbeek

Joost
From e4a43859fc768103a64fdc19617190d8728a7332 Mon Sep 17 00:00:00 2001
From: Joost Wezenbeek <joost.eekhoorn@gmail.com>
Date: Tue, 28 Dec 2010 16:07:11 +0100
Subject: [PATCH] New layout Move/Copy sheet in calc

OK, Cancel and Help buttons placed at bottom of the dialog
Copy checkbox changed to Copy/Move option buttons
Sections: Action, Location and Name
Warning: This name is already used.
---
 sc/inc/scabstdlg.hxx               |    1 -
 sc/source/ui/attrdlg/scdlgfact.cxx |    4 --
 sc/source/ui/attrdlg/scdlgfact.hxx |    1 -
 sc/source/ui/inc/miscdlgs.hrc      |    7 +++
 sc/source/ui/inc/mvtabdlg.hxx      |   13 ++++-
 sc/source/ui/miscdlgs/mvtabdlg.cxx |   76 ++++++++++++++++++++++++-------
 sc/source/ui/src/miscdlgs.src      |   88 +++++++++++++++++++++++++++---------
 7 files changed, 143 insertions(+), 47 deletions(-)

diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 0b33261..9a60ab4 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -217,7 +217,6 @@ public:
     virtual void    GetTabNameString( String& rString ) const = 0;
     virtual void       SetCopyTable                    (BOOL bFlag=TRUE) = 0;
     virtual void       EnableCopyTable                 (BOOL bFlag=TRUE) = 0;
-    virtual void       SetRenameTable                  (BOOL bFlag=TRUE) = 0;
     virtual void       EnableRenameTable               (BOOL bFlag=TRUE) = 0;
 };
 
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index bdfdd1a..dae78d1 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -518,10 +518,6 @@ void       AbstractScMoveTableDlg_Impl::EnableCopyTable(BOOL bFlag)
 {
     return pDlg->EnableCopyTable( bFlag);
 }
-void   AbstractScMoveTableDlg_Impl::SetRenameTable(BOOL bFla)
-{
-    return pDlg->SetRenameTable( bFla );
-}
 void   AbstractScMoveTableDlg_Impl::EnableRenameTable(BOOL bFlag)
 {
     return pDlg->EnableRenameTable( bFlag);
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 121b791..dff3c30 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -267,7 +267,6 @@ class AbstractScMoveTableDlg_Impl : public AbstractScMoveTableDlg  //add for ScM
     virtual void    GetTabNameString( String& rString ) const;
     virtual void       SetCopyTable                    (BOOL bFlag=TRUE);
     virtual void       EnableCopyTable                 (BOOL bFlag=TRUE);
-    virtual void       SetRenameTable                  (BOOL bFlag=TRUE);
     virtual void       EnableRenameTable               (BOOL bFlag=TRUE);
 };
 
diff --git a/sc/source/ui/inc/miscdlgs.hrc b/sc/source/ui/inc/miscdlgs.hrc
index 79b5fd0..8b5fed7 100644
--- a/sc/source/ui/inc/miscdlgs.hrc
+++ b/sc/source/ui/inc/miscdlgs.hrc
@@ -98,6 +98,13 @@
 #define LB_INSERT              4
 #define BTN_COPY               5
 #define STR_NEWDOC      6
+#define BTN_MOVE               7
+#define FL_ACTION       8
+#define FL_LOCATION     9
+#define FL_NAME         11
+#define FT_TABNAME      12
+#define FT_WARN         13
+#define STR_CURRENTDOC  14
 
 // Eingabe eines Strings
 #define ED_INPUT               10
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index 3c1b6d2..756a3e3 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -55,21 +55,27 @@ public:
     void    GetTabNameString( String& rString ) const;
     void    SetCopyTable            (BOOL bFlag=TRUE);
     void    EnableCopyTable         (BOOL bFlag=TRUE);
-    void    SetRenameTable          (BOOL bFlag=TRUE);
     void    EnableRenameTable       (BOOL bFlag=TRUE);
 
 private:
     void ResetRenameInput();
+    void CheckNewNameExists();
     ScDocument* GetSelectedDoc();
 
 private:
+    FixedLine       aFlAction;
+    RadioButton                aBtnMove;
+    RadioButton                aBtnCopy;
+    FixedLine       aFlLocation;
     FixedText       aFtDoc;
     ListBox         aLbDoc;
     FixedText       aFtTable;
     ListBox         aLbTable;
-    CheckBox        aBtnCopy;
-    CheckBox        aBtnRename;
+    FixedLine       aFlName;
+    FixedText       aFtTabName;
     Edit            aEdTabName;
+    FixedText       aFtWarn;
+    FixedLine       aFixedLine;
     OKButton        aBtnOk;
     CancelButton    aBtnCancel;
     HelpButton      aBtnHelp;
@@ -87,6 +93,7 @@ private:
     DECL_LINK( OkHdl, void * );
     DECL_LINK( SelHdl, ListBox * );
     DECL_LINK( CheckBtnHdl, void * );
+    DECL_LINK( CheckNameHdl, Edit * );
 };
 
 #include <layout/layout-post.hxx>
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index a5c0118..2b08805 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -61,13 +61,19 @@ ScMoveTableDlg::ScMoveTableDlg( Window*       pParent,
 
     :   ModalDialog ( pParent, ScResId( RID_SCDLG_MOVETAB ) ),
         //
+        aFlAction   ( this, ScResId( FL_ACTION ) ),
+        aBtnMove    ( this, ScResId( BTN_MOVE ) ),
+        aBtnCopy    ( this, ScResId( BTN_COPY ) ),
+        aFlLocation ( this, ScResId( FL_LOCATION ) ),
         aFtDoc      ( this, ScResId( FT_DEST ) ),
         aLbDoc      ( this, ScResId( LB_DEST ) ),
         aFtTable    ( this, ScResId( FT_INSERT ) ),
         aLbTable    ( this, ScResId( LB_INSERT ) ),
-        aBtnCopy    ( this, ScResId( BTN_COPY ) ),
-        aBtnRename  ( this, ScResId( BTN_RENAME ) ),
+        aFlName     ( this, ScResId( FL_NAME ) ),
+        aFtTabName  ( this, ScResId( FT_TABNAME ) ),
         aEdTabName  ( this, ScResId( ED_INPUT ) ),
+        aFtWarn     ( this, ScResId( FT_WARN ) ),
+        aFixedLine  ( this, ScResId( FL_SEP1 ) ),
         aBtnOk      ( this, ScResId( BTN_OK ) ),
         aBtnCancel  ( this, ScResId( BTN_CANCEL ) ),
         aBtnHelp    ( this, ScResId( BTN_HELP ) ),
@@ -120,21 +126,16 @@ void ScMoveTableDlg::EnableCopyTable(BOOL bFlag)
         aBtnCopy.Disable();
 }
 
-void ScMoveTableDlg::SetRenameTable(BOOL bFlag)
-{
-    aBtnRename.Check(bFlag);
-    aEdTabName.Enable(bFlag);
-}
-
 void ScMoveTableDlg::EnableRenameTable(BOOL bFlag)
 {
-    aBtnRename.Enable(bFlag);
+    bRenameTable = bFlag;
+    aEdTabName.Enable(bFlag);
     ResetRenameInput();
 }
 
 void ScMoveTableDlg::ResetRenameInput()
 {
-    if (!aBtnRename.IsEnabled())
+    if (!aEdTabName.IsEnabled())
     {
         aEdTabName.SetText(String());
         return;
@@ -157,6 +158,33 @@ void ScMoveTableDlg::ResetRenameInput()
     else
         // move
         aEdTabName.SetText(mrDefaultName);
+
+    CheckNewNameExists();
+}
+
+void ScMoveTableDlg::CheckNewNameExists()
+{
+    BOOL   bFound = FALSE;
+    USHORT nLast  = aLbTable.GetEntryCount() - 1;
+    for ( USHORT i=0; i<=nLast; ++i )
+    {
+        if ( aEdTabName.GetText() == aLbTable.GetEntry( i ) )
+        {
+            if( ( aBtnMove.IsChecked() ) &&
+                ( aLbDoc.GetSelectEntryPos() == 0 ) &&
+                ( aEdTabName.GetText() == mrDefaultName) )
+
+                // Move inside same document, thus same name is allowed.
+                bFound = FALSE;
+            else
+                bFound = TRUE;
+
+        }
+    }
+    if ( bFound )
+        aFtWarn.Show();
+    else
+            aFtWarn.Hide();
 }
 
 ScDocument* ScMoveTableDlg::GetSelectedDoc()
@@ -172,10 +200,12 @@ void ScMoveTableDlg::Init()
     aBtnOk.SetClickHdl   ( LINK( this, ScMoveTableDlg, OkHdl ) );
     aLbDoc.SetSelectHdl  ( LINK( this, ScMoveTableDlg, SelHdl ) );
     aBtnCopy.SetToggleHdl( LINK( this, ScMoveTableDlg, CheckBtnHdl ) );
-    aBtnRename.SetToggleHdl( LINK( this, ScMoveTableDlg, CheckBtnHdl ) );
+    aEdTabName.SetModifyHdl( LINK( this, ScMoveTableDlg, CheckNameHdl ) );
+    aBtnMove.Check( TRUE );
     aBtnCopy.Check( FALSE );
-    aBtnRename.Check( FALSE );
     aEdTabName.Enable(false);
+    aFtWarn.SetControlBackground( Color( COL_YELLOW ) );
+    aFtWarn.Hide();
     InitDocListBox();
     SelHdl( &aLbDoc );
 }
@@ -188,6 +218,7 @@ void ScMoveTableDlg::InitDocListBox()
     ScDocShell*     pScSh   = NULL;
     USHORT          nSelPos = 0;
     USHORT          i       = 0;
+    String          aEntryName;
 
     aLbDoc.Clear();
     aLbDoc.SetUpdateMode( FALSE );
@@ -198,10 +229,16 @@ void ScMoveTableDlg::InitDocListBox()
 
         if ( pScSh )
         {
+            aEntryName = pScSh->GetTitle();
+
             if ( pScSh == SfxObjectShell::Current() )
+            {
                 nSelPos = i;
+                aEntryName += sal_Unicode( ' ' );
+                aEntryName += String( ScResId( STR_CURRENTDOC ) );
+            }
 
-            aLbDoc.InsertEntry( pScSh->GetTitle(), i );
+            aLbDoc.InsertEntry( aEntryName, i );
             aLbDoc.SetEntryData( i, (void*)pScSh->GetDocument() );
 
             i++;
@@ -219,9 +256,7 @@ void ScMoveTableDlg::InitDocListBox()
 
 IMPL_LINK( ScMoveTableDlg, CheckBtnHdl, void *, pBtn )
 {
-    if (pBtn == &aBtnRename)
-        aEdTabName.Enable( aBtnRename.IsChecked() );
-    else if (pBtn == &aBtnCopy)
+    if (pBtn == &aBtnCopy)
         ResetRenameInput();
 
     return 0;
@@ -237,7 +272,6 @@ IMPL_LINK( ScMoveTableDlg, OkHdl, void *, EMPTYARG )
     nDocument   = (nDocSel != nDocLast) ? nDocSel : SC_DOC_NEW;
     nTable      = (nTabSel != nTabLast) ? static_cast<SCTAB>(nTabSel) : SC_TAB_APPEND;
     bCopyTable  = aBtnCopy.IsChecked();
-    bRenameTable= aBtnRename.IsChecked();
 
     if (bCopyTable)
     {
@@ -291,6 +325,14 @@ IMPL_LINK( ScMoveTableDlg, SelHdl, ListBox *, pLb )
     return 0;
 }
 
+IMPL_LINK( ScMoveTableDlg, CheckNameHdl, Edit *, pEdt )
+{
+    if ( pEdt == &aEdTabName )
+        CheckNewNameExists();
+
+    return 0;
+}
+
 
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src
index 0c3c0db..130a621 100644
--- a/sc/source/ui/src/miscdlgs.src
+++ b/sc/source/ui/src/miscdlgs.src
@@ -439,77 +439,123 @@ ModalDialog RID_SCDLG_MOVETAB
     OutputSize = TRUE ;
     HelpId = FID_TAB_MOVE ;
     SVLook = TRUE ;
-    Size = MAP_APPFONT ( 168 , 145 ) ;
+    Size = MAP_APPFONT ( 158 , 236 ) ;
     Text [ en-US ] = "Move/Copy Sheet" ;
     Moveable = TRUE ;
     Closeable = FALSE ;
     OKButton BTN_OK
     {
-        Pos = MAP_APPFONT ( 112 , 6 ) ;
-        Size = MAP_APPFONT ( 50 , 14 ) ;
+        Pos = MAP_APPFONT ( 66 , 216 ) ;
+        Size = MAP_APPFONT ( 42 , 14 ) ;
         TabStop = TRUE ;
         DefButton = TRUE ;
     };
     CancelButton BTN_CANCEL
     {
-        Pos = MAP_APPFONT ( 112 , 23 ) ;
-        Size = MAP_APPFONT ( 50 , 14 ) ;
+        Pos = MAP_APPFONT ( 110 , 216 ) ;
+        Size = MAP_APPFONT ( 42 , 14 ) ;
         TabStop = TRUE ;
     };
     HelpButton BTN_HELP
     {
-        Pos = MAP_APPFONT ( 112 , 43 ) ;
-        Size = MAP_APPFONT ( 50 , 14 ) ;
+        Pos = MAP_APPFONT ( 6 , 216 ) ;
+        Size = MAP_APPFONT ( 42 , 14 ) ;
+        TabStop = TRUE ;
+    };
+    FixedLine FL_SEP1
+    {
+        Pos = MAP_APPFONT ( 0 , 208 ) ;
+        Size = MAP_APPFONT (168 , 4 ) ;
+    };
+    FixedLine FL_ACTION
+    {
+        Pos = MAP_APPFONT ( 6 , 3 ) ;
+        Size = MAP_APPFONT ( 146 , 8 ) ;
+        Text [ en-US ] = "Action" ;
+    };
+    RadioButton BTN_MOVE
+    {
+        Pos = MAP_APPFONT ( 12 , 14 ) ;
+        Size = MAP_APPFONT ( 114 , 10 ) ;
+        Text [ en-US ] = "~Move" ;
+        TabStop = TRUE ;
+    };
+    RadioButton BTN_COPY
+    {
+        Pos = MAP_APPFONT ( 12 , 28 ) ;
+        Size = MAP_APPFONT ( 114 , 10 ) ;
+        Text [ en-US ] = "~Copy" ;
         TabStop = TRUE ;
     };
+    FixedLine FL_LOCATION
+    {
+        Pos = MAP_APPFONT ( 6 , 42 ) ;
+        Size = MAP_APPFONT ( 146 , 8 ) ;
+        Text [ en-US ] = "Location" ;
+    };
     FixedText FT_DEST
     {
-        Pos = MAP_APPFONT ( 6 , 6 ) ;
+        Pos = MAP_APPFONT ( 12 , 53 ) ;
         Size = MAP_APPFONT ( 100 , 8 ) ;
         Text [ en-US ] = "To ~document" ;
     };
     ListBox LB_DEST
     {
         Border = TRUE ;
-        Pos = MAP_APPFONT ( 6 , 17 ) ;
-        Size = MAP_APPFONT ( 100 , 60 ) ;
+        Pos = MAP_APPFONT ( 12 , 64 ) ;
+        Size = MAP_APPFONT ( 120 , 60 ) ;
         TabStop = TRUE ;
         DropDown = TRUE ;
     };
     FixedText FT_INSERT
     {
-        Pos = MAP_APPFONT ( 6 , 35 ) ;
+        Pos = MAP_APPFONT ( 12 , 83 ) ;
         Size = MAP_APPFONT ( 100 , 8 ) ;
         Text [ en-US ] = "~Insert before" ;
     };
     ListBox LB_INSERT
     {
         Border = TRUE ;
-        Pos = MAP_APPFONT ( 6 , 46 ) ;
-        Size = MAP_APPFONT ( 100 , 62 ) ;
+        Pos = MAP_APPFONT ( 12 , 93 ) ;
+        Size = MAP_APPFONT ( 120 , 62 ) ;
         TabStop = TRUE ;
     };
-    CheckBox BTN_COPY
+    FixedLine FL_NAME
     {
-        Pos = MAP_APPFONT ( 6 , 114 ) ;
-        Size = MAP_APPFONT ( 100 , 10 ) ;
-        Text [ en-US ] = "~Copy" ;
-        TabStop = TRUE ;
+        Pos = MAP_APPFONT ( 6 , 162 ) ;
+        Size = MAP_APPFONT ( 146 , 8 ) ;
+        Text [ en-US ] = "Name" ;
     };
     CheckBox BTN_RENAME
     {
-        Pos = MAP_APPFONT ( 6 , 128 ) ;
+        Pos = MAP_APPFONT ( 6 , 189 ) ;
         Size = MAP_APPFONT ( 52 , 10 ) ;
         Text [ en-US ] = "~Rename" ;
         TabStop = TRUE ;
     };
+    FixedText FT_TABNAME
+    {
+        Pos = MAP_APPFONT ( 12 , 173 ) ;
+        Size = MAP_APPFONT ( 100 , 8 ) ;
+        Text [ en-US ] = "New ~name" ;
+    };
     Edit ED_INPUT
     {
         Border = TRUE ;
-        Pos = MAP_APPFONT ( 58 , 127 ) ;
-        Size = MAP_APPFONT ( 104 , 12 ) ;
+        Pos = MAP_APPFONT ( 12 , 183 ) ;
+        Size = MAP_APPFONT ( 120 , 12 ) ;
         TabStop = TRUE ;
     };
+    FixedText FT_WARN
+    {
+        Pos = MAP_APPFONT ( 24 , 194 ) ;
+        Size = MAP_APPFONT ( 122 , 8 ) ;
+        Text [ en-US ] = " ! This name is already used." ;
+    };
+    String STR_CURRENTDOC
+    {
+        Text [ en-US ] = "(Current document)" ;
+    };
     String STR_NEWDOC
     {
         Text [ en-US ] = "- new document -" ;
-- 
1.7.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.