diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index 516558828e..448c2dab4b 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -21,6 +21,7 @@ class BufferView; class CursorSlice; class FuncRequest; class FuncStatus; +class InsetText; class LaTeXFeatures; class LCursor; class LyXLex; @@ -216,8 +217,10 @@ public: virtual EDITABLE editable() const; /// can we go further down on mouse click? virtual bool descendable() const { return false; } - /// - virtual bool isTextInset() const { return false; } + /// does this contain text that can be change track marked in DVI? + virtual bool canTrackChanges() const { return false; } + /// is this inset based on the TextInset class? + virtual InsetText * asTextInset() const { return 0; } /// return true if the inset should be removed automatically virtual bool autoDelete() const; diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 22697c4828..9455eabbb2 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -57,8 +57,6 @@ public: /// can we go further down on mouse click? bool descendable() const; /// - bool isTextInset() const { return true; } - /// void setLabel(std::string const & l); /// virtual void setButtonLabel() {} diff --git a/src/insets/insetenv.h b/src/insets/insetenv.h index aeeb992c63..e030600930 100644 --- a/src/insets/insetenv.h +++ b/src/insets/insetenv.h @@ -34,8 +34,6 @@ public: /// InsetBase::EDITABLE editable() const { return HIGHLY_EDITABLE; } /// - bool isTextInset() const { return true; } - /// LyXLayout_ptr const & layout() const; /** returns true if, when outputing LaTeX, font changes should be closed before generating this inset. This is needed for diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 3664c12ace..889070e9a1 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -69,7 +69,7 @@ public: /// bool insetAllowed(InsetBase::Code) const { return true; } /// - bool isTextInset() const { return true; } + bool canTrackChanges() const { return true; } /** returns true if, when outputing LaTeX, font changes should be closed before generating this inset. This is needed for insets that may contain several paragraphs */ diff --git a/src/insets/insettext.C b/src/insets/insettext.C index bd02ffcc4a..0044259c07 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -258,6 +258,12 @@ InsetBase * InsetText::editXY(LCursor & cur, int x, int y) } +bool const InsetText::Tall() const +{ + return text_.ascent() + text_.descent() > 2 * defaultRowHeight(); +} + + void InsetText::doDispatch(LCursor & cur, FuncRequest & cmd) { lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION diff --git a/src/insets/insettext.h b/src/insets/insettext.h index dadc5593a1..1e17937c45 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -57,7 +57,9 @@ public: /// EDITABLE editable() const { return HIGHLY_EDITABLE; } /// - bool isTextInset() const { return true; } + bool canTrackChanges() const { return true; } + /// + InsetText * asTextInset() const { return const_cast(this); } /// int latex(Buffer const &, std::ostream &, OutputParams const &) const; @@ -139,7 +141,9 @@ public: InsetText(InsetText const &); /// bool & Wide() const { return wide_inset_; } - + /// + bool const Tall() const; + protected: /// virtual void doDispatch(LCursor & cur, FuncRequest & cmd); diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index 9767f0f883..d50400b14d 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -189,7 +189,7 @@ public: /// what appears in the minibuffer when opening virtual std::string const editMessage() const; /// - virtual bool isTextInset() const { return true; } + virtual bool canTrackChanges() const { return true; } /// virtual void mutateToText(); /// diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 76065063c5..4ffd914f3e 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -536,7 +536,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf, && runparams.flavor == OutputParams::LATEX && features.isAvailable("dvipost"); - if (inset->isTextInset()) { + if (inset->canTrackChanges()) { column += Changes::latexMarkChange(os, running_change, Change::UNCHANGED, output); running_change = Change::UNCHANGED; diff --git a/src/rowpainter.C b/src/rowpainter.C index bdd1f6bcf1..69ea2edbc2 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -151,15 +151,6 @@ int RowPainter::leftMargin() const } -bool isTrueTextInset(InsetBase * in) -{ - // Math and tabular insets have isTextInset = true, though they are - // not derived from InsetText. Paint them fully - return (in && in->isTextInset() && in->asMathInset() == 0 - && in->lyxCode() != InsetBase::TABULAR_CODE); -} - - void RowPainter::paintInset(pos_type const pos, LyXFont const & font) { InsetBase const * inset = par_.getInset(pos); @@ -176,8 +167,10 @@ void RowPainter::paintInset(pos_type const pos, LyXFont const & font) InsetBase * in = const_cast(inset); // non-wide insets are painted completely. Recursive bool tmp = bv_.repaintAll(); - if (!isTrueTextInset(in) || !static_cast(in)->Wide()) + if (!in->asTextInset() || !static_cast(in)->Wide()) { bv_.repaintAll(true); + lyxerr[Debug::PAINTING] << endl << "Paint inset fully" << endl; + } if (bv_.repaintAll()) inset->drawSelection(pi, int(x_), yo_); inset->draw(pi, int(x_), yo_); @@ -821,9 +814,11 @@ void paintPar for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) { InsetBase* in = const_cast(par.getInset(i)); - if (isTrueTextInset(in)) + if (in && in->asTextInset()) { static_cast(in)->Wide() - = in_inset_alone_on_row; + = in_inset_alone_on_row && + static_cast(in)->Tall(); + } } // If selection is on, the current row signature differs