1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "breakpoint.hxx"
22 #include <basic/sbmod.hxx>
23 #include <tools/debug.hxx>
29 BreakPointList::BreakPointList()
32 BreakPointList::BreakPointList(BreakPointList
const & rList
)
34 for (size_t i
= 0; i
< rList
.size(); ++i
)
35 maBreakPoints
.push_back( new BreakPoint(*rList
.at( i
) ) );
38 BreakPointList::~BreakPointList()
43 void BreakPointList::reset()
45 for (BreakPoint
* pBreakPoint
: maBreakPoints
)
47 maBreakPoints
.clear();
50 void BreakPointList::transfer(BreakPointList
& rList
)
52 maBreakPoints
.swap(rList
.maBreakPoints
);
56 void BreakPointList::InsertSorted(BreakPoint
* pNewBrk
)
58 for ( std::vector
< BreakPoint
* >::iterator i
= maBreakPoints
.begin(); i
!= maBreakPoints
.end(); ++i
)
60 if ( pNewBrk
->nLine
<= (*i
)->nLine
)
62 DBG_ASSERT( (*i
)->nLine
!= pNewBrk
->nLine
, "BreakPoint exists already!" );
63 maBreakPoints
.insert( i
, pNewBrk
);
67 // no insert position found => LIST_APPEND
68 maBreakPoints
.push_back( pNewBrk
);
71 void BreakPointList::SetBreakPointsInBasic(SbModule
* pModule
)
73 pModule
->ClearAllBP();
75 for (BreakPoint
* pBrk
: maBreakPoints
)
78 pModule
->SetBP( static_cast<sal_uInt16
>(pBrk
->nLine
) );
82 BreakPoint
* BreakPointList::FindBreakPoint(size_t nLine
)
84 for (BreakPoint
* pBrk
: maBreakPoints
)
86 if ( pBrk
->nLine
== nLine
)
92 void BreakPointList::AdjustBreakPoints(size_t nLine
, bool bInserted
)
94 for ( size_t i
= 0; i
< maBreakPoints
.size(); )
96 BreakPoint
* pBrk
= maBreakPoints
[ i
];
98 if ( pBrk
->nLine
== nLine
)
105 else if ( pBrk
->nLine
> nLine
)
115 delete remove( pBrk
);
124 void BreakPointList::ResetHitCount()
126 for (BreakPoint
* pBrk
: maBreakPoints
)
132 BreakPoint
* BreakPointList::remove(BreakPoint
* ptr
)
134 for ( std::vector
< BreakPoint
* >::iterator i
= maBreakPoints
.begin(); i
!= maBreakPoints
.end(); ++i
)
138 maBreakPoints
.erase( i
);
145 size_t BreakPointList::size() const
147 return maBreakPoints
.size();
150 BreakPoint
* BreakPointList::at(size_t i
)
152 return i
< maBreakPoints
.size() ? maBreakPoints
[ i
] : nullptr;
155 const BreakPoint
* BreakPointList::at(size_t i
) const
157 return i
< maBreakPoints
.size() ? maBreakPoints
[ i
] : nullptr;
160 } // namespace basctl
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */