]> git.lyx.org Git - lyx.git/blob - lib/lyx2lyx/lyx_1_0.py
Length.cpp: add new unit representing \baselineskip
[lyx.git] / lib / lyx2lyx / lyx_1_0.py
1 # This file is part of lyx2lyx
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2004 José Matos <jamatos@lyx.org>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
19 """ Convert files to the file format generated by lyx 1.0"""
20
21 import re
22 from parser_tools import find_token, find_re
23
24 def obsolete_latex_title(document):
25     " Replace LatexTitle layout with Title. "
26
27     body = document.body
28     i = 0
29     while True:
30         i = find_token(body, '\\layout', i)
31         if i == -1:
32             return
33
34         if body[i].lower().find('latex title') != -1:
35             body[i] = '\\layout Title'
36
37         i = i + 1
38
39
40 def update_tabular(document):
41     " Update from tabular format 3 to 4 if necessary."
42
43     lines = document.body
44     lyxtable_re = re.compile(r".*\\LyXTable$")
45     i = 0
46     while True:
47         i = find_re(lines, lyxtable_re, i)
48         if i == -1:
49             break
50         i = i + 1
51         format = lines[i][8:]
52
53         if format != '3':
54             continue
55
56         lines[i] = 'multicol4'
57         i = i + 1
58         rows = int(lines[i].split()[0])
59         columns = int(lines[i].split()[1])
60
61         lines[i] = lines[i] + ' 0 0 -1 -1 -1 -1'
62         i = i + 1
63
64         for j in range(rows):
65             lines[i] = lines[i] + ' 0 0'
66             i = i + 1
67
68         for j in range(columns):
69             lines[i] = lines[i] + ' '
70             i = i + 1
71
72         while lines[i].strip():
73             lines[i] = lines[i] + ' 0 0 0'
74             i = i + 1
75
76         lines[i] = lines[i].strip()
77
78
79 supported_versions = ["1.0.%d" % i for i in range(5)] + ["1.0"]
80 convert = [[215, [obsolete_latex_title, update_tabular]]]
81 revert  = []
82
83
84 if __name__ == "__main__":
85     pass
86