1 # This file is part of lyx2lyx
2 # Copyright (C) 2002 Dekel Tsur <dekel@lyx.org>
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 from parser_tools import *
22 def change_insetgraphics(lines):
25 i = find_token(lines, "\\begin_inset Graphics", i)
28 j = find_end_of_inset(lines, i)
30 lines[i] = "\\begin_inset Graphics"
32 if get_value(lines, "display", i, j) == "default":
33 j = del_token(lines, "display", i, j)
34 if get_value(lines, "rotateOrigin", i, j) == "leftBaseline":
35 j = del_token(lines, "rotateOrigin", i, j)
37 k = find_token2(lines, "rotate", i, j)
42 j = del_token(lines, "rotateAngle", i, j)
44 k = find_token2(lines, "size_type", i, j)
46 k = find_token2(lines, "size_kind", i, j)
47 size_type = string.split(lines[k])[1]
50 if size_type in ["0", "original"]:
51 j = del_token(lines, "width", i, j)
52 j = del_token(lines, "height", i, j)
53 j = del_token(lines, "scale", i, j)
54 elif size_type in ["2", "scale"]:
55 j = del_token(lines, "width", i, j)
56 j = del_token(lines, "height", i, j)
57 if get_value(lines, "scale", i, j) == "100":
58 j = del_token(lines, "scale", i, j)
60 j = del_token(lines, "scale", i, j)
62 k = find_token2(lines, "lyxsize_type", i, j)
64 k = find_token2(lines, "lyxsize_kind", i, j)
65 lyxsize_type = string.split(lines[k])[1]
68 j = del_token(lines, "lyxwidth", i, j)
69 j = del_token(lines, "lyxheight", i, j)
70 if lyxsize_type not in ["2", "scale"] or \
71 get_value(lines, "lyxscale", i, j) == "100":
72 j = del_token(lines, "lyxscale", i, j)
77 def convert(header, body):
78 change_insetgraphics(body)
80 if __name__ == "__main__":