From b01075469d416889bbc01fa0ead6609ca65e451b Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 6 Aug 2019 18:18:37 +0200 Subject: [PATCH] Add more page sizes to KOMA and memoir --- development/FORMAT | 3 ++ lib/layouts/memoir.layout | 2 ++ lib/layouts/scrclass.inc | 6 +++- lib/lyx2lyx/lyx_2_4.py | 67 ++++++++++++++++++++++++++++++++++++++- src/version.h | 4 +-- 5 files changed, 78 insertions(+), 4 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 688869231e..b6ca416932 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,6 +7,9 @@ changes happened in particular if possible. A good example would be ----------------------- +2019-08-06 Jürgen Spitzmüller + * Format incremented to 585: Add more page sizes to KOMA and memoir. + 2019-07-26 Joel Kulesza * Format incremented to 584: support for revision InsetInfo addition of revision-abbrev. This entry is added to accommodate git abbreviated diff --git a/lib/layouts/memoir.layout b/lib/layouts/memoir.layout index a60518f15b..a5a9e2418a 100644 --- a/lib/layouts/memoir.layout +++ b/lib/layouts/memoir.layout @@ -14,6 +14,7 @@ SecNumDepth 1 TocDepth 1 DefaultStyle Standard PageStyle Headings +PageSize letterpaper Provides makeidx 1 Provides framed 1 Provides subscript 1 @@ -27,6 +28,7 @@ Provides SetSpace 1 ClassOptions FontSize 9|10|11|12|14|17 + PageSize a3paper|a4paper|a5paper|a6paper|b3paper|b4paper|b5paper|b6paper|executivepaper|legalpaper|letterpaper PageStyle empty|plain|headings|myheadings|ruled|Ruled|companion Other oldfontcommands End diff --git a/lib/layouts/scrclass.inc b/lib/layouts/scrclass.inc index 358a84fa9b..ab64f2d24b 100644 --- a/lib/layouts/scrclass.inc +++ b/lib/layouts/scrclass.inc @@ -8,12 +8,16 @@ # Labeling is now used also in non-KOMA classes -Format 76 +Format 77 SecNumDepth 2 TocDepth 2 DefaultStyle Standard Provides subscript 1 +ClassOptions + PageSize a0paper|a1paper|a2paper|a3paper|a4paper|a5paper|a6paper|b0paper|b1paper|b2paper|b3paper|b4paper|b5paper|b6paper|c0paper|c1paper|c2paper|c3paper|c4paper|c5paper|c6paper|executivepaper|legalpaper|letterpaper +End + Style Standard Category MainText LatexName dummy diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 7473699e08..1f47342407 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -3122,6 +3122,69 @@ def revert_CrimsonProFont(document): if revert_fonts(document, fm, fontmap, False, True): add_preamble_fonts(document, fontmap) + +def revert_pagesizes(document): + " Revert new page sizes in memoir and KOMA to options " + + if document.textclass != "memoir" and document.textclass[:2] != "scr": + return + + i = find_token(document.header, "\\use_geometry true", 0) + if i != -1: + return + + defsizes = ["default", "custom", "letterpaper", "legalpaper", "executivepaper", "a4paper", "a5paper", "b5paper"] + + i = find_token(document.header, "\\papersize", 0) + if i == -1: + document.warning("Malformed LyX document! Missing \\papersize header.") + return + val = get_value(document.header, "\\papersize", i) + if val in defsizes: + # nothing to do + return + + document.header[i] = "\\papersize default" + + i = find_token(document.header, "\\options", 0) + if i == -1: + i = find_token(document.header, "\\textclass", 0) + if i == -1: + document.warning("Malformed LyX document! Missing \\textclass header.") + return + document.header.insert(i, "\\options " + val) + return + document.header[i] = document.header[i] + "," + val + + +def convert_pagesizes(document): + " Convert to new page sizes in memoir and KOMA to options " + + if document.textclass != "memoir" and document.textclass[:2] != "scr": + return + + i = find_token(document.header, "\\use_geometry true", 0) + if i != -1: + return + + defsizes = ["default", "custom", "letterpaper", "legalpaper", "executivepaper", "a4paper", "a5paper", "b5paper"] + + i = find_token(document.header, "\\papersize", 0) + if i == -1: + document.warning("Malformed LyX document! Missing \\papersize header.") + return + val = get_value(document.header, "\\papersize", i) + if val in defsizes: + # nothing to do + return + + i = find_token(document.header, "\\use_geometry false", 0) + if i != -1: + # Maintain use of geometry + document.header[1] = "\\use_geometry true" + + + ## # Conversion hub # @@ -3168,9 +3231,11 @@ convert = [ [582, [convert_AdobeFonts,convert_latexFonts,convert_notoFonts,convert_CantarellFont,convert_FiraFont]],# old font re-converterted due to extra options [583, [convert_ChivoFont,convert_Semibolds,convert_NotoRegulars,convert_CrimsonProFont]], [584, []], + [585, [convert_pagesizes]] ] -revert = [[583, [revert_vcsinfo_rev_abbrev]], +revert = [[584, [revert_pagesizes]], + [583, [revert_vcsinfo_rev_abbrev]], [582, [revert_ChivoFont,revert_CrimsonProFont]], [581, [revert_CantarellFont,revert_FiraFont]], [580, [revert_texfontopts,revert_osf]], diff --git a/src/version.h b/src/version.h index 8e3e17a0ec..15e2e737fd 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 584 // Kornel: Add Chivo sans serif font -#define LYX_FORMAT_TEX2LYX 584 +#define LYX_FORMAT_LYX 585 // spitz: add more page sizes to KOMA and memoir +#define LYX_FORMAT_TEX2LYX 585 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER