]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
fix reading the author field.
[lyx.git] / src / tabular.C
index 2294c231a58f8fb6b76405e1ceed508270529425..b8957c2ba2a6723a7c369b3bb4d9120c75b78144 100644 (file)
@@ -32,7 +32,7 @@
 #include "support/lstrings.h"
 #include "support/tostr.h"
 
-#include "support/std_sstream.h"
+#include <sstream>
 
 using lyx::support::ltrim;
 using lyx::support::prefixIs;
@@ -377,7 +377,9 @@ void LyXTabular::fixCellNums()
        int cellno = 0;
        for (int i = 0; i < rows_; ++i) {
                for (int j = 0; j < columns_; ++j) {
-                       cell_info[i][j].inset.setDrawFrame(InsetText::LOCKED);
+                       // When debugging it can be nice to set
+                       // this to true.
+                       cell_info[i][j].inset.setDrawFrame(false);
                        cell_info[i][j].cellno = cellno++;
                }
                cell_info[i].back().right_line = true;
@@ -387,17 +389,6 @@ void LyXTabular::fixCellNums()
 }
 
 
-void LyXTabular::setOwner(InsetTabular * inset)
-{
-       for (int i = 0; i < rows_; ++i) {
-               for (int j = 0; j < columns_; ++j) {
-                       cell_info[i][j].inset.setOwner(inset);
-                       cell_info[i][j].inset.setDrawFrame(InsetText::LOCKED);
-               }
-       }
-}
-
-
 void LyXTabular::appendRow(BufferParams const & bp, int cell)
 {
        ++rows_;
@@ -1135,7 +1126,7 @@ void LyXTabular::write(Buffer const & buf, ostream & os) const
                           << ">\n";
                        os << "\\begin_inset ";
                        cell_info[i][j].inset.write(buf, os);
-                       os << "\n\\end_inset \n"
+                       os << "\n\\end_inset\n"
                           << "</cell>\n";
                }
                os << "</row>\n";
@@ -1692,8 +1683,7 @@ int LyXTabular::getAscentOfRow(int row) const
 
 int LyXTabular::getDescentOfRow(int row) const
 {
-       if (row >= rows_)
-               return 0;
+       BOOST_ASSERT(row < rows_);
        return row_info[row].descent_of_row;
 }
 
@@ -1710,16 +1700,16 @@ int LyXTabular::getHeightOfTabular() const
 
 bool LyXTabular::isPartOfMultiColumn(int row, int column) const
 {
-       if (row >= rows_ || column >= columns_)
-               return false;
+       BOOST_ASSERT(row < rows_);
+       BOOST_ASSERT(column < columns_);
        return cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN;
 }
 
 
 int LyXTabular::TeXTopHLine(ostream & os, int row) const
 {
-       if (row < 0 || row >= rows_)
-               return 0;
+       BOOST_ASSERT(row >= 0);
+       BOOST_ASSERT(row < rows_);
 
        int const fcell = getFirstCellInRow(row);
        int const n = numberOfCellsInRow(fcell) + fcell;
@@ -1999,7 +1989,6 @@ int LyXTabular::TeXRow(ostream & os, int i, Buffer const & buf,
 {
        int ret = 0;
        int cell = getCellNumber(i, 0);
-       BufferParams const & bufferparams = buf.params();
 
        ret += TeXTopHLine(os, i);
        for (int j = 0; j < columns_; ++j) {
@@ -2008,8 +1997,10 @@ int LyXTabular::TeXRow(ostream & os, int i, Buffer const & buf,
                ret += TeXCellPreamble(os, cell);
                InsetText & inset = getCellInset(cell);
 
-               bool rtl = inset.paragraphs().begin()->isRightToLeftPar(bufferparams) &&
-                       !inset.paragraphs().begin()->empty() && getPWidth(cell).zero();
+               Paragraph & par = inset.paragraphs().front();
+               bool rtl = par.isRightToLeftPar(buf.params())
+                       && !par.empty()
+                       && getPWidth(cell).zero();
 
                if (rtl)
                        os << "\\R{";
@@ -2260,7 +2251,10 @@ int LyXTabular::docbook(Buffer const & buf, ostream & os,
                        os << "center";
                        break;
                }
-               os << "\">\n";
+               os << '"';
+               if (runparams.flavor == OutputParams::XML)
+                       os << '/';
+               os << ">\n";
                ++ret;
        }
 
@@ -2347,7 +2341,8 @@ int LyXTabular::asciiTopHLine(ostream & os, int row,
                }
                int column = column_of_cell(i);
                int len = clen[column];
-               while (isPartOfMultiColumn(row, ++column))
+               while (column < columns_ - 1  
+                      && isPartOfMultiColumn(row, ++column))
                        len += clen[column] + 4;
                os << string(len, ch);
                if (topLine(i)) {
@@ -2394,7 +2389,8 @@ int LyXTabular::asciiBottomHLine(ostream & os, int row,
                }
                int column = column_of_cell(i);
                int len = clen[column];
-               while (isPartOfMultiColumn(row, ++column))
+               while (column < columns_ -1
+                      && isPartOfMultiColumn(row, ++column))
                        len += clen[column] + 4;
                os << string(len, ch);
                if (bottomLine(i)) {
@@ -2432,7 +2428,8 @@ int LyXTabular::asciiPrintCell(Buffer const & buf, ostream & os,
 
        unsigned int len1 = sstr.str().length();
        unsigned int len2 = clen[column];
-       while (isPartOfMultiColumn(row, ++column))
+       while (column < columns_ -1
+              && isPartOfMultiColumn(row, ++column))
                len2 += clen[column] + 4;
        len2 -= len1;
 
@@ -2542,12 +2539,12 @@ InsetText & LyXTabular::getCellInset(int row, int column) const
 }
 
 
-int LyXTabular::getCellFromInset(InsetOld const * inset) const
+int LyXTabular::getCellFromInset(InsetBase const * inset) const
 {
        // is this inset part of the tabular?
        if (!inset) {
                lyxerr << "Error: this is not a cell of the tabular!" << endl;
-               return -1;
+               BOOST_ASSERT(false);
        }
 
        for (int cell = 0, n = getNumberOfCells(); cell < n; ++cell)
@@ -2560,7 +2557,9 @@ int LyXTabular::getCellFromInset(InsetOld const * inset) const
        // We should have found a cell at this point
        lyxerr << "LyXTabular::getCellFromInset: Cell of inset "
                << inset << " not found!" << endl;
-       return -1;
+       BOOST_ASSERT(false);
+       // shut up compiler
+       return 0;
 }