mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 20:45:47 +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)
|
||||
return;
|
||||
|
||||
InsetIterator it = inset_iterator_begin(*d->inset);
|
||||
InsetIterator const end = inset_iterator_end(*d->inset);
|
||||
for (; it != end; ++it)
|
||||
InsetIterator it = begin(*d->inset);
|
||||
InsetIterator const itend = end(*d->inset);
|
||||
for (; it != itend; ++it)
|
||||
it->addPreview(it, *ploader);
|
||||
|
||||
ploader->startLoading();
|
||||
@ -2581,7 +2581,7 @@ void Buffer::collectBibKeys(FileNameList & checkedFiles) const
|
||||
if (!parent())
|
||||
clearIncludeList();
|
||||
|
||||
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
|
||||
for (InsetIterator it = begin(inset()); it; ++it) {
|
||||
it->collectBibKeys(it, checkedFiles);
|
||||
if (it->lyxCode() == BIBITEM_CODE) {
|
||||
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 newname = from_utf8(func.getArg(1));
|
||||
InsetIterator it = inset_iterator_begin(inset());
|
||||
InsetIterator const end = inset_iterator_end(inset());
|
||||
InsetIterator it = begin(inset());
|
||||
InsetIterator const itend = end(inset());
|
||||
bool success = false;
|
||||
for (; it != end; ++it) {
|
||||
for (; it != itend; ++it) {
|
||||
if (it->lyxCode() == BRANCH_CODE) {
|
||||
InsetBranch & ins = static_cast<InsetBranch &>(*it);
|
||||
if (ins.branch() == oldname) {
|
||||
@ -3841,11 +3841,9 @@ void Buffer::updateMacros() const
|
||||
|
||||
void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_master) const
|
||||
{
|
||||
InsetIterator it = inset_iterator_begin(inset());
|
||||
InsetIterator const end = inset_iterator_end(inset());
|
||||
for (; it != end; ++it) {
|
||||
if (it->lyxCode() == BRANCH_CODE) {
|
||||
InsetBranch & br = static_cast<InsetBranch &>(*it);
|
||||
for (Inset const & it : inset()) {
|
||||
if (it.lyxCode() == BRANCH_CODE) {
|
||||
InsetBranch const & br = static_cast<InsetBranch const &>(it);
|
||||
docstring const name = br.branch();
|
||||
if (!from_master && !params().branchlist().find(name))
|
||||
result.push_back(name);
|
||||
@ -3853,10 +3851,10 @@ void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_mast
|
||||
result.push_back(name);
|
||||
continue;
|
||||
}
|
||||
if (it->lyxCode() == INCLUDE_CODE) {
|
||||
if (it.lyxCode() == INCLUDE_CODE) {
|
||||
// get buffer of external file
|
||||
InsetInclude const & ins =
|
||||
static_cast<InsetInclude const &>(*it);
|
||||
static_cast<InsetInclude const &>(it);
|
||||
Buffer * child = ins.loadIfNeeded();
|
||||
if (!child)
|
||||
continue;
|
||||
@ -4027,7 +4025,7 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
|
||||
|
||||
string const paramName = "key";
|
||||
UndoGroupHelper ugh(this);
|
||||
InsetIterator it = inset_iterator_begin(inset());
|
||||
InsetIterator it = begin(inset());
|
||||
for (; it; ++it) {
|
||||
if (it->lyxCode() != CITE_CODE)
|
||||
continue;
|
||||
|
@ -35,11 +35,8 @@ void BufferEncodings::initUnicodeMath(Buffer const & buffer, bool for_master)
|
||||
}
|
||||
|
||||
// Check this buffer
|
||||
Inset & inset = buffer.inset();
|
||||
InsetIterator it = inset_iterator_begin(inset);
|
||||
InsetIterator const end = inset_iterator_end(inset);
|
||||
for (; it != end; ++it)
|
||||
it->initUnicodeMath();
|
||||
for (Inset const & it : buffer.inset())
|
||||
it.initUnicodeMath();
|
||||
|
||||
if (!for_master)
|
||||
return;
|
||||
|
@ -292,8 +292,8 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
||||
// Prepare the paragraphs and insets for insertion.
|
||||
insertion.swap(in.paragraphs());
|
||||
|
||||
InsetIterator const i_end = inset_iterator_end(in);
|
||||
for (InsetIterator it = inset_iterator_begin(in); it != i_end; ++it) {
|
||||
InsetIterator const i_end = end(in);
|
||||
for (InsetIterator it = begin(in); it != i_end; ++it) {
|
||||
// Even though this will also be done later, it has to be done here
|
||||
// since some inset might try to access the buffer() member.
|
||||
it->setBuffer(const_cast<Buffer &>(buffer));
|
||||
@ -315,7 +315,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
||||
if (oldname == newname)
|
||||
continue;
|
||||
// adapt the references
|
||||
for (InsetIterator itt = inset_iterator_begin(in);
|
||||
for (InsetIterator itt = begin(in);
|
||||
itt != i_end; ++itt) {
|
||||
if (itt->lyxCode() == REF_CODE) {
|
||||
InsetCommand * ref = itt->asInsetCommand();
|
||||
@ -346,7 +346,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
||||
if (oldname == newname)
|
||||
break;
|
||||
// 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) {
|
||||
InsetCommand & ref = static_cast<InsetCommand &>(*itt);
|
||||
if (ref.getParam("reference") == oldname)
|
||||
@ -393,7 +393,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
||||
if (oldkey == newkey)
|
||||
break;
|
||||
// adapt the references
|
||||
for (InsetIterator itt = inset_iterator_begin(in);
|
||||
for (InsetIterator itt = begin(in);
|
||||
itt != i_end; ++itt) {
|
||||
if (itt->lyxCode() == CITE_CODE) {
|
||||
InsetCommand * ref = itt->asInsetCommand();
|
||||
@ -806,10 +806,10 @@ void switchBetweenClasses(DocumentClassConstPtr oldone,
|
||||
|
||||
// layouts
|
||||
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
|
||||
set<docstring> newlayouts;
|
||||
for (; it != end; ++it) {
|
||||
for (; it != pend; ++it) {
|
||||
docstring const name = it->layout().name();
|
||||
|
||||
// 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
|
||||
InsetIterator const i_end = inset_iterator_end(in);
|
||||
for (InsetIterator iit = inset_iterator_begin(in); iit != i_end; ++iit) {
|
||||
InsetIterator const i_end = end(in);
|
||||
for (InsetIterator iit = begin(in); iit != i_end; ++iit) {
|
||||
InsetCode const code = iit->lyxCode();
|
||||
if (code == FLEX_CODE) {
|
||||
// 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);
|
||||
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);
|
||||
}
|
||||
|
@ -33,9 +33,9 @@ public:
|
||||
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)
|
||||
{
|
||||
Inset & inset = b.inset();
|
||||
InsetIterator it = inset_iterator_begin(inset);
|
||||
InsetIterator const end = inset_iterator_end(inset);
|
||||
for (; it != end; ++it) {
|
||||
InsetGraphics const * ins = it->asInsetGraphics();
|
||||
for (Inset const & it : b.inset()) {
|
||||
InsetGraphics const * ins = it.asInsetGraphics();
|
||||
if (!ins)
|
||||
continue;
|
||||
InsetGraphicsParams const & inspar = ins->getParams();
|
||||
@ -1208,11 +1205,8 @@ int countGroupMembers(Buffer const & b, string const & groupId)
|
||||
int n = 0;
|
||||
if (groupId.empty())
|
||||
return n;
|
||||
Inset & inset = b.inset();
|
||||
InsetIterator it = inset_iterator_begin(inset);
|
||||
InsetIterator const end = inset_iterator_end(inset);
|
||||
for (; it != end; ++it) {
|
||||
InsetGraphics const * ins = it->asInsetGraphics();
|
||||
for (Inset const & it : b.inset()) {
|
||||
InsetGraphics const * ins = it.asInsetGraphics();
|
||||
if (!ins)
|
||||
continue;
|
||||
if (ins->getParams().groupId == groupId)
|
||||
@ -1226,11 +1220,8 @@ string getGroupParams(Buffer const & b, string const & groupId)
|
||||
{
|
||||
if (groupId.empty())
|
||||
return string();
|
||||
Inset & inset = b.inset();
|
||||
InsetIterator it = inset_iterator_begin(inset);
|
||||
InsetIterator const end = inset_iterator_end(inset);
|
||||
for (; it != end; ++it) {
|
||||
InsetGraphics const * ins = it->asInsetGraphics();
|
||||
for (Inset const & it : b.inset()) {
|
||||
InsetGraphics const * ins = it.asInsetGraphics();
|
||||
if (!ins)
|
||||
continue;
|
||||
InsetGraphicsParams const & inspar = ins->getParams();
|
||||
@ -1252,9 +1243,9 @@ void unifyGraphicsGroups(Buffer & b, string const & argument)
|
||||
// This handles undo groups automagically
|
||||
UndoGroupHelper ugh(&b);
|
||||
Inset & inset = b.inset();
|
||||
InsetIterator it = inset_iterator_begin(inset);
|
||||
InsetIterator const end = inset_iterator_end(inset);
|
||||
for (; it != end; ++it) {
|
||||
InsetIterator it = begin(inset);
|
||||
InsetIterator const itend = end(inset);
|
||||
for (; it != itend; ++it) {
|
||||
InsetGraphics * ins = it->asInsetGraphics();
|
||||
if (!ins)
|
||||
continue;
|
||||
|
@ -3132,12 +3132,11 @@ void Tabular::TeXRow(otexstream & os, row_type row,
|
||||
} else if (ltCaption(row)) {
|
||||
// Inside longtable caption rows, we must only output the caption inset
|
||||
// with its content and omit anything outside of that (see #10791)
|
||||
InsetIterator it = inset_iterator_begin(*const_cast<InsetTableCell *>(inset));
|
||||
InsetIterator i_end = inset_iterator_end(*const_cast<InsetTableCell *>(inset));
|
||||
for (; it != i_end; ++it) {
|
||||
if (it->lyxCode() != CAPTION_CODE)
|
||||
InsetTableCell & tc_inset = *const_cast<InsetTableCell *>(inset);
|
||||
for (Inset const & it : tc_inset) {
|
||||
if (it.lyxCode() != CAPTION_CODE)
|
||||
continue;
|
||||
it->latex(os, runparams);
|
||||
it.latex(os, runparams);
|
||||
break;
|
||||
}
|
||||
} else if (!isPartOfMultiRow(row, c)) {
|
||||
|
Loading…
Reference in New Issue
Block a user