Kaydet (Commit) 444c242c authored tarafından Joseph Powers's avatar Joseph Powers

remove DECLARE_LIST( BreakPL, BreakPoint* )

Also simplify the prior patch & make sure the list is in the right order.
üst 52b66899
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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()
{
}
......
......@@ -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;
}
......
......@@ -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() )
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment