patch from Dekel, change lyxformat to int

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1313 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-01-11 11:06:10 +00:00
parent 4e839f35c6
commit 716cd578ae
4 changed files with 88 additions and 2 deletions

View File

@ -1,3 +1,19 @@
2001-01-11 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/buffer.h: change format to int, and change name to file_format
* src/buffer.C: change LYX_FORMAT to int, and bump version number
to 218.
(readLyXformat2): handle it
handle it
(readFile): handle it
(writeFile): handle it
2001-01-10 Dekel Tsur <dekelts@tau.ac.il>
* src/insets/insettext.C (LocalDispatch): Add handling of
LFUN_BREAKPARAGRAPHKEEPLAYOUT.
2001-01-10 Lars Gullik Bjønnes <larsbj@lyx.org> 2001-01-10 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/tabular.C (Write): write lowercase identifiers * src/tabular.C (Write): write lowercase identifiers

View File

@ -113,7 +113,11 @@ extern BufferList bufferlist;
extern LyXAction lyxaction; extern LyXAction lyxaction;
#if 0
static const float LYX_FORMAT = 2.17; static const float LYX_FORMAT = 2.17;
#else
static const int LYX_FORMAT = 218;
#endif
extern int tex_code_break_column; extern int tex_code_break_column;
@ -248,9 +252,13 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par)
LyXParagraph * return_par = 0; LyXParagraph * return_par = 0;
LyXFont font(LyXFont::ALL_INHERIT, params.language); LyXFont font(LyXFont::ALL_INHERIT, params.language);
#if 0
if (format < 2.16 && params.language->lang() == "hebrew") if (format < 2.16 && params.language->lang() == "hebrew")
font.setLanguage(default_language); font.setLanguage(default_language);
#else
if (file_format < 216 && params.language->lang() == "hebrew")
font.setLanguage(default_language);
#endif
// If we are inserting, we cheat and get a token in advance // If we are inserting, we cheat and get a token in advance
bool has_token = false; bool has_token = false;
string pretoken; string pretoken;
@ -365,8 +373,13 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
#endif #endif
par->depth = depth; par->depth = depth;
font = LyXFont(LyXFont::ALL_INHERIT, params.language); font = LyXFont(LyXFont::ALL_INHERIT, params.language);
#if 0
if (format < 2.16 && params.language->lang() == "hebrew") if (format < 2.16 && params.language->lang() == "hebrew")
font.setLanguage(default_language); font.setLanguage(default_language);
#else
if (file_format < 216 && params.language->lang() == "hebrew")
font.setLanguage(default_language);
#endif
#ifndef NEW_INSETS #ifndef NEW_INSETS
} else if (token == "\\end_float") { } else if (token == "\\end_float") {
if (!return_par) if (!return_par)
@ -381,8 +394,13 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
lex.EatLine(); lex.EatLine();
par->layout = LYX_DUMMY_LAYOUT; par->layout = LYX_DUMMY_LAYOUT;
font = LyXFont(LyXFont::ALL_INHERIT, params.language); font = LyXFont(LyXFont::ALL_INHERIT, params.language);
#if 0
if (format < 2.16 && params.language->lang() == "hebrew") if (format < 2.16 && params.language->lang() == "hebrew")
font.setLanguage(default_language); font.setLanguage(default_language);
#else
if (file_format < 216 && params.language->lang() == "hebrew")
font.setLanguage(default_language);
#endif
} else if (token == "\\begin_float") { } else if (token == "\\begin_float") {
int tmpret = lex.FindToken(string_footnotekinds); int tmpret = lex.FindToken(string_footnotekinds);
if (tmpret == -1) ++tmpret; if (tmpret == -1) ++tmpret;
@ -1053,6 +1071,7 @@ bool Buffer::readFile(LyXLex & lex, LyXParagraph * par)
string const token(lex.GetString()); string const token(lex.GetString());
if (token == "\\lyxformat") { // the first token _must_ be... if (token == "\\lyxformat") { // the first token _must_ be...
lex.EatLine(); lex.EatLine();
#if 0
format = lex.GetFloat(); format = lex.GetFloat();
if (format > 1.0) { if (format > 1.0) {
if (LYX_FORMAT - format > 0.05) { if (LYX_FORMAT - format > 0.05) {
@ -1085,6 +1104,44 @@ bool Buffer::readFile(LyXLex & lex, LyXParagraph * par)
return false; return false;
} }
#else
string tmp_format = lex.GetString();
//lyxerr << "LyX Format: `" << tmp_format << "'" << endl;
// if present remove ".," from string.
string::size_type dot = tmp_format.find_first_of(".,");
//lyxerr << " dot found at " << dot << endl;
if (dot != string::npos)
tmp_format.erase(dot, 1);
file_format = strToInt(tmp_format);
if (file_format == LYX_FORMAT) {
// current format
} else if (file_format > LYX_FORMAT) {
// future format
WriteAlert(_("Warning!"),
_("LyX file format is newer that what"),
_("is supported in this LyX version. Expect some problems."));
} else if (file_format < LYX_FORMAT) {
// old formats
if (file_format < 200) {
WriteAlert(_("ERROR!"),
_("Old LyX file format found. "
"Use LyX 0.10.x to read this!"));
return false;
}
}
bool the_end = readLyXformat2(lex, par);
setPaperStuff();
// the_end was added in 213
if (file_format < 213)
the_end = true;
if (!the_end)
WriteAlert(_("Warning!"),
_("Reading of document is not complete"),
_("Maybe the document is truncated"));
return true;
#endif
} else { // "\\lyxformat" not found } else { // "\\lyxformat" not found
WriteAlert(_("ERROR!"), _("Not a LyX file!")); WriteAlert(_("ERROR!"), _("Not a LyX file!"));
} }
@ -1225,6 +1282,7 @@ bool Buffer::writeFile(string const & fname, bool flag) const
// write out a comment in the top of the file // write out a comment in the top of the file
ofs << '#' << LYX_DOCVERSION ofs << '#' << LYX_DOCVERSION
<< " created this file. For more info see http://www.lyx.org/\n"; << " created this file. For more info see http://www.lyx.org/\n";
#if 0
ofs.setf(ios::showpoint|ios::fixed); ofs.setf(ios::showpoint|ios::fixed);
ofs.precision(2); ofs.precision(2);
#ifndef HAVE_LOCALE #ifndef HAVE_LOCALE
@ -1233,6 +1291,9 @@ bool Buffer::writeFile(string const & fname, bool flag) const
ofs << "\\lyxformat " << dummy_format << "\n"; ofs << "\\lyxformat " << dummy_format << "\n";
#else #else
ofs << "\\lyxformat " << setw(4) << LYX_FORMAT << "\n"; ofs << "\\lyxformat " << setw(4) << LYX_FORMAT << "\n";
#endif
#else
ofs << "\\lyxformat" << LYX_FORMAT << "\n";
#endif #endif
// now write out the buffer paramters. // now write out the buffer paramters.
params.writeFile(ofs); params.writeFile(ofs);

View File

@ -399,8 +399,11 @@ private:
string filename; string filename;
/// Format number of buffer /// Format number of buffer
#if 0
float format; float format;
#else
int file_format;
#endif
/** A list of views using this buffer. /** A list of views using this buffer.
Why not keep a list of the BufferViews that use this buffer? Why not keep a list of the BufferViews that use this buffer?

View File

@ -991,6 +991,12 @@ InsetText::LocalDispatch(BufferView * bv,
TEXT(bv)->BreakParagraph(bv, 0); TEXT(bv)->BreakParagraph(bv, 0);
UpdateLocal(bv, FULL, true); UpdateLocal(bv, FULL, true);
break; break;
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
if (!autoBreakRows)
return DISPATCHED;
TEXT(bv)->BreakParagraph(bv, 1);
UpdateLocal(bv, FULL, true);
break;
case LFUN_BREAKLINE: case LFUN_BREAKLINE:
if (!autoBreakRows) if (!autoBreakRows)
return DISPATCHED; return DISPATCHED;