diff options
author | Eike Rathke <erack@redhat.com> | 2012-04-17 20:57:34 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2012-04-17 20:57:34 +0200 |
commit | e1ca72ca9f783a2f956f1445ce82cd3eacffe4a2 (patch) | |
tree | cbe670274cb6ededb899e64a1d6bae685cd89eb3 | |
parent | fe4f272a385ee4fe5f541ff37eb710956a0ad38b (diff) |
resolved rhbz#813280 the current document is not always the first in list
i.e. if more than one document open and dialog invoked on any but the first
document.
-rw-r--r-- | sc/source/ui/inc/mvtabdlg.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/mvtabdlg.cxx | 27 |
2 files changed, 19 insertions, 10 deletions
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx index c53a59fe7314..f9c63a334520 100644 --- a/sc/source/ui/inc/mvtabdlg.hxx +++ b/sc/source/ui/inc/mvtabdlg.hxx @@ -55,12 +55,13 @@ public: void EnableRenameTable (sal_Bool bFlag=true); private: void ResetRenameInput(); void CheckNewTabName(); ScDocument* GetSelectedDoc(); + bool IsCurrentDocSelected() const; private: FixedLine aFlAction; RadioButton aBtnMove; RadioButton aBtnCopy; FixedLine aFlLocation; @@ -79,12 +80,13 @@ private: rtl::OUString maStrTabNameUsed; rtl::OUString maStrTabNameEmpty; rtl::OUString maStrTabNameInvalid; const rtl::OUString maDefaultName; + sal_uInt16 mnCurrentDocPos; sal_uInt16 nDocument; SCTAB nTable; bool bCopyTable:1; bool bRenameTable:1; bool mbEverEdited:1; diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx index 4287e20fcbe1..b3f30c43fe65 100644 --- a/sc/source/ui/miscdlgs/mvtabdlg.cxx +++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx @@ -67,12 +67,13 @@ ScMoveTableDlg::ScMoveTableDlg(Window* pParent, const rtl::OUString& rDefault) maStrTabNameUsed( ResId::toString(ScResId(STR_TABNAME_WARN_USED)) ), maStrTabNameEmpty( ResId::toString(ScResId(STR_TABNAME_WARN_EMPTY)) ), maStrTabNameInvalid( ResId::toString(ScResId(STR_TABNAME_WARN_INVALID)) ), // maDefaultName( rDefault ), + mnCurrentDocPos( 0 ), nDocument ( 0 ), nTable ( 0 ), bCopyTable ( false ), bRenameTable( false ), mbEverEdited( false ) { @@ -124,14 +125,19 @@ void ScMoveTableDlg::EnableRenameTable(sal_Bool bFlag) ResetRenameInput(); } void ScMoveTableDlg::ResetRenameInput() { if (mbEverEdited) + { // Don't reset the name when the sheet name has ever been edited. + // But check the name, as this is also called for change of copy/move + // buttons and document listbox selection. + CheckNewTabName(); return; + } if (!aEdTabName.IsEnabled()) { aEdTabName.SetText(String()); return; } @@ -175,25 +181,21 @@ void ScMoveTableDlg::CheckNewTabName() aFtWarn.SetText(maStrTabNameInvalid); aFtWarn.Show(); aBtnOk.Disable(); return; } - bool bFound = false; + bool bMoveInCurrentDoc = (aBtnMove.IsChecked() && IsCurrentDocSelected()); + bool bFound = false; sal_uInt16 nLast = aLbTable.GetEntryCount() - 1; - for ( sal_uInt16 i=0; i<=nLast; ++i ) + for ( sal_uInt16 i=0; i<=nLast && !bFound; ++i ) { if ( aNewName.equals(aLbTable.GetEntry(i)) ) { - if (aBtnMove.IsChecked() && - aLbDoc.GetSelectEntryPos() == 0 && - maDefaultName.equals(aEdTabName.GetText())) - - // Move inside same document, thus same name is allowed. - bFound = false; - else + // Only for move within same document the same name is allowed. + if (!bMoveInCurrentDoc || !maDefaultName.equals( aEdTabName.GetText())) bFound = true; } } if ( bFound ) { @@ -211,12 +213,17 @@ void ScMoveTableDlg::CheckNewTabName() ScDocument* ScMoveTableDlg::GetSelectedDoc() { sal_uInt16 nPos = aLbDoc.GetSelectEntryPos(); return static_cast<ScDocument*>(aLbDoc.GetEntryData(nPos)); } +bool ScMoveTableDlg::IsCurrentDocSelected() const +{ + return aLbDoc.GetSelectEntryPos() == mnCurrentDocPos; +} + //------------------------------------------------------------------------ void ScMoveTableDlg::Init() { aBtnOk.SetClickHdl ( LINK( this, ScMoveTableDlg, OkHdl ) ); aLbDoc.SetSelectHdl ( LINK( this, ScMoveTableDlg, SelHdl ) ); @@ -251,13 +258,13 @@ void ScMoveTableDlg::InitDocListBox() if ( pScSh ) { aEntryName = pScSh->GetTitle(); if ( pScSh == SfxObjectShell::Current() ) { - nSelPos = i; + mnCurrentDocPos = nSelPos = i; aEntryName += sal_Unicode( ' ' ); aEntryName += String( ScResId( STR_CURRENTDOC ) ); } aLbDoc.InsertEntry( aEntryName, i ); aLbDoc.SetEntryData( i, (void*)pScSh->GetDocument() ); |