On Tuesday 15 May 2007 16:54:43 Jürgen Spitzmüller wrote:
>
> yes.

  Could you please test the attached patch. It should give you a clean 
roundup. This means, in this context, that if you revert a document with 11pt 
to 1.4 and you import it back you will a font size of 11 instead of having 
this value in the Options field.

  I have tested and it works for me but I would like to have an independent 
confirmation before committing it.

> Jürgen

-- 
José Abílio
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(revision 18352)
+++ src/Buffer.cpp	(working copy)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bj�nnes
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -141,7 +141,7 @@
 
 namespace {
 
-int const LYX_FORMAT = 270;
+int const LYX_FORMAT = 271;
 
 } // namespace anon
 
Index: lib/lyx2lyx/LyX.py
===================================================================
--- lib/lyx2lyx/LyX.py	(revision 18352)
+++ lib/lyx2lyx/LyX.py	(working copy)
@@ -74,7 +74,7 @@
                    ("1_2",     [220], generate_minor_versions("1.2" , 4)),
                    ("1_3",     [221], generate_minor_versions("1.3" , 7)),
                    ("1_4", range(222,246), generate_minor_versions("1.4" , 4)),
-                   ("1_5", range(246,271), generate_minor_versions("1.5" , 0))]
+                   ("1_5", range(246,272), generate_minor_versions("1.5" , 0))]
 
 
 def formats_list():
Index: lib/lyx2lyx/lyx_1_5.py
===================================================================
--- lib/lyx2lyx/lyx_1_5.py	(revision 18352)
+++ lib/lyx2lyx/lyx_1_5.py	(working copy)
@@ -1601,6 +1601,61 @@
                                     r'\end_inset']
 
 
+def revert_ext_font_sizes(document):
+    if document.backend != "latex": return
+    if not document.textclass.startswith("ext"): return
+
+    fontsize = get_value(document.header, '\\paperfontsize', 0)
+    if fontsize not in ('10', '11', '12'): return
+
+    i = find_token(document.header, '\\paperfontsize', 0)
+    document.header[i] = '\\paperfontsize default'
+
+    i = find_token(document.header, '\\options', 0)
+    if i == -1:
+        i = find_token(document.header, '\\textclass', 0) + 1
+        document.header[i:i] = ['\\options %spt' % fontsize]
+    else:
+        document.header[i] += ',%s' % fontsize
+
+
+def convert_ext_font_sizes(document):
+    if document.backend != "latex": return
+    if not document.textclass.startswith("ext"): return
+
+    fontsize = get_value(document.header, '\\paperfontsize', 0)
+    if fontsize != 'default': return
+
+    i = find_token(document.header, '\\options', 0)
+    if i == -1: return
+
+    options = get_value(document.header, '\\options', i)
+
+    fontsizes = '10pt', '11pt', '12pt'
+    for fs in fontsizes:
+        if options.find(fs) != -1:
+            break
+    else: # this else will only be attained if the for cycle had no match
+        return
+
+    options = options.split(',')
+    for j, opt in enumerate(options):
+        if opt in fontsizes:
+            fontsize = opt[:-2]
+            del options[j]
+            break
+    else:
+        return
+
+    k = find_token(document.header, '\\paperfontsize', 0)
+    document.header[k] = '\\paperfontsize %s' % fontsize
+
+    if options:
+        document.header[i] = '\\options %s' % ','.join(options)
+    else:
+        del document.header[i]
+
+
 ##
 # Conversion hub
 #
@@ -1630,9 +1685,13 @@
            [267, []],
            [268, []],
            [269, []],
-           [270, []]]
+           [270, []],
+           [271, [convert_ext_font_sizes]]
+          ]
 
-revert =  [[269, [revert_beamer_alert, revert_beamer_structure]],
+revert =  [
+           [270, [revert_ext_font_sizes]],
+           [269, [revert_beamer_alert, revert_beamer_structure]],
            [268, [revert_preamble_listings_params, revert_listings_inset, revert_include_listings]],
            [267, [revert_CJK]],
            [266, [revert_utf8plain]],
Index: development/FORMAT
===================================================================
--- development/FORMAT	(revision 18352)
+++ development/FORMAT	(working copy)
@@ -1,5 +1,8 @@
 LyX file-format changes
 -----------------------
+2007-05-15 José Matos <[EMAIL PROTECTED]>
+	* format incremented to 271: extended textclasses accept the
+        normal font sizes: 10, 11 and 12pt.
 
 2007-05-14 Martin Vermeer <[EMAIL PROTECTED]>
 	* format incremented to 270: support beamer \alert, \structure

Reply via email to