mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-21 07:12:10 +00:00
iterators-2.diff + some whitespace changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6995 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cff6c33f78
commit
d605c30d8c
@ -373,7 +373,7 @@ bool BufferView::removeAutoInsets()
|
||||
ParIterator it = buffer()->par_iterator_begin();
|
||||
ParIterator end = buffer()->par_iterator_end();
|
||||
for (; it != end; ++it) {
|
||||
Paragraph * par = *it;
|
||||
Paragraph * par = &*(*it);
|
||||
Paragraph * par_prev = par ? par->previous() : 0;
|
||||
bool removed = false;
|
||||
|
||||
@ -495,7 +495,7 @@ void BufferView::showErrorList(string const & action) const
|
||||
}
|
||||
|
||||
|
||||
ErrorList const &
|
||||
ErrorList const &
|
||||
BufferView::getErrorList() const
|
||||
{
|
||||
return pimpl_->errorlist_;
|
||||
@ -764,7 +764,7 @@ bool BufferView::ChangeInsets(Inset::Code code,
|
||||
ParIterator end = buffer()->par_iterator_end();
|
||||
for (ParIterator it = buffer()->par_iterator_begin();
|
||||
it != end; ++it) {
|
||||
Paragraph * par = *it;
|
||||
Paragraph * par = &*(*it);
|
||||
bool changed_inset = false;
|
||||
for (InsetList::iterator it2 = par->insetlist.begin();
|
||||
it2 != par->insetlist.end(); ++it2) {
|
||||
|
@ -842,9 +842,9 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
|
||||
string const disp_fn = MakeDisplayPath(filename);
|
||||
owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
|
||||
bool const res = bv_->insertLyXFile(filename);
|
||||
if (res)
|
||||
if (res)
|
||||
owner_->message(bformat(_("Document %1$s inserted."), disp_fn));
|
||||
else
|
||||
else
|
||||
owner_->message(bformat(_("Could not insert document %1$s"), disp_fn));
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,17 @@
|
||||
2003-05-21 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* toc.C (getTocList): adjust
|
||||
|
||||
* iterators.[Ch]: rework for parlist
|
||||
|
||||
* buffer.C (par_iterator_begin): adjust
|
||||
(par_iterator_end): adjust
|
||||
|
||||
* CutAndPaste.C (SwitchLayoutsBetweenClasses): adjust
|
||||
|
||||
* BufferView.C (removeAutoInsets): adjust
|
||||
(ChangeInsets): adjust
|
||||
|
||||
2003-05-21 Alfredo Braunstein <abraunst@libero.it>
|
||||
|
||||
* text.C (top_y): fix bug 1110
|
||||
@ -55,13 +69,13 @@
|
||||
* ParagraphParameters.C (params2string): small bug fixed
|
||||
|
||||
2003-05-16 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
|
||||
* debug.C:
|
||||
* bufferview_funcs.C: patch from Kornel Benko to prevent
|
||||
* bufferview_funcs.C: patch from Kornel Benko to prevent
|
||||
crash when _(...) is called twice in a statement
|
||||
|
||||
2003-05-16 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
|
||||
* BufferView.C:
|
||||
* lyxfunc.C:
|
||||
* text.C:
|
||||
@ -74,7 +88,7 @@
|
||||
* lyx_main.C (init): remove spurious static_cast
|
||||
|
||||
2003-05-14 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
|
||||
* BufferView.C: fix format string
|
||||
|
||||
2003-05-12 Alfredo Braunstein <abraunst@libero.it>
|
||||
@ -85,7 +99,7 @@
|
||||
* converter.C (scanLog): call showErrorList instead of inserterrors
|
||||
|
||||
2003-05-13 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
|
||||
* BufferView_pimpl.C:
|
||||
* buffer.C:
|
||||
* bufferview_func.C:
|
||||
|
@ -223,7 +223,7 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
|
||||
// new environment and set also another font if that is required.
|
||||
|
||||
// Make sure there is no class difference.
|
||||
SwitchLayoutsBetweenClasses(textclass, tc, simple_cut_clone,
|
||||
SwitchLayoutsBetweenClasses(textclass, tc, simple_cut_clone,
|
||||
errorlist);
|
||||
|
||||
ParagraphList::iterator tmpbuf = simple_cut_clone.begin();
|
||||
@ -338,17 +338,15 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
|
||||
{
|
||||
lyx::Assert(!pars.empty());
|
||||
|
||||
Paragraph * par = &*pars.begin();
|
||||
|
||||
int ret = 0;
|
||||
if (c1 == c2)
|
||||
return ret;
|
||||
|
||||
LyXTextClass const & tclass1 = textclasslist[c1];
|
||||
LyXTextClass const & tclass2 = textclasslist[c2];
|
||||
ParIterator end = ParIterator();
|
||||
for (ParIterator it = ParIterator(par); it != end; ++it) {
|
||||
par = *it;
|
||||
ParIterator end = ParIterator(pars.end(), pars);
|
||||
for (ParIterator it = ParIterator(pars.begin(), pars); it != end; ++it) {
|
||||
Paragraph * par = &*(*it);
|
||||
string const name = par->layout()->name();
|
||||
bool hasLayout = tclass2.hasLayout(name);
|
||||
|
||||
@ -364,8 +362,8 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
|
||||
"because of class conversion from\n%3$s to %4$s"),
|
||||
name, par->layout()->name(), tclass1.name(), tclass2.name());
|
||||
// To warn the user that something had to be done.
|
||||
errorlist.push_back(ErrorItem("Changed Layout", s,
|
||||
par->id(), 0,
|
||||
errorlist.push_back(ErrorItem("Changed Layout", s,
|
||||
par->id(), 0,
|
||||
par->size()));
|
||||
}
|
||||
}
|
||||
|
14
src/buffer.C
14
src/buffer.C
@ -148,7 +148,7 @@ Buffer::~Buffer()
|
||||
users->buffer(0);
|
||||
|
||||
if (!tmppath.empty() && destroyDir(tmppath) != 0) {
|
||||
Alert::warning(_("Could not remove temporary directory"),
|
||||
Alert::warning(_("Could not remove temporary directory"),
|
||||
bformat(_("Could not remove the temporary directory %1$s"), tmppath));
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ namespace {
|
||||
|
||||
void unknownClass(string const & unknown)
|
||||
{
|
||||
Alert::warning(_("Unknown document class"),
|
||||
Alert::warning(_("Unknown document class"),
|
||||
bformat(_("Using the default document class, because the "
|
||||
" class %1$s is unknown."), unknown));
|
||||
}
|
||||
@ -1969,7 +1969,7 @@ int Buffer::runChktex()
|
||||
_("Could not run chktex successfully."));
|
||||
} else if (res > 0) {
|
||||
// Insert all errors as errors boxes
|
||||
ErrorList el (*this, terr);
|
||||
ErrorList el (*this, terr);
|
||||
users->setErrorList(el);
|
||||
users->showErrorList(_("ChkTeX"));
|
||||
}
|
||||
@ -2249,24 +2249,24 @@ bool Buffer::hasParWithID(int id) const
|
||||
|
||||
ParIterator Buffer::par_iterator_begin()
|
||||
{
|
||||
return ParIterator(&*(paragraphs.begin()));
|
||||
return ParIterator(paragraphs.begin(), paragraphs);
|
||||
}
|
||||
|
||||
|
||||
ParIterator Buffer::par_iterator_end()
|
||||
{
|
||||
return ParIterator();
|
||||
return ParIterator(paragraphs.end(), paragraphs);
|
||||
}
|
||||
|
||||
ParConstIterator Buffer::par_iterator_begin() const
|
||||
{
|
||||
return ParConstIterator(&*(paragraphs.begin()));
|
||||
return ParConstIterator(paragraphs.begin(), paragraphs);
|
||||
}
|
||||
|
||||
|
||||
ParConstIterator Buffer::par_iterator_end() const
|
||||
{
|
||||
return ParConstIterator();
|
||||
return ParConstIterator(paragraphs.end(), paragraphs);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
2003-05-21 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* insetfloat.C (addToToc): adjust
|
||||
|
||||
2003-05-21 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
@ -24,17 +27,17 @@
|
||||
* insetspecialchar.[Ch]:
|
||||
* insettabular.[Ch]:
|
||||
* insettext.[Ch]: dimensions() instead of ascend/descend/width
|
||||
|
||||
|
||||
2003-05-19 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* insetenv.[Ch]:
|
||||
* insettext.C: more insetenv
|
||||
* insettext.C: more insetenv
|
||||
|
||||
2003-05-16 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* insetcommand.C:
|
||||
* insetminimpage.[Ch]:
|
||||
* insetcollapsable.[Ch]: fix #832
|
||||
* insetcollapsable.[Ch]: fix #832
|
||||
|
||||
2003-05-16 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
@ -61,7 +64,7 @@
|
||||
* insettoc.[Ch]:
|
||||
* inseturl.[Ch]:
|
||||
* updatableinset.[Ch]: edit() -> LFUN_INSET_EDIT
|
||||
|
||||
|
||||
2003-05-13 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* insetbibitem.C:
|
||||
|
@ -37,11 +37,11 @@ void InsetButton::dimension(BufferView * bv, LyXFont const &,
|
||||
|
||||
string const s = getScreenLabel(bv->buffer());
|
||||
|
||||
if (editable())
|
||||
if (editable())
|
||||
font_metrics::buttonText(s, font, dim.w, dim.a, dim.d);
|
||||
else
|
||||
else
|
||||
font_metrics::rectText(s, font, dim.w, dim.a, dim.d);
|
||||
|
||||
|
||||
dim.w += 4;
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ void InsetCollapsable::dimension(BufferView * bv, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
dimension_collapsed(dim);
|
||||
if (collapsed_)
|
||||
if (collapsed_)
|
||||
return;
|
||||
Dimension insetdim;
|
||||
inset.dimension(bv, font, insetdim);
|
||||
|
@ -44,8 +44,8 @@ dispatch_result InsetError::localDispatch(FuncRequest const & cmd)
|
||||
dispatch_result result = UNDISPATCHED;
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
case LFUN_INSET_EDIT:
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
case LFUN_INSET_EDIT:
|
||||
cmd.view()->owner()->getDialogs().show("error", getContents(), this);
|
||||
return DISPATCHED;
|
||||
|
||||
|
@ -555,7 +555,7 @@ bool InsetERT::checkInsertChar(LyXFont & /* font */)
|
||||
void InsetERT::dimension(BufferView * bv, LyXFont const & font,
|
||||
Dimension & dim) const
|
||||
{
|
||||
if (inlined())
|
||||
if (inlined())
|
||||
inset.dimension(bv, font, dim);
|
||||
else
|
||||
InsetCollapsable::dimension(bv, font, dim);
|
||||
|
@ -362,12 +362,12 @@ void InsetFloat::wide(bool w, BufferParams const & bp)
|
||||
|
||||
void InsetFloat::addToToc(toc::TocList & toclist, Buffer const * buf) const
|
||||
{
|
||||
ParIterator pit(&*inset.paragraphs.begin());
|
||||
ParIterator end;
|
||||
ParIterator pit(inset.paragraphs.begin(), inset.paragraphs);
|
||||
ParIterator end(inset.paragraphs.end(), inset.paragraphs);
|
||||
|
||||
// Find a caption layout in one of the (child inset's) pars
|
||||
for (; pit != end; ++pit) {
|
||||
Paragraph * tmp = *pit;
|
||||
Paragraph * tmp = &*(*pit);
|
||||
|
||||
if (tmp->layout()->name() == caplayout) {
|
||||
string const name = floatname(params_.type, buf->params);
|
||||
@ -401,7 +401,7 @@ void InsetFloatMailer::string2params(string const & in,
|
||||
|
||||
if (in.empty())
|
||||
return;
|
||||
|
||||
|
||||
istringstream data(STRCONV(in));
|
||||
LyXLex lex(0,0);
|
||||
lex.setStream(data);
|
||||
|
251
src/iterators.C
251
src/iterators.C
@ -1,86 +1,273 @@
|
||||
/* \file iterators.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author unknown
|
||||
* \author Lars Gullik Bjønnes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "iterators.h"
|
||||
#include "paragraph.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <stack>
|
||||
|
||||
using boost::next;
|
||||
using boost::optional;
|
||||
using std::stack;
|
||||
|
||||
///
|
||||
/// ParPosition
|
||||
///
|
||||
|
||||
class ParPosition {
|
||||
public:
|
||||
///
|
||||
ParPosition(ParagraphList::iterator p, ParagraphList const & pl);
|
||||
///
|
||||
ParagraphList::iterator pit;
|
||||
///
|
||||
ParagraphList const * plist;
|
||||
///
|
||||
optional<InsetList::iterator> it;
|
||||
///
|
||||
optional<int> index;
|
||||
};
|
||||
|
||||
|
||||
ParPosition::ParPosition(ParagraphList::iterator p, ParagraphList const & pl)
|
||||
: pit(p), plist(&pl)
|
||||
{
|
||||
if (p != pl.end()) {
|
||||
it.reset(p->insetlist.begin());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool operator==(ParPosition const & pos1, ParPosition const & pos2)
|
||||
{
|
||||
return pos1.pit == pos2.pit;
|
||||
}
|
||||
|
||||
|
||||
bool operator!=(ParPosition const & pos1, ParPosition const & pos2)
|
||||
{
|
||||
return !(pos1 == pos2);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// ParIterator
|
||||
///
|
||||
|
||||
struct ParIterator::Pimpl {
|
||||
typedef stack<ParPosition> PosHolder;
|
||||
PosHolder positions;
|
||||
};
|
||||
|
||||
ParIterator::ParIterator(ParagraphList::iterator pit, ParagraphList const & pl)
|
||||
: pimpl_(new Pimpl)
|
||||
{
|
||||
pimpl_->positions.push(ParPosition(pit, pl));
|
||||
}
|
||||
|
||||
|
||||
ParIterator::~ParIterator()
|
||||
{}
|
||||
|
||||
|
||||
ParIterator::ParIterator(ParIterator const & pi)
|
||||
: pimpl_(new Pimpl(*pi.pimpl_))
|
||||
{}
|
||||
|
||||
|
||||
ParIterator & ParIterator::operator++()
|
||||
{
|
||||
while (!positions.empty()) {
|
||||
ParPosition & p = positions.top();
|
||||
while (!pimpl_->positions.empty()) {
|
||||
ParPosition & p = pimpl_->positions.top();
|
||||
|
||||
// Does the current inset contain more "cells" ?
|
||||
if (p.index >= 0) {
|
||||
++p.index;
|
||||
ParagraphList * plist = p.it.getInset()->getParagraphs(p.index);
|
||||
if (p.index) {
|
||||
++(*p.index);
|
||||
ParagraphList * plist = p.it->getInset()->getParagraphs(*p.index);
|
||||
if (plist && !plist->empty()) {
|
||||
positions.push(ParPosition(&plist->front()));
|
||||
pimpl_->positions.push(ParPosition(plist->begin(), *plist));
|
||||
return *this;
|
||||
}
|
||||
++p.it;
|
||||
++(*p.it);
|
||||
} else
|
||||
// The following line is needed because the value of
|
||||
// p.it may be invalid if inset was added/removed to
|
||||
// the paragraph pointed by the iterator
|
||||
p.it = p.par->insetlist.begin();
|
||||
p.it.reset(p.pit->insetlist.begin());
|
||||
|
||||
// Try to find the next inset that contains paragraphs
|
||||
InsetList::iterator end = p.par->insetlist.end();
|
||||
for (; p.it != end; ++p.it) {
|
||||
ParagraphList * plist = p.it.getInset()->getParagraphs(0);
|
||||
InsetList::iterator end = p.pit->insetlist.end();
|
||||
for (; *p.it != end; ++(*p.it)) {
|
||||
ParagraphList * plist = p.it->getInset()->getParagraphs(0);
|
||||
if (plist && !plist->empty()) {
|
||||
p.index = 0;
|
||||
positions.push(ParPosition(&plist->front()));
|
||||
p.index.reset(0);
|
||||
pimpl_->positions.push(ParPosition(plist->begin(), *plist));
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to go to the next paragarph
|
||||
if (p.par->next()) {
|
||||
p = ParPosition(p.par->next());
|
||||
if (next(p.pit) != p.plist->end()
|
||||
|| pimpl_->positions.size() == 1) {
|
||||
++p.pit;
|
||||
p.index.reset();
|
||||
p.it.reset();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
positions.pop();
|
||||
// Drop end and move up in the stack.
|
||||
pimpl_->positions.pop();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
ParagraphList::iterator ParIterator::operator*()
|
||||
{
|
||||
return pimpl_->positions.top().pit;
|
||||
}
|
||||
|
||||
|
||||
ParagraphList::iterator ParIterator::operator->()
|
||||
{
|
||||
return pimpl_->positions.top().pit;
|
||||
}
|
||||
|
||||
|
||||
size_t ParIterator::size() const
|
||||
{
|
||||
return pimpl_->positions.size();
|
||||
}
|
||||
|
||||
|
||||
bool operator==(ParIterator const & iter1, ParIterator const & iter2)
|
||||
{
|
||||
return iter1.pimpl_->positions == iter2.pimpl_->positions;
|
||||
}
|
||||
|
||||
|
||||
bool operator!=(ParIterator const & iter1, ParIterator const & iter2)
|
||||
{
|
||||
return !(iter1 == iter2);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// ParConstIterator
|
||||
///
|
||||
|
||||
|
||||
struct ParConstIterator::Pimpl {
|
||||
typedef stack<ParPosition> PosHolder;
|
||||
PosHolder positions;
|
||||
};
|
||||
|
||||
|
||||
ParConstIterator::ParConstIterator(ParagraphList::iterator pit,
|
||||
ParagraphList const & pl)
|
||||
: pimpl_(new Pimpl)
|
||||
{
|
||||
pimpl_->positions.push(ParPosition(pit, pl));
|
||||
}
|
||||
|
||||
|
||||
ParConstIterator::~ParConstIterator()
|
||||
{}
|
||||
|
||||
|
||||
ParConstIterator::ParConstIterator(ParConstIterator const & pi)
|
||||
: pimpl_(new Pimpl(*pi.pimpl_))
|
||||
{}
|
||||
|
||||
|
||||
ParConstIterator & ParConstIterator::operator++()
|
||||
{
|
||||
while (!positions.empty()) {
|
||||
ParPosition & p = positions.top();
|
||||
while (!pimpl_->positions.empty()) {
|
||||
ParPosition & p = pimpl_->positions.top();
|
||||
|
||||
// Does the current inset contain more "cells" ?
|
||||
if (p.index >= 0) {
|
||||
++p.index;
|
||||
ParagraphList * plist = p.it.getInset()->getParagraphs(p.index);
|
||||
if (p.index) {
|
||||
++(*p.index);
|
||||
ParagraphList * plist = p.it->getInset()->getParagraphs(*p.index);
|
||||
if (plist && !plist->empty()) {
|
||||
positions.push(ParPosition(&plist->front()));
|
||||
pimpl_->positions.push(ParPosition(plist->begin(), *plist));
|
||||
return *this;
|
||||
}
|
||||
++p.it;
|
||||
++(*p.it);
|
||||
} else
|
||||
// The following line is needed because the value of
|
||||
// p.it may be invalid if inset was added/removed to
|
||||
// the paragraph pointed by the iterator
|
||||
p.it = p.par->insetlist.begin();
|
||||
p.it.reset(p.pit->insetlist.begin());
|
||||
|
||||
// Try to find the next inset that contains paragraphs
|
||||
InsetList::iterator end = p.par->insetlist.end();
|
||||
for (; p.it != end; ++p.it) {
|
||||
ParagraphList * plist = p.it.getInset()->getParagraphs(0);
|
||||
InsetList::iterator end = p.pit->insetlist.end();
|
||||
for (; *p.it != end; ++(*p.it)) {
|
||||
ParagraphList * plist = p.it->getInset()->getParagraphs(0);
|
||||
if (plist && !plist->empty()) {
|
||||
p.index = 0;
|
||||
positions.push(ParPosition(&plist->front()));
|
||||
p.index.reset(0);
|
||||
pimpl_->positions.push(ParPosition(plist->begin(), *plist));
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to go to the next paragarph
|
||||
if (p.par->next()) {
|
||||
p = ParPosition(p.par->next());
|
||||
if (next(p.pit) != p.plist->end()
|
||||
|| pimpl_->positions.size() == 1) {
|
||||
++p.pit;
|
||||
p.index.reset();
|
||||
p.it.reset();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
positions.pop();
|
||||
// Drop end and move up in the stack.
|
||||
pimpl_->positions.pop();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
ParagraphList::iterator ParConstIterator::operator*()
|
||||
{
|
||||
return pimpl_->positions.top().pit;
|
||||
}
|
||||
|
||||
|
||||
ParagraphList::iterator ParConstIterator::operator->()
|
||||
{
|
||||
return pimpl_->positions.top().pit;
|
||||
}
|
||||
|
||||
|
||||
size_t ParConstIterator::size() const
|
||||
{
|
||||
return pimpl_->positions.size();
|
||||
}
|
||||
|
||||
|
||||
bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
|
||||
{
|
||||
return iter1.pimpl_->positions == iter2.pimpl_->positions;
|
||||
}
|
||||
|
||||
|
||||
bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
|
||||
{
|
||||
return !(iter1 == iter2);
|
||||
}
|
||||
|
112
src/iterators.h
112
src/iterators.h
@ -1,119 +1,83 @@
|
||||
// -*- C++ -*-
|
||||
/* \file iterators.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author unknown
|
||||
* \author Lars Gullik Bjønnes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS
|
||||
*/
|
||||
|
||||
#ifndef ITERATORS_H
|
||||
#define ITERATORS_H
|
||||
|
||||
#include <stack>
|
||||
|
||||
#include "paragraph.h"
|
||||
|
||||
class ParPosition {
|
||||
public:
|
||||
ParPosition(Paragraph * p)
|
||||
: par(p), it(p->insetlist.begin()), index(-1) {}
|
||||
///
|
||||
Paragraph * par;
|
||||
///
|
||||
InsetList::iterator it;
|
||||
///
|
||||
int index;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
bool operator==(ParPosition const & pos1, ParPosition const & pos2) {
|
||||
return pos1.par == pos2.par &&
|
||||
pos1.it == pos2.it &&
|
||||
pos1.index == pos2.index;
|
||||
}
|
||||
|
||||
inline
|
||||
bool operator!=(ParPosition const & pos1, ParPosition const & pos2) {
|
||||
return !(pos1 == pos2);
|
||||
}
|
||||
#include "ParagraphList.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
class ParIterator {
|
||||
public:
|
||||
///
|
||||
typedef std::stack<ParPosition> PosHolder;
|
||||
ParIterator(ParagraphList::iterator pit, ParagraphList const & pl);
|
||||
///
|
||||
ParIterator() {}
|
||||
~ParIterator();
|
||||
///
|
||||
ParIterator(Paragraph * par) {
|
||||
positions.push(ParPosition(par));
|
||||
}
|
||||
ParIterator(ParIterator const &);
|
||||
///
|
||||
ParIterator & operator++();
|
||||
///
|
||||
Paragraph * operator*() {
|
||||
return positions.top().par;
|
||||
}
|
||||
ParagraphList::iterator operator*();
|
||||
///
|
||||
PosHolder::size_type size() const
|
||||
{ return positions.size(); }
|
||||
ParagraphList::iterator operator->();
|
||||
///
|
||||
size_t size() const;
|
||||
///
|
||||
friend
|
||||
bool operator==(ParIterator const & iter1, ParIterator const & iter2);
|
||||
private:
|
||||
///
|
||||
PosHolder positions;
|
||||
struct Pimpl;
|
||||
boost::scoped_ptr<Pimpl> pimpl_;
|
||||
};
|
||||
|
||||
///
|
||||
bool operator==(ParIterator const & iter1, ParIterator const & iter2);
|
||||
|
||||
///
|
||||
inline
|
||||
bool operator==(ParIterator const & iter1, ParIterator const & iter2) {
|
||||
return iter1.positions == iter2.positions;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
inline
|
||||
bool operator!=(ParIterator const & iter1, ParIterator const & iter2) {
|
||||
return !(iter1 == iter2);
|
||||
}
|
||||
bool operator!=(ParIterator const & iter1, ParIterator const & iter2);
|
||||
|
||||
|
||||
class ParConstIterator {
|
||||
public:
|
||||
///
|
||||
typedef std::stack<ParPosition> PosHolder;
|
||||
ParConstIterator(ParagraphList::iterator pit, ParagraphList const & pl);
|
||||
///
|
||||
ParConstIterator() {}
|
||||
~ParConstIterator();
|
||||
///
|
||||
ParConstIterator(Paragraph * par) {
|
||||
positions.push(ParPosition(par));
|
||||
}
|
||||
ParConstIterator(ParConstIterator const &);
|
||||
///
|
||||
ParConstIterator & operator++();
|
||||
///
|
||||
Paragraph const * operator*() {
|
||||
return positions.top().par;
|
||||
}
|
||||
ParagraphList::iterator operator*();
|
||||
|
||||
///
|
||||
PosHolder::size_type size() const
|
||||
{ return positions.size(); }
|
||||
ParagraphList::iterator operator->();
|
||||
|
||||
///
|
||||
size_t size() const;
|
||||
///
|
||||
friend
|
||||
bool operator==(ParConstIterator const & iter1,
|
||||
ParConstIterator const & iter2);
|
||||
private:
|
||||
///
|
||||
PosHolder positions;
|
||||
struct Pimpl;
|
||||
boost::scoped_ptr<Pimpl> pimpl_;
|
||||
};
|
||||
|
||||
bool operator==(ParConstIterator const & iter1,
|
||||
ParConstIterator const & iter2);
|
||||
|
||||
///
|
||||
inline
|
||||
bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2) {
|
||||
return iter1.positions == iter2.positions;
|
||||
}
|
||||
|
||||
///
|
||||
inline
|
||||
bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2) {
|
||||
return !(iter1 == iter2);
|
||||
}
|
||||
bool operator!=(ParConstIterator const & iter1,
|
||||
ParConstIterator const & iter2);
|
||||
|
||||
#endif
|
||||
|
@ -1409,7 +1409,7 @@ MathCursorPos MathCursor::normalAnchor() const
|
||||
|
||||
dispatch_result MathCursor::dispatch(FuncRequest const & cmd)
|
||||
{
|
||||
// mouse clicks are somewhat special
|
||||
// mouse clicks are somewhat special
|
||||
// check
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
|
@ -617,7 +617,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
|
||||
|
||||
if (flags & FLAG_ITEM) {
|
||||
|
||||
if (t.cat() == catBegin) {
|
||||
if (t.cat() == catBegin) {
|
||||
// skip the brace and collect everything to the next matching
|
||||
// closing brace
|
||||
parse1(grid, FLAG_BRACE_LAST, mode, numbered);
|
||||
|
12
src/toc.C
12
src/toc.C
@ -78,26 +78,24 @@ TocList const getTocList(Buffer const * buf)
|
||||
ParConstIterator pit = buf->par_iterator_begin();
|
||||
ParConstIterator end = buf->par_iterator_end();
|
||||
for (; pit != end; ++pit) {
|
||||
Paragraph const * par = *pit;
|
||||
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning bogus type (Lgb)
|
||||
#endif
|
||||
char const labeltype = par->layout()->labeltype;
|
||||
char const labeltype = pit->layout()->labeltype;
|
||||
|
||||
if (labeltype >= LABEL_COUNTER_CHAPTER
|
||||
&& labeltype <= LABEL_COUNTER_CHAPTER + buf->params.tocdepth) {
|
||||
// insert this into the table of contents
|
||||
const int depth = max(0, labeltype - textclass.maxcounter());
|
||||
TocItem const item(par->id(), depth,
|
||||
par->asString(buf, true));
|
||||
TocItem const item(pit->id(), depth,
|
||||
pit->asString(buf, true));
|
||||
toclist["TOC"].push_back(item);
|
||||
}
|
||||
|
||||
// For each paragraph, traverse its insets and look for
|
||||
// FLOAT_CODE or WRAP_CODE
|
||||
InsetList::iterator it = par->insetlist.begin();
|
||||
InsetList::iterator end = par->insetlist.end();
|
||||
InsetList::iterator it = pit->insetlist.begin();
|
||||
InsetList::iterator end = pit->insetlist.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it.getInset()->lyxCode() == Inset::FLOAT_CODE) {
|
||||
InsetFloat * il =
|
||||
|
Loading…
Reference in New Issue
Block a user