From ca81b43f0334d5210696543c2c84e9d29c8a0687 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Matox?= Date: Sun, 12 Aug 2007 13:25:36 +0000 Subject: [PATCH] Fix bug 518 (thanks to Jean Marc and Martin for the help) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19455 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/LyX.py | 8 ++-- lib/lyx2lyx/Makefile.am | 1 + lib/lyx2lyx/lyx_1_6.py | 85 +++++++++++++++++++++++++++++++++++++ src/Buffer.cpp | 2 +- src/insets/InsetTabular.cpp | 25 +++++------ 5 files changed, 102 insertions(+), 19 deletions(-) create mode 100644 lib/lyx2lyx/lyx_1_6.py diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index 615598c673..f237468866 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -30,7 +30,7 @@ try: import lyx2lyx_version version_lyx2lyx = lyx2lyx_version.version except: # we are running from build directory so assume the last version - version_lyx2lyx = '1.5.0svn' + version_lyx2lyx = '1.6.0svn' default_debug_level = 2 @@ -77,7 +77,8 @@ 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" , 5)), - ("1_5", range(246,277), generate_minor_versions("1.5" , 0))] + ("1_5", range(246,277), generate_minor_versions("1.5" , 1)), + ("1_6", range(277,278), generate_minor_versions("1.6" , 0))] def formats_list(): @@ -470,7 +471,7 @@ class LyX_Base: first_step = 1 for step in format_relation: if initial_step <= step[0] <= final_step: - if first_step and len(step[1]) == 1: + if first_step: first_step = 0 continue steps.append(step[0]) @@ -488,6 +489,7 @@ class LyX_Base: if last_step[1][-1] == self.end_format: steps.pop() + self.warning("Convertion mode: %s\tsteps%s" %(mode, steps), 10) return mode, steps diff --git a/lib/lyx2lyx/Makefile.am b/lib/lyx2lyx/Makefile.am index d047bc0d5e..b499a5d541 100644 --- a/lib/lyx2lyx/Makefile.am +++ b/lib/lyx2lyx/Makefile.am @@ -27,6 +27,7 @@ dist_lyx2lyx_PYTHON = \ lyx_1_3.py \ lyx_1_4.py \ lyx_1_5.py \ + lyx_1_6.py \ profiling.py \ test_parser_tools.py diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py new file mode 100644 index 0000000000..448ea4f6b1 --- /dev/null +++ b/lib/lyx2lyx/lyx_1_6.py @@ -0,0 +1,85 @@ +# This file is part of lyx2lyx +# -*- coding: utf-8 -*- +# Copyright (C) 2007 José Matos +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +""" Convert files to the file format generated by lyx 1.6""" + +import re +import unicodedata +import sys, os + +from parser_tools import find_token, find_end_of + +#################################################################### +# Private helper functions + +def find_end_of_inset(lines, i): + " Find end of inset, where lines[i] is included." + return find_end_of(lines, i, "\\begin_inset", "\\end_inset") + +#################################################################### + +def fix_wrong_tables(document): + i = 0 + while True: + i = find_token(document.body, "\\begin_inset Tabular", i) + if i == -1: + return + j = find_end_of_inset(document.body, i + 1) + if j == -1: + document.warning("Malformed LyX document: Could not find end of tabular.") + continue + + m = i + 1 + nrows = int(document.body[i+1].split('"')[3]) + ncols = int(document.body[i+1].split('"')[5]) + + for l in range(nrows): + prev_multicolumn = 0 + for k in range(ncols): + m = find_token(document.body, '