From: Georg Baum Date: Wed, 9 Jul 2014 18:58:44 +0000 (+0200) Subject: Fix bug #9162: Missing \use_indices X-Git-Tag: 2.1.2~44 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=275c6dabe66c84b683b93eab77e8e40388c8c218;p=features.git 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. --- diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index 5d8a052494..e3a57b7bd4 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -714,6 +714,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): @@ -742,6 +743,7 @@ class File(LyX_base): # "\\use_amsmath 1", # "\\cite_engine basic", # "\\use_bibtopic false", +# "\\use_indices false", # "\\paperorientation portrait", # "\\secnumdepth 3", # "\\tocdepth 3", diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index 2756418f88..7914cc4995 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -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 diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index ae95841fa5..f9b1e32b63 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -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") diff --git a/status.21x b/status.21x index 11f13d9969..0522009016 100644 --- a/status.21x +++ b/status.21x @@ -55,6 +55,8 @@ What's new * LYX2LYX +- Fix warning "Missing \use_indices" when converting from 1.6.x format or older + * USER INTERFACE