diff options
author | Joseph Powers <jpowers27@cox.net> | 2010-12-15 05:56:53 -0800 |
---|---|---|
committer | Joseph Powers <jpowers27@cox.net> | 2010-12-15 05:57:48 -0800 |
commit | 335a249c91fb95f68f0ca8bf68e637713a915e06 (patch) | |
tree | 7b2013300c7b8d20cd81e9e90156f962b96bb493 /basic | |
parent | f51f9bf2e5b56d19d59c535b6acc2996e082f020 (diff) |
Remove DECLARE_LIST( ErrorList, BasicError* ) correctly this time
Diffstat (limited to 'basic')
-rw-r--r-- | basic/inc/basic/mybasic.hxx | 20 | ||||
-rw-r--r-- | basic/source/app/app.cxx | 8 | ||||
-rw-r--r-- | basic/source/app/appbased.cxx | 10 | ||||
-rw-r--r-- | basic/source/app/mybasic.cxx | 44 |
4 files changed, 58 insertions, 24 deletions
diff --git a/basic/inc/basic/mybasic.hxx b/basic/inc/basic/mybasic.hxx index 2f520253a6b3..2f87fb69c5a6 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 c3902d8a9cc7..3875e9fc7e1f 100644 --- a/basic/source/app/app.cxx +++ b/basic/source/app/app.cxx @@ -1101,10 +1101,10 @@ IMPL_LINK( BasicFrame, InitMenu, Menu *, pMenu ) BOOL bPrev = bHasErr & bNormal; 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 ); @@ -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 527390f9a46c..a6caa408ec29 100644 --- a/basic/source/app/appbased.cxx +++ b/basic/source/app/appbased.cxx @@ -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() ); @@ -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,7 +278,7 @@ void AppBasEd::Run() pMain->Run(); if (aBasicApp.pFrame) { - BasicError* pErr = aBasicApp.pFrame->Basic().aErrors.First(); + 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 c5ae5e4c4a49..5c165f441058 100644 --- a/basic/source/app/mybasic.cxx +++ b/basic/source/app/mybasic.cxx @@ -79,6 +79,7 @@ SbxBase* MyFactory::Create( UINT16 nSbxId, UINT32 nCr ) MyBasic::MyBasic() : StarBASIC() { nError = 0; + CurrentError = 0; if( !nInst++ ) { AddFactory( &aFac1 ); @@ -161,7 +162,7 @@ SbTextType MyBasic::GetSymbolType( const String &rSymbol, BOOL bWasTTControl ) 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 |