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.
Here is what I have in mind. Objection?
Abdel.
Index: insets/insettext.C
===================================================================
--- insets/insettext.C (revision 17412)
+++ insets/insettext.C (working copy)
@@ -77,7 +77,7 @@
InsetText::InsetText(BufferParams const & bp)
- : drawFrame_(false), frame_color_(LColor::insetframe)
+ : drawFrame_(false), frame_color_(LColor::insetframe), text_(*this)
{
paragraphs().push_back(Paragraph());
paragraphs().back().layout(bp.getLyXTextClass().defaultLayout());
@@ -89,7 +89,7 @@
InsetText::InsetText(InsetText const & in)
- : InsetOld(in), text_()
+ : InsetOld(in), text_(*this)
{
text_.autoBreakRows_ = in.text_.autoBreakRows_;
drawFrame_ = in.drawFrame_;
@@ -103,7 +103,7 @@
}
-InsetText::InsetText()
+InsetText::InsetText(): text_(*this)
{}
Index: lyxtext.h
===================================================================
--- lyxtext.h (revision 17412)
+++ lyxtext.h (working copy)
@@ -48,9 +48,12 @@
class LyXText {
public:
/// constructor
- explicit LyXText();
+ explicit LyXText(InsetBase const & parent);
///
+ InsetBase const & parent();
+
+ ///
LyXFont getFont(Buffer const & buffer, Paragraph const & par,
pos_type pos) const;
///
@@ -404,6 +407,8 @@
/// \param asParagraphs whether to paste as paragraphs or as lines
void pasteString(LCursor & cur, docstring const & str,
bool asParagraphs);
+
+ InsetBase const & parent_;
};
} // namespace lyx
Index: text2.C
===================================================================
--- text2.C (revision 17412)
+++ text2.C (working copy)
@@ -73,13 +73,19 @@
using std::min;
-LyXText::LyXText()
+LyXText::LyXText(InsetBase const & parent)
: current_font(LyXFont::ALL_INHERIT),
background_color_(LColor::background),
- autoBreakRows_(false)
+ autoBreakRows_(false), parent_(parent)
{}
+InsetBase const & LyXText::parent()
+{
+ return parent_;
+}
+
+
bool LyXText::isMainText(Buffer const & buffer) const
{
return &buffer.text() == this;