LCOV - code coverage report
Current view: top level - libreoffice/basctl/source/basicide - breakpoint.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 75 0.0 %
Date: 2012-12-17 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include <stddef.h>
      26             : 
      27             : namespace basctl
      28             : {
      29             : 
      30           0 : BreakPointList::BreakPointList()
      31           0 : {}
      32             : 
      33           0 : BreakPointList::BreakPointList(BreakPointList const & rList)
      34             : {
      35           0 :     for (size_t i = 0; i < rList.size(); ++i)
      36           0 :         maBreakPoints.push_back( new BreakPoint(*rList.at( i ) ) );
      37           0 : }
      38             : 
      39           0 : BreakPointList::~BreakPointList()
      40             : {
      41           0 :     reset();
      42           0 : }
      43             : 
      44           0 : void BreakPointList::reset()
      45             : {
      46           0 :     for ( size_t i = 0, n = maBreakPoints.size(); i < n; ++i )
      47           0 :         delete maBreakPoints[ i ];
      48           0 :     maBreakPoints.clear();
      49           0 : }
      50             : 
      51           0 : void BreakPointList::transfer(BreakPointList & rList)
      52             : {
      53           0 :     reset();
      54           0 :     for (size_t i = 0; i < rList.size(); ++i)
      55           0 :         maBreakPoints.push_back( rList.at( i ) );
      56           0 :     rList.clear();
      57           0 : }
      58             : 
      59           0 : void BreakPointList::InsertSorted(BreakPoint* pNewBrk)
      60             : {
      61           0 :     for ( ::std::vector< BreakPoint* >::iterator i = maBreakPoints.begin(); i < maBreakPoints.end(); ++i )
      62             :     {
      63           0 :         if ( pNewBrk->nLine <= (*i)->nLine )
      64             :         {
      65             :             DBG_ASSERT( ( (*i)->nLine != pNewBrk->nLine ) || pNewBrk->bTemp, "BreakPoint existiert schon!" );
      66           0 :             maBreakPoints.insert( i, pNewBrk );
      67           0 :             return;
      68             :         }
      69             :     }
      70             :     // no insert position found => LIST_APPEND
      71           0 :     maBreakPoints.push_back( pNewBrk );
      72             : }
      73             : 
      74           0 : void BreakPointList::SetBreakPointsInBasic(SbModule* pModule)
      75             : {
      76           0 :     pModule->ClearAllBP();
      77             : 
      78           0 :     for ( size_t i = 0, n = maBreakPoints.size(); i < n; ++i )
      79             :     {
      80           0 :         BreakPoint* pBrk = maBreakPoints[ i ];
      81           0 :         if ( pBrk->bEnabled )
      82           0 :             pModule->SetBP( (sal_uInt16)pBrk->nLine );
      83             :     }
      84           0 : }
      85             : 
      86           0 : BreakPoint* BreakPointList::FindBreakPoint(size_t nLine)
      87             : {
      88           0 :     for ( size_t i = 0, n = maBreakPoints.size(); i < n; ++i )
      89             :     {
      90           0 :         BreakPoint* pBrk = maBreakPoints[ i ];
      91           0 :         if ( pBrk->nLine == nLine )
      92           0 :             return pBrk;
      93             :     }
      94           0 :     return NULL;
      95             : }
      96             : 
      97           0 : void BreakPointList::AdjustBreakPoints(size_t nLine, bool bInserted)
      98             : {
      99           0 :     for ( size_t i = 0; i < maBreakPoints.size(); )
     100             :     {
     101           0 :         BreakPoint* pBrk = maBreakPoints[ i ];
     102           0 :         bool bDelBrk = false;
     103           0 :         if ( pBrk->nLine == nLine )
     104             :         {
     105           0 :             if ( bInserted )
     106           0 :                 pBrk->nLine++;
     107             :             else
     108           0 :                 bDelBrk = true;
     109             :         }
     110           0 :         else if ( pBrk->nLine > nLine )
     111             :         {
     112           0 :             if ( bInserted )
     113           0 :                 pBrk->nLine++;
     114             :             else
     115           0 :                 pBrk->nLine--;
     116             :         }
     117             : 
     118           0 :         if ( bDelBrk )
     119             :         {
     120           0 :             delete remove( pBrk );
     121             :         }
     122             :         else
     123             :         {
     124           0 :             ++i;
     125             :         }
     126             :     }
     127           0 : }
     128             : 
     129           0 : void BreakPointList::ResetHitCount()
     130             : {
     131           0 :     for ( size_t i = 0, n = maBreakPoints.size(); i < n; ++i )
     132             :     {
     133           0 :         BreakPoint* pBrk = maBreakPoints[ i ];
     134           0 :         pBrk->nHitCount = 0;
     135             :     }
     136           0 : }
     137             : 
     138           0 : BreakPoint* BreakPointList::remove(BreakPoint* ptr)
     139             : {
     140           0 :     for ( ::std::vector< BreakPoint* >::iterator i = maBreakPoints.begin(); i < maBreakPoints.end(); ++i )
     141             :     {
     142           0 :         if ( ptr == *i )
     143             :         {
     144           0 :             maBreakPoints.erase( i );
     145           0 :             return ptr;
     146             :         }
     147             :     }
     148           0 :     return NULL;
     149             : }
     150             : 
     151           0 : size_t BreakPointList::size() const
     152             : {
     153           0 :     return maBreakPoints.size();
     154             : }
     155             : 
     156           0 : BreakPoint* BreakPointList::at(size_t i)
     157             : {
     158           0 :     return i < maBreakPoints.size() ? maBreakPoints[ i ] : NULL;
     159             : }
     160             : 
     161           0 : const BreakPoint* BreakPointList::at(size_t i) const
     162             : {
     163           0 :     return i < maBreakPoints.size() ? maBreakPoints[ i ] : NULL;
     164             : }
     165             : 
     166           0 : void BreakPointList::clear()
     167             : {
     168           0 :     maBreakPoints.clear();
     169           0 : }
     170             : 
     171             : } // namespace basctl
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10