Return here unless the doc class is correct.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34783 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-07-06 13:50:23 +00:00
parent 9defda7c32
commit 2909e6450b

View File

@ -350,25 +350,24 @@ def revert_layout_command(document, name, LaTeXname, position):
i = find_token(document.body, '\\begin_layout ' + name, i) i = find_token(document.body, '\\begin_layout ' + name, i)
if i == -1: if i == -1:
return return
else: k = -1
k = -1 # find the next layout
# find the next layout j = i + 1
j = i + 1 while k == -1:
while k == -1: j = find_token(document.body, '\\begin_layout', j)
j = find_token(document.body, '\\begin_layout', j) l = len(document.body)
l = len(document.body) # if nothing was found it was the last layout of the document
# if nothing was found it was the last layout of the document if j == -1:
if j == -1: document.body[l - 4:l - 4] = put_cmd_in_ert("}")
document.body[l - 4:l - 4] = put_cmd_in_ert("}") k = 0
k = 0 # exclude plain layout because this can be TeX code or another inset
# exclude plain layout because this can be TeX code or another inset elif document.body[j] != '\\begin_layout Plain Layout':
elif document.body[j] != '\\begin_layout Plain Layout': document.body[j - 2:j - 2] = put_cmd_in_ert("}")
document.body[j - 2:j - 2] = put_cmd_in_ert("}") k = 0
k = 0 else:
else: j += 1
j += 1 document.body[i] = '\\begin_layout Standard'
document.body[i] = '\\begin_layout Standard' document.body[i + 1:i + 1] = put_cmd_in_ert(LaTeXname + "{")
document.body[i + 1:i + 1] = put_cmd_in_ert(LaTeXname + "{")
i += 1 i += 1
@ -1848,6 +1847,9 @@ def revert_makebox(document):
def revert_IEEEtran(document): def revert_IEEEtran(document):
" Convert IEEEtran layouts and styles to TeX code " " Convert IEEEtran layouts and styles to TeX code "
if document.textclass != "IEEEtran":
return
revert_flex_inset(document, "IEEE membership", "\\IEEEmembership", 0) revert_flex_inset(document, "IEEE membership", "\\IEEEmembership", 0)
revert_flex_inset(document, "Lowercase", "\\MakeLowercase", 0) revert_flex_inset(document, "Lowercase", "\\MakeLowercase", 0)
revert_layout_command(document, "Special Paper Notice", "\\IEEEspecialpapernotice", 0) revert_layout_command(document, "Special Paper Notice", "\\IEEEspecialpapernotice", 0)
@ -1870,34 +1872,33 @@ def revert_IEEEtran(document):
+ '\\end_layout\n\n' \ + '\\end_layout\n\n' \
+ '\\end_inset\n\n\n' \ + '\\end_inset\n\n\n' \
+ '\\end_layout\n\n' + '\\end_layout\n\n'
if document.textclass == "IEEEtran": # insert a note that title and author must be given in TeX code
# insert a note that title and author must be given in TeX code document.body.insert(0, note)
document.body.insert(0, note) # we need to revert title and author to TeX code to set \maketitle correctly
# we need to revert title and author to TeX code to set \maketitle correctly revert_layout_command(document, "Title", "\\title", 0)
revert_layout_command(document, "Title", "\\title", 0) revert_layout_command(document, "Author", "\\author", 0)
revert_layout_command(document, "Author", "\\author", 0) # write \markboth code to the preamble
# write \markboth code to the preamble insert_to_preamble(0, document,
insert_to_preamble(0, document, '% Commands inserted by lyx2lyx\n'
'% Commands inserted by lyx2lyx\n' + '% protect \\markboth against an old bug reintroduced in babel >= 3.8g\n'
+ '% protect \\markboth against an old bug reintroduced in babel >= 3.8g\n' + '\\let\\oldforeign@language\\foreign@language\n'
+ '\\let\\oldforeign@language\\foreign@language\n' + '\\DeclareRobustCommand{\\foreign@language}[1]{%\n'
+ '\\DeclareRobustCommand{\\foreign@language}[1]{%\n' + ' \\lowercase{\\oldforeign@language{#1}}}\n')
+ ' \\lowercase{\\oldforeign@language{#1}}}\n') # set maketitle
# set maketitle y = find_token(document.body, '\\begin_layout Abstract', 0)
y = find_token(document.body, '\\begin_layout Abstract', 0) if y == -1:
if y == -1: document.warning("Malformed LyX document: Can't find abstract of IEEEtran paper.")
document.warning("Malformed LyX document: Can't find abstract of IEEEtran paper.") return
else: maketitle = ['\\begin_layout Standard\n', \
maketitle = ['\\begin_layout Standard\n', \ '\\begin_inset ERT\n', \
'\\begin_inset ERT\n', \ 'status collapsed\n', \
'status collapsed\n', \ '\\begin_layout Plain Layout\n', \
'\\begin_layout Plain Layout\n', \ '\\backslash\n', \
'\\backslash\n', \ 'maketitle \n', \
'maketitle \n', \ '\\end_layout\n', \
'\\end_layout\n', \ '\\end_inset\n', \
'\\end_inset\n', \ '\\end_layout\n']
'\\end_layout\n'] document.body[y:y] = maketitle
document.body[y:y] = maketitle
## ##