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>
30 BreakPointList::BreakPointList()
33 BreakPointList::BreakPointList(BreakPointList
const & rList
)
35 for (size_t i
= 0; i
< rList
.size(); ++i
)
36 maBreakPoints
.push_back( new BreakPoint(*rList
.at( i
) ) );
39 BreakPointList::~BreakPointList()
44 void BreakPointList::reset()
46 for ( size_t i
= 0, n
= maBreakPoints
.size(); i
< n
; ++i
)
47 delete maBreakPoints
[ i
];
48 maBreakPoints
.clear();
51 void BreakPointList::transfer(BreakPointList
& rList
)
54 for (size_t i
= 0; i
< rList
.size(); ++i
)
55 maBreakPoints
.push_back( rList
.at( i
) );
59 void BreakPointList::InsertSorted(BreakPoint
* pNewBrk
)
61 for ( ::std::vector
< BreakPoint
* >::iterator i
= maBreakPoints
.begin(); i
< maBreakPoints
.end(); ++i
)
63 if ( pNewBrk
->nLine
<= (*i
)->nLine
)
65 DBG_ASSERT( ( (*i
)->nLine
!= pNewBrk
->nLine
) || pNewBrk
->bTemp
, "BreakPoint existiert schon!" );
66 maBreakPoints
.insert( i
, pNewBrk
);
70 // no insert position found => LIST_APPEND
71 maBreakPoints
.push_back( pNewBrk
);
74 void BreakPointList::SetBreakPointsInBasic(SbModule
* pModule
)
76 pModule
->ClearAllBP();
78 for ( size_t i
= 0, n
= maBreakPoints
.size(); i
< n
; ++i
)
80 BreakPoint
* pBrk
= maBreakPoints
[ i
];
82 pModule
->SetBP( (sal_uInt16
)pBrk
->nLine
);
86 BreakPoint
* BreakPointList::FindBreakPoint(size_t nLine
)
88 for ( size_t i
= 0, n
= maBreakPoints
.size(); i
< n
; ++i
)
90 BreakPoint
* pBrk
= maBreakPoints
[ i
];
91 if ( pBrk
->nLine
== nLine
)
97 void BreakPointList::AdjustBreakPoints(size_t nLine
, bool bInserted
)
99 for ( size_t i
= 0; i
< maBreakPoints
.size(); )
101 BreakPoint
* pBrk
= maBreakPoints
[ i
];
102 bool bDelBrk
= false;
103 if ( pBrk
->nLine
== nLine
)
110 else if ( pBrk
->nLine
> nLine
)
120 delete remove( pBrk
);
129 void BreakPointList::ResetHitCount()
131 for ( size_t i
= 0, n
= maBreakPoints
.size(); i
< n
; ++i
)
133 BreakPoint
* pBrk
= maBreakPoints
[ i
];
138 BreakPoint
* BreakPointList::remove(BreakPoint
* ptr
)
140 for ( ::std::vector
< BreakPoint
* >::iterator i
= maBreakPoints
.begin(); i
< maBreakPoints
.end(); ++i
)
144 maBreakPoints
.erase( i
);
151 size_t BreakPointList::size() const
153 return maBreakPoints
.size();
156 BreakPoint
* BreakPointList::at(size_t i
)
158 return i
< maBreakPoints
.size() ? maBreakPoints
[ i
] : NULL
;
161 const BreakPoint
* BreakPointList::at(size_t i
) const
163 return i
< maBreakPoints
.size() ? maBreakPoints
[ i
] : NULL
;
166 void BreakPointList::clear()
168 maBreakPoints
.clear();
171 } // namespace basctl
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */