Fix bug #9162: Missing \use_indices

The lyx2lyx conversion for format 352 was incomplete: It should have been
added the \use_indices setting, but it relied on the fact that the default in
LyX for missing \use_indices is the same as the old format without that
setting used. However, the default might change in the future, and later
lyx2lyx conversions rely on that setting as well.
This commit is contained in:
Georg Baum 2014-07-04 19:55:44 +02:00
parent 906a7d9142
commit 22dcdd6d8f
3 changed files with 37 additions and 8 deletions

View File

@ -720,6 +720,7 @@ class File(LyX_base):
self.read()
# FIXME: header settings are completely outdated, don't use like this
#class NewFile(LyX_base):
# " This class is to create new LyX files."
# def set_header(self, **params):
@ -748,6 +749,7 @@ class File(LyX_base):
# "\\use_amsmath 1",
# "\\cite_engine basic",
# "\\use_bibtopic false",
# "\\use_indices false",
# "\\paperorientation portrait",
# "\\secnumdepth 3",
# "\\tocdepth 3",

View File

@ -317,11 +317,33 @@ def revert_backgroundcolor(document):
'\\pagecolor{page_backgroundcolor}'])
def revert_splitindex(document):
" Reverts splitindex-aware documents "
def add_use_indices(document):
" Add \\use_indices if it is missing "
i = find_token(document.header, '\\use_indices', 0)
if i != -1:
return i
i = find_token(document.header, '\\use_bibtopic', 0)
if i == -1:
i = find_token(document.header, '\\cite_engine', 0)
if i == -1:
i = find_token(document.header, '\\use_mathdots', 0)
if i == -1:
i = find_token(document.header, '\\use_mhchem', 0)
if i == -1:
i = find_token(document.header, '\\use_esint', 0)
if i == -1:
i = find_token(document.header, '\\use_amsmath', 0)
if i == -1:
document.warning("Malformed LyX document: Missing \\use_indices.")
return -1
document.header.insert(i + 1, '\\use_indices 0')
return i + 1
def revert_splitindex(document):
" Reverts splitindex-aware documents "
i = add_use_indices(document)
if i == -1:
return
useindices = str2bool(get_value(document.header, "\\use_indices", i))
del document.header[i]
@ -398,6 +420,7 @@ def revert_splitindex(document):
def convert_splitindex(document):
" Converts index and printindex insets to splitindex-aware format "
add_use_indices(document)
i = 0
while True:
i = find_token(document.body, "\\begin_inset Index", i)
@ -422,9 +445,8 @@ def convert_splitindex(document):
def revert_subindex(document):
" Reverts \\printsubindex CommandInset types "
i = find_token(document.header, '\\use_indices', 0)
i = add_use_indices(document)
if i == -1:
document.warning("Malformed LyX document: Missing \\use_indices.")
return
useindices = str2bool(get_value(document.header, "\\use_indices", i))
i = 0
@ -448,9 +470,8 @@ def revert_subindex(document):
def revert_printindexall(document):
" Reverts \\print[sub]index* CommandInset types "
i = find_token(document.header, '\\use_indices', 0)
i = add_use_indices(document)
if i == -1:
document.warning("Malformed LyX document: Missing \\use_indices.")
return
useindices = str2bool(get_value(document.header, "\\use_indices", i))
i = 0

View File

@ -409,9 +409,15 @@ def revert_japanese_encodings(document):
def convert_justification(document):
" Add the \\justification buffer param"
i = find_token(document.header, "\\use_indices" , 0)
i = find_token(document.header, "\\suppress_date" , 0)
if i == -1:
document.warning("Malformed LyX document: Missing \\use_indices.")
i = find_token(document.header, "\\paperorientation" , 0)
if i == -1:
i = find_token(document.header, "\\use_indices" , 0)
if i == -1:
i = find_token(document.header, "\\use_bibtopic" , 0)
if i == -1:
document.warning("Malformed LyX document: Missing \\suppress_date.")
return
document.header.insert(i + 1, "\\justification true")