]> git.lyx.org Git - features.git/commitdiff
place one paragraph parameter per line. (file format = 239)
authorJosé Matox <jamatos@lyx.org>
Thu, 6 Jan 2005 16:52:08 +0000 (16:52 +0000)
committerJosé Matox <jamatos@lyx.org>
Thu, 6 Jan 2005 16:52:08 +0000 (16:52 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9450 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/lyx2lyx/ChangeLog
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_4.py
src/ChangeLog
src/ParagraphParameters.C
src/buffer.C
src/paragraph.C

index b62e5278e84c7ce34ecf99c367b2a558737bb4d8..7bd5e0a94b0e50981f9d5dd4966fe3c76f0b656b 100644 (file)
@@ -1,26 +1,43 @@
 LyX file-format changes
 -----------------------
 
+2005-01-06  José Matos  <jamatos@lyx.org>
+
+       * format incremented to 239.
+       * the paragraph parameters are displayed in their own line. This
+       change is consistent with the insets behaviour, and corresponds
+       to a more uniform treatment of the paragraphs since some of them
+       had already their own line.
+
+       An example of a single paragraph follows:
+
+\begin_layout Standard
+\paragraph_spacing single
+\align left
+Paragraph text.
+\end_layout
+
+
 2004-12-03  José Matos  <jamatos@lyx.org>
 
-       * format up to 238.
-       * The compatibility code to read old latex accents from 0.12.x in
-       InsetLatexAccent::checkContents has been removed.
-       The following translations are done:
-               "\i \x"   -> "\i \x{}"
-               "\i \xy"  -> "\i \x{y}"
-               "\i \x y" -> "\i \x{y}"
-               "\i \x\i" -> "\i \x{\i}"
-               "\i \x\j" -> "\i \x{\j}"
-       x is a latex accent command, y the base character. \, i and j are
-       literal.
-       lyx did these changes already from 0.12.x -> 215, but not lyx2lyx,
-       so formats 215 - 237 can have both versions.
+       * format incremented to 238.
+       * The compatibility code to read old latex accents from 0.12.x in
+       InsetLatexAccent::checkContents has been removed.
+       The following translations are done:
+               "\i \x"   -> "\i \x{}"
+               "\i \xy"  -> "\i \x{y}"
+               "\i \x y" -> "\i \x{y}"
+               "\i \x\i" -> "\i \x{\i}"
+               "\i \x\j" -> "\i \x{\j}"
+       x is a latex accent command, y the base character. \, i and j are
+       literal.
+       lyx did these changes already from 0.12.x -> 215, but not lyx2lyx,
+       so formats 215 - 237 can have both versions.
 
 
 2004-10-10  José Matos  <jamatos@lyx.org>
 
-       * format up to 237.
+       * format incremented to 237.
        * In the header, the following statments use now booleans values,
        instead of 0, 1:
                - \use_geometry
index b7f102853870c965b66b79d8cf6094a58e21f465..18d00214cdadbfc6200c99e37cd9bab82186e916 100644 (file)
@@ -1,3 +1,10 @@
+2005-01-06  José Matos  <jamatos@lyx.org>
+
+       * lyx_1_4.py (normalize_paragraph_params): update file format to 239.
+
+       * LyX.py (convert): simplify code and add running times
+       information for higher debug levels.
+
 2005-01-04  José Matos  <jamatos@lyx.org>
 
        * lyx_0_12.py:
index df8baa3d8a7c4a00f1d0e383c5a02e49bd5aa817..e3e2739d8ab6f08db4db9a289b22277413b5df49 100644 (file)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-from parser_tools import get_value, check_token, find_token, find_tokens, find_end_of, find_end_of_inset
+from parser_tools import get_value, check_token, find_token,\
+     find_tokens, find_end_of, find_end_of_inset
 import os.path
 import gzip
 import sys
 import re
 import string
+import time
 
 version_lyx2lyx = "1.4.0cvs"
 default_debug_level = 2
@@ -44,7 +46,7 @@ format_relation = [("0_10",  [210], ["0.10.7","0.10"]),
                    ("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
                    ("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
                    ("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3"]),
-                   ("1_4", range(223,239), ["1.4.0cvs","1.4"])]
+                   ("1_4", range(223,240), ["1.4.0cvs","1.4"])]
 
 
 def formats_list():
@@ -267,23 +269,23 @@ class LyX_Base:
         for step in convertion_chain:
             steps = getattr(__import__("lyx_" + step), mode)
 
+            self.warning("Convertion step: %s - %s" % (step, mode), default_debug_level + 1)
             if not steps:
                     self.error("The convertion to an older format (%s) is not implemented." % self.format)
 
-            if len(steps) == 1:
-                version, table = steps[0]
-                for conv in table:
-                    conv(self)
-                self.format = version
-                continue
-
+            multi_conv = len(steps) != 1
             for version, table in steps:
-                if self.format >= version and mode == "convert":
-                    continue
-                if self.format <= version and mode == "revert":
+                if multi_conv and \
+                   (self.format >= version and mode == "convert") or\
+                   (self.format <= version and mode == "revert"):
                     continue
+
                 for conv in table:
+                    init_t = time.time()
                     conv(self)
+                    self.warning("%lf: Elapsed time on %s"  % (time.time() - init_t, str(conv)),
+                                 default_debug_level + 1)
+
                 self.format = version
                 if self.end_format == self.format:
                     return
index 0722503a4228d2336fc45e89bf448900d8c97b5f..ac81fc39b750473e6753e6c8e4f9b66578884052 100644 (file)
@@ -1507,6 +1507,32 @@ def use_x_binary(file):
         decompose = split(file.header[i])
         file.header[i] = decompose[0] + ' ' + bool2bin[decompose[1]]
 
+##
+# Place all the paragraph parameters in their own line
+#
+def normalize_paragraph_params(file):
+    body = file.body
+    allowed_parameters = '\\paragraph_spacing', '\\noindent', '\\align', '\\labelwidthstring'
+
+    i = 0
+    while 1:
+        i = find_token(file.body, '\\begin_layout', i)
+        if i == -1:
+            return
+
+        i = i + 1
+        while 1:
+            if strip(body[i]) and split(body[i])[0] not in allowed_parameters:
+                break
+
+            j = find(body[i],'\\', 1)
+
+            if j != -1:
+                body[i:i+1] = [strip(body[i][:j]), body[i][j:]]
+
+            i = i + 1
+
+
 ##
 # Convertion hub
 #
@@ -1529,9 +1555,11 @@ convert = [[223, [insert_tracking_changes, add_end_header, remove_color_default,
            [236, [convert_bullets, add_begin_header, add_begin_body,
                   normalize_papersize, strip_end_space]],
            [237, [use_x_boolean]],
-           [238, [update_latexaccents]]]
+           [238, [update_latexaccents]],
+           [239, [normalize_paragraph_params]]]
 
-revert =  [[237, []],
+revert =  [[238, []],
+           [237, []],
            [236, [use_x_binary]],
            [235, [denormalize_papersize, remove_begin_body,remove_begin_header,
                   revert_bullets]],
index 66fac148bdd0c9d1c8c65f4d3952f4176ed3f2eb..a2194bcc5fafa41f1b1dad88d985a6f3f9cc847f 100644 (file)
@@ -1,3 +1,9 @@
+2005-01-06  José Matos  <jamatos@lyx.org>
+
+       * ParagraphParameters.C (write): put every parameter in its own line.
+       * paragraph.C (write): reduce number of consecutive empty lines exported.
+       * buffer.C (LYX_FORMAT): increase file format to 239.
+
 2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * everywhere: change support/tostr.h -> support/convert.h
 
        * Makefile.am (BOOST_LIBS): use boost variables
 
-2004-12-03  José Matos <jamatos@lyx.org>
+2004-12-03  José Matos  <jamatos@lyx.org>
 
        * buffer.C: format up to 238.
 
index d93e07cbb66af9e4b12c1eb83e134f438c207131..1f5da6720a93de1cb22715edf5508c2a1a17f7d3 100644 (file)
@@ -246,28 +246,25 @@ void ParagraphParameters::read(LyXLex & lex)
 
 void ParagraphParameters::write(ostream & os) const
 {
-       ostringstream oss;
-
        // Maybe the paragraph has special spacing
-       spacing().writeFile(oss, true);
+       spacing().writeFile(os, true);
 
        // The labelwidth string used in lists.
        if (!labelWidthString().empty())
-               oss << "\\labelwidthstring "
+               os << "\\labelwidthstring "
                   << labelWidthString() << '\n';
 
        // Start of appendix?
        if (startOfAppendix())
-               oss << "\\start_of_appendix ";
+               os << "\\start_of_appendix\n";
 
        // Noindent?
        if (noindent())
-               oss << "\\noindent ";
+               os << "\\noindent\n";
 
        // Do we have a manual left indent?
        if (!leftIndent().zero())
-               oss << "\\leftindent " << leftIndent().asString()
-                  << ' ';
+               os << "\\leftindent " << leftIndent().asString() << '\n';
 
        // Alignment?
        if (align() != LYX_ALIGN_LAYOUT) {
@@ -278,9 +275,8 @@ void ParagraphParameters::write(ostream & os) const
                case LYX_ALIGN_CENTER: h = 3; break;
                default: h = 0; break;
                }
-               oss << "\\align " << string_align[h] << ' ';
+               os << "\\align " << string_align[h] << '\n';
        }
-       os << rtrim(oss.str());
 }
 
 
@@ -301,7 +297,7 @@ void params2string(Paragraph const & par, string & data)
        params.write(os);
 
        // Is alignment possible
-       os << '\n' << "\\alignpossible " << layout->alignpossible << '\n';
+       os << "\\alignpossible " << layout->alignpossible << '\n';
 
        /// set default alignment
        os << "\\aligndefault " << layout->align << '\n';
index de6a46b06eebc4fb6a26562bb512fa3a3a662759..3439e408dada1b75821a7f082122de395f94bcae 100644 (file)
@@ -136,7 +136,7 @@ extern BufferList bufferlist;
 
 namespace {
 
-int const LYX_FORMAT = 238;
+int const LYX_FORMAT = 239;
 
 } // namespace anon
 
index ce8b9967d8f6d0af1f825423e8ac15f71dd2b26b..5be1eaaa76da4c9c3269dc2c0e086c63bbea2a9c 100644 (file)
@@ -156,10 +156,6 @@ void Paragraph::write(Buffer const & buf, ostream & os,
 
        int column = 0;
        for (pos_type i = 0; i < size(); ++i) {
-               if (!i) {
-                       os << '\n';
-                       column = 0;
-               }
 
                Change change = pimpl_->lookupChangeFull(i);
                Changes::lyxMarkChange(os, column, curtime, running_change, change);
@@ -185,7 +181,9 @@ void Paragraph::write(Buffer const & buf, ostream & os,
                                        // the file
                                        inset->write(buf, os);
                                } else {
-                                       os << "\n\\begin_inset ";
+                                       if (i)
+                                               os << '\n';
+                                       os << "\\begin_inset ";
                                        inset->write(buf, os);
                                        os << "\n\\end_inset\n\n";
                                        column = 0;