]> git.lyx.org Git - features.git/commitdiff
patch from Dekel, change lyxformat to int
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 11 Jan 2001 11:06:10 +0000 (11:06 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 11 Jan 2001 11:06:10 +0000 (11:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1313 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/buffer.C
src/buffer.h
src/insets/insettext.C

index ac658a7b3efe133dbb9a40e31fc1e91426368942..e4ad465cdb85420ffc0289cacd3bdb84ae5f8922 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * src/tabular.C (Write): write lowercase identifiers
index d0b864ef9a9eb1cb287d85941835c1be66d9e774..785568d896b7c39815d7b0b93a0e3ff96acf3401 100644 (file)
@@ -113,7 +113,11 @@ extern BufferList bufferlist;
 extern LyXAction lyxaction;
 
 
+#if 0
 static const float LYX_FORMAT = 2.17;
+#else
+static const int LYX_FORMAT = 218;
+#endif
 
 extern int tex_code_break_column;
 
@@ -248,9 +252,13 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par)
 
        LyXParagraph * return_par = 0;
        LyXFont font(LyXFont::ALL_INHERIT, params.language);
+#if 0
        if (format < 2.16 && params.language->lang() == "hebrew")
                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
        bool has_token = false;
        string pretoken;
@@ -365,8 +373,13 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
 #endif
                par->depth = depth;
                font = LyXFont(LyXFont::ALL_INHERIT, params.language);
+#if 0
                if (format < 2.16 && params.language->lang() == "hebrew")
                        font.setLanguage(default_language);
+#else
+               if (file_format < 216 && params.language->lang() == "hebrew")
+                       font.setLanguage(default_language);
+#endif
 #ifndef NEW_INSETS
        } else if (token == "\\end_float") {
                if (!return_par) 
@@ -381,8 +394,13 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                lex.EatLine();
                par->layout = LYX_DUMMY_LAYOUT;
                font = LyXFont(LyXFont::ALL_INHERIT, params.language);
+#if 0
                if (format < 2.16 && params.language->lang() == "hebrew")
                        font.setLanguage(default_language);
+#else
+               if (file_format < 216 && params.language->lang() == "hebrew")
+                       font.setLanguage(default_language);
+#endif
        } else if (token == "\\begin_float") {
                int tmpret = lex.FindToken(string_footnotekinds);
                if (tmpret == -1) ++tmpret;
@@ -1053,6 +1071,7 @@ bool Buffer::readFile(LyXLex & lex, LyXParagraph * par)
                string const token(lex.GetString());
                if (token == "\\lyxformat") { // the first token _must_ be...
                        lex.EatLine();
+#if 0
                        format = lex.GetFloat();
                        if (format > 1.0) {
                                if (LYX_FORMAT - format > 0.05) {
@@ -1085,6 +1104,44 @@ bool Buffer::readFile(LyXLex & lex, LyXParagraph * par)
                                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
                        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
        ofs << '#' << LYX_DOCVERSION 
            << " created this file. For more info see http://www.lyx.org/\n";
+#if 0
        ofs.setf(ios::showpoint|ios::fixed);
        ofs.precision(2);
 #ifndef HAVE_LOCALE
@@ -1233,6 +1291,9 @@ bool Buffer::writeFile(string const & fname, bool flag) const
        ofs << "\\lyxformat " <<  dummy_format << "\n";
 #else
        ofs << "\\lyxformat " << setw(4) <<  LYX_FORMAT << "\n";
+#endif
+#else
+       ofs << "\\lyxformat" << LYX_FORMAT << "\n";
 #endif
        // now write out the buffer paramters.
        params.writeFile(ofs);
index 3a6465b3b1c3f8d3d9dcd4405be075ddf29130dc..05ce5ba17c7a5064e190c6c4453e0550ed39fcb0 100644 (file)
@@ -399,8 +399,11 @@ private:
        string filename;
 
        /// Format number of buffer
+#if 0
        float format;
-       
+#else
+       int file_format;
+#endif
        /** A list of views using this buffer.
            Why not keep a list of the BufferViews that use this buffer?
 
index c03d10b1a2a7e4c15bb6abb42aa1427af56a980e..a1f98b51634c6bc2a35215c4e8b531167776bfec 100644 (file)
@@ -991,6 +991,12 @@ InsetText::LocalDispatch(BufferView * bv,
        TEXT(bv)->BreakParagraph(bv, 0);
        UpdateLocal(bv, FULL, true);
        break;
+    case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
+       if (!autoBreakRows)
+           return DISPATCHED;
+       TEXT(bv)->BreakParagraph(bv, 1);
+       UpdateLocal(bv, FULL, true);
+       break;
     case LFUN_BREAKLINE:
        if (!autoBreakRows)
            return DISPATCHED;