mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Transfer Paragraph::hfillExpansion() to ParagraphMetrics. This also reduce the dependency to Row.h which is probably going to change in the near future.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19951 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
02227212b2
commit
7d97e555fc
@ -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:
|
||||
|
@ -17,10 +17,8 @@
|
||||
#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.
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user