Andre Poenitz wrote:
On Wed, Mar 14, 2007 at 11:09:03AM +0100, Abdelrazak Younes wrote:
I'd rather do:
- if (layout->labeltype == LABEL_SENSITIVE) {
+ if (cur.innerInsetOfType(InsetBase::CAPTION_CODE) ||
layout->labeltype == LABEL_SENSITIVE) {
Yes. That's what I meant in my previous comment (obviously InsetCaption
derives from InsetText, not LyXText).
But instead of using 'cur' I'd rather have a new method in LyXText:
InsetText * parent();
InsetText const * parent() const;
Then the above code will be
+ if (parent()->lyxCode() == InsetBase::CAPTION_CODE) ||
layout->labeltype == LABEL_SENSITIVE) {
That would of course mean that we pass the Parent at LyXText
construction. I think that having access to the parent InsetText will
remove may hacks in the code.
Not having the parents has benefits, too.
Removing the parent was one of the efforts in giving paragraphs (and
consequently contained insets) a value-semantic. Access to the
parent was given by DocIterators (or a cursor for that matter)
The two approaches are not orthogonal.
This effort was not finished 100%. I am not sure why.
However, it is probably time to decide whether we want parents
(i.e. basically a treelike structure with simpla navigation but
ugoly copy semantics as needed for undo) or not (i.e. sometimes
cumbersome naviation but simple copies) - and than go for it 100%.
IMO, the tree-like approach fits very well the upcoming XML format. I
reckon that we should switch to a truly structured memory model.
Abdel.