]> git.lyx.org Git - features.git/commitdiff
Final touch 'inset display()'; fix 'is a bit silly' bug
authorMartin Vermeer <martin.vermeer@hut.fi>
Tue, 21 Oct 2003 13:04:14 +0000 (13:04 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Tue, 21 Oct 2003 13:04:14 +0000 (13:04 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7941 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insetcollapsable.h
src/insets/insetcommand.h
src/insets/insetfloat.h
src/insets/insetfootlike.h
src/insets/insetinclude.h
src/text.C

index 054943975597c6fa95785a98cba4ae7acaa1e2c1..c2e7649ee13be0a8fef638a6a93a1f752fedcc48 100644 (file)
@@ -1,3 +1,9 @@
+2003-10-21  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * 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  <martin.vermeer@hut.fi>
 
        * text.C: re-introduce display() for insets, fixing the
index eb25292ab985cc011e178d42c08afe50339e5da4..52c5c73de15f04a6426bd9424df23ada89a819bd 100644 (file)
@@ -1,3 +1,13 @@
+2003-10-21  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * 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  <martin.vermeer@hut.fi>
 
        * inset.h:
index cd62a24956a1878372e0112bd4fcb29c7ce487b4..7fef35072010e23e616b744caf482182dda1265f 100644 (file)
@@ -120,6 +120,8 @@ public:
        ///
        LyXCursor const & cursor(BufferView *) const;
        ///
+       virtual bool display() const { return isOpen(); }
+       ///
        bool isOpen() const;
        ///
        void open(BufferView *);
index a12a2ceaad78b0329f2d3bb42ab514d4ba27e8b7..969f987da073b53f902ec245907b8b9b6acc5625 100644 (file)
@@ -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_; }
        ///
index 2ffa79218e9ba33f6ad07477ab3320f3c615b75d..5416845ac27d83000f1aa3c9334471d6ea473a3f 100644 (file)
@@ -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);
index 12615d57a080ecddf6ad23a31f24a85b98288c13..c6489f53d399b392d87e7c1b3578451f2cefde47 100644 (file)
@@ -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
index 72dc2eed46b8138e5a1b355b3546ab8a9f09f229..5064e03c0233ec520d340aeae8358bf947149a55 100644 (file)
@@ -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;
index a3c33d9f8b6ba5d2a15b962d96104931738b44b3..9760a8a60aa6ba0d2748932137c4ebf3594fa780 100644 (file)
@@ -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;
                }