From ebe6c9287f51b4f5169118bd3302a75d5259fa66 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 28 Mar 2011 23:11:54 +0000 Subject: [PATCH] Fix bug #7080. - Have InsetFlex::layoutName() report "Flex:" + the inset name. - Do some layout2layout work so that user insets that do not have the "Flex:" prefix get it. Note that this will break some CopyStyle stuff, but we do not have any decent way to do that, so users will have to make that change for themselves. I guess we should add that to the release notes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38112 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/scripts/layout2layout.py | 36 +++++++++++++++++++++++++++++++++++- src/TextClass.cpp | 2 +- src/insets/InsetFlex.h | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index bbecf80cea..d9f8cabc46 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -119,6 +119,9 @@ import os, re, string, sys # Incremented to format 34, 28 March 2011 by rgh # Remove obsolete Fill_(Top|Bottom) tags +# Incremented to format 35, 28 March 2011 by rgh +# Try to add "Flex:" to any flex insets that don't have it. + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). @@ -126,7 +129,7 @@ import os, re, string, sys # development/tools/updatelayouts.sh script to update all # layout files to the new format. -currentFormat = 34 +currentFormat = 35 def usage(prog_name): @@ -217,6 +220,10 @@ def convert(lines): re_QInsetLayout_CopyStyle = re.compile(r'^\s*CopyStyle\s+"(?:Custom|CharStyle|Element):([^"]+)"\s*$', re.IGNORECASE) re_NeedsFloatPkg = re.compile(r'^(\s*)NeedsFloatPkg\s+(\w+)\s*$', re.IGNORECASE) re_Fill = re.compile(r'^\s*Fill_(?:Top|Bottom).*$', re.IGNORECASE) + re_InsetLayout2 = re.compile(r'^\s*InsetLayout\s+(\S+)\s*$', re.IGNORECASE) + # with quotes + re_QInsetLayout2 = re.compile(r'^\s*InsetLayout\s+"([^"]+)"\s*$', re.IGNORECASE) + re_IsFlex = re.compile(r'\s*LyXType.*$', re.IGNORECASE) # counters for sectioning styles (hardcoded in 1.3) counters = {"part" : "\\Roman{part}", @@ -305,6 +312,33 @@ def convert(lines): i += 1 continue + if format == 34: + match = re_InsetLayout2.match(lines[i]) + if not match: + match = re_QInsetLayout2.match(lines[i]) + if not match: + i += 1 + continue + name = match.group(1) + names = name.split(":", 1) + if len(names) > 1 and names[0] == "Flex": + i += 1 + continue + + isflex = False + for j in range(i + 1, len(lines)): + if re_IsFlex.match(lines[j]): + isflex = True + break + if re_End.match(lines[j]): + break + + if isflex: + lines[i] = "InsetLayout \"Flex:" + name + "\"" + + i += 1 + continue + if format == 33: m = re_Fill.match(lines[i]) if m: diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 9d097a0209..00558d5862 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -60,7 +60,7 @@ namespace lyx { // development/updatelayouts.sh script, to update the format of // all of our layout files. // -int const LAYOUT_FORMAT = 34; +int const LAYOUT_FORMAT = 35; namespace { diff --git a/src/insets/InsetFlex.h b/src/insets/InsetFlex.h index 8a73a24c51..a51f30ae41 100644 --- a/src/insets/InsetFlex.h +++ b/src/insets/InsetFlex.h @@ -25,7 +25,7 @@ public: /// InsetFlex(Buffer *, std::string const & layoutName); /// - docstring layoutName() const { return from_utf8(name_); } + docstring layoutName() const { return from_utf8("Flex:" + name_); } /// InsetLayout const & getLayout() const; /// -- 2.39.2