]> git.lyx.org Git - lyx.git/blob - lib/lyx2lyx/lyx_1_0_0.py
Get lots of nice icons from the desktop theme
[lyx.git] / lib / lyx2lyx / lyx_1_0_0.py
1 # This file is part of lyx2lyx
2 # -*- coding: iso-8859-1 -*-
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 import re
20 import string
21 from parser_tools import find_token, find_re
22
23 def obsolete_latex_title(file):
24     body = file.body
25     i = 0
26     while 1:
27         i = find_token(body, '\\layout', i)
28         if i == -1:
29             return
30
31         if string.find(string.lower(body[i]),'latex title') != -1:
32             body[i] = '\\layout Title'
33
34         i = i + 1
35
36
37 # Update from tabular format 3 to 4 if necessary
38 def update_tabular(file):
39     lines = file.body
40     lyxtable_re = re.compile(r".*\\LyXTable$")
41     i=0
42     while 1:
43         i = find_re(lines, lyxtable_re, i)
44         if i == -1:
45             break
46         i = i + 1
47         format = lines[i][8:]
48
49         if format != '3':
50             continue
51
52         lines[i]='multicol4'
53         i = i + 1
54         rows = int(string.split(lines[i])[0])
55         columns = int(string.split(lines[i])[1])
56
57         lines[i] = lines[i] + ' 0 0 -1 -1 -1 -1'
58         i = i + 1
59
60         for j in range(rows):
61             lines[i] = lines[i] + ' 0 0'
62             i = i + 1
63
64         for j in range(columns):
65             lines[i] = lines[i] + ' '
66             i = i + 1
67
68         while string.strip(lines[i]):
69             lines[i] = lines[i] + ' 0 0 0'
70             i = i + 1
71
72         lines[i] = string.strip(lines[i])
73
74
75 convert = [[215, [obsolete_latex_title, update_tabular]]]
76 revert  = []
77
78
79 if __name__ == "__main__":
80     pass
81