diff options
Diffstat (limited to 'basic/source/app/brkpnts.cxx')
-rw-r--r-- | basic/source/app/brkpnts.cxx | 168 |
1 files changed, 83 insertions, 85 deletions
diff --git a/basic/source/app/brkpnts.cxx b/basic/source/app/brkpnts.cxx index 60195971b9..c4358a7848 100644 --- a/basic/source/app/brkpnts.cxx +++ b/basic/source/app/brkpnts.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 @@ -28,7 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#include <tools/list.hxx> #include <basic/sbx.hxx> #include <basic/sbmod.hxx> #include <basic/sbstar.hxx> @@ -47,21 +46,18 @@ struct Breakpoint { - USHORT nLine; - - Breakpoint( USHORT nL ) { nLine = nL; } + sal_uInt32 nLine; + Breakpoint( sal_uInt32 nL ) { nLine = nL; } }; - ImageList* BreakpointWindow::pImages = NULL; - BreakpointWindow::BreakpointWindow( Window *pParent ) : Window( pParent ) , nCurYOffset( 0 ) , nMarkerPos( MARKER_NOMARKER ) , pModule( NULL ) -, bErrorMarker( FALSE ) +, bErrorMarker( sal_False ) { if ( !pImages ) pImages = new ImageList( SttResId( RID_IMGLST_LAYOUT ) ); @@ -75,13 +71,9 @@ BreakpointWindow::BreakpointWindow( Window *pParent ) void BreakpointWindow::Reset() { - Breakpoint* pBrk = First(); - while ( pBrk ) - { - delete pBrk; - pBrk = Next(); - } - Clear(); + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) + delete BreakpointList[ i ]; + BreakpointList.clear(); pModule->ClearAllBP(); } @@ -89,7 +81,7 @@ void BreakpointWindow::Reset() void BreakpointWindow::SetModule( SbModule *pMod ) { pModule = pMod; - USHORT i; + sal_uInt16 i; for ( i=0 ; i < pModule->GetBPCount() ; i++ ) { InsertBreakpoint( pModule->GetBP( i ) ); @@ -102,16 +94,15 @@ void BreakpointWindow::SetBPsInModule() { pModule->ClearAllBP(); - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { - pModule->SetBP( (USHORT)pBrk->nLine ); + Breakpoint* pBrk = BreakpointList[ i ]; + pModule->SetBP( (sal_uInt16)pBrk->nLine ); #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( (USHORT)pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" ); + DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( (sal_uInt16)pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" ); #endif - pBrk = Next(); } - for ( USHORT nMethod = 0; nMethod < pModule->GetMethods()->Count(); nMethod++ ) + for ( sal_uInt16 nMethod = 0; nMethod < pModule->GetMethods()->Count(); nMethod++ ) { SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Get( nMethod ); DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" ); @@ -120,27 +111,30 @@ void BreakpointWindow::SetBPsInModule() } -void BreakpointWindow::InsertBreakpoint( USHORT nLine ) +void BreakpointWindow::InsertBreakpoint( sal_uInt32 nLine ) { Breakpoint* pNewBrk = new Breakpoint( nLine ); - Breakpoint* pBrk = First(); - while ( pBrk ) + + for ( ::std::vector< Breakpoint* >::iterator i = BreakpointList.begin(); + i < BreakpointList.end(); + ++ i + ) { + Breakpoint* pBrk = *i; if ( nLine <= pBrk->nLine ) { - if ( pBrk->nLine != nLine ) - Insert( pNewBrk ); + if ( nLine != pBrk->nLine ) + BreakpointList.insert( i, pNewBrk ); else delete pNewBrk; pNewBrk = NULL; - pBrk = NULL; + break; } - else - pBrk = Next(); } + // No insert position found => LIST_APPEND if ( pNewBrk ) - Insert( pNewBrk, LIST_APPEND ); + BreakpointList.push_back( pNewBrk ); Invalidate(); @@ -151,7 +145,7 @@ void BreakpointWindow::InsertBreakpoint( USHORT nLine ) #endif if ( StarBASIC::IsRunning() ) { - for ( USHORT nMethod = 0; nMethod < pModule->GetMethods()->Count(); nMethod++ ) + for ( sal_uInt16 nMethod = 0; nMethod < pModule->GetMethods()->Count(); nMethod++ ) { SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Get( nMethod ); DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" ); @@ -165,35 +159,34 @@ void BreakpointWindow::InsertBreakpoint( USHORT nLine ) } -Breakpoint* BreakpointWindow::FindBreakpoint( ULONG nLine ) +Breakpoint* BreakpointWindow::FindBreakpoint( sal_uInt32 nLine ) { - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { - if ( pBrk->nLine == nLine ) - return pBrk; - - pBrk = Next(); + Breakpoint* pBP = BreakpointList[ i ]; + if ( pBP->nLine == nLine ) + return pBP; } - - return (Breakpoint*)0; + return NULL; } -void BreakpointWindow::AdjustBreakpoints( ULONG nLine, BOOL bInserted ) +void BreakpointWindow::AdjustBreakpoints( sal_uInt32 nLine, bool bInserted ) { if ( nLine == 0 ) //TODO: nLine == TEXT_PARA_ALL+1 return; - Breakpoint* pBrk = First(); - while ( pBrk ) + + for ( size_t i = 0; i < BreakpointList.size(); ) { - BOOL bDelBrk = FALSE; + Breakpoint* pBrk = BreakpointList[ i ]; + bool bDelBrk = false; + if ( pBrk->nLine == nLine ) { if ( bInserted ) pBrk->nLine++; else - bDelBrk = TRUE; + bDelBrk = true; } else if ( pBrk->nLine > nLine ) { @@ -202,18 +195,19 @@ void BreakpointWindow::AdjustBreakpoints( ULONG nLine, BOOL bInserted ) else pBrk->nLine--; } - if ( bDelBrk ) { - ULONG n = GetCurPos(); - delete Remove( pBrk ); - pBrk = Seek( n ); + delete pBrk; + ::std::vector< Breakpoint* >::iterator it = BreakpointList.begin(); + ::std::advance( it, i ); + BreakpointList.erase( it ); } else { - pBrk = Next(); + ++i; } } + Invalidate(); } @@ -231,7 +225,7 @@ void BreakpointWindow::LoadBreakpoints( String aFilename ) for ( i = 0 ; i < aBreakpoints.GetTokenCount( ';' ) ; i++ ) { - InsertBreakpoint( (USHORT)aBreakpoints.GetToken( i, ';' ).ToInt32() ); + InsertBreakpoint( (sal_uInt16)aBreakpoints.GetToken( i, ';' ).ToInt32() ); } } @@ -240,14 +234,12 @@ void BreakpointWindow::SaveBreakpoints( String aFilename ) { ByteString aBreakpoints; - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { + Breakpoint* pBrk = BreakpointList[ i ]; if ( aBreakpoints.Len() ) aBreakpoints += ';'; - aBreakpoints += ByteString::CreateFromInt32( pBrk->nLine ); - pBrk = Next(); } Config aConfig(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") )); @@ -273,56 +265,62 @@ void BreakpointWindow::Paint( const Rectangle& ) aBmpOff.X() = ( aOutSz.Width() - aBmpSz.Width() ) / 2; aBmpOff.Y() = ( nLineHeight - aBmpSz.Height() ) / 2; - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { + Breakpoint* pBrk = BreakpointList[ i ]; #if OSL_DEBUG_LEVEL > 1 DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" ); #endif - ULONG nLine = pBrk->nLine-1; - ULONG nY = nLine*nLineHeight - nCurYOffset; + sal_Int32 nLine = pBrk->nLine-1; + sal_Int32 nY = nLine*nLineHeight - nCurYOffset; DrawImage( Point( 0, nY ) + aBmpOff, aBrk ); - pBrk = Next(); } - ShowMarker( TRUE ); + ShowMarker( sal_True ); } Breakpoint* BreakpointWindow::FindBreakpoint( const Point& rMousePos ) { - long nLineHeight = GetTextHeight(); - long nYPos = rMousePos.Y() + nCurYOffset; + sal_Int32 nLineHeight = GetTextHeight(); + sal_Int32 nYPos = rMousePos.Y() + nCurYOffset; - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { - ULONG nLine = pBrk->nLine-1; - long nY = nLine*nLineHeight; + Breakpoint* pBrk = BreakpointList[ i ]; + sal_Int32 nLine = pBrk->nLine-1; + sal_Int32 nY = nLine * nLineHeight; if ( ( nYPos > nY ) && ( nYPos < ( nY + nLineHeight ) ) ) return pBrk; - pBrk = Next(); } - return 0; + return NULL; } -void BreakpointWindow::ToggleBreakpoint( USHORT nLine ) +void BreakpointWindow::ToggleBreakpoint( sal_uInt32 nLine ) { - Breakpoint* pBrk = FindBreakpoint( nLine ); - if ( pBrk ) // remove + bool Removed = false; + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { - pModule->ClearBP( nLine ); - delete Remove( pBrk ); + Breakpoint* pBP = BreakpointList[ i ]; + if ( pBP->nLine == nLine ) // remove + { + pModule->ClearBP( nLine ); + delete pBP; + ::std::vector< Breakpoint* >::iterator it = BreakpointList.begin(); + ::std::advance( it, i ); + BreakpointList.erase( it ); + Removed = true; + break; + } } - else // create one - { + + if ( !Removed ) // create one InsertBreakpoint( nLine ); - } Invalidate(); } -void BreakpointWindow::ShowMarker( BOOL bShow ) +void BreakpointWindow::ShowMarker( bool bShow ) { if ( nMarkerPos == MARKER_NOMARKER ) return; @@ -342,7 +340,7 @@ void BreakpointWindow::ShowMarker( BOOL bShow ) aMarkerOff.X() = ( aOutSz.Width() - aMarkerSz.Width() ) / 2; aMarkerOff.Y() = ( nLineHeight - aMarkerSz.Height() ) / 2; - ULONG nY = nMarkerPos*nLineHeight - nCurYOffset; + sal_uIntPtr nY = nMarkerPos*nLineHeight - nCurYOffset; Point aPos( 0, nY ); aPos += aMarkerOff; if ( bShow ) @@ -360,23 +358,23 @@ void BreakpointWindow::MouseButtonDown( const MouseEvent& rMEvt ) long nLineHeight = GetTextHeight(); long nYPos = aMousePos.Y() + nCurYOffset; long nLine = nYPos / nLineHeight + 1; - ToggleBreakpoint( sal::static_int_cast< USHORT >(nLine) ); + ToggleBreakpoint( sal::static_int_cast< sal_uInt16 >(nLine) ); Invalidate(); } } -void BreakpointWindow::SetMarkerPos( USHORT nLine, BOOL bError ) +void BreakpointWindow::SetMarkerPos( sal_uInt32 nLine, bool bError ) { - ShowMarker( FALSE ); // Remove old one + ShowMarker( false ); // Remove old one nMarkerPos = nLine; bErrorMarker = bError; - ShowMarker( TRUE ); // Draw new one + ShowMarker( true ); // Draw new one Update(); } -void BreakpointWindow::Scroll( long nHorzScroll, long nVertScroll, USHORT nFlags ) +void BreakpointWindow::Scroll( long nHorzScroll, long nVertScroll, sal_uInt16 nFlags ) { (void) nFlags; /* avoid warning about unused parameter */ nCurYOffset -= nVertScroll; |