]> git.lyx.org Git - features.git/commitdiff
moderncv.layout: update some styles and add new ones
authorUwe Stöhr <uwestoehr@lyx.org>
Wed, 28 Oct 2015 01:27:32 +0000 (02:27 +0100)
committerUwe Stöhr <uwestoehr@lyx.org>
Wed, 28 Oct 2015 01:27:32 +0000 (02:27 +0100)
- support for at least modernCV 1.5 (layout will still work with moderncv 1.3 as before)
- fileformat change

22 files changed:
development/FORMAT
lib/examples/modernCV.lyx
lib/layouts/moderncv.layout
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_2_2.py
src/tex2lyx/test/CJK.lyx.lyx
src/tex2lyx/test/CJKutf8.lyx.lyx
src/tex2lyx/test/DummyDocument.lyx.lyx
src/tex2lyx/test/Dummy~Document.lyx.lyx
src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
src/tex2lyx/test/algo2e.lyx.lyx
src/tex2lyx/test/box-color-size-space-align.lyx.lyx
src/tex2lyx/test/test-insets-basic.lyx.lyx
src/tex2lyx/test/test-insets.lyx.lyx
src/tex2lyx/test/test-memoir.lyx.lyx
src/tex2lyx/test/test-modules.lyx.lyx
src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
src/tex2lyx/test/test-scr.lyx.lyx
src/tex2lyx/test/test-structure.lyx.lyx
src/tex2lyx/test/test.lyx.lyx
src/tex2lyx/test/verbatim.lyx.lyx
src/version.h

index 4204a2af252a66f090f23f62fa81618c13695c1f..c7af47a1f84d4251ccc0218b15b257eeb094d5c5 100644 (file)
@@ -11,6 +11,14 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
 
 -----------------------
 
+2015-10-27 Uwe Stöhr <uwestoehr@web.de>
+       * Format incremented to 499
+         No new parameters.
+         moderncv layout improvements:
+         - new style Name ,obsoletes the styles FamilyName and FirstName
+         - new argument for style Phone, obsoletes styles Mobile and Fax
+         - new styles CVIcons and CVColumnWidth
+
 2015-10-19 Uwe Stöhr <uwestoehr@web.de>
        * Format incremented to 498
          No new parameters.
index d732cb3c55d380b73413c6f3e8abbbd4547b466a..2ed3e6f24a10daae4eaa5b92dce6c3422dd5c436 100644 (file)
@@ -2,12 +2,8 @@
 \lyxformat 498
 \begin_document
 \begin_header
-\origin unavailable
+\origin /systemlyxdir/examples/
 \textclass moderncv
-\begin_preamble
-% uncomment if you want to change the width of the column with the dates:
-%\setlength{\hintscolumnwidth}{3cm} 
-\end_preamble
 \use_default_options false
 \maintain_unincluded_children false
 \language english
@@ -81,9 +77,8 @@
 status open
 
 \begin_layout Plain Layout
-The moderncv class offers lots of customization possibilities; one is explained
- in the preamble of this document; for more information look at the documentatio
-n of the \SpecialChar LaTeX
+The moderncv class offers lots of customization possibilities; for more
+ information look at the documentation of the \SpecialChar LaTeX
 -package 
 \series bold
 moderncv
@@ -112,6 +107,24 @@ http://mirrors.ctan.org/macros/latex/contrib/moderncv/examples/template.tex
 \end_layout
 
 \begin_layout CVStyle
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Plain Layout
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+left
+\end_layout
+
+\end_inset
+
+options can only be activated if moderncv 2.0 is installed
+\end_layout
+
+\end_inset
+
 casual
 \begin_inset Note Note
 status open
@@ -124,6 +137,21 @@ required, possible styles are 'casual' (default), 'classic', 'fancy' ('fancy'
 \end_inset
 
 
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Plain Layout
+To be able to use style options you need at least moderncv version 2.0 installed.
+ A list of possible options can be found here:
+\begin_inset Newline newline
+\end_inset
+
+http://article.gmane.org/gmane.comp.tex.ctan.announce/11898
+\end_layout
+
+\end_inset
+
+
 \end_layout
 
 \begin_layout CVColor
@@ -139,6 +167,40 @@ required, possible colors are 'blue' (default), 'orange', 'green', 'red',
 \end_inset
 
 
+\end_layout
+
+\begin_layout CVIcons
+awesome
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Plain Layout
+optional, must be inserted after the 
+\family sans
+CV Style
+\family default
+, possible icon sets are 'awesome' (default for style 'casual' and 'banking'),
+ 'marvosym' (default for the other styles) and 'letters' (default for style
+ 'oldstyle')
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout CVColumnWidth
+3cm
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Plain Layout
+optional, the width of the column with the dates, default is '3cm'
+\end_layout
+
+\end_inset
+
+
 \end_layout
 
 \begin_layout PDF Page Mode
@@ -203,11 +265,16 @@ Fonts.
 
 \end_layout
 
-\begin_layout FirstName
+\begin_layout Name
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
 Paul
 \end_layout
 
-\begin_layout FamilyName
+\end_inset
+
 Testman
 \end_layout
 
@@ -285,7 +352,16 @@ oldstyle
 
 \end_layout
 
-\begin_layout Mobile
+\begin_layout Phone
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+mobile
+\end_layout
+
+\end_inset
+
 +43(0)999 888
 \end_layout
 
@@ -293,7 +369,16 @@ oldstyle
 +43(0)999 9999
 \end_layout
 
-\begin_layout Fax
+\begin_layout Phone
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+fax
+\end_layout
+
+\end_inset
+
 +43(0)999 7777
 \end_layout
 
index bae80096a4304eb20c1fa3382bfb9922a966d589..d23d16bbf68870b7d7d68624ceed3d6760114865 100644 (file)
@@ -48,6 +48,10 @@ Style CVStyle
          Series        Bold
          Color         Blue
        EndFont
+       Argument 1
+         LabelString   "Style Options"
+         Tooltip               "Options for the CV style"
+       EndArgument
 End
 
 Style CVColor
@@ -56,15 +60,27 @@ Style CVColor
        LabelString     "CV Color Scheme:"
 End
 
+Style CVIcons
+       CopyStyle       CVStyle
+       LatexName       moderncvicons
+       LabelString     "CV Icon Set:"
+End
+
+Style CVColumnWidth
+       CopyStyle       CVStyle
+       LatexName       setlength{\hintscolumnwidth}
+       LabelString     "Column Width:"
+End
+
 Style PDF_Page_Mode
        CopyStyle       CVStyle
        LatexName       renewcommand{\pdfpagemode}
        LabelString     "PDF Page Mode:"
 End
 
-Style FirstName
+Style Name
        LatexType       command
-       LatexName       firstname
+       LatexName       name
        Category        FrontMatter
        InPreamble      1
        TopSep          0.7
@@ -73,6 +89,18 @@ Style FirstName
          Family        Sans
          Size          Largest
        EndFont
+       Argument 1
+         LabelString   "First Name"
+         Tooltip       "First name"
+         Mandatory     1
+       EndArgument
+End
+
+Style FirstName
+       CopyStyle       Name
+       LatexName       firstname
+       ResetArgs       0
+       ObsoletedBy     Name
 End
 
 Style FamilyName
@@ -80,6 +108,7 @@ Style FamilyName
        LatexName       familyname
        TopSep          0.3
        LabelString     "Family Name:"
+       ObsoletedBy     Name
 End
 
 Style Title
@@ -121,22 +150,28 @@ Style Address
        EndArgument
 End
 
-Style Mobile
-       CopyStyle       CVStyle
-       LatexName       mobile
-       LabelString     "Mobile:"
-End
-
 Style Phone
        CopyStyle       CVStyle
        LatexName       phone
        LabelString     "Phone:"
+       Argument 1
+         LabelString   "Phone Type"
+         Tooltip       "can be fixed, mobile or fax"
+       EndArgument
+End
+
+Style Mobile
+       CopyStyle       CVStyle
+       LatexName       mobile
+       LabelString     "Mobile:"
+       ObsoletedBy     Phone
 End
 
 Style Fax
        CopyStyle       CVStyle
        LatexName       fax
        LabelString     "Fax:"
+       ObsoletedBy     Phone
 End
 
 Style Email
index 74ac72e8ee19b0025b262b5088725a11f3abc5fe..04acb24f595674e798e1426b005728dada7e8ca6 100644 (file)
@@ -1,6 +1,6 @@
 # This file is part of lyx2lyx
 # -*- coding: utf-8 -*-
-# Copyright (C) 2002-2011 The LyX Team
+# Copyright (C) 2002-2015 The LyX Team
 # Copyright (C) 2002-2004 Dekel Tsur <dekel@lyx.org>
 # Copyright (C) 2002-2006 José Matos <jamatos@lyx.org>
 #
@@ -85,7 +85,7 @@ format_relation = [("0_06",    [200], minor_versions("0.6" , 4)),
                    ("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
                    ("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
                    ("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
-                   ("2_2", list(range(475,499)), minor_versions("2.2" , 0))
+                   ("2_2", list(range(475,500)), minor_versions("2.2" , 0))
                   ]
 
 ####################################################################
index ad06400e14e0510235341183086d29b11e3e720e..ea690c3568e0b1dc1529c943eea823a24fcc91d0 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 # This file is part of lyx2lyx
 # -*- coding: utf-8 -*-
-# Copyright (C) 2011 The LyX team
+# Copyright (C) 2015 The LyX team
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -1812,6 +1812,187 @@ def revert_tcolorbox_8(document):
       return
 
 
+def revert_moderncv_1(document):
+  " Reverts the new inset of moderncv to TeX-code in preamble "
+  
+  if document.textclass != "moderncv":
+    return
+  i = 0
+  j = 0
+  lineArg = 0
+  while True:
+    # at first revert the new styles
+    # \moderncvicons
+    i = find_token(document.body, "\\begin_layout CVIcons", 0)
+    if i == -1:
+      return
+    j = find_end_of_layout(document.body, i)
+    if j == -1:
+      document.warning("Malformed LyX document: Can't find end of CVIcons layout")
+      i += 1
+      continue
+    content = lyx2latex(document, document.body[i:j + 1])
+    add_to_preamble(document, ["\\moderncvicons{" + content + "}"])
+    del document.body[i:j + 1]
+    # \hintscolumnwidth
+    i = find_token(document.body, "\\begin_layout CVColumnWidth", 0)
+    if i == -1:
+      return
+    j = find_end_of_layout(document.body, i)
+    if j == -1:
+      document.warning("Malformed LyX document: Can't find end of CVColumnWidth layout")
+      i += 1
+      continue
+    content = lyx2latex(document, document.body[i:j + 1])
+    add_to_preamble(document, ["\\setlength{\hintscolumnwidth}{" + content + "}"])
+    del document.body[i:j + 1]
+    # now change the new styles to the obsolete ones
+    # \name
+    i = find_token(document.body, "\\begin_layout Name", 0)
+    if i == -1:
+      return
+    j = find_end_of_layout(document.body, i)
+    if j == -1:
+      document.warning("Malformed LyX document: Can't find end of Name layout")
+      i += 1
+      continue
+    lineArg = find_token(document.body, "\\begin_inset Argument 1", i)
+    if lineArg > j and j != 0:
+      return
+    if lineArg != -1:
+      beginPlain = find_token(document.body, "\\begin_layout Plain Layout", lineArg)
+      # we have to assure that no other inset is in the Argument
+      beginInset = find_token(document.body, "\\begin_inset", beginPlain)
+      endInset = find_token(document.body, "\\end_inset", beginPlain)
+      k = beginPlain + 1
+      l = k
+      while beginInset < endInset and beginInset != -1:
+        beginInset = find_token(document.body, "\\begin_inset", k)
+        endInset = find_token(document.body, "\\end_inset", l)
+        k = beginInset + 1
+        l = endInset + 1
+      Arg2 = document.body[l + 5 : l + 6]
+      # rename the style
+      document.body[i : i + 1]= ["\\begin_layout FirstName"]
+      # delete the Argument inset
+      del( document.body[endInset - 2 : endInset + 3])
+      del( document.body[lineArg : beginPlain + 1])
+      document.body[i + 4 : i + 4]= ["\\begin_layout FamilyName"] + Arg2 + ["\\end_layout"] + [""]
+
+
+def revert_moderncv_2(document):
+  " Reverts the phone inset of moderncv to the obsoleted mobile or fax "
+  
+  if document.textclass != "moderncv":
+    return
+  i = 0
+  j = 0
+  lineArg = 0
+  while True:
+    # \phone
+    i = find_token(document.body, "\\begin_layout Phone", i)
+    if i == -1:
+      return
+    j = find_end_of_layout(document.body, i)
+    if j == -1:
+      document.warning("Malformed LyX document: Can't find end of Phone layout")
+      i += 1
+      return
+    lineArg = find_token(document.body, "\\begin_inset Argument 1", i)
+    if lineArg > j and j != 0:
+      i += 1
+      continue
+    if lineArg != -1:
+      beginPlain = find_token(document.body, "\\begin_layout Plain Layout", lineArg)
+      # we have to assure that no other inset is in the Argument
+      beginInset = find_token(document.body, "\\begin_inset", beginPlain)
+      endInset = find_token(document.body, "\\end_inset", beginPlain)
+      k = beginPlain + 1
+      l = k
+      while beginInset < endInset and beginInset != -1:
+        beginInset = find_token(document.body, "\\begin_inset", k)
+        endInset = find_token(document.body, "\\end_inset", l)
+        k = beginInset + 1
+        l = endInset + 1
+      Arg = document.body[beginPlain + 1 : beginPlain + 2]
+      # rename the style
+      if Arg[0] == "mobile":
+        document.body[i : i + 1]= ["\\begin_layout Mobile"]
+      if Arg[0] == "fax":
+        document.body[i : i + 1]= ["\\begin_layout Fax"]
+      # delete the Argument inset
+      del(document.body[endInset - 2 : endInset + 1])
+      del(document.body[lineArg : beginPlain + 3])
+    i += 1
+
+
+def convert_moderncv(document):
+  " Convert the Fax and Mobile inset of moderncv to the new phone inset "
+  
+  if document.textclass != "moderncv":
+    return
+  i = 0
+  j = 0
+  lineArg = 0
+  while True:
+    # \mobile
+    i = find_token(document.body, "\\begin_layout Mobile", i)
+    if i == -1:
+      return
+    j = find_end_of_layout(document.body, i)
+    if j == -1:
+      document.warning("Malformed LyX document: Can't find end of Mobile layout")
+      i += 1
+      return
+    document.body[i + 1 : i + 1] = ["\\begin_inset Argument 1", "status open", "",
+                        "\\begin_layout Plain Layout", "mobile", "\\end_layout", "",
+                        "\\end_inset", ""]
+    # \fax
+    i = find_token(document.body, "\\begin_layout Fax", i)
+    if i == -1:
+      return
+    j = find_end_of_layout(document.body, i)
+    if j == -1:
+      document.warning("Malformed LyX document: Can't find end of Fax layout")
+      i += 1
+      return
+    document.body[i + 1 : i + 1] = ["\\begin_inset Argument 1", "status open", "",
+                        "\\begin_layout Plain Layout", "fax", "\\end_layout", "",
+                        "\\end_inset", ""]
+    # \firstname and \familyname
+    i1 = find_token(document.body, "\\begin_layout FirstName", 0)
+    if i1 == -1:
+      return
+    j1 = find_end_of_layout(document.body, i1)
+    if j1 == -1:
+      document.warning("Malformed LyX document: Can't find end of FirstName layout")
+      i1 += 1
+      return
+    FirstName = document.body[i1 + 1 : i1 + 2]
+    i2 = find_token(document.body, "\\begin_layout FamilyName", 0)
+    if i2 == -1:
+      return
+    j2 = find_end_of_layout(document.body, i2)
+    if j2 == -1:
+      document.warning("Malformed LyX document: Can't find end of FamilyName layout")
+      i2 += 1
+      return
+    FamilyName = document.body[i2 + 1 : i2 + 2]
+    if j1 > j2:
+      k = j1
+      l = i2
+    else:
+      k = j2
+      l = i1
+    document.body[k + 1 : k + 1] = ["\\begin_layout Name", "\\begin_inset Argument 1", "status open", "",
+                        "\\begin_layout Plain Layout", FirstName[0], "\\end_layout", "",
+                        "\\end_inset", "", FamilyName[0], "\\end_layout", ""]
+    #document.body[i2 + 1 : i2 + 1] = ["hellok: ", str(k)]
+    del(document.body[l : k])
+    i += 1
+    i1 += 1
+    i2 += 1
+
 ##
 # Conversion hub
 #
@@ -1844,10 +2025,12 @@ convert = [
            [495, [convert_subref]],
            [496, [convert_nounzip]],
            [497, [convert_external_bbox]],
-           [498, []]
+           [498, []],
+           [499, [convert_moderncv]]
           ]
 
 revert =  [
+           [498, [revert_moderncv_1, revert_moderncv_2]],
            [497, [revert_tcolorbox_1, revert_tcolorbox_2,
                   revert_tcolorbox_3, revert_tcolorbox_4, revert_tcolorbox_5,
                   revert_tcolorbox_6, revert_tcolorbox_7, revert_tcolorbox_8]],
index 5ef5b1edcd08fed508a8e7c759d72e84d7013656..8c6724fbd688ee91f63b488e169dd73e9bef659b 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index b44f55baf7f4f00970ba4246efc1ea0740b0cf21..355a3ee232e6ae5a1bb3633ad616f0571d6e2ced 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index fb74ef16ec682f910661f22219a67a14ecadd2ec..a105c6ac7d5fd0fe7971e919a93cdee86386b06e 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index 5cc61492d72a5db26f690f1634d7c3357e107ac4..85d416a5c05613d91e83aaed92d01767ab08d216 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index eb11823f47b93e0e508e7b6c9e81c363b3423eb7..0fb0377ad6ba8b3c40862c2d279ab3e011422391 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index 015ad355d1b504c80082261ae3f6f73d4c564aaf..fe6ec09cd117c5e308e2b291fc08ba826ec4188d 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index 131777a35ba503724c685682393c77118c73a594..35e6bd41bccc9f633c90e8f9c46cddc717b6ea98 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index 02ef62fbc15f3fafcac3efab991d3650bab4b538..4c9e136d378af1830f72ff61a19eafd4bcae83b4 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index c505117b683b22d2a1eb6cc9a1e2c07999d0862c..f754e351d3f00c77d4d892f614a851c06c17a15f 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index 14047ba6824c13cc13dca058f4da05c43fb18273..7f0e210e6fc1cfa8e0f4d75166186da6dfd7e842 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index 9ac510071163bd1290354e33a6a6db42836fb251..16d4845d27cbf0d93167f52d4458181d6e9b471e 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index a08aacca2d8ba01a38df56bf6463df7850f6fef3..52bc01a730d7abfad00b8ca645339f9e8051b79d 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index b7ca1a27d37389cdf63e8da537a75f3d3f2fd871..555267b649ece5df6137eabaa90d9064f04346ab 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index 6a9080f8edb03010e88808d7cebaf8e7e660854b..2a60201eb44835b0fa9584852fe17dc1ccac7fd4 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index 0d38dc60288ed82d068686220f76a52e4af5e556..27dee5eb28a0bacaed859ed20f2af12c97bfdf76 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index aefdee9aca6ce59bff160edf260442c611bd010c..568b5d5c95be918014235b8f549abbcde9b3229f 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 498
+\lyxformat 499
 \begin_document
 \begin_header
 \origin roundtrip
index d647224770c25dc3a9bdd52b2272cf185550c355..7fb1e552aaa8ffa3c94afc080e1a5024c30165f6 100644 (file)
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 498 // uwestoehr: tcolorbox module improvements
-#define LYX_FORMAT_TEX2LYX 498
+#define LYX_FORMAT_LYX 499 // uwestoehr: moderncv module improvements
+#define LYX_FORMAT_TEX2LYX 499
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER