summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-01-03 16:27:54 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-01-03 16:27:54 -0500
commit8a3f4fb915e240bc26b0ba6337acc751cee05d8c (patch)
tree16f120787737eb8498c977b42c7fe9c9d40ef644 /sc
parentForce copy when all sheets are selected. (diff)
downloadcore-8a3f4fb915e240bc26b0ba6337acc751cee05d8c.tar.gz
core-8a3f4fb915e240bc26b0ba6337acc751cee05d8c.zip
Different warning messages for different causes.
Now we display three different warning texts: * name is already taken. * name is empty. * name contains invalid characters.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/document.hxx3
-rw-r--r--sc/source/core/data/document.cxx2
-rw-r--r--sc/source/ui/inc/miscdlgs.hrc3
-rw-r--r--sc/source/ui/inc/mvtabdlg.hxx6
-rw-r--r--sc/source/ui/miscdlgs/mvtabdlg.cxx40
-rw-r--r--sc/source/ui/src/miscdlgs.src14
6 files changed, 59 insertions, 9 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index cde3227ea007..1aa6716d1847 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -569,7 +569,8 @@ public:
void SetEmbedded( const Rectangle& rRect ); // aus VisArea (1/100 mm)
void SnapVisArea( Rectangle& rRect ) const; // 1/100 mm
- SC_DLLPUBLIC BOOL ValidTabName( const String& rName ) const;
+ static SC_DLLPUBLIC bool ValidTabName( const String& rName );
+
SC_DLLPUBLIC BOOL ValidNewTabName( const String& rName ) const;
SC_DLLPUBLIC void CreateValidTabName(String& rName) const;
SC_DLLPUBLIC BOOL InsertTab( SCTAB nPos, const String& rName,
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index a55809f89e5a..3531b0f8f844 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -226,7 +226,7 @@ BOOL ScDocument::GetTable( const String& rName, SCTAB& rTab ) const
}
-BOOL ScDocument::ValidTabName( const String& rName ) const
+bool ScDocument::ValidTabName( const String& rName )
{
xub_StrLen nLen = rName.Len();
if (!nLen)
diff --git a/sc/source/ui/inc/miscdlgs.hrc b/sc/source/ui/inc/miscdlgs.hrc
index e2586597a3ff..3f1faa5492aa 100644
--- a/sc/source/ui/inc/miscdlgs.hrc
+++ b/sc/source/ui/inc/miscdlgs.hrc
@@ -105,6 +105,9 @@
#define FT_TABNAME 12
#define FT_TABNAME_WARN 13
#define STR_CURRENTDOC 14
+#define STR_TABNAME_WARN_USED 15
+#define STR_TABNAME_WARN_EMPTY 16
+#define STR_TABNAME_WARN_INVALID 17
// Eingabe eines Strings
#define ED_INPUT 10
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index 0dd96130d155..152a8bf927a6 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -59,7 +59,7 @@ public:
private:
void ResetRenameInput();
- void CheckNewNameExists();
+ void CheckNewTabName();
ScDocument* GetSelectedDoc();
private:
@@ -79,6 +79,10 @@ private:
CancelButton aBtnCancel;
HelpButton aBtnHelp;
+ String maStrTabNameUsed;
+ String maStrTabNameEmpty;
+ String maStrTabNameInvalid;
+
const String& mrDefaultName;
USHORT nDocument;
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index 5413190144c7..4985706c3991 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -76,6 +76,10 @@ ScMoveTableDlg::ScMoveTableDlg( Window* pParent,
aBtnOk ( this, ScResId( BTN_OK ) ),
aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
aBtnHelp ( this, ScResId( BTN_HELP ) ),
+
+ maStrTabNameUsed( ScResId(STR_TABNAME_WARN_USED) ),
+ maStrTabNameEmpty( ScResId(STR_TABNAME_WARN_EMPTY) ),
+ maStrTabNameInvalid( ScResId(STR_TABNAME_WARN_INVALID) ),
//
mrDefaultName( rDefault ),
nDocument ( 0 ),
@@ -161,16 +165,35 @@ void ScMoveTableDlg::ResetRenameInput()
// move
aEdTabName.SetText(mrDefaultName);
- CheckNewNameExists();
+ CheckNewTabName();
}
-void ScMoveTableDlg::CheckNewNameExists()
+void ScMoveTableDlg::CheckNewTabName()
{
+ const String& rNewName = aEdTabName.GetText();
+ if (!rNewName.Len())
+ {
+ // New sheet name is empty. This is not good.
+ aFtWarn.SetText(maStrTabNameEmpty);
+ aFtWarn.Show();
+ aBtnOk.Disable();
+ return;
+ }
+
+ if (!ScDocument::ValidTabName(rNewName))
+ {
+ // New sheet name contains invalid characters.
+ aFtWarn.SetText(maStrTabNameInvalid);
+ aFtWarn.Show();
+ aBtnOk.Disable();
+ return;
+ }
+
bool bFound = false;
USHORT nLast = aLbTable.GetEntryCount() - 1;
for ( USHORT i=0; i<=nLast; ++i )
{
- if ( aEdTabName.GetText() == aLbTable.GetEntry( i ) )
+ if ( rNewName == aLbTable.GetEntry( i ) )
{
if( ( aBtnMove.IsChecked() ) &&
( aLbDoc.GetSelectEntryPos() == 0 ) &&
@@ -180,13 +203,20 @@ void ScMoveTableDlg::CheckNewNameExists()
bFound = false;
else
bFound = true;
-
}
}
+
if ( bFound )
+ {
+ aFtWarn.SetText(maStrTabNameUsed);
aFtWarn.Show();
+ aBtnOk.Disable();
+ }
else
+ {
aFtWarn.Hide();
+ aBtnOk.Enable();
+ }
}
ScDocument* ScMoveTableDlg::GetSelectedDoc()
@@ -330,7 +360,7 @@ IMPL_LINK( ScMoveTableDlg, SelHdl, ListBox *, pLb )
IMPL_LINK( ScMoveTableDlg, CheckNameHdl, Edit *, pEdt )
{
if ( pEdt == &aEdTabName )
- CheckNewNameExists();
+ CheckNewTabName();
return 0;
}
diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src
index e42cff3e1c83..6da360c708dd 100644
--- a/sc/source/ui/src/miscdlgs.src
+++ b/sc/source/ui/src/miscdlgs.src
@@ -543,7 +543,7 @@ ModalDialog RID_SCDLG_MOVETAB
{
Pos = MAP_APPFONT ( 12 , 197 ) ;
Size = MAP_APPFONT ( 134 , 8 ) ;
- Text [ en-US ] = "This name is already used." ;
+ Text [ en-US ] = "..." ;
};
String STR_CURRENTDOC
{
@@ -553,6 +553,18 @@ ModalDialog RID_SCDLG_MOVETAB
{
Text [ en-US ] = "- new document -" ;
};
+ String STR_TABNAME_WARN_USED
+ {
+ Text [ en-US ] = "This name is already used." ;
+ };
+ String STR_TABNAME_WARN_EMPTY
+ {
+ Text [ en-US ] = "Name is empty." ;
+ };
+ String STR_TABNAME_WARN_INVALID
+ {
+ Text [ en-US ] = "Name contains one or more invalid characters." ;
+ };
};
ModalDialog RID_SCDLG_STRINPUT