summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorAndreas Bregas <ab@openoffice.org>2002-07-30 12:10:28 +0000
committerAndreas Bregas <ab@openoffice.org>2002-07-30 12:10:28 +0000
commitb2f27987b2c766f511dad8415942109042a36b2a (patch)
tree1b27f9863d6e487f5718737389f72e3b78a98086 /basctl
parentb598ce202a3f7f9d655e7520e1e9cd9211c986da (diff)
#101304# Save dialog for macro recording
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/basidesh.src6
-rw-r--r--basctl/source/basicide/macrodlg.cxx93
-rw-r--r--basctl/source/basicide/macrodlg.hrc9
-rw-r--r--basctl/source/basicide/macrodlg.hxx9
-rw-r--r--basctl/source/basicide/macrodlg.src65
-rw-r--r--basctl/source/basicide/moduldl2.cxx194
-rw-r--r--basctl/source/basicide/moduldlg.cxx110
-rw-r--r--basctl/source/basicide/moduldlg.hxx10
8 files changed, 310 insertions, 186 deletions
diff --git a/basctl/source/basicide/basidesh.src b/basctl/source/basicide/basidesh.src
index 391383c5efdd..0a509dfb0208 100644
--- a/basctl/source/basicide/basidesh.src
+++ b/basctl/source/basicide/basidesh.src
@@ -2,9 +2,9 @@
*
* $RCSfile: basidesh.src,v $
*
- * $Revision: 1.71 $
+ * $Revision: 1.72 $
*
- * last change: $Author: sb $ $Date: 2002-07-09 14:49:04 $
+ * last change: $Author: ab $ $Date: 2002-07-30 13:10:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -3038,7 +3038,7 @@ Menu RID_POPUP_DLGED
ImageList RID_IMGLST_OBJECTS
{
ImageBitmap = Bitmap { FILE = "im_ges.bmp" ; };
- MaskColor = Color { Red = 0xFFFF ; Green = 0xFFFF ; Blue = 0xFFFF ; };
+ MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
IdList =
{
IMGID_APPICON ;
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index ad8f48c0ba19..06bdc2d924a2 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: macrodlg.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: ab $ $Date: 2002-07-30 10:35:43 $
+ * last change: $Author: ab $ $Date: 2002-07-30 13:10:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -102,8 +102,10 @@ MacroChooser::MacroChooser( Window* pParnt, BOOL bScanBasics ) :
SfxModalDialog( pParnt, IDEResId( RID_MACROCHOOSER ) ),
aMacroNameTxt( this, IDEResId( RID_TXT_MACRONAME ) ),
aMacroNameEdit( this, IDEResId( RID_ED_MACRONAME ) ),
+ aMacrosInTxt( this, IDEResId( RID_TXT_MACROSIN ) ),
aMacroBox( this, IDEResId( RID_CTRL_MACRO ) ),
aMacroFromTxT( this, IDEResId( RID_TXT_MACROFROM ) ),
+ aMacrosSaveInTxt( this, IDEResId( RID_TXT_SAVEMACRO ) ),
aBasicBox( this, IDEResId( RID_CTRL_LIB ) ),
aRunButton( this, IDEResId( RID_PB_RUN ) ),
aCloseButton( this, IDEResId( RID_PB_CLOSE ) ),
@@ -111,7 +113,9 @@ MacroChooser::MacroChooser( Window* pParnt, BOOL bScanBasics ) :
aEditButton( this, IDEResId( RID_PB_EDIT ) ),
aNewDelButton( this, IDEResId( RID_PB_DEL ) ),
aOrganizeButton( this, IDEResId( RID_PB_ORG ) ),
- aHelpButton( this, IDEResId( RID_PB_HELP ) )
+ aHelpButton( this, IDEResId( RID_PB_HELP ) ),
+ aNewLibButton( this, IDEResId( RID_PB_NEWLIB ) ),
+ aNewModButton( this, IDEResId( RID_PB_NEWMOD ) )
//aDescrTxt( this, IDEResId( RID_TXT_DESCRIPTION ) ),
//aDescrEdit( this, IDEResId( RID_ML_DESCRIPTION ) )
{
@@ -136,6 +140,13 @@ MacroChooser::MacroChooser( Window* pParnt, BOOL bScanBasics ) :
aNewDelButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
aOrganizeButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ // Buttons only for MACROCHOOSER_RECORDING
+ aNewLibButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ aNewModButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ aNewLibButton.Hide(); // default
+ aNewModButton.Hide(); // default
+ aMacrosSaveInTxt.Hide(); // default
+
aMacroNameEdit.SetModifyHdl( LINK( this, MacroChooser, EditModifyHdl ) );
aBasicBox.SetSelectHdl( LINK( this, MacroChooser, BasicSelectHdl ) );
@@ -436,38 +447,10 @@ SbMethod* MacroChooser::CreateMacro()
if ( aLibName != pBasic->GetName() )
aLibName = pBasic->GetName();
- if ( aModName.Len() == 0 )
- aModName = pModule ? pModule->GetName() : BasicIDE::CreateModuleName( pShell, aLibName );
-
if ( !pModule )
{
- std::auto_ptr< NewObjectDialog > xNewDlg(
- new NewObjectDialog(this, NEWOBJECTMODE_MOD, true));
- xNewDlg->SetObjectName(aModName);
- if (xNewDlg->Execute() != 0)
- {
- aModName = xNewDlg->GetObjectName();
-
- if ( aModName.Len() == 0 )
- aModName = BasicIDE::CreateModuleName( pShell, aLibName );
-
- try
- {
- ::rtl::OUString aModule = BasicIDE::CreateModule( pShell, aLibName, aModName, FALSE );
- pModule = pBasic->FindModule( aModName );
- DBG_ASSERT( pModule , "MacroChooser::CreateMacro: module was not created!" );
- }
- catch ( container::ElementExistException& )
- {
- ErrorBox( this, WB_OK | WB_DEF_OK,
- String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
- }
- catch ( container::NoSuchElementException& e )
- {
- ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
- DBG_ERROR( aBStr.GetBuffer() );
- }
- }
+ pModule = createModImpl( static_cast<Window*>( this ),
+ pShell, pBasic, aBasicBox, aLibName, aModName );
}
DBG_ASSERT( !pModule || !pModule->GetMethods()->Find( aSubName, SbxCLASS_METHOD ), "Macro existiert schon!" );
@@ -816,6 +799,7 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton )
}
}
}
+
else if ( pButton == &aAssignButton )
{
String aLib, aMod, aSub;
@@ -839,6 +823,31 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton )
if ( pChildWin )
EndDialog( MACRO_CLOSE );
}
+ else if ( pButton == &aNewLibButton )
+ {
+ String aLib, aMod, aSub;
+ BasicManager* pBasMgr = aBasicBox.GetSelectedSbx( aLib, aMod, aSub );
+
+ DBG_ASSERT( pBasMgr, "Record/New library: No BasicManager?" );
+ SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
+ createLibImpl( static_cast<Window*>( this ), pShell, NULL, &aBasicBox );
+ }
+ else if ( pButton == &aNewModButton )
+ {
+ String aLibName, aModName, aSubName;
+ BasicManager* pBasMgr = aBasicBox.GetSelectedSbx( aLibName, aModName, aSubName );
+
+ DBG_ASSERT( pBasMgr, "Record/New module: No BasicManager?" );
+ StarBASIC* pBasic = aLibName.Len() ? pBasMgr->GetLib( aLibName ) : pBasMgr->GetLib( 0 );
+ if ( !pBasic )
+ pBasic = pBasMgr->GetLib( 0 );
+ DBG_ASSERT( pBasic, "Record/New module: Kein Basic?" );
+
+ SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
+ aModName = String();
+ createModImpl( static_cast<Window*>( this ), pShell,
+ pBasic, aBasicBox, aLibName, aModName );
+ }
else if ( pButton == &aOrganizeButton )
{
StoreMacroDescription();
@@ -917,9 +926,25 @@ void MacroChooser::SetMode( USHORT nM )
aRunButton.SetText( String( IDEResId( RID_STR_RECORD ) ) );
EnableButton( aNewDelButton, FALSE );
EnableButton( aOrganizeButton, FALSE );
+
+ aAssignButton.Hide();
+ aEditButton.Hide();
+ aNewDelButton.Hide();
+ aOrganizeButton.Hide();
+ aMacroFromTxT.Hide();
+
+ aNewLibButton.Show();
+ aNewModButton.Show();
+ aMacrosSaveInTxt.Show();
+
+ Point aHelpPos = aHelpButton.GetPosPixel();
+ Point aHelpPosLogic = PixelToLogic( aHelpPos, MapMode(MAP_APPFONT) );
+ aHelpPosLogic.Y() -= 34;
+ aHelpPos = LogicToPixel( aHelpPosLogic, MapMode(MAP_APPFONT) );
+ aHelpButton.SetPosPixel( aHelpPos );
+
//aDescrEdit.Disable();
}
-
CheckButtons();
}
diff --git a/basctl/source/basicide/macrodlg.hrc b/basctl/source/basicide/macrodlg.hrc
index 409edd5f3e35..a0608fc4dd50 100644
--- a/basctl/source/basicide/macrodlg.hrc
+++ b/basctl/source/basicide/macrodlg.hrc
@@ -2,9 +2,9 @@
*
* $RCSfile: macrodlg.hrc,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mba $ $Date: 2002-04-22 16:59:54 $
+ * last change: $Author: ab $ $Date: 2002-07-30 13:10:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -84,5 +84,10 @@
#define RID_PB_ASSIGN 13
#define RID_PB_HELP 15
#define RID_ML_DESCRIPTION 16
+#define RID_TXT_MACROSIN 17
+#define RID_TXT_SAVEMACRO 18
+#define RID_PB_NEWLIB 19
+#define RID_PB_NEWMOD 20
#endif // _MACRODLG_HRC
+
diff --git a/basctl/source/basicide/macrodlg.hxx b/basctl/source/basicide/macrodlg.hxx
index 34386aead0ec..0d92d24e8bbc 100644
--- a/basctl/source/basicide/macrodlg.hxx
+++ b/basctl/source/basicide/macrodlg.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: macrodlg.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: mba $ $Date: 2002-04-22 16:59:54 $
+ * last change: $Author: ab $ $Date: 2002-07-30 13:10:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,8 +99,10 @@ class MacroChooser : public SfxModalDialog
private:
FixedText aMacroNameTxt;
Edit aMacroNameEdit;
+ FixedText aMacrosInTxt;
SvTreeListBox aMacroBox;
FixedText aMacroFromTxT;
+ FixedText aMacrosSaveInTxt;
BasicTreeListBox aBasicBox;
PushButton aRunButton;
@@ -110,6 +112,8 @@ private:
PushButton aNewDelButton;
PushButton aOrganizeButton;
HelpButton aHelpButton;
+ PushButton aNewLibButton;
+ PushButton aNewModButton;
//FixedText aDescrTxt;
//ExtendedMultiLineEdit aDescrEdit;
@@ -142,7 +146,6 @@ private:
void StoreMacroDescription();
void RestoreMacroDescription();
-
public:
MacroChooser( Window* pParent, BOOL ScanBasics = TRUE );
~MacroChooser();
diff --git a/basctl/source/basicide/macrodlg.src b/basctl/source/basicide/macrodlg.src
index b3c1140369fe..ae9c80b243ef 100644
--- a/basctl/source/basicide/macrodlg.src
+++ b/basctl/source/basicide/macrodlg.src
@@ -2,9 +2,9 @@
*
* $RCSfile: macrodlg.src,v $
*
- * $Revision: 1.38 $
+ * $Revision: 1.39 $
*
- * last change: $Author: sb $ $Date: 2002-07-03 16:08:13 $
+ * last change: $Author: ab $ $Date: 2002-07-30 13:10:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -84,22 +84,29 @@ ModalDialog RID_MACROCHOOSER
Text [ english_us ] = "Macro" ;
Moveable = TRUE ;
// Closeable = TRUE;
+
+ FixedText RID_TXT_MACROSIN
+ {
+ Pos = MAP_APPFONT ( 122 , 30 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text = "Makros ~in " ;
+ Text [ ENGLISH ] = "Macros ~in " ;
+ };
Control RID_CTRL_MACRO
{
HelpID = HID_BASICIDE_MACROS ;
Border = TRUE ;
- Pos = MAP_APPFONT ( 6 , 31 ) ;
- //Size = MAP_APPFONT ( 100 , 80 ) ;
- Size = MAP_APPFONT ( 100 , 128 ) ;
+ Pos = MAP_APPFONT ( 122 , 41 ) ;
+ Size = MAP_APPFONT ( 100 , 117 ) ;
+ // Size = MAP_APPFONT ( 100 , 117 ) ;
TabStop = TRUE ;
};
Control RID_CTRL_LIB
{
HelpID = HID_BASICIDE_LIBS ;
Border = TRUE ;
- Pos = MAP_APPFONT ( 112 , 16 ) ;
- //Size = MAP_APPFONT ( 110 , 95 ) ;
- Size = MAP_APPFONT ( 110 , 143 ) ;
+ Pos = MAP_APPFONT ( 6 , 41 ) ;
+ Size = MAP_APPFONT ( 110 , 117 ) ;
TabStop = TRUE ;
};
FixedText RID_TXT_MACRONAME
@@ -131,9 +138,17 @@ ModalDialog RID_MACROCHOOSER
Text[ catalan ] = "Nom de la ~macro";
Text[ thai ] = "ชื่อ~มาโคร";
};
+ Edit RID_ED_MACRONAME
+ {
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 110 , 12 ) ;
+ TabStop = TRUE ;
+ };
FixedText RID_TXT_MACROFROM
{
- Pos = MAP_APPFONT ( 112 , 3 ) ;
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
Size = MAP_APPFONT ( 100 , 10 ) ;
Text = "Makro a~us" ;
Text [ ENGLISH ] = "Macro ~from" ;
@@ -160,14 +175,14 @@ ModalDialog RID_MACROCHOOSER
Text[ catalan ] = "Macro ~des de";
Text[ thai ] = "มาโคร~จาก";
};
- Edit RID_ED_MACRONAME
+ FixedText RID_TXT_SAVEMACRO
{
- Border = TRUE ;
- SVLook = TRUE ;
- Pos = MAP_APPFONT ( 6 , 16 ) ;
- Size = MAP_APPFONT ( 100 , 12 ) ;
- TabStop = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text = "M~akro speichern in" ;
+ Text [ ENGLISH ] = "Save m~acros in" ;
};
+
FixedText RID_TXT_DESCRIPTION
{
Pos = MAP_APPFONT ( 6 , 117 ) ;
@@ -258,6 +273,7 @@ ModalDialog RID_MACROCHOOSER
Text[ catalan ] = "Close";
Text[ thai ] = "ปิด";
};
+
PushButton RID_PB_ASSIGN
{
Pos = MAP_APPFONT ( 231 , 60 ) ;
@@ -318,6 +334,20 @@ ModalDialog RID_MACROCHOOSER
Text[ catalan ] = "~Edita";
Text[ thai ] = "แ~ก้ไข";
};
+ PushButton RID_PB_NEWLIB
+ {
+ Pos = MAP_APPFONT ( 231 , 60 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text = "Neue ~Bibliothek" ;
+ Text [ English ] = "New ~libary" ;
+ };
+ PushButton RID_PB_NEWMOD
+ {
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Pos = MAP_APPFONT ( 231 , 77 ) ;
+ Text = "Neues M~odul" ;
+ Text [ English ] = "New m~odule" ;
+ };
PushButton RID_PB_DEL
{
Pos = MAP_APPFONT ( 231 , 94 ) ;
@@ -574,8 +604,8 @@ String RID_STR_RUN
String RID_STR_RECORD
{
- Text = "~Aufzeichnen" ;
- Text [ ENGLISH ] = "~Record" ;
+ Text = "~Speichern" ;
+ Text [ ENGLISH ] = "~Save" ;
Text [ norwegian ] = "~Record" ;
Text [ italian ] = "~Registra" ;
Text [ portuguese_brazilian ] = "~Gravar" ;
@@ -599,3 +629,4 @@ String RID_STR_RECORD
Text[ catalan ] = "~Record";
Text[ thai ] = "~Record";
};
+
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index ab489c26071d..589bb22b520d 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: moduldl2.cxx,v $
*
- * $Revision: 1.37 $
+ * $Revision: 1.38 $
*
- * last change: $Author: sb $ $Date: 2002-07-09 08:12:30 $
+ * last change: $Author: ab $ $Date: 2002-07-30 13:10:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -813,83 +813,7 @@ void LibPage::NewLib()
DBG_ASSERT( pBasMgr, "BasMgr?!" );
SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
- // create library name
- String aLibName;
- String aLibStdName( String( RTL_CONSTASCII_USTRINGPARAM( "Library" ) ) );
- //String aLibStdName( IDEResId( RID_STR_STDLIBNAME ) );
- BOOL bValid = FALSE;
- USHORT i = 1;
- while ( !bValid )
- {
- aLibName = aLibStdName;
- aLibName += String::CreateFromInt32( i );
- if ( !BasicIDE::HasModuleLibrary( pShell, aLibName ) && !BasicIDE::HasDialogLibrary( pShell, aLibName ) )
- bValid = TRUE;
- i++;
- }
-
- NewObjectDialog* pNewDlg = new NewObjectDialog( this, NEWOBJECTMODE_LIB );
- pNewDlg->SetObjectName( aLibName );
-
- if ( pNewDlg->Execute() )
- {
- if ( pNewDlg->GetObjectName().Len() )
- aLibName = pNewDlg->GetObjectName();
-
- if ( aLibName.Len() > 30 )
- {
- ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_LIBNAMETOLONG ) ) ).Execute();
- }
- else if ( !BasicIDE::IsValidSbxName( aLibName ) )
- {
- ErrorBox( this, WB_OK | WB_DEF_OK,
- String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
- }
- else if ( BasicIDE::HasModuleLibrary( pShell, aLibName ) || BasicIDE::HasDialogLibrary( pShell, aLibName ) )
- {
- ErrorBox( this, WB_OK | WB_DEF_OK,
- String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
- }
- else
- {
- try
- {
- // create module and dialog library
- Reference< container::XNameContainer > xModLib = BasicIDE::CreateModuleLibrary( pShell, aLibName );
- Reference< container::XNameContainer > xDlgLib = BasicIDE::CreateDialogLibrary( pShell, aLibName );
-
- SvLBoxEntry* pEntry = aLibBox.InsertEntry( aLibName );
- pEntry->SetUserData( new BasicLibUserData( pShell ) );
- aLibBox.SetCurEntry( pEntry );
- //USHORT nPos = (USHORT)aLibBox.GetModel()->GetAbsPos( pEntry );
- //aLibBox.CheckEntryPos( nPos, bLoaded );
-
- // create a module
- String aModName = BasicIDE::CreateModuleName( pShell, aLibName );
- ::rtl::OUString aModule = BasicIDE::CreateModule( pShell, aLibName, aModName, TRUE );
- SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, aModName, BASICIDE_TYPE_MODULE );
- BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
- SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
- SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
- if( pDispatcher )
- {
- pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
- SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
- }
- }
- catch ( container::ElementExistException& e )
- {
- ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
- DBG_ERROR( aBStr.GetBuffer() );
- }
- catch ( container::NoSuchElementException& e )
- {
- ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
- DBG_ERROR( aBStr.GetBuffer() );
- }
- }
- }
- delete pNewDlg;
+ createLibImpl( static_cast<Window*>( this ), pShell, &aLibBox, NULL);
}
//----------------------------------------------------------------------------
@@ -1480,3 +1404,115 @@ SvLBoxEntry* LibPage::ImpInsertLibEntry( const String& rLibName, ULONG nPos )
}
//----------------------------------------------------------------------------
+
+// Helper function
+void createLibImpl( Window* pWin, SfxObjectShell* pShell,
+ BasicCheckBox* pLibBox, BasicTreeListBox* pBasicBox )
+{
+ // create library name
+ String aLibName;
+ String aLibStdName( String( RTL_CONSTASCII_USTRINGPARAM( "Library" ) ) );
+ //String aLibStdName( IDEResId( RID_STR_STDLIBNAME ) );
+ BOOL bValid = FALSE;
+ USHORT i = 1;
+ while ( !bValid )
+ {
+ aLibName = aLibStdName;
+ aLibName += String::CreateFromInt32( i );
+ if ( !BasicIDE::HasModuleLibrary( pShell, aLibName ) && !BasicIDE::HasDialogLibrary( pShell, aLibName ) )
+ bValid = TRUE;
+ i++;
+ }
+
+ std::auto_ptr< NewObjectDialog > xNewDlg( new NewObjectDialog( pWin, NEWOBJECTMODE_LIB ) );
+ xNewDlg->SetObjectName( aLibName );
+
+ if ( xNewDlg->Execute() )
+ {
+ if ( xNewDlg->GetObjectName().Len() )
+ aLibName = xNewDlg->GetObjectName();
+
+ if ( aLibName.Len() > 30 )
+ {
+ ErrorBox( pWin, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_LIBNAMETOLONG ) ) ).Execute();
+ }
+ else if ( !BasicIDE::IsValidSbxName( aLibName ) )
+ {
+ ErrorBox( pWin, WB_OK | WB_DEF_OK,
+ String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
+ }
+ else if ( BasicIDE::HasModuleLibrary( pShell, aLibName ) || BasicIDE::HasDialogLibrary( pShell, aLibName ) )
+ {
+ ErrorBox( pWin, WB_OK | WB_DEF_OK,
+ String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
+ }
+ else
+ {
+ try
+ {
+ // create module and dialog library
+ Reference< container::XNameContainer > xModLib = BasicIDE::CreateModuleLibrary( pShell, aLibName );
+ Reference< container::XNameContainer > xDlgLib = BasicIDE::CreateDialogLibrary( pShell, aLibName );
+
+ if( pLibBox )
+ {
+ SvLBoxEntry* pEntry = pLibBox->InsertEntry( aLibName );
+ pEntry->SetUserData( new BasicLibUserData( pShell ) );
+ pLibBox->SetCurEntry( pEntry );
+ }
+
+ // create a module
+ String aModName = BasicIDE::CreateModuleName( pShell, aLibName );
+ ::rtl::OUString aModule = BasicIDE::CreateModule( pShell, aLibName, aModName, TRUE );
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, aModName, BASICIDE_TYPE_MODULE );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+
+ if( pBasicBox )
+ {
+ SvLBoxEntry* pEntry = pBasicBox->GetCurEntry();
+ SvLBoxEntry* pRootEntry = NULL;
+ while( pEntry )
+ {
+ pRootEntry = pEntry;
+ pEntry = pBasicBox->GetParent( pEntry );
+ }
+
+ SvLBoxEntry* pNewLibEntry = pBasicBox->insertEntry(
+ aLibName, IMGID_LIB, pRootEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJTYPE_LIB ) ) );
+ DBG_ASSERT( pNewLibEntry, "InsertEntry fehlgeschlagen!" );
+
+ if( pNewLibEntry )
+ {
+ SvLBoxEntry* pEntry = pBasicBox->insertEntry(
+ aModName, IMGID_MODULE, pNewLibEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJTYPE_MODULE ) ) );
+ DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
+ pBasicBox->SetCurEntry( pEntry );
+ pBasicBox->Select( pBasicBox->GetCurEntry() ); // OV-Bug?!
+ }
+ }
+ }
+ catch ( container::ElementExistException& e )
+ {
+ ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR( aBStr.GetBuffer() );
+ }
+ catch ( container::NoSuchElementException& e )
+ {
+ ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR( aBStr.GetBuffer() );
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 83442925153c..fc6ccdee976d 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: moduldlg.cxx,v $
*
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
*
- * last change: $Author: sb $ $Date: 2002-07-09 08:12:30 $
+ * last change: $Author: ab $ $Date: 2002-07-30 13:10:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -904,50 +904,9 @@ void ObjectPage::NewModule()
if ( pBasMgr )
{
SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr );
- std::auto_ptr< NewObjectDialog > xNewDlg(
- new NewObjectDialog(this, NEWOBJECTMODE_MOD, true));
- xNewDlg->SetObjectName( BasicIDE::CreateModuleName( pShell, aLibName ) );
-
- if (xNewDlg->Execute() != 0)
- {
- String aModName( xNewDlg->GetObjectName() );
-
- if ( aModName.Len() == 0 )
- aModName = BasicIDE::CreateModuleName( pShell, aLibName );
-
- try
- {
- ::rtl::OUString aModule = BasicIDE::CreateModule( pShell, aLibName, aModName, TRUE );
- SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, aModName, BASICIDE_TYPE_MODULE );
- BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
- SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
- SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
- if( pDispatcher )
- {
- pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
- SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
- }
- SvLBoxEntry* pLibEntry = aBasicBox.FindLibEntry( pLib );
- DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" );
- SvLBoxEntry * pEntry = aBasicBox.insertEntry(
- aModName, IMGID_MODULE, pLibEntry, false,
- std::auto_ptr< BasicEntry >(new BasicEntry(
- OBJTYPE_MODULE)));
- DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
- aBasicBox.SetCurEntry( pEntry );
- aBasicBox.Select( aBasicBox.GetCurEntry() ); // OV-Bug?!
- }
- catch ( container::ElementExistException& )
- {
- ErrorBox( this, WB_OK | WB_DEF_OK,
- String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
- }
- catch ( container::NoSuchElementException& e )
- {
- ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
- DBG_ERROR( aBStr.GetBuffer() );
- }
- }
+ String aModName;
+ createModImpl( static_cast<Window*>( this ), pShell,
+ pLib, aBasicBox, aLibName, aModName );
}
}
}
@@ -1091,3 +1050,62 @@ void LibDialog::SetStorageName( const String& rName )
aName += rName;
aStorageName.SetText( aName );
}
+
+// Helper function
+SbModule* createModImpl( Window* pWin, SfxObjectShell* pShell, StarBASIC* pLib,
+ BasicTreeListBox& rBasicBox, const String& aLibName, String aModName )
+{
+ SbModule* pModule = NULL;
+
+ std::auto_ptr< NewObjectDialog > xNewDlg(
+ new NewObjectDialog( pWin, NEWOBJECTMODE_MOD, true ) );
+ if ( aModName.Len() == 0 )
+ aModName = BasicIDE::CreateModuleName( pShell, aLibName );
+ xNewDlg->SetObjectName( aModName );
+
+ if (xNewDlg->Execute() != 0)
+ {
+ if ( aModName.Len() == 0 )
+ aModName = BasicIDE::CreateModuleName( pShell, aLibName );
+
+ try
+ {
+ ::rtl::OUString aModule = BasicIDE::CreateModule( pShell, aLibName, aModName, TRUE );
+ pModule = pLib->FindModule( aModName );
+
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, aModName, BASICIDE_TYPE_MODULE );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+ SvLBoxEntry* pLibEntry = rBasicBox.FindLibEntry( pLib );
+ DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" );
+ SvLBoxEntry * pEntry = rBasicBox.insertEntry(
+ aModName, IMGID_MODULE, pLibEntry, false,
+ std::auto_ptr< BasicEntry >(new BasicEntry(
+ OBJTYPE_MODULE)));
+ DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
+ rBasicBox.SetCurEntry( pEntry );
+ rBasicBox.Select( rBasicBox.GetCurEntry() ); // OV-Bug?!
+ }
+ catch ( container::ElementExistException& )
+ {
+ ErrorBox( pWin, WB_OK | WB_DEF_OK,
+ String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
+ }
+ catch ( container::NoSuchElementException& e )
+ {
+ ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR( aBStr.GetBuffer() );
+ }
+ }
+ return pModule;
+}
+
+
+
+
diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx
index 7992fc2c879e..02f8e944a6a8 100644
--- a/basctl/source/basicide/moduldlg.hxx
+++ b/basctl/source/basicide/moduldlg.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: moduldlg.hxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: sb $ $Date: 2002-07-09 08:12:31 $
+ * last change: $Author: ab $ $Date: 2002-07-30 13:10:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -307,4 +307,10 @@ public:
void SetTabDlg( TabDialog* p ) { pTabDlg = p;}
};
+// Helper functions
+SbModule* createModImpl( Window* pWin, SfxObjectShell* pShell, StarBASIC* pLib,
+ BasicTreeListBox& rBasicBox, const String& aLibName, String aModName );
+void createLibImpl( Window* pWin, SfxObjectShell* pShell,
+ BasicCheckBox* pLibBox, BasicTreeListBox* pBasicBox );
+
#endif // _MODULDLG_HXX