]> git.lyx.org Git - features.git/commitdiff
* lib/lyx2lyx/lyx_1_5.py:
authorJürgen Spitzmüller <spitz@lyx.org>
Sat, 30 Jun 2007 06:07:20 +0000 (06:07 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Sat, 30 Jun 2007 06:07:20 +0000 (06:07 +0000)
- fix convert_graphics_rotation and make revert_graphics_rotation actually work.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18948 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_1_5.py

index 7463f230aea7238b26d19a58861e8b74c45872d4..1e1efe441a0097502307628e1c4a6255cd08bbf2 100644 (file)
@@ -1372,17 +1372,15 @@ def convert_graphics_rotation(document):
             document.warning("Malformed LyX document: Could not find end of graphics inset.")
         # Seach for rotateAngle and width or height or scale
         # If these params are not there, nothing needs to be done.
-        # FIXME: this also inserts scaleBeforeRotation if "rotateAngle" is not there!
-        for k in range(i+1, j):
-            if (document.body[k].find("rotateAngle") and \
-                (document.body[k].find("width") or \
-                document.body[k].find("height") or \
-                document.body[k].find("scale"))):
-                        document.body.insert(j, 'scaleBeforeRotation')
+        k = find_token(document.body, "\trotateAngle", i + 1, j)
+        l = find_tokens(document.body, ["\twidth", "\theight", "\tscale"], i + 1, j)
+        if (k != -1 and l != -1):
+            document.body.insert(j, 'scaleBeforeRotation')
         i = i + 1
 
 
-# FIXME: does not work at all
+#
+# remove scaleBeforeRotation graphics param
 def revert_graphics_rotation(document):
     " remove scaleBeforeRotation graphics parameter. "
     i = 0
@@ -1394,24 +1392,27 @@ def revert_graphics_rotation(document):
         if j == -1:
             # should not happen
             document.warning("Malformed LyX document: Could not find end of graphics inset.")
-        for k in range(i+1, j):
-            # If there's a scaleBeforeRotation param, just remove that
-            if document.body[k].find('scaleBeforeRotation'):
-                del document.body[k]
-                break
+        # If there's a scaleBeforeRotation param, just remove that
+        k = find_token(document.body, "\tscaleBeforeRotation", i + 1, j)
+        if k != -1:
+            del document.body[k]
+        else:
             # if not, and if we have rotateAngle and width or height or scale,
             # we have to put the rotateAngle value to special
-            rotateAngle = get_value(document.body, 'rotateAngle', i+1, j)
-            special = get_value(document.body, 'special', i+1, j)
-            if (document.body[k].find("width") or \
-                document.body[k].find("height") or \
-                document.body[k].find("scale") and \
-                document.body[k].find("rotateAngle")):
-                    if special == "":
-                        document.body.insert(j-1, '\tspecial angle=%s' % rotateAngle)
-                    else:
-                        l = find_token(document.body, "special", i+1, j)
-                        document.body[l].replace(special, 'angle=%s,%s' % (rotateAngle, special))
+            rotateAngle = get_value(document.body, 'rotateAngle', i + 1, j)
+            special = get_value(document.body, 'special', i + 1, j)
+            if rotateAngle != "":
+                k = find_tokens(document.body, ["\twidth", "\theight", "\tscale"], i + 1, j)
+                if k == -1:
+                    break
+                if special == "":
+                    document.body.insert(j-1, '\tspecial angle=%s' % rotateAngle)
+                else:
+                    l = find_token(document.body, "\tspecial", i + 1, j)
+                    document.body[l] = document.body[l].replace(special, 'angle=%s,%s' % (rotateAngle, special))
+                k = find_token(document.body, "\trotateAngle", i + 1, j)
+                if k != -1:
+                    del document.body[k]
         i = i + 1