diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 649c74ba7a..d6977e642e 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -4472,7 +4472,7 @@ Buffer::ReadStatus Buffer::loadThisLyXFile(FileName const & fn) void Buffer::bufferErrors(TeXErrors const & terr, ErrorList & errorList) const { for (auto const & err : terr) { - TextEntry start, end = TexRow::text_none; + TexRow::TextEntry start, end = TexRow::text_none; int errorRow = err.error_in_line; Buffer const * buf = 0; Impl const * p = d; diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 862344c3be..a9ce9a1092 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2345,7 +2345,7 @@ int BufferView::scrollUp(int offset) bool BufferView::setCursorFromRow(int row) { - TextEntry start, end; + TexRow::TextEntry start, end; tie(start,end) = buffer_.texrow().getEntriesFromRow(row); LYXERR(Debug::LATEX, "setCursorFromRow: for row " << row << ", TexRow has found " @@ -2355,7 +2355,8 @@ bool BufferView::setCursorFromRow(int row) } -bool BufferView::setCursorFromEntries(TextEntry start, TextEntry end) +bool BufferView::setCursorFromEntries(TexRow::TextEntry start, + TexRow::TextEntry end) { DocIterator dit_start, dit_end; tie(dit_start,dit_end) = diff --git a/src/BufferView.h b/src/BufferView.h index 016423f87b..ee2de8276e 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -16,6 +16,7 @@ #define BUFFER_VIEW_H #include "DocumentClassPtr.h" +#include "TexRow.h" #include "update_flags.h" #include "support/strfwd.h" @@ -46,7 +47,6 @@ class ParagraphMetrics; class Point; class TexRow; class Text; -struct TextEntry; class TextMetrics; enum CursorStatus { @@ -165,7 +165,7 @@ public: /// set the cursor based on the given TeX source row. bool setCursorFromRow(int row); /// set the cursor based on the given start and end TextEntries. - bool setCursorFromEntries(TextEntry start, TextEntry end); + bool setCursorFromEntries(TexRow::TextEntry start, TexRow::TextEntry end); /// set cursor to the given inset. Return true if found. bool setCursorFromInset(Inset const *); diff --git a/src/ErrorList.h b/src/ErrorList.h index 41c65fc24a..35294476dc 100644 --- a/src/ErrorList.h +++ b/src/ErrorList.h @@ -27,6 +27,7 @@ class Buffer; /// A class to hold an error item class ErrorItem { public: + typedef TexRow::TextEntry TextEntry; docstring error; docstring description; // To generalise into RowEntries @@ -35,8 +36,7 @@ public: Buffer const * buffer; // With a start position and an end position ErrorItem(docstring const & error, docstring const & description, - TextEntry start, TextEntry end, - Buffer const * buf = 0); + TextEntry start, TextEntry end, Buffer const * buf = 0); // Error outside the document body ErrorItem(docstring const & error, docstring const & description, Buffer const * buf = 0); diff --git a/src/TexRow.cpp b/src/TexRow.cpp index 68843b5586..2884cda664 100644 --- a/src/TexRow.cpp +++ b/src/TexRow.cpp @@ -84,7 +84,7 @@ void TexRow::RowEntryList::forceAddEntry(RowEntry entry) } -TextEntry TexRow::RowEntryList::getTextEntry() const +TexRow::TextEntry TexRow::RowEntryList::getTextEntry() const { if (!isNone(text_entry_)) return text_entry_; @@ -106,8 +106,8 @@ TexRow::TexRow() } -TextEntry const TexRow::text_none = { -1, 0 }; -RowEntry const TexRow::row_none = { false, { TexRow::text_none } }; +TexRow::TextEntry const TexRow::text_none = { -1, 0 }; +TexRow::RowEntry const TexRow::row_none = { false, { TexRow::text_none } }; //static @@ -138,7 +138,7 @@ TexRow::RowEntryList & TexRow::currentRow() //static -RowEntry TexRow::textEntry(int id, pos_type pos) +TexRow::RowEntry TexRow::textEntry(int id, pos_type pos) { RowEntry entry; entry.is_math = false; @@ -149,7 +149,7 @@ RowEntry TexRow::textEntry(int id, pos_type pos) //static -RowEntry TexRow::mathEntry(uid_type id, idx_type cell) +TexRow::RowEntry TexRow::mathEntry(uid_type id, idx_type cell) { RowEntry entry; entry.is_math = true; @@ -159,7 +159,7 @@ RowEntry TexRow::mathEntry(uid_type id, idx_type cell) } -bool operator==(RowEntry entry1, RowEntry entry2) +bool operator==(TexRow::RowEntry entry1, TexRow::RowEntry entry2) { return entry1.is_math == entry2.is_math && (entry1.is_math @@ -217,7 +217,8 @@ void TexRow::append(TexRow other) } -pair TexRow::getEntriesFromRow(int const row) const +pair +TexRow::getEntriesFromRow(int const row) const { LYXERR(Debug::LATEX, "getEntriesFromRow: row " << row << " requested"); // check bounds for row - 1, our target index @@ -312,7 +313,7 @@ FuncRequest TexRow::goToFuncFromRow(int const row) const //static -RowEntry TexRow::rowEntryFromCursorSlice(CursorSlice const & slice) +TexRow::RowEntry TexRow::rowEntryFromCursorSlice(CursorSlice const & slice) { RowEntry entry; InsetMath * insetMath = slice.asInsetMath(); diff --git a/src/TexRow.h b/src/TexRow.h index 7697761987..57c01ddb9e 100644 --- a/src/TexRow.h +++ b/src/TexRow.h @@ -47,26 +47,27 @@ typedef void const * uid_type; typedef size_t idx_type; -/// an individual par id/pos <=> row mapping -struct TextEntry { int id; pos_type 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; pos_type 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; + }; + }; + +private: /// id/pos correspondence for a single row class RowEntryList; @@ -286,7 +287,7 @@ public: }; -bool operator==(RowEntry entry1, RowEntry entry2); +bool operator==(TexRow::RowEntry entry1, TexRow::RowEntry entry2); } // namespace lyx diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 3a16c815d4..bf21ae73f1 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2708,7 +2708,7 @@ void Tabular::TeXRow(otexstream & os, row_type row, void Tabular::latex(otexstream & os, OutputParams const & runparams) const { bool const is_tabular_star = !tabular_width.zero(); - RowEntry pos = TexRow::textEntry(runparams.lastid, runparams.lastpos); + TexRow::RowEntry pos = TexRow::textEntry(runparams.lastid, runparams.lastpos); //+--------------------------------------------------------------------- //+ first the opening preamble + diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index a0269c511f..053958d1c5 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -1276,7 +1276,7 @@ void InsetMathGrid::write(WriteStream & os, for (col_type col = beg_col; col < end_col;) { int nccols = 1; idx_type const idx = index(row, col); - RowEntry entry = TexRow::mathEntry(id(),idx); + TexRow::RowEntry entry = TexRow::mathEntry(id(),idx); os.texrow().start(entry); if (col >= lastcol) { ++col; diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp index e2b65662de..ee6583530e 100644 --- a/src/mathed/MathStream.cpp +++ b/src/mathed/MathStream.cpp @@ -131,7 +131,7 @@ WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex, output_(output), pendingspace_(false), pendingbrace_(false), textmode_(false), locked_(0), ascii_(0), canbreakline_(true), mathsout_(false), ulemcmd_(NONE), line_(0), encoding_(encoding), - row_entry_(make_unique(TexRow::row_none)) + row_entry_(TexRow::row_none) {} @@ -180,17 +180,17 @@ void WriteStream::asciiOnly(bool ascii) } -Changer WriteStream::changeRowEntry(RowEntry entry) +Changer WriteStream::changeRowEntry(TexRow::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_); } diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h index 996525bc3e..2a4d4d7cbe 100644 --- a/src/mathed/MathStream.h +++ b/src/mathed/MathStream.h @@ -13,6 +13,8 @@ #define MATH_MATHMLSTREAM_H #include "InsetMath.h" + +#include "TexRow.h" #include "texstream.h" #include "support/Changer.h" @@ -26,7 +28,6 @@ class Encoding; class InsetMath; class MathAtom; class MathData; -struct RowEntry; // // LaTeX/LyX @@ -104,7 +105,7 @@ public: Encoding const * encoding() const { return encoding_; } /// Temporarily change the TexRow information about the outer row entry. - Changer changeRowEntry(RowEntry 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(); @@ -140,8 +141,7 @@ private: /// Encoding const * encoding_; /// Row entry we are in - /// (it is a pointer to allow forward-declaration) - unique_ptr row_entry_; + TexRow::RowEntry row_entry_; }; ///