diff options
author | Thomas Benisch <tbe@openoffice.org> | 2001-10-24 09:27:33 +0000 |
---|---|---|
committer | Thomas Benisch <tbe@openoffice.org> | 2001-10-24 09:27:33 +0000 |
commit | c9c530f9de875b9419da22703c37a1cd5f2e320d (patch) | |
tree | 8ca7556dbcace09d00f452e6ecbba96f2e642304 /basctl | |
parent | 9fcd600eecc329f2a734dfef1cae793a8cc1c1bd (diff) |
#88565# change module management from sbx to library container
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2.cxx | 229 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 46 | ||||
-rw-r--r-- | basctl/source/basicide/basides1.cxx | 6 |
3 files changed, 145 insertions, 136 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index f9380888f387..c6e3675382f3 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: baside2.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: tbe $ $Date: 2001-09-25 09:08:45 $ + * last change: $Author: tbe $ $Date: 2001-10-24 10:27:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -304,39 +304,42 @@ void ModulWindow::CheckCompileBasic() { DBG_CHKTHIS( ModulWindow, 0 ); - // Zur Laufzeit wird niemals compiliert! - BOOL bRunning = StarBASIC::IsRunning(); - BOOL bModified = ( !xModule->IsCompiled() || - ( GetEditEngine() && GetEditEngine()->IsModified() ) ); - - if ( !bRunning && bModified ) + if ( xModule.Is() ) { - BOOL bDone = FALSE; - Application::EnterWait(); + // Zur Laufzeit wird niemals compiliert! + BOOL bRunning = StarBASIC::IsRunning(); + BOOL bModified = ( !xModule->IsCompiled() || + ( GetEditEngine() && GetEditEngine()->IsModified() ) ); - if( bModified ) + if ( !bRunning && bModified ) { - AssertValidEditEngine(); - GetEditorWindow().SetSourceInBasic( FALSE ); - } + BOOL bDone = FALSE; + Application::EnterWait(); - BOOL bWasModified = GetBasic()->IsModified(); + if( bModified ) + { + AssertValidEditEngine(); + GetEditorWindow().SetSourceInBasic( FALSE ); + } - bDone = GetBasic()->Compile( xModule ); - if ( !bWasModified ) - GetBasic()->SetModified( FALSE ); + BOOL bWasModified = GetBasic()->IsModified(); - if ( bDone ) - { - GetBreakPoints().SetBreakPointsInBasic( xModule ); - } + bDone = GetBasic()->Compile( xModule ); + if ( !bWasModified ) + GetBasic()->SetModified( FALSE ); - Application::LeaveWait(); + if ( bDone ) + { + GetBreakPoints().SetBreakPointsInBasic( xModule ); + } + + Application::LeaveWait(); -// BasicIDE::MarkDocShellModified( GetBasic() ); + //BasicIDE::MarkDocShellModified( GetBasic() ); - aStatus.bError = !bDone; - aStatus.bIsRunning = FALSE; + aStatus.bError = !bDone; + aStatus.bIsRunning = FALSE; + } } } @@ -345,7 +348,7 @@ BOOL ModulWindow::BasicExecute() DBG_CHKTHIS( ModulWindow, 0 ); CheckCompileBasic(); - if ( !aStatus.bError && xModule->IsCompiled() ) + if ( xModule.Is() && xModule->IsCompiled() && !aStatus.bError ) { if ( GetBreakPoints().Count() ) aStatus.nBasicFlags = aStatus.nBasicFlags | SbDEBUG_BREAK; @@ -395,7 +398,12 @@ BOOL ModulWindow::CompileBasic() { DBG_CHKTHIS( ModulWindow, 0 ); CheckCompileBasic(); - return xModule->IsCompiled(); + + BOOL bIsCompiled = FALSE; + if ( xModule.Is() ) + bIsCompiled = xModule->IsCompiled(); + + return bIsCompiled; } BOOL ModulWindow::BasicRun() @@ -561,39 +569,44 @@ BOOL ModulWindow::SaveBasicSource() BOOL ModulWindow::ToggleBreakPoint( ULONG nLine ) { DBG_ASSERT( xModule.Is(), "Kein Modul!" ); - CheckCompileBasic(); - if ( aStatus.bError ) - { - Sound::Beep(); - return FALSE; - } BOOL bNewBreakPoint = FALSE; - BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine ); - if ( pBrk ) // entfernen - { - xModule->ClearBP( (USHORT)nLine ); - delete GetBreakPoints().Remove( pBrk ); - } - else // einen erzeugen + + if ( xModule.Is() ) { - if ( xModule->SetBP( (USHORT)nLine) ) + CheckCompileBasic(); + if ( aStatus.bError ) { - GetBreakPoints().InsertSorted( new BreakPoint( nLine ) ); - bNewBreakPoint = TRUE; - if ( StarBASIC::IsRunning() ) + Sound::Beep(); + return FALSE; + } + + BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine ); + if ( pBrk ) // entfernen + { + xModule->ClearBP( (USHORT)nLine ); + delete GetBreakPoints().Remove( pBrk ); + } + else // einen erzeugen + { + if ( xModule->SetBP( (USHORT)nLine) ) { - for ( USHORT nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ ) + GetBreakPoints().InsertSorted( new BreakPoint( nLine ) ); + bNewBreakPoint = TRUE; + if ( StarBASIC::IsRunning() ) { - SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod ); - DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" ); - pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK ); + for ( USHORT nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ ) + { + SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod ); + DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" ); + pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK ); + } } } - } - if ( !bNewBreakPoint ) - Sound::Beep(); + if ( !bNewBreakPoint ) + Sound::Beep(); + } } return bNewBreakPoint; @@ -603,13 +616,15 @@ void ModulWindow::UpdateBreakPoint( const BreakPoint& rBrk ) { DBG_ASSERT( xModule.Is(), "Kein Modul!" ); - CheckCompileBasic(); + if ( xModule.Is() ) + { + CheckCompileBasic(); - rtl::OUString aModName; - if ( rBrk.bEnabled ) - xModule->SetBP( (USHORT)rBrk.nLine ); - else - xModule->ClearBP( (USHORT)rBrk.nLine ); + if ( rBrk.bEnabled ) + xModule->SetBP( (USHORT)rBrk.nLine ); + else + xModule->ClearBP( (USHORT)rBrk.nLine ); + } } @@ -787,39 +802,43 @@ void ModulWindow::EditMacro( const String& rMacroName ) { DBG_CHKTHIS( ModulWindow, 0 ); DBG_ASSERT( xModule.Is(), "Kein Modul!" ); - CheckCompileBasic(); - if ( !aStatus.bError ) + if ( xModule.Is() ) { - USHORT nStart, nEnd; - SbMethod* pMethod = (SbMethod*)xModule->Find( rMacroName, SbxCLASS_METHOD ); - if ( pMethod ) + CheckCompileBasic(); + + if ( !aStatus.bError ) { - pMethod->GetLineRange( nStart, nEnd ); - if ( nStart ) - { - // Basic beginnt bei 1 - nStart--; - nEnd--; - } - TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) ); - AssertValidEditEngine(); - TextView * pView = GetEditView(); - // ggf. hinscrollen, so dass erste Zeile oben... - long nVisHeight = GetOutputSizePixel().Height(); - if ( (long)pView->GetTextEngine()->GetTextHeight() > nVisHeight ) + USHORT nStart, nEnd; + SbMethod* pMethod = (SbMethod*)xModule->Find( rMacroName, SbxCLASS_METHOD ); + if ( pMethod ) { - long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight; - long nOldStartY = pView->GetStartDocPos().Y(); - long nNewStartY = nStart * pView->GetTextEngine()->GetCharHeight(); - nNewStartY = Min( nNewStartY, nMaxY ); - pView->Scroll( 0, -(nNewStartY-nOldStartY) ); - pView->ShowCursor( FALSE, TRUE ); - GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() ); + pMethod->GetLineRange( nStart, nEnd ); + if ( nStart ) + { + // Basic beginnt bei 1 + nStart--; + nEnd--; + } + TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) ); + AssertValidEditEngine(); + TextView * pView = GetEditView(); + // ggf. hinscrollen, so dass erste Zeile oben... + long nVisHeight = GetOutputSizePixel().Height(); + if ( (long)pView->GetTextEngine()->GetTextHeight() > nVisHeight ) + { + long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight; + long nOldStartY = pView->GetStartDocPos().Y(); + long nNewStartY = nStart * pView->GetTextEngine()->GetCharHeight(); + nNewStartY = Min( nNewStartY, nMaxY ); + pView->Scroll( 0, -(nNewStartY-nOldStartY) ); + pView->ShowCursor( FALSE, TRUE ); + GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() ); + } + pView->SetSelection( aSel ); + pView->ShowCursor(); + pView->GetWindow()->GrabFocus(); } - pView->SetSelection( aSel ); - pView->ShowCursor(); - pView->GetWindow()->GrabFocus(); } } } @@ -871,15 +890,18 @@ void __EXPORT ModulWindow::UpdateData() // geaendert hat. // => Keine Unterbrechungen erwuenscht! - SetModule( ::rtl::OUString( xModule->GetSource() ) ); - - if ( GetEditView() ) + if ( xModule.Is() ) { - TextSelection aSel = GetEditView()->GetSelection(); - GetEditEngine()->SetText( xModule->GetSource() ); - GetEditView()->SetSelection( aSel ); - GetEditEngine()->SetModified( FALSE ); - BasicIDE::MarkDocShellModified( GetBasic() ); + SetModule( ::rtl::OUString( xModule->GetSource() ) ); + + if ( GetEditView() ) + { + TextSelection aSel = GetEditView()->GetSelection(); + GetEditEngine()->SetText( xModule->GetSource() ); + GetEditView()->SetSelection( aSel ); + GetEditEngine()->SetModified( FALSE ); + BasicIDE::MarkDocShellModified( GetBasic() ); + } } } @@ -1264,15 +1286,18 @@ USHORT __EXPORT ModulWindow::GetSearchOptions() void __EXPORT ModulWindow::BasicStarted() { - aStatus.bIsRunning = TRUE; - if ( GetBreakPoints().Count() ) + if ( xModule.Is() ) { - GetBreakPoints().SetBreakPointsInBasic( xModule ); - for ( USHORT nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ ) + aStatus.bIsRunning = TRUE; + if ( GetBreakPoints().Count() ) { - SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod ); - DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" ); - pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK ); + GetBreakPoints().SetBreakPointsInBasic( xModule ); + for ( USHORT nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ ) + { + SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod ); + DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" ); + pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK ); + } } } } @@ -1287,7 +1312,7 @@ String ModulWindow::CreateSbxDescription() { String aDescription = IDEBaseWindow::CreateSbxDescription(); aDescription += ';'; - aDescription += GetSbModule()->GetName(); + aDescription += GetName(); return aDescription; } diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 7853368c5c3d..437f33052d6d 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -2,9 +2,9 @@ * * $RCSfile: baside2b.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: tbe $ $Date: 2001-10-04 16:49:24 $ + * last change: $Author: tbe $ $Date: 2001-10-24 10:27:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -658,36 +658,25 @@ BOOL EditorWindow::SetSourceInBasic( BOOL bQuiet ) else if ( !StarBASIC::IsRunning() ) // Nicht zur Laufzeit! { String aSource( pEditEngine->GetText() ); - DBG_ASSERT( pModulWindow->GetSbModule(), "Kein Modul?!" ); - pModulWindow->GetSbModule()->SetSource( aSource ); - pModulWindow->SetModule( ::rtl::OUString( aSource ) ); + ::rtl::OUString aModule( aSource ); - // update module in library + // update module in basic SbModule* pModule = pModulWindow->GetSbModule(); DBG_ASSERT(pModule, "EditorWindow::SetSourceInBasic: No Module found!"); if ( pModule ) - { - SbxObject* pParent = pModule->GetParent(); - StarBASIC* pBasic = PTR_CAST(StarBASIC,pParent); - DBG_ASSERT(pBasic, "EditorWindow::SetSourceInBasic: No Basic found!"); - if ( pBasic ) - { - BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic ); - DBG_ASSERT(pBasMgr, "EditorWindow::SetSourceInBasic: No BasicManager found!"); - if ( pBasMgr ) - { - SfxObjectShell* pShell = BasicIDE::FindDocShell( pBasMgr ); - String aLibName = pBasic->GetName(); - String aModName = pModule->GetName(); - ::rtl::OUString aModule = pModule->GetSource(); + pModule->SetSource( aSource ); - BasicIDE::UpdateModule( pShell, aLibName, aModName, aModule ); - } - } - } + // update module in module window + pModulWindow->SetModule( aModule ); + + // update module in library + SfxObjectShell* pShell = pModulWindow->GetShell(); + String aLibName = pModulWindow->GetLibName(); + String aName = pModulWindow->GetName(); + BasicIDE::UpdateModule( pShell, aLibName, aName, aModule ); pEditEngine->SetModified( FALSE ); - BasicIDE::MarkDocShellModified( pModulWindow->GetBasic() ); + BasicIDE::MarkDocShellModified( pShell ); bChanged = TRUE; } } @@ -700,11 +689,6 @@ void EditorWindow::CreateEditEngine() if ( pEditEngine ) return; -#ifdef DEBUG - BOOL bModified = pModulWindow->GetSbModule()->IsModified(); -#endif - - pEditEngine = new ExtTextEngine; pEditView = new ExtTextView( pEditEngine, this ); pEditView->SetAutoIndentMode( TRUE ); @@ -731,7 +715,7 @@ void EditorWindow::CreateEditEngine() aHighlighter.initialize( HIGHLIGHT_BASIC ); bDoSyntaxHighlight = FALSE; // Bei grossen Texten zu langsam... - String aSource( pModulWindow->GetSbModule()->GetSource() ); + String aSource( pModulWindow->GetModule() ); aSource.ConvertLineEnd( LINEEND_LF ); USHORT nLines = aSource.GetTokenCount( LINE_SEP ); diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 11a76107cff2..7590a759c1b3 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -2,9 +2,9 @@ * * $RCSfile: basides1.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: tbe $ $Date: 2001-09-25 09:10:50 $ + * last change: $Author: tbe $ $Date: 2001-10-24 10:27:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1028,7 +1028,7 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, BOOL bUpdateTabBar, BO { StarBASIC* pLib = ((ModulWindow*)pCurWin)->GetBasic(); LibInfo* pLibInf = IDE_DLL()->GetExtraData()->GetLibInfos().GetInfo( pLib, TRUE ); - pLibInf->aCurrentModule = ((ModulWindow*)pCurWin)->GetSbModule()->GetName(); + pLibInf->aCurrentModule = pCurWin->GetName(); } } else |