2011-12-04 22:01:35 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-26 20:42:49 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2011-12-04 22:01:35 -05:00
|
|
|
|
|
|
|
#include "breakpoint.hxx"
|
|
|
|
|
|
|
|
#include <basic/sbmod.hxx>
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
|
2011-12-05 00:52:02 -05:00
|
|
|
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
namespace basctl
|
|
|
|
{
|
|
|
|
|
2011-12-04 22:01:35 -05:00
|
|
|
BreakPointList::BreakPointList()
|
|
|
|
{}
|
|
|
|
|
|
|
|
BreakPointList::BreakPointList(BreakPointList const & rList)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < rList.size(); ++i)
|
2018-11-16 10:41:03 +02:00
|
|
|
maBreakPoints.push_back( rList.at( i ) );
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
BreakPointList::~BreakPointList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void BreakPointList::reset()
|
|
|
|
{
|
|
|
|
maBreakPoints.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BreakPointList::transfer(BreakPointList & rList)
|
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
maBreakPoints = std::move(rList.maBreakPoints);
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
|
2018-05-17 15:31:21 +02:00
|
|
|
void BreakPointList::InsertSorted(BreakPoint aNewBrk)
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
for ( auto it = maBreakPoints.begin(); it != maBreakPoints.end(); ++it )
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
if ( aNewBrk.nLine <= it->nLine )
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
DBG_ASSERT( it->nLine != aNewBrk.nLine, "BreakPoint exists already!" );
|
|
|
|
maBreakPoints.insert( it, aNewBrk );
|
2011-12-04 22:01:35 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// no insert position found => LIST_APPEND
|
2018-05-17 15:31:21 +02:00
|
|
|
maBreakPoints.push_back( aNewBrk );
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void BreakPointList::SetBreakPointsInBasic(SbModule* pModule)
|
|
|
|
{
|
|
|
|
pModule->ClearAllBP();
|
|
|
|
|
2018-05-17 15:31:21 +02:00
|
|
|
for (BreakPoint& rBrk : maBreakPoints)
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
if ( rBrk.bEnabled )
|
|
|
|
pModule->SetBP( rBrk.nLine );
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-17 15:31:21 +02:00
|
|
|
BreakPoint* BreakPointList::FindBreakPoint(sal_uInt16 nLine)
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
for (BreakPoint& rBrk : maBreakPoints)
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
if ( rBrk.nLine == nLine )
|
|
|
|
return &rBrk;
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
2015-11-10 10:10:16 +01:00
|
|
|
return nullptr;
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
|
2018-05-17 15:31:21 +02:00
|
|
|
void BreakPointList::AdjustBreakPoints(sal_uInt16 nLine, bool bInserted)
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
|
|
|
for ( size_t i = 0; i < maBreakPoints.size(); )
|
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
BreakPoint& rBrk = maBreakPoints[ i ];
|
2011-12-04 22:01:35 -05:00
|
|
|
bool bDelBrk = false;
|
2018-05-17 15:31:21 +02:00
|
|
|
if ( rBrk.nLine == nLine )
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
|
|
|
if ( bInserted )
|
2018-05-17 15:31:21 +02:00
|
|
|
rBrk.nLine++;
|
2011-12-04 22:01:35 -05:00
|
|
|
else
|
|
|
|
bDelBrk = true;
|
|
|
|
}
|
2018-05-17 15:31:21 +02:00
|
|
|
else if ( rBrk.nLine > nLine )
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
|
|
|
if ( bInserted )
|
2018-05-17 15:31:21 +02:00
|
|
|
rBrk.nLine++;
|
2011-12-04 22:01:35 -05:00
|
|
|
else
|
2018-05-17 15:31:21 +02:00
|
|
|
rBrk.nLine--;
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bDelBrk )
|
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
maBreakPoints.erase(maBreakPoints.begin() + i);
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BreakPointList::ResetHitCount()
|
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
for (BreakPoint& rBrk : maBreakPoints)
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
rBrk.nHitCount = 0;
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-23 14:31:11 +02:00
|
|
|
void BreakPointList::remove(const BreakPoint* ptr)
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
for ( auto i = maBreakPoints.begin(); i != maBreakPoints.end(); ++i )
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
if ( ptr == &(*i) )
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
|
|
|
maBreakPoints.erase( i );
|
2018-05-17 15:31:21 +02:00
|
|
|
return;
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
}
|
2018-05-17 15:31:21 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BreakPointList::remove(size_t idx)
|
|
|
|
{
|
|
|
|
maBreakPoints.erase( maBreakPoints.begin() + idx );
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t BreakPointList::size() const
|
|
|
|
{
|
|
|
|
return maBreakPoints.size();
|
|
|
|
}
|
|
|
|
|
2018-05-17 15:31:21 +02:00
|
|
|
BreakPoint& BreakPointList::at(size_t i)
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
return maBreakPoints[ i ];
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
|
2018-05-17 15:31:21 +02:00
|
|
|
const BreakPoint& BreakPointList::at(size_t i) const
|
2011-12-04 22:01:35 -05:00
|
|
|
{
|
2018-05-17 15:31:21 +02:00
|
|
|
return maBreakPoints[ i ];
|
2011-12-04 22:01:35 -05:00
|
|
|
}
|
|
|
|
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
} // namespace basctl
|
|
|
|
|
2011-12-04 22:01:35 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|