From: Martin Vermeer Date: Tue, 21 Oct 2003 13:04:14 +0000 (+0000) Subject: Final touch 'inset display()'; fix 'is a bit silly' bug X-Git-Tag: 1.6.10~15927 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=de039bb341afcfe9929b5fd6833308d509feae47;p=features.git Final touch 'inset display()'; fix 'is a bit silly' bug git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7941 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 0549439755..c2e7649ee1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-10-21 Martin Vermeer + + * text.C: (1) finish off the inset display() work; + (2) fix the "is a bit silly" bug (accessing char + past end of par). + 2003-10-20 Martin Vermeer * text.C: re-introduce display() for insets, fixing the diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index eb25292ab9..52c5c73de1 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,13 @@ +2003-10-21 Martin Vermeer + + * insetcollapsable.h: + * insetcommand.h: + * insetfloat.h: + * insetfootlike.h: + * insetinclude.h: (1) finish off the inset display() work; + (2) fix the "is a bit silly" bug (accessing char + past end of par). + 2003-10-20 Martin Vermeer * inset.h: diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index cd62a24956..7fef350720 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -120,6 +120,8 @@ public: /// LyXCursor const & cursor(BufferView *) const; /// + virtual bool display() const { return isOpen(); } + /// bool isOpen() const; /// void open(BufferView *); diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index a12a2ceaad..969f987da0 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -55,7 +55,9 @@ public: virtual int docbook(Buffer const &, std::ostream &, bool) const; /// InsetOld::Code lyxCode() const { return InsetOld::NO_CODE; } - + /// + virtual bool display() const { return true; } + /// InsetCommandParams const & params() const { return p_; } /// diff --git a/src/insets/insetfloat.h b/src/insets/insetfloat.h index 2ffa79218e..5416845ac2 100644 --- a/src/insets/insetfloat.h +++ b/src/insets/insetfloat.h @@ -45,8 +45,6 @@ public: /// ~InsetFloat(); /// - virtual bool display() const { return true; } - /// void write(Buffer const & buf, std::ostream & os) const; /// void read(Buffer const & buf, LyXLex & lex); diff --git a/src/insets/insetfootlike.h b/src/insets/insetfootlike.h index 12615d57a0..c6489f53d3 100644 --- a/src/insets/insetfootlike.h +++ b/src/insets/insetfootlike.h @@ -28,8 +28,6 @@ public: /// void write(Buffer const & buf, std::ostream & os) const; /// - bool display() const { return true; } - /// bool insetAllowed(InsetOld::Code) 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/insetinclude.h b/src/insets/insetinclude.h index 72dc2eed46..5064e03c02 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -38,6 +38,8 @@ public: void metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; + /// + virtual bool display() const { return true; } /// get the parameters InsetCommandParams const & params(void) const; diff --git a/src/text.C b/src/text.C index a3c33d9f8b..9760a8a60a 100644 --- a/src/text.C +++ b/src/text.C @@ -691,10 +691,9 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit, point = i; break; } - InsetOld * in; // Break before... if (i + 1 < last) { - in = pit->getInset(i + 1); + InsetOld * in = pit->getInset(i + 1); if (in && in->display()) { point = i; break; @@ -731,15 +730,18 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit, x += thiswidth; chunkwidth += thiswidth; - in = pit->getInset(i); + InsetOld * in = pit->getInset(i); // break before a character that will fall off // the right of the row if (x >= width) { // if no break before, break here - if (point == last || chunkwidth >= width - left) - point = (pos < i) ? i - 1 : i; - break; + if (point == last || chunkwidth >= width - left) { + if (pos < i) { + point = i - 1; + break; + } + } } if (!in || in->isChar()) { @@ -1461,9 +1463,9 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, } // Display-style insets should always be on a centred row - // (Simplify this to inset = pit->getInset(rit->pos()) once - // the "bit silly" bug is fixed, MV) - inset = pit->isInset(rit->pos()) ? pit->getInset(rit->pos()) : 0; + // The test on pit->size() is to catch zero-size pars, which + // would trigger the assert in Paragraph::getInset(). + inset = pit->size() ? pit->getInset(rit->pos()) : 0; if (inset && inset->display()) { align = LYX_ALIGN_CENTER; }