fix lyx2lyx bugs for revertion to 221.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10172 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
José Matox 2005-07-12 21:27:12 +00:00
parent 5ae47a84eb
commit 2796b1fe32
2 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2005-07-12 José Matos <jamatos@lyx.org>
* lyx_1_4.py (add_to_preamble): Make it more robust.
(convert_frameless_box): Fix wrong type for parameter.
(revert_paperpackage): Consider empty paper package case.
2005-07-08 José Matos <jamatos@lyx.org> 2005-07-08 José Matos <jamatos@lyx.org>
* lyx_0_12.py (update_tabular): Support old tables format 1. * lyx_0_12.py (update_tabular): Support old tables format 1.

View File

@ -1047,12 +1047,16 @@ def insert_ert(body, i, status, text):
def add_to_preamble(file, text): def add_to_preamble(file, text):
i = find_token(file.header, '\\begin_preamble', 0) i = find_token(file.header, '\\begin_preamble', 0)
if i == -1: if i == -1:
file.warning("Malformed LyX file: Missing '\\begin_preamble'.") file.header.extend(['\\begin_preamble'] + text + ['\\end_preamble'])
return return
j = find_token(file.header, '\\end_preamble', i) j = find_token(file.header, '\\end_preamble', i)
if j == -1: if j == -1:
file.warning("Malformed LyX file: Missing '\\end_preamble'.") file.warning("Malformed LyX file: Missing '\\end_preamble'.")
return file.warning("Adding it now and hoping for the best.")
file.header.append('\\end_preamble')
j = len(file.header)
if find_token(file.header, text[0], i, j) != -1: if find_token(file.header, text[0], i, j) != -1:
return return
file.header[j:j] = text file.header[j:j] = text
@ -1075,8 +1079,8 @@ def convert_frameless_box(file):
j = j - 1 j = j - 1
# Gather parameters # Gather parameters
params = {'position':'0', 'hor_pos':'c', 'has_inner_box':'1', params = {'position':0, 'hor_pos':'c', 'has_inner_box':'1',
'inner_pos':'1', 'use_parbox':'0', 'width':'100col%', 'inner_pos':1, 'use_parbox':'0', 'width':'100col%',
'special':'none', 'height':'1in', 'special':'none', 'height':'1in',
'height_special':'totalheight', 'collapsed':'false'} 'height_special':'totalheight', 'collapsed':'false'}
for key in params.keys(): for key in params.keys():
@ -1536,8 +1540,11 @@ def revert_paperpackage(file):
return return
packages = {'none':'a4', 'a4':'a4wide', 'a4wide':'widemarginsa4', packages = {'none':'a4', 'a4':'a4wide', 'a4wide':'widemarginsa4',
'widemarginsa4':''} 'widemarginsa4':'', 'default': 'default'}
paperpackage = split(file.header[i])[1] if len(split(file.header[i])) > 1:
paperpackage = split(file.header[i])[1]
else:
paperpackage = 'default'
file.header[i] = replace(file.header[i], paperpackage, packages[paperpackage]) file.header[i] = replace(file.header[i], paperpackage, packages[paperpackage])