On Wed, Mar 15, 2006 at 10:27:04PM +0100, Georg Baum wrote: > Am Mittwoch, 15. März 2006 21:34 schrieb Martin Vermeer: > > On Fri, Mar 10, 2006 at 04:13:47PM +0100, Georg Baum wrote:
... > > > >> 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) With all due respect, I think you miss the point. What the isTrueTextInset method tries to establish, is whether a certain type of inset (math; collapsable; tabular) is _derived_ from textinset, by inheritance. The reason this is necessary is, that only then will it have the data member wide_inset_, and is it safe to assign a value to it, to a memory location that the inset actually owns. (It would be possible to put wide_inset_ in insetbase; bad idea because of memory allocation. Lots of little insets in math.) Yes, we could adapt isTextInset() to provide this info, as you propose for math. The price you pay is the extra testing condition in paragraph_pimpl.C. You _shift_ the problem, but don't _solve_ it. You could do the same with tabular: make its isTextInset return false. Then you could add a third condition for tabular to paragraph_pimpl.C too ;-/ (There's a Danish saying: nissen flytter med. Hard to translate.) The reason for this is, that paragraph_pimpl.C expects something different from isTextInset than rowpainter.C. It expects to find out if the inset _actually contains_ a lyxtext with paragraphs. One method cannot serve these two masters. BTW checking insets/ I see the following: grep isTextInset *.h insetbase.h: virtual bool isTextInset() const { return false; } insetcollapsable.h: bool isTextInset() const { return true; } insetenv.h: bool isTextInset() const { return true; } insettabular.h: bool isTextInset() const { return true; } insettext.h: bool isTextInset() const { return true; } Of these, I think insetenv.h and insetcollapsable.h are simply unnecessary as they derive from insettext.h which already returns true. Agreed? Should we remove them? - Martin
pgpO7HB0IK9lD.pgp
Description: PGP signature