From e59b0d2c28fa157eeabce2a9719146412b98893a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 21 Jul 2009 17:02:26 +0000 Subject: [PATCH] * lyx_2_0.py: - use predefined methods for getting length values. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30736 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_2_0.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index e88136c6f8..a9b09ec75f 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -1019,9 +1019,9 @@ def revert_percent_hspace_lengths(document): i = 0 j = 0 while True: - i = find_token(document.body, "\\begin_inset space \hspace{}", i) + i = find_token(document.body, "\\begin_inset space \\hspace{}", i) if i == -1: - j = find_token(document.body, "\\begin_inset space \hspace*{}", j) + j = find_token(document.body, "\\begin_inset space \\hspace*{}", j) if j == -1: break else: @@ -1031,13 +1031,10 @@ def revert_percent_hspace_lengths(document): star = False # only revert when a custom length was set and when # it used a percent length - o = document.body[i+1].find("\\length") - if o == -1: - document.warning("Error: Cannot find lenght for \\hspace!") - break - # search for the beginning of the value via the space - k = document.body[i+1].find(" ") - length = document.body[i+1][k+1:] + length = get_value(document.body, '\\length', i+1) + if length == '': + document.warning("Malformed lyx document: Missing '\\length' in Space inset.") + return # handle percent lengths length = latex_length(length) # latex_length returns "bool,length" @@ -1060,9 +1057,9 @@ def revert_hspace_glue_lengths(document): i = 0 j = 0 while True: - i = find_token(document.body, "\\begin_inset space \hspace{}", i) + i = find_token(document.body, "\\begin_inset space \\hspace{}", i) if i == -1: - j = find_token(document.body, "\\begin_inset space \hspace*{}", j) + j = find_token(document.body, "\\begin_inset space \\hspace*{}", j) if j == -1: break else: @@ -1070,13 +1067,10 @@ def revert_hspace_glue_lengths(document): i = j else: star = False - o = document.body[i+1].find("\\length") - if o == -1: - document.warning("Error: Cannot find lenght for \\hspace!") - break - # search for the beginning of the value via the space - k = document.body[i+1].find(" ") - length = document.body[i+1][k+1:] + length = get_value(document.body, '\\length', i+1) + if length == '': + document.warning("Malformed lyx document: Missing '\\length' in Space inset.") + return # only revert when the length contains a plus or minus l = length.find("+") if l == -1: