commit af402d81c734211351c95eda3f7268739a23fa22
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Sun Feb 28 16:23:43 2016 +0100
Use isMainText() instead of doing explicit tests
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index fdf0da6..39eb2d4 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 6f5cf68..507213a 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<pit_type, ParagraphMetrics> ParMetricsCache;
///
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 6608263..017e144 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();