]> git.lyx.org Git - features.git/commitdiff
File format change: Fix bug 1746 partly
authorUwe Stöhr <uwestoehr@web.de>
Thu, 26 Apr 2007 21:40:51 +0000 (21:40 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Thu, 26 Apr 2007 21:40:51 +0000 (21:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18052 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_5.py
src/Buffer.cpp
src/insets/InsetTabular.cpp

index fbba433b8d9813ac8d8623e97c46d509bdaf7c5a..7dca45b607691dfe75a7413bb861b843e57d6dc6 100644 (file)
@@ -1,5 +1,13 @@
 LyX file-format changes
 -----------------------
+
+2007-04-26  Uwe Stöhr  <uwestoehr@web.de>
+
+       * format incremented to 265: fix LyX's table border line handling
+       With the fix (see bug 1746) LyX now takes care if the user has entered
+       a "|" character in the argument field of tables. Therefore the "|"
+       character has to be removed when also a table border is set.
+
 2007-04-24  José Matos  <jamatos@lyx.org>
 
        * format incremented to 264:
@@ -45,7 +53,7 @@ LyX file-format changes
             'xx \textbf{yy} zz'.
        New: Spaces are always output with the font set by the user.
 
-2007-01-31  Uwe Stöhr
+2007-01-31  Uwe Stöhr  <uwestoehr@web.de>
 
        * format incremented to 258: new \lyxline definition
        Old:
index 51f261fdc5ded0f06b4f379ce3f8be41f6b0f1fd..c975aa372491526088ecb91cbee1e6f257559ef9 100644 (file)
@@ -74,7 +74,7 @@ format_relation = [("0_06",    [200], generate_minor_versions("0.6" , 4)),
                    ("1_2",     [220], generate_minor_versions("1.2" , 4)),
                    ("1_3",     [221], generate_minor_versions("1.3" , 7)),
                    ("1_4", range(222,246), generate_minor_versions("1.4" , 4)),
-                   ("1_5", range(246,265), generate_minor_versions("1.5" , 0))]
+                   ("1_5", range(246,266), generate_minor_versions("1.5" , 0))]
 
 
 def formats_list():
index 3b1bc7afc3a8f76150127799bd0cca82e2c3ba0b..9f1b1ff9803e04a9317a00e165b50d3cfef30fe8 100644 (file)
@@ -732,7 +732,7 @@ def convert_lyxline(document):
         k = 0
         while i < len(document.body):
             i = find_token(document.body, "\\size " + fontsizes[n], i)
-            k = find_token(document.body, "\\lyxline",i)
+            k = find_token(document.body, "\\lyxline", i)
             # the corresponding fontsize command is always 2 lines before the \lyxline
             if (i != -1 and k == i+2):
                 document.body[i:i+1] = []
@@ -1257,6 +1257,32 @@ def revert_cv_textclass(document):
         document.textclass = "cv"
 
 
+def convert_tableborder(document):
+    # The problematic is: LyX double the table cell border as it ignores the "|" character in
+    # the cell arguments. A fix takes care of this and therefore the "|" has to be removed
+    i = 0
+    while i < len(document.body):
+        h = document.body[i].find("leftline=\"true\"", 0, len(document.body[i]))
+        k = document.body[i].find("|>{", 0, len(document.body[i]))
+        # the two tokens have to be in one line
+        if (h != -1 and k != -1):
+            # delete the "|"
+            document.body[i] = document.body[i][:k] + document.body[i][k+1:len(document.body[i])-1]
+        i = i + 1
+
+
+def revert_tableborder(document):
+    i = 0
+    while i < len(document.body):
+        h = document.body[i].find("leftline=\"true\"", 0, len(document.body[i]))
+        k = document.body[i].find(">{", 0, len(document.body[i]))
+        # the two tokens have to be in one line
+        if (h != -1 and k != -1):
+            # add the "|"
+            document.body[i] = document.body[i][:k] + '|' + document.body[i][k:]
+        i = i + 1
+
+
 ##
 # Conversion hub
 #
@@ -1280,9 +1306,11 @@ convert = [[246, []],
            [261, [convert_changes]],
            [262, []],
            [263, [normalize_language_name]],
-           [264, [convert_cv_textclass]]]
+           [264, [convert_cv_textclass]],
+           [265, [convert_tableborder]]]
 
-revert =  [[263, [revert_cv_textclass]],
+revert =  [[264, [revert_tableborder]],
+           [263, [revert_cv_textclass]],
            [262, [revert_language_name]],
            [261, [revert_ascii]],
            [260, []],
@@ -1306,4 +1334,3 @@ revert =  [[263, [revert_cv_textclass]],
 if __name__ == "__main__":
     pass
 
-
index 728d288ce96c7bf9979f4ac9b877919170698b38..2216084ed123c8c45a7573979dcc28eaa785a917 100644 (file)
@@ -141,7 +141,7 @@ using std::string;
 
 namespace {
 
-int const LYX_FORMAT = 264;
+int const LYX_FORMAT = 265;
 
 } // namespace anon
 
index 6596396c35a266af095921714a323b1cd8a9b959..85900d7e08ced3775e5856cfa976a3c257070583 100644 (file)
@@ -835,14 +835,8 @@ bool Tabular::leftLine(idx_type cell, bool wholecolumn) const
                return false;
        if (!wholecolumn && isMultiColumn(cell) &&
                (isFirstCellInRow(cell) || isMultiColumn(cell-1)))
-       {
-               if (cellinfo_of_cell(cell).align_special.empty())
-                       return cellinfo_of_cell(cell).left_line;
-               return prefixIs(ltrim(cellinfo_of_cell(cell).align_special), '|');
-       }
-       if (column_info[column_of_cell(cell)].align_special.empty())
-               return column_info[column_of_cell(cell)].left_line;
-       return prefixIs(ltrim(column_info[column_of_cell(cell)].align_special), '|');
+               return cellinfo_of_cell(cell).left_line;
+       return column_info[column_of_cell(cell)].left_line;
 }
 
 
@@ -852,14 +846,8 @@ bool Tabular::rightLine(idx_type cell, bool wholecolumn) const
                return false;
        if (!wholecolumn && isMultiColumn(cell) &&
                (isLastCellInRow(cell) || isMultiColumn(cell + 1)))
-       {
-               if (cellinfo_of_cell(cell).align_special.empty())
-                       return cellinfo_of_cell(cell).right_line;
-               return suffixIs(rtrim(cellinfo_of_cell(cell).align_special), '|');
-       }
-       if (column_info[column_of_cell(cell)].align_special.empty())
-               return column_info[right_column_of_cell(cell)].right_line;
-       return suffixIs(rtrim(column_info[column_of_cell(cell)].align_special), '|');
+               return cellinfo_of_cell(cell).right_line;
+       return column_info[right_column_of_cell(cell)].right_line;
 }
 
 
@@ -2055,16 +2043,14 @@ int Tabular::TeXCellPreamble(odocstream & os, idx_type cell) const
        }
        if (isMultiColumn(cell)) {
                os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
+               if (leftLine(cell) &&
+                       (isFirstCellInRow(cell) ||
+                        (!isMultiColumn(cell - 1) && !leftLine(cell, true) &&
+                         !rightLine(cell - 1, true))))
+                       os << '|';
                if (!cellinfo_of_cell(cell).align_special.empty()) {
-                       os << cellinfo_of_cell(cell).align_special << "}{";
+                       os << cellinfo_of_cell(cell).align_special;
                } else {
-                       if (leftLine(cell) &&
-                               (isFirstCellInRow(cell) ||
-                                (!isMultiColumn(cell - 1) && !leftLine(cell, true) &&
-                                 !rightLine(cell - 1, true))))
-                       {
-                               os << '|';
-                       }
                        if (!getPWidth(cell).zero()) {
                                switch (getVAlignment(cell)) {
                                case LYX_VALIGN_TOP:
@@ -2092,15 +2078,15 @@ int Tabular::TeXCellPreamble(odocstream & os, idx_type cell) const
                                        os << 'c';
                                        break;
                                }
-                       }
-                       if (rightLine(cell))
-                               os << '|';
-                       if (((cell + 1) < numberofcells) && !isFirstCellInRow(cell+1) &&
-                               leftLine(cell+1))
-                               os << '|';
-                       os << "}{";
+                       } // end if else !getPWidth
+               } // end if else !cellinfo_of_cell
+               if (rightLine(cell))
+                       os << '|';
+               if (((cell + 1) < numberofcells) && !isFirstCellInRow(cell+1) &&
+                       leftLine(cell+1))
+                       os << '|';
+               os << "}{";
                }
-       }
        if (getUsebox(cell) == BOX_PARBOX) {
                os << "\\parbox[";
                switch (getVAlignment(cell)) {
@@ -2361,11 +2347,11 @@ int Tabular::latex(Buffer const & buf, odocstream & os,
        else
                os << "\\begin{tabular}{";
        for (col_type i = 0; i < columns_; ++i) {
+               if (!use_booktabs && column_info[i].left_line)
+                       os << '|';
                if (!column_info[i].align_special.empty()) {
                        os << column_info[i].align_special;
                } else {
-                       if (!use_booktabs && column_info[i].left_line)
-                               os << '|';
                        if (!column_info[i].p_width.zero()) {
                                switch (column_info[i].alignment) {
                                case LYX_ALIGN_LEFT:
@@ -2410,10 +2396,10 @@ int Tabular::latex(Buffer const & buf, odocstream & os,
                                        os << 'c';
                                        break;
                                }
-                       }
-                       if (!use_booktabs && column_info[i].right_line)
-                               os << '|';
-               }
+                       } // end if else !column_info[i].p_width
+               } // end if else !column_info[i].align_special
+               if (!use_booktabs && column_info[i].right_line)
+                       os << '|';
        }
        os << "}\n";
        ++ret;