Remove the manifest section of the .lyx file

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21104 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2007-10-21 18:06:00 +00:00
parent eb9b8ef0cc
commit 7063b33b1b
6 changed files with 4 additions and 121 deletions

View File

@ -39,7 +39,6 @@ LyX file-format changes
2007-09-11 Bo Peng <ben.bob@gmail.com>
* Format incremented to 285: Tweaks to embedded file format.
Add manifest to .lyx file.
Remove inzip parameter from graphics insets.
2007-09-09 Helge Hafting <helge.hafting@aitel.hist.no>

View File

@ -178,7 +178,6 @@ class LyX_base:
self.default_layout = ''
self.header = []
self.preamble = []
self.manifest = []
self.body = []
self.status = 0
self.encoding = encoding
@ -203,7 +202,7 @@ class LyX_base:
def read(self):
"""Reads a file into the self.header, self.manifest and
"""Reads a file into the self.header and
self.body parts, from self.input."""
while True:
@ -235,27 +234,6 @@ class LyX_base:
if check_token(line, '\\end_preamble'):
continue
if check_token(line, '\\begin_manifest'):
while 1:
line = self.input.readline()
if not line:
self.error("Invalid LyX file.")
line = trim_eol(line)
if check_token(line, "\\end_manifest"):
break
if not line.startswith('\\filename') and \
not line.startswith('\\inzipName') and \
not line.startswith('\\embed'):
self.warning("Malformed LyX file: Missing"
"'\\end_manifest'.")
self.manifest.append(line)
if check_token(line, '\\end_manifest'):
continue
line = line.strip()
if not line:
continue
@ -311,14 +289,7 @@ class LyX_base:
else:
header = self.header
# LyX file format <= 284 does not have a manifest section
# so this section is set to None
if self.manifest is None:
manifest = []
else:
manifest = ['\\begin_manifest'] + self.manifest + ['\\end_manifest', '']
for line in header + [''] + manifest + self.body:
for line in header + [''] + self.body:
self.output.write(line.encode(self.encoding)+"\n")

View File

@ -174,11 +174,6 @@ def revert_flex(document):
document.body[i] = document.body[i].replace('\\begin_inset Flex', '\\begin_inset CharStyle')
def remove_manifest(document):
"Remove the manifest section"
document.manifest = None
# Discard PDF options for hyperref
def revert_pdf_options(document):
"Revert PDF options for hyperref."
@ -600,7 +595,7 @@ convert = [[277, [fix_wrong_tables]],
[282, []],
[283, [convert_flex]],
[284, []],
[285, []], # an empty manifest is automatically added
[285, []],
[286, []],
[287, [convert_wrapfig_options]],
[288, [convert_inset_command]],
@ -623,7 +618,7 @@ revert = [[294, [revert_href]],
[287, [revert_inset_command]],
[286, [revert_wrapfig_options]],
[285, [revert_pdf_options]],
[284, [remove_manifest, remove_inzip_options]],
[284, [remove_inzip_options]],
[283, []],
[282, [revert_flex]],
[281, []],

View File

@ -570,8 +570,6 @@ bool Buffer::readDocument(Lexer & lex)
"\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
}
}
// read manifest after header
embeddedFiles().readManifest(lex, errorList);
// read main text
bool const res = text().read(*this, lex, errorList);
@ -962,12 +960,6 @@ bool Buffer::write(ostream & ofs) const
params().writeFile(ofs);
ofs << "\\end_header\n";
// write the manifest after header
ofs << "\n\\begin_manifest\n";
pimpl_->embedded_files.update();
embeddedFiles().writeManifest(ofs);
ofs << "\\end_manifest\n";
// write the text
ofs << "\n\\begin_body\n";
text().write(*this, ofs);

View File

@ -410,78 +410,6 @@ string const EmbeddedFiles::getInzipName(string const & abs_filename, string con
}
bool EmbeddedFiles::readManifest(Lexer & lex, ErrorList & errorList)
{
int line = -1;
int begin_manifest_line = -1;
file_list_.clear();
string filename;
string inzipName;
bool embedded = false;
while (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token.empty())
continue;
if (token == "\\end_manifest")
break;
++line;
if (token == "\\begin_manifest") {
begin_manifest_line = line;
continue;
}
LYXERR(Debug::PARSER) << "Handling document manifest token: `"
<< token << '\'' << endl;
if (token == "\\filename")
lex >> filename;
else if (token == "\\inzipName")
lex >> inzipName;
else if (token == "\\embed") {
lex >> embedded;
registerFile(filename, embedded, NULL, inzipName);
filename = "";
inzipName = "";
} else {
docstring const s = _("\\begin_file is missing");
errorList.push_back(ErrorItem(_("Manifest error"),
s, -1, 0, 0));
}
}
if (begin_manifest_line) {
docstring const s = _("\\begin_manifest is missing");
errorList.push_back(ErrorItem(_("Manifest error"),
s, -1, 0, 0));
}
return true;
}
void EmbeddedFiles::writeManifest(ostream & os) const
{
EmbeddedFiles::EmbeddedFileList::const_iterator it = begin();
EmbeddedFiles::EmbeddedFileList::const_iterator it_end = end();
for (; it != it_end; ++it) {
// only saved 'extra' files. Other embedded files are saved
// with insets.
if (!it->valid() || it->refCount() > 0)
continue;
// save the relative path
os << "\\filename "
<< to_utf8(makeRelPath(from_utf8(it->absFilename()),
from_utf8(buffer_->filePath()))) << '\n'
<< "\\inzipName " << it->inzipName() << '\n'
<< "\\embed " << (it->embedded() ? "true" : "false") << '\n';
}
}
void EmbeddedFiles::updateInsets() const
{
EmbeddedFiles::EmbeddedFileList::const_iterator it = begin();

View File

@ -227,8 +227,6 @@ public:
/// update all files from external, used when enable embedding
bool updateFromExternalFile() const;
///
bool readManifest(Lexer & lex, ErrorList & errorList);
void writeManifest(std::ostream & os) const;
/// update all insets to use embedded files when embedding status is changed
void updateInsets() const;
private: