]> git.lyx.org Git - features.git/commitdiff
delete BufferView::text() method and add two FIXME in text.C
authorAbdelrazak Younes <younes@lyx.org>
Sat, 16 Sep 2006 13:34:09 +0000 (13:34 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 16 Sep 2006 13:34:09 +0000 (13:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15017 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/lyx_cb.C
src/lyxfind.C
src/rowpainter.C
src/text.C

index 431585ba7b8879a85b20cc1a8aecf621932ae331..2cde9ab9f09631f2a8ff34577917fa535bd1baea 100644 (file)
@@ -1208,12 +1208,6 @@ int BufferView::workHeight() const
 }
 
 
-LyXText * BufferView::text() const
-{
-       return buffer_ ? &buffer_->text() : 0;
-}
-
-
 void BufferView::setCursor(DocIterator const & dit)
 {
        size_t const n = dit.depth();
index fc69fd34a8de514bc8524ffb255e5177894109c9..11c95453c216f5d4a49ff61cbf97a558fbb48b37 100644 (file)
@@ -199,8 +199,6 @@ public:
        LCursor & cursor();
        /// access to full cursor
        LCursor const & cursor() const;
-       ///
-       LyXText * text() const;
        /// sets cursor and open all relevant collapsable insets.
        void setCursor(DocIterator const &);
        /// sets cursor; this is used when handling LFUN_MOUSE_PRESS.
index 2a4d9b69bddf38400baa5655dcfa8503c0fd7321..3635a4a0a13cde61ad739921fa5240b205038d2c 100644 (file)
@@ -362,7 +362,8 @@ void insertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
                return;
 
        // clear the selection
-       if (bv->text() == bv->getLyXText())
+       LyXText & const text = bv->buffer()->text();
+       if (&text == bv->getLyXText())
                bv->cursor().clearSelection();
        if (asParagraph)
                bv->getLyXText()->insertStringAsParagraphs(bv->cursor(), tmpstr);
index 8ca56cbc4ace2c6ea1f21abbd5e191a6264b3e53..f2752a82f0a8a8a9611fd49d0084621cdebefa65 100644 (file)
@@ -192,7 +192,7 @@ int replaceAll(BufferView * bv,
                ++num;
        }
 
-       bv->text()->init(bv);
+       bv->buffer()->text().init(bv);
        bv->putSelectionAt(doc_iterator_begin(buf.inset()), 0, false);
        if (num)
                buf.markDirty();
index 53c27fc1b1c2cfe009808906c9e670ef7e8d5711..9d3593092b95a9c7e44b7fc6a94ea1b9c2e83c74 100644 (file)
@@ -910,7 +910,7 @@ void paintPar
 void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
               Painter & pain)
 {
-       LyXText * const text = bv.text();
+       LyXText & text = bv.buffer()->text();
        bool const select = bv.cursor().selection();
 
        PainterInfo pi(const_cast<BufferView *>(&bv), pain);
@@ -920,19 +920,19 @@ void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
        if (repaintAll) {
                // Clear background (if not delegated to rows)
                pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
-                       text->backgroundColor());
+                       text.backgroundColor());
        }
        if (select) {
-               text->drawSelection(pi, 0, 0);
+               text.drawSelection(pi, 0, 0);
        }
 
        int yy = vi.y1;
        // draw contents
        for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
                refreshInside = repaintAll;
-               Paragraph const & par = text->getPar(pit);
+               Paragraph const & par = text.getPar(pit);
                yy += par.ascent();
-               paintPar(pi, *bv.text(), pit, 0, yy, repaintAll);
+               paintPar(pi, text, pit, 0, yy, repaintAll);
                yy += par.descent();
        }
 
@@ -941,24 +941,24 @@ void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
        // Try viewing the User Guide Mobius figure
 
        if (vi.p1 > 0) {
-               text->redoParagraph(vi.p1 - 1);
-               theCoords.parPos()[bv.text()][vi.p1 - 1] =
-                       Point(0, vi.y1 - text->getPar(vi.p1 - 1).descent());
+               text.redoParagraph(vi.p1 - 1);
+               theCoords.parPos()[&text][vi.p1 - 1] =
+                       Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
        }
 
-       if (vi.p2 < lyx::pit_type(text->paragraphs().size()) - 1) {
-               text->redoParagraph(vi.p2 + 1);
-               theCoords.parPos()[bv.text()][vi.p2 + 1] =
-                       Point(0, vi.y2 + text->getPar(vi.p2 + 1).ascent());
+       if (vi.p2 < lyx::pit_type(text.paragraphs().size()) - 1) {
+               text.redoParagraph(vi.p2 + 1);
+               theCoords.parPos()[&text][vi.p2 + 1] =
+                       Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
        }
 
        // and grey out above (should not happen later)
-//     lyxerr << "par ascent: " << text->getPar(vi.p1).ascent() << endl;
+//     lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
        if (vi.y1 > 0 && !vi.singlepar)
                pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
 
        // and possibly grey out below
-//     lyxerr << "par descent: " << text->getPar(vi.p1).ascent() << endl;
+//     lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
        if (vi.y2 < bv.workHeight() && !vi.singlepar)
                pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
 }
index 0d279b7a9f3095e14c476cf9262bfce2b7ea8ebf..22b5741227c6da281414ebfb7aad1872b6ca4f4f 100644 (file)
@@ -684,8 +684,11 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const
 
 int LyXText::rightMargin(Paragraph const & par) const
 {
+       // FIXME: the correct way is to only call rightMargin() only
+       // within the main LyXText. The following test is thus bogus.
+       LyXText const & text = bv()->buffer()->text();
        // We do not want rightmargins on inner texts.
-       if (bv()->text() != this)
+       if (&text != this)
                return 0;
 
        BufferParams const & params = bv()->buffer()->params();
@@ -1079,8 +1082,12 @@ void LyXText::setHeightOfRow(pit_type const pit, Row & row)
        maxasc  += int(layoutasc  * 2 / (2 + pars_[pit].getDepth()));
        maxdesc += int(layoutdesc * 2 / (2 + pars_[pit].getDepth()));
 
+       // FIXME: the correct way is to do the following is to move the 
+       // following code in another method specially tailored for the 
+       // main LyXText. The following test is thus bogus.
+       LyXText const & text = bv_owner->buffer()->text();
        // Top and bottom margin of the document (only at top-level)
-       if (bv_owner->text() == this) {
+       if (&text == this) {
                if (pit == 0 && row.pos() == 0)
                        maxasc += 20;
                if (pit + 1 == pit_type(pars_.size()) &&