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 if get_value(lines, "display", i, j) == "default":
31 j = del_token(lines, "display", i, j)
32 if get_value(lines, "rotateOrigin", i, j) == "leftBaseline":
33 j = del_token(lines, "rotateOrigin", i, j)
35 k = find_token2(lines, "rotate", i, j)
40 j = del_token(lines, "rotateAngle", i, j)
42 k = find_token2(lines, "size_type", i, j)
44 k = find_token2(lines, "size_kind", i, j)
45 size_type = string.split(lines[k])[1]
48 if size_type in ["0", "original"]:
49 j = del_token(lines, "width", i, j)
50 j = del_token(lines, "height", i, j)
51 j = del_token(lines, "scale", i, j)
52 elif size_type in ["2", "scale"]:
53 j = del_token(lines, "width", i, j)
54 j = del_token(lines, "height", i, j)
55 if get_value(lines, "scale", i, j) == "100":
56 j = del_token(lines, "scale", i, j)
58 j = del_token(lines, "scale", i, j)
60 k = find_token2(lines, "lyxsize_type", i, j)
62 k = find_token2(lines, "lyxsize_kind", i, j)
63 lyxsize_type = string.split(lines[k])[1]
66 j = del_token(lines, "lyxwidth", i, j)
67 j = del_token(lines, "lyxheight", i, j)
68 if lyxsize_type not in ["2", "scale"] or \
69 get_value(lines, "lyxscale", i, j) == "100":
70 j = del_token(lines, "lyxscale", i, j)
75 def convert(header, body):
76 change_insetgraphics(body)
78 if __name__ == "__main__":