commit 3fd2398a28c8d2c85d1bb2c33c6ca15bfc398b54
Author: Guillaume Munch <[email protected]>
Date: Sun Sep 4 03:02:47 2016 +0100
Remove option to disable texrow
I suspect that the gain was negligible, yet it made debugging and
maintainance
harder.
---
src/Buffer.cpp | 2 +-
src/Cursor.cpp | 2 +-
src/Paragraph.cpp | 2 +-
src/TexRow.cpp | 15 +++------------
src/TexRow.h | 9 +++------
src/insets/InsetExternal.cpp | 8 ++++----
src/insets/InsetFloat.cpp | 2 +-
src/insets/InsetIPA.cpp | 2 +-
src/insets/InsetInclude.cpp | 2 +-
src/insets/InsetListings.cpp | 2 +-
src/insets/InsetPreview.cpp | 2 +-
src/lyxfind.cpp | 6 +++---
src/mathed/InsetMath.cpp | 6 +++---
src/mathed/InsetMathHull.cpp | 12 ++++++------
src/mathed/InsetMathNest.cpp | 2 +-
src/mathed/MacroTable.cpp | 2 +-
src/mathed/MathFactory.cpp | 2 +-
src/mathed/MathMacroTemplate.cpp | 2 +-
src/mathed/MathSupport.cpp | 6 +++---
src/texstream.cpp | 4 ++--
src/texstream.h | 6 +++---
21 files changed, 42 insertions(+), 54 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 7adab9f..bf83f9f 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -1959,7 +1959,7 @@ void Buffer::writeDocBookSource(odocstream & os, string
const & fname,
LaTeXFeatures features(*this, params(), runparams);
validate(features);
- d->texrow.reset(false);
+ d->texrow.reset();
DocumentClass const & tclass = params().documentClass();
string const & top_element = tclass.latexname();
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 72c723b..b13b6a5 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -1592,7 +1592,7 @@ void Cursor::normalize()
<< pos() << ' ' << lastpos() << " in idx: " << idx()
<< " in atom: '";
odocstringstream os;
- otexrowstream ots(os, false);
+ otexrowstream ots(os);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
inset().asInsetMath()->write(wi);
lyxerr << to_utf8(os.str()) << endl;
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index f9d942e..94cf931 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -1387,7 +1387,7 @@ void Paragraph::Private::validate(LaTeXFeatures &
features) const
// output is wrong if this paragraph contains content
// that needs to switch encoding.
odocstringstream ods;
- otexstream os(ods, false);
+ otexstream os(ods);
if (is_command) {
os << '\\' << from_ascii(layout_->latexname());
// we have to provide all the optional arguments here,
even though
diff --git a/src/TexRow.cpp b/src/TexRow.cpp
index 0b3f717..d427227 100644
--- a/src/TexRow.cpp
+++ b/src/TexRow.cpp
@@ -68,9 +68,9 @@ void TexRow::RowEntryList::append(RowEntryList row)
}
-TexRow::TexRow(bool enable)
+TexRow::TexRow()
{
- reset(enable);
+ reset();
}
@@ -92,10 +92,9 @@ bool TexRow::isNone(RowEntry r)
}
-void TexRow::reset(bool enable)
+void TexRow::reset()
{
rowlist_.clear();
- enabled_ = enable;
newline();
}
@@ -141,8 +140,6 @@ bool operator==(RowEntry entry1, RowEntry entry2)
bool TexRow::start(RowEntry entry)
{
- if (!enabled_)
- return false;
return currentRow().addEntry(entry);
}
@@ -155,8 +152,6 @@ bool TexRow::start(int id, pos_type pos)
void TexRow::forceStart(int id, pos_type pos)
{
- if (!enabled_)
- return;
return currentRow().forceAddEntry(textEntry(id,pos));
}
@@ -169,8 +164,6 @@ void TexRow::startMath(uid_type id, idx_type cell)
void TexRow::newline()
{
- if (!enabled_)
- return;
rowlist_.push_back(RowEntryList());
}
@@ -184,8 +177,6 @@ void TexRow::newlines(size_t num_lines)
void TexRow::append(TexRow other)
{
- if (!enabled_ || !other.enabled_)
- return;
RowList::iterator it = other.rowlist_.begin();
RowList::iterator const end = other.rowlist_.end();
LASSERT(it != end, return);
diff --git a/src/TexRow.h b/src/TexRow.h
index f74213e..dc0efdc 100644
--- a/src/TexRow.h
+++ b/src/TexRow.h
@@ -76,8 +76,6 @@ class TexRow {
///
RowList rowlist_;
///
- bool enabled_;
- ///
RowEntryList & currentRow();
///
@@ -88,11 +86,10 @@ class TexRow {
RowListIterator end() const;
public:
///
- TexRow(bool enable = true);
+ TexRow();
- /// Clears structure. Set enable to false if texrow is not needed, to
avoid
- /// computing TexRow when it is going to be immediately discarded.
- void reset(bool enable = true);
+ /// Clears structure.
+ void reset();
static const TextEntry text_none;
static const RowEntry row_none;
diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp
index e2ac61c..e208137 100644
--- a/src/insets/InsetExternal.cpp
+++ b/src/insets/InsetExternal.cpp
@@ -563,7 +563,7 @@ static bool isPreviewWanted(InsetExternalParams const &
params)
static docstring latexString(InsetExternal const & inset)
{
odocstringstream ods;
- otexstream os(ods, false);
+ otexstream os(ods);
// We don't need to set runparams.encoding since it is not used by
// latex().
OutputParams runparams(0);
@@ -733,7 +733,7 @@ int InsetExternal::plaintext(odocstringstream & os,
bool const external_in_tmpdir = !runparams.nice;
bool const dryrun = runparams.dryrun || runparams.inComment;
- otexstream ots(os, false);
+ otexstream ots(os);
ots << '\n'; // output external material on a new line
external::writeExternal(params_, "Ascii", buffer(), ots,
*(runparams.exportdata), external_in_tmpdir,
dryrun);
@@ -747,7 +747,7 @@ int InsetExternal::docbook(odocstream & os,
bool const external_in_tmpdir = !runparams.nice;
bool const dryrun = runparams.dryrun || runparams.inComment;
odocstringstream ods;
- otexstream ots(ods, false);
+ otexstream ots(ods);
external::writeExternal(params_, "DocBook", buffer(), ots,
*(runparams.exportdata), external_in_tmpdir,
dryrun);
os << ods.str();
@@ -761,7 +761,7 @@ docstring InsetExternal::xhtml(XHTMLStream & xs,
bool const external_in_tmpdir = !runparams.nice;
bool const dryrun = runparams.dryrun || runparams.inComment;
odocstringstream ods;
- otexstream ots(ods, false);
+ otexstream ots(ods);
external::writeExternal(params_, "XHTML", buffer(), ots,
*(runparams.exportdata),
external_in_tmpdir, dryrun);
xs << XHTMLStream::ESCAPE_NONE << ods.str();
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index e1538e2..49fd3bb 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -497,7 +497,7 @@ bool InsetFloat::allowsCaptionVariation(std::string const &
newtype) const
docstring InsetFloat::getCaption(OutputParams const & runparams) const
{
odocstringstream ods;
- otexstream os(ods, false);
+ otexstream os(ods);
getCaption(os, runparams);
return ods.str();
}
diff --git a/src/insets/InsetIPA.cpp b/src/insets/InsetIPA.cpp
index 84caac2..1c20866 100644
--- a/src/insets/InsetIPA.cpp
+++ b/src/insets/InsetIPA.cpp
@@ -122,7 +122,7 @@ void InsetIPA::addPreview(DocIterator const & inset_pos,
void InsetIPA::preparePreview(DocIterator const & pos) const
{
odocstringstream str;
- otexstream os(str, false);
+ otexstream os(str);
OutputParams runparams(&pos.buffer()->params().encoding());
latex(os, runparams);
docstring const snippet = str.str();
diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index 33bc7b5..6a11b1d 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -1090,7 +1090,7 @@ bool preview_wanted(InsetCommandParams const & params,
Buffer const & buffer)
docstring latexString(InsetInclude const & inset)
{
odocstringstream ods;
- otexstream os(ods, false);
+ otexstream os(ods);
// We don't need to set runparams.encoding since this will be done
// by latex() anyway.
OutputParams runparams(0);
diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp
index 8d9a67b..67e5234 100644
--- a/src/insets/InsetListings.cpp
+++ b/src/insets/InsetListings.cpp
@@ -398,7 +398,7 @@ docstring InsetListings::getCaption(OutputParams const &
runparams) const
return docstring();
odocstringstream ods;
- otexstream os(ods, false);
+ otexstream os(ods);
ins->getArgs(os, runparams);
ins->getArgument(os, runparams);
diff --git a/src/insets/InsetPreview.cpp b/src/insets/InsetPreview.cpp
index 334a8f2..37aec63 100644
--- a/src/insets/InsetPreview.cpp
+++ b/src/insets/InsetPreview.cpp
@@ -83,7 +83,7 @@ void InsetPreview::addPreview(DocIterator const & inset_pos,
void InsetPreview::preparePreview(DocIterator const & pos) const
{
odocstringstream str;
- otexstream os(str, false);
+ otexstream os(str);
OutputParams runparams(&pos.buffer()->params().encoding());
latex(os, runparams);
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 92f9be1..4d01547 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -756,7 +756,7 @@ static docstring buffer_to_latex(Buffer & buffer)
{
OutputParams runparams(&buffer.params().encoding());
odocstringstream ods;
- otexstream os(ods, false);
+ otexstream os(ods);
runparams.nice = true;
runparams.flavor = OutputParams::LATEX;
runparams.linelen = 80; //lyxrc.plaintext_linelen;
@@ -1076,7 +1076,7 @@ docstring latexifyFromCursor(DocIterator const & cur, int
len)
LBUFERR(buf.params().isLatex());
odocstringstream ods;
- otexstream os(ods, false);
+ otexstream os(ods);
OutputParams runparams(&buf.params().encoding());
runparams.nice = false;
runparams.flavor = OutputParams::LATEX;
@@ -1422,7 +1422,7 @@ static void findAdvReplace(BufferView * bv,
FindAndReplaceOptions const & opt, M
sel_len = repl_buffer.paragraphs().begin()->size();
} else if (cur.inMathed()) {
odocstringstream ods;
- otexstream os(ods, false);
+ otexstream os(ods);
OutputParams runparams(&repl_buffer.params().encoding());
runparams.nice = false;
runparams.flavor = OutputParams::LATEX;
diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp
index 87952f5..2fb1ff5 100644
--- a/src/mathed/InsetMath.cpp
+++ b/src/mathed/InsetMath.cpp
@@ -53,7 +53,7 @@ void InsetMath::dump() const
{
lyxerr << "---------------------------------------------" << endl;
odocstringstream os;
- otexrowstream ots(os, false);
+ otexrowstream ots(os);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi);
lyxerr << to_utf8(os.str());
@@ -157,7 +157,7 @@ HullType InsetMath::getType() const
ostream & operator<<(ostream & os, MathAtom const & at)
{
odocstringstream oss;
- otexrowstream ots(oss, false);
+ otexrowstream ots(oss);
WriteStream wi(ots, false, false, WriteStream::wsDefault);
at->write(wi);
return os << to_utf8(oss.str());
@@ -166,7 +166,7 @@ ostream & operator<<(ostream & os, MathAtom const & at)
odocstream & operator<<(odocstream & os, MathAtom const & at)
{
- otexrowstream ots(os, false);
+ otexrowstream ots(os);
WriteStream wi(ots, false, false, WriteStream::wsDefault);
at->write(wi);
return os;
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 5dffc3d..c4f1207 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -615,7 +615,7 @@ void InsetMathHull::metricsT(TextMetricsInfo const & mi,
Dimension & dim) const
InsetMathGrid::metricsT(mi, dim);
} else {
odocstringstream os;
- otexrowstream ots(os, false);
+ otexrowstream ots(os);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi);
dim.wid = os.str().size();
@@ -631,7 +631,7 @@ void InsetMathHull::drawT(TextPainter & pain, int x, int y)
const
InsetMathGrid::drawT(pain, x, y);
} else {
odocstringstream os;
- otexrowstream ots(os, false);
+ otexrowstream ots(os);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi);
pain.draw(x, y, os.str().c_str());
@@ -650,7 +650,7 @@ static docstring latexString(InsetMathHull const & inset)
static Encoding const * encoding = 0;
if (inset.isBufferValid())
encoding = &(inset.buffer().params().encoding());
- otexrowstream ots(ls, false);
+ otexrowstream ots(ls);
WriteStream wi(ots, false, true, WriteStream::wsPreview, encoding);
inset.write(wi);
return ls.str();
@@ -2180,7 +2180,7 @@ bool InsetMathHull::searchForward(BufferView * bv, string
const & str,
void InsetMathHull::write(ostream & os) const
{
odocstringstream oss;
- otexrowstream ots(oss, false);
+ otexrowstream ots(oss);
WriteStream wi(ots, false, false, WriteStream::wsDefault);
oss << "Formula ";
write(wi);
@@ -2223,7 +2223,7 @@ int InsetMathHull::plaintext(odocstringstream & os,
}
odocstringstream oss;
- otexrowstream ots(oss, false);
+ otexrowstream ots(oss);
Encoding const * const enc = encodings.fromLyXName("utf8");
WriteStream wi(ots, false, true, WriteStream::wsDefault, enc);
@@ -2532,7 +2532,7 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs,
OutputParams const & op) const
// Unfortunately, we cannot use latexString() because we do not
want
// $...$ or whatever.
odocstringstream ls;
- otexrowstream ots(ls, false);
+ otexrowstream ots(ls);
WriteStream wi(ots, false, true, WriteStream::wsPreview);
ModeSpecifier specifier(wi, MATH_MODE);
mathAsLatex(wi);
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 4216145..ee3b92d 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -252,7 +252,7 @@ bool InsetMathNest::idxLast(Cursor & cur) const
void InsetMathNest::dump() const
{
odocstringstream oss;
- otexrowstream ots(oss, false);
+ otexrowstream ots(oss);
WriteStream os(ots);
os << "---------------------------------------------\n";
write(os);
diff --git a/src/mathed/MacroTable.cpp b/src/mathed/MacroTable.cpp
index 5f43fa7..5a61a8b 100644
--- a/src/mathed/MacroTable.cpp
+++ b/src/mathed/MacroTable.cpp
@@ -200,7 +200,7 @@ int MacroData::write(odocstream & os, bool
overwriteRedefinition) const
// output template
MathMacroTemplate const & tmpl =
static_cast<MathMacroTemplate const &>(*inset);
- otexrowstream ots(os, false);
+ otexrowstream ots(os);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
return tmpl.write(wi, overwriteRedefinition);
}
diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp
index 478d22a..bb7be8b 100644
--- a/src/mathed/MathFactory.cpp
+++ b/src/mathed/MathFactory.cpp
@@ -689,7 +689,7 @@ bool createInsetMath_fromDialogStr(docstring const & str,
MathData & ar)
InsetSpace::string2params(to_utf8(str), isp);
InsetSpace is(isp);
odocstringstream ods;
- otexstream os(ods, false);
+ otexstream os(ods);
Encoding const * const ascii = encodings.fromLyXName("ascii");
OutputParams op(ascii);
is.latex(os, op);
diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp
index 31250e2..5fbba55 100644
--- a/src/mathed/MathMacroTemplate.cpp
+++ b/src/mathed/MathMacroTemplate.cpp
@@ -1172,7 +1172,7 @@ void MathMacroTemplate::read(Lexer & lex)
void MathMacroTemplate::write(ostream & os) const
{
odocstringstream oss;
- otexrowstream ots(oss, false);
+ otexrowstream ots(oss);
WriteStream wi(ots, false, false, WriteStream::wsDefault);
oss << "FormulaMacro\n";
write(wi);
diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp
index 42f7376..5c3e84f 100644
--- a/src/mathed/MathSupport.cpp
+++ b/src/mathed/MathSupport.cpp
@@ -919,7 +919,7 @@ bool isAlphaSymbol(MathAtom const & at)
docstring asString(MathData const & ar)
{
odocstringstream os;
- otexrowstream ots(os, false);
+ otexrowstream ots(os);
WriteStream ws(ots);
ws << ar;
return os.str();
@@ -937,7 +937,7 @@ void asArray(docstring const & str, MathData & ar,
Parse::flags pf)
docstring asString(InsetMath const & inset)
{
odocstringstream os;
- otexrowstream ots(os, false);
+ otexrowstream ots(os);
WriteStream ws(ots);
inset.write(ws);
return os.str();
@@ -947,7 +947,7 @@ docstring asString(InsetMath const & inset)
docstring asString(MathAtom const & at)
{
odocstringstream os;
- otexrowstream ots(os, false);
+ otexrowstream ots(os);
WriteStream ws(ots);
at->write(ws);
return os.str();
diff --git a/src/texstream.cpp b/src/texstream.cpp
index ec8158d..e312d2c 100644
--- a/src/texstream.cpp
+++ b/src/texstream.cpp
@@ -33,8 +33,8 @@ using lyx::support::split;
namespace lyx {
-otexrowstream::otexrowstream(odocstream & os, bool enable)
- : os_(os), texrow_(make_unique<TexRow>(enable))
+otexrowstream::otexrowstream(odocstream & os)
+ : os_(os), texrow_(make_unique<TexRow>())
{}
diff --git a/src/texstream.h b/src/texstream.h
index 2c8299f..53040d1 100644
--- a/src/texstream.h
+++ b/src/texstream.h
@@ -31,7 +31,7 @@ class otexstringstream;
class otexrowstream {
public:
///
- explicit otexrowstream(odocstream & os, bool enable = true);
+ explicit otexrowstream(odocstream & os);
/// defaulted
~otexrowstream();
///
@@ -79,8 +79,8 @@ otexrowstream & operator<<(otexrowstream & ots, Type value);
class otexstream : public otexrowstream {
public:
///
- explicit otexstream(odocstream & os, bool enable = true)
- : otexrowstream(os, enable), canbreakline_(false),
+ explicit otexstream(odocstream & os)
+ : otexrowstream(os), canbreakline_(false),
protectspace_(false), parbreak_(true), lastchar_(0) {}
///
void put(char_type const & c);