]> git.lyx.org Git - features.git/commitdiff
layout2layout, changeover to version 5
authorMartin Vermeer <martin.vermeer@hut.fi>
Wed, 22 Aug 2007 14:36:07 +0000 (14:36 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Wed, 22 Aug 2007 14:36:07 +0000 (14:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19723 a592a061-630c-0410-9148-cb99ea01b6c8

lib/scripts/layout2layout.py
src/TextClass.cpp
src/TextClass.h

index 97c7066162a28878675c4bf4e2a9ad893e2bb75e..e539714921f563db467d614472ebe36bc91588f9 100644 (file)
@@ -80,6 +80,7 @@ def convert(lines):
     re_NoStyle = re.compile(r'^(\s*)(NoStyle)(\s+)(\S+)', re.IGNORECASE)
     re_End = re.compile(r'^(\s*)(End)(\s*)$', re.IGNORECASE)
     re_Provides = re.compile(r'^(\s*)Provides(\S+)(\s+)(\S+)', re.IGNORECASE)
+    re_CharStyle = re.compile(r'^(\s*)CharStyle(\s+)(\S+)$', re.IGNORECASE)
 
     # counters for sectioning styles (hardcoded in 1.3)
     counters = {"part"          : "\\Roman{part}",
@@ -126,7 +127,7 @@ def convert(lines):
 
         # Skip comments and empty lines
         if re_Comment.match(lines[i]) or re_Empty.match(lines[i]):
-            i = i + 1
+            i += 1
             continue
 
         # insert file format if not already there
@@ -134,10 +135,10 @@ def convert(lines):
                 match = re_Format.match(lines[i])
                 if match:
                         format = int(match.group(4))
-                        if format > 1 and format < 4:
+                        if format > 1 and format < 5:
                             lines[i] = "Format %d" % (format + 1)
                             only_comment = 0
-                        elif format == 4:
+                        elif format == 5:
                                 # nothing to do
                                 return format
                         else:
@@ -149,9 +150,22 @@ def convert(lines):
 
         # Don't get confused by LaTeX code
         if re_Preamble.match(lines[i]):
-            i = i + 1
+            i += 1
             while i < len(lines) and not re_EndPreamble.match(lines[i]):
-                i = i + 1
+                i += 1
+            continue
+
+        if format == 4:
+            # Handle conversion to long CharStyle names
+            match = re_CharStyle.match(lines[i])
+            if match:
+                lines[i] = "InsetLayout CharStyle:%s" % (match.group(3))
+                i += 1
+                lines.insert(i, "\tLyXType charstyle")
+                i += 1
+                lines.insert(i, "")
+                lines[i] = "\tLabelString %s" % (match.group(3))
+            i += 1
             continue
 
         if format == 3:
@@ -162,7 +176,7 @@ def convert(lines):
             if match:
                 lines[i] = "%sProvides %s%s%s" % (match.group(1), match.group(2).lower(),
                                                   match.group(3), match.group(4))
-            i = i + 1
+            i += 1
             continue
 
         if format == 2:
@@ -219,7 +233,7 @@ def convert(lines):
                                         '        Series              Bold',
                                         '      EndFont']
 
-            i = i + 1
+            i += 1
             continue
 
         # Delete MaxCounter and remember the value of it
@@ -308,7 +322,7 @@ def convert(lines):
             if string.lower(label) == "bibliography":
                 if (latextype_line < 0):
                     lines.insert(i, "%sLatexType Bib_Environment" % space1)
-                    i = i + 1
+                    i += 1
                 else:
                     lines[latextype_line] = re_LatexType.sub(r'\1\2\3Bib_Environment', lines[latextype_line])
 
@@ -337,7 +351,7 @@ def convert(lines):
                 if counters.has_key(style):
                     if labelstring_line < 0:
                         lines.insert(i, '%sLabelString "%s"' % (space1, counters[style]))
-                        i = i + 1
+                        i += 1
                     else:
                         new_labelstring = concatenate_label(labelstring, counters[style])
                         lines[labelstring_line] = re_LabelString.sub(
@@ -346,7 +360,7 @@ def convert(lines):
                 if appendixcounters.has_key(style):
                     if labelstringappendix_line < 0:
                         lines.insert(i, '%sLabelStringAppendix "%s"' % (space1, appendixcounters[style]))
-                        i = i + 1
+                        i += 1
                     else:
                         new_labelstring = concatenate_label(labelstring, appendixcounters[style])
                         lines[labelstringappendix_line] = re_LabelStringAppendix.sub(
@@ -355,14 +369,14 @@ def convert(lines):
 
                 # Now we can safely add the LabelCounter line
                 lines.insert(labeltype_line + 1, "%sLabelCounter %s" % (space1, counter))
-                i = i + 1
+                i += 1
 
             # Add the TocLevel setting for sectioning styles
             if toclevels.has_key(style) and maxcounter <= toclevels[style]:
                 lines.insert(i, '%sTocLevel %d' % (space1, toclevels[style]))
-                i = i + 1
+                i += 1
 
-        i = i + 1
+        i += 1
 
     return format + 1
 
index 377f6fabe0d79c755bc8269283753782f7001b45..2a4d69d0c78ecb27b6eda7f9002720b9666c89aa 100644 (file)
@@ -68,7 +68,7 @@ private:
 };
 
 
-int const FORMAT = 4;
+int const FORMAT = 5;
 
 
 bool layout2layout(FileName const & filename, FileName const & tempfile)
@@ -598,12 +598,12 @@ void TextClass::readClassOptions(Lexer & lexrc)
 
 enum InsetLayoutTags {
        IL_FONT = 1,
-       IL_LYXTYPE,
        IL_LABELFONT,
        IL_LABELSTRING,
-       IL_LATEXTYPE,
        IL_LATEXNAME,
        IL_LATEXPARAM,
+       IL_LATEXTYPE,
+       IL_LYXTYPE,
        IL_PREAMBLE,
        IL_END
 };
@@ -620,7 +620,7 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                { "latexparam", IL_LATEXPARAM },
                { "latextype", IL_LATEXTYPE },
                { "lyxtype", IL_LYXTYPE },
-               { "preamble", IL_PREAMBLE}
+               { "preamble", IL_PREAMBLE }
        };
 
        lexrc.pushTable(elementTags, IL_END);
@@ -694,7 +694,7 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                il.latexparam = latexparam;
                il.font = font;
                il.labelfont = labelfont;
-               il.preamble = from_utf8(preamble);
+               il.preamble = preamble;
                insetlayoutlist_[name] = il;
 
                // test name for CS:
index afab7ffd3e7c5b4dcb162485f5b06cd6f4ce7378..d1aeddf860d1ccbf5f0dfffb911797808b3bd7fb 100644 (file)
@@ -39,7 +39,7 @@ public:
        std::string latexparam;
        Font font;
        Font labelfont;
-       docstring preamble;
+       std::string preamble;
 };