mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Simplify the TexRow information for mathed output
Replace the manual manipulation of a stack of RowEntries with a Changer function. When I introduced the stack of RowEntries, I did not know about the Changer mechanism.
This commit is contained in:
parent
348e0241af
commit
d2d243d77f
@ -34,7 +34,6 @@
|
||||
#include "support/docstream.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "support/lassert.h"
|
||||
|
||||
#include <sstream>
|
||||
@ -1275,7 +1274,7 @@ void InsetMathGrid::write(WriteStream & os,
|
||||
++col;
|
||||
continue;
|
||||
}
|
||||
os.pushRowEntry(entry);
|
||||
Changer dummy = os.changeRowEntry(entry);
|
||||
if (cellinfo_[idx].multi_ == CELL_BEGIN_OF_MULTICOLUMN) {
|
||||
size_t s = col + 1;
|
||||
while (s < ncols() &&
|
||||
@ -1293,7 +1292,6 @@ void InsetMathGrid::write(WriteStream & os,
|
||||
os << '}';
|
||||
os << eocString(col + nccols - 1, lastcol);
|
||||
col += nccols;
|
||||
os.popRowEntry();
|
||||
}
|
||||
eol = eolString(row, os.fragile(), os.latex(), last_eoln);
|
||||
os << eol;
|
||||
|
@ -59,12 +59,12 @@
|
||||
#include "frontends/Painter.h"
|
||||
#include "frontends/Selection.h"
|
||||
|
||||
#include "support/lassert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/textutils.h"
|
||||
#include "support/docstream.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
@ -380,9 +380,8 @@ void InsetMathNest::write(WriteStream & os) const
|
||||
docstring const latex_name = name();
|
||||
os << '\\' << latex_name;
|
||||
for (size_t i = 0; i < nargs(); ++i) {
|
||||
os.pushRowEntry(TexRow::mathEntry(id(),i));
|
||||
Changer dummy = os.changeRowEntry(TexRow::mathEntry(id(),i));
|
||||
os << '{' << cell(i) << '}';
|
||||
os.popRowEntry();
|
||||
}
|
||||
if (nargs() == 0)
|
||||
os.pendingSpace(true);
|
||||
@ -408,13 +407,9 @@ void InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
|
||||
runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
|
||||
runparams.encoding);
|
||||
wi.canBreakLine(os.canBreakLine());
|
||||
if (runparams.lastid != -1) {
|
||||
wi.pushRowEntry(os.texrow().textEntry(runparams.lastid,
|
||||
runparams.lastpos));
|
||||
write(wi);
|
||||
wi.popRowEntry();
|
||||
} else
|
||||
write(wi);
|
||||
Changer dummy = wi.changeRowEntry(os.texrow().textEntry(runparams.lastid,
|
||||
runparams.lastpos));
|
||||
write(wi);
|
||||
// Reset parbreak status after a math inset.
|
||||
os.lastChar(0);
|
||||
os.canBreakLine(wi.canBreakLine());
|
||||
|
@ -15,8 +15,9 @@
|
||||
#include "MathData.h"
|
||||
#include "MathExtern.h"
|
||||
|
||||
#include "support/textutils.h"
|
||||
#include "support/docstring.h"
|
||||
#include "support/RefChanger.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
@ -123,18 +124,20 @@ WriteStream & operator<<(WriteStream & ws, docstring const & s)
|
||||
|
||||
WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex,
|
||||
OutputType output, Encoding const * encoding)
|
||||
: os_(os), fragile_(fragile), firstitem_(false), latex_(latex),
|
||||
output_(output), pendingspace_(false), pendingbrace_(false),
|
||||
textmode_(false), locked_(0), ascii_(0), canbreakline_(true),
|
||||
line_(0), encoding_(encoding)
|
||||
{}
|
||||
: WriteStream(os)
|
||||
{
|
||||
fragile_ = fragile;
|
||||
latex_ = latex;
|
||||
output_ = output;
|
||||
encoding_ = encoding;
|
||||
}
|
||||
|
||||
|
||||
WriteStream::WriteStream(otexrowstream & os)
|
||||
: os_(os), fragile_(false), firstitem_(false), latex_(false),
|
||||
output_(wsDefault), pendingspace_(false), pendingbrace_(false),
|
||||
textmode_(false), locked_(0), ascii_(0), canbreakline_(true),
|
||||
line_(0), encoding_(0)
|
||||
line_(0), encoding_(0), row_entry_(TexRow::row_none)
|
||||
{}
|
||||
|
||||
|
||||
@ -183,26 +186,17 @@ void WriteStream::asciiOnly(bool ascii)
|
||||
}
|
||||
|
||||
|
||||
void WriteStream::pushRowEntry(TexRow::RowEntry entry)
|
||||
Changer WriteStream::changeRowEntry(TexRow::RowEntry entry)
|
||||
{
|
||||
outer_row_entries_.push_back(entry);
|
||||
}
|
||||
|
||||
|
||||
void WriteStream::popRowEntry()
|
||||
{
|
||||
if (!outer_row_entries_.empty())
|
||||
outer_row_entries_.pop_back();
|
||||
return make_change(row_entry_, entry);
|
||||
}
|
||||
|
||||
|
||||
bool WriteStream::startOuterRow()
|
||||
{
|
||||
size_t n = outer_row_entries_.size();
|
||||
if (n > 0)
|
||||
return texrow().start(outer_row_entries_[n - 1]);
|
||||
else
|
||||
if (TexRow::isNone(row_entry_))
|
||||
return false;
|
||||
return texrow().start(row_entry_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,11 +12,12 @@
|
||||
#ifndef MATH_MATHMLSTREAM_H
|
||||
#define MATH_MATHMLSTREAM_H
|
||||
|
||||
#include "support/strfwd.h"
|
||||
|
||||
#include "InsetMath.h"
|
||||
#include "texstream.h"
|
||||
|
||||
#include "support/Changer.h"
|
||||
#include "support/strfwd.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
@ -87,11 +88,8 @@ public:
|
||||
/// LaTeX encoding
|
||||
Encoding const * encoding() const { return encoding_; }
|
||||
|
||||
/// maintains a stack of texrow informations about outer math insets.
|
||||
/// push an entry
|
||||
void pushRowEntry(TexRow::RowEntry entry);
|
||||
/// pop an entry
|
||||
void popRowEntry();
|
||||
/// Temporarily change the TexRow information about the outer row entry.
|
||||
Changer changeRowEntry(TexRow::RowEntry entry);
|
||||
/// TexRow::starts the innermost outer math inset
|
||||
/// returns true if the outer row entry will appear at this line
|
||||
bool startOuterRow();
|
||||
@ -122,8 +120,8 @@ private:
|
||||
int line_;
|
||||
///
|
||||
Encoding const * encoding_;
|
||||
///
|
||||
std::vector<TexRow::RowEntry> outer_row_entries_;
|
||||
/// Row entry we are in
|
||||
TexRow::RowEntry row_entry_;
|
||||
};
|
||||
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user