mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 02:49:46 +00:00
Make InsetIterator compatible with range-based loops
This commit is contained in:
parent
813eb0f9f7
commit
ad7c5568cd
@ -1275,9 +1275,9 @@ void Buffer::updatePreviews() const
|
|||||||
if (!ploader)
|
if (!ploader)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
InsetIterator it = inset_iterator_begin(*d->inset);
|
InsetIterator it = begin(*d->inset);
|
||||||
InsetIterator const end = inset_iterator_end(*d->inset);
|
InsetIterator const itend = end(*d->inset);
|
||||||
for (; it != end; ++it)
|
for (; it != itend; ++it)
|
||||||
it->addPreview(it, *ploader);
|
it->addPreview(it, *ploader);
|
||||||
|
|
||||||
ploader->startLoading();
|
ploader->startLoading();
|
||||||
@ -2581,7 +2581,7 @@ void Buffer::collectBibKeys(FileNameList & checkedFiles) const
|
|||||||
if (!parent())
|
if (!parent())
|
||||||
clearIncludeList();
|
clearIncludeList();
|
||||||
|
|
||||||
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
|
for (InsetIterator it = begin(inset()); it; ++it) {
|
||||||
it->collectBibKeys(it, checkedFiles);
|
it->collectBibKeys(it, checkedFiles);
|
||||||
if (it->lyxCode() == BIBITEM_CODE) {
|
if (it->lyxCode() == BIBITEM_CODE) {
|
||||||
if (parent() != nullptr)
|
if (parent() != nullptr)
|
||||||
@ -2959,10 +2959,10 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
|||||||
|
|
||||||
docstring const oldname = from_utf8(func.getArg(0));
|
docstring const oldname = from_utf8(func.getArg(0));
|
||||||
docstring const newname = from_utf8(func.getArg(1));
|
docstring const newname = from_utf8(func.getArg(1));
|
||||||
InsetIterator it = inset_iterator_begin(inset());
|
InsetIterator it = begin(inset());
|
||||||
InsetIterator const end = inset_iterator_end(inset());
|
InsetIterator const itend = end(inset());
|
||||||
bool success = false;
|
bool success = false;
|
||||||
for (; it != end; ++it) {
|
for (; it != itend; ++it) {
|
||||||
if (it->lyxCode() == BRANCH_CODE) {
|
if (it->lyxCode() == BRANCH_CODE) {
|
||||||
InsetBranch & ins = static_cast<InsetBranch &>(*it);
|
InsetBranch & ins = static_cast<InsetBranch &>(*it);
|
||||||
if (ins.branch() == oldname) {
|
if (ins.branch() == oldname) {
|
||||||
@ -3841,11 +3841,9 @@ void Buffer::updateMacros() const
|
|||||||
|
|
||||||
void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_master) const
|
void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_master) const
|
||||||
{
|
{
|
||||||
InsetIterator it = inset_iterator_begin(inset());
|
for (Inset const & it : inset()) {
|
||||||
InsetIterator const end = inset_iterator_end(inset());
|
if (it.lyxCode() == BRANCH_CODE) {
|
||||||
for (; it != end; ++it) {
|
InsetBranch const & br = static_cast<InsetBranch const &>(it);
|
||||||
if (it->lyxCode() == BRANCH_CODE) {
|
|
||||||
InsetBranch & br = static_cast<InsetBranch &>(*it);
|
|
||||||
docstring const name = br.branch();
|
docstring const name = br.branch();
|
||||||
if (!from_master && !params().branchlist().find(name))
|
if (!from_master && !params().branchlist().find(name))
|
||||||
result.push_back(name);
|
result.push_back(name);
|
||||||
@ -3853,10 +3851,10 @@ void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_mast
|
|||||||
result.push_back(name);
|
result.push_back(name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it->lyxCode() == INCLUDE_CODE) {
|
if (it.lyxCode() == INCLUDE_CODE) {
|
||||||
// get buffer of external file
|
// get buffer of external file
|
||||||
InsetInclude const & ins =
|
InsetInclude const & ins =
|
||||||
static_cast<InsetInclude const &>(*it);
|
static_cast<InsetInclude const &>(it);
|
||||||
Buffer * child = ins.loadIfNeeded();
|
Buffer * child = ins.loadIfNeeded();
|
||||||
if (!child)
|
if (!child)
|
||||||
continue;
|
continue;
|
||||||
@ -4027,7 +4025,7 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
|
|||||||
|
|
||||||
string const paramName = "key";
|
string const paramName = "key";
|
||||||
UndoGroupHelper ugh(this);
|
UndoGroupHelper ugh(this);
|
||||||
InsetIterator it = inset_iterator_begin(inset());
|
InsetIterator it = begin(inset());
|
||||||
for (; it; ++it) {
|
for (; it; ++it) {
|
||||||
if (it->lyxCode() != CITE_CODE)
|
if (it->lyxCode() != CITE_CODE)
|
||||||
continue;
|
continue;
|
||||||
|
@ -35,11 +35,8 @@ void BufferEncodings::initUnicodeMath(Buffer const & buffer, bool for_master)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check this buffer
|
// Check this buffer
|
||||||
Inset & inset = buffer.inset();
|
for (Inset const & it : buffer.inset())
|
||||||
InsetIterator it = inset_iterator_begin(inset);
|
it.initUnicodeMath();
|
||||||
InsetIterator const end = inset_iterator_end(inset);
|
|
||||||
for (; it != end; ++it)
|
|
||||||
it->initUnicodeMath();
|
|
||||||
|
|
||||||
if (!for_master)
|
if (!for_master)
|
||||||
return;
|
return;
|
||||||
|
@ -292,8 +292,8 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
|||||||
// Prepare the paragraphs and insets for insertion.
|
// Prepare the paragraphs and insets for insertion.
|
||||||
insertion.swap(in.paragraphs());
|
insertion.swap(in.paragraphs());
|
||||||
|
|
||||||
InsetIterator const i_end = inset_iterator_end(in);
|
InsetIterator const i_end = end(in);
|
||||||
for (InsetIterator it = inset_iterator_begin(in); it != i_end; ++it) {
|
for (InsetIterator it = begin(in); it != i_end; ++it) {
|
||||||
// Even though this will also be done later, it has to be done here
|
// Even though this will also be done later, it has to be done here
|
||||||
// since some inset might try to access the buffer() member.
|
// since some inset might try to access the buffer() member.
|
||||||
it->setBuffer(const_cast<Buffer &>(buffer));
|
it->setBuffer(const_cast<Buffer &>(buffer));
|
||||||
@ -315,7 +315,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
|||||||
if (oldname == newname)
|
if (oldname == newname)
|
||||||
continue;
|
continue;
|
||||||
// adapt the references
|
// adapt the references
|
||||||
for (InsetIterator itt = inset_iterator_begin(in);
|
for (InsetIterator itt = begin(in);
|
||||||
itt != i_end; ++itt) {
|
itt != i_end; ++itt) {
|
||||||
if (itt->lyxCode() == REF_CODE) {
|
if (itt->lyxCode() == REF_CODE) {
|
||||||
InsetCommand * ref = itt->asInsetCommand();
|
InsetCommand * ref = itt->asInsetCommand();
|
||||||
@ -346,7 +346,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
|||||||
if (oldname == newname)
|
if (oldname == newname)
|
||||||
break;
|
break;
|
||||||
// adapt the references
|
// adapt the references
|
||||||
for (InsetIterator itt = inset_iterator_begin(in); itt != i_end; ++itt) {
|
for (InsetIterator itt = begin(in); itt != i_end; ++itt) {
|
||||||
if (itt->lyxCode() == REF_CODE) {
|
if (itt->lyxCode() == REF_CODE) {
|
||||||
InsetCommand & ref = static_cast<InsetCommand &>(*itt);
|
InsetCommand & ref = static_cast<InsetCommand &>(*itt);
|
||||||
if (ref.getParam("reference") == oldname)
|
if (ref.getParam("reference") == oldname)
|
||||||
@ -393,7 +393,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
|||||||
if (oldkey == newkey)
|
if (oldkey == newkey)
|
||||||
break;
|
break;
|
||||||
// adapt the references
|
// adapt the references
|
||||||
for (InsetIterator itt = inset_iterator_begin(in);
|
for (InsetIterator itt = begin(in);
|
||||||
itt != i_end; ++itt) {
|
itt != i_end; ++itt) {
|
||||||
if (itt->lyxCode() == CITE_CODE) {
|
if (itt->lyxCode() == CITE_CODE) {
|
||||||
InsetCommand * ref = itt->asInsetCommand();
|
InsetCommand * ref = itt->asInsetCommand();
|
||||||
@ -806,10 +806,10 @@ void switchBetweenClasses(DocumentClassConstPtr oldone,
|
|||||||
|
|
||||||
// layouts
|
// layouts
|
||||||
ParIterator it = par_iterator_begin(in);
|
ParIterator it = par_iterator_begin(in);
|
||||||
ParIterator end = par_iterator_end(in);
|
ParIterator pend = par_iterator_end(in);
|
||||||
// for remembering which layouts we've had to add
|
// for remembering which layouts we've had to add
|
||||||
set<docstring> newlayouts;
|
set<docstring> newlayouts;
|
||||||
for (; it != end; ++it) {
|
for (; it != pend; ++it) {
|
||||||
docstring const name = it->layout().name();
|
docstring const name = it->layout().name();
|
||||||
|
|
||||||
// the pasted text will keep their own layout name. If this layout does
|
// the pasted text will keep their own layout name. If this layout does
|
||||||
@ -832,8 +832,8 @@ void switchBetweenClasses(DocumentClassConstPtr oldone,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// character styles and hidden table cells
|
// character styles and hidden table cells
|
||||||
InsetIterator const i_end = inset_iterator_end(in);
|
InsetIterator const i_end = end(in);
|
||||||
for (InsetIterator iit = inset_iterator_begin(in); iit != i_end; ++iit) {
|
for (InsetIterator iit = begin(in); iit != i_end; ++iit) {
|
||||||
InsetCode const code = iit->lyxCode();
|
InsetCode const code = iit->lyxCode();
|
||||||
if (code == FLEX_CODE) {
|
if (code == FLEX_CODE) {
|
||||||
// FIXME: Should we verify all InsetCollapsible?
|
// FIXME: Should we verify all InsetCollapsible?
|
||||||
|
@ -25,7 +25,7 @@ InsetIterator::InsetIterator(Inset & inset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetIterator inset_iterator_begin(Inset & inset)
|
InsetIterator begin(Inset & inset)
|
||||||
{
|
{
|
||||||
InsetIterator it = InsetIterator(inset);
|
InsetIterator it = InsetIterator(inset);
|
||||||
it.forwardInset();
|
it.forwardInset();
|
||||||
@ -33,7 +33,7 @@ InsetIterator inset_iterator_begin(Inset & inset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetIterator inset_iterator_end(Inset & inset)
|
InsetIterator end(Inset & inset)
|
||||||
{
|
{
|
||||||
return InsetIterator(inset);
|
return InsetIterator(inset);
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,9 @@ public:
|
|||||||
Inset & operator*() { return *nextInset(); }
|
Inset & operator*() { return *nextInset(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
InsetIterator inset_iterator_begin(Inset & inset);
|
InsetIterator begin(Inset & inset);
|
||||||
|
|
||||||
InsetIterator inset_iterator_end(Inset & inset);
|
InsetIterator end(Inset & inset);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1189,11 +1189,8 @@ namespace graphics {
|
|||||||
|
|
||||||
void getGraphicsGroups(Buffer const & b, set<string> & ids)
|
void getGraphicsGroups(Buffer const & b, set<string> & ids)
|
||||||
{
|
{
|
||||||
Inset & inset = b.inset();
|
for (Inset const & it : b.inset()) {
|
||||||
InsetIterator it = inset_iterator_begin(inset);
|
InsetGraphics const * ins = it.asInsetGraphics();
|
||||||
InsetIterator const end = inset_iterator_end(inset);
|
|
||||||
for (; it != end; ++it) {
|
|
||||||
InsetGraphics const * ins = it->asInsetGraphics();
|
|
||||||
if (!ins)
|
if (!ins)
|
||||||
continue;
|
continue;
|
||||||
InsetGraphicsParams const & inspar = ins->getParams();
|
InsetGraphicsParams const & inspar = ins->getParams();
|
||||||
@ -1208,11 +1205,8 @@ int countGroupMembers(Buffer const & b, string const & groupId)
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
if (groupId.empty())
|
if (groupId.empty())
|
||||||
return n;
|
return n;
|
||||||
Inset & inset = b.inset();
|
for (Inset const & it : b.inset()) {
|
||||||
InsetIterator it = inset_iterator_begin(inset);
|
InsetGraphics const * ins = it.asInsetGraphics();
|
||||||
InsetIterator const end = inset_iterator_end(inset);
|
|
||||||
for (; it != end; ++it) {
|
|
||||||
InsetGraphics const * ins = it->asInsetGraphics();
|
|
||||||
if (!ins)
|
if (!ins)
|
||||||
continue;
|
continue;
|
||||||
if (ins->getParams().groupId == groupId)
|
if (ins->getParams().groupId == groupId)
|
||||||
@ -1226,11 +1220,8 @@ string getGroupParams(Buffer const & b, string const & groupId)
|
|||||||
{
|
{
|
||||||
if (groupId.empty())
|
if (groupId.empty())
|
||||||
return string();
|
return string();
|
||||||
Inset & inset = b.inset();
|
for (Inset const & it : b.inset()) {
|
||||||
InsetIterator it = inset_iterator_begin(inset);
|
InsetGraphics const * ins = it.asInsetGraphics();
|
||||||
InsetIterator const end = inset_iterator_end(inset);
|
|
||||||
for (; it != end; ++it) {
|
|
||||||
InsetGraphics const * ins = it->asInsetGraphics();
|
|
||||||
if (!ins)
|
if (!ins)
|
||||||
continue;
|
continue;
|
||||||
InsetGraphicsParams const & inspar = ins->getParams();
|
InsetGraphicsParams const & inspar = ins->getParams();
|
||||||
@ -1252,9 +1243,9 @@ void unifyGraphicsGroups(Buffer & b, string const & argument)
|
|||||||
// This handles undo groups automagically
|
// This handles undo groups automagically
|
||||||
UndoGroupHelper ugh(&b);
|
UndoGroupHelper ugh(&b);
|
||||||
Inset & inset = b.inset();
|
Inset & inset = b.inset();
|
||||||
InsetIterator it = inset_iterator_begin(inset);
|
InsetIterator it = begin(inset);
|
||||||
InsetIterator const end = inset_iterator_end(inset);
|
InsetIterator const itend = end(inset);
|
||||||
for (; it != end; ++it) {
|
for (; it != itend; ++it) {
|
||||||
InsetGraphics * ins = it->asInsetGraphics();
|
InsetGraphics * ins = it->asInsetGraphics();
|
||||||
if (!ins)
|
if (!ins)
|
||||||
continue;
|
continue;
|
||||||
|
@ -3132,12 +3132,11 @@ void Tabular::TeXRow(otexstream & os, row_type row,
|
|||||||
} else if (ltCaption(row)) {
|
} else if (ltCaption(row)) {
|
||||||
// Inside longtable caption rows, we must only output the caption inset
|
// Inside longtable caption rows, we must only output the caption inset
|
||||||
// with its content and omit anything outside of that (see #10791)
|
// with its content and omit anything outside of that (see #10791)
|
||||||
InsetIterator it = inset_iterator_begin(*const_cast<InsetTableCell *>(inset));
|
InsetTableCell & tc_inset = *const_cast<InsetTableCell *>(inset);
|
||||||
InsetIterator i_end = inset_iterator_end(*const_cast<InsetTableCell *>(inset));
|
for (Inset const & it : tc_inset) {
|
||||||
for (; it != i_end; ++it) {
|
if (it.lyxCode() != CAPTION_CODE)
|
||||||
if (it->lyxCode() != CAPTION_CODE)
|
|
||||||
continue;
|
continue;
|
||||||
it->latex(os, runparams);
|
it.latex(os, runparams);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!isPartOfMultiRow(row, c)) {
|
} else if (!isPartOfMultiRow(row, c)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user