From 4fb8e9b6393ad5fe5af12cfcdd18a62b11e032b6 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sun, 28 Feb 2016 16:23:43 +0100 Subject: [PATCH] Use isMainText() instead of doing explicit tests --- src/TextMetrics.cpp | 7 +++---- src/TextMetrics.h | 3 +-- src/insets/InsetText.cpp | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index fdf0da6926..39eb2d441b 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -200,13 +200,13 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width) int TextMetrics::rightMargin(ParagraphMetrics const & pm) const { - return main_text_? pm.rightMargin(*bv_) : 0; + return text_->isMainText() ? pm.rightMargin(*bv_) : 0; } int TextMetrics::rightMargin(pit_type const pit) const { - return main_text_? par_metrics_[pit].rightMargin(*bv_) : 0; + return text_->isMainText() ? par_metrics_[pit].rightMargin(*bv_) : 0; } @@ -353,7 +353,6 @@ bool TextMetrics::redoParagraph(pit_type const pit) pm.reset(par); Buffer & buffer = bv_->buffer(); - main_text_ = (text_ == &buffer.text()); bool changed = false; // Check whether there are InsetBibItems that need fixing @@ -1087,7 +1086,7 @@ void TextMetrics::setRowHeight(Row & row, pit_type const pit, // following code in another method specially tailored for the // main Text. The following test is thus bogus. // Top and bottom margin of the document (only at top-level) - if (main_text_ && topBottomSpace) { + if (text_->isMainText() && topBottomSpace) { if (pit == 0 && row.pos() == 0) maxasc += 20; if (pit + 1 == pit_type(pars.size()) && diff --git a/src/TextMetrics.h b/src/TextMetrics.h index 6f5cf68733..507213a5ab 100644 --- a/src/TextMetrics.h +++ b/src/TextMetrics.h @@ -35,7 +35,7 @@ class TextMetrics { public: /// Default constructor (only here for STL containers). - TextMetrics() : bv_(0), text_(0), main_text_(false), max_width_(0) {} + TextMetrics() : bv_(0), text_(0), max_width_(0) {} /// The only useful constructor. TextMetrics(BufferView *, Text *); @@ -243,7 +243,6 @@ private: /// \todo FIXME: this should be const. Text * text_; - bool main_text_; /// A map from paragraph index number to paragraph metrics typedef std::map ParMetricsCache; /// diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 660826309f..017e1445d0 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -290,7 +290,7 @@ void InsetText::doDispatch(Cursor & cur, FuncRequest & cmd) break; case LFUN_INSET_DISSOLVE: { - bool const main_inset = &buffer().inset() == this; + bool const main_inset = text_.isMainText(); bool const target_inset = cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode()); // cur.inset() is the tabular when this is a single cell (bug #9954) @@ -323,7 +323,7 @@ bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd, { switch (cmd.action()) { case LFUN_INSET_DISSOLVE: { - bool const main_inset = &buffer().inset() == this; + bool const main_inset = text_.isMainText(); bool const target_inset = cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode()); // cur.inset() is the tabular when this is a single cell (bug #9954) @@ -340,7 +340,7 @@ bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd, status.setEnabled(false); return true; } - if (&buffer().inset() == this || !cur.paragraph().layout().args().empty()) + if (text_.isMainText() || !cur.paragraph().layout().args().empty()) return text_.getStatus(cur, cmd, status); Layout::LaTeXArgMap args = getLayout().args();