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 maBreakPoints
.insert(maBreakPoints
.end(), rList
.maBreakPoints
.begin(), rList
.maBreakPoints
.end());
37 BreakPointList::~BreakPointList()
41 void BreakPointList::reset()
43 maBreakPoints
.clear();
46 void BreakPointList::transfer(BreakPointList
& rList
)
48 maBreakPoints
= std::move(rList
.maBreakPoints
);
51 void BreakPointList::InsertSorted(BreakPoint aNewBrk
)
53 auto it
= std::find_if(maBreakPoints
.begin(), maBreakPoints
.end(),
54 [&aNewBrk
](const BreakPoint
& rBreakPoint
) { return aNewBrk
.nLine
<= rBreakPoint
.nLine
; });
55 if (it
!= maBreakPoints
.end())
57 DBG_ASSERT( it
->nLine
!= aNewBrk
.nLine
, "BreakPoint exists already!" );
58 maBreakPoints
.insert( it
, aNewBrk
);
61 // no insert position found => LIST_APPEND
62 maBreakPoints
.push_back( aNewBrk
);
65 void BreakPointList::SetBreakPointsInBasic(SbModule
* pModule
)
67 pModule
->ClearAllBP();
69 for (const BreakPoint
& rBrk
: maBreakPoints
)
72 pModule
->SetBP( rBrk
.nLine
);
76 BreakPoint
* BreakPointList::FindBreakPoint(sal_uInt16 nLine
)
78 for (BreakPoint
& rBrk
: maBreakPoints
)
80 if ( rBrk
.nLine
== nLine
)
86 void BreakPointList::AdjustBreakPoints(sal_uInt16 nLine
, bool bInserted
)
88 for ( size_t i
= 0; i
< maBreakPoints
.size(); )
90 BreakPoint
& rBrk
= maBreakPoints
[ i
];
92 if ( rBrk
.nLine
== nLine
)
99 else if ( rBrk
.nLine
> nLine
)
109 maBreakPoints
.erase(maBreakPoints
.begin() + i
);
118 void BreakPointList::ResetHitCount()
120 for (BreakPoint
& rBrk
: maBreakPoints
)
126 void BreakPointList::remove(const BreakPoint
* ptr
)
128 auto i
= std::find_if(maBreakPoints
.begin(), maBreakPoints
.end(),
129 [&ptr
](const BreakPoint
& rBreakPoint
) { return ptr
== &rBreakPoint
; });
130 if (i
!= maBreakPoints
.end())
131 maBreakPoints
.erase( i
);
135 void BreakPointList::remove(size_t idx
)
137 maBreakPoints
.erase( maBreakPoints
.begin() + idx
);
140 size_t BreakPointList::size() const
142 return maBreakPoints
.size();
145 BreakPoint
& BreakPointList::at(size_t i
)
147 return maBreakPoints
[ i
];
150 const BreakPoint
& BreakPointList::at(size_t i
) const
152 return maBreakPoints
[ i
];
155 } // namespace basctl
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */