[Libreoffice-commits] .: 12 commits - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Dec 13 20:46:01 PST 2010


 sc/inc/scabstdlg.hxx               |    8 ++
 sc/source/ui/attrdlg/scdlgfact.cxx |   23 ++++++-
 sc/source/ui/attrdlg/scdlgfact.hxx |    9 ++
 sc/source/ui/inc/mvtabdlg.hxx      |   54 +++++++++++------
 sc/source/ui/inc/undotab.hxx       |   22 +++++--
 sc/source/ui/inc/viewfunc.hxx      |    2 
 sc/source/ui/miscdlgs/mvtabdlg.cxx |  113 +++++++++++++++++++++++++++++++++----
 sc/source/ui/src/miscdlgs.src      |   16 ++++-
 sc/source/ui/undo/undotab.cxx      |   47 +++++++++++++--
 sc/source/ui/view/tabvwshf.cxx     |   21 ++++++
 sc/source/ui/view/viewfun2.cxx     |   72 +++++++++++++++++------
 11 files changed, 316 insertions(+), 71 deletions(-)

New commits:
commit 139726734ba6ed653ee0b8c1186b3c65190e8759
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 23:30:36 2010 -0500

    When the name equals the automatically assigned one, remove it.
    
    This prevents e.g. copying Sheet1 with the default name of Sheet1_2
    from being renamed to Sheet1_2_2.

diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index 18d1c7d..a5c0118 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -239,9 +239,24 @@ IMPL_LINK( ScMoveTableDlg, OkHdl, void *, EMPTYARG )
     bCopyTable  = aBtnCopy.IsChecked();
     bRenameTable= aBtnRename.IsChecked();
 
-    // Return an empty string, when the new name is the same as the original name.
-    if( mrDefaultName == aEdTabName.GetText() )
-        aEdTabName.SetText( String() );
+    if (bCopyTable)
+    {
+        // Return an empty string when the new name is the same as the
+        // automatic name assigned by the document.
+        String aCopyName = mrDefaultName;
+        ScDocument* pDoc = GetSelectedDoc();
+        if (pDoc)
+            pDoc->CreateValidTabName(aCopyName);
+        if (aCopyName == aEdTabName.GetText())
+            aEdTabName.SetText( String() );
+    }
+    else
+    {
+        // Return an empty string, when the new name is the same as the
+        // original name.
+        if( mrDefaultName == aEdTabName.GetText() )
+            aEdTabName.SetText( String() );
+    }
 
     EndDialog( RET_OK );
 
commit 0e405c692ad036fead59aa80974e65e499005f32
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 23:16:28 2010 -0500

    Properly support redo of renamed sheet copy.

diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx
index 90a75e3..5d46136 100644
--- a/sc/source/ui/inc/undotab.hxx
+++ b/sc/source/ui/inc/undotab.hxx
@@ -211,9 +211,11 @@ class ScUndoCopyTab: public ScSimpleUndo
 {
 public:
                     TYPEINFO();
-                    ScUndoCopyTab(ScDocShell* pNewDocShell,
-                                  const SvShorts &aOldTab,
-                                  const SvShorts &aNewTab);
+                    ScUndoCopyTab(
+                        ScDocShell* pNewDocShell,
+                        const SvShorts &aOldTab,
+                        const SvShorts &aNewTab,
+                        ::std::vector< ::rtl::OUString>* pNewNames = NULL );
 
     virtual			~ScUndoCopyTab();
 
@@ -225,6 +227,7 @@ public:
     virtual String	GetComment() const;
 
 private:
+    ::boost::shared_ptr< ::std::vector< ::rtl::OUString> > mpNewNames;
     SdrUndoAction*	pDrawUndo;
     SvShorts	theOldTabs;
     SvShorts	theNewTabs;
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index ba8cbef..65c7f67 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -657,10 +657,11 @@ BOOL ScUndoMoveTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
 //		Tabelle kopieren
 //
 
-ScUndoCopyTab::ScUndoCopyTab( ScDocShell* pNewDocShell,
-                                  const SvShorts &aOldTab,
-                                  const SvShorts &aNewTab) :
+ScUndoCopyTab::ScUndoCopyTab(
+    ScDocShell* pNewDocShell, const SvShorts &aOldTab, const SvShorts &aNewTab,
+    vector<OUString>* pNewNames) :
     ScSimpleUndo( pNewDocShell ),
+    mpNewNames(pNewNames),
     pDrawUndo( NULL )
 {
     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
@@ -671,6 +672,10 @@ ScUndoCopyTab::ScUndoCopyTab( ScDocShell* pNewDocShell,
 
     for(i=0;i<aNewTab.Count();i++)
         theNewTabs.Insert(aNewTab[sal::static_int_cast<USHORT>(i)],theNewTabs.Count());
+
+    if (mpNewNames && theNewTabs.Count() != mpNewNames->size())
+        // The sizes differ.  Something is wrong.
+        mpNewNames.reset();
 }
 
 ScUndoCopyTab::~ScUndoCopyTab()
@@ -770,6 +775,12 @@ void ScUndoCopyTab::Redo()
 
         if ( pDoc->IsTabProtected( nAdjSource ) )
             pDoc->CopyTabProtection(nAdjSource, nNewTab);
+
+        if (mpNewNames)
+        {
+            const OUString& rName = (*mpNewNames)[i];
+            pDoc->RenameTab(nNewTab, rName);
+        }
     }
 
     RedoSdrUndoAction( pDrawUndo );             // after the sheets are inserted
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 22d43da..8b923c7 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2865,7 +2865,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
             if (bCopy)
             {
                 pDocShell->GetUndoManager()->AddUndoAction(
-                        new ScUndoCopyTab( pDocShell, TheTabs, TheDestTabs));
+                        new ScUndoCopyTab( pDocShell, TheTabs, TheDestTabs, pDestNames.release()));
             }
             else
             {
commit bc1fddc43a67193b3d97b0d3a2d5dbeba62581d6
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 23:06:26 2010 -0500

    Properly support undo and redo when moving sheets.

diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx
index d725386..90a75e3 100644
--- a/sc/source/ui/inc/undotab.hxx
+++ b/sc/source/ui/inc/undotab.hxx
@@ -51,7 +51,9 @@
 
 #include <com/sun/star/uno/Sequence.hxx>
 
+#include <boost/shared_ptr.hpp>
 #include <memory>
+#include <vector>
 
 class ScDocShell;
 class ScDocument;
@@ -180,9 +182,12 @@ class ScUndoMoveTab: public ScSimpleUndo
 {
 public:
                     TYPEINFO();
-                    ScUndoMoveTab( ScDocShell* pNewDocShell,
-                                  const SvShorts &aOldTab,
-                                  const SvShorts &aNewTab);
+                    ScUndoMoveTab(
+                        ScDocShell* pNewDocShell,
+                        const SvShorts &aOldTab, const SvShorts &aNewTab,
+                        ::std::vector< ::rtl::OUString>* pOldNames = NULL,
+                        ::std::vector< ::rtl::OUString>* pNewNames = NULL );
+
     virtual			~ScUndoMoveTab();
 
     virtual void	Undo();
@@ -193,6 +198,8 @@ public:
     virtual String	GetComment() const;
 
 private:
+    ::boost::shared_ptr< ::std::vector< ::rtl::OUString> > mpOldNames;
+    ::boost::shared_ptr< ::std::vector< ::rtl::OUString> > mpNewNames;
     SvShorts	theOldTabs;
     SvShorts	theNewTabs;
 
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index f32a335..ba8cbef 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -61,7 +61,10 @@ extern BOOL bDrawIsInUndo;			//! irgendwo als Member !!!
 
 using namespace com::sun::star;
 using ::com::sun::star::uno::Sequence;
+using ::rtl::OUString;
 using ::std::auto_ptr;
+using ::std::vector;
+using ::boost::shared_ptr;
 
 // STATIC DATA -----------------------------------------------------------
 
@@ -543,10 +546,11 @@ BOOL ScUndoRenameTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
 //		Tabelle verschieben
 //
 
-ScUndoMoveTab::ScUndoMoveTab( ScDocShell* pNewDocShell,
-                                  const SvShorts &aOldTab,
-                                  const SvShorts &aNewTab) :
-    ScSimpleUndo( pNewDocShell )
+ScUndoMoveTab::ScUndoMoveTab(
+    ScDocShell* pNewDocShell, const SvShorts &aOldTab, const SvShorts &aNewTab,
+    vector<OUString>* pOldNames, vector<OUString>* pNewNames) :
+    ScSimpleUndo( pNewDocShell ),
+    mpOldNames(pOldNames), mpNewNames(pNewNames)
 {
     int i;
     for(i=0;i<aOldTab.Count();i++)
@@ -554,6 +558,14 @@ ScUndoMoveTab::ScUndoMoveTab( ScDocShell* pNewDocShell,
 
     for(i=0;i<aNewTab.Count();i++)
         theNewTabs.Insert(aNewTab[sal::static_int_cast<USHORT>(i)],theNewTabs.Count());
+
+    if (mpOldNames && theOldTabs.Count() != mpOldNames->size())
+        // The sizes differ.  Something is wrong.
+        mpOldNames.reset();
+
+    if (mpNewNames && theNewTabs.Count() != mpNewNames->size())
+        // The sizes differ.  Something is wrong.
+        mpNewNames.reset();
 }
 
 ScUndoMoveTab::~ScUndoMoveTab()
@@ -584,6 +596,11 @@ void ScUndoMoveTab::DoChange( BOOL bUndo ) const
             pDoc->MoveTab( nDestTab, nOldTab );
             pViewShell->GetViewData()->MoveTab( nDestTab, nOldTab );
             pViewShell->SetTabNo( nOldTab, TRUE );
+            if (mpOldNames)
+            {
+                const OUString& rOldName = (*mpOldNames)[i];
+                pDoc->RenameTab(nOldTab, rOldName);
+            }
         }
     }
     else
@@ -599,6 +616,11 @@ void ScUndoMoveTab::DoChange( BOOL bUndo ) const
             pDoc->MoveTab( nOldTab, nNewTab );
             pViewShell->GetViewData()->MoveTab( nOldTab, nNewTab );
             pViewShell->SetTabNo( nDestTab, TRUE );
+            if (mpNewNames)
+            {
+                const OUString& rNewName = (*mpNewNames)[i];
+                pDoc->RenameTab(nNewTab, rNewName);
+            }
         }
     }
 
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 848989e..22d43da 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -56,7 +56,6 @@
 #include <basic/sbstar.hxx>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/script/XLibraryContainer.hpp>
-using namespace com::sun::star;
 
 #include "viewfunc.hxx"
 
@@ -98,11 +97,16 @@ using namespace com::sun::star;
 #include <com/sun/star/script/XLibraryContainer.hpp>
 
 #include <boost/scoped_ptr.hpp>
+#include <vector>
+#include <memory>
 
 using namespace com::sun::star;
 using ::rtl::OUStringBuffer;
 using ::rtl::OUString;
 
+using ::std::vector;
+using ::std::auto_ptr;
+
 // helper func defined in docfunc.cxx
 void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName );
 
@@ -2761,9 +2765,10 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
 
         SvShorts	TheTabs;
         SvShorts	TheDestTabs;
-        SvStrings	TheTabNames;
+        auto_ptr< vector<OUString> > pTabNames(new vector<OUString>);
+        auto_ptr< vector<OUString> > pDestNames(NULL);
+        pTabNames->reserve(nTabCount);
         String		aDestName;
-        const String* pString;
 
         for(SCTAB i=0;i<nTabCount;i++)
         {
@@ -2771,19 +2776,18 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
             {
                 String aTabName;
                 pDoc->GetName( i, aTabName);
-                TheTabNames.Insert(new String(aTabName),TheTabNames.Count());
+                pTabNames->push_back(aTabName);
 
                 for(SCTAB j=i+1;j<nTabCount;j++)
                 {
                     if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j)))
                     {
                         pDoc->GetName( j, aTabName);
-                        TheTabNames.Insert(new String(aTabName),TheTabNames.Count());
+                        pTabNames->push_back(aTabName);
                         i=j;
                     }
                     else break;
                 }
-
             }
         }
 
@@ -2793,11 +2797,11 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
         pDoc->GetName( nDestTab, aDestName);
         SCTAB nDestTab1=nDestTab;
         SCTAB nMovTab=0;
-        for(int j=0;j<TheTabNames.Count();j++)
+        for (size_t j = 0, n = pTabNames->size(); j < n; ++j)
         {
             nTabCount	= pDoc->GetTableCount();
-            pString=TheTabNames[sal::static_int_cast<USHORT>(j)];
-            if(!pDoc->GetTable(*pString,nMovTab))
+            const OUString& rStr = (*pTabNames)[j];
+            if(!pDoc->GetTable(rStr,nMovTab))
             {
                 nMovTab=nTabCount;
             }
@@ -2826,27 +2830,33 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
 
             if(!bCopy)
             {
-                if(!pDoc->GetTable(*pString,nDestTab1))
+                if(!pDoc->GetTable(rStr,nDestTab1))
                 {
                     nDestTab1=nTabCount;
                 }
             }
 
             TheDestTabs.Insert(nDestTab1,TheDestTabs.Count());
-            delete pString;
         }
 
-        // Rename must be done after that all sheets have been moved.
+        // Rename must be done after all sheets have been moved.
         if (bRename)
         {
-            for(int j=0;j<TheDestTabs.Count();j++)
+            pDestNames.reset(new vector<OUString>);
+            size_t n = TheDestTabs.Count();
+            pDestNames->reserve(n);
+            for (size_t j = 0; j < n; ++j)
             {
                 SCTAB nRenameTab = static_cast<SCTAB>(TheDestTabs[j]);
                 String aTabName = *pNewTabName;
                 pDoc->CreateValidTabName( aTabName );
-                pDocShell->GetDocFunc().RenameTable( nRenameTab, aTabName, false, false );
+                pDestNames->push_back(aTabName);
+                pDoc->RenameTab(nRenameTab, aTabName);
             }
         }
+        else
+            // No need to keep this around when we are not renaming.
+            pTabNames.reset();
 
         nTab = GetViewData()->GetTabNo();
 
@@ -2860,7 +2870,8 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
             else
             {
                 pDocShell->GetUndoManager()->AddUndoAction(
-                        new ScUndoMoveTab( pDocShell, TheTabs, TheDestTabs));
+                        new ScUndoMoveTab(
+                            pDocShell, TheTabs, TheDestTabs, pTabNames.release(), pDestNames.release()));
             }
         }
 
commit a710124689874ed3f0857ba76c6eb2b7b7cb1b82
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 21:43:04 2010 -0500

    A little code cleanups.

diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 95158e9..98107ea 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, const String* pName = NULL );
+    void			MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const String* pNewTabName = NULL );
     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 d9381ae..18d1c7d 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -128,14 +128,18 @@ void ScMoveTableDlg::SetRenameTable(BOOL bFlag)
 
 void ScMoveTableDlg::EnableRenameTable(BOOL bFlag)
 {
-    if( bFlag )
-        aBtnRename.Enable();
-    else
-        aBtnRename.Disable();
+    aBtnRename.Enable(bFlag);
+    ResetRenameInput();
 }
 
 void ScMoveTableDlg::ResetRenameInput()
 {
+    if (!aBtnRename.IsEnabled())
+    {
+        aEdTabName.SetText(String());
+        return;
+    }
+
     bool bVal = aBtnCopy.IsChecked();
     if (bVal)
     {
@@ -174,7 +178,6 @@ void ScMoveTableDlg::Init()
     aEdTabName.Enable(false);
     InitDocListBox();
     SelHdl( &aLbDoc );
-    ResetRenameInput();
 }
 
 //------------------------------------------------------------------------
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index 56d9b5e..497a4c0 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -558,10 +558,11 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                         pDlg->SetCopyTable();
                         pDlg->EnableCopyTable(FALSE);
                     }
-                    if(nTabSelCount != 1)
-                    {
-                        pDlg->EnableRenameTable(FALSE);
-                    }
+
+                    // We support direct renaming of sheet only when one sheet
+                    // is selected.
+                    pDlg->EnableRenameTable(nTabSelCount == 1);
+
                     if ( pDlg->Execute() == RET_OK )
                     {
                         nDoc = pDlg->GetSelectedDocument();
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 21e7194..848989e 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2543,7 +2543,7 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
 //----------------------------------------------------------------------------
 //	Tabelle in anderes Dokument verschieben / kopieren
 
-void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const String* pName )
+void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const String* pNewTabName )
 {
     ScDocument* pDoc	   = GetViewData()->GetDocument();
     ScDocShell* pDocShell  = GetViewData()->GetDocShell();
@@ -2551,6 +2551,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
     ScDocShell* pDestShell = NULL;
     ScTabViewShell* pDestViewSh = NULL;
     BOOL bUndo (pDoc->IsUndoEnabled());
+    bool bRename = pNewTabName && pNewTabName->Len();
 
     BOOL bNewDoc = ( nDestDocNo == SC_DOC_NEW );
     if ( bNewDoc )
@@ -2589,6 +2590,14 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
         return;
     }
 
+    ScMarkData& rMark = GetViewData()->GetMarkData();
+    if (bRename && rMark.GetSelectCount() != 1)
+    {
+        // Custom sheet name is provided, but more than one sheet is selected.
+        // We don't support this scenario at the moment.
+        return;
+    }
+
     pDestDoc = pDestShell->GetDocument();
 
     SCTAB nTab = GetViewData()->GetTabNo();
@@ -2604,7 +2613,6 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
                         FALSE );
         }
 
-        ScMarkData& rMark		= GetViewData()->GetMarkData();
         SCTAB		nTabCount	= pDoc->GetTableCount();
         SCTAB		nTabSelCount = rMark.GetSelectCount();
 
@@ -2645,8 +2653,8 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
         for( USHORT j=0; j<TheTabs.Count(); j++, nDestTab1++ )
         {	// #63304# insert sheets first and update all references
             String aName;
-            if( (pName != NULL ) && ( pName->Len() ) )
-                aName = *pName;
+            if (bRename)
+                aName = *pNewTabName;
             else
                 pDoc->GetName( TheTabs[j], aName );
 
@@ -2746,17 +2754,16 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
         pDestShell->SetDocumentModified();
         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
     }
-    else					// innerhalb des Dokuments
+    else
     {
-
-        ScMarkData& rMark		= GetViewData()->GetMarkData();
+        // Move or copy within the same document.
         SCTAB		nTabCount	= pDoc->GetTableCount();
 
         SvShorts	TheTabs;
         SvShorts	TheDestTabs;
         SvStrings	TheTabNames;
         String		aDestName;
-        String		*pString;
+        const String* pString;
 
         for(SCTAB i=0;i<nTabCount;i++)
         {
@@ -2830,14 +2837,14 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
         }
 
         // Rename must be done after that all sheets have been moved.
-        if( (pName != NULL) && ( pName->Len() ) )
+        if (bRename)
         {
             for(int j=0;j<TheDestTabs.Count();j++)
             {
                 SCTAB nRenameTab = static_cast<SCTAB>(TheDestTabs[j]);
-                String aTabName( *pName);
+                String aTabName = *pNewTabName;
                 pDoc->CreateValidTabName( aTabName );
-                pDocShell->GetDocFunc().RenameTable( nRenameTab, aTabName, TRUE, FALSE );
+                pDocShell->GetDocFunc().RenameTable( nRenameTab, aTabName, false, false );
             }
         }
 
commit c203454a76f455fe565c5c7dca688f30cb85ed3d
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 20:34:30 2010 -0500

    Removed unused block.

diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index 4bf4174..56d9b5e 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -498,12 +498,6 @@ 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();
commit 5425a9944573c50c8b5548e69f5631094c088931
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 20:13:33 2010 -0500

    Update new sheet name when control states change.

diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index 8ee5847..3c1b6d2 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -57,7 +57,10 @@ public:
     void    EnableCopyTable         (BOOL bFlag=TRUE);
     void    SetRenameTable          (BOOL bFlag=TRUE);
     void    EnableRenameTable       (BOOL bFlag=TRUE);
-    void    EnableTabName           (BOOL bFlag=TRUE);
+
+private:
+    void ResetRenameInput();
+    ScDocument* GetSelectedDoc();
 
 private:
     FixedText       aFtDoc;
@@ -83,7 +86,7 @@ private:
     void    InitDocListBox  ();
     DECL_LINK( OkHdl, void * );
     DECL_LINK( SelHdl, ListBox * );
-    DECL_LINK( RenameHdl, void * );
+    DECL_LINK( CheckBtnHdl, void * );
 };
 
 #include <layout/layout-post.hxx>
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index 1e81606..d9381ae 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -123,28 +123,42 @@ void ScMoveTableDlg::EnableCopyTable(BOOL bFlag)
 void ScMoveTableDlg::SetRenameTable(BOOL bFlag)
 {
     aBtnRename.Check(bFlag);
-    EnableTabName(bFlag);
+    aEdTabName.Enable(bFlag);
 }
 
 void ScMoveTableDlg::EnableRenameTable(BOOL bFlag)
-{    if( bFlag )
+{
+    if( bFlag )
         aBtnRename.Enable();
     else
         aBtnRename.Disable();
 }
 
-void ScMoveTableDlg::EnableTabName(BOOL bFlag)
+void ScMoveTableDlg::ResetRenameInput()
 {
-    if(bFlag)
+    bool bVal = aBtnCopy.IsChecked();
+    if (bVal)
     {
-        aEdTabName.Enable();
-        aEdTabName.SetText( mrDefaultName );
+        // copy
+        ScDocument* pDoc = GetSelectedDoc();
+        if (pDoc)
+        {
+            String aStr = mrDefaultName;
+            pDoc->CreateValidTabName(aStr);
+            aEdTabName.SetText(aStr);
+        }
+        else
+            aEdTabName.SetText(mrDefaultName);
     }
     else
-    {
-        aEdTabName.Disable();
-        aEdTabName.SetText( String() );
-    }
+        // move
+        aEdTabName.SetText(mrDefaultName);
+}
+
+ScDocument* ScMoveTableDlg::GetSelectedDoc()
+{
+    USHORT nPos = aLbDoc.GetSelectEntryPos();
+    return static_cast<ScDocument*>(aLbDoc.GetEntryData(nPos));
 }
 
 //------------------------------------------------------------------------
@@ -153,12 +167,14 @@ void ScMoveTableDlg::Init()
 {
     aBtnOk.SetClickHdl   ( LINK( this, ScMoveTableDlg, OkHdl ) );
     aLbDoc.SetSelectHdl  ( LINK( this, ScMoveTableDlg, SelHdl ) );
-    aBtnRename.SetToggleHdl( LINK( this, ScMoveTableDlg, RenameHdl ) );
+    aBtnCopy.SetToggleHdl( LINK( this, ScMoveTableDlg, CheckBtnHdl ) );
+    aBtnRename.SetToggleHdl( LINK( this, ScMoveTableDlg, CheckBtnHdl ) );
     aBtnCopy.Check( FALSE );
     aBtnRename.Check( FALSE );
-    EnableTabName( FALSE );
+    aEdTabName.Enable(false);
     InitDocListBox();
     SelHdl( &aLbDoc );
+    ResetRenameInput();
 }
 
 //------------------------------------------------------------------------
@@ -198,9 +214,12 @@ void ScMoveTableDlg::InitDocListBox()
 //------------------------------------------------------------------------
 // Handler:
 
-IMPL_LINK( ScMoveTableDlg, RenameHdl, void *, EMPTYARG )
+IMPL_LINK( ScMoveTableDlg, CheckBtnHdl, void *, pBtn )
 {
-    EnableTabName( aBtnRename.IsChecked() );
+    if (pBtn == &aBtnRename)
+        aEdTabName.Enable( aBtnRename.IsChecked() );
+    else if (pBtn == &aBtnCopy)
+        ResetRenameInput();
 
     return 0;
 }
@@ -226,14 +245,11 @@ IMPL_LINK( ScMoveTableDlg, OkHdl, void *, EMPTYARG )
     return 0;
 }
 
-//------------------------------------------------------------------------
-
 IMPL_LINK( ScMoveTableDlg, SelHdl, ListBox *, pLb )
 {
     if ( pLb == &aLbDoc )
     {
-        ScDocument* pDoc   = (ScDocument*)
-                             aLbDoc.GetEntryData( aLbDoc.GetSelectEntryPos() );
+        ScDocument* pDoc = GetSelectedDoc();
         SCTAB      nLast  = 0;
         String      aName;
 
@@ -251,6 +267,7 @@ IMPL_LINK( ScMoveTableDlg, SelHdl, ListBox *, pLb )
         aLbTable.InsertEntry( ScGlobal::GetRscString(STR_MOVE_TO_END) );
         aLbTable.SetUpdateMode( TRUE );
         aLbTable.SelectEntryPos( 0 );
+        ResetRenameInput();
     }
 
     return 0;
commit 20c5b51c515497a9eb8a2ff349f2c5cf52060045
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 17:04:43 2010 -0500

    Tabs to space conversion.

diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index b157241..bdfdd1a 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -506,7 +506,7 @@ bool AbstractScMoveTableDlg_Impl::GetRenameTable() const
 {
     return pDlg->GetRenameTable();
 }
-void	AbstractScMoveTableDlg_Impl::GetTabNameString( String& rString ) const
+void AbstractScMoveTableDlg_Impl::GetTabNameString( String& rString ) const
 {
     pDlg->GetTabNameString( rString );
 }
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index 7b05ad2..8ee5847 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -48,39 +48,39 @@ public:
                     ScMoveTableDlg( Window* pParent, const String& rDefault );
                     ~ScMoveTableDlg();
 
-    USHORT	GetSelectedDocument		() const;
-    SCTAB	GetSelectedTable		() const;
-    BOOL	GetCopyTable			() const;
+    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	EnableRenameTable		(BOOL bFlag=TRUE);
-    void	EnableTabName			(BOOL bFlag=TRUE);
+    void    SetCopyTable            (BOOL bFlag=TRUE);
+    void    EnableCopyTable         (BOOL bFlag=TRUE);
+    void    SetRenameTable          (BOOL bFlag=TRUE);
+    void    EnableRenameTable       (BOOL bFlag=TRUE);
+    void    EnableTabName           (BOOL bFlag=TRUE);
 
 private:
-    FixedText		aFtDoc;
-    ListBox			aLbDoc;
-    FixedText		aFtTable;
-    ListBox			aLbTable;
-    CheckBox		aBtnCopy;
-    CheckBox		aBtnRename;
-    Edit     		aEdTabName;
-    OKButton		aBtnOk;
-    CancelButton	aBtnCancel;
-    HelpButton		aBtnHelp;
+    FixedText       aFtDoc;
+    ListBox         aLbDoc;
+    FixedText       aFtTable;
+    ListBox         aLbTable;
+    CheckBox        aBtnCopy;
+    CheckBox        aBtnRename;
+    Edit            aEdTabName;
+    OKButton        aBtnOk;
+    CancelButton    aBtnCancel;
+    HelpButton      aBtnHelp;
 
-    const String&	mrDefaultName;
+    const String&   mrDefaultName;
 
-    USHORT			nDocument;
-    SCTAB			nTable;
-    BOOL			bCopyTable;
-    BOOL			bRenameTable;
+    USHORT          nDocument;
+    SCTAB           nTable;
+    BOOL            bCopyTable;
+    BOOL            bRenameTable;
     //--------------------------------------
-    void	Init			();
-    void    InitBtnRename	();
-    void	InitDocListBox	();
+    void    Init            ();
+    void    InitBtnRename   ();
+    void    InitDocListBox  ();
     DECL_LINK( OkHdl, void * );
     DECL_LINK( SelHdl, ListBox * );
     DECL_LINK( RenameHdl, void * );
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index 8b12ae5..1e81606 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -59,7 +59,7 @@
 ScMoveTableDlg::ScMoveTableDlg( Window*       pParent,
                                 const String& rDefault )
 
-    :	ModalDialog ( pParent, ScResId( RID_SCDLG_MOVETAB ) ),
+    :   ModalDialog ( pParent, ScResId( RID_SCDLG_MOVETAB ) ),
         //
         aFtDoc      ( this, ScResId( FT_DEST ) ),
         aLbDoc      ( this, ScResId( LB_DEST ) ),
@@ -67,7 +67,7 @@ ScMoveTableDlg::ScMoveTableDlg( Window*       pParent,
         aLbTable    ( this, ScResId( LB_INSERT ) ),
         aBtnCopy    ( this, ScResId( BTN_COPY ) ),
         aBtnRename  ( this, ScResId( BTN_RENAME ) ),
-        aEdTabName	( this, ScResId( ED_INPUT ) ),
+        aEdTabName  ( this, ScResId( ED_INPUT ) ),
         aBtnOk      ( this, ScResId( BTN_OK ) ),
         aBtnCancel  ( this, ScResId( BTN_CANCEL ) ),
         aBtnHelp    ( this, ScResId( BTN_HELP ) ),
@@ -165,10 +165,10 @@ void ScMoveTableDlg::Init()
 
 void ScMoveTableDlg::InitDocListBox()
 {
-    SfxObjectShell* pSh		= SfxObjectShell::GetFirst();
-    ScDocShell*		pScSh	= NULL;
-    USHORT    		nSelPos	= 0;
-    USHORT    		i    	= 0;
+    SfxObjectShell* pSh     = SfxObjectShell::GetFirst();
+    ScDocShell*     pScSh   = NULL;
+    USHORT          nSelPos = 0;
+    USHORT          i       = 0;
 
     aLbDoc.Clear();
     aLbDoc.SetUpdateMode( FALSE );
commit d9d515299663d9399904b73a494c248578f43360
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 13:51:18 2010 -0500

    BOOL -> bool, and tabs to whitespace in new code.
    
    Also, putting a bool declaration in the right context.

diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 93b291c..0b33261 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -213,7 +213,7 @@ public:
     virtual USHORT	GetSelectedDocument		() const = 0;
     virtual USHORT	GetSelectedTable		() const = 0;
     virtual BOOL	GetCopyTable			() const = 0;
-    virtual BOOL	GetRenameTable			() 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 d31bd7e..b157241 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -502,7 +502,7 @@ BOOL	AbstractScMoveTableDlg_Impl::GetCopyTable() const
 {
     return pDlg->GetCopyTable();
 }
-BOOL	AbstractScMoveTableDlg_Impl::GetRenameTable() const
+bool AbstractScMoveTableDlg_Impl::GetRenameTable() const
 {
     return pDlg->GetRenameTable();
 }
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 0738e97..121b791 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -263,7 +263,7 @@ 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 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 8724bc4..7b05ad2 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -51,7 +51,7 @@ public:
     USHORT	GetSelectedDocument		() const;
     SCTAB	GetSelectedTable		() const;
     BOOL	GetCopyTable			() const;
-    BOOL	GetRenameTable			() const;
+    bool    GetRenameTable          () const;
     void    GetTabNameString( String& rString ) const;
     void	SetCopyTable			(BOOL bFlag=TRUE);
     void	EnableCopyTable			(BOOL bFlag=TRUE);
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index 9ded781..8b12ae5 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -100,7 +100,7 @@ SCTAB ScMoveTableDlg::GetSelectedTable    () const { return nTable;     }
 
 BOOL   ScMoveTableDlg::GetCopyTable        () const { return bCopyTable; }
 
-BOOL   ScMoveTableDlg::GetRenameTable        () const { return bRenameTable; }
+bool   ScMoveTableDlg::GetRenameTable        () const { return bRenameTable; }
 
 void ScMoveTableDlg::GetTabNameString( String& rString ) const
 {
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index d46d7ec..4bf4174 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -478,7 +478,6 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                 USHORT nDoc = 0;
                 SCTAB nTab = pViewData->GetTabNo();
                 BOOL   bCpy = FALSE;
-                BOOL   bRna = FALSE;
                 String aDocName;
                 String aTabName;
 
@@ -574,7 +573,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                         nDoc = pDlg->GetSelectedDocument();
                         nTab = pDlg->GetSelectedTable();
                         bCpy = pDlg->GetCopyTable();
-                        bRna = pDlg->GetRenameTable();
+                        bool bRna = pDlg->GetRenameTable();
                         // Leave aTabName string empty, when Rename is FALSE.
                         if( bRna )
                         {
commit 93f5901f42e57c5c3cbd070e6a716945bd4bbb14
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Dec 13 13:41:56 2010 -0500

    Made the dialog a bit smaller to fit.

diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src
index cd7b2c6..0c3c0db 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 , 154 ) ;
+    Size = MAP_APPFONT ( 168 , 145 ) ;
     Text [ en-US ] = "Move/Copy Sheet" ;
     Moveable = TRUE ;
     Closeable = FALSE ;
@@ -499,7 +499,7 @@ ModalDialog RID_SCDLG_MOVETAB
     CheckBox BTN_RENAME
     {
         Pos = MAP_APPFONT ( 6 , 128 ) ;
-        Size = MAP_APPFONT (  52 , 10 ) ;
+        Size = MAP_APPFONT ( 52 , 10 ) ;
         Text [ en-US ] = "~Rename" ;
         TabStop = TRUE ;
     };
commit dd42e1b87bef10b20278e3c4a69c18b540056fc8
Author: Joost Wezenbeek <joost.eekhoorn at gmail.com>
Date:   Sun Dec 12 12:04:34 2010 +0100

    Change Sheet copy process
    
    Easy Hacks 3.27
    Added rename in Move/Copy Sheet in calc

diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 102ea20..93b291c 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -410,7 +410,9 @@ public:
                                                                 long			nFirst	  = 1,
                                                                 long          nLast     = 100 ) = 0;
 
-    virtual AbstractScMoveTableDlg * CreateScMoveTableDlg(  Window* pParent, int nId ) = 0; //add for ScMoveTableDlg
+    virtual AbstractScMoveTableDlg * CreateScMoveTableDlg(  Window* pParent,  //add for ScMoveTableDlg
+                                                            const String& rDefault,
+                                                            int nId ) = 0;
 
     virtual AbstractScNameCreateDlg * CreateScNameCreateDlg ( Window * pParent, USHORT nFlags, int nId ) = 0; //add for ScNameCreateDlg
 
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 10f0065..d31bd7e 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -1125,13 +1125,15 @@ AbstractScMetricInputDlg * ScAbstractDialogFactory_Impl::CreateScMetricInputDlg
 
 
 //add for  ScMoveTableDlg  begin
-AbstractScMoveTableDlg * ScAbstractDialogFactory_Impl::CreateScMoveTableDlg(  Window* pParent, int nId )
+AbstractScMoveTableDlg * ScAbstractDialogFactory_Impl::CreateScMoveTableDlg(  Window* pParent,
+                                                                              const String& rDefault,
+                                                                              int nId )
 {
     ScMoveTableDlg * pDlg=NULL;
     switch ( nId )
     {
         case RID_SCDLG_MOVETAB :
-            pDlg = new ScMoveTableDlg( pParent );
+            pDlg = new ScMoveTableDlg( pParent, rDefault );
             break;
         default:
             break;
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index f4a8286..0738e97 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -492,7 +492,10 @@ public:
                                                                 long			nFirst	  = 1,
                                                                 long          nLast     = 100 );
 
-    virtual AbstractScMoveTableDlg * CreateScMoveTableDlg(  Window* pParent, int nId ); //add for ScMoveTableDlg
+    virtual AbstractScMoveTableDlg * CreateScMoveTableDlg(  Window* pParent,  //add for ScMoveTableDlg
+                                                            const String& rDefault,
+                                                            int nId );
+
     virtual AbstractScNameCreateDlg * CreateScNameCreateDlg ( Window * pParent, USHORT nFlags, int nId ); //add for ScNameCreateDlg
 
     virtual AbstractScNamePasteDlg * CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList, //add for ScNamePasteDlg
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index 1ffdc28..8724bc4 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -45,7 +45,7 @@
 class ScMoveTableDlg : public ModalDialog
 {
 public:
-                    ScMoveTableDlg( Window* pParent );
+                    ScMoveTableDlg( Window* pParent, const String& rDefault );
                     ~ScMoveTableDlg();
 
     USHORT	GetSelectedDocument		() const;
@@ -71,6 +71,8 @@ private:
     CancelButton	aBtnCancel;
     HelpButton		aBtnHelp;
 
+    const String&	mrDefaultName;
+
     USHORT			nDocument;
     SCTAB			nTable;
     BOOL			bCopyTable;
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index cf394a7..9ded781 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -56,7 +56,8 @@
 
 //==================================================================
 
-ScMoveTableDlg::ScMoveTableDlg( Window* pParent )
+ScMoveTableDlg::ScMoveTableDlg( Window*       pParent,
+                                const String& rDefault )
 
     :	ModalDialog ( pParent, ScResId( RID_SCDLG_MOVETAB ) ),
         //
@@ -71,6 +72,7 @@ ScMoveTableDlg::ScMoveTableDlg( Window* pParent )
         aBtnCancel  ( this, ScResId( BTN_CANCEL ) ),
         aBtnHelp    ( this, ScResId( BTN_HELP ) ),
         //
+        mrDefaultName( rDefault ),
         nDocument   ( 0 ),
         nTable      ( 0 ),
         bCopyTable  ( FALSE ),
@@ -136,6 +138,7 @@ void ScMoveTableDlg::EnableTabName(BOOL bFlag)
     if(bFlag)
     {
         aEdTabName.Enable();
+        aEdTabName.SetText( mrDefaultName );
     }
     else
     {
@@ -213,6 +216,11 @@ IMPL_LINK( ScMoveTableDlg, OkHdl, void *, EMPTYARG )
     nTable      = (nTabSel != nTabLast) ? static_cast<SCTAB>(nTabSel) : SC_TAB_APPEND;
     bCopyTable  = aBtnCopy.IsChecked();
     bRenameTable= aBtnRename.IsChecked();
+
+    // Return an empty string, when the new name is the same as the original name.
+    if( mrDefaultName == aEdTabName.GetText() )
+        aEdTabName.SetText( String() );
+
     EndDialog( RET_OK );
 
     return 0;
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index b22c1ca..d46d7ec 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -544,10 +544,15 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                 }
                 else
                 {
+                    String aDefaultName;
+                    pDoc->GetName( pViewData->GetTabNo(), aDefaultName );
+
                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
                     DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
 
-                    AbstractScMoveTableDlg* pDlg = pFact->CreateScMoveTableDlg( GetDialogParent(), RID_SCDLG_MOVETAB );
+                    AbstractScMoveTableDlg* pDlg = pFact->CreateScMoveTableDlg( GetDialogParent(),
+                                                                                aDefaultName,
+                                                                                RID_SCDLG_MOVETAB );
                     DBG_ASSERT(pDlg, "Dialog create fail!");
 
                     SCTAB nTableCount = pDoc->GetTableCount();
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 49c876c..21e7194 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2645,7 +2645,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
         for( USHORT j=0; j<TheTabs.Count(); j++, nDestTab1++ )
         {	// #63304# insert sheets first and update all references
             String aName;
-            if( pName->Len() )
+            if( (pName != NULL ) && ( pName->Len() ) )
                 aName = *pName;
             else
                 pDoc->GetName( TheTabs[j], aName );
@@ -2830,7 +2830,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
         }
 
         // Rename must be done after that all sheets have been moved.
-        if( pName->Len() )
+        if( (pName != NULL) && ( pName->Len() ) )
         {
             for(int j=0;j<TheDestTabs.Count();j++)
             {
commit 977f9973be22defae88f6e46e62c02280a583851
Author: Joost Wezenbeek <joost.eekhoorn at gmail.com>
Date:   Sat Dec 11 21:52:42 2010 +0100

    Change Sheet copy process
    
    Easy Hacks 3.27
    Added rename in Move/Copy Sheet in calc

diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index dc20e8f..102ea20 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -217,6 +217,8 @@ 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;
 };
 
 class AbstractScNameCreateDlg : public VclAbstractDialog  //add for ScNameCreateDlg
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 5a78eae..10f0065 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -518,6 +518,15 @@ 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);
+}
+
 //add for AbstractScMoveTableDlg_Impl end
 
 //add for AbstractScNameCreateDlg_Impl begin
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index dc583a6..f4a8286 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -267,6 +267,8 @@ 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);
 };
 
 class AbstractScNameCreateDlg_Impl : public AbstractScNameCreateDlg  //add for ScNameCreateDlg
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index 543fa01..1ffdc28 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -56,7 +56,8 @@ public:
     void	SetCopyTable			(BOOL bFlag=TRUE);
     void	EnableCopyTable			(BOOL bFlag=TRUE);
     void	SetRenameTable			(BOOL bFlag=TRUE);
-    void	SetTabNameVisible		(BOOL bFlag=TRUE);
+    void	EnableRenameTable		(BOOL bFlag=TRUE);
+    void	EnableTabName			(BOOL bFlag=TRUE);
 
 private:
     FixedText		aFtDoc;
@@ -65,7 +66,6 @@ private:
     ListBox			aLbTable;
     CheckBox		aBtnCopy;
     CheckBox		aBtnRename;
-    FixedText		aFtTabName;
     Edit     		aEdTabName;
     OKButton		aBtnOk;
     CancelButton	aBtnCancel;
@@ -77,6 +77,7 @@ private:
     BOOL			bRenameTable;
     //--------------------------------------
     void	Init			();
+    void    InitBtnRename	();
     void	InitDocListBox	();
     DECL_LINK( OkHdl, void * );
     DECL_LINK( SelHdl, ListBox * );
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index e8ed808..95158e9 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, const String& rName );
+    void			MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const String* pName = NULL );
     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 5cb79d9..cf394a7 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -66,7 +66,6 @@ ScMoveTableDlg::ScMoveTableDlg( Window* pParent )
         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 ) ),
@@ -110,6 +109,7 @@ void ScMoveTableDlg::SetCopyTable(BOOL bFlag)
 {
     aBtnCopy.Check(bFlag);
 }
+
 void ScMoveTableDlg::EnableCopyTable(BOOL bFlag)
 {
     if(bFlag)
@@ -121,19 +121,26 @@ void ScMoveTableDlg::EnableCopyTable(BOOL bFlag)
 void ScMoveTableDlg::SetRenameTable(BOOL bFlag)
 {
     aBtnRename.Check(bFlag);
-    SetTabNameVisible(bFlag);
+    EnableTabName(bFlag);
+}
+
+void ScMoveTableDlg::EnableRenameTable(BOOL bFlag)
+{    if( bFlag )
+        aBtnRename.Enable();
+    else
+        aBtnRename.Disable();
 }
 
-void ScMoveTableDlg::SetTabNameVisible(BOOL bFlag)
+void ScMoveTableDlg::EnableTabName(BOOL bFlag)
 {
     if(bFlag)
     {
-        aFtTabName.Show();
-        aEdTabName.Show();
-    } else
+        aEdTabName.Enable();
+    }
+    else
     {
-        aFtTabName.Hide();
-        aEdTabName.Hide();
+        aEdTabName.Disable();
+        aEdTabName.SetText( String() );
     }
 }
 
@@ -146,7 +153,7 @@ void ScMoveTableDlg::Init()
     aBtnRename.SetToggleHdl( LINK( this, ScMoveTableDlg, RenameHdl ) );
     aBtnCopy.Check( FALSE );
     aBtnRename.Check( FALSE );
-    SetTabNameVisible( FALSE );
+    EnableTabName( FALSE );
     InitDocListBox();
     SelHdl( &aLbDoc );
 }
@@ -185,13 +192,12 @@ void ScMoveTableDlg::InitDocListBox()
     aLbDoc.SelectEntryPos( nSelPos );
 }
 
-
 //------------------------------------------------------------------------
 // Handler:
 
 IMPL_LINK( ScMoveTableDlg, RenameHdl, void *, EMPTYARG )
 {
-    SetTabNameVisible( aBtnRename.IsChecked() );
+    EnableTabName( aBtnRename.IsChecked() );
 
     return 0;
 }
diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src
index 49bda22..cd7b2c6 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 , 180 ) ;
+    Size = MAP_APPFONT ( 168 , 154 ) ;
     Text [ en-US ] = "Move/Copy Sheet" ;
     Moveable = TRUE ;
     Closeable = FALSE ;
@@ -498,22 +498,16 @@ ModalDialog RID_SCDLG_MOVETAB
     };
     CheckBox BTN_RENAME
     {
-        Pos = MAP_APPFONT ( 6 , 124 ) ;
-        Size = MAP_APPFONT ( 100 , 10 ) ;
+        Pos = MAP_APPFONT ( 6 , 128 ) ;
+        Size = MAP_APPFONT (  52 , 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 ) ;
+        Pos = MAP_APPFONT ( 58 , 127 ) ;
+        Size = MAP_APPFONT ( 104 , 12 ) ;
         TabStop = TRUE ;
     };
     String STR_NEWDOC
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index b56fc42..14d0a33 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, String() );
+                pViewData->GetView()->MoveTable( lcl_DocShellNr(pDoc), nPos, rEvt.mnAction != DND_ACTION_MOVE );
 
                 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 2fe2758..b22c1ca 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -560,6 +560,10 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                         pDlg->SetCopyTable();
                         pDlg->EnableCopyTable(FALSE);
                     }
+                    if(nTabSelCount != 1)
+                    {
+                        pDlg->EnableRenameTable(FALSE);
+                    }
                     if ( pDlg->Execute() == RET_OK )
                     {
                         nDoc = pDlg->GetSelectedDocument();
@@ -600,7 +604,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                 {
                     rReq.Done();		// aufzeichnen, solange das Dokument noch aktiv ist
 
-                    MoveTable( nDoc, nTab, bCpy, aTabName );
+                    MoveTable( nDoc, nTab, bCpy, &aTabName );
                 }
             }
             break;
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 0d93136..49c876c 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2543,7 +2543,7 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
 //----------------------------------------------------------------------------
 //	Tabelle in anderes Dokument verschieben / kopieren
 
-void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const String& rName )
+void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const String* pName )
 {
     ScDocument* pDoc	   = GetViewData()->GetDocument();
     ScDocShell* pDocShell  = GetViewData()->GetDocShell();
@@ -2645,8 +2645,8 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
         for( USHORT j=0; j<TheTabs.Count(); j++, nDestTab1++ )
         {	// #63304# insert sheets first and update all references
             String aName;
-            if( rName.Len() )
-                aName = rName;
+            if( pName->Len() )
+                aName = *pName;
             else
                 pDoc->GetName( TheTabs[j], aName );
 
@@ -2830,12 +2830,12 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
         }
 
         // Rename must be done after that all sheets have been moved.
-        if( rName.Len() )
+        if( pName->Len() )
         {
             for(int j=0;j<TheDestTabs.Count();j++)
             {
                 SCTAB nRenameTab = static_cast<SCTAB>(TheDestTabs[j]);
-                String aTabName( rName);
+                String aTabName( *pName);
                 pDoc->CreateValidTabName( aTabName );
                 pDocShell->GetDocFunc().RenameTable( nRenameTab, aTabName, TRUE, FALSE );
             }
commit af9d123791ebeaca9dd84a4294169237e193d6ff
Author: Joost Wezenbeek <joost.eekhoorn at gmail.com>
Date:   Fri Dec 10 20:03:11 2010 +0100

    Change Sheet copy process
    
    Easy Hacks 3.27
    Added rename in Move/Copy Sheet in calc

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 8664da5..5cb79d9 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 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 fd053ec..0d93136 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2543,7 +2543,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();
@@ -2645,7 +2645,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 ) )
             {
@@ -2825,6 +2829,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)


More information about the Libreoffice-commits mailing list