]> git.lyx.org Git - features.git/commitdiff
Transfer Paragraph::hfillExpansion() to ParagraphMetrics. This also reduce the depend...
authorAbdelrazak Younes <younes@lyx.org>
Fri, 31 Aug 2007 14:46:13 +0000 (14:46 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 31 Aug 2007 14:46:13 +0000 (14:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19951 a592a061-630c-0410-9148-cb99ea01b6c8

src/Paragraph.cpp
src/Paragraph.h
src/ParagraphMetrics.cpp
src/ParagraphMetrics.h
src/Text.cpp
src/TextMetrics.cpp
src/rowpainter.cpp

index 7a56557750b931d0d445913423755c788c3a894e..7a987dc5591cebedf74e9f66f20046a754efe0ba 100644 (file)
@@ -2624,42 +2624,6 @@ char_type Paragraph::transformChar(char_type c, pos_type pos) const
 }
 
 
-bool Paragraph::hfillExpansion(Row const & row, pos_type pos) const
-{
-       if (!isHfill(pos))
-               return false;
-
-       BOOST_ASSERT(pos >= row.pos() && pos < row.endpos());
-
-       // expand at the end of a row only if there is another hfill on the same row
-       if (pos == row.endpos() - 1) {
-               for (pos_type i = row.pos(); i < pos; i++) {
-                       if (isHfill(i))
-                               return true;
-               }
-               return false;
-       }
-
-       // expand at the beginning of a row only if it is the first row of a paragraph
-       if (pos == row.pos()) {
-               return pos == 0;
-       }
-
-       // do not expand in some labels
-       if (layout()->margintype != MARGIN_MANUAL && pos < beginOfBody())
-               return false;
-
-       // if there is anything between the first char of the row and
-       // the specified position that is neither a newline nor an hfill,
-       // the hfill will be expanded, otherwise it won't
-       for (pos_type i = row.pos(); i < pos; i++) {
-               if (!isNewline(i) && !isHfill(i))
-                       return true;
-       }
-       return false;
-}
-
-
 int Paragraph::checkBiblio(bool track_changes)
 {
        //FIXME From JS:
index cd43609321fd53d04be1bf0a1bf11b01fb2946c8..21a96719c91dce868fd5aef264a9744e7caf166e 100644 (file)
 #define PARAGRAPH_H
 
 #include "Changes.h"
-#include "Dimension.h"
 #include "InsetList.h"
 #include "lyxlayout_ptr_fwd.h"
-#include "Row.h"
 
 #include "insets/Inset.h" // only for Inset::Code
 
@@ -356,8 +354,6 @@ public:
        ParagraphParameters & params();
        ///
        ParagraphParameters const & params() const;
-       ///
-       bool hfillExpansion(Row const & row, pos_type pos) const;
 
        /// Check if we are in a Biblio environment and insert or
        /// delete InsetBibitems as necessary.
index 65aedd2c1c29c831623b0e887f17b64fcac54c75..d9272f225501213a6fa82e9d5cd3bc648bce8e0b 100644 (file)
@@ -213,4 +213,39 @@ int ParagraphMetrics::singleWidth(pos_type pos, Font const & font) const
 }
 
 
+bool ParagraphMetrics::hfillExpansion(Row const & row, pos_type pos) const
+{
+       if (!par_->isHfill(pos))
+               return false;
+
+       BOOST_ASSERT(pos >= row.pos() && pos < row.endpos());
+
+       // expand at the end of a row only if there is another hfill on the same row
+       if (pos == row.endpos() - 1) {
+               for (pos_type i = row.pos(); i < pos; i++) {
+                       if (par_->isHfill(i))
+                               return true;
+               }
+               return false;
+       }
+
+       // expand at the beginning of a row only if it is the first row of a paragraph
+       if (pos == row.pos()) {
+               return pos == 0;
+       }
+
+       // do not expand in some labels
+       if (par_->layout()->margintype != MARGIN_MANUAL && pos < par_->beginOfBody())
+               return false;
+
+       // if there is anything between the first char of the row and
+       // the specified position that is neither a newline nor an hfill,
+       // the hfill will be expanded, otherwise it won't
+       for (pos_type i = row.pos(); i < pos; i++) {
+               if (!par_->isNewline(i) && !par_->isHfill(i))
+                       return true;
+       }
+       return false;
+}
+
 } // namespace lyx
index 759c346b01726a3a1e22056d213ebb8ab2dc845a..42f6d8720472fb629b4ba0705080fa7696e7a4ee 100644 (file)
@@ -17,7 +17,9 @@
 #ifndef PARAGRAPH_METRICS_H
 #define PARAGRAPH_METRICS_H
 
+#include "Dimension.h"
 #include "Paragraph.h"
+#include "Row.h"
 
 namespace lyx {
 
@@ -73,6 +75,10 @@ public:
 
        /// dump some information to lyxerr
        void dump() const;
+
+       ///
+       bool hfillExpansion(Row const & row, pos_type pos) const;
+
        /// 
        void computeRowSignature(Row &, BufferParams const & bparams);
 
index 09606366ac596d330cb9476a24e65a192102b175..7b16ed0c72692dbcfe40a9e7f71cb4209c600b65 100644 (file)
@@ -1553,7 +1553,7 @@ int Text::cursorX(BufferView const & bv, CursorSlice const & sl,
 
                x += pm.singleWidth(pos, font);
 
-               if (par.hfillExpansion(row, pos))
+               if (pm.hfillExpansion(row, pos))
                        x += (pos >= body_pos) ? row.hfill : row.label_hfill;
                else if (par.isSeparator(pos) && pos >= body_pos)
                        x += row.separator;
index 8f3f993816a74d238bf09339f993ed16b17ff091..81a9626966eab4803946b10b1e62f1e0368a9d88 100644 (file)
@@ -820,6 +820,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
        int const xo = main_text_? 0 : bv_->coordCache().get(text_, pit).x_;
        x -= xo;
        Paragraph const & par = text_->getPar(pit);
+       ParagraphMetrics const & pm = par_metrics_[pit];
        Bidi bidi;
        bidi.computeTables(par, buffer, row);
 
@@ -856,7 +857,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
                                tmpx -= singleWidth(pit, body_pos - 1);
                }
 
-               if (par.hfillExpansion(row, c)) {
+               if (pm.hfillExpansion(row, c)) {
                        tmpx += singleWidth(pit, c);
                        if (c >= body_pos)
                                tmpx += row.hfill;
@@ -1054,7 +1055,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co
        // Re-enable screen drawing for future use of the painter.
        pi.pain.setDrawingEnabled(true);
 
-       LYXERR(Debug::PAINTING) << "." << endl;
+       //LYXERR(Debug::PAINTING) << "." << endl;
 }
 
 
index d20c644ca433373a7ac246b116d0a4aa8b9a5093..d8b05eb1c1e0d9819050521e974c889fb8a63fd4 100644 (file)
@@ -96,7 +96,7 @@ void RowPainter::paintHfill(pos_type const pos, pos_type const body_pos)
 
        pi_.pain.line(int(x_), y1, int(x_), y0, Color::added_space);
 
-       if (par_.hfillExpansion(row_, pos)) {
+       if (pm_.hfillExpansion(row_, pos)) {
                int const y2 = (y0 + y1) / 2;
 
                if (pos >= body_pos) {