Kaydet (Commit) e1ca72ca authored tarafından Eike Rathke's avatar Eike Rathke

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.
üst fe4f272a
...@@ -58,6 +58,7 @@ private: ...@@ -58,6 +58,7 @@ private:
void ResetRenameInput(); void ResetRenameInput();
void CheckNewTabName(); void CheckNewTabName();
ScDocument* GetSelectedDoc(); ScDocument* GetSelectedDoc();
bool IsCurrentDocSelected() const;
private: private:
FixedLine aFlAction; FixedLine aFlAction;
...@@ -82,6 +83,7 @@ private: ...@@ -82,6 +83,7 @@ private:
const rtl::OUString maDefaultName; const rtl::OUString maDefaultName;
sal_uInt16 mnCurrentDocPos;
sal_uInt16 nDocument; sal_uInt16 nDocument;
SCTAB nTable; SCTAB nTable;
bool bCopyTable:1; bool bCopyTable:1;
......
...@@ -70,6 +70,7 @@ ScMoveTableDlg::ScMoveTableDlg(Window* pParent, const rtl::OUString& rDefault) ...@@ -70,6 +70,7 @@ ScMoveTableDlg::ScMoveTableDlg(Window* pParent, const rtl::OUString& rDefault)
maStrTabNameInvalid( ResId::toString(ScResId(STR_TABNAME_WARN_INVALID)) ), maStrTabNameInvalid( ResId::toString(ScResId(STR_TABNAME_WARN_INVALID)) ),
// //
maDefaultName( rDefault ), maDefaultName( rDefault ),
mnCurrentDocPos( 0 ),
nDocument ( 0 ), nDocument ( 0 ),
nTable ( 0 ), nTable ( 0 ),
bCopyTable ( false ), bCopyTable ( false ),
...@@ -127,8 +128,13 @@ void ScMoveTableDlg::EnableRenameTable(sal_Bool bFlag) ...@@ -127,8 +128,13 @@ void ScMoveTableDlg::EnableRenameTable(sal_Bool bFlag)
void ScMoveTableDlg::ResetRenameInput() void ScMoveTableDlg::ResetRenameInput()
{ {
if (mbEverEdited) if (mbEverEdited)
{
// Don't reset the name when the sheet name has ever been edited. // 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; return;
}
if (!aEdTabName.IsEnabled()) if (!aEdTabName.IsEnabled())
{ {
...@@ -178,19 +184,15 @@ void ScMoveTableDlg::CheckNewTabName() ...@@ -178,19 +184,15 @@ void ScMoveTableDlg::CheckNewTabName()
return; return;
} }
bool bFound = false; bool bMoveInCurrentDoc = (aBtnMove.IsChecked() && IsCurrentDocSelected());
bool bFound = false;
sal_uInt16 nLast = aLbTable.GetEntryCount() - 1; 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 ( aNewName.equals(aLbTable.GetEntry(i)) )
{ {
if (aBtnMove.IsChecked() && // Only for move within same document the same name is allowed.
aLbDoc.GetSelectEntryPos() == 0 && if (!bMoveInCurrentDoc || !maDefaultName.equals( aEdTabName.GetText()))
maDefaultName.equals(aEdTabName.GetText()))
// Move inside same document, thus same name is allowed.
bFound = false;
else
bFound = true; bFound = true;
} }
} }
...@@ -214,6 +216,11 @@ ScDocument* ScMoveTableDlg::GetSelectedDoc() ...@@ -214,6 +216,11 @@ ScDocument* ScMoveTableDlg::GetSelectedDoc()
return static_cast<ScDocument*>(aLbDoc.GetEntryData(nPos)); return static_cast<ScDocument*>(aLbDoc.GetEntryData(nPos));
} }
bool ScMoveTableDlg::IsCurrentDocSelected() const
{
return aLbDoc.GetSelectEntryPos() == mnCurrentDocPos;
}
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void ScMoveTableDlg::Init() void ScMoveTableDlg::Init()
...@@ -254,7 +261,7 @@ void ScMoveTableDlg::InitDocListBox() ...@@ -254,7 +261,7 @@ void ScMoveTableDlg::InitDocListBox()
if ( pScSh == SfxObjectShell::Current() ) if ( pScSh == SfxObjectShell::Current() )
{ {
nSelPos = i; mnCurrentDocPos = nSelPos = i;
aEntryName += sal_Unicode( ' ' ); aEntryName += sal_Unicode( ' ' );
aEntryName += String( ScResId( STR_CURRENTDOC ) ); aEntryName += String( ScResId( STR_CURRENTDOC ) );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment