From: Uwe Stöhr Date: Wed, 28 Oct 2015 01:27:32 +0000 (+0100) Subject: moderncv.layout: update some styles and add new ones X-Git-Tag: 2.2.0alpha1~133 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=2c1851e2ec8ec422fc626a2defe7c5ad47ec5c11;p=features.git moderncv.layout: update some styles and add new ones - support for at least modernCV 1.5 (layout will still work with moderncv 1.3 as before) - fileformat change --- diff --git a/development/FORMAT b/development/FORMAT index 4204a2af25..c7af47a1f8 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -11,6 +11,14 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx. ----------------------- +2015-10-27 Uwe Stöhr + * 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 * Format incremented to 498 No new parameters. diff --git a/lib/examples/modernCV.lyx b/lib/examples/modernCV.lyx index d732cb3c55..2ed3e6f24a 100644 --- a/lib/examples/modernCV.lyx +++ b/lib/examples/modernCV.lyx @@ -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 diff --git a/lib/layouts/moderncv.layout b/lib/layouts/moderncv.layout index bae80096a4..d23d16bbf6 100644 --- a/lib/layouts/moderncv.layout +++ b/lib/layouts/moderncv.layout @@ -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 diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index 74ac72e8ee..04acb24f59 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -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 # Copyright (C) 2002-2006 José Matos # @@ -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)) ] #################################################################### diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py index ad06400e14..ea690c3568 100644 --- a/lib/lyx2lyx/lyx_2_2.py +++ b/lib/lyx2lyx/lyx_2_2.py @@ -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]], diff --git a/src/tex2lyx/test/CJK.lyx.lyx b/src/tex2lyx/test/CJK.lyx.lyx index 5ef5b1edcd..8c6724fbd6 100644 --- a/src/tex2lyx/test/CJK.lyx.lyx +++ b/src/tex2lyx/test/CJK.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/CJKutf8.lyx.lyx b/src/tex2lyx/test/CJKutf8.lyx.lyx index b44f55baf7..355a3ee232 100644 --- a/src/tex2lyx/test/CJKutf8.lyx.lyx +++ b/src/tex2lyx/test/CJKutf8.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/DummyDocument.lyx.lyx b/src/tex2lyx/test/DummyDocument.lyx.lyx index fb74ef16ec..a105c6ac7d 100644 --- a/src/tex2lyx/test/DummyDocument.lyx.lyx +++ b/src/tex2lyx/test/DummyDocument.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/Dummy~Document.lyx.lyx b/src/tex2lyx/test/Dummy~Document.lyx.lyx index 5cc61492d7..85d416a5c0 100644 --- a/src/tex2lyx/test/Dummy~Document.lyx.lyx +++ b/src/tex2lyx/test/Dummy~Document.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx index eb11823f47..0fb0377ad6 100644 --- a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx +++ b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/algo2e.lyx.lyx b/src/tex2lyx/test/algo2e.lyx.lyx index 015ad355d1..fe6ec09cd1 100644 --- a/src/tex2lyx/test/algo2e.lyx.lyx +++ b/src/tex2lyx/test/algo2e.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx index 131777a35b..35e6bd41bc 100644 --- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx +++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/test-insets-basic.lyx.lyx b/src/tex2lyx/test/test-insets-basic.lyx.lyx index 02ef62fbc1..4c9e136d37 100644 --- a/src/tex2lyx/test/test-insets-basic.lyx.lyx +++ b/src/tex2lyx/test/test-insets-basic.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/test-insets.lyx.lyx b/src/tex2lyx/test/test-insets.lyx.lyx index c505117b68..f754e351d3 100644 --- a/src/tex2lyx/test/test-insets.lyx.lyx +++ b/src/tex2lyx/test/test-insets.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/test-memoir.lyx.lyx b/src/tex2lyx/test/test-memoir.lyx.lyx index 14047ba682..7f0e210e6f 100644 --- a/src/tex2lyx/test/test-memoir.lyx.lyx +++ b/src/tex2lyx/test/test-memoir.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/test-modules.lyx.lyx b/src/tex2lyx/test/test-modules.lyx.lyx index 9ac5100711..16d4845d27 100644 --- a/src/tex2lyx/test/test-modules.lyx.lyx +++ b/src/tex2lyx/test/test-modules.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx index a08aacca2d..52bc01a730 100644 --- a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx +++ b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/test-scr.lyx.lyx b/src/tex2lyx/test/test-scr.lyx.lyx index b7ca1a27d3..555267b649 100644 --- a/src/tex2lyx/test/test-scr.lyx.lyx +++ b/src/tex2lyx/test/test-scr.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/test-structure.lyx.lyx b/src/tex2lyx/test/test-structure.lyx.lyx index 6a9080f8ed..2a60201eb4 100644 --- a/src/tex2lyx/test/test-structure.lyx.lyx +++ b/src/tex2lyx/test/test-structure.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/test.lyx.lyx b/src/tex2lyx/test/test.lyx.lyx index 0d38dc6028..27dee5eb28 100644 --- a/src/tex2lyx/test/test.lyx.lyx +++ b/src/tex2lyx/test/test.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/tex2lyx/test/verbatim.lyx.lyx b/src/tex2lyx/test/verbatim.lyx.lyx index aefdee9aca..568b5d5c95 100644 --- a/src/tex2lyx/test/verbatim.lyx.lyx +++ b/src/tex2lyx/test/verbatim.lyx.lyx @@ -1,5 +1,5 @@ #LyX file created by tex2lyx 2.2 -\lyxformat 498 +\lyxformat 499 \begin_document \begin_header \origin roundtrip diff --git a/src/version.h b/src/version.h index d647224770..7fb1e552aa 100644 --- a/src/version.h +++ b/src/version.h @@ -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