#include "PDFOptions.h"
#include "SpellChecker.h"
#include "sgml.h"
+#include "texstream.h"
#include "TexRow.h"
#include "Text.h"
#include "TextClass.h"
ErrorList & errorList = d->errorLists["Export"];
errorList.clear();
bool failed_export = false;
- otexstream os(ofs, d->texrow);
+ otexstream os(ofs);
// make sure we are ready to export
// this needs to be done before we validate
updateMacroInstances(OutputUpdate);
try {
- os.texrow().reset();
writeLaTeXSource(os, original_path, runparams, output);
}
catch (EncodingException const & e) {
lyx_exit(1);
}
+ d->texrow = move(os.texrow());
+
ofs.close();
if (ofs.fail()) {
failed_export = true;
LaTeXFeatures features(*this, params(), runparams);
params().validate(features);
runparams.use_polyglossia = features.usePolyglossia();
- texrow = make_unique<TexRow>();
- texrow->newline();
- texrow->newline();
// latex or literate
- otexstream ots(os, *texrow);
-
+ otexstream ots(os);
+ // output above
+ ots.texrow().newlines(2);
// the real stuff
latexParagraphs(*this, text(), ots, runparams);
+ texrow = ots.releaseTexRow();
texrow->finalize();
// Restore the parenthood
writeDocBookSource(os, absFileName(), runparams, output);
} else {
// latex or literate
- texrow = make_unique<TexRow>();
- texrow->newline();
- texrow->newline();
- otexstream ots(os, *texrow);
+ otexstream ots(os);
+ // output above
+ ots.texrow().newlines(2);
if (master)
runparams.is_child = true;
writeLaTeXSource(ots, string(), runparams, output);
+ texrow = ots.releaseTexRow();
texrow->finalize();
}
}
#define BUFFER_H
#include "OutputEnums.h"
-#include "OutputParams.h"
#include "support/unique_ptr.h"
#include "support/strfwd.h"
class MacroNameSet;
class MacroSet;
class OutputParams;
+class otexstream;
class Paragraph;
class ParConstIterator;
class ParIterator;
method with a string stream if the output is supposed to go to a
file. \code
ofdocstream ofs;
- otexstream os(ofs, texrow);
+ otexstream os(ofs);
ofs.open("test.tex");
writeLaTeXSource(os, ...);
ofs.close();
\endcode is NOT equivalent to \code
odocstringstream oss;
- otexstream os(oss, texrow);
+ otexstream os(oss);
writeLaTeXSource(os, ...);
ofdocstream ofs;
ofs.open("test.tex");
#include "LyXRC.h"
#include "OutputParams.h"
#include "Spacing.h"
+#include "texstream.h"
#include "TexRow.h"
#include "VSpace.h"
#include "PDFOptions.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "Paragraph.h"
+#include "texstream.h"
#include "TocBackend.h"
#include "support/debug.h"
#include "support/types.h"
#include "support/lyxtime.h"
-#include "texstream.h"
-
#include <vector>
class Buffer;
class DocIterator;
class OutputParams;
+class otexstream;
class PainterInfo;
class FontInfo;
+
class Change {
public:
/// the type of change
#include "insets/InsetText.h"
+#include "support/docstream.h"
#include "support/lassert.h"
#include "support/lyxalgo.h"
#include "support/qstring_helpers.h"
class ErrorList;
class Format;
class Formats;
-class OutputParams;
///
#include "Paragraph.h"
#include "ParIterator.h"
#include "Row.h"
+#include "texstream.h"
#include "Text.h"
#include "TextMetrics.h"
#include "TocBackend.h"
<< pos() << ' ' << lastpos() << " in idx: " << idx()
<< " in atom: '";
odocstringstream os;
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os, false);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
inset().asInsetMath()->write(wi);
lyxerr << to_utf8(os.str()) << endl;
#include "LyXRC.h"
#include "output_latex.h"
#include "OutputParams.h"
+#include "texstream.h"
#include "support/lassert.h"
#include "support/convert.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/mutex.h"
+#include "support/docstream.h"
#include "support/os.h"
#include "support/PathChanger.h"
#include "support/Systemcall.h"
#include "support/convert.h"
#include "support/debug.h"
+#include "support/docstream.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/gettext.h"
#include "Encoding.h"
#include "Lexer.h"
+#include "texstream.h"
#include "support/convert.h"
#include "support/debug.h"
#include "ParagraphParameters.h"
#include "SpellChecker.h"
#include "sgml.h"
+#include "texstream.h"
#include "TextClass.h"
#include "TexRow.h"
#include "Text.h"
BufferParams const & bp = features.runparams().is_child
? buf.masterParams() : buf.params();
Font f;
- TexRow texrow;
// Using a string stream here circumvents the encoding
// switching machinery of odocstream. Therefore the
// output is wrong if this paragraph contains content
// that needs to switch encoding.
odocstringstream ods;
- otexstream os(ods, texrow);
+ otexstream os(ods, false);
if (is_command) {
os << '\\' << from_ascii(layout_->latexname());
// we have to provide all the optional arguments here, even though
}
-TexRow::TextEntry TexRow::RowEntryList::getTextEntry() const
+TextEntry TexRow::RowEntryList::getTextEntry() const
{
if (text_entry_ < size())
return operator[](text_entry_).text;
}
-TexRow::RowEntry TexRow::RowEntryList::entry() const
+RowEntry TexRow::RowEntryList::entry() const
{
if (0 < size())
return operator[](0);
}
-TexRow::TextEntry const TexRow::text_none = { -1, 0 };
-TexRow::RowEntry const TexRow::row_none = { false, { TexRow::text_none } };
+TextEntry const TexRow::text_none = { -1, 0 };
+RowEntry const TexRow::row_none = { false, { TexRow::text_none } };
bool TexRow::isNone(TextEntry const & t)
}
-TexRow::RowEntry TexRow::textEntry(int id, int pos)
+RowEntry TexRow::textEntry(int id, int pos)
{
RowEntry entry;
entry.is_math = false;
}
-TexRow::RowEntry TexRow::mathEntry(uid_type id, idx_type cell)
+RowEntry TexRow::mathEntry(uid_type id, idx_type cell)
{
RowEntry entry;
entry.is_math = true;
}
-bool operator==(TexRow::RowEntry const & entry1,
- TexRow::RowEntry const & entry2)
+bool operator==(RowEntry const & entry1,
+ RowEntry const & entry2)
{
return entry1.is_math == entry2.is_math
&& (entry1.is_math
}
-TexRow::RowEntry TexRow::rowEntryFromCursorSlice(CursorSlice const & slice)
+RowEntry TexRow::rowEntryFromCursorSlice(CursorSlice const & slice)
{
RowEntry entry;
InsetMath * insetMath = slice.asInsetMath();
// matches either at a deeper level, or at the same level but not
// before.
for (size_t i = best_slice; i < n; ++i) {
- TexRow::RowEntry entry_i = rowEntryFromCursorSlice(dit[i]);
+ RowEntry entry_i = rowEntryFromCursorSlice(dit[i]);
if (sameParOrInsetMath(*it, entry_i)) {
if (comparePos(*it, entry_i) >= 0
&& (i > best_slice
typedef size_t idx_type;
+/// an individual par id/pos <=> row mapping
+struct TextEntry { int id; int pos; };
+
+/// an individual math id/cell <=> row mapping
+struct MathEntry { uid_type id; idx_type cell; };
+
+/// a container for passing entries around
+struct RowEntry {
+ bool is_math;// true iff the union is a math
+ union {
+ struct TextEntry text;
+ struct MathEntry math;
+ };
+};
+
+
/// Represents the correspondence between paragraphs and the generated
/// LaTeX file
class TexRow {
public:
- /// an individual par id/pos <=> row mapping
- struct TextEntry { int id; int pos; };
-
- /// an individual math id/cell <=> row mapping
- struct MathEntry { uid_type id; idx_type cell; };
-
- /// a container for passing entries around
- struct RowEntry {
- bool is_math;// true iff the union is a math
- union {
- struct TextEntry text;
- struct MathEntry math;
- };
- };
-
// For each row we store a list of one special TextEntry and several
// RowEntries. (The order is important.) We only want one text entry
// because we do not want to store every position in the lyx file. On the
bool enabled_;
};
-bool operator==(TexRow::RowEntry const &, TexRow::RowEntry const &);
+bool operator==(RowEntry const &, RowEntry const &);
LyXErr & operator<<(LyXErr &, TexRow &);
#include "frontends/alert.h"
#include "support/debug.h"
+#include "support/docstream.h"
#include "support/filetools.h"
#include "support/FileName.h"
#include "support/gettext.h"
#include "Cursor.h"
#include "Format.h"
#include "Paragraph.h"
+#include "TexRow.h"
#include "support/debug.h"
#include "support/lassert.h"
#include "Buffer.h"
#include "DockView.h"
-#include "TexRow.h"
#include <QDockWidget>
#include <QString>
#include <QTimer>
+
class QTextDocument;
+
namespace lyx {
+
+class TexRow;
+
+
namespace frontend {
class GuiViewSource;
class LaTeXHighlighter;
+
class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
{
Q_OBJECT
#include "output.h"
#include "OutputParams.h"
#include "TexRow.h"
+#include "texstream.h"
#include "frontends/Application.h" // hexName
return;
}
- TexRow texrow;
- otexstream os(of, texrow);
+ otexstream os(of);
OutputParams runparams(&enc);
LaTeXFeatures features(buffer_, buffer_.params(), runparams);
#include "Format.h"
#include "support/debug.h"
+#include "support/docstream.h"
#include "support/filetools.h"
#include "support/FileName.h"
#include "support/regex.h"
#include "Exporter.h"
#include "Format.h"
#include "Mover.h"
+#include "texstream.h"
#include "frontends/alert.h"
#ifndef EXTERNALSUPPORT_H
#define EXTERNALSUPPORT_H
-#include "texstream.h"
+#include <string>
+
namespace lyx {
class Buffer;
class ExportData;
class InsetExternalParams;
+class otexstream;
namespace external {
#include "Lexer.h"
#include "OutputParams.h"
#include "ParIterator.h"
+#include "TexRow.h"
+#include "texstream.h"
#include "support/convert.h"
#include "support/debug.h"
OutputParams const & runparams_in, docstring const & ldelim,
docstring const & rdelim, docstring const & presetarg) const
{
- TexRow texrow;
odocstringstream ss;
- otexstream ots(ss, texrow);
+ otexstream ots(ss);
OutputParams runparams = runparams_in;
if (!pass_thru_chars_.empty())
runparams.pass_thru_chars += pass_thru_chars_;
str = presetarg + sep + str;
if (ldelim != "{" && support::contains(str, rdelim))
str = '{' + str + '}';
+ // TODO: append texrow information
os << ldelim << str << rdelim;
}
#include "output_xhtml.h"
#include "OutputParams.h"
#include "PDFOptions.h"
+#include "texstream.h"
#include "TextClass.h"
#include "frontends/alert.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "output_xhtml.h"
+#include "TexRow.h"
+#include "texstream.h"
#include "TextClass.h"
#include "support/debug.h"
#include "OutputParams.h"
#include "Paragraph.h"
#include "ParIterator.h"
+#include "TexRow.h"
+#include "texstream.h"
#include "TextClass.h"
#include "TextMetrics.h"
#include "TocBackend.h"
#include "LaTeXFeatures.h"
#include "output_xhtml.h"
#include "ParIterator.h"
+#include "texstream.h"
#include "TocBackend.h"
#include "support/debug.h"
#include "FuncStatus.h"
#include "Lexer.h"
#include "MetricsInfo.h"
+#include "texstream.h"
#include "insets/InsetBox.h"
#include "insets/InsetBranch.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "output_latex.h"
+#include "texstream.h"
#include "TocBackend.h"
#include "frontends/alert.h"
static docstring latexString(InsetExternal const & inset)
{
- TexRow texrow;
odocstringstream ods;
- otexstream os(ods, texrow);
+ otexstream os(ods, false);
// We don't need to set runparams.encoding since it is not used by
// latex().
OutputParams runparams(0);
if (runparams.for_tooltip)
return 0;
- TexRow texrow;
- otexstream ots(os, texrow);
+ otexstream ots(os, false);
ots << '\n'; // output external material on a new line
external::writeExternal(params_, "Ascii", buffer(), ots,
*(runparams.exportdata), false,
int InsetExternal::docbook(odocstream & os,
OutputParams const & runparams) const
{
- TexRow texrow;
odocstringstream ods;
- otexstream ots(ods, texrow);
+ otexstream ots(ods, false);
external::writeExternal(params_, "DocBook", buffer(), ots,
*(runparams.exportdata), false,
runparams.dryrun || runparams.inComment);
#include "Lexer.h"
#include "output_xhtml.h"
#include "ParIterator.h"
+#include "TexRow.h"
+#include "texstream.h"
#include "TextClass.h"
#include "support/debug.h"
docstring InsetFloat::getCaption(OutputParams const & runparams) const
{
- TexRow texrow(false);
odocstringstream ods;
- otexstream os(ods, texrow);
+ otexstream os(ods, false);
getCaption(os, runparams);
return ods.str();
}
ins->getArgs(os, runparams);
os << '[';
- TexRow texrow;
odocstringstream ods;
- otexstream oss(ods, texrow);
+ otexstream oss(ods);
ins->getArgument(oss, runparams);
docstring arg = ods.str();
// Protect ']'
if (arg.find(']') != docstring::npos)
arg = '{' + arg + '}';
- os.append(arg, texrow);
+ os.append(arg, move(oss.texrow()));
os << ']';
}
#include "Lexer.h"
#include "Paragraph.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "TextClass.h"
#include "TocBackend.h"
#include "OutputParams.h"
#include "output_xhtml.h"
#include "sgml.h"
+#include "texstream.h"
#include "TocBackend.h"
#include "frontends/alert.h"
#include "LaTeXFeatures.h"
#include "OutputParams.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "support/docstream.h"
#include "support/FileName.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "RenderPreview.h"
+#include "texstream.h"
#include "frontends/Painter.h"
void InsetIPA::preparePreview(DocIterator const & pos) const
{
- TexRow texrow;
- odocstringstream str;
- otexstream os(str, texrow);
+ odocstringstream str;
+ otexstream os(str, false);
OutputParams runparams(&pos.buffer()->params().encoding());
latex(os, runparams);
docstring const snippet = str.str();
#include "Lexer.h"
#include "MetricsInfo.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include "output_plaintext.h"
#include "output_xhtml.h"
#include "OutputParams.h"
+#include "texstream.h"
#include "TextClass.h"
#include "TocBackend.h"
docstring latexString(InsetInclude const & inset)
{
- TexRow texrow;
odocstringstream ods;
- otexstream os(ods, texrow);
+ otexstream os(ods, false);
// We don't need to set runparams.encoding since this will be done
// by latex() anyway.
OutputParams runparams(0);
#include "output_latex.h"
#include "output_xhtml.h"
#include "sgml.h"
+#include "texstream.h"
#include "TextClass.h"
#include "TocBackend.h"
}
// get contents of InsetText as LaTeX and plaintext
- TexRow texrow;
odocstringstream ourlatex;
- otexstream ots(ourlatex, texrow);
+ otexstream ots(ourlatex);
InsetText::latex(ots, runparams);
odocstringstream ourplain;
InsetText::plaintext(ourplain, runparams);
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "Text.h"
#include "frontends/FontMetrics.h"
#include "output_xhtml.h"
#include "OutputParams.h"
#include "TextClass.h"
+#include "texstream.h"
#include "support/debug.h"
#include "support/docstream.h"
if (ins == 0)
return docstring();
- TexRow texrow;
odocstringstream ods;
- otexstream os(ods, texrow);
+ otexstream os(ods, false);
ins->getArgs(os, runparams);
ins->getArgument(os, runparams);
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "frontends/Application.h"
#include "frontends/FontMetrics.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "Text.h"
#include "TextMetrics.h"
#include "OutputParams.h"
#include "output_xhtml.h"
#include "sgml.h"
+#include "texstream.h"
#include "TocBackend.h"
#include "frontends/FontMetrics.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
+#include "texstream.h"
#include "TextClass.h"
#include "support/docstream.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "RenderPreview.h"
+#include "texstream.h"
#include "frontends/Painter.h"
void InsetPreview::preparePreview(DocIterator const & pos) const
{
- TexRow texrow;
odocstringstream str;
- otexstream os(str, texrow);
+ otexstream os(str, false);
OutputParams runparams(&pos.buffer()->params().encoding());
latex(os, runparams);
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include "output_xhtml.h"
#include "ParIterator.h"
#include "sgml.h"
+#include "texstream.h"
#include "TocBackend.h"
#include "support/debug.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "frontends/Application.h"
#include "frontends/FontMetrics.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "support/debug.h"
#include "support/docstream.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include "Paragraph.h"
#include "ParagraphParameters.h"
#include "ParIterator.h"
+#include "TexRow.h"
+#include "texstream.h"
#include "TextClass.h"
#include "TextMetrics.h"
void Tabular::latex(otexstream & os, OutputParams const & runparams) const
{
bool const is_tabular_star = !tabular_width.zero();
- TexRow::RowEntry pos = TexRow::textEntry(runparams.lastid,
- runparams.lastpos);
+ RowEntry pos = TexRow::textEntry(runparams.lastid, runparams.lastpos);
//+---------------------------------------------------------------------
//+ first the opening preamble +
#include "Row.h"
#include "sgml.h"
#include "TexRow.h"
+#include "texstream.h"
#include "TextClass.h"
#include "Text.h"
#include "TextMetrics.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "Text.h"
#include "support/debug.h"
#include "LaTeXFeatures.h"
#include "Lexer.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "TextClass.h"
#include "support/debug.h"
static docstring buffer_to_latex(Buffer & buffer)
{
OutputParams runparams(&buffer.params().encoding());
- TexRow texrow(false);
odocstringstream ods;
- otexstream os(ods, texrow);
+ otexstream os(ods, false);
runparams.nice = true;
runparams.flavor = OutputParams::LATEX;
runparams.linelen = 80; //lyxrc.plaintext_linelen;
Buffer const & buf = *cur.buffer();
LBUFERR(buf.params().isLatex());
- TexRow texrow(false);
odocstringstream ods;
- otexstream os(ods, texrow);
+ otexstream os(ods, false);
OutputParams runparams(&buf.params().encoding());
runparams.nice = false;
runparams.flavor = OutputParams::LATEX;
LYXERR(Debug::FIND, "After pasteParagraphList() cur=" << cur << endl);
sel_len = repl_buffer.paragraphs().begin()->size();
} else if (cur.inMathed()) {
- TexRow texrow(false);
odocstringstream ods;
- otexstream os(ods, texrow);
+ otexstream os(ods, false);
OutputParams runparams(&repl_buffer.params().encoding());
runparams.nice = false;
runparams.flavor = OutputParams::LATEX;
{
lyxerr << "---------------------------------------------" << endl;
odocstringstream os;
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os, false);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi);
lyxerr << to_utf8(os.str());
ostream & operator<<(ostream & os, MathAtom const & at)
{
odocstringstream oss;
- TexRow texrow(false);
- otexrowstream ots(oss,texrow);
+ otexrowstream ots(oss, false);
WriteStream wi(ots, false, false, WriteStream::wsDefault);
at->write(wi);
return os << to_utf8(oss.str());
odocstream & operator<<(odocstream & os, MathAtom const & at)
{
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os, false);
WriteStream wi(ots, false, false, WriteStream::wsDefault);
at->write(wi);
return os;
#include "insets/Inset.h"
-#include "TexRow.h"
-
namespace lyx {
class TextMetricsInfo;
class ReplaceData;
+/// Type of unique identifiers for math insets (used in TexRow)
+typedef void const * uid_type;
+
class InsetMath : public Inset {
public:
#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
-#include "CutAndPaste.h"
-#include "FuncStatus.h"
#include "Cursor.h"
+#include "CutAndPaste.h"
#include "FuncRequest.h"
+#include "FuncStatus.h"
+#include "TexRow.h"
#include "frontends/Clipboard.h"
#include "frontends/Painter.h"
for (col_type col = beg_col; col < end_col;) {
int nccols = 1;
idx_type const idx = index(row, col);
- TexRow::RowEntry entry = os.texrow().mathEntry(id(),idx);
- os.texrow().startMath(id(),idx);
+ RowEntry entry = TexRow::mathEntry(id(),idx);
+ os.texrow().start(entry);
if (col >= lastcol) {
++col;
continue;
#include "Paragraph.h"
#include "ParIterator.h"
#include "sgml.h"
+#include "TexRow.h"
#include "TextClass.h"
#include "TextPainter.h"
#include "TocBackend.h"
InsetMathGrid::metricsT(mi, dim);
} else {
odocstringstream os;
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os, false);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi);
dim.wid = os.str().size();
InsetMathGrid::drawT(pain, x, y);
} else {
odocstringstream os;
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os, false);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi);
pain.draw(x, y, os.str().c_str());
static Encoding const * encoding = 0;
if (inset.isBufferValid())
encoding = &(inset.buffer().params().encoding());
- TexRow texrow(false);
- otexrowstream ots(ls,texrow);
+ otexrowstream ots(ls, false);
WriteStream wi(ots, false, true, WriteStream::wsPreview, encoding);
inset.write(wi);
return ls.str();
void InsetMathHull::write(ostream & os) const
{
odocstringstream oss;
- TexRow texrow(false);
- otexrowstream ots(oss,texrow);
+ otexrowstream ots(oss, false);
WriteStream wi(ots, false, false, WriteStream::wsDefault);
oss << "Formula ";
write(wi);
}
odocstringstream oss;
- TexRow texrow(false);
- otexrowstream ots(oss,texrow);
+ otexrowstream ots(oss, false);
Encoding const * const enc = encodings.fromLyXName("utf8");
WriteStream wi(ots, false, true, WriteStream::wsDefault, enc);
++ms.tab(); ms.cr(); ms.os() << '<' << bname << '>';
odocstringstream ls;
- TexRow texrow;
- otexstream ols(ls, texrow);
+ otexstream ols(ls);
if (runparams.flavor == OutputParams::XML) {
ms << MTag("alt role='tex' ");
// Workaround for db2latex: db2latex always includes equations with
} else {
ms << MTag("alt role='tex'");
latex(ols, runparams);
- res = texrow.rows();
+ res = ols.texrow().rows();
ms << from_utf8(subst(subst(to_utf8(ls.str()), "&", "&"), "<", "<"));
ms << ETag("alt");
}
// Unfortunately, we cannot use latexString() because we do not want
// $...$ or whatever.
odocstringstream ls;
- TexRow texrow(false);
- otexrowstream ots(ls,texrow);
+ otexrowstream ots(ls, false);
WriteStream wi(ots, false, true, WriteStream::wsPreview);
ModeSpecifier specifier(wi, MATH_MODE);
mathAsLatex(wi);
#include "LyXRC.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
+#include "TexRow.h"
#include "Text.h"
#include "frontends/Application.h"
void InsetMathNest::dump() const
{
odocstringstream oss;
- TexRow texrow(false);
- otexrowstream ots(oss,texrow);
+ otexrowstream ots(oss, false);
WriteStream os(ots);
os << "---------------------------------------------\n";
write(os);
runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
runparams.encoding);
wi.canBreakLine(os.canBreakLine());
- Changer dummy = wi.changeRowEntry(os.texrow().textEntry(runparams.lastid,
- runparams.lastpos));
+ Changer dummy = wi.changeRowEntry(TexRow::textEntry(runparams.lastid,
+ runparams.lastpos));
write(wi);
// Reset parbreak status after a math inset.
os.lastChar(0);
// output template
MathMacroTemplate const & tmpl =
static_cast<MathMacroTemplate const &>(*inset);
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os, false);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
return tmpl.write(wi, overwriteRedefinition);
}
#include "LyX.h" // use_gui
#include "OutputParams.h"
+
using namespace std;
using namespace lyx::support;
InsetSpaceParams isp(true);
InsetSpace::string2params(to_utf8(str), isp);
InsetSpace is(isp);
- TexRow texrow;
odocstringstream ods;
- otexstream os(ods, texrow);
+ otexstream os(ods, false);
Encoding const * const ascii = encodings.fromLyXName("ascii");
OutputParams op(ascii);
is.latex(os, op);
void MathMacroTemplate::write(ostream & os) const
{
odocstringstream oss;
- TexRow texrow(false);
- otexrowstream ots(oss,texrow);
+ otexrowstream ots(oss, false);
WriteStream wi(ots, false, false, WriteStream::wsDefault);
oss << "FormulaMacro\n";
write(wi);
#include "MathData.h"
#include "MathExtern.h"
+#include "TexRow.h"
+
#include "support/docstring.h"
#include "support/RefChanger.h"
#include "support/textutils.h"
: 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), row_entry_(TexRow::row_none)
+ line_(0), encoding_(encoding),
+ row_entry_(make_unique<RowEntry>(TexRow::row_none))
{}
}
-Changer WriteStream::changeRowEntry(TexRow::RowEntry entry)
+Changer WriteStream::changeRowEntry(RowEntry entry)
{
- return make_change(row_entry_, entry);
+ return make_change(*row_entry_, entry);
}
bool WriteStream::startOuterRow()
{
- if (TexRow::isNone(row_entry_))
+ if (TexRow::isNone(*row_entry_))
return false;
- return texrow().start(row_entry_);
+ return texrow().start(*row_entry_);
}
#include "support/Changer.h"
#include "support/strfwd.h"
+#include "support/unique_ptr.h"
namespace lyx {
class InsetMath;
class MathAtom;
class MathData;
+class RowEntry;
//
// LaTeX/LyX
Encoding const * encoding() const { return encoding_; }
/// Temporarily change the TexRow information about the outer row entry.
- Changer changeRowEntry(TexRow::RowEntry entry);
+ Changer changeRowEntry(RowEntry entry);
/// TexRow::starts the innermost outer math inset
/// returns true if the outer row entry will appear at this line
bool startOuterRow();
///
Encoding const * encoding_;
/// Row entry we are in
- TexRow::RowEntry row_entry_;
+ /// (it is a pointer to allow forward-declaration)
+ unique_ptr<RowEntry> row_entry_;
};
///
docstring asString(MathData const & ar)
{
odocstringstream os;
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os, false);
WriteStream ws(ots);
ws << ar;
return os.str();
docstring asString(InsetMath const & inset)
{
odocstringstream os;
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os, false);
WriteStream ws(ots);
inset.write(ws);
return os.str();
docstring asString(MathAtom const & at)
{
odocstringstream os;
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os, false);
WriteStream ws(ots);
at->write(ws);
return os.str();
#include "OutputParams.h"
#include "Paragraph.h"
#include "ParagraphParameters.h"
+#include "texstream.h"
#include "TextClass.h"
#include "insets/InsetBibitem.h"
}
-//
-// Dummy TexRow support (needed by docstream)
-//
-
-
-void TexRow::newline()
-{}
-
-
-void TexRow::newlines(int)
-{}
-
-
//
// Dummy LyXRC support
//
#include <config.h>
#include "texstream.h"
+
+#include "TexRow.h"
+
#include "support/lstrings.h"
#include "support/unicode.h"
namespace lyx {
-void otexrowstream::append(docstring const & str, TexRow const & texrow)
+otexrowstream::otexrowstream(odocstream & os, bool enable)
+ : os_(os), texrow_(make_unique<TexRow>(enable))
+{}
+
+
+otexrowstream::~otexrowstream() = default;
+
+
+unique_ptr<TexRow> && otexrowstream::releaseTexRow()
+{
+ auto p = make_unique<TexRow>();
+ swap(texrow_, p);
+ return move(p);
+}
+
+
+void otexrowstream::append(docstring const & str, TexRow texrow)
{
os_ << str;
- texrow_.append(texrow);
+ texrow_->append(move(texrow));
}
{
os_.put(c);
if (c == '\n')
- texrow_.newline();
+ texrow_->newline();
}
#ifndef LYX_TEXSTREAM_H
#define LYX_TEXSTREAM_H
-#include "TexRow.h"
#include "support/docstream.h"
+#include "support/unique_ptr.h"
namespace lyx {
+class TexRow;
+
+
+// declared below
+class otexstringstream;
+
/** Wrapper class for odocstream.
This class is used to automatically count the lines of the exported latex
code.
class otexrowstream {
public:
///
- otexrowstream(odocstream & os, TexRow & texrow)
- : os_(os), texrow_(texrow) {}
+ explicit otexrowstream(odocstream & os, bool enable = true);
+ /// defaulted
+ ~otexrowstream();
///
odocstream & os() { return os_; }
///
- TexRow & texrow() { return texrow_; }
+ TexRow & texrow() { return *texrow_; }
+ ///
+ unique_ptr<TexRow> && releaseTexRow();
///
void put(char_type const & c);
///
- void append(docstring const &, TexRow const &);
+ void append(docstring const & str, TexRow texrow);
private:
///
odocstream & os_;
///
- TexRow & texrow_;
+ unique_ptr<TexRow> texrow_;
};
///
class otexstream : public otexrowstream {
public:
///
- otexstream(odocstream & os, TexRow & texrow)
- : otexrowstream(os, texrow), canbreakline_(false),
+ explicit otexstream(odocstream & os, bool enable = true)
+ : otexrowstream(os, enable), canbreakline_(false),
protectspace_(false), parbreak_(true), lastchar_(0) {}
///
void put(char_type const & c);
template <typename Type>
otexstream & operator<<(otexstream & ots, Type value);
+
}
#endif