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


Hi,

Please review if this patch is realy correct and complete.

- 'Rename input box' is only visible when 'Rename check box' is checked.
- Rename is only done when 'Rename check box' is checked and 'Rename input
box'
has a string.
- Rename works for copied and moved sheets.
- Rename works when the target is the same document, a new document or a
other existing document.

I did not know how test the automation part in source/ui/view/viewfun2.cxx

And check if String() in correct in ExecuteDrop() in
sc/source/ui/view/tabcont.cxx

What must I did with move-copy-sheet.xml (on 2 places!).

Must the help be adapted? How/where must that be done?

Joost
From 6125b12150b1eabb66d83029b3da912e34e24a7d Mon Sep 17 00:00:00 2001
From: Joost Wezenbeek <joost.eekhoorn@gmail.com>
Date: Fri, 10 Dec 2010 20:03:11 +0100
Subject: [PATCH] Change Sheet copy process

Easy Hacks 3.27
Added rename in Move/Copy Sheet in calc
---
 sc/inc/scabstdlg.hxx               |    2 +
 sc/source/ui/attrdlg/scdlgfact.cxx |    8 ++++++
 sc/source/ui/attrdlg/scdlgfact.hxx |    2 +
 sc/source/ui/inc/mvtabdlg.hxx      |   10 ++++++++
 sc/source/ui/inc/viewfunc.hxx      |    2 +-
 sc/source/ui/miscdlgs/mvtabdlg.cxx |   42 +++++++++++++++++++++++++++++++++++-
 sc/source/ui/src/miscdlgs.src      |   22 ++++++++++++++++++-
 sc/source/ui/view/tabcont.cxx      |    2 +-
 sc/source/ui/view/tabvwshf.cxx     |   16 ++++++++++++-
 sc/source/ui/view/viewfun2.cxx     |   20 +++++++++++++++-
 10 files changed, 119 insertions(+), 7 deletions(-)

diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index e880df8..dc20e8f 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -213,6 +213,8 @@ public:
     virtual USHORT     GetSelectedDocument             () const = 0;
     virtual USHORT     GetSelectedTable                () const = 0;
     virtual BOOL       GetCopyTable                    () const = 0;
+    virtual BOOL       GetRenameTable                  () const = 0;
+    virtual void    GetTabNameString( String& rString ) const = 0;
     virtual void       SetCopyTable                    (BOOL bFlag=TRUE) = 0;
     virtual void       EnableCopyTable                 (BOOL bFlag=TRUE) = 0;
 };
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index fa14720..5a78eae 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -502,6 +502,14 @@ BOOL       AbstractScMoveTableDlg_Impl::GetCopyTable() const
 {
     return pDlg->GetCopyTable();
 }
+BOOL   AbstractScMoveTableDlg_Impl::GetRenameTable() const
+{
+    return pDlg->GetRenameTable();
+}
+void   AbstractScMoveTableDlg_Impl::GetTabNameString( String& rString ) const
+{
+    pDlg->GetTabNameString( rString );
+}
 void   AbstractScMoveTableDlg_Impl::SetCopyTable(BOOL bFla)
 {
     return pDlg->SetCopyTable( bFla );
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index f1ec2a5..dc583a6 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -263,6 +263,8 @@ class AbstractScMoveTableDlg_Impl : public AbstractScMoveTableDlg  //add for ScM
     virtual USHORT     GetSelectedDocument             () const;
     virtual USHORT     GetSelectedTable                () const;
     virtual BOOL       GetCopyTable                    () const;
+    virtual BOOL       GetRenameTable                  () const;
+    virtual void    GetTabNameString( String& rString ) const;
     virtual void       SetCopyTable                    (BOOL bFlag=TRUE);
     virtual void       EnableCopyTable                 (BOOL bFlag=TRUE);
 };
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index 1260737..543fa01 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -35,6 +35,7 @@
 #include <vcl/imagebtn.hxx>
 #include <vcl/lstbox.hxx>
 #include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
 
 #include <layout/layout.hxx>
 #include <layout/layout-pre.hxx>
@@ -50,8 +51,12 @@ public:
     USHORT     GetSelectedDocument             () const;
     SCTAB      GetSelectedTable                () const;
     BOOL       GetCopyTable                    () const;
+    BOOL       GetRenameTable                  () const;
+    void    GetTabNameString( String& rString ) const;
     void       SetCopyTable                    (BOOL bFlag=TRUE);
     void       EnableCopyTable                 (BOOL bFlag=TRUE);
+    void       SetRenameTable                  (BOOL bFlag=TRUE);
+    void       SetTabNameVisible               (BOOL bFlag=TRUE);
 
 private:
     FixedText          aFtDoc;
@@ -59,6 +64,9 @@ private:
     FixedText          aFtTable;
     ListBox                    aLbTable;
     CheckBox           aBtnCopy;
+    CheckBox           aBtnRename;
+    FixedText          aFtTabName;
+    Edit               aEdTabName;
     OKButton           aBtnOk;
     CancelButton       aBtnCancel;
     HelpButton         aBtnHelp;
@@ -66,11 +74,13 @@ private:
     USHORT                     nDocument;
     SCTAB                      nTable;
     BOOL                       bCopyTable;
+    BOOL                       bRenameTable;
     //--------------------------------------
     void       Init                    ();
     void       InitDocListBox  ();
     DECL_LINK( OkHdl, void * );
     DECL_LINK( SelHdl, ListBox * );
+    DECL_LINK( RenameHdl, void * );
 };
 
 #include <layout/layout-post.hxx>
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 0cacc54..e8ed808 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -272,7 +272,7 @@ public:
     BOOL                       DeleteTables(const SvShorts &TheTabs, BOOL bRecord = TRUE );
 
     BOOL                       RenameTable( const String& rName, SCTAB nTabNr );
-    void                       MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy );
+    void                       MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const 
String& rName );
     void                       ImportTables( ScDocShell* pSrcShell,
                                     SCTAB nCount, const SCTAB* pSrcTabs,
                                     BOOL bLink,SCTAB nTab);
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index a000b1d..6de8234 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -65,13 +65,17 @@ ScMoveTableDlg::ScMoveTableDlg( Window* pParent )
         aFtTable    ( this, ScResId( FT_INSERT ) ),
         aLbTable    ( this, ScResId( LB_INSERT ) ),
         aBtnCopy    ( this, ScResId( BTN_COPY ) ),
+        aBtnRename  ( this, ScResId( BTN_RENAME ) ),
+        aFtTabName  ( this, ScResId( FT_LABEL ) ),
+        aEdTabName     ( this, ScResId( ED_INPUT ) ),
         aBtnOk      ( this, ScResId( BTN_OK ) ),
         aBtnCancel  ( this, ScResId( BTN_CANCEL ) ),
         aBtnHelp    ( this, ScResId( BTN_HELP ) ),
         //
         nDocument   ( 0 ),
         nTable      ( 0 ),
-        bCopyTable  ( FALSE )
+        bCopyTable  ( FALSE ),
+        bRenameTable( FALSE )
 {
 #if ENABLE_LAYOUT
 #undef ScResId
@@ -95,6 +99,13 @@ SCTAB ScMoveTableDlg::GetSelectedTable    () const { return nTable;     }
 
 BOOL   ScMoveTableDlg::GetCopyTable        () const { return bCopyTable; }
 
+BOOL   ScMoveTableDlg::GetRenameTable        () const { return bRenameTable; }
+
+void ScMoveTableDlg::GetTabNameString( String& rString ) const
+{
+    rString = aEdTabName.GetText();
+}
+
 void ScMoveTableDlg::SetCopyTable(BOOL bFlag)
 {
     aBtnCopy.Check(bFlag);
@@ -107,6 +118,24 @@ void ScMoveTableDlg::EnableCopyTable(BOOL bFlag)
         aBtnCopy.Disable();
 }
 
+void ScMoveTableDlg::SetRenameTable(BOOL bFlag)
+{
+    aBtnRename.Check(bFlag);
+    SetTabNameVisible(bFlag);
+}
+
+void ScMoveTableDlg::SetTabNameVisible(BOOL bFlag)
+{
+    if(bFlag)
+    {
+        aFtTabName.Show();
+        aEdTabName.Show();
+    } else
+    {
+        aFtTabName.Hide();
+        aEdTabName.Hide();
+    }
+}
 
 //------------------------------------------------------------------------
 
@@ -114,7 +143,10 @@ void __EXPORT ScMoveTableDlg::Init()
 {
     aBtnOk.SetClickHdl   ( LINK( this, ScMoveTableDlg, OkHdl ) );
     aLbDoc.SetSelectHdl  ( LINK( this, ScMoveTableDlg, SelHdl ) );
+    aBtnRename.SetToggleHdl( LINK( this, ScMoveTableDlg, RenameHdl ) );
     aBtnCopy.Check( FALSE );
+    aBtnRename.Check( FALSE );
+    SetTabNameVisible( FALSE );
     InitDocListBox();
     SelHdl( &aLbDoc );
 }
@@ -157,6 +189,13 @@ void ScMoveTableDlg::InitDocListBox()
 //------------------------------------------------------------------------
 // Handler:
 
+IMPL_LINK( ScMoveTableDlg, RenameHdl, void *, EMPTYARG )
+{
+    SetTabNameVisible( aBtnRename.IsChecked() );
+
+    return 0;
+}
+
 IMPL_LINK( ScMoveTableDlg, OkHdl, void *, EMPTYARG )
 {
     USHORT  nDocSel     = aLbDoc.GetSelectEntryPos();
@@ -167,6 +206,7 @@ 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();
     EndDialog( RET_OK );
 
     return 0;
diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src
index b16de65..49bda22 100644
--- a/sc/source/ui/src/miscdlgs.src
+++ b/sc/source/ui/src/miscdlgs.src
@@ -439,7 +439,7 @@ ModalDialog RID_SCDLG_MOVETAB
     OutputSize = TRUE ;
     HelpId = FID_TAB_MOVE ;
     SVLook = TRUE ;
-    Size = MAP_APPFONT ( 168 , 130 ) ;
+    Size = MAP_APPFONT ( 168 , 180 ) ;
     Text [ en-US ] = "Move/Copy Sheet" ;
     Moveable = TRUE ;
     Closeable = FALSE ;
@@ -496,6 +496,26 @@ ModalDialog RID_SCDLG_MOVETAB
         Text [ en-US ] = "~Copy" ;
         TabStop = TRUE ;
     };
+    CheckBox BTN_RENAME
+    {
+        Pos = MAP_APPFONT ( 6 , 124 ) ;
+        Size = MAP_APPFONT ( 100 , 10 ) ;
+        Text [ en-US ] = "~Rename" ;
+        TabStop = TRUE ;
+    };
+    FixedText FT_LABEL
+    {
+        Pos = MAP_APPFONT ( 6 , 137 ) ;
+        Size = MAP_APPFONT ( 100 , 8 ) ;
+        Text [ en-US ] = "New ~name" ;
+    };
+    Edit ED_INPUT
+    {
+        Border = TRUE ;
+        Pos = MAP_APPFONT ( 6 , 149 ) ;
+        Size = MAP_APPFONT ( 110 , 12 ) ;
+        TabStop = TRUE ;
+    };
     String STR_NEWDOC
     {
         Text [ en-US ] = "- new document -" ;
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index 14d0a33..b56fc42 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -552,7 +552,7 @@ sal_Int8 ScTabControl::ExecuteDrop( const ExecuteDropEvent& rEvt )
             if ( !pDoc->GetChangeTrack() && pDoc->IsDocEditable() )
             {
                 //! use table selection from the tab control where dragging was started?
-                pViewData->GetView()->MoveTable( lcl_DocShellNr(pDoc), nPos, rEvt.mnAction != 
DND_ACTION_MOVE );
+                pViewData->GetView()->MoveTable( lcl_DocShellNr(pDoc), nPos, rEvt.mnAction != 
DND_ACTION_MOVE, String() );
 
                 rData.pCellTransfer->SetDragWasInternal();          // don't delete
                 return TRUE;
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index e38cb88..2fe2758 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -478,7 +478,9 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                 USHORT nDoc = 0;
                 SCTAB nTab = pViewData->GetTabNo();
                 BOOL   bCpy = FALSE;
+                BOOL   bRna = FALSE;
                 String aDocName;
+                String aTabName;
 
                 if( pReqArgs != NULL )
                 {
@@ -497,6 +499,12 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                     if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
                         bCpy = ((const SfxBoolItem*)pItem)->GetValue();
 
+#if 0
+// This must be checked:
+                    if( IS_AVAILABLE( FN_PARAM_3, &pItem ) )
+                        aTabName = ((const SfxStringItem*)pItem)->GetValue();
+#endif
+
                     if( aDocName.Len() )
                     {
                         SfxObjectShell* pSh            = SfxObjectShell::GetFirst();
@@ -557,6 +565,12 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                         nDoc = pDlg->GetSelectedDocument();
                         nTab = pDlg->GetSelectedTable();
                         bCpy = pDlg->GetCopyTable();
+                        bRna = pDlg->GetRenameTable();
+                        // Leave aTabName string empty, when Rename is FALSE.
+                        if( bRna )
+                        {
+                           pDlg->GetTabNameString( aTabName );
+                        }
                         bDoIt = TRUE;
 
                         String aFoundDocName;
@@ -586,7 +600,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                 {
                     rReq.Done();               // aufzeichnen, solange das Dokument noch aktiv ist
 
-                    MoveTable( nDoc, nTab, bCpy );
+                    MoveTable( nDoc, nTab, bCpy, aTabName );
                 }
             }
             break;
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 04ebe2d..95bbe70 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2547,7 +2547,7 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
 //----------------------------------------------------------------------------
 //     Tabelle in anderes Dokument verschieben / kopieren
 
-void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy )
+void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const String& rName )
 {
     ScDocument* pDoc      = GetViewData()->GetDocument();
     ScDocShell* pDocShell  = GetViewData()->GetDocShell();
@@ -2649,7 +2649,11 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy )
         for( USHORT j=0; j<TheTabs.Count(); j++, nDestTab1++ )
         {      // #63304# insert sheets first and update all references
             String aName;
-            pDoc->GetName( TheTabs[j], aName );
+            if( rName.Len() )
+                aName = rName;
+            else
+                pDoc->GetName( TheTabs[j], aName );
+
             pDestDoc->CreateValidTabName( aName );
             if ( !pDestDoc->InsertTab( nDestTab1, aName ) )
             {
@@ -2829,6 +2833,18 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy )
             delete pString;
         }
 
+        // Rename must be done after that all sheets have been moved.
+        if( rName.Len() )
+        {
+            for(int j=0;j<TheDestTabs.Count();j++)
+            {
+                SCTAB nRenameTab = static_cast<SCTAB>(TheDestTabs[j]);
+                String aTabName( rName);
+                pDoc->CreateValidTabName( aTabName );
+                pDocShell->GetDocFunc().RenameTable( nRenameTab, aTabName, TRUE, FALSE );
+            }
+        }
+
         nTab = GetViewData()->GetTabNo();
 
         if (bUndo)
-- 
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.