summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sb@openoffice.org>2002-07-09 07:12:31 +0000
committerStephan Bergmann <sb@openoffice.org>2002-07-09 07:12:31 +0000
commit61e62613dce4d1eb2d0f60f3ed4c8aaa29257704 (patch)
tree446488f4c7f770e3787fe6abde2f476467bb916a
parentd91055a4ac6bc1a3044cacabe452683a6502a7a5 (diff)
#99316# Check for valid names when creating new Modules/Dialogs.
-rw-r--r--basctl/source/basicide/macrodlg.cxx15
-rw-r--r--basctl/source/basicide/moduldl2.cxx23
-rw-r--r--basctl/source/basicide/moduldlg.cxx27
-rw-r--r--basctl/source/basicide/moduldlg.hxx8
4 files changed, 48 insertions, 25 deletions
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 496534068ef0..8834298862f4 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: macrodlg.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: mba $ $Date: 2002-04-24 08:25:53 $
+ * last change: $Author: sb $ $Date: 2002-07-09 08:12:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,6 +59,7 @@
*
************************************************************************/
+#include <memory>
#include <ide_pch.hxx>
@@ -440,11 +441,12 @@ SbMethod* MacroChooser::CreateMacro()
if ( !pModule )
{
- NewObjectDialog* pNewDlg = new NewObjectDialog( this, NEWOBJECTMODE_MOD );
- pNewDlg->SetObjectName( aModName );
- if ( pNewDlg->Execute() )
+ std::auto_ptr< NewObjectDialog > xNewDlg(
+ new NewObjectDialog(this, NEWOBJECTMODE_MOD, true));
+ xNewDlg->SetObjectName(aModName);
+ if (xNewDlg->Execute() != 0)
{
- aModName = pNewDlg->GetObjectName();
+ aModName = xNewDlg->GetObjectName();
if ( aModName.Len() == 0 )
aModName = BasicIDE::CreateModuleName( pShell, aLibName );
@@ -466,7 +468,6 @@ SbMethod* MacroChooser::CreateMacro()
DBG_ERROR( aBStr.GetBuffer() );
}
}
- delete pNewDlg;
}
DBG_ASSERT( !pModule || !pModule->GetMethods()->Find( aSubName, SbxCLASS_METHOD ), "Macro existiert schon!" );
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index e5019afb7372..ab489c26071d 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: moduldl2.cxx,v $
*
- * $Revision: 1.36 $
+ * $Revision: 1.37 $
*
- * last change: $Author: sb $ $Date: 2002-07-05 10:27:37 $
+ * last change: $Author: sb $ $Date: 2002-07-09 08:12:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -474,7 +474,21 @@ BOOL __EXPORT BasicCheckBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNe
// NewObjectDialog
//----------------------------------------------------------------------------
-NewObjectDialog::NewObjectDialog( Window* pParent, USHORT nMode )
+IMPL_LINK(NewObjectDialog, OkButtonHandler, Button *, EMPTYARG)
+{
+ if (BasicIDE::IsValidSbxName(aEdit.GetText()))
+ EndDialog(1);
+ else
+ {
+ ErrorBox(this, WB_OK | WB_DEF_OK,
+ String(IDEResId(RID_STR_BADSBXNAME))).Execute();
+ aEdit.GrabFocus();
+ }
+ return 0;
+}
+
+NewObjectDialog::NewObjectDialog(Window * pParent, USHORT nMode,
+ bool bCheckName)
: ModalDialog( pParent, IDEResId( RID_DLG_NEWLIB ) ),
aText( this, IDEResId( RID_FT_NEWLIB ) ),
aEdit( this, IDEResId( RID_ED_LIBNAME ) ),
@@ -496,6 +510,9 @@ NewObjectDialog::NewObjectDialog( Window* pParent, USHORT nMode )
{
SetText( String( IDEResId( RID_STR_NEWDLG ) ) );
}
+
+ if (bCheckName)
+ aOKButton.SetClickHdl(LINK(this, NewObjectDialog, OkButtonHandler));
}
//----------------------------------------------------------------------------
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 7489e2c5edc6..83442925153c 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: moduldlg.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: sb $ $Date: 2002-07-03 15:50:53 $
+ * last change: $Author: sb $ $Date: 2002-07-09 08:12:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,6 +59,7 @@
*
************************************************************************/
+#include <memory>
#include <ide_pch.hxx>
@@ -903,12 +904,13 @@ void ObjectPage::NewModule()
if ( pBasMgr )
{
SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
- NewObjectDialog* pNewDlg = new NewObjectDialog( this, NEWOBJECTMODE_MOD );
- pNewDlg->SetObjectName( BasicIDE::CreateModuleName( pShell, aLibName ) );
+ std::auto_ptr< NewObjectDialog > xNewDlg(
+ new NewObjectDialog(this, NEWOBJECTMODE_MOD, true));
+ xNewDlg->SetObjectName( BasicIDE::CreateModuleName( pShell, aLibName ) );
- if ( pNewDlg->Execute() )
+ if (xNewDlg->Execute() != 0)
{
- String aModName( pNewDlg->GetObjectName() );
+ String aModName( xNewDlg->GetObjectName() );
if ( aModName.Len() == 0 )
aModName = BasicIDE::CreateModuleName( pShell, aLibName );
@@ -946,7 +948,6 @@ void ObjectPage::NewModule()
DBG_ERROR( aBStr.GetBuffer() );
}
}
- delete pNewDlg;
}
}
}
@@ -962,12 +963,15 @@ void ObjectPage::NewDialog()
if ( pBasMgr )
{
SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
- NewObjectDialog* pNewDlg = new NewObjectDialog( this, NEWOBJECTMODE_DLG );
- pNewDlg->SetObjectName( BasicIDE::CreateDialogName( pShell, aLibName ) );
+ std::auto_ptr< NewObjectDialog > xNewDlg(
+ new NewObjectDialog(this, NEWOBJECTMODE_DLG, true));
+ xNewDlg->SetObjectName( BasicIDE::CreateDialogName( pShell, aLibName ) );
- if ( pNewDlg->Execute() )
+ if (xNewDlg->Execute() != 0)
{
- String aDlgName( pNewDlg->GetObjectName() );
+ String aDlgName( xNewDlg->GetObjectName() );
+ if (aDlgName.Len() == 0)
+ aDlgName = BasicIDE::CreateDialogName(pShell, aLibName);
try
{
@@ -1002,7 +1006,6 @@ void ObjectPage::NewDialog()
DBG_ERROR( aBStr.GetBuffer() );
}
}
- delete pNewDlg;
}
}
}
diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx
index b7e96a1b7b7a..7992fc2c879e 100644
--- a/basctl/source/basicide/moduldlg.hxx
+++ b/basctl/source/basicide/moduldlg.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: moduldlg.hxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: sb $ $Date: 2002-07-03 15:50:51 $
+ * last change: $Author: sb $ $Date: 2002-07-09 08:12:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -111,8 +111,10 @@ private:
OKButton aOKButton;
CancelButton aCancelButton;
+ DECL_LINK(OkButtonHandler, Button *);
+
public:
- NewObjectDialog( Window* pParent, USHORT nMode );
+ NewObjectDialog(Window * pParent, USHORT nMode, bool bCheckName = false);
~NewObjectDialog();
String GetObjectName() const { return aEdit.GetText(); }