Am Mittwoch, 15. März 2006 21:34 schrieb Martin Vermeer: > On Fri, Mar 10, 2006 at 04:13:47PM +0100, Georg Baum wrote: > > Martin Vermeer wrote: > > > > > On Fri, 2006-03-10 at 15:54 +0100, Jean-Marc Lasgouttes wrote: > > > > > >> Small note: I do not like the following much > > >> > > >> +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); > > >> +} > > >> + > > >> + > > > > > > Join the club. > > > > > >> Isn't there another way? > > > > > > A method in the inset (base inset) itself? > > > > Please not if possible. Do you know why math insets return isTextInset() == > > true? Maybe this can be changed? > > Actually I would like to bring up this alternative once again. A method > (derivesFromTextInset?) implemented in insetbase.h returning false, and > re-implemented in insettext returning true.
But this is exactly what isTextInset is supposed to tell! I had a look, and it is not used much. The attached patch (ignoring your isTrueTextInset changes) should restore the true meaning of isTextInset, but change no functionality. I think that you should build on this. I am not sure about the tabular inset, we probably need to treat it separately sometimes, because it a) is a text inset (it contains text) b) is no text inset (it does not have a amin LyXText) > This is much more robust than the current solution against possible > future changes in the inset landscape. Imagine someone adds a new inset > type that (like tabular) can contain texts yet does not derive from > insettext. Then we would have to add a condition to the above method, > which is essentially un-guessable. A built-in timebomb. The alternative > solution proposed -- if you want to know if an inset derives from > textinset, just ask it -- would simply keep working right. > > What do you say? I fully agree. Georg
Index: src/paragraph_pimpl.C =================================================================== --- src/paragraph_pimpl.C (Revision 13383) +++ src/paragraph_pimpl.C (Arbeitskopie) @@ -536,7 +536,8 @@ void Paragraph::Pimpl::simpleTeXSpecialC && runparams.flavor == OutputParams::LATEX && features.isAvailable("dvipost"); - if (inset->isTextInset()) { + if (inset->isTextInset() || + inset->lyxCode() == InsetBase::MATH_CODE) { column += Changes::latexMarkChange(os, running_change, Change::UNCHANGED, output); running_change = Change::UNCHANGED; Index: src/mathed/math_hullinset.h =================================================================== --- src/mathed/math_hullinset.h (Revision 13383) +++ src/mathed/math_hullinset.h (Arbeitskopie) @@ -189,8 +189,6 @@ public: /// what appears in the minibuffer when opening virtual std::string const editMessage() const; /// - virtual bool isTextInset() const { return true; } - /// virtual void mutateToText(); /// virtual void revealCodes(LCursor & cur) const; Index: src/rowpainter.C =================================================================== --- src/rowpainter.C (Revision 13383) +++ src/rowpainter.C (Arbeitskopie) @@ -153,9 +153,7 @@ 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 + return (in && in->isTextInset() && in->lyxCode() != InsetBase::TABULAR_CODE); }