[Libreoffice-commits] .: basic/inc basic/source

Joseph Powers jpowers at kemper.freedesktop.org
Wed Dec 15 05:58:25 PST 2010


 basic/inc/basic/mybasic.hxx   |   20 +++++++++-----
 basic/source/app/app.cxx      |   24 ++++++++---------
 basic/source/app/appbased.cxx |   18 ++++---------
 basic/source/app/mybasic.cxx  |   58 +++++++++++++++++++++++++++++++++---------
 4 files changed, 77 insertions(+), 43 deletions(-)

New commits:
commit f012846e65b6eccd6a40cd67765fcfa766654388
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Wed Dec 15 05:56:53 2010 -0800

    Remove DECLARE_LIST( ErrorList, BasicError* ) correctly this time

diff --git a/basic/inc/basic/mybasic.hxx b/basic/inc/basic/mybasic.hxx
index a004f64..fb48d8c 100644
--- a/basic/inc/basic/mybasic.hxx
+++ b/basic/inc/basic/mybasic.hxx
@@ -30,11 +30,16 @@
 #define _MYBASIC_HXX
 
 #include <basic/sbstar.hxx>
+#include <vector>
 
 class BasicApp;
 class AppBasEd;
 class ErrorEntry;
 
+#define SBXID_MYBASIC	0x594D		// MyBasic: MY
+#define	SBXCR_TEST		0x54534554	// TEST
+
+//-----------------------------------------------------------------------------
 class BasicError {
     AppBasEd* pWin;
     USHORT  nLine, nCol1, nCol2;
@@ -44,11 +49,7 @@ public:
     void Show();
 };
 
-DECLARE_LIST( ErrorList, BasicError* )
-
-#define SBXID_MYBASIC	0x594D		// MyBasic: MY
-#define	SBXCR_TEST		0x54534554	// TEST
-
+//-----------------------------------------------------------------------------
 class MyBasic : public StarBASIC
 {
     SbError nError;
@@ -56,6 +57,8 @@ class MyBasic : public StarBASIC
     virtual USHORT BreakHdl();
 
 protected:
+    ::std::vector< BasicError* > aErrors;
+    size_t CurrentError;
     Link GenLogHdl();
     Link GenWinInfoHdl();
     Link GenModuleWinExistsHdl();
@@ -68,14 +71,17 @@ protected:
 public:
     SBX_DECL_PERSIST_NODATA(SBXCR_TEST,SBXID_MYBASIC,1);
     TYPEINFO();
-    ErrorList aErrors;
     MyBasic();
     virtual ~MyBasic();
     virtual BOOL Compile( SbModule* );
     void Reset();
     SbError GetErrors() { return nError; }
+    size_t GetCurrentError() { return CurrentError; }
+    BasicError* FirstError();
+    BasicError* NextError();
+    BasicError* PrevError();
 
-        // Do not use #ifdefs here because this header file is both used for testtool and basic
+    // Do not use #ifdefs here because this header file is both used for testtool and basic
     SbxObject *pTestObject; // for Testool; otherwise NULL
 
     virtual void LoadIniFile();
diff --git a/basic/source/app/app.cxx b/basic/source/app/app.cxx
index 8577dbb..70759b8 100644
--- a/basic/source/app/app.cxx
+++ b/basic/source/app/app.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -352,7 +352,7 @@ void BasicApp::SetFocus()
 
 IMPL_LINK( BasicApp, LateInit, void *, pDummy )
 {
-    (void) pDummy; /* avoid warning about unused parameter */ 
+    (void) pDummy; /* avoid warning about unused parameter */
     USHORT i;
     for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ )
     {
@@ -460,7 +460,7 @@ void FloatingExecutionStatus::SetAdditionalInfo( String aF )
 
 IMPL_LINK(FloatingExecutionStatus, HideNow, FloatingExecutionStatus*, pFLC )
 {
-    (void) pFLC; /* avoid warning about unused parameter */ 
+    (void) pFLC; /* avoid warning about unused parameter */
     Hide();
     return 0;
 }
@@ -649,7 +649,7 @@ BasicFrame::~BasicFrame()
     pBasic.Clear();
 }
 
-void BasicFrame::Command( const CommandEvent& rCEvt ) 
+void BasicFrame::Command( const CommandEvent& rCEvt )
 {
     switch( rCEvt.GetCommand() ) {
         case COMMAND_SHOWDIALOG:
@@ -1099,18 +1099,18 @@ IMPL_LINK( BasicFrame, InitMenu, Menu *, pMenu )
     BOOL bHasErr = BOOL( bNormal && pBasic->GetErrors() != 0 );
     BOOL bNext   = bHasErr & bNormal;
     BOOL bPrev   = bHasErr & bNormal;
-    if( bHasErr ) 
+    if( bHasErr )
     {
-        ULONG n = pBasic->aErrors.GetCurPos();
+        size_t n = pBasic->GetCurrentError();
         if( n == 0 )
             bPrev = FALSE;
-        if( USHORT(n+1) == pBasic->GetErrors() ) 
+        if( SbError(n+1) == pBasic->GetErrors() )
             bNext = FALSE;
     }
     pMenu->EnableItem( RID_RUNNEXTERR, bNext );
     pMenu->EnableItem( RID_RUNPREVERR, bPrev );
     pMenu->CheckItem( RID_RUNDISAS, bDisas );
-    if( pWork ) 
+    if( pWork )
         pWork->InitMenu( pMenu );
 
     return TRUE;
@@ -1118,7 +1118,7 @@ IMPL_LINK( BasicFrame, InitMenu, Menu *, pMenu )
 
 IMPL_LINK_INLINE_START( BasicFrame, DeInitMenu, Menu *, pMenu )
 {
-    (void) pMenu; /* avoid warning about unused parameter */ 
+    (void) pMenu; /* avoid warning about unused parameter */
 
     SetAutoRun( FALSE );
     String aString;
@@ -1152,7 +1152,7 @@ IMPL_LINK_INLINE_END( BasicFrame, Accel, Accelerator*, pAcc )
 
 IMPL_LINK_INLINE_START( BasicFrame, ShowLineNr, AutoTimer *, pTimer )
 {
-    (void) pTimer; /* avoid warning about unused parameter */ 
+    (void) pTimer; /* avoid warning about unused parameter */
     String aPos;
     if ( pWork && pWork->ISA(AppBasEd))
     {
@@ -1378,11 +1378,11 @@ long BasicFrame::Command( short nID, BOOL bChecked )
             bInBreak = FALSE;
             break;
         case RID_RUNNEXTERR:
-            pErr = pBasic->aErrors.Next();
+            pErr = pBasic->NextError();
             if( pErr ) pErr->Show();
             break;
         case RID_RUNPREVERR:
-            pErr = pBasic->aErrors.Prev();
+            pErr = pBasic->PrevError();
             if( pErr ) pErr->Show();
             break;
 
diff --git a/basic/source/app/appbased.cxx b/basic/source/app/appbased.cxx
index 09ed489..78236df 100644
--- a/basic/source/app/appbased.cxx
+++ b/basic/source/app/appbased.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -59,7 +59,6 @@ AppBasEd::AppBasEd( BasicFrame* pParent, SbModule* p )
 
     ((TextEdit*)pDataEdit)->GetTextEditImp().pTextView->SetAutoIndentMode( TRUE );
     ((TextEdit*)pDataEdit)->GetTextEditImp().pTextEngine->SetMaxTextLen( STRING_MAXLEN );
-//	((TextEdit*)pDataEdit)->GetTextEditImp().pTextEngine->SetWordDelimiters( CUniString(" ,.;:(){}[]\"'+-*/<>^\\") );
     ((TextEdit*)pDataEdit)->GetTextEditImp().SyntaxHighlight( TRUE );
     ((TextEdit*)pDataEdit)->SaveAsUTF8( TRUE );
 
@@ -76,10 +75,6 @@ AppBasEd::AppBasEd( BasicFrame* pParent, SbModule* p )
 
     pBreakpoints->SetModule( pMod );
 
-    // Define icon:
-//	pIcon = new Icon( ResId( RID_WORKICON ) );
-//	if( pIcon ) SetIcon( *pIcon );
-
     SetText( pMod->GetName() );
     pDataEdit->SetText( pMod->GetSource() );
 
@@ -122,7 +117,7 @@ FileType AppBasEd::GetFileType()
 
 IMPL_LINK_INLINE_START( AppBasEd, EditChange, void *, p )
 {
-    (void) p; /* avoid warning about unused parameter */ 
+    (void) p; /* avoid warning about unused parameter */
     bCompiled = FALSE;
     return TRUE;
 }
@@ -158,7 +153,7 @@ void AppBasEd::Command( const CommandEvent& rCEvt )
 
 void AppBasEd::Resize()
 {
-  if( pDataEdit ) 
+  if( pDataEdit )
   {
     AppEdit::Resize();
 
@@ -207,7 +202,6 @@ void AppBasEd::LoadSource()
 {
     BOOL bErr;
 
-//	if( pDataEdit->GetText().Len() != 0 ) return;
     String aName = pMod->GetName();
     bErr = !pDataEdit->Load( aName );
     pBreakpoints->LoadBreakpoints( GetText() );
@@ -247,7 +241,7 @@ BOOL AppBasEd::Compile()
     }
     else
     {
-        BasicError* pErr = pFrame->Basic().aErrors.First();
+        BasicError* pErr = pFrame->Basic().FirstError();
         if( pErr ) pErr->Show();
     }
     return bCompiled = bRes;
@@ -284,8 +278,8 @@ void AppBasEd::Run()
         pMain->Run();
         if (aBasicApp.pFrame)
         {
-            BasicError* pErr = aBasicApp.pFrame->Basic().aErrors.First();
-            if( pErr ) 
+            BasicError* pErr = aBasicApp.pFrame->Basic().FirstError();
+            if( pErr )
                 pErr->Show();
             aBasicApp.pFrame->SetAppMode( String() );
         }
diff --git a/basic/source/app/mybasic.cxx b/basic/source/app/mybasic.cxx
index 22bf7f6..727a1e1 100644
--- a/basic/source/app/mybasic.cxx
+++ b/basic/source/app/mybasic.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -79,6 +79,7 @@ SbxBase* MyFactory::Create( UINT16 nSbxId, UINT32 nCr )
 MyBasic::MyBasic() : StarBASIC()
 {
     nError = 0;
+    CurrentError = 0;
     if( !nInst++ )
     {
         AddFactory( &aFac1 );
@@ -153,15 +154,15 @@ void MyBasic::LoadIniFile()
 
 SbTextType MyBasic::GetSymbolType( const String &rSymbol, BOOL bWasTTControl )
 {
-    (void) rSymbol;       /* avoid warning about unused parameter */ 
-    (void) bWasTTControl; /* avoid warning about unused parameter */ 
+    (void) rSymbol;       /* avoid warning about unused parameter */
+    (void) bWasTTControl; /* avoid warning about unused parameter */
     return SB_SYMBOL;     // Everything here is of type SB_SYMBOL and continues to be so
 }
 
 
 MyBasic::~MyBasic()
 {
-    aErrors.Clear();
+    Reset();
     if( !--nInst )
     {
         RemoveFactory( &aFac1 );
@@ -172,8 +173,10 @@ MyBasic::~MyBasic()
 
 void MyBasic::Reset()
 {
-    aErrors.Clear();
+    for ( size_t i = 0, n = aErrors.size(); i < n; ++i ) delete aErrors[ i ];
+    aErrors.clear();
     nError = 0;
+    CurrentError = 0;
 }
 
 BOOL MyBasic::Compile( SbModule* p )
@@ -182,6 +185,36 @@ BOOL MyBasic::Compile( SbModule* p )
     return StarBASIC::Compile( p );
 }
 
+BasicError* MyBasic::NextError()
+{
+    if ( CurrentError < ( aErrors.size() - 1 ) )
+    {
+        ++CurrentError;
+        return aErrors[ CurrentError ];
+    }
+    return NULL;
+}
+
+BasicError* MyBasic::PrevError()
+{
+    if ( !aErrors.empty() && CurrentError > 0 )
+    {
+        --CurrentError;
+        return aErrors[ CurrentError ];
+    }
+    return NULL;
+}
+
+BasicError* MyBasic::FirstError()
+{
+    if ( !aErrors.empty() )
+    {
+        CurrentError = 0;
+        return aErrors[ CurrentError ];
+    }
+    return NULL;
+}
+
 BOOL MyBasic::ErrorHdl()
 {
     AppBasEd* pWin = aBasicApp.pFrame->FindModuleWin( GetActiveModule()->GetName() );
@@ -193,12 +226,13 @@ BOOL MyBasic::ErrorHdl()
         pWin->ToTop();
     if( IsCompilerError() )
     {
-        aErrors.Insert(
+        aErrors.push_back(
           new BasicError
             ( pWin,
-              0, StarBASIC::GetErrorText(), GetLine(), GetCol1(), GetCol2() ),
-              LIST_APPEND );
+              0, StarBASIC::GetErrorText(), GetLine(), GetCol1(), GetCol2() )
+            );
         nError++;
+        CurrentError = aErrors.size() - 1;
         return BOOL( nError < 20 );	// Cancel after 20 errors
     }
     else
@@ -223,7 +257,7 @@ void MyBasic::ReportRuntimeError( AppBasEd *pEditWin )
 
 void MyBasic::DebugFindNoErrors( BOOL bDebugFindNoErrors )
 {
-    (void) bDebugFindNoErrors; /* avoid warning about unused parameter */ 
+    (void) bDebugFindNoErrors; /* avoid warning about unused parameter */
 }
 
 const String MyBasic::GetSpechialErrorText()
@@ -286,12 +320,12 @@ BasicError::BasicError
 // to highlight a statement
 void BasicError::Show()
 {
-    if( pWin && aBasicApp.pFrame->IsWinValid( pWin ) ) 
+    if( pWin && aBasicApp.pFrame->IsWinValid( pWin ) )
     {
         pWin->Highlight( nLine, nCol1, nCol2 );
         aBasicApp.pFrame->pStatus->Message( aText );
-    } 
-    else 
+    }
+    else
         MessBox( aBasicApp.pFrame, WB_OK, aBasicApp.pFrame->GetText(),
                  aText ).Execute();
 }


More information about the Libreoffice-commits mailing list