bump product version to 4.1.6.2
[LibreOffice.git] / basctl / source / basicide / breakpoint.cxx
blob6af1365254514fd735436dd5a0572d8534ec205f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
25 #include <stddef.h>
27 namespace basctl
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()
41 reset();
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)
53 reset();
54 for (size_t i = 0; i < rList.size(); ++i)
55 maBreakPoints.push_back( rList.at( i ) );
56 rList.clear();
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 );
67 return;
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 ];
81 if ( pBrk->bEnabled )
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 )
92 return pBrk;
94 return NULL;
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 )
105 if ( bInserted )
106 pBrk->nLine++;
107 else
108 bDelBrk = true;
110 else if ( pBrk->nLine > nLine )
112 if ( bInserted )
113 pBrk->nLine++;
114 else
115 pBrk->nLine--;
118 if ( bDelBrk )
120 delete remove( pBrk );
122 else
124 ++i;
129 void BreakPointList::ResetHitCount()
131 for ( size_t i = 0, n = maBreakPoints.size(); i < n; ++i )
133 BreakPoint* pBrk = maBreakPoints[ i ];
134 pBrk->nHitCount = 0;
138 BreakPoint* BreakPointList::remove(BreakPoint* ptr)
140 for ( ::std::vector< BreakPoint* >::iterator i = maBreakPoints.begin(); i < maBreakPoints.end(); ++i )
142 if ( ptr == *i )
144 maBreakPoints.erase( i );
145 return ptr;
148 return NULL;
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: */