diff options
author | Eike Rathke <erack@redhat.com> | 2012-04-17 20:57:34 +0200 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-17 15:50:08 -0400 |
commit | 05579aa8b26f593af650d8434ff1c25c0a2702a6 (patch) | |
tree | 35b61f498694ae10bda70307a433cbc9b8436bb6 | |
parent | 5920b681eaf2f1203efd5af581827db2e1a81bc8 (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.
Signed-off-by: Kohei Yoshida <kohei.yoshida@gmail.com>
-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 | |||
@@ -58,6 +58,7 @@ private: | |||
58 | void ResetRenameInput(); | 58 | void ResetRenameInput(); |
59 | void CheckNewTabName(); | 59 | void CheckNewTabName(); |
60 | ScDocument* GetSelectedDoc(); | 60 | ScDocument* GetSelectedDoc(); |
61 | bool IsCurrentDocSelected() const; | ||
61 | 62 | ||
62 | private: | 63 | private: |
63 | FixedLine aFlAction; | 64 | FixedLine aFlAction; |
@@ -82,6 +83,7 @@ private: | |||
82 | 83 | ||
83 | const rtl::OUString maDefaultName; | 84 | const rtl::OUString maDefaultName; |
84 | 85 | ||
86 | sal_uInt16 mnCurrentDocPos; | ||
85 | sal_uInt16 nDocument; | 87 | sal_uInt16 nDocument; |
86 | SCTAB nTable; | 88 | SCTAB nTable; |
87 | bool bCopyTable:1; | 89 | bool bCopyTable:1; |
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx index 831905d1ea55..ffe96af26663 100644 --- a/sc/source/ui/miscdlgs/mvtabdlg.cxx +++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx | |||
@@ -70,6 +70,7 @@ ScMoveTableDlg::ScMoveTableDlg(Window* pParent, const rtl::OUString& rDefault) | |||
70 | maStrTabNameInvalid( ResId::toString(ScResId(STR_TABNAME_WARN_INVALID)) ), | 70 | maStrTabNameInvalid( ResId::toString(ScResId(STR_TABNAME_WARN_INVALID)) ), |
71 | // | 71 | // |
72 | maDefaultName( rDefault ), | 72 | maDefaultName( rDefault ), |
73 | mnCurrentDocPos( 0 ), | ||
73 | nDocument ( 0 ), | 74 | nDocument ( 0 ), |
74 | nTable ( 0 ), | 75 | nTable ( 0 ), |
75 | bCopyTable ( false ), | 76 | bCopyTable ( false ), |
@@ -127,8 +128,13 @@ void ScMoveTableDlg::EnableRenameTable(sal_Bool bFlag) | |||
127 | void ScMoveTableDlg::ResetRenameInput() | 128 | void ScMoveTableDlg::ResetRenameInput() |
128 | { | 129 | { |
129 | if (mbEverEdited) | 130 | if (mbEverEdited) |
131 | { | ||
130 | // Don't reset the name when the sheet name has ever been edited. | 132 | // Don't reset the name when the sheet name has ever been edited. |
133 | // But check the name, as this is also called for change of copy/move | ||
134 | // buttons and document listbox selection. | ||
135 | CheckNewTabName(); | ||
131 | return; | 136 | return; |
137 | } | ||
132 | 138 | ||
133 | if (!aEdTabName.IsEnabled()) | 139 | if (!aEdTabName.IsEnabled()) |
134 | { | 140 | { |
@@ -178,19 +184,15 @@ void ScMoveTableDlg::CheckNewTabName() | |||
178 | return; | 184 | return; |
179 | } | 185 | } |
180 | 186 | ||
181 | bool bFound = false; | 187 | bool bMoveInCurrentDoc = (aBtnMove.IsChecked() && IsCurrentDocSelected()); |
188 | bool bFound = false; | ||
182 | sal_uInt16 nLast = aLbTable.GetEntryCount() - 1; | 189 | sal_uInt16 nLast = aLbTable.GetEntryCount() - 1; |
183 | for ( sal_uInt16 i=0; i<=nLast; ++i ) | 190 | for ( sal_uInt16 i=0; i<=nLast && !bFound; ++i ) |
184 | { | 191 | { |
185 | if ( aNewName.equals(aLbTable.GetEntry(i)) ) | 192 | if ( aNewName.equals(aLbTable.GetEntry(i)) ) |
186 | { | 193 | { |
187 | if (aBtnMove.IsChecked() && | 194 | // Only for move within same document the same name is allowed. |
188 | aLbDoc.GetSelectEntryPos() == 0 && | 195 | if (!bMoveInCurrentDoc || !maDefaultName.equals( aEdTabName.GetText())) |
189 | maDefaultName.equals(aEdTabName.GetText())) | ||
190 | |||
191 | // Move inside same document, thus same name is allowed. | ||
192 | bFound = false; | ||
193 | else | ||
194 | bFound = true; | 196 | bFound = true; |
195 | } | 197 | } |
196 | } | 198 | } |
@@ -214,6 +216,11 @@ ScDocument* ScMoveTableDlg::GetSelectedDoc() | |||
214 | return static_cast<ScDocument*>(aLbDoc.GetEntryData(nPos)); | 216 | return static_cast<ScDocument*>(aLbDoc.GetEntryData(nPos)); |
215 | } | 217 | } |
216 | 218 | ||
219 | bool ScMoveTableDlg::IsCurrentDocSelected() const | ||
220 | { | ||
221 | return aLbDoc.GetSelectEntryPos() == mnCurrentDocPos; | ||
222 | } | ||
223 | |||
217 | //------------------------------------------------------------------------ | 224 | //------------------------------------------------------------------------ |
218 | 225 | ||
219 | void ScMoveTableDlg::Init() | 226 | void ScMoveTableDlg::Init() |
@@ -254,7 +261,7 @@ void ScMoveTableDlg::InitDocListBox() | |||
254 | 261 | ||
255 | if ( pScSh == SfxObjectShell::Current() ) | 262 | if ( pScSh == SfxObjectShell::Current() ) |
256 | { | 263 | { |
257 | nSelPos = i; | 264 | mnCurrentDocPos = nSelPos = i; |
258 | aEntryName += sal_Unicode( ' ' ); | 265 | aEntryName += sal_Unicode( ' ' ); |
259 | aEntryName += String( ScResId( STR_CURRENTDOC ) ); | 266 | aEntryName += String( ScResId( STR_CURRENTDOC ) ); |
260 | } | 267 | } |