Pavel Sanda wrote:
Buffer & buf = bv->buffer();
DocIterator cur = doc_iterator_begin(buf.inset());
while (findInset(cur, vector<InsetCode>(1, GRAPHICS_CODE), false))
lyxerr<<"inset found";
when i put single image in document nothing is found; i must some characters
before text to have it found.
One of the first thing that findInset does is:
tmpdit.forwardInset();
This means that the first inset is just ignored. This is useful in the
context where findinset is used (like Next Note).
You should try something like:
while(!cur.nextInset() || cur.nextInset().lyxCode() != GRAPHICS_CODE)
cur.forwardInset();
finally i use this:
while (findNextInset(cur, vector<InsetCode>(1, GRAPHICS_CODE), contents)){
//add some assert for cur.nextInset()->lyxCode() != GRAPHICS_CODE
InsetGraphics & ins = static_cast<InsetGraphics &>(*cur.nextInset());
I'm no expert on the use of these iterators, but I can't help but wonder
why you're not using InsetIterator here. See e.g. LyXFunc.cpp, in the
ALL_INSETS_TOGGLE bit.
Richard