Rationalise includes

Modifying TexRow.h or texstream.h no longer triggers the recompilation of the
complete source tree.
This commit is contained in:
Guillaume Munch 2016-06-19 03:39:38 +01:00
parent 5e371da306
commit 670efa8f64
69 changed files with 210 additions and 157 deletions

View File

@ -57,6 +57,7 @@
#include "PDFOptions.h" #include "PDFOptions.h"
#include "SpellChecker.h" #include "SpellChecker.h"
#include "sgml.h" #include "sgml.h"
#include "texstream.h"
#include "TexRow.h" #include "TexRow.h"
#include "Text.h" #include "Text.h"
#include "TextClass.h" #include "TextClass.h"
@ -1684,7 +1685,7 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
ErrorList & errorList = d->errorLists["Export"]; ErrorList & errorList = d->errorLists["Export"];
errorList.clear(); errorList.clear();
bool failed_export = false; bool failed_export = false;
otexstream os(ofs, d->texrow); otexstream os(ofs);
// make sure we are ready to export // make sure we are ready to export
// this needs to be done before we validate // this needs to be done before we validate
@ -1694,7 +1695,6 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
updateMacroInstances(OutputUpdate); updateMacroInstances(OutputUpdate);
try { try {
os.texrow().reset();
writeLaTeXSource(os, original_path, runparams, output); writeLaTeXSource(os, original_path, runparams, output);
} }
catch (EncodingException const & e) { catch (EncodingException const & e) {
@ -1725,6 +1725,8 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
lyx_exit(1); lyx_exit(1);
} }
d->texrow = move(os.texrow());
ofs.close(); ofs.close();
if (ofs.fail()) { if (ofs.fail()) {
failed_export = true; failed_export = true;
@ -3715,14 +3717,13 @@ unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
LaTeXFeatures features(*this, params(), runparams); LaTeXFeatures features(*this, params(), runparams);
params().validate(features); params().validate(features);
runparams.use_polyglossia = features.usePolyglossia(); runparams.use_polyglossia = features.usePolyglossia();
texrow = make_unique<TexRow>();
texrow->newline();
texrow->newline();
// latex or literate // latex or literate
otexstream ots(os, *texrow); otexstream ots(os);
// output above
ots.texrow().newlines(2);
// the real stuff // the real stuff
latexParagraphs(*this, text(), ots, runparams); latexParagraphs(*this, text(), ots, runparams);
texrow = ots.releaseTexRow();
texrow->finalize(); texrow->finalize();
// Restore the parenthood // Restore the parenthood
@ -3758,13 +3759,13 @@ unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
writeDocBookSource(os, absFileName(), runparams, output); writeDocBookSource(os, absFileName(), runparams, output);
} else { } else {
// latex or literate // latex or literate
texrow = make_unique<TexRow>(); otexstream ots(os);
texrow->newline(); // output above
texrow->newline(); ots.texrow().newlines(2);
otexstream ots(os, *texrow);
if (master) if (master)
runparams.is_child = true; runparams.is_child = true;
writeLaTeXSource(ots, string(), runparams, output); writeLaTeXSource(ots, string(), runparams, output);
texrow = ots.releaseTexRow();
texrow->finalize(); texrow->finalize();
} }
} }

View File

@ -13,7 +13,6 @@
#define BUFFER_H #define BUFFER_H
#include "OutputEnums.h" #include "OutputEnums.h"
#include "OutputParams.h"
#include "support/unique_ptr.h" #include "support/unique_ptr.h"
#include "support/strfwd.h" #include "support/strfwd.h"
@ -51,6 +50,7 @@ class MacroData;
class MacroNameSet; class MacroNameSet;
class MacroSet; class MacroSet;
class OutputParams; class OutputParams;
class otexstream;
class Paragraph; class Paragraph;
class ParConstIterator; class ParConstIterator;
class ParIterator; class ParIterator;
@ -325,13 +325,13 @@ public:
method with a string stream if the output is supposed to go to a method with a string stream if the output is supposed to go to a
file. \code file. \code
ofdocstream ofs; ofdocstream ofs;
otexstream os(ofs, texrow); otexstream os(ofs);
ofs.open("test.tex"); ofs.open("test.tex");
writeLaTeXSource(os, ...); writeLaTeXSource(os, ...);
ofs.close(); ofs.close();
\endcode is NOT equivalent to \code \endcode is NOT equivalent to \code
odocstringstream oss; odocstringstream oss;
otexstream os(oss, texrow); otexstream os(oss);
writeLaTeXSource(os, ...); writeLaTeXSource(os, ...);
ofdocstream ofs; ofdocstream ofs;
ofs.open("test.tex"); ofs.open("test.tex");

View File

@ -38,6 +38,7 @@
#include "LyXRC.h" #include "LyXRC.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "Spacing.h" #include "Spacing.h"
#include "texstream.h"
#include "TexRow.h" #include "TexRow.h"
#include "VSpace.h" #include "VSpace.h"
#include "PDFOptions.h" #include "PDFOptions.h"

View File

@ -22,6 +22,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "Paragraph.h" #include "Paragraph.h"
#include "texstream.h"
#include "TocBackend.h" #include "TocBackend.h"
#include "support/debug.h" #include "support/debug.h"

View File

@ -21,8 +21,6 @@
#include "support/types.h" #include "support/types.h"
#include "support/lyxtime.h" #include "support/lyxtime.h"
#include "texstream.h"
#include <vector> #include <vector>
@ -32,9 +30,11 @@ class AuthorList;
class Buffer; class Buffer;
class DocIterator; class DocIterator;
class OutputParams; class OutputParams;
class otexstream;
class PainterInfo; class PainterInfo;
class FontInfo; class FontInfo;
class Change { class Change {
public: public:
/// the type of change /// the type of change

View File

@ -19,6 +19,7 @@
#include "insets/InsetText.h" #include "insets/InsetText.h"
#include "support/docstream.h"
#include "support/lassert.h" #include "support/lassert.h"
#include "support/lyxalgo.h" #include "support/lyxalgo.h"
#include "support/qstring_helpers.h" #include "support/qstring_helpers.h"

View File

@ -29,7 +29,6 @@ class Buffer;
class ErrorList; class ErrorList;
class Format; class Format;
class Formats; class Formats;
class OutputParams;
/// ///

View File

@ -31,6 +31,7 @@
#include "Paragraph.h" #include "Paragraph.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "Row.h" #include "Row.h"
#include "texstream.h"
#include "Text.h" #include "Text.h"
#include "TextMetrics.h" #include "TextMetrics.h"
#include "TocBackend.h" #include "TocBackend.h"
@ -1566,8 +1567,7 @@ void Cursor::normalize()
<< pos() << ' ' << lastpos() << " in idx: " << idx() << pos() << ' ' << lastpos() << " in idx: " << idx()
<< " in atom: '"; << " in atom: '";
odocstringstream os; odocstringstream os;
TexRow texrow(false); otexrowstream ots(os, false);
otexrowstream ots(os,texrow);
WriteStream wi(ots, false, true, WriteStream::wsDefault); WriteStream wi(ots, false, true, WriteStream::wsDefault);
inset().asInsetMath()->write(wi); inset().asInsetMath()->write(wi);
lyxerr << to_utf8(os.str()) << endl; lyxerr << to_utf8(os.str()) << endl;

View File

@ -25,6 +25,7 @@
#include "LyXRC.h" #include "LyXRC.h"
#include "output_latex.h" #include "output_latex.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "texstream.h"
#include "support/lassert.h" #include "support/lassert.h"
#include "support/convert.h" #include "support/convert.h"

View File

@ -23,6 +23,7 @@
#include "support/gettext.h" #include "support/gettext.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/mutex.h" #include "support/mutex.h"
#include "support/docstream.h"
#include "support/os.h" #include "support/os.h"
#include "support/PathChanger.h" #include "support/PathChanger.h"
#include "support/Systemcall.h" #include "support/Systemcall.h"

View File

@ -19,6 +19,7 @@
#include "support/convert.h" #include "support/convert.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h"
#include "support/FileName.h" #include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/gettext.h" #include "support/gettext.h"

View File

@ -15,6 +15,7 @@
#include "Encoding.h" #include "Encoding.h"
#include "Lexer.h" #include "Lexer.h"
#include "texstream.h"
#include "support/convert.h" #include "support/convert.h"
#include "support/debug.h" #include "support/debug.h"

View File

@ -40,6 +40,7 @@
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "SpellChecker.h" #include "SpellChecker.h"
#include "sgml.h" #include "sgml.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "TexRow.h" #include "TexRow.h"
#include "Text.h" #include "Text.h"
@ -1377,13 +1378,12 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
BufferParams const & bp = features.runparams().is_child BufferParams const & bp = features.runparams().is_child
? buf.masterParams() : buf.params(); ? buf.masterParams() : buf.params();
Font f; Font f;
TexRow texrow;
// Using a string stream here circumvents the encoding // Using a string stream here circumvents the encoding
// switching machinery of odocstream. Therefore the // switching machinery of odocstream. Therefore the
// output is wrong if this paragraph contains content // output is wrong if this paragraph contains content
// that needs to switch encoding. // that needs to switch encoding.
odocstringstream ods; odocstringstream ods;
otexstream os(ods, texrow); otexstream os(ods, false);
if (is_command) { if (is_command) {
os << '\\' << from_ascii(layout_->latexname()); os << '\\' << from_ascii(layout_->latexname());
// we have to provide all the optional arguments here, even though // we have to provide all the optional arguments here, even though

View File

@ -53,7 +53,7 @@ void TexRow::RowEntryList::forceAddEntry(RowEntry const & entry)
} }
TexRow::TextEntry TexRow::RowEntryList::getTextEntry() const TextEntry TexRow::RowEntryList::getTextEntry() const
{ {
if (text_entry_ < size()) if (text_entry_ < size())
return operator[](text_entry_).text; return operator[](text_entry_).text;
@ -61,7 +61,7 @@ TexRow::TextEntry TexRow::RowEntryList::getTextEntry() const
} }
TexRow::RowEntry TexRow::RowEntryList::entry() const RowEntry TexRow::RowEntryList::entry() const
{ {
if (0 < size()) if (0 < size())
return operator[](0); return operator[](0);
@ -77,8 +77,8 @@ void TexRow::RowEntryList::append(RowEntryList const & row)
} }
TexRow::TextEntry const TexRow::text_none = { -1, 0 }; TextEntry const TexRow::text_none = { -1, 0 };
TexRow::RowEntry const TexRow::row_none = { false, { TexRow::text_none } }; RowEntry const TexRow::row_none = { false, { TexRow::text_none } };
bool TexRow::isNone(TextEntry const & t) bool TexRow::isNone(TextEntry const & t)
@ -101,7 +101,7 @@ void TexRow::reset(bool enable)
} }
TexRow::RowEntry TexRow::textEntry(int id, int pos) RowEntry TexRow::textEntry(int id, int pos)
{ {
RowEntry entry; RowEntry entry;
entry.is_math = false; entry.is_math = false;
@ -111,7 +111,7 @@ TexRow::RowEntry TexRow::textEntry(int id, int pos)
} }
TexRow::RowEntry TexRow::mathEntry(uid_type id, idx_type cell) RowEntry TexRow::mathEntry(uid_type id, idx_type cell)
{ {
RowEntry entry; RowEntry entry;
entry.is_math = true; entry.is_math = true;
@ -121,8 +121,8 @@ TexRow::RowEntry TexRow::mathEntry(uid_type id, idx_type cell)
} }
bool operator==(TexRow::RowEntry const & entry1, bool operator==(RowEntry const & entry1,
TexRow::RowEntry const & entry2) RowEntry const & entry2)
{ {
return entry1.is_math == entry2.is_math return entry1.is_math == entry2.is_math
&& (entry1.is_math && (entry1.is_math
@ -216,7 +216,7 @@ bool TexRow::getIdFromRow(int row, int & id, int & pos) const
} }
TexRow::RowEntry TexRow::rowEntryFromCursorSlice(CursorSlice const & slice) RowEntry TexRow::rowEntryFromCursorSlice(CursorSlice const & slice)
{ {
RowEntry entry; RowEntry entry;
InsetMath * insetMath = slice.asInsetMath(); InsetMath * insetMath = slice.asInsetMath();
@ -408,7 +408,7 @@ std::pair<int,int> TexRow::rowFromDocIterator(DocIterator const & dit) const
// matches either at a deeper level, or at the same level but not // matches either at a deeper level, or at the same level but not
// before. // before.
for (size_t i = best_slice; i < n; ++i) { 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 (sameParOrInsetMath(*it, entry_i)) {
if (comparePos(*it, entry_i) >= 0 if (comparePos(*it, entry_i) >= 0
&& (i > best_slice && (i > best_slice

View File

@ -46,11 +46,6 @@ typedef void const * uid_type;
typedef size_t idx_type; typedef size_t idx_type;
/// Represents the correspondence between paragraphs and the generated
/// LaTeX file
class TexRow {
public:
/// an individual par id/pos <=> row mapping /// an individual par id/pos <=> row mapping
struct TextEntry { int id; int pos; }; struct TextEntry { int id; int pos; };
@ -66,6 +61,12 @@ public:
}; };
}; };
/// Represents the correspondence between paragraphs and the generated
/// LaTeX file
class TexRow {
public:
// For each row we store a list of one special TextEntry and several // For each row we store a list of one special TextEntry and several
// RowEntries. (The order is important.) We only want one text entry // 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 // because we do not want to store every position in the lyx file. On the
@ -205,7 +206,7 @@ private:
bool enabled_; bool enabled_;
}; };
bool operator==(TexRow::RowEntry const &, TexRow::RowEntry const &); bool operator==(RowEntry const &, RowEntry const &);
LyXErr & operator<<(LyXErr &, TexRow &); LyXErr & operator<<(LyXErr &, TexRow &);

View File

@ -33,6 +33,7 @@
#include "frontends/alert.h" #include "frontends/alert.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/FileName.h" #include "support/FileName.h"
#include "support/gettext.h" #include "support/gettext.h"

View File

@ -22,6 +22,7 @@
#include "Cursor.h" #include "Cursor.h"
#include "Format.h" #include "Format.h"
#include "Paragraph.h" #include "Paragraph.h"
#include "TexRow.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/lassert.h" #include "support/lassert.h"

View File

@ -18,20 +18,26 @@
#include "Buffer.h" #include "Buffer.h"
#include "DockView.h" #include "DockView.h"
#include "TexRow.h"
#include <QDockWidget> #include <QDockWidget>
#include <QString> #include <QString>
#include <QTimer> #include <QTimer>
class QTextDocument; class QTextDocument;
namespace lyx { namespace lyx {
class TexRow;
namespace frontend { namespace frontend {
class GuiViewSource; class GuiViewSource;
class LaTeXHighlighter; class LaTeXHighlighter;
class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
{ {
Q_OBJECT Q_OBJECT

View File

@ -25,6 +25,7 @@
#include "output.h" #include "output.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "TexRow.h" #include "TexRow.h"
#include "texstream.h"
#include "frontends/Application.h" // hexName #include "frontends/Application.h" // hexName
@ -625,8 +626,7 @@ void PreviewLoader::Impl::startLoading(bool wait)
return; return;
} }
TexRow texrow; otexstream os(of);
otexstream os(of, texrow);
OutputParams runparams(&enc); OutputParams runparams(&enc);
LaTeXFeatures features(buffer_, buffer_.params(), runparams); LaTeXFeatures features(buffer_, buffer_.params(), runparams);

View File

@ -26,6 +26,7 @@
#include "Format.h" #include "Format.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/FileName.h" #include "support/FileName.h"
#include "support/regex.h" #include "support/regex.h"

View File

@ -22,6 +22,7 @@
#include "Exporter.h" #include "Exporter.h"
#include "Format.h" #include "Format.h"
#include "Mover.h" #include "Mover.h"
#include "texstream.h"
#include "frontends/alert.h" #include "frontends/alert.h"

View File

@ -13,13 +13,15 @@
#ifndef EXTERNALSUPPORT_H #ifndef EXTERNALSUPPORT_H
#define EXTERNALSUPPORT_H #define EXTERNALSUPPORT_H
#include "texstream.h" #include <string>
namespace lyx { namespace lyx {
class Buffer; class Buffer;
class ExportData; class ExportData;
class InsetExternalParams; class InsetExternalParams;
class otexstream;
namespace external { namespace external {

View File

@ -24,6 +24,8 @@
#include "Lexer.h" #include "Lexer.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "TexRow.h"
#include "texstream.h"
#include "support/convert.h" #include "support/convert.h"
#include "support/debug.h" #include "support/debug.h"
@ -268,9 +270,8 @@ void InsetArgument::latexArgument(otexstream & os,
OutputParams const & runparams_in, docstring const & ldelim, OutputParams const & runparams_in, docstring const & ldelim,
docstring const & rdelim, docstring const & presetarg) const docstring const & rdelim, docstring const & presetarg) const
{ {
TexRow texrow;
odocstringstream ss; odocstringstream ss;
otexstream ots(ss, texrow); otexstream ots(ss);
OutputParams runparams = runparams_in; OutputParams runparams = runparams_in;
if (!pass_thru_chars_.empty()) if (!pass_thru_chars_.empty())
runparams.pass_thru_chars += pass_thru_chars_; runparams.pass_thru_chars += pass_thru_chars_;
@ -281,6 +282,7 @@ void InsetArgument::latexArgument(otexstream & os,
str = presetarg + sep + str; str = presetarg + sep + str;
if (ldelim != "{" && support::contains(str, rdelim)) if (ldelim != "{" && support::contains(str, rdelim))
str = '{' + str + '}'; str = '{' + str + '}';
// TODO: append texrow information
os << ldelim << str << rdelim; os << ldelim << str << rdelim;
} }

View File

@ -27,6 +27,7 @@
#include "output_xhtml.h" #include "output_xhtml.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "PDFOptions.h" #include "PDFOptions.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "frontends/alert.h" #include "frontends/alert.h"

View File

@ -27,6 +27,8 @@
#include "Lexer.h" #include "Lexer.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "TexRow.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "support/debug.h" #include "support/debug.h"

View File

@ -32,6 +32,8 @@
#include "OutputParams.h" #include "OutputParams.h"
#include "Paragraph.h" #include "Paragraph.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "TexRow.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "TextMetrics.h" #include "TextMetrics.h"
#include "TocBackend.h" #include "TocBackend.h"

View File

@ -24,6 +24,7 @@
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "texstream.h"
#include "TocBackend.h" #include "TocBackend.h"
#include "support/debug.h" #include "support/debug.h"

View File

@ -21,6 +21,7 @@
#include "FuncStatus.h" #include "FuncStatus.h"
#include "Lexer.h" #include "Lexer.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "texstream.h"
#include "insets/InsetBox.h" #include "insets/InsetBox.h"
#include "insets/InsetBranch.h" #include "insets/InsetBranch.h"

View File

@ -30,6 +30,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_latex.h" #include "output_latex.h"
#include "texstream.h"
#include "TocBackend.h" #include "TocBackend.h"
#include "frontends/alert.h" #include "frontends/alert.h"
@ -560,9 +561,8 @@ static bool isPreviewWanted(InsetExternalParams const & params)
static docstring latexString(InsetExternal const & inset) static docstring latexString(InsetExternal const & inset)
{ {
TexRow texrow;
odocstringstream ods; odocstringstream ods;
otexstream os(ods, texrow); otexstream os(ods, false);
// We don't need to set runparams.encoding since it is not used by // We don't need to set runparams.encoding since it is not used by
// latex(). // latex().
OutputParams runparams(0); OutputParams runparams(0);
@ -730,8 +730,7 @@ int InsetExternal::plaintext(odocstringstream & os,
if (runparams.for_tooltip) if (runparams.for_tooltip)
return 0; return 0;
TexRow texrow; otexstream ots(os, false);
otexstream ots(os, texrow);
ots << '\n'; // output external material on a new line ots << '\n'; // output external material on a new line
external::writeExternal(params_, "Ascii", buffer(), ots, external::writeExternal(params_, "Ascii", buffer(), ots,
*(runparams.exportdata), false, *(runparams.exportdata), false,
@ -743,9 +742,8 @@ int InsetExternal::plaintext(odocstringstream & os,
int InsetExternal::docbook(odocstream & os, int InsetExternal::docbook(odocstream & os,
OutputParams const & runparams) const OutputParams const & runparams) const
{ {
TexRow texrow;
odocstringstream ods; odocstringstream ods;
otexstream ots(ods, texrow); otexstream ots(ods, false);
external::writeExternal(params_, "DocBook", buffer(), ots, external::writeExternal(params_, "DocBook", buffer(), ots,
*(runparams.exportdata), false, *(runparams.exportdata), false,
runparams.dryrun || runparams.inComment); runparams.dryrun || runparams.inComment);

View File

@ -29,6 +29,8 @@
#include "Lexer.h" #include "Lexer.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "TexRow.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "support/debug.h" #include "support/debug.h"
@ -493,9 +495,8 @@ bool InsetFloat::allowsCaptionVariation(std::string const & newtype) const
docstring InsetFloat::getCaption(OutputParams const & runparams) const docstring InsetFloat::getCaption(OutputParams const & runparams) const
{ {
TexRow texrow(false);
odocstringstream ods; odocstringstream ods;
otexstream os(ods, texrow); otexstream os(ods, false);
getCaption(os, runparams); getCaption(os, runparams);
return ods.str(); return ods.str();
} }
@ -514,15 +515,14 @@ void InsetFloat::getCaption(otexstream & os,
ins->getArgs(os, runparams); ins->getArgs(os, runparams);
os << '['; os << '[';
TexRow texrow;
odocstringstream ods; odocstringstream ods;
otexstream oss(ods, texrow); otexstream oss(ods);
ins->getArgument(oss, runparams); ins->getArgument(oss, runparams);
docstring arg = ods.str(); docstring arg = ods.str();
// Protect ']' // Protect ']'
if (arg.find(']') != docstring::npos) if (arg.find(']') != docstring::npos)
arg = '{' + arg + '}'; arg = '{' + arg + '}';
os.append(arg, texrow); os.append(arg, move(oss.texrow()));
os << ']'; os << ']';
} }

View File

@ -26,6 +26,7 @@
#include "Lexer.h" #include "Lexer.h"
#include "Paragraph.h" #include "Paragraph.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "TocBackend.h" #include "TocBackend.h"

View File

@ -68,6 +68,7 @@ TODO
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "sgml.h" #include "sgml.h"
#include "texstream.h"
#include "TocBackend.h" #include "TocBackend.h"
#include "frontends/alert.h" #include "frontends/alert.h"

View File

@ -22,6 +22,7 @@
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/FileName.h" #include "support/FileName.h"

View File

@ -22,6 +22,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "RenderPreview.h" #include "RenderPreview.h"
#include "texstream.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
@ -120,9 +121,8 @@ void InsetIPA::addPreview(DocIterator const & inset_pos,
void InsetIPA::preparePreview(DocIterator const & pos) const void InsetIPA::preparePreview(DocIterator const & pos) const
{ {
TexRow texrow;
odocstringstream str; odocstringstream str;
otexstream os(str, texrow); otexstream os(str, false);
OutputParams runparams(&pos.buffer()->params().encoding()); OutputParams runparams(&pos.buffer()->params().encoding());
latex(os, runparams); latex(os, runparams);
docstring const snippet = str.str(); docstring const snippet = str.str();

View File

@ -23,6 +23,7 @@
#include "Lexer.h" #include "Lexer.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "frontends/FontMetrics.h" #include "frontends/FontMetrics.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"

View File

@ -36,6 +36,7 @@
#include "output_plaintext.h" #include "output_plaintext.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "TocBackend.h" #include "TocBackend.h"
@ -1085,9 +1086,8 @@ bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
docstring latexString(InsetInclude const & inset) docstring latexString(InsetInclude const & inset)
{ {
TexRow texrow;
odocstringstream ods; odocstringstream ods;
otexstream os(ods, texrow); otexstream os(ods, false);
// We don't need to set runparams.encoding since this will be done // We don't need to set runparams.encoding since this will be done
// by latex() anyway. // by latex() anyway.
OutputParams runparams(0); OutputParams runparams(0);

View File

@ -28,6 +28,7 @@
#include "output_latex.h" #include "output_latex.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "sgml.h" #include "sgml.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "TocBackend.h" #include "TocBackend.h"
@ -74,9 +75,8 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
} }
// get contents of InsetText as LaTeX and plaintext // get contents of InsetText as LaTeX and plaintext
TexRow texrow;
odocstringstream ourlatex; odocstringstream ourlatex;
otexstream ots(ourlatex, texrow); otexstream ots(ourlatex);
InsetText::latex(ots, runparams); InsetText::latex(ots, runparams);
odocstringstream ourplain; odocstringstream ourplain;
InsetText::plaintext(ourplain, runparams); InsetText::plaintext(ourplain, runparams);

View File

@ -25,6 +25,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "Text.h" #include "Text.h"
#include "frontends/FontMetrics.h" #include "frontends/FontMetrics.h"

View File

@ -30,6 +30,7 @@
#include "output_xhtml.h" #include "output_xhtml.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "TextClass.h" #include "TextClass.h"
#include "texstream.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h" #include "support/docstream.h"
@ -395,9 +396,8 @@ docstring InsetListings::getCaption(OutputParams const & runparams) const
if (ins == 0) if (ins == 0)
return docstring(); return docstring();
TexRow texrow;
odocstringstream ods; odocstringstream ods;
otexstream os(ods, texrow); otexstream os(ods, false);
ins->getArgs(os, runparams); ins->getArgs(os, runparams);
ins->getArgument(os, runparams); ins->getArgument(os, runparams);

View File

@ -21,6 +21,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "frontends/Application.h" #include "frontends/Application.h"
#include "frontends/FontMetrics.h" #include "frontends/FontMetrics.h"

View File

@ -20,6 +20,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "Text.h" #include "Text.h"
#include "TextMetrics.h" #include "TextMetrics.h"

View File

@ -31,6 +31,7 @@
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "sgml.h" #include "sgml.h"
#include "texstream.h"
#include "TocBackend.h" #include "TocBackend.h"
#include "frontends/FontMetrics.h" #include "frontends/FontMetrics.h"

View File

@ -28,6 +28,7 @@
#include "Lexer.h" #include "Lexer.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "support/docstream.h" #include "support/docstream.h"

View File

@ -19,6 +19,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "RenderPreview.h" #include "RenderPreview.h"
#include "texstream.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
@ -81,9 +82,8 @@ void InsetPreview::addPreview(DocIterator const & inset_pos,
void InsetPreview::preparePreview(DocIterator const & pos) const void InsetPreview::preparePreview(DocIterator const & pos) const
{ {
TexRow texrow;
odocstringstream str; odocstringstream str;
otexstream os(str, texrow); otexstream os(str, false);
OutputParams runparams(&pos.buffer()->params().encoding()); OutputParams runparams(&pos.buffer()->params().encoding());
latex(os, runparams); latex(os, runparams);

View File

@ -24,6 +24,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "frontends/FontMetrics.h" #include "frontends/FontMetrics.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"

View File

@ -23,6 +23,7 @@
#include "output_xhtml.h" #include "output_xhtml.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "sgml.h" #include "sgml.h"
#include "texstream.h"
#include "TocBackend.h" #include "TocBackend.h"
#include "support/debug.h" #include "support/debug.h"

View File

@ -20,6 +20,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "frontends/Application.h" #include "frontends/Application.h"
#include "frontends/FontMetrics.h" #include "frontends/FontMetrics.h"

View File

@ -27,6 +27,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h" #include "support/docstream.h"

View File

@ -20,6 +20,7 @@
#include "Lexer.h" #include "Lexer.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "frontends/FontMetrics.h" #include "frontends/FontMetrics.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"

View File

@ -45,6 +45,8 @@
#include "Paragraph.h" #include "Paragraph.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "TexRow.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "TextMetrics.h" #include "TextMetrics.h"
@ -2685,8 +2687,7 @@ void Tabular::TeXRow(otexstream & os, row_type row,
void Tabular::latex(otexstream & os, OutputParams const & runparams) const void Tabular::latex(otexstream & os, OutputParams const & runparams) const
{ {
bool const is_tabular_star = !tabular_width.zero(); bool const is_tabular_star = !tabular_width.zero();
TexRow::RowEntry pos = TexRow::textEntry(runparams.lastid, RowEntry pos = TexRow::textEntry(runparams.lastid, runparams.lastpos);
runparams.lastpos);
//+--------------------------------------------------------------------- //+---------------------------------------------------------------------
//+ first the opening preamble + //+ first the opening preamble +

View File

@ -48,6 +48,7 @@
#include "Row.h" #include "Row.h"
#include "sgml.h" #include "sgml.h"
#include "TexRow.h" #include "TexRow.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "Text.h" #include "Text.h"
#include "TextMetrics.h" #include "TextMetrics.h"

View File

@ -24,6 +24,7 @@
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "Text.h" #include "Text.h"
#include "support/debug.h" #include "support/debug.h"

View File

@ -27,6 +27,7 @@
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "Lexer.h" #include "Lexer.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "support/debug.h" #include "support/debug.h"

View File

@ -727,9 +727,8 @@ private:
static docstring buffer_to_latex(Buffer & buffer) static docstring buffer_to_latex(Buffer & buffer)
{ {
OutputParams runparams(&buffer.params().encoding()); OutputParams runparams(&buffer.params().encoding());
TexRow texrow(false);
odocstringstream ods; odocstringstream ods;
otexstream os(ods, texrow); otexstream os(ods, false);
runparams.nice = true; runparams.nice = true;
runparams.flavor = OutputParams::LATEX; runparams.flavor = OutputParams::LATEX;
runparams.linelen = 80; //lyxrc.plaintext_linelen; runparams.linelen = 80; //lyxrc.plaintext_linelen;
@ -1048,9 +1047,8 @@ docstring latexifyFromCursor(DocIterator const & cur, int len)
Buffer const & buf = *cur.buffer(); Buffer const & buf = *cur.buffer();
LBUFERR(buf.params().isLatex()); LBUFERR(buf.params().isLatex());
TexRow texrow(false);
odocstringstream ods; odocstringstream ods;
otexstream os(ods, texrow); otexstream os(ods, false);
OutputParams runparams(&buf.params().encoding()); OutputParams runparams(&buf.params().encoding());
runparams.nice = false; runparams.nice = false;
runparams.flavor = OutputParams::LATEX; runparams.flavor = OutputParams::LATEX;
@ -1395,9 +1393,8 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
LYXERR(Debug::FIND, "After pasteParagraphList() cur=" << cur << endl); LYXERR(Debug::FIND, "After pasteParagraphList() cur=" << cur << endl);
sel_len = repl_buffer.paragraphs().begin()->size(); sel_len = repl_buffer.paragraphs().begin()->size();
} else if (cur.inMathed()) { } else if (cur.inMathed()) {
TexRow texrow(false);
odocstringstream ods; odocstringstream ods;
otexstream os(ods, texrow); otexstream os(ods, false);
OutputParams runparams(&repl_buffer.params().encoding()); OutputParams runparams(&repl_buffer.params().encoding());
runparams.nice = false; runparams.nice = false;
runparams.flavor = OutputParams::LATEX; runparams.flavor = OutputParams::LATEX;

View File

@ -53,8 +53,7 @@ void InsetMath::dump() const
{ {
lyxerr << "---------------------------------------------" << endl; lyxerr << "---------------------------------------------" << endl;
odocstringstream os; odocstringstream os;
TexRow texrow(false); otexrowstream ots(os, false);
otexrowstream ots(os,texrow);
WriteStream wi(ots, false, true, WriteStream::wsDefault); WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi); write(wi);
lyxerr << to_utf8(os.str()); lyxerr << to_utf8(os.str());
@ -158,8 +157,7 @@ HullType InsetMath::getType() const
ostream & operator<<(ostream & os, MathAtom const & at) ostream & operator<<(ostream & os, MathAtom const & at)
{ {
odocstringstream oss; odocstringstream oss;
TexRow texrow(false); otexrowstream ots(oss, false);
otexrowstream ots(oss,texrow);
WriteStream wi(ots, false, false, WriteStream::wsDefault); WriteStream wi(ots, false, false, WriteStream::wsDefault);
at->write(wi); at->write(wi);
return os << to_utf8(oss.str()); return os << to_utf8(oss.str());
@ -168,8 +166,7 @@ ostream & operator<<(ostream & os, MathAtom const & at)
odocstream & operator<<(odocstream & os, MathAtom const & at) odocstream & operator<<(odocstream & os, MathAtom const & at)
{ {
TexRow texrow(false); otexrowstream ots(os, false);
otexrowstream ots(os,texrow);
WriteStream wi(ots, false, false, WriteStream::wsDefault); WriteStream wi(ots, false, false, WriteStream::wsDefault);
at->write(wi); at->write(wi);
return os; return os;

View File

@ -17,8 +17,6 @@
#include "insets/Inset.h" #include "insets/Inset.h"
#include "TexRow.h"
namespace lyx { namespace lyx {
@ -93,6 +91,9 @@ class TextPainter;
class TextMetricsInfo; class TextMetricsInfo;
class ReplaceData; class ReplaceData;
/// Type of unique identifiers for math insets (used in TexRow)
typedef void const * uid_type;
class InsetMath : public Inset { class InsetMath : public Inset {
public: public:

View File

@ -22,10 +22,11 @@
#include "Buffer.h" #include "Buffer.h"
#include "BufferParams.h" #include "BufferParams.h"
#include "BufferView.h" #include "BufferView.h"
#include "CutAndPaste.h"
#include "FuncStatus.h"
#include "Cursor.h" #include "Cursor.h"
#include "CutAndPaste.h"
#include "FuncRequest.h" #include "FuncRequest.h"
#include "FuncStatus.h"
#include "TexRow.h"
#include "frontends/Clipboard.h" #include "frontends/Clipboard.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
@ -1268,8 +1269,8 @@ void InsetMathGrid::write(WriteStream & os,
for (col_type col = beg_col; col < end_col;) { for (col_type col = beg_col; col < end_col;) {
int nccols = 1; int nccols = 1;
idx_type const idx = index(row, col); idx_type const idx = index(row, col);
TexRow::RowEntry entry = os.texrow().mathEntry(id(),idx); RowEntry entry = TexRow::mathEntry(id(),idx);
os.texrow().startMath(id(),idx); os.texrow().start(entry);
if (col >= lastcol) { if (col >= lastcol) {
++col; ++col;
continue; continue;

View File

@ -43,6 +43,7 @@
#include "Paragraph.h" #include "Paragraph.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "sgml.h" #include "sgml.h"
#include "TexRow.h"
#include "TextClass.h" #include "TextClass.h"
#include "TextPainter.h" #include "TextPainter.h"
#include "TocBackend.h" #include "TocBackend.h"
@ -614,8 +615,7 @@ void InsetMathHull::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
InsetMathGrid::metricsT(mi, dim); InsetMathGrid::metricsT(mi, dim);
} else { } else {
odocstringstream os; odocstringstream os;
TexRow texrow(false); otexrowstream ots(os, false);
otexrowstream ots(os,texrow);
WriteStream wi(ots, false, true, WriteStream::wsDefault); WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi); write(wi);
dim.wid = os.str().size(); dim.wid = os.str().size();
@ -631,8 +631,7 @@ void InsetMathHull::drawT(TextPainter & pain, int x, int y) const
InsetMathGrid::drawT(pain, x, y); InsetMathGrid::drawT(pain, x, y);
} else { } else {
odocstringstream os; odocstringstream os;
TexRow texrow(false); otexrowstream ots(os, false);
otexrowstream ots(os,texrow);
WriteStream wi(ots, false, true, WriteStream::wsDefault); WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi); write(wi);
pain.draw(x, y, os.str().c_str()); pain.draw(x, y, os.str().c_str());
@ -651,8 +650,7 @@ static docstring latexString(InsetMathHull const & inset)
static Encoding const * encoding = 0; static Encoding const * encoding = 0;
if (inset.isBufferValid()) if (inset.isBufferValid())
encoding = &(inset.buffer().params().encoding()); encoding = &(inset.buffer().params().encoding());
TexRow texrow(false); otexrowstream ots(ls, false);
otexrowstream ots(ls,texrow);
WriteStream wi(ots, false, true, WriteStream::wsPreview, encoding); WriteStream wi(ots, false, true, WriteStream::wsPreview, encoding);
inset.write(wi); inset.write(wi);
return ls.str(); return ls.str();
@ -2182,8 +2180,7 @@ bool InsetMathHull::searchForward(BufferView * bv, string const & str,
void InsetMathHull::write(ostream & os) const void InsetMathHull::write(ostream & os) const
{ {
odocstringstream oss; odocstringstream oss;
TexRow texrow(false); otexrowstream ots(oss, false);
otexrowstream ots(oss,texrow);
WriteStream wi(ots, false, false, WriteStream::wsDefault); WriteStream wi(ots, false, false, WriteStream::wsDefault);
oss << "Formula "; oss << "Formula ";
write(wi); write(wi);
@ -2226,8 +2223,7 @@ int InsetMathHull::plaintext(odocstringstream & os,
} }
odocstringstream oss; odocstringstream oss;
TexRow texrow(false); otexrowstream ots(oss, false);
otexrowstream ots(oss,texrow);
Encoding const * const enc = encodings.fromLyXName("utf8"); Encoding const * const enc = encodings.fromLyXName("utf8");
WriteStream wi(ots, false, true, WriteStream::wsDefault, enc); WriteStream wi(ots, false, true, WriteStream::wsDefault, enc);
@ -2269,8 +2265,7 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
++ms.tab(); ms.cr(); ms.os() << '<' << bname << '>'; ++ms.tab(); ms.cr(); ms.os() << '<' << bname << '>';
odocstringstream ls; odocstringstream ls;
TexRow texrow; otexstream ols(ls);
otexstream ols(ls, texrow);
if (runparams.flavor == OutputParams::XML) { if (runparams.flavor == OutputParams::XML) {
ms << MTag("alt role='tex' "); ms << MTag("alt role='tex' ");
// Workaround for db2latex: db2latex always includes equations with // Workaround for db2latex: db2latex always includes equations with
@ -2288,7 +2283,7 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
} else { } else {
ms << MTag("alt role='tex'"); ms << MTag("alt role='tex'");
latex(ols, runparams); latex(ols, runparams);
res = texrow.rows(); res = ols.texrow().rows();
ms << from_utf8(subst(subst(to_utf8(ls.str()), "&", "&amp;"), "<", "&lt;")); ms << from_utf8(subst(subst(to_utf8(ls.str()), "&", "&amp;"), "<", "&lt;"));
ms << ETag("alt"); ms << ETag("alt");
} }
@ -2537,8 +2532,7 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
// Unfortunately, we cannot use latexString() because we do not want // Unfortunately, we cannot use latexString() because we do not want
// $...$ or whatever. // $...$ or whatever.
odocstringstream ls; odocstringstream ls;
TexRow texrow(false); otexrowstream ots(ls, false);
otexrowstream ots(ls,texrow);
WriteStream wi(ots, false, true, WriteStream::wsPreview); WriteStream wi(ots, false, true, WriteStream::wsPreview);
ModeSpecifier specifier(wi, MATH_MODE); ModeSpecifier specifier(wi, MATH_MODE);
mathAsLatex(wi); mathAsLatex(wi);

View File

@ -52,6 +52,7 @@
#include "LyXRC.h" #include "LyXRC.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "TexRow.h"
#include "Text.h" #include "Text.h"
#include "frontends/Application.h" #include "frontends/Application.h"
@ -251,8 +252,7 @@ bool InsetMathNest::idxLast(Cursor & cur) const
void InsetMathNest::dump() const void InsetMathNest::dump() const
{ {
odocstringstream oss; odocstringstream oss;
TexRow texrow(false); otexrowstream ots(oss, false);
otexrowstream ots(oss,texrow);
WriteStream os(ots); WriteStream os(ots);
os << "---------------------------------------------\n"; os << "---------------------------------------------\n";
write(os); write(os);
@ -407,7 +407,7 @@ void InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault, runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
runparams.encoding); runparams.encoding);
wi.canBreakLine(os.canBreakLine()); wi.canBreakLine(os.canBreakLine());
Changer dummy = wi.changeRowEntry(os.texrow().textEntry(runparams.lastid, Changer dummy = wi.changeRowEntry(TexRow::textEntry(runparams.lastid,
runparams.lastpos)); runparams.lastpos));
write(wi); write(wi);
// Reset parbreak status after a math inset. // Reset parbreak status after a math inset.

View File

@ -200,8 +200,7 @@ int MacroData::write(odocstream & os, bool overwriteRedefinition) const
// output template // output template
MathMacroTemplate const & tmpl = MathMacroTemplate const & tmpl =
static_cast<MathMacroTemplate const &>(*inset); static_cast<MathMacroTemplate const &>(*inset);
TexRow texrow(false); otexrowstream ots(os, false);
otexrowstream ots(os,texrow);
WriteStream wi(ots, false, true, WriteStream::wsDefault); WriteStream wi(ots, false, true, WriteStream::wsDefault);
return tmpl.write(wi, overwriteRedefinition); return tmpl.write(wi, overwriteRedefinition);
} }

View File

@ -73,6 +73,7 @@
#include "LyX.h" // use_gui #include "LyX.h" // use_gui
#include "OutputParams.h" #include "OutputParams.h"
using namespace std; using namespace std;
using namespace lyx::support; using namespace lyx::support;
@ -669,9 +670,8 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar)
InsetSpaceParams isp(true); InsetSpaceParams isp(true);
InsetSpace::string2params(to_utf8(str), isp); InsetSpace::string2params(to_utf8(str), isp);
InsetSpace is(isp); InsetSpace is(isp);
TexRow texrow;
odocstringstream ods; odocstringstream ods;
otexstream os(ods, texrow); otexstream os(ods, false);
Encoding const * const ascii = encodings.fromLyXName("ascii"); Encoding const * const ascii = encodings.fromLyXName("ascii");
OutputParams op(ascii); OutputParams op(ascii);
is.latex(os, op); is.latex(os, op);

View File

@ -1172,8 +1172,7 @@ void MathMacroTemplate::read(Lexer & lex)
void MathMacroTemplate::write(ostream & os) const void MathMacroTemplate::write(ostream & os) const
{ {
odocstringstream oss; odocstringstream oss;
TexRow texrow(false); otexrowstream ots(oss, false);
otexrowstream ots(oss,texrow);
WriteStream wi(ots, false, false, WriteStream::wsDefault); WriteStream wi(ots, false, false, WriteStream::wsDefault);
oss << "FormulaMacro\n"; oss << "FormulaMacro\n";
write(wi); write(wi);

View File

@ -16,6 +16,8 @@
#include "MathData.h" #include "MathData.h"
#include "MathExtern.h" #include "MathExtern.h"
#include "TexRow.h"
#include "support/docstring.h" #include "support/docstring.h"
#include "support/RefChanger.h" #include "support/RefChanger.h"
#include "support/textutils.h" #include "support/textutils.h"
@ -128,7 +130,8 @@ WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex,
: os_(os), fragile_(fragile), firstitem_(false), latex_(latex), : os_(os), fragile_(fragile), firstitem_(false), latex_(latex),
output_(output), pendingspace_(false), pendingbrace_(false), output_(output), pendingspace_(false), pendingbrace_(false),
textmode_(false), locked_(0), ascii_(0), canbreakline_(true), 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))
{} {}
@ -177,17 +180,17 @@ void WriteStream::asciiOnly(bool ascii)
} }
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() bool WriteStream::startOuterRow()
{ {
if (TexRow::isNone(row_entry_)) if (TexRow::isNone(*row_entry_))
return false; return false;
return texrow().start(row_entry_); return texrow().start(*row_entry_);
} }

View File

@ -17,6 +17,7 @@
#include "support/Changer.h" #include "support/Changer.h"
#include "support/strfwd.h" #include "support/strfwd.h"
#include "support/unique_ptr.h"
namespace lyx { namespace lyx {
@ -25,6 +26,7 @@ class Encoding;
class InsetMath; class InsetMath;
class MathAtom; class MathAtom;
class MathData; class MathData;
class RowEntry;
// //
// LaTeX/LyX // LaTeX/LyX
@ -88,7 +90,7 @@ public:
Encoding const * encoding() const { return encoding_; } Encoding const * encoding() const { return encoding_; }
/// Temporarily change the TexRow information about the outer row entry. /// 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 /// TexRow::starts the innermost outer math inset
/// returns true if the outer row entry will appear at this line /// returns true if the outer row entry will appear at this line
bool startOuterRow(); bool startOuterRow();
@ -120,7 +122,8 @@ private:
/// ///
Encoding const * encoding_; Encoding const * encoding_;
/// Row entry we are in /// Row entry we are in
TexRow::RowEntry row_entry_; /// (it is a pointer to allow forward-declaration)
unique_ptr<RowEntry> row_entry_;
}; };
/// ///

View File

@ -919,8 +919,7 @@ bool isAlphaSymbol(MathAtom const & at)
docstring asString(MathData const & ar) docstring asString(MathData const & ar)
{ {
odocstringstream os; odocstringstream os;
TexRow texrow(false); otexrowstream ots(os, false);
otexrowstream ots(os,texrow);
WriteStream ws(ots); WriteStream ws(ots);
ws << ar; ws << ar;
return os.str(); return os.str();
@ -938,8 +937,7 @@ void asArray(docstring const & str, MathData & ar, Parse::flags pf)
docstring asString(InsetMath const & inset) docstring asString(InsetMath const & inset)
{ {
odocstringstream os; odocstringstream os;
TexRow texrow(false); otexrowstream ots(os, false);
otexrowstream ots(os,texrow);
WriteStream ws(ots); WriteStream ws(ots);
inset.write(ws); inset.write(ws);
return os.str(); return os.str();
@ -949,8 +947,7 @@ docstring asString(InsetMath const & inset)
docstring asString(MathAtom const & at) docstring asString(MathAtom const & at)
{ {
odocstringstream os; odocstringstream os;
TexRow texrow(false); otexrowstream ots(os, false);
otexrowstream ots(os,texrow);
WriteStream ws(ots); WriteStream ws(ots);
at->write(ws); at->write(ws);
return os.str(); return os.str();

View File

@ -23,6 +23,7 @@
#include "OutputParams.h" #include "OutputParams.h"
#include "Paragraph.h" #include "Paragraph.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "insets/InsetBibitem.h" #include "insets/InsetBibitem.h"

View File

@ -47,19 +47,6 @@ namespace Alert {
} }
//
// Dummy TexRow support (needed by docstream)
//
void TexRow::newline()
{}
void TexRow::newlines(int)
{}
// //
// Dummy LyXRC support // Dummy LyXRC support
// //

View File

@ -11,6 +11,9 @@
#include <config.h> #include <config.h>
#include "texstream.h" #include "texstream.h"
#include "TexRow.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/unicode.h" #include "support/unicode.h"
@ -30,10 +33,26 @@ using lyx::support::split;
namespace lyx { 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; os_ << str;
texrow_.append(texrow); texrow_->append(move(texrow));
} }
@ -41,7 +60,7 @@ void otexrowstream::put(char_type const & c)
{ {
os_.put(c); os_.put(c);
if (c == '\n') if (c == '\n')
texrow_.newline(); texrow_->newline();
} }

View File

@ -12,11 +12,17 @@
#ifndef LYX_TEXSTREAM_H #ifndef LYX_TEXSTREAM_H
#define LYX_TEXSTREAM_H #define LYX_TEXSTREAM_H
#include "TexRow.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/unique_ptr.h"
namespace lyx { namespace lyx {
class TexRow;
// declared below
class otexstringstream;
/** Wrapper class for odocstream. /** Wrapper class for odocstream.
This class is used to automatically count the lines of the exported latex This class is used to automatically count the lines of the exported latex
code. code.
@ -25,21 +31,24 @@ namespace lyx {
class otexrowstream { class otexrowstream {
public: public:
/// ///
otexrowstream(odocstream & os, TexRow & texrow) explicit otexrowstream(odocstream & os, bool enable = true);
: os_(os), texrow_(texrow) {} /// defaulted
~otexrowstream();
/// ///
odocstream & os() { return os_; } odocstream & os() { return os_; }
/// ///
TexRow & texrow() { return texrow_; } TexRow & texrow() { return *texrow_; }
///
unique_ptr<TexRow> && releaseTexRow();
/// ///
void put(char_type const & c); void put(char_type const & c);
/// ///
void append(docstring const &, TexRow const &); void append(docstring const & str, TexRow texrow);
private: private:
/// ///
odocstream & os_; odocstream & os_;
/// ///
TexRow & texrow_; unique_ptr<TexRow> texrow_;
}; };
/// ///
@ -70,8 +79,8 @@ otexrowstream & operator<<(otexrowstream & ots, Type value);
class otexstream : public otexrowstream { class otexstream : public otexrowstream {
public: public:
/// ///
otexstream(odocstream & os, TexRow & texrow) explicit otexstream(odocstream & os, bool enable = true)
: otexrowstream(os, texrow), canbreakline_(false), : otexrowstream(os, enable), canbreakline_(false),
protectspace_(false), parbreak_(true), lastchar_(0) {} protectspace_(false), parbreak_(true), lastchar_(0) {}
/// ///
void put(char_type const & c); void put(char_type const & c);
@ -135,6 +144,7 @@ otexstream & operator<<(otexstream &, char);
template <typename Type> template <typename Type>
otexstream & operator<<(otexstream & ots, Type value); otexstream & operator<<(otexstream & ots, Type value);
} }
#endif #endif