Fix bug 4639 - loading of lyx files without a textclass defined.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@23825 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
José Matox 2008-03-19 12:14:29 +00:00
parent 0639100f3b
commit 3dde4900ea
3 changed files with 12 additions and 7 deletions

View File

@ -236,6 +236,12 @@ class LyX_Base:
self.header.append(line)
i = find_token(self.header, '\\textclass', 0)
if i == -1:
self.warning("Malformed LyX file: Missing '\\textclass'.")
i = find_token(self.header, '\\lyxformat', 0) + 1
self.header[i:i] = ['\\textclass article']
self.textclass = get_value(self.header, "\\textclass", 0)
self.backend = get_backend(self.textclass)
self.format = self.read_format()
@ -269,10 +275,7 @@ class LyX_Base:
if self.preamble:
i = find_token(self.header, '\\textclass', 0) + 1
preamble = ['\\begin_preamble'] + self.preamble + ['\\end_preamble']
if i == 0:
self.error("Malformed LyX file: Missing '\\textclass'.")
else:
header = self.header[:i] + preamble + self.header[i:]
header = self.header[:i] + preamble + self.header[i:]
else:
header = self.header

View File

@ -149,7 +149,7 @@ def get_value(lines, token, start, end = 0, default = ""):
i = find_token_exact(lines, token, start, end)
if i == -1:
return ""
return default
if len(lines[i].split()) > 1:
return lines[i].split()[1]
else:

View File

@ -86,6 +86,8 @@ What's new
macro, such that bold super and subscripts have the correct size even
when not using amsmath.
- Fix loading of lyx documents generated with csv2lyx (bug 4639).
* USER INTERFACE: