X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTextClass.cpp;h=9cf75a7669debf447b09e46b512a6c7b877954f6;hb=04e6076ebb889a3215eaa4ff5cb200822611185c;hp=a158116d3eadb8dbd5ef63848a86da701ddf43d3;hpb=287612cfba4c749decf848f585300c826e2217e6;p=lyx.git diff --git a/src/TextClass.cpp b/src/TextClass.cpp index a158116d3e..9cf75a7669 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -49,6 +49,19 @@ using namespace lyx::support; namespace lyx { +// Keep the changes documented in the Customization manual. +// +// If you change this format, then you MUST also make sure that +// your changes do not invalidate the hardcoded layout file in +// LayoutFile.cpp. Additions will never do so, but syntax changes +// could. See LayoutFileList::addEmptyClass() and, especially, the +// definition of the layoutpost string. +// You should also run (or ask someone who has bash to run) the +// development/updatelayouts.sh script, to update the format of +// all of our layout files. +// +int const LAYOUT_FORMAT = 30; + namespace { class LayoutNamesEqual : public unary_function { @@ -64,9 +77,6 @@ private: docstring name_; }; -// Keep the changes documented in the Customization manual. -int const FORMAT = 26; - bool layout2layout(FileName const & filename, FileName const & tempfile) { @@ -94,7 +104,7 @@ bool layout2layout(FileName const & filename, FileName const & tempfile) } -string translateRT(TextClass::ReadType rt) +string translateReadType(TextClass::ReadType rt) { switch (rt) { case TextClass::BASECLASS: @@ -246,7 +256,7 @@ namespace { bool TextClass::convertLayoutFormat(support::FileName const & filename, ReadType rt) { - LYXERR(Debug::TCLASS, "Converting layout file to " << FORMAT); + LYXERR(Debug::TCLASS, "Converting layout file to " << LAYOUT_FORMAT); FileName const tempfile = FileName::tempName("convert_layout"); bool success = layout2layout(filename, tempfile); if (success) @@ -264,8 +274,8 @@ TextClass::ReturnValues TextClass::readWithoutConv(FileName const & filename, Re return ERROR; } - LYXERR(Debug::TCLASS, "Reading " + translateRT(rt) + ": " + - to_utf8(makeDisplayPath(filename.absFilename()))); + LYXERR(Debug::TCLASS, "Reading " + translateReadType(rt) + ": " + + to_utf8(makeDisplayPath(filename.absFileName()))); // Define the plain layout used in table cells, ert, etc. Note that // we do this before loading any layout file, so that classes can @@ -277,8 +287,8 @@ TextClass::ReturnValues TextClass::readWithoutConv(FileName const & filename, Re lexrc.setFile(filename); ReturnValues retval = read(lexrc, rt); - LYXERR(Debug::TCLASS, "Finished reading " + translateRT(rt) + ": " + - to_utf8(makeDisplayPath(filename.absFilename()))); + LYXERR(Debug::TCLASS, "Finished reading " + translateReadType(rt) + ": " + + to_utf8(makeDisplayPath(filename.absFileName()))); return retval; } @@ -293,7 +303,7 @@ bool TextClass::read(FileName const & filename, ReadType rt) bool const worx = convertLayoutFormat(filename, rt); if (!worx) { LYXERR0 ("Unable to convert " << filename << - " to format " << FORMAT); + " to format " << LAYOUT_FORMAT); return false; } return true; @@ -331,7 +341,7 @@ bool TextClass::read(std::string const & str, ReadType rt) bool const worx = convertLayoutFormat(tempfile, rt); if (!worx) { LYXERR0("Unable to convert internal layout information to format " - << FORMAT); + << LAYOUT_FORMAT); } tempfile.removeFile(); return worx; @@ -406,7 +416,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt) lexrc.printError("Could not find input file: " + inc); error = true; } else if (!read(tmp, MERGE)) { - lexrc.printError("Error reading input file: " + tmp.absFilename()); + lexrc.printError("Error reading input file: " + tmp.absFileName()); error = true; } } @@ -635,7 +645,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt) } case TC_FLOAT: - error = readFloat(lexrc); + error = !readFloat(lexrc); break; case TC_CITEFORMAT: @@ -685,7 +695,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt) // Note that this is triggered the first time through the loop unless // we hit a format tag. - if (format != FORMAT) + if (format != LAYOUT_FORMAT) return FORMAT_MISMATCH; } @@ -1036,7 +1046,6 @@ bool TextClass::readFloat(Lexer & lexrc) counters_.newCounter(subtype, from_ascii(type), "\\alph{" + subtype + "}", docstring()); } - return getout; } @@ -1148,7 +1157,7 @@ bool TextClass::load(string const & path) const if (!loaded_) { lyxerr << "Error reading `" - << to_utf8(makeDisplayPath(layout_file.absFilename())) + << to_utf8(makeDisplayPath(layout_file.absFileName())) << "'\n(Check `" << name_ << "')\nCheck your installation and " "try Options/Reconfigure..."