X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftabular.C;h=711e5432ab5f1044e0fa8b5c219f034386ae6ad0;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=614c0a33724a737ffb64a4cb90ce3e86dfa1d1ba;hpb=0d449056ef9ace3ef737e4b9aba8d3994615dc18;p=lyx.git diff --git a/src/tabular.C b/src/tabular.C index 614c0a3372..711e5432ab 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -37,12 +37,13 @@ #include -using lyx::docstring; -using lyx::odocstream; -using lyx::support::ltrim; -using lyx::support::prefixIs; -using lyx::support::rtrim; -using lyx::support::suffixIs; + +namespace lyx { + +using support::prefixIs; +using support::ltrim; +using support::rtrim; +using support::suffixIs; using boost::shared_ptr; using boost::dynamic_pointer_cast; @@ -498,9 +499,8 @@ void LyXTabular::appendRow(BufferParams const & bp, idx_type const cell) swap(cell_info[i], old[i - 1]); if (bp.trackChanges) - // FIXME: Change Tracking (MG) for (col_type j = 0; j < columns_; ++j) - cell_info[row + 1][j].inset->markNew(true); + cell_info[row + 1][j].inset->setChange(Change(Change::INSERTED)); set_row_column_number_info(); } @@ -527,9 +527,8 @@ void LyXTabular::copyRow(BufferParams const & bp, row_type const row) cell_info.insert(cell_info.begin() + row, cell_info[row]); if (bp.trackChanges) - // FIXME: Change Tracking (MG) for (col_type j = 0; j < columns_; ++j) - cell_info[row + 1][j].inset->markNew(true); + cell_info[row + 1][j].inset->setChange(Change(Change::INSERTED)); set_row_column_number_info(); } @@ -560,8 +559,7 @@ void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell) for (row_type i = 0; i < rows_; ++i) { cell_info[i][column + 1].inset->clear(); if (bp.trackChanges) - // FIXME: Change Tracking (MG) - cell_info[i][column + 1].inset->markNew(true); + cell_info[i][column + 1].inset->setChange(Change(Change::INSERTED)); } fixCellNums(); } @@ -591,9 +589,8 @@ void LyXTabular::copyColumn(BufferParams const & bp, col_type const column) cell_info[i].insert(cell_info[i].begin() + column, cell_info[i][column]); if (bp.trackChanges) - // FIXME: Change Tracking (MG) for (row_type i = 0; i < rows_; ++i) - cell_info[i][column + 1].inset->markNew(true); + cell_info[i][column + 1].inset->setChange(Change(Change::INSERTED)); fixCellNums(); } @@ -665,29 +662,29 @@ LyXTabular::idx_type LyXTabular::numberOfCellsInRow(idx_type const cell) const } -bool LyXTabular::topLine(idx_type const cell, bool const onlycolumn) const +bool LyXTabular::topLine(idx_type const cell, bool const wholerow) const { - if (!onlycolumn && isMultiColumn(cell) && + if (!wholerow && isMultiColumn(cell) && !(use_booktabs && row_of_cell(cell) == 0)) return cellinfo_of_cell(cell).top_line; return row_info[row_of_cell(cell)].top_line; } -bool LyXTabular::bottomLine(idx_type const cell, bool onlycolumn) const +bool LyXTabular::bottomLine(idx_type const cell, bool wholerow) const { - if (!onlycolumn && isMultiColumn(cell) && + if (!wholerow && isMultiColumn(cell) && !(use_booktabs && isLastRow(cell))) return cellinfo_of_cell(cell).bottom_line; return row_info[row_of_cell(cell)].bottom_line; } -bool LyXTabular::leftLine(idx_type cell, bool onlycolumn) const +bool LyXTabular::leftLine(idx_type cell, bool wholecolumn) const { if (use_booktabs) return false; - if (!onlycolumn && isMultiColumn(cell) && + if (!wholecolumn && isMultiColumn(cell) && (isFirstCellInRow(cell) || isMultiColumn(cell-1))) { if (cellinfo_of_cell(cell).align_special.empty()) @@ -700,11 +697,11 @@ bool LyXTabular::leftLine(idx_type cell, bool onlycolumn) const } -bool LyXTabular::rightLine(idx_type cell, bool onlycolumn) const +bool LyXTabular::rightLine(idx_type cell, bool wholecolumn) const { if (use_booktabs) return false; - if (!onlycolumn && isMultiColumn(cell) && + if (!wholecolumn && isMultiColumn(cell) && (isLastCellInRow(cell) || isMultiColumn(cell + 1))) { if (cellinfo_of_cell(cell).align_special.empty()) @@ -955,15 +952,14 @@ void toggleFixedWidth(LCursor & cur, InsetText * inset, bool fixedWidth) return; // merge all paragraphs to one - BufferParams const & bp = - inset->getText(0)->bv_owner->buffer()->params(); + BufferParams const & bp = cur.bv().buffer()->params(); while (inset->paragraphs().size() > 1) mergeParagraph(bp, inset->paragraphs(), 0); // reset layout cur.push(*inset); // undo information has already been recorded - inset->getText(0)->setLayout(0, cur.lastpit() + 1, + inset->getText(0)->setLayout(*cur.bv().buffer(), 0, cur.lastpit() + 1, bp.getLyXTextClass().defaultLayoutName()); cur.pop(); } @@ -1029,37 +1025,37 @@ void LyXTabular::setAllLines(idx_type cell, bool line) } -void LyXTabular::setTopLine(idx_type cell, bool line, bool onlycolumn) +void LyXTabular::setTopLine(idx_type cell, bool line, bool wholerow) { row_type const row = row_of_cell(cell); - if (onlycolumn || !isMultiColumn(cell)) + if (wholerow || !isMultiColumn(cell)) row_info[row].top_line = line; else cellinfo_of_cell(cell).top_line = line; } -void LyXTabular::setBottomLine(idx_type cell, bool line, bool onlycolumn) +void LyXTabular::setBottomLine(idx_type cell, bool line, bool wholerow) { - if (onlycolumn || !isMultiColumn(cell)) + if (wholerow || !isMultiColumn(cell)) row_info[row_of_cell(cell)].bottom_line = line; else cellinfo_of_cell(cell).bottom_line = line; } -void LyXTabular::setLeftLine(idx_type cell, bool line, bool onlycolumn) +void LyXTabular::setLeftLine(idx_type cell, bool line, bool wholecolumn) { - if (onlycolumn || !isMultiColumn(cell)) + if (wholecolumn || !isMultiColumn(cell)) column_info[column_of_cell(cell)].left_line = line; else cellinfo_of_cell(cell).left_line = line; } -void LyXTabular::setRightLine(idx_type cell, bool line, bool onlycolumn) +void LyXTabular::setRightLine(idx_type cell, bool line, bool wholecolumn) { - if (onlycolumn || !isMultiColumn(cell)) + if (wholecolumn || !isMultiColumn(cell)) column_info[right_column_of_cell(cell)].right_line = line; else cellinfo_of_cell(cell).right_line = line; @@ -1911,7 +1907,7 @@ int LyXTabular::TeXCellPreamble(odocstream & os, idx_type cell) const if (isMultiColumn(cell)) { os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{"; if (!cellinfo_of_cell(cell).align_special.empty()) { - os << lyx::from_ascii(cellinfo_of_cell(cell).align_special) + os << from_ascii(cellinfo_of_cell(cell).align_special) << "}{"; } else { if (leftLine(cell) && @@ -1934,7 +1930,7 @@ int LyXTabular::TeXCellPreamble(odocstream & os, idx_type cell) const break; } os << '{' - << lyx::from_ascii(getPWidth(cell).asLatexString()) + << from_ascii(getPWidth(cell).asLatexString()) << '}'; } else { switch (getAlignment(cell)) { @@ -1970,7 +1966,7 @@ int LyXTabular::TeXCellPreamble(odocstream & os, idx_type cell) const os << 'b'; break; } - os << "]{" << lyx::from_ascii(getPWidth(cell).asLatexString()) + os << "]{" << from_ascii(getPWidth(cell).asLatexString()) << "}{"; } else if (getUsebox(cell) == BOX_MINIPAGE) { os << "\\begin{minipage}["; @@ -1985,7 +1981,7 @@ int LyXTabular::TeXCellPreamble(odocstream & os, idx_type cell) const os << 'b'; break; } - os << "]{" << lyx::from_ascii(getPWidth(cell).asLatexString()) + os << "]{" << from_ascii(getPWidth(cell).asLatexString()) << "}\n"; ++ret; } @@ -2128,11 +2124,11 @@ int LyXTabular::TeXRow(odocstream & os, row_type i, Buffer const & buf, } else if(!row_info[i].top_space.zero()) { if (use_booktabs) os << "\\addlinespace[" - << lyx::from_ascii(row_info[i].top_space.asLatexString()) + << from_ascii(row_info[i].top_space.asLatexString()) << "]\n"; else { os << "\\noalign{\\vskip" - << lyx::from_ascii(row_info[i].top_space.asLatexString()) + << from_ascii(row_info[i].top_space.asLatexString()) << "}\n"; } ++ret; @@ -2157,8 +2153,7 @@ int LyXTabular::TeXRow(odocstream & os, row_type i, Buffer const & buf, ret += TeXCellPostamble(os, cell); if (!isLastCellInRow(cell)) { // not last cell in row - os << "&\n"; - ++ret; + os << " & "; } ++cell; } @@ -2172,7 +2167,7 @@ int LyXTabular::TeXRow(odocstream & os, row_type i, Buffer const & buf, if (use_booktabs) os << "\\addlinespace"; os << '[' - << lyx::from_ascii(row_info[i].bottom_space.asLatexString()) + << from_ascii(row_info[i].bottom_space.asLatexString()) << ']'; } os << '\n'; @@ -2186,11 +2181,11 @@ int LyXTabular::TeXRow(odocstream & os, row_type i, Buffer const & buf, } else if (!row_info[i].interline_space.zero()) { if (use_booktabs) os << "\\addlinespace[" - << lyx::from_ascii(row_info[i].interline_space.asLatexString()) + << from_ascii(row_info[i].interline_space.asLatexString()) << "]\n"; else os << "\\noalign{\\vskip" - << lyx::from_ascii(row_info[i].interline_space.asLatexString()) + << from_ascii(row_info[i].interline_space.asLatexString()) << "}\n"; ++ret; } @@ -2217,7 +2212,7 @@ int LyXTabular::latex(Buffer const & buf, odocstream & os, os << "\\begin{tabular}{"; for (col_type i = 0; i < columns_; ++i) { if (!column_info[i].align_special.empty()) { - os << lyx::from_ascii(column_info[i].align_special); + os << from_ascii(column_info[i].align_special); } else { if (!use_booktabs && column_info[i].left_line) os << '|'; @@ -2251,7 +2246,7 @@ int LyXTabular::latex(Buffer const & buf, odocstream & os, break; } os << '{' - << lyx::from_ascii(column_info[i].p_width.asLatexString()) + << from_ascii(column_info[i].p_width.asLatexString()) << '}'; } else { switch (column_info[i].alignment) { @@ -2443,7 +2438,7 @@ int LyXTabular::docbook(Buffer const & buf, odocstream & os, } -int LyXTabular::asciiTopHLine(lyx::odocstream & os, row_type row, +int LyXTabular::asciiTopHLine(odocstream & os, row_type row, vector const & clen) const { idx_type const fcell = getFirstCellInRow(row); @@ -2459,7 +2454,7 @@ int LyXTabular::asciiTopHLine(lyx::odocstream & os, row_type row, if (!tmp) return 0; - lyx::char_type ch; + char_type ch; for (idx_type i = fcell; i < n; ++i) { if (topLine(i)) { if (leftLine(i)) @@ -2491,7 +2486,7 @@ int LyXTabular::asciiTopHLine(lyx::odocstream & os, row_type row, } -int LyXTabular::asciiBottomHLine(lyx::odocstream & os, row_type row, +int LyXTabular::asciiBottomHLine(odocstream & os, row_type row, vector const & clen) const { idx_type const fcell = getFirstCellInRow(row); @@ -2507,7 +2502,7 @@ int LyXTabular::asciiBottomHLine(lyx::odocstream & os, row_type row, if (!tmp) return 0; - lyx::char_type ch; + char_type ch; for (idx_type i = fcell; i < n; ++i) { if (bottomLine(i)) { if (leftLine(i)) @@ -2539,13 +2534,13 @@ int LyXTabular::asciiBottomHLine(lyx::odocstream & os, row_type row, } -int LyXTabular::asciiPrintCell(Buffer const & buf, lyx::odocstream & os, +int LyXTabular::asciiPrintCell(Buffer const & buf, odocstream & os, OutputParams const & runparams, idx_type cell, row_type row, col_type column, vector const & clen, bool onlydata) const { - lyx::odocstringstream sstr; + odocstringstream sstr; int const ret = getCellInset(cell)->plaintext(buf, sstr, runparams); if (onlydata) { @@ -2592,7 +2587,7 @@ int LyXTabular::asciiPrintCell(Buffer const & buf, lyx::odocstream & os, } -int LyXTabular::plaintext(Buffer const & buf, lyx::odocstream & os, +int LyXTabular::plaintext(Buffer const & buf, odocstream & os, OutputParams const & runparams, int const depth, bool onlydata, unsigned char delim) const @@ -2610,7 +2605,7 @@ int LyXTabular::plaintext(Buffer const & buf, lyx::odocstream & os, idx_type cell = getCellNumber(i, j); if (isMultiColumnReal(cell)) continue; - lyx::odocstringstream sstr; + odocstringstream sstr; getCellInset(cell)->plaintext(buf, sstr, runparams); if (clen[j] < sstr.str().length()) clen[j] = sstr.str().length(); @@ -2622,7 +2617,7 @@ int LyXTabular::plaintext(Buffer const & buf, lyx::odocstream & os, idx_type cell = getCellNumber(i, j); if (!isMultiColumnReal(cell) || isPartOfMultiColumn(i, j)) continue; - lyx::odocstringstream sstr; + odocstringstream sstr; getCellInset(cell)->plaintext(buf, sstr, runparams); int len = int(sstr.str().length()); idx_type const n = cells_in_multicolumn(cell); @@ -2733,3 +2728,6 @@ LyXTabular::BoxType LyXTabular::useParbox(idx_type cell) const return BOX_NONE; } + + +} // namespace lyx