OK, so this is hardly regressions and crashes, but it's simple and starts to disentangle some of the mess of classes. All this does is move the "extra fonts" stuff in extarticle, extbook, extletter, and extreport into a module, and then it has the necessary lyx2lyx to make this painless. The format change is of course needed to drive the lyx2lyx conversion.

Any objections?

I think there are probably similar conversions that can be done to other layouts, but they'd all need format changes, too, so they'll likely have to wait.

Richard

Index: development/FORMAT
===================================================================
--- development/FORMAT	(revision 26729)
+++ development/FORMAT	(working copy)
@@ -1,6 +1,9 @@
 LyX file-format changes
 -----------------------
 
+2008-10-04 Richard Heck <[EMAIL PROTECTED]>
+	* Format incremented to 342: modularization of "extra font" classes.
+
 2008-09-30 Uwe Stöhr <[EMAIL PROTECTED]>
 	* Format incremented to 341: support for TABs in listings".
 
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(revision 26729)
+++ src/Buffer.cpp	(working copy)
@@ -115,7 +115,7 @@
 
 namespace {
 
-int const LYX_FORMAT = 341; //uwestoehr: TAB support for listings
+int const LYX_FORMAT = 342; //rgh: change font size stuff to module
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
Index: lib/lyx2lyx/LyX.py
===================================================================
--- lib/lyx2lyx/LyX.py	(revision 26729)
+++ lib/lyx2lyx/LyX.py	(working copy)
@@ -428,6 +428,14 @@
       self.header.insert(j, module)
 
 
+    def remove_module(self, module):
+      if not self.has_module(module):
+          return
+      mods = self.get_module_list()
+      mods.remove(module)
+      self.set_module_list(mods)
+
+
     def get_module_list(self):
       i = find_token(self.header, "\\begin_modules", 0)
       if (i == -1):
@@ -436,6 +444,11 @@
       return self.header[i + 1 : j]
 
 
+    def has_module(self, module):
+      mods = self.get_module_list()
+      return module in mods
+
+
     def set_module_list(self, mlist):
       modbegin = find_token(self.header, "\\begin_modules", 0)
       newmodlist = ['\\begin_modules'] + mlist + ['\\end_modules']
Index: lib/lyx2lyx/lyx_1_6.py
===================================================================
--- lib/lyx2lyx/lyx_1_6.py	(revision 26729)
+++ lib/lyx2lyx/lyx_1_6.py	(working copy)
@@ -2937,6 +2937,36 @@
         j += 1
 
 
+def convert_fontsize(document):
+    "Convert the ext*.layout classes to normal classes with module."
+    tc = document.textclass
+    newtc = ""
+    # it might seem better to do this with a regex, or just by checking 
+    # for "ext", but we only know about these four classes.
+    if tc == "extarticle":
+        newtc = "article"
+    elif tc == "extbook":
+        newtc = "book"
+    elif tc == "extreport":
+        newtc = "report"
+    elif tc == "extletter":
+        newtc = "letter"
+    if newtc == "":
+        return
+    document.textclass = newtc
+    document.add_module("extrafonts")
+
+
+def revert_fontsize(document):
+    if not document.has_module("extrafonts"):
+        return
+    tc = document.textclass
+    if tc != "article" and tc != "book" and tc != "report" and tc != "letter":
+        return
+    tc = "ext" + tc
+    document.textclass = tc
+    document.remove_module("extrafonts")
+
 ##
 # Conversion hub
 #
@@ -3006,10 +3036,12 @@
            [338, []],
            [339, []],
            [340, [add_plain_layout]],
-           [341, []]
+           [341, []],
+           [342, [convert_fontsize]]
           ]
 
-revert =  [[340, [revert_tabulators, revert_tabsize]],
+revert =  [[341, [revert_fontsize]],
+           [340, [revert_tabulators, revert_tabsize]],
            [339, []],
            [338, [revert_removed_modules]],
            [337, [revert_polytonicgreek]],
Index: lib/layouts/extreport.layout
===================================================================
--- lib/layouts/extreport.layout	(revision 26729)
+++ lib/layouts/extreport.layout	(working copy)
@@ -1,12 +0,0 @@
-#% Do not delete the line below; configure depends on this
-#  \DeclareLaTeXClass[extreport]{report (more font sizes)}
-# Extented report textclass definition file.
-# Herbert Voss <[EMAIL PROTECTED]>
-
-Format 8
-Input report.layout
-
-# change available fontsizes
-ClassOptions
-	FontSize              8|9|10|11|12|14|17|20
-End
Index: lib/layouts/extarticle.layout
===================================================================
--- lib/layouts/extarticle.layout	(revision 26729)
+++ lib/layouts/extarticle.layout	(working copy)
@@ -1,11 +0,0 @@
-#% Do not delete the line below; configure depends on this
-#  \DeclareLaTeXClass[extarticle]{article (more font sizes)}
-# Herbert Voss <[EMAIL PROTECTED]>
-
-Format 8
-Input article.layout
-
-# change available fontsizes
-ClassOptions
-	FontSize              8|9|10|11|12|14|17|20
-end
Index: lib/layouts/extbook.layout
===================================================================
--- lib/layouts/extbook.layout	(revision 26729)
+++ lib/layouts/extbook.layout	(working copy)
@@ -1,12 +0,0 @@
-#% Do not delete the line below; configure depends on this
-#  \DeclareLaTeXClass[extbook]{book (more font sizes)}
-# Extended book textclass definition file.
-# Herbert Voss <[EMAIL PROTECTED]>
-
-Format 8
-Input book.layout
-
-# change available fontsizes
-ClassOptions
-	FontSize              8|9|10|11|12|14|17|20
-end
Index: lib/layouts/extletter.layout
===================================================================
--- lib/layouts/extletter.layout	(revision 26729)
+++ lib/layouts/extletter.layout	(working copy)
@@ -1,12 +0,0 @@
-#% Do not delete the line below; configure depends on this
-#  \DeclareLaTeXClass[extletter]{letter (more font sizes)}
-# Extended article textclass definition file.
-# Herbert Voss <[EMAIL PROTECTED]>
-
-Format 8
-Input letter.layout
-
-# change available fontsizes
-ClassOptions
-	FontSize              8|9|10|11|12|14|17|20
-end
Index: lib/Makefile.am
===================================================================
--- lib/Makefile.am	(revision 26729)
+++ lib/Makefile.am	(working copy)
@@ -981,10 +981,7 @@
 	layouts/endnotes.module \
 	layouts/entcs.layout \
 	layouts/europecv.layout \
-	layouts/extarticle.layout \
-	layouts/extbook.layout \
-	layouts/extletter.layout \
-	layouts/extreport.layout \
+	layouts/extrafonts.module \
 	layouts/foils.layout \
 	layouts/foottoend.module \
 	layouts/g-brief-de.layout \

Reply via email to