]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
* Painter.h:
[lyx.git] / src / tabular.C
index bb28318de32bba4404cc46029793065e9159755d..bb185489b9061316eee9fae285bd4f5c82a06dcd 100644 (file)
 
 #include <sstream>
 
-using lyx::docstring;
-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;
@@ -499,7 +501,7 @@ void LyXTabular::appendRow(BufferParams const & bp, idx_type const cell)
        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();
 }
@@ -528,7 +530,7 @@ void LyXTabular::copyRow(BufferParams const & bp, row_type const 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();
 }
@@ -558,9 +560,9 @@ void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell)
        //++column;
        for (row_type i = 0; i < rows_; ++i) {
                cell_info[i][column + 1].inset->clear();
+               // FIXME: Change Tracking (MG)
                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();
 }
@@ -592,7 +594,7 @@ void LyXTabular::copyColumn(BufferParams const & bp, col_type const 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();
 }
 
@@ -1827,7 +1829,7 @@ bool LyXTabular::isPartOfMultiColumn(row_type row, col_type column) const
 }
 
 
-int LyXTabular::TeXTopHLine(ostream & os, row_type row) const
+int LyXTabular::TeXTopHLine(odocstream & os, row_type row) const
 {
        // FIXME: assert or return 0 as in TeXBottomHLine()?
        BOOST_ASSERT(row != npos);
@@ -1863,7 +1865,7 @@ int LyXTabular::TeXTopHLine(ostream & os, row_type row) const
 }
 
 
-int LyXTabular::TeXBottomHLine(ostream & os, row_type row) const
+int LyXTabular::TeXBottomHLine(odocstream & os, row_type row) const
 {
        // FIXME: return 0 or assert as in TeXTopHLine()?
        if (row == npos || row >= rows_)
@@ -1899,7 +1901,7 @@ int LyXTabular::TeXBottomHLine(ostream & os, row_type row) const
 }
 
 
-int LyXTabular::TeXCellPreamble(ostream & os, idx_type cell) const
+int LyXTabular::TeXCellPreamble(odocstream & os, idx_type cell) const
 {
        int ret = 0;
 
@@ -1910,7 +1912,8 @@ int LyXTabular::TeXCellPreamble(ostream & os, idx_type cell) const
        if (isMultiColumn(cell)) {
                os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
                if (!cellinfo_of_cell(cell).align_special.empty()) {
-                       os << cellinfo_of_cell(cell).align_special << "}{";
+                       os << from_ascii(cellinfo_of_cell(cell).align_special)
+                          << "}{";
                } else {
                        if (leftLine(cell) &&
                                (isFirstCellInRow(cell) ||
@@ -1932,7 +1935,7 @@ int LyXTabular::TeXCellPreamble(ostream & os, idx_type cell) const
                                        break;
                                }
                                os << '{'
-                                  << getPWidth(cell).asLatexString()
+                                  << from_ascii(getPWidth(cell).asLatexString())
                                   << '}';
                        } else {
                                switch (getAlignment(cell)) {
@@ -1968,7 +1971,8 @@ int LyXTabular::TeXCellPreamble(ostream & os, idx_type cell) const
                        os << 'b';
                        break;
                }
-               os << "]{" << getPWidth(cell).asLatexString() << "}{";
+               os << "]{" << from_ascii(getPWidth(cell).asLatexString())
+                  << "}{";
        } else if (getUsebox(cell) == BOX_MINIPAGE) {
                os << "\\begin{minipage}[";
                switch (getVAlignment(cell)) {
@@ -1982,14 +1986,15 @@ int LyXTabular::TeXCellPreamble(ostream & os, idx_type cell) const
                        os << 'b';
                        break;
                }
-               os << "]{" << getPWidth(cell).asLatexString() << "}\n";
+               os << "]{" << from_ascii(getPWidth(cell).asLatexString())
+                  << "}\n";
                ++ret;
        }
        return ret;
 }
 
 
-int LyXTabular::TeXCellPostamble(ostream & os, idx_type cell) const
+int LyXTabular::TeXCellPostamble(odocstream & os, idx_type cell) const
 {
        int ret = 0;
 
@@ -2011,7 +2016,7 @@ int LyXTabular::TeXCellPostamble(ostream & os, idx_type cell) const
 }
 
 
-int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const & buf,
+int LyXTabular::TeXLongtableHeaderFooter(odocstream & os, Buffer const & buf,
                                         OutputParams const & runparams) const
 {
        if (!is_long_tabular)
@@ -2111,7 +2116,7 @@ bool LyXTabular::isValidRow(row_type row) const
 }
 
 
-int LyXTabular::TeXRow(ostream & os, row_type i, Buffer const & buf,
+int LyXTabular::TeXRow(odocstream & os, row_type i, Buffer const & buf,
                       OutputParams const & runparams) const
 {
        idx_type cell = getCellNumber(i, 0);
@@ -2124,10 +2129,12 @@ int LyXTabular::TeXRow(ostream & os, row_type i, Buffer const & buf,
        } else if(!row_info[i].top_space.zero()) {
                if (use_booktabs)
                        os << "\\addlinespace["
-                          << row_info[i].top_space.asLatexString() << "]\n";
+                          << from_ascii(row_info[i].top_space.asLatexString())
+                          << "]\n";
                else {
                        os << "\\noalign{\\vskip"
-                          << row_info[i].top_space.asLatexString() << "}\n";
+                          << from_ascii(row_info[i].top_space.asLatexString())
+                          << "}\n";
                }
                ++ret;
        }
@@ -2151,8 +2158,7 @@ int LyXTabular::TeXRow(ostream & os, row_type i, Buffer const & buf,
 
                ret += TeXCellPostamble(os, cell);
                if (!isLastCellInRow(cell)) { // not last cell in row
-                       os << "&\n";
-                       ++ret;
+                       os << " & ";
                }
                ++cell;
        }
@@ -2165,7 +2171,9 @@ int LyXTabular::TeXRow(ostream & os, row_type i, Buffer const & buf,
        } else if (!row_info[i].bottom_space.zero()) {
                if (use_booktabs)
                        os << "\\addlinespace";
-               os << '[' << row_info[i].bottom_space.asLatexString() << ']';
+               os << '['
+                  << from_ascii(row_info[i].bottom_space.asLatexString())
+                  << ']';
        }
        os << '\n';
        ++ret;
@@ -2178,11 +2186,11 @@ int LyXTabular::TeXRow(ostream & os, row_type i, Buffer const & buf,
        } else if (!row_info[i].interline_space.zero()) {
                if (use_booktabs)
                        os << "\\addlinespace["
-                          << row_info[i].interline_space.asLatexString()
+                          << from_ascii(row_info[i].interline_space.asLatexString())
                           << "]\n";
                else
                        os << "\\noalign{\\vskip"
-                          << row_info[i].interline_space.asLatexString()
+                          << from_ascii(row_info[i].interline_space.asLatexString())
                           << "}\n";
                ++ret;
        }
@@ -2190,7 +2198,7 @@ int LyXTabular::TeXRow(ostream & os, row_type i, Buffer const & buf,
 }
 
 
-int LyXTabular::latex(Buffer const & buf, ostream & os,
+int LyXTabular::latex(Buffer const & buf, odocstream & os,
                      OutputParams const & runparams) const
 {
        int ret = 0;
@@ -2209,7 +2217,7 @@ int LyXTabular::latex(Buffer const & buf, ostream & os,
                os << "\\begin{tabular}{";
        for (col_type i = 0; i < columns_; ++i) {
                if (!column_info[i].align_special.empty()) {
-                       os << column_info[i].align_special;
+                       os << from_ascii(column_info[i].align_special);
                } else {
                        if (!use_booktabs && column_info[i].left_line)
                                os << '|';
@@ -2243,7 +2251,7 @@ int LyXTabular::latex(Buffer const & buf, ostream & os,
                                        break;
                        }
                                os << '{'
-                                  << column_info[i].p_width.asLatexString()
+                                  << from_ascii(column_info[i].p_width.asLatexString())
                                   << '}';
                        } else {
                                switch (column_info[i].alignment) {
@@ -2298,7 +2306,7 @@ int LyXTabular::latex(Buffer const & buf, ostream & os,
 }
 
 
-int LyXTabular::docbookRow(Buffer const & buf, ostream & os, row_type row,
+int LyXTabular::docbookRow(Buffer const & buf, odocstream & os, row_type row,
                           OutputParams const & runparams) const
 {
        int ret = 0;
@@ -2350,7 +2358,7 @@ int LyXTabular::docbookRow(Buffer const & buf, ostream & os, row_type row,
 }
 
 
-int LyXTabular::docbook(Buffer const & buf, ostream & os,
+int LyXTabular::docbook(Buffer const & buf, odocstream & os,
                        OutputParams const & runparams) const
 {
        int ret = 0;
@@ -2435,7 +2443,7 @@ int LyXTabular::docbook(Buffer const & buf, ostream & os,
 }
 
 
-int LyXTabular::asciiTopHLine(lyx::odocstream & os, row_type row,
+int LyXTabular::asciiTopHLine(odocstream & os, row_type row,
                              vector<unsigned int> const & clen) const
 {
        idx_type const fcell = getFirstCellInRow(row);
@@ -2451,7 +2459,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))
@@ -2483,7 +2491,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<unsigned int> const & clen) const
 {
        idx_type const fcell = getFirstCellInRow(row);
@@ -2499,7 +2507,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))
@@ -2531,13 +2539,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<unsigned int> const & clen,
                               bool onlydata) const
 {
-       lyx::odocstringstream sstr;
+       odocstringstream sstr;
        int const ret = getCellInset(cell)->plaintext(buf, sstr, runparams);
 
        if (onlydata) {
@@ -2584,7 +2592,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
@@ -2602,7 +2610,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();
@@ -2614,7 +2622,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);
@@ -2725,3 +2733,6 @@ LyXTabular::BoxType LyXTabular::useParbox(idx_type cell) const
 
        return BOX_NONE;
 }
+
+
+} // namespace lyx