LibreOffice Module basctl (master) 1
breakpoint.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "breakpoint.hxx"
21
22#include <basic/sbmod.hxx>
23#include <tools/debug.hxx>
24
25
26namespace basctl
27{
28
30{}
31
33{
34 for (size_t i = 0; i < rList.size(); ++i)
35 maBreakPoints.push_back( rList.at( i ) );
36}
37
39{
40}
41
43{
44 maBreakPoints.clear();
45}
46
48{
49 maBreakPoints = std::move(rList.maBreakPoints);
50}
51
53{
54 auto it = std::find_if(maBreakPoints.begin(), maBreakPoints.end(),
55 [&aNewBrk](const BreakPoint& rBreakPoint) { return aNewBrk.nLine <= rBreakPoint.nLine; });
56 if (it != maBreakPoints.end())
57 {
58 DBG_ASSERT( it->nLine != aNewBrk.nLine, "BreakPoint exists already!" );
59 maBreakPoints.insert( it, aNewBrk );
60 return;
61 }
62 // no insert position found => LIST_APPEND
63 maBreakPoints.push_back( aNewBrk );
64}
65
67{
68 pModule->ClearAllBP();
69
70 for (const BreakPoint& rBrk : maBreakPoints)
71 {
72 if ( rBrk.bEnabled )
73 pModule->SetBP( rBrk.nLine );
74 }
75}
76
78{
79 for (BreakPoint& rBrk : maBreakPoints)
80 {
81 if ( rBrk.nLine == nLine )
82 return &rBrk;
83 }
84 return nullptr;
85}
86
87void BreakPointList::AdjustBreakPoints(sal_uInt16 nLine, bool bInserted)
88{
89 for ( size_t i = 0; i < maBreakPoints.size(); )
90 {
91 BreakPoint& rBrk = maBreakPoints[ i ];
92 bool bDelBrk = false;
93 if ( rBrk.nLine == nLine )
94 {
95 if ( bInserted )
96 rBrk.nLine++;
97 else
98 bDelBrk = true;
99 }
100 else if ( rBrk.nLine > nLine )
101 {
102 if ( bInserted )
103 rBrk.nLine++;
104 else
105 rBrk.nLine--;
106 }
107
108 if ( bDelBrk )
109 {
110 maBreakPoints.erase(maBreakPoints.begin() + i);
111 }
112 else
113 {
114 ++i;
115 }
116 }
117}
118
120{
121 for (BreakPoint& rBrk : maBreakPoints)
122 {
123 rBrk.nHitCount = 0;
124 }
125}
126
128{
129 auto i = std::find_if(maBreakPoints.begin(), maBreakPoints.end(),
130 [&ptr](const BreakPoint& rBreakPoint) { return ptr == &rBreakPoint; });
131 if (i != maBreakPoints.end())
132 maBreakPoints.erase( i );
133 return;
134}
135
137{
138 maBreakPoints.erase( maBreakPoints.begin() + idx );
139}
140
142{
143 return maBreakPoints.size();
144}
145
147{
148 return maBreakPoints[ i ];
149}
150
151const BreakPoint& BreakPointList::at(size_t i) const
152{
153 return maBreakPoints[ i ];
154}
155
156} // namespace basctl
157
158/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool SetBP(sal_uInt16 nLine)
void ClearAllBP()
void InsertSorted(BreakPoint pBrk)
Definition: breakpoint.cxx:52
size_t size() const
Definition: breakpoint.cxx:141
void transfer(BreakPointList &rList)
Definition: breakpoint.cxx:47
void SetBreakPointsInBasic(SbModule *pModule)
Definition: breakpoint.cxx:66
void remove(const BreakPoint *ptr)
Definition: breakpoint.cxx:127
std::vector< BreakPoint > maBreakPoints
Definition: breakpoint.hxx:51
void AdjustBreakPoints(sal_uInt16 nLine, bool bInserted)
Definition: breakpoint.cxx:87
BreakPoint * FindBreakPoint(sal_uInt16 nLine)
Definition: breakpoint.cxx:77
BreakPoint & at(size_t i)
Definition: breakpoint.cxx:146
#define DBG_ASSERT(sCon, aError)
const sal_uInt16 idx[]
int i
sal_uInt16 nLine
Definition: breakpoint.hxx:34