X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetTabular.cpp;h=68fff9b51f816e16746a13ee3571a60674876434;hb=110f8f67ac1afe9892dad5566d1c697044427cf0;hp=7b4db191732032526bf4d72872f749744a16025b;hpb=e900b61d46f02b2af9afcc697168e47e846b982d;p=lyx.git diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 7b4db19173..68fff9b51f 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -451,7 +451,7 @@ bool getTokenValue(string const & str, char const * token, Length & len) } -bool getTokenValue(string const & str, char const * token, Change & change, BufferParams bp) +bool getTokenValue(string const & str, char const * token, Change & change, BufferParams & bp) { // set the change to be Change() as default as this it should be if not // in the file format. @@ -570,11 +570,11 @@ string const write_attribute(string const & name, Tabular::idx_type const & i) template <> string const write_attribute(string const & name, Length const & value) { - // we write only the value if we really have one same reson as above. + // we write only the value if we really have one same reason as above. return value.zero() ? string() : write_attribute(name, value.asString()); } -string const write_attribute(string const & name, Change const & change, BufferParams const bp) +string const write_attribute(string const & name, Change const & change, BufferParams const & bp) { odocstringstream ods; if (change.inserted()) @@ -620,7 +620,7 @@ InsetTableCell splitCell(InsetTableCell & head, docstring const & align_d, bool DocIterator const dit = separatorPos(&head, align_d); hassep = (bool)dit; if (hassep) { - pit_type const psize = head.paragraphs().front().size(); + pos_type const psize = head.paragraphs().front().size(); head.paragraphs().front().eraseChars(dit.pos(), psize, false); tail.paragraphs().front().eraseChars(0, dit.pos() < psize ? dit.pos() + 1 : psize, false); @@ -1013,7 +1013,7 @@ void Tabular::updateIndexes() continue; } cell_info[row][column].inset->toggleMultiCol(false); - // columnofcell needs to be called before setting width and aligment + // columnofcell needs to be called before setting width and alignment // multirow cells inherit the width from the column width if (!isPartOfMultiRow(row, column)) { columnofcell[i] = column; @@ -1174,7 +1174,7 @@ bool Tabular::updateColumnWidths(MetricsInfo & mi) int restwidth = -1; if (!tab_width.zero()) { restwidth = mi.base.inPixels(tab_width); - // Substract the fixed widths from the table width + // Subtract the fixed widths from the table width for (auto const w : max_pwidth) restwidth -= w.second; } @@ -3649,14 +3649,14 @@ int Tabular::docbook(odocstream & os, OutputParams const & runparams) const } -docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row, +docstring Tabular::xhtmlRow(XMLStream & xs, row_type row, OutputParams const & runparams, bool header) const { docstring ret; string const celltag = header ? "th" : "td"; idx_type cell = getFirstCellInRow(row); - xs << html::StartTag("tr"); + xs << xml::StartTag("tr"); for (col_type c = 0; c < ncols(); ++c) { if (isPartOfMultiColumn(row, c) || isPartOfMultiRow(row, c)) continue; @@ -3700,17 +3700,17 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row, else if (isMultiRow(cell)) attr << " rowspan='" << rowSpan(cell) << "'"; - xs << html::StartTag(celltag, attr.str(), true) << html::CR(); + xs << xml::StartTag(celltag, attr.str(), true) << xml::CR(); ret += cellInset(cell)->xhtml(xs, runparams); - xs << html::EndTag(celltag) << html::CR(); + xs << xml::EndTag(celltag) << xml::CR(); ++cell; } - xs << html::EndTag("tr"); + xs << xml::EndTag("tr"); return ret; } -docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const +docstring Tabular::xhtml(XMLStream & xs, OutputParams const & runparams) const { docstring ret; @@ -3728,20 +3728,20 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const align = "right"; break; } - xs << html::StartTag("div", "class='longtable' style='text-align: " + align + ";'") - << html::CR(); + xs << xml::StartTag("div", "class='longtable' style='text-align: " + align + ";'") + << xml::CR(); // The caption flag wins over head/foot if (haveLTCaption()) { - xs << html::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'") - << html::CR(); + xs << xml::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'") + << xml::CR(); for (row_type r = 0; r < nrows(); ++r) if (row_info[r].caption) ret += xhtmlRow(xs, r, runparams); - xs << html::EndTag("div") << html::CR(); + xs << xml::EndTag("div") << xml::CR(); } } - xs << html::StartTag("table") << html::CR(); + xs << xml::StartTag("table") << xml::CR(); // output header info bool const havefirsthead = haveLTFirstHead(false); @@ -3750,7 +3750,7 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const // in XHTML. this test accomplishes that. bool const havehead = !havefirsthead && haveLTHead(false); if (havehead || havefirsthead) { - xs << html::StartTag("thead") << html::CR(); + xs << xml::StartTag("thead") << xml::CR(); for (row_type r = 0; r < nrows(); ++r) { if (((havefirsthead && row_info[r].endfirsthead) || (havehead && row_info[r].endhead)) && @@ -3758,14 +3758,14 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const ret += xhtmlRow(xs, r, runparams, true); } } - xs << html::EndTag("thead") << html::CR(); + xs << xml::EndTag("thead") << xml::CR(); } // output footer info bool const havelastfoot = haveLTLastFoot(false); // as before. bool const havefoot = !havelastfoot && haveLTFoot(false); if (havefoot || havelastfoot) { - xs << html::StartTag("tfoot") << html::CR(); + xs << xml::StartTag("tfoot") << xml::CR(); for (row_type r = 0; r < nrows(); ++r) { if (((havelastfoot && row_info[r].endlastfoot) || (havefoot && row_info[r].endfoot)) && @@ -3773,21 +3773,21 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const ret += xhtmlRow(xs, r, runparams); } } - xs << html::EndTag("tfoot") << html::CR(); + xs << xml::EndTag("tfoot") << xml::CR(); } - xs << html::StartTag("tbody") << html::CR(); + xs << xml::StartTag("tbody") << xml::CR(); for (row_type r = 0; r < nrows(); ++r) { if (isValidRow(r)) { ret += xhtmlRow(xs, r, runparams); } } - xs << html::EndTag("tbody") - << html::CR() - << html::EndTag("table") - << html::CR(); + xs << xml::EndTag("tbody") + << xml::CR() + << xml::EndTag("table") + << xml::CR(); if (is_long_tabular) - xs << html::EndTag("div") << html::CR(); + xs << xml::EndTag("div") << xml::CR(); return ret; } @@ -4167,7 +4167,7 @@ void InsetTableCell::addToToc(DocIterator const & di, bool output_active, } -docstring InsetTableCell::xhtml(XHTMLStream & xs, OutputParams const & rp) const +docstring InsetTableCell::xhtml(XMLStream & xs, OutputParams const & rp) const { if (!isFixedWidth) return InsetText::insetAsXHTML(xs, rp, InsetText::JustText); @@ -4203,7 +4203,6 @@ void InsetTableCell::metrics(MetricsInfo & mi, Dimension & dim) const } - ///////////////////////////////////////////////////////////////////// // // InsetTabular @@ -4377,7 +4376,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const docstring const align_d = tabular.column_info[c].decimal_point; dit = separatorPos(&tail, align_d); - pit_type const psize = tail.paragraphs().front().size(); + pos_type const psize = tail.paragraphs().front().size(); if (dit) { tail.paragraphs().front().eraseChars(0, dit.pos() < psize ? dit.pos() + 1 : psize, false); @@ -4693,7 +4692,7 @@ void InsetTabular::edit(Cursor & cur, bool front, EntryDirection) } -void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype) +void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype, bool const /*deleted*/) { // In a longtable, tell captions what the current float is Counters & cnts = buffer().masterBuffer()->params().documentClass().counters(); @@ -5967,18 +5966,18 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, } -Inset::DisplayType InsetTabular::display() const +Inset::RowFlags InsetTabular::rowFlags() const { if (tabular.is_long_tabular) { switch (tabular.longtabular_alignment) { case Tabular::LYX_LONGTABULAR_ALIGN_LEFT: - return AlignLeft; + return Display | AlignLeft; case Tabular::LYX_LONGTABULAR_ALIGN_CENTER: - return AlignCenter; + return Display; case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT: - return AlignRight; + return Display | AlignRight; default: - return AlignCenter; + return Display; } } else return Inline; @@ -6028,7 +6027,7 @@ int InsetTabular::docbook(odocstream & os, OutputParams const & runparams) const } -docstring InsetTabular::xhtml(XHTMLStream & xs, OutputParams const & rp) const +docstring InsetTabular::xhtml(XMLStream & xs, OutputParams const & rp) const { return tabular.xhtml(xs, rp); } @@ -7064,18 +7063,18 @@ bool InsetTabular::copySelection(Cursor & cur) paste_tabular.reset(new Tabular(tabular)); for (row_type r = 0; r < rs; ++r) - paste_tabular->deleteRow(0); + paste_tabular->deleteRow(0, true); row_type const rows = re - rs + 1; while (paste_tabular->nrows() > rows) - paste_tabular->deleteRow(rows); + paste_tabular->deleteRow(rows, true); for (col_type c = 0; c < cs; ++c) - paste_tabular->deleteColumn(0); + paste_tabular->deleteColumn(0, true); col_type const columns = ce - cs + 1; while (paste_tabular->ncols() > columns) - paste_tabular->deleteColumn(columns); + paste_tabular->deleteColumn(columns, true); paste_tabular->setBuffer(tabular.buffer()); @@ -7131,9 +7130,12 @@ bool InsetTabular::pasteClipboard(Cursor & cur) // FIXME?: why do we need to do this explicitly? (EL) tabular.cellInset(r2, c2)->setBuffer(tabular.buffer()); - // FIXME: change tracking (MG) - inset->setChange(Change(buffer().params().track_changes ? + if (!lyxrc.ct_markup_copied) { + // do not paste deleted text + inset->acceptChanges(); + inset->setChange(Change(buffer().params().track_changes ? Change::INSERTED : Change::UNCHANGED)); + } cur.pos() = 0; cur.pit() = 0; }