summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorJoseph Powers <jpowers27@cox.net>2010-12-11 07:39:25 -0800
committerJoseph Powers <jpowers27@cox.net>2010-12-11 07:45:10 -0800
commit444c242c51e6b049598359ea6cf98e34f611838b (patch)
treec273485fbadc3e0dc7955f3fc8ace23f433c2934 /basctl
parent52b66899d1fe579e3c89cb6f65ab505cc563a990 (diff)
remove DECLARE_LIST( BreakPL, BreakPoint* )
Also simplify the prior patch & make sure the list is in the right order.
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2.cxx6
-rw-r--r--basctl/source/basicide/baside2b.cxx25
-rw-r--r--basctl/source/basicide/bastypes.cxx110
-rw-r--r--basctl/source/basicide/brkdlg.cxx34
-rw-r--r--basctl/source/basicide/macrodlg.cxx27
-rw-r--r--basctl/source/inc/bastypes.hxx29
6 files changed, 126 insertions, 105 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index d2688fb696ba..01780c4b13b8 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -334,7 +334,7 @@ BOOL ModulWindow::BasicExecute()
if ( XModule().Is() && xModule->IsCompiled() && !aStatus.bError )
{
- if ( GetBreakPoints().Count() )
+ if ( GetBreakPoints().size() )
aStatus.nBasicFlags = aStatus.nBasicFlags | SbDEBUG_BREAK;
if ( !aStatus.bIsRunning )
@@ -584,7 +584,7 @@ BOOL ModulWindow::ToggleBreakPoint( ULONG nLine )
if ( pBrk ) // entfernen
{
xModule->ClearBP( (USHORT)nLine );
- delete GetBreakPoints().Remove( pBrk );
+ delete GetBreakPoints().remove( pBrk );
}
else // einen erzeugen
{
@@ -1350,7 +1350,7 @@ void __EXPORT ModulWindow::BasicStarted()
{
aStatus.bIsRunning = TRUE;
BreakPointList& rList = GetBreakPoints();
- if ( rList.Count() )
+ if ( rList.size() )
{
rList.ResetHitCount();
rList.SetBreakPointsInBasic( xModule );
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 63fcf84d6290..4157d8284d84 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -975,13 +975,12 @@ void __EXPORT BreakPointWindow::Paint( const Rectangle& )
aBmpOff.X() = ( aOutSz.Width() - aBmpSz.Width() ) / 2;
aBmpOff.Y() = ( nLineHeight - aBmpSz.Height() ) / 2;
- BreakPoint* pBrk = GetBreakPoints().First();
- while ( pBrk )
+ for ( size_t i = 0, n = GetBreakPoints().size(); i < n ; ++i )
{
- ULONG nLine = pBrk->nLine-1;
- ULONG nY = nLine*nLineHeight - nCurYOffset;
+ BreakPoint* pBrk = GetBreakPoints().at( i );
+ size_t nLine = pBrk->nLine-1;
+ size_t nY = nLine*nLineHeight - nCurYOffset;
DrawImage( Point( 0, nY ) + aBmpOff, pBrk->bEnabled ? aBrk1 : aBrk0 );
- pBrk = GetBreakPoints().Next();
}
ShowMarker( TRUE );
}
@@ -1039,20 +1038,16 @@ void BreakPointWindow::ShowMarker( BOOL bShow )
BreakPoint* BreakPointWindow::FindBreakPoint( const Point& rMousePos )
{
- long nLineHeight = GetTextHeight();
- long nYPos = rMousePos.Y() + nCurYOffset;
-// Image aBrk( ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->GetImage( IMGID_BRKENABLED ) );
-// Size aBmpSz( aBrk.GetSizePixel() );
-// aBmpSz = PixelToLogic( aBmpSz );
+ size_t nLineHeight = GetTextHeight();
+ size_t nYPos = rMousePos.Y() + nCurYOffset;
- BreakPoint* pBrk = GetBreakPoints().First();
- while ( pBrk )
+ for ( size_t i = 0, n = GetBreakPoints().size(); i < n ; ++i )
{
- ULONG nLine = pBrk->nLine-1;
- long nY = nLine*nLineHeight;
+ BreakPoint* pBrk = GetBreakPoints().at( i );
+ size_t nLine = pBrk->nLine-1;
+ size_t nY = nLine*nLineHeight;
if ( ( nYPos > nY ) && ( nYPos < ( nY + nLineHeight ) ) )
return pBrk;
- pBrk = GetBreakPoints().Next();
}
return 0;
}
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx
index 5faaf7988313..245fba82626d 100644
--- a/basctl/source/basicide/bastypes.cxx
+++ b/basctl/source/basicide/bastypes.cxx
@@ -59,6 +59,7 @@
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
+using ::std::vector;
DBG_NAME( IDEBaseWindow )
@@ -265,11 +266,10 @@ SfxUndoManager* __EXPORT IDEBaseWindow::GetUndoManager()
BreakPointList::BreakPointList()
{}
-BreakPointList::BreakPointList(BreakPointList const & rList):
- BreakPL( sal::static_int_cast<USHORT>( rList.Count() ))
+BreakPointList::BreakPointList(BreakPointList const & rList)
{
- for (ULONG i = 0; i < rList.Count(); ++i)
- Insert(new BreakPoint(*rList.GetObject(i)), i);
+ for (size_t i = 0; i < rList.size(); ++i)
+ maBreakPoints.push_back( new BreakPoint(*rList.at( i ) ) );
}
BreakPointList::~BreakPointList()
@@ -279,76 +279,69 @@ BreakPointList::~BreakPointList()
void BreakPointList::reset()
{
- while (Count() > 0)
- delete Remove(Count() - 1);
+ for ( size_t i = 0, n = maBreakPoints.size(); i < n; ++i )
+ delete maBreakPoints[ i ];
+ maBreakPoints.clear();
}
void BreakPointList::transfer(BreakPointList & rList)
{
reset();
- for (ULONG i = 0; i < rList.Count(); ++i)
- Insert(rList.GetObject(i), i);
- rList.Clear();
+ for (size_t i = 0; i < rList.size(); ++i)
+ maBreakPoints.push_back( rList.at( i ) );
+ rList.reset();
}
void BreakPointList::InsertSorted( BreakPoint* pNewBrk )
{
- BreakPoint* pBrk = First();
- while ( pBrk )
+ for ( vector< BreakPoint* >::iterator i = maBreakPoints.begin(); i < maBreakPoints.end(); ++i )
{
- if ( pNewBrk->nLine <= pBrk->nLine )
+ if ( pNewBrk->nLine <= (*i)->nLine )
{
DBG_ASSERT( ( pBrk->nLine != pNewBrk->nLine ) || pNewBrk->bTemp, "BreakPoint existiert schon!" );
- Insert( pNewBrk );
+ maBreakPoints.insert( i, pNewBrk );
return;
}
- pBrk = Next();
}
// Keine Einfuegeposition gefunden => LIST_APPEND
- Insert( pNewBrk, LIST_APPEND );
+ maBreakPoints.push_back( pNewBrk );
}
void BreakPointList::SetBreakPointsInBasic( SbModule* pModule )
{
pModule->ClearAllBP();
- BreakPoint* pBrk = First();
- while ( pBrk )
+ for ( size_t i = 0, n = maBreakPoints.size(); i < n; ++i )
{
+ BreakPoint* pBrk = maBreakPoints[ i ];
if ( pBrk->bEnabled )
pModule->SetBP( (USHORT)pBrk->nLine );
- pBrk = Next();
}
}
-BreakPoint* BreakPointList::FindBreakPoint( ULONG nLine )
+BreakPoint* BreakPointList::FindBreakPoint( size_t nLine )
{
- BreakPoint* pBrk = First();
- while ( pBrk )
+ for ( size_t i = 0, n = maBreakPoints.size(); i < n; ++i )
{
+ BreakPoint* pBrk = maBreakPoints[ i ];
if ( pBrk->nLine == nLine )
return pBrk;
-
- pBrk = Next();
}
-
- return (BreakPoint*)0;
+ return NULL;
}
-
-
-void BreakPointList::AdjustBreakPoints( ULONG nLine, BOOL bInserted )
+void BreakPointList::AdjustBreakPoints( size_t nLine, bool bInserted )
{
- BreakPoint* pBrk = First();
- while ( pBrk )
+ for ( size_t i = 0; i < maBreakPoints.size(); )
{
- BOOL bDelBrk = FALSE;
+ BreakPoint* pBrk = maBreakPoints[ i ];
+ bool bDelBrk = false;
if ( pBrk->nLine == nLine )
{
if ( bInserted )
pBrk->nLine++;
else
- bDelBrk = TRUE;
+ bDelBrk = true;
}
else if ( pBrk->nLine > nLine )
{
@@ -360,27 +353,66 @@ void BreakPointList::AdjustBreakPoints( ULONG nLine, BOOL bInserted )
if ( bDelBrk )
{
- ULONG n = GetCurPos();
- delete Remove( pBrk );
- pBrk = Seek( n );
+ delete remove( pBrk );
}
else
{
- pBrk = Next();
+ ++i;
}
}
}
void BreakPointList::ResetHitCount()
{
- BreakPoint* pBrk = First();
- while ( pBrk )
+ for ( size_t i = 0, n = maBreakPoints.size(); i < n; ++i )
{
+ BreakPoint* pBrk = maBreakPoints[ i ];
pBrk->nHitCount = 0;
- pBrk = Next();
}
}
+size_t BreakPointList::size() const
+{
+ return maBreakPoints.size();
+}
+
+BreakPoint* BreakPointList::at( size_t i )
+{
+ if ( i < maBreakPoints.size() )
+ return maBreakPoints[ i ];
+ else
+ return NULL;
+}
+
+const BreakPoint* BreakPointList::at( size_t i ) const
+{
+ return maBreakPoints[ i ];
+}
+
+BreakPoint* BreakPointList::remove( BreakPoint* ptr )
+{
+ for ( vector< BreakPoint* >::iterator i = maBreakPoints.begin(); i < maBreakPoints.end(); ++i )
+ {
+ if ( ptr == *i )
+ {
+ maBreakPoints.erase( i );
+ return ptr;
+ }
+ }
+ return NULL;
+}
+
+void BreakPointList::push_back( BreakPoint* item )
+{
+ maBreakPoints.push_back( item );
+}
+
+void BreakPointList::clear()
+{
+ maBreakPoints.clear();
+}
+
+
void IDEBaseWindow::Deactivating()
{
}
diff --git a/basctl/source/basicide/brkdlg.cxx b/basctl/source/basicide/brkdlg.cxx
index 34a1f8f62c94..be57acc4ed98 100644
--- a/basctl/source/basicide/brkdlg.cxx
+++ b/basctl/source/basicide/brkdlg.cxx
@@ -46,7 +46,7 @@
// FIXME Why does BreakPointDialog allow only USHORT for break-point line
// numbers, whereas BreakPoint supports ULONG?
-bool lcl_ParseText( String aText, USHORT& rLineNr )
+bool lcl_ParseText( String aText, size_t& rLineNr )
{
// aText should look like "# n" where
// n > 0 && n < std::numeric_limits< USHORT >::max().
@@ -61,9 +61,9 @@ bool lcl_ParseText( String aText, USHORT& rLineNr )
aText.Erase(0, 1);
// XXX Assumes that USHORT is contained within sal_Int32:
sal_Int32 n = aText.ToInt32();
- if (n <= 0 || n > std::numeric_limits< USHORT >::max())
+ if ( n <= 0 )
return false;
- rLineNr = static_cast< USHORT >(n);
+ rLineNr = static_cast< size_t >(n);
return true;
}
@@ -84,14 +84,12 @@ BreakPointDialog::BreakPointDialog( Window* pParent, BreakPointList& rBrkPntList
FreeResource();
aComboBox.SetUpdateMode( FALSE );
- BreakPoint* pBrk = m_aModifiedBreakPointList.First();
- BreakPoint* pFirstBrk = pBrk;
- while ( pBrk )
+ for ( size_t i = 0, n = m_aModifiedBreakPointList.size(); i < n; ++i )
{
+ BreakPoint* pBrk = m_aModifiedBreakPointList.at( i );
String aEntryStr( RTL_CONSTASCII_USTRINGPARAM( "# " ) );
aEntryStr += String::CreateFromInt32( pBrk->nLine );
aComboBox.InsertEntry( aEntryStr, COMBOBOX_APPEND );
- pBrk = m_aModifiedBreakPointList.Next();
}
aComboBox.SetUpdateMode( TRUE );
@@ -112,7 +110,7 @@ BreakPointDialog::BreakPointDialog( Window* pParent, BreakPointList& rBrkPntList
aNumericField.SetModifyHdl( LINK( this, BreakPointDialog, EditModifyHdl ) );
aComboBox.SetText( aComboBox.GetEntry( 0 ) );
- UpdateFields( pFirstBrk );
+ UpdateFields( m_aModifiedBreakPointList.at( 0 ) );
CheckButtons();
}
@@ -130,7 +128,7 @@ void BreakPointDialog::CheckButtons()
// "New" button is enabled if the combo box edit contains a valid line
// number that is not already present in the combo box list; otherwise
// "OK" and "Delete" buttons are enabled:
- USHORT nLine;
+ size_t nLine;
if (lcl_ParseText(aComboBox.GetText(), nLine)
&& m_aModifiedBreakPointList.FindBreakPoint(nLine) == 0)
{
@@ -165,7 +163,7 @@ IMPL_LINK( BreakPointDialog, ComboBoxHighlightHdl, ComboBox *, pBox )
aDelButton.Enable();
USHORT nEntry = pBox->GetEntryPos( pBox->GetText() );
- BreakPoint* pBrk = m_aModifiedBreakPointList.GetObject( nEntry );
+ BreakPoint* pBrk = m_aModifiedBreakPointList.at( nEntry );
DBG_ASSERT( pBrk, "Kein passender Breakpoint zur Liste ?" );
UpdateFields( pBrk );
@@ -200,13 +198,13 @@ IMPL_LINK( BreakPointDialog, ButtonHdl, Button *, pButton )
{
// Checkbox beruecksichtigen!
String aText( aComboBox.GetText() );
- USHORT nLine;
- BOOL bValid = lcl_ParseText( aText, nLine );
+ size_t nLine;
+ bool bValid = lcl_ParseText( aText, nLine );
if ( bValid )
{
BreakPoint* pBrk = new BreakPoint( nLine );
pBrk->bEnabled = aCheckBox.IsChecked();
- pBrk->nStopAfter = (ULONG) aNumericField.GetValue();
+ pBrk->nStopAfter = (size_t) aNumericField.GetValue();
m_aModifiedBreakPointList.InsertSorted( pBrk );
String aEntryStr( RTL_CONSTASCII_USTRINGPARAM( "# " ) );
aEntryStr += String::CreateFromInt32( pBrk->nLine );
@@ -229,11 +227,11 @@ IMPL_LINK( BreakPointDialog, ButtonHdl, Button *, pButton )
}
else if ( pButton == &aDelButton )
{
- USHORT nEntry = aComboBox.GetEntryPos( aComboBox.GetText() );
- BreakPoint* pBrk = m_aModifiedBreakPointList.GetObject( nEntry );
+ size_t nEntry = aComboBox.GetEntryPos( aComboBox.GetText() );
+ BreakPoint* pBrk = m_aModifiedBreakPointList.at( nEntry );
if ( pBrk )
{
- delete m_aModifiedBreakPointList.Remove( pBrk );
+ delete m_aModifiedBreakPointList.remove( pBrk );
aComboBox.RemoveEntry( nEntry );
if ( nEntry && !( nEntry < aComboBox.GetEntryCount() ) )
nEntry--;
@@ -272,8 +270,8 @@ void BreakPointDialog::UpdateFields( BreakPoint* pBrk )
BreakPoint* BreakPointDialog::GetSelectedBreakPoint()
{
- USHORT nEntry = aComboBox.GetEntryPos( aComboBox.GetText() );
- BreakPoint* pBrk = m_aModifiedBreakPointList.GetObject( nEntry );
+ size_t nEntry = aComboBox.GetEntryPos( aComboBox.GetText() );
+ BreakPoint* pBrk = m_aModifiedBreakPointList.at( nEntry );
return pBrk;
}
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 155079ed30f0..58f0ade3bec7 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -56,8 +56,9 @@
#include <com/sun/star/script/XLibraryContainer2.hpp>
#include <com/sun/star/document/MacroExecMode.hpp>
-#include <list>
-using ::std::list;
+#include <map>
+using ::std::map;
+using ::std::pair;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -553,7 +554,7 @@ IMPL_LINK( MacroChooser, BasicSelectHdl, SvTreeListBox *, pBox )
// Die Macros sollen in der Reihenfolge angezeigt werden,
// wie sie im Modul stehen.
- list< SbMethod* > aMacros;
+ map< sal_uInt16, SbMethod* > aMacros;
size_t nMacroCount = pModule->GetMethods()->Count();
for ( size_t iMeth = 0; iMeth < nMacroCount; iMeth++ )
{
@@ -562,26 +563,14 @@ IMPL_LINK( MacroChooser, BasicSelectHdl, SvTreeListBox *, pBox )
continue;
DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
// Eventuell weiter vorne ?
- USHORT nStart, nEnd;
+ sal_uInt16 nStart, nEnd;
pMethod->GetLineRange( nStart, nEnd );
- list< SbMethod* >::iterator itr;
- for ( itr = aMacros.begin(); itr != aMacros.end(); ++itr )
- {
- USHORT nS, nE;
- SbMethod* pM = *itr;
- DBG_ASSERT( pM, "Macro nicht in Liste ?!" );
- pM->GetLineRange( nS, nE );
- if ( nS > nStart ) {
- break;
- }
- }
- if ( itr != aMacros.end() ) ++itr;
- aMacros.insert( itr, pMethod );
+ aMacros.insert( map< sal_uInt16, SbMethod*>::value_type( nStart, pMethod ) );
}
aMacroBox.SetUpdateMode( FALSE );
- for ( list< SbMethod* >::iterator itr = aMacros.begin(); itr != aMacros.end(); ++itr )
- aMacroBox.InsertEntry( (*itr)->GetName() );
+ for ( map< sal_uInt16, SbMethod* >::iterator it = aMacros.begin(); it != aMacros.end(); ++it )
+ aMacroBox.InsertEntry( (*it).second->GetName() );
aMacroBox.SetUpdateMode( TRUE );
if ( aMacroBox.GetEntryCount() )
diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx
index 2d9ded65fef1..65dbe43abc39 100644
--- a/basctl/source/inc/bastypes.hxx
+++ b/basctl/source/inc/bastypes.hxx
@@ -54,6 +54,7 @@ class SfxItemSet;
#include <com/sun/star/script/XLibraryContainer.hpp>
#include <hash_map>
+#include <vector>
#define LINE_SEP_CR 0x0D
#define LINE_SEP 0x0A
@@ -84,14 +85,13 @@ struct BasicStatus
struct BreakPoint
{
- BOOL bEnabled;
- BOOL bTemp;
- ULONG nLine;
- ULONG nStopAfter;
- ULONG nHitCount;
-
- BreakPoint( ULONG nL ) { nLine = nL; nStopAfter = 0; nHitCount = 0; bEnabled = TRUE; bTemp = FALSE; }
+ bool bEnabled;
+ bool bTemp;
+ size_t nLine;
+ size_t nStopAfter;
+ size_t nHitCount;
+ BreakPoint( size_t nL ) { nLine = nL; nStopAfter = 0; nHitCount = 0; bEnabled = true; bTemp = false; }
};
class BasicDockingWindow : public DockingWindow
@@ -109,11 +109,11 @@ public:
BasicDockingWindow( Window* pParent );
};
-DECLARE_LIST( BreakPL, BreakPoint* )
-class BreakPointList : public BreakPL
+class BreakPointList
{
private:
void operator =(BreakPointList); // not implemented
+ ::std::vector< BreakPoint* > maBreakPoints;
public:
BreakPointList();
@@ -127,10 +127,17 @@ public:
void transfer(BreakPointList & rList);
void InsertSorted( BreakPoint* pBrk );
- BreakPoint* FindBreakPoint( ULONG nLine );
- void AdjustBreakPoints( ULONG nLine, BOOL bInserted );
+ BreakPoint* FindBreakPoint( size_t nLine );
+ void AdjustBreakPoints( size_t nLine, bool bInserted );
void SetBreakPointsInBasic( SbModule* pModule );
void ResetHitCount();
+
+ size_t size() const;
+ BreakPoint* at( size_t i );
+ const BreakPoint* at( size_t i ) const;
+ BreakPoint* remove( BreakPoint* ptr );
+ void push_back( BreakPoint* item );
+ void clear();
};
// helper class for sorting TabBar