]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
Dekels tabular/textinset patches
[lyx.git] / src / tabular.C
index e417847a0272f4614d4c6d4dbcf482c5576eae62..a7115bdb68ba30bffa2863c41eac27b2a3ef0765 100644 (file)
@@ -323,31 +323,6 @@ void LyXTabular::set_row_column_number_info(bool oldformat)
     rowofcell.resize(numberofcells);
     columnofcell.resize(numberofcells);
 
-#if 0
-    int row = 0;
-    int column = 0;
-    int c = 0;
-    
-    while (c < numberofcells && row < rows_ && column < columns_) {
-       rowofcell[c] = row;
-       columnofcell[c] = column;
-       ++c;
-       do {
-           ++column;
-       } while (column < columns_ &&
-                cell_info[row][column].multicolumn
-                == LyXTabular::CELL_PART_OF_MULTICOLUMN);
-       if (column == columns_) {
-           column = 0;
-           ++row;
-       }
-    }
-#else
-    // Isn't this the same as the while above? (Lgb)
-#ifdef WITH_WARNINGS
-#warning Please check this Jürgen.
-#endif
-    // if ok please delete the #if 0 section above. (Lgb)
     for (int row = 0, column = 0, c = 0;
         c < numberofcells && row < rows_ && column < columns_;) {
        rowofcell[c] = row;
@@ -363,7 +338,6 @@ void LyXTabular::set_row_column_number_info(bool oldformat)
            ++row;
        }
     }
-#endif
 
     for (int row = 0; row < rows_; ++row) {
        for (int column = 0; column < columns_; ++column) {
@@ -1393,7 +1367,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
     string tmptok;
     int pos = 0;
     char depth = 0;
-    LyXFont font(LyXFont::ALL_SANE);
+    LyXFont font(LyXFont::ALL_INHERIT);
     font.setLanguage(owner_->BufferOwner()->GetLanguage());
 
     while (lex.IsOK()) {
@@ -1463,7 +1437,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
                par->InsertChar(i, ' ');
            }
        }
-       par->CopyIntoMinibuffer(owner_->BufferOwner()->params, i);
+       par->CopyIntoMinibuffer(*owner_->BufferOwner(), i);
        inset->par->InsertFromMinibuffer(inset->par->Last());
     }
     delete par;
@@ -2034,8 +2008,8 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
     }
     if (IsMultiColumn(cell)) {
        os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
-       if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
-           os << cellinfo_of_cell(cell+1)->align_special << "}{";
+       if (!cellinfo_of_cell(cell)->align_special.empty()) {
+           os << cellinfo_of_cell(cell)->align_special << "}{";
        } else {
            if (LeftLine(cell))
                os << '|';
@@ -2221,7 +2195,16 @@ int LyXTabular::Latex(Buffer const * buf,
            if (IsPartOfMultiColumn(i,j))
                continue;
            ret += TeXCellPreamble(os, cell);
-           ret += GetCellInset(cell)->Latex(buf, os, fragile, fp);
+           InsetText * inset = GetCellInset(cell);
+
+           bool rtl = inset->par->isRightToLeftPar(buf->params) &&
+                   inset->par->Last() > 0 && GetPWidth(cell).empty();
+           if (rtl)
+               os << "\\R{";
+           ret += inset->Latex(buf, os, fragile, fp);
+           if (rtl)
+               os << "}";
+
            ret += TeXCellPostamble(os, cell);
            if (!IsLastCellInRow(cell)) { // not last cell in row
                os << "&\n";
@@ -2378,27 +2361,16 @@ int LyXTabular::AsciiTopHLine(ostream & os, int row,
 {
     int const fcell = GetFirstCellInRow(row);
     int const n = NumberOfCellsInRow(fcell) + fcell;
-
-#if 0
     int tmp = 0;
 
     for (int i = fcell; i < n; ++i) {
-       if (TopLine(i))
+       if (TopLine(i)) {
            ++tmp;
+           break;
+       }
     }
     if (!tmp)
        return 0;
-#else
-    // Isn't this equivalent? (Lgb)
-#ifdef WITH_WARNINGS
-#warning Please check this Jürgen.
-#endif
-    // If ok please delete the abofe #if 0 section. (Lgb)
-    for (int i = fcell; i < n; ++i) {
-           if (TopLine(i))
-                   return 0;
-    }
-#endif
 
     unsigned char ch;
     for (int i = fcell; i < n; ++i) {
@@ -2436,27 +2408,17 @@ int LyXTabular::AsciiBottomHLine(ostream & os, int row,
 {
     int const fcell = GetFirstCellInRow(row);
     int const n = NumberOfCellsInRow(fcell) + fcell;
-
-#if 0
     int tmp = 0;
 
     for (int i = fcell; i < n; ++i) {
-       if (BottomLine(i))
+       if (BottomLine(i)) {
            ++tmp;
+           break;
+       }
     }
     if (!tmp)
        return 0;
-#else
-    // Isn't this equivalent? (Lgb)
-#ifdef WITH_WARNINGS
-#warning Please check this Jürgen.
-#endif
-    // If ok, please delete the above #if 0 section. (Lgb)
-    for (int i = fcell; i < n; ++i) {
-       if (BottomLine(i))
-           return 0;
-    }
-#endif
+
     unsigned char ch;
     for (int i = fcell; i < n; ++i) {
        if (BottomLine(i)) {
@@ -2595,6 +2557,12 @@ InsetText * LyXTabular::GetCellInset(int cell) const
 }
 
 
+InsetText * LyXTabular::GetCellInset(int row, int column) const
+{
+    return GetCellInset(GetCellNumber(row, column));
+}
+
+
 void LyXTabular::Validate(LaTeXFeatures & features) const
 {
     if (IsLongTabular())