]> git.lyx.org Git - features.git/commitdiff
one less use of ownerPar means faster code
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 14 Aug 2004 23:57:29 +0000 (23:57 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 14 Aug 2004 23:57:29 +0000 (23:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8939 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insetnewline.C
src/metricsinfo.C
src/metricsinfo.h
src/rowpainter.C
src/text.C

index 94c537234bcb77d775724e62974c0fc7597ce0c7..28f2abe1cbde6fa220b2b670a5a4fc0eb3cac907 100644 (file)
@@ -1,3 +1,11 @@
+2004-08-15  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * metricsinfo.h: add a new field ltr_pos to PainterInfo
+
+       * rowpainter.C (paintInset): initialize PainterInfo::ltr_pos
+
+       * text.C (singleWidth): remove useless test
+
 2004-08-14  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * tabular.h: remove bogus comments
index 0588c673f5833290d156cdcc692364eae5a1ca3f..81ca55cf31403abcd8852bfcb78a2fa29f0075d7 100644 (file)
@@ -1,3 +1,6 @@
+2004-08-15  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * insetnewline.C (draw): use PainterInfo::ltr_pos instead of ownerPar.
 
 2004-08-14  André Pönitz  <poenitz@gmx.net>
 
index 9b05ff477cf99a8a435b2e124049669d528857e6..1ebf900acd95a25dddf2f68393497886b1b927d2 100644 (file)
@@ -86,11 +86,6 @@ void InsetNewline::draw(PainterInfo & pi, int x, int y) const
        int const wid = font_metrics::width('n', pi.base.font);
        int const asc = font_metrics::maxAscent(pi.base.font);
 
-       // hack, and highly dubious
-       lyx::pos_type pos = ownerPar(*pi.base.bv->buffer(), this)
-               .getPositionOfInset(this);
-       bool const ltr_pos = (pi.base.bv->text()->bidi.level(pos) % 2 == 0);
-
        int xp[3];
        int yp[3];
 
@@ -98,7 +93,7 @@ void InsetNewline::draw(PainterInfo & pi, int x, int y) const
        yp[1] = int(y - 0.500 * asc * 0.75);
        yp[2] = int(y - 0.125 * asc * 0.75);
 
-       if (ltr_pos) {
+       if (pi.ltr_pos) {
                xp[0] = int(x + wid * 0.375);
                xp[1] = int(x);
                xp[2] = int(x + wid * 0.375);
@@ -114,7 +109,7 @@ void InsetNewline::draw(PainterInfo & pi, int x, int y) const
        yp[1] = int(y - 0.500 * asc * 0.75);
        yp[2] = int(y - asc * 0.75);
 
-       if (ltr_pos) {
+       if (pi.ltr_pos) {
                xp[0] = int(x);
                xp[1] = int(x + wid);
                xp[2] = int(x + wid);
index b49eac04c8f67290df571e854f501bb7e7c5b401..b0bb7c7864073765eb8c29a710d49fd1f279d6d3 100644 (file)
@@ -47,7 +47,7 @@ MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth)
 
 
 PainterInfo::PainterInfo(BufferView * bv, Painter & painter)
-       : pain(painter)
+       : pain(painter), ltr_pos(false)
 {
        base.bv = bv;
 }
index dc3bef45e2eeaef2db63bbc27b008a2784ff2128..2e401c3eb7c3cb172b9d2433249162c4110056f5 100644 (file)
@@ -84,6 +84,8 @@ struct PainterInfo {
        MetricsBase base;
        ///
        Painter & pain;
+       /// Whether the text at this point is right-to-left (for InsetNewline)
+       bool ltr_pos;
 };
 
 
index 7c765847e3844d3ea7b0a1ceef5f332a2a0f53bd..f69d693f85cf877d57217014cff09c6f134aed92 100644 (file)
@@ -200,6 +200,7 @@ void RowPainter::paintInset(pos_type const pos)
        BOOST_ASSERT(inset);
        PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
        pi.base.font = getFont(pos);
+       pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
        theCoords.insets_.add(inset, int(x_), yo_ + row_.baseline());
        inset->drawSelection(pi, int(x_), yo_ + row_.baseline());
        inset->draw(pi, int(x_), yo_ + row_.baseline());
index 3dec428f4d62ca7361410ec4cbcafbf0c205d231..20c889266b9b90f8595731fda627a1addc151d7d 100644 (file)
@@ -441,9 +441,6 @@ int LyXText::height() const
 
 int LyXText::singleWidth(par_type par, pos_type pos) const
 {
-       if (pos >= pars_[par].size())
-               return 0;
-
        char const c = pars_[par].getChar(pos);
        return singleWidth(par, pos, c, getFont(par, pos));
 }