Dov Feldstern wrote:
Abdelrazak Younes wrote:
Dov Feldstern wrote:
Hi!

I have a cursor inside an inset. How can I easily get to the paragraph containing this inset? What I really want is to get to the character which represents the inset I'm in, so that I can get its font.

If you have access to the Cursor this information is in the previous CursorSlice. That is:

int current_slice_index = cur.depth() - 1;
CursorSlice const & previous_slice = cur[current_slice_index - 1];

pos_type char_previous_to_inset_pos = previous_slice.pos() - 1;

Abdel.



Thanks!

Just to make sure I understand: the current_slice_index depth is "cur.depth() - 1" (and not cur.depth()) because the depth is 1-based, whereas I need a 0-based index?

Yes, depth() is just size() actually, look at DocIterator.h:

        /// how many nested insets do we have?
        size_t depth() const { return slices_.size(); }

Abdel.

Reply via email to