From e995e8556bd670c7183bab7e105073a5f4ccfbc0 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 21 Mar 2008 06:16:05 +0000 Subject: [PATCH] Prepare for InsetTableCell. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23858 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetTabular.cpp | 32 ++++++++++++++++---------------- src/insets/InsetTabular.h | 14 ++++++++------ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 1b6c587766..b874311ecf 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -482,7 +482,7 @@ Tabular::CellData::CellData(Buffer const & buf) right_line(false), usebox(BOX_NONE), rotate(false), - inset(new InsetText(buf)) + inset(new InsetTableCell(buf)) { inset->setBuffer(const_cast(buf)); inset->paragraphs().back().setLayout(buf.params().documentClass().emptyLayout()); @@ -503,7 +503,7 @@ Tabular::CellData::CellData(CellData const & cs) rotate(cs.rotate), align_special(cs.align_special), p_width(cs.p_width), - inset(dynamic_cast(cs.inset->clone())) + inset(dynamic_cast(cs.inset->clone())) {} @@ -1018,7 +1018,7 @@ namespace { * merge cell paragraphs and reset layout to standard for variable width * cells. */ -void toggleFixedWidth(Cursor & cur, InsetText * inset, bool fixedWidth) +void toggleFixedWidth(Cursor & cur, InsetTableCell * inset, bool fixedWidth) { inset->setAutoBreakRows(fixedWidth); if (fixedWidth) @@ -2226,7 +2226,7 @@ int Tabular::TeXRow(odocstream & os, row_type i, if (isPartOfMultiColumn(i, j)) continue; ret += TeXCellPreamble(os, cell); - shared_ptr inset = getCellInset(cell); + shared_ptr inset = getCellInset(cell); Paragraph const & par = inset->paragraphs().front(); bool rtl = par.isRTL(buffer().params()) @@ -2743,13 +2743,13 @@ void Tabular::plaintext(odocstream & os, } -shared_ptr Tabular::getCellInset(idx_type cell) const +shared_ptr Tabular::getCellInset(idx_type cell) const { return cell_info[cellRow(cell)][cellColumn(cell)].inset; } -shared_ptr Tabular::getCellInset(row_type row, +shared_ptr Tabular::getCellInset(row_type row, col_type column) const { return cell_info[row][column].inset; @@ -2757,7 +2757,7 @@ shared_ptr Tabular::getCellInset(row_type row, void Tabular::setCellInset(row_type row, col_type column, - shared_ptr ins) const + shared_ptr ins) const { cell_info[row][column].inset = ins; } @@ -3222,7 +3222,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) && tablemode(bvcur)) ; else - // Let InsetText do it + // Let InsetTableCell do it cell(cur.idx())->dispatch(cur, cmd); break; } @@ -3871,13 +3871,13 @@ void InsetTabular::validate(LaTeXFeatures & features) const } -shared_ptr InsetTabular::cell(idx_type idx) const +shared_ptr InsetTabular::cell(idx_type idx) const { return tabular.getCellInset(idx); } -shared_ptr InsetTabular::cell(idx_type idx) +shared_ptr InsetTabular::cell(idx_type idx) { return tabular.getCellInset(idx); } @@ -4593,8 +4593,8 @@ bool InsetTabular::pasteClipboard(Cursor & cur) --c1; continue; } - shared_ptr inset( - new InsetText(*paste_tabular->getCellInset(r1, c1))); + shared_ptr inset( + new InsetTableCell(*paste_tabular->getCellInset(r1, c1))); tabular.setCellInset(r2, c2, inset); // FIXME: change tracking (MG) inset->setChange(Change(cur.buffer().params().trackChanges ? @@ -4616,7 +4616,7 @@ void InsetTabular::cutSelection(Cursor & cur) getSelection(cur, rs, re, cs, ce); for (row_type i = rs; i <= re; ++i) { for (col_type j = cs; j <= ce; ++j) { - shared_ptr t + shared_ptr t = cell(tabular.cellIndex(i, j)); if (cur.buffer().params().trackChanges) // FIXME: Change tracking (MG) @@ -4765,7 +4765,7 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf, case '\t': // we can only set this if we are not too far right if (cols < columns) { - shared_ptr inset = loctab->getCellInset(cell); + shared_ptr inset = loctab->getCellInset(cell); Font const font = bv.textMetrics(&inset->text_). displayFont(0, 0); inset->setText(buf.substr(op, p - op), font, @@ -4777,7 +4777,7 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf, case '\n': // we can only set this if we are not too far right if (cols < columns) { - shared_ptr inset = tabular.getCellInset(cell); + shared_ptr inset = tabular.getCellInset(cell); Font const font = bv.textMetrics(&inset->text_). displayFont(0, 0); inset->setText(buf.substr(op, p - op), font, @@ -4794,7 +4794,7 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf, } // check for the last cell if there is no trailing '\n' if (cell < cells && op < len) { - shared_ptr inset = loctab->getCellInset(cell); + shared_ptr inset = loctab->getCellInset(cell); Font const font = bv.textMetrics(&inset->text_).displayFont(0, 0); inset->setText(buf.substr(op, len - op), font, buffer().params().trackChanges); diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 829c9e9e6c..a54099ea9d 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -65,6 +65,8 @@ class InsetTabular; class Cursor; class OutputParams; +typedef InsetText InsetTableCell; + // // A helper struct for tables // @@ -443,13 +445,13 @@ public: /// // end longtable support /// - boost::shared_ptr getCellInset(idx_type cell) const; + boost::shared_ptr getCellInset(idx_type cell) const; /// - boost::shared_ptr getCellInset(row_type row, + boost::shared_ptr getCellInset(row_type row, col_type column) const; /// void setCellInset(row_type row, col_type column, - boost::shared_ptr) const; + boost::shared_ptr) const; /// Search for \param inset in the tabular, with the /// idx_type getCellFromInset(Inset const * inset) const; @@ -499,7 +501,7 @@ public: /// Length p_width; // this is only set for multicolumn!!! /// - boost::shared_ptr inset; + boost::shared_ptr inset; }; CellData & cellinfo_of_cell(idx_type cell) const; /// @@ -722,9 +724,9 @@ public: /// number of cells size_t nargs() const { return tabular.cellCount(); } /// - boost::shared_ptr cell(idx_type) const; + boost::shared_ptr cell(idx_type) const; /// - boost::shared_ptr cell(idx_type); + boost::shared_ptr cell(idx_type); /// Text * getText(int) const; -- 2.39.5