mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
Revert "Get rid of lyx::next uses for RandomAccessList"
This is not ready (see #11861).
This reverts commit 6d97e39934
.
This commit is contained in:
parent
2663e3845e
commit
c756749991
@ -439,8 +439,8 @@ static void getParagraphList(DocRange const & range,
|
||||
pit_type startpit = range.from.pit();
|
||||
pit_type endpit = range.to.pit();
|
||||
ParagraphList const & ps_ = range.text()->paragraphs();
|
||||
ParagraphList tmp_pars(ps_.iterator_at(startpit),
|
||||
ps_.iterator_at(endpit + 1));
|
||||
ParagraphList tmp_pars(lyx::next(ps_.begin(), startpit),
|
||||
lyx::next(ps_.begin(), endpit + 1));
|
||||
|
||||
// Remove the end of the last paragraph; afterwards, remove the
|
||||
// beginning of the first paragraph. Keep this order - there may only
|
||||
|
@ -462,15 +462,17 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
||||
|
||||
// Paste it!
|
||||
if (empty) {
|
||||
pars.insert(pars.iterator_at(pit),
|
||||
insertion.begin(), insertion.end());
|
||||
pars.insert(lyx::next(pars.begin(), pit),
|
||||
insertion.begin(),
|
||||
insertion.end());
|
||||
|
||||
// merge the empty par with the last par of the insertion
|
||||
mergeParagraph(buffer.params(), pars,
|
||||
pit + insertion.size() - 1);
|
||||
} else {
|
||||
pars.insert(pars.iterator_at(pit + 1),
|
||||
insertion.begin(), insertion.end());
|
||||
pars.insert(lyx::next(pars.begin(), pit + 1),
|
||||
insertion.begin(),
|
||||
insertion.end());
|
||||
|
||||
// merge the first par of the insertion with the current par
|
||||
mergeParagraph(buffer.params(), pars, pit);
|
||||
@ -681,8 +683,8 @@ void copySelectionHelper(Buffer const & buf, Text const & text,
|
||||
LASSERT(startpit != endpit || start <= end, return);
|
||||
|
||||
// Clone the paragraphs within the selection.
|
||||
ParagraphList copy_pars(pars.iterator_at(startpit),
|
||||
pars.iterator_at(endpit + 1));
|
||||
ParagraphList copy_pars(lyx::next(pars.begin(), startpit),
|
||||
lyx::next(pars.begin(), endpit + 1));
|
||||
|
||||
// Remove the end of the last paragraph; afterwards, remove the
|
||||
// beginning of the first paragraph. Keep this order - there may only
|
||||
|
12
src/Text.cpp
12
src/Text.cpp
@ -113,7 +113,8 @@ void breakParagraphConservative(BufferParams const & bparams,
|
||||
ParagraphList & pars, pit_type pit, pos_type pos)
|
||||
{
|
||||
// create a new paragraph
|
||||
Paragraph & tmp = *pars.insert(pars.iterator_at(pit + 1), Paragraph());
|
||||
Paragraph & tmp = *pars.insert(lyx::next(pars.begin(), pit + 1),
|
||||
Paragraph());
|
||||
Paragraph & par = pars[pit];
|
||||
|
||||
tmp.setInsetOwner(&par.inInset());
|
||||
@ -168,7 +169,7 @@ void mergeParagraph(BufferParams const & bparams,
|
||||
// move the change of the end-of-paragraph character
|
||||
par.setChange(par.size(), change);
|
||||
|
||||
pars.erase(pars.iterator_at(par_offset + 1));
|
||||
pars.erase(lyx::next(pars.begin(), par_offset + 1));
|
||||
}
|
||||
|
||||
|
||||
@ -690,7 +691,8 @@ static void breakParagraph(Text & text, pit_type par_offset, pos_type pos,
|
||||
ParagraphList & pars = text.paragraphs();
|
||||
// create a new paragraph, and insert into the list
|
||||
ParagraphList::iterator tmp =
|
||||
pars.insert(pars.iterator_at(par_offset + 1), Paragraph());
|
||||
pars.insert(lyx::next(pars.begin(), par_offset + 1),
|
||||
Paragraph());
|
||||
|
||||
Paragraph & par = pars[par_offset];
|
||||
|
||||
@ -1699,14 +1701,14 @@ bool Text::backspacePos0(Cursor & cur)
|
||||
if (cur.lastpos() == 0
|
||||
|| (cur.lastpos() == 1 && par.isSeparator(0))) {
|
||||
cur.recordUndo(prevcur.pit());
|
||||
plist.erase(plist.iterator_at(cur.pit()));
|
||||
plist.erase(lyx::next(plist.begin(), cur.pit()));
|
||||
needsUpdate = true;
|
||||
}
|
||||
// is previous par empty?
|
||||
else if (prevcur.lastpos() == 0
|
||||
|| (prevcur.lastpos() == 1 && prevpar.isSeparator(0))) {
|
||||
cur.recordUndo(prevcur.pit());
|
||||
plist.erase(plist.iterator_at(prevcur.pit()));
|
||||
plist.erase(lyx::next(plist.begin(), prevcur.pit()));
|
||||
needsUpdate = true;
|
||||
}
|
||||
// FIXME: Do we really not want to allow this???
|
||||
|
@ -917,7 +917,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
|
||||
min(old.pit() + 1, old.lastpit()));
|
||||
ParagraphList & plist = old.text()->paragraphs();
|
||||
bool const soa = oldpar.params().startOfAppendix();
|
||||
plist.erase(plist.iterator_at(old.pit()));
|
||||
plist.erase(lyx::next(plist.begin(), old.pit()));
|
||||
// do not lose start of appendix marker (bug 4212)
|
||||
if (soa && old.pit() < pit_type(plist.size()))
|
||||
plist[old.pit()].params().startOfAppendix(true);
|
||||
@ -989,7 +989,7 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool tra
|
||||
continue;
|
||||
|
||||
if (par.empty() || (par.size() == 1 && par.isLineSeparator(0))) {
|
||||
pars_.erase(pars_.iterator_at(pit));
|
||||
pars_.erase(lyx::next(pars_.begin(), pit));
|
||||
--pit;
|
||||
--last;
|
||||
continue;
|
||||
|
@ -384,7 +384,7 @@ static void outline(OutlineOp mode, Cursor & cur, Text * text)
|
||||
ParagraphList & pars = buf.text().paragraphs();
|
||||
ParagraphList::iterator const bgn = pars.begin();
|
||||
// The first paragraph of the area to be copied:
|
||||
ParagraphList::iterator start = pars.iterator_at(pit);
|
||||
ParagraphList::iterator start = lyx::next(bgn, pit);
|
||||
// The final paragraph of area to be copied:
|
||||
ParagraphList::iterator finish = start;
|
||||
ParagraphList::iterator const end = pars.end();
|
||||
@ -962,7 +962,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
ParagraphList & pars = buf.text().paragraphs();
|
||||
ParagraphList::iterator bgn = pars.begin();
|
||||
// The first paragraph of the area to be selected:
|
||||
ParagraphList::iterator start = pars.iterator_at(pit);
|
||||
ParagraphList::iterator start = lyx::next(bgn, pit);
|
||||
// The final paragraph of area to be selected:
|
||||
ParagraphList::iterator finish = start;
|
||||
ParagraphList::iterator end = pars.end();
|
||||
|
@ -329,8 +329,8 @@ void docbookParagraphs(Text const & text,
|
||||
|
||||
// if only part of the paragraphs will be outputed
|
||||
if (runparams.par_begin != runparams.par_end) {
|
||||
par = paragraphs.iterator_at(runparams.par_begin);
|
||||
pend = paragraphs.iterator_at(runparams.par_end);
|
||||
par = lyx::next(paragraphs.begin(), runparams.par_begin);
|
||||
pend = lyx::next(paragraphs.begin(), runparams.par_end);
|
||||
// runparams will be passed to nested paragraphs, so
|
||||
// we have to reset the range parameters.
|
||||
const_cast<OutputParams&>(runparams).par_begin = 0;
|
||||
|
@ -383,7 +383,7 @@ void TeXEnvironment(Buffer const & buf, Text const & text,
|
||||
pit_type & pit, otexstream & os)
|
||||
{
|
||||
ParagraphList const & paragraphs = text.paragraphs();
|
||||
ParagraphList::const_iterator ipar = paragraphs.iterator_at(pit);
|
||||
ParagraphList::const_iterator ipar = paragraphs.constIterator(pit);
|
||||
LYXERR(Debug::LATEX, "TeXEnvironment for paragraph " << pit);
|
||||
|
||||
Layout const & current_layout = ipar->layout();
|
||||
@ -393,7 +393,7 @@ void TeXEnvironment(Buffer const & buf, Text const & text,
|
||||
// This is for debugging purpose at the end.
|
||||
pit_type const par_begin = pit;
|
||||
for (; pit < runparams.par_end; ++pit) {
|
||||
ParagraphList::const_iterator par = paragraphs.iterator_at(pit);
|
||||
ParagraphList::const_iterator par = paragraphs.constIterator(pit);
|
||||
|
||||
// check first if this is an higher depth paragraph.
|
||||
bool go_out = (par->params().depth() < current_depth);
|
||||
@ -437,7 +437,7 @@ void TeXEnvironment(Buffer const & buf, Text const & text,
|
||||
// Do not output empty environments if the whole paragraph has
|
||||
// been deleted with ct and changes are not output.
|
||||
if (size_t(pit + 1) < paragraphs.size()) {
|
||||
ParagraphList::const_iterator nextpar = paragraphs.iterator_at(pit + 1);
|
||||
ParagraphList::const_iterator nextpar = paragraphs.constIterator(pit + 1);
|
||||
Paragraph const & cpar = paragraphs.at(pit);
|
||||
if ((par->layout() != nextpar->layout()
|
||||
|| par->params().depth() == nextpar->params().depth()
|
||||
@ -643,11 +643,11 @@ void latexArgInsets(ParagraphList const & pars,
|
||||
Layout const current_layout = pit->layout();
|
||||
|
||||
// get the first paragraph in sequence with this layout and depth
|
||||
ptrdiff_t offset = 0;
|
||||
pit_type offset = 0;
|
||||
while (true) {
|
||||
if (prev(pit, offset) == pars.begin())
|
||||
if (lyx::prev(pit, offset) == pars.begin())
|
||||
break;
|
||||
ParagraphList::const_iterator priorpit = prev(pit, offset + 1);
|
||||
ParagraphList::const_iterator priorpit = lyx::prev(pit, offset + 1);
|
||||
if (priorpit->layout() == current_layout
|
||||
&& priorpit->params().depth() == current_depth)
|
||||
++offset;
|
||||
@ -655,7 +655,7 @@ void latexArgInsets(ParagraphList const & pars,
|
||||
break;
|
||||
}
|
||||
|
||||
ParagraphList::const_iterator spit = prev(pit, offset);
|
||||
ParagraphList::const_iterator spit = lyx::prev(pit, offset);
|
||||
|
||||
for (; spit != pars.end(); ++spit) {
|
||||
if (spit->layout() != current_layout ||
|
||||
@ -1601,7 +1601,7 @@ void latexParagraphs(Buffer const & buf,
|
||||
bool gave_layout_warning = false;
|
||||
for (; pit < runparams.par_end; ++pit) {
|
||||
lastpit = pit;
|
||||
ParagraphList::const_iterator par = paragraphs.iterator_at(pit);
|
||||
ParagraphList::const_iterator par = paragraphs.constIterator(pit);
|
||||
|
||||
// FIXME This check should not be needed. We should
|
||||
// perhaps issue an error if it is.
|
||||
@ -1660,7 +1660,7 @@ void latexParagraphs(Buffer const & buf,
|
||||
// Do not output empty environments if the whole paragraph has
|
||||
// been deleted with ct and changes are not output.
|
||||
if (size_t(pit + 1) < paragraphs.size()) {
|
||||
ParagraphList::const_iterator nextpar = paragraphs.iterator_at(pit + 1);
|
||||
ParagraphList::const_iterator nextpar = paragraphs.constIterator(pit + 1);
|
||||
Paragraph const & cpar = paragraphs.at(pit);
|
||||
if ((par->layout() != nextpar->layout()
|
||||
|| par->params().depth() == nextpar->params().depth()
|
||||
|
@ -1156,9 +1156,9 @@ void xhtmlParagraphs(Text const & text,
|
||||
OutputParams ourparams = runparams;
|
||||
ParagraphList::const_iterator const pend =
|
||||
(epit == (int) paragraphs.size()) ?
|
||||
paragraphs.end() : paragraphs.iterator_at(epit);
|
||||
paragraphs.end() : paragraphs.constIterator(epit);
|
||||
while (bpit < epit) {
|
||||
ParagraphList::const_iterator par = paragraphs.iterator_at(bpit);
|
||||
ParagraphList::const_iterator par = paragraphs.constIterator(bpit);
|
||||
if (par->params().startOfAppendix()) {
|
||||
// We want to reset the counter corresponding to toplevel sectioning
|
||||
Layout const & lay =
|
||||
|
@ -294,12 +294,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
const_iterator iterator_at(size_t i) const
|
||||
{
|
||||
return iterCont_[i];
|
||||
}
|
||||
|
||||
iterator iterator_at(size_t i)
|
||||
const_iterator constIterator(size_t i) const
|
||||
{
|
||||
return iterCont_[i];
|
||||
}
|
||||
|
@ -84,6 +84,11 @@ void eliminate_duplicates(C & c)
|
||||
}
|
||||
|
||||
|
||||
using std::next;
|
||||
|
||||
|
||||
using std::prev;
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif // LYX_ALGO_H
|
||||
|
Loading…
Reference in New Issue
Block a user