\end_inset
.
+\change_inserted -712698321 1417953494
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1417953559
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1417953494
+ObsoletedBy
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1417953574
+<layout>
+\end_layout
+
+\end_inset
+
+] Name of an
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1417953533
+InsetLayout
+\end_layout
+
+\end_inset
+
+ that has replaced this
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1417953551
+InsetLayout
+\end_layout
+
+\end_inset
+
+.
+ This is used to rename an
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1417953559
+InsetLayout
+\end_layout
+
+\end_inset
+
+, while keeping backward compatibility.
+\change_unchanged
+
\end_layout
\begin_layout Description
# Incremented to format 52, 1 December 2014 by spitz
# New InsetLayout tag "ForceOwnlines"
+# Incremented to format 53, 7 December 2014 by spitz
+# New InsetLayout tag "ObsoletedBy"
+
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
# development/tools/updatelayouts.py script to update all
# layout files to the new format.
-currentFormat = 52
+currentFormat = 53
def usage(prog_name):
i += 1
continue
- if format == 50 or format == 51:
+ if format >= 50 and format <= 52:
# nothing to do.
i += 1
continue
// You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files.
//
-int const LAYOUT_FORMAT = 52; //spitz: add ForceOwnlines tag
+int const LAYOUT_FORMAT = 53; //spitz: add ObsoletedBy tag for InsetLayouts
namespace {
InsetLayouts::const_iterator cen = insetlayoutlist_.end();
while (!n.empty()) {
InsetLayouts::const_iterator cit = insetlayoutlist_.lower_bound(n);
- if (cit != cen && cit->first == n)
- return cit->second;
+ if (cit != cen && cit->first == n) {
+ if (cit->second.obsoleted_by().empty())
+ return cit->second;
+ n = cit->second.obsoleted_by();
+ return insetLayout(n);
+ }
+ // If we have a generic prefix (e.g., "Note:"),
+ // try if this one alone is found.
size_t i = n.find(':');
if (i == string::npos)
break;
n = n.substr(0, i);
}
+ // Layout "name" not found.
return plain_insetlayout_;
}
#include "TextClass.h"
#include "support/gettext.h"
+#include "support/lstrings.h"
#include <ostream>
void InsetFlex::write(ostream & os) const
{
- os << "Flex " <<
- (name_.empty() ? "undefined" : name_) << "\n";
+ os << "Flex ";
+ InsetLayout const & il = getLayout();
+ if (name_.empty())
+ os << "undefined";
+ else {
+ // use il.name(), since this resolves obsoleted
+ // InsetLayout names
+ string name = to_utf8(il.name());
+ // Remove the "Flex:" prefix, if it is present
+ if (support::prefixIs(name, "Flex:"))
+ name = support::token(name, ':', 1);
+ os << name;
+ }
+ os << "\n";
InsetCollapsable::write(os);
}
IL_LATEXTYPE,
IL_LEFTDELIM,
IL_LYXTYPE,
+ IL_OBSOLETEDBY,
IL_KEEPEMPTY,
IL_MULTIPAR,
IL_NEEDPROTECT,
{ "lyxtype", IL_LYXTYPE },
{ "multipar", IL_MULTIPAR },
{ "needprotect", IL_NEEDPROTECT },
+ { "obsoletedby", IL_OBSOLETEDBY },
{ "parbreakisnewline", IL_PARBREAKISNEWLINE },
{ "passthru", IL_PASSTHRU },
{ "preamble", IL_PREAMBLE },
}
break;
}
+ case IL_OBSOLETEDBY: {
+ docstring style;
+ lex >> style;
+ style = support::subst(style, '_', ' ');
+
+ // We don't want to apply the algorithm in DocumentClass::insetLayout()
+ // here. So we do it the long way.
+ TextClass::InsetLayouts::const_iterator it =
+ tclass.insetLayouts().find(style);
+ if (it != tclass.insetLayouts().end()) {
+ docstring const tmpname = name_;
+ this->operator=(it->second);
+ name_ = tmpname;
+ if (obsoleted_by().empty())
+ obsoleted_by_ = style;
+ } else {
+ LYXERR0("Cannot replace with unknown InsetLayout `"
+ << style << '\'');
+ }
+ break;
+ }
case IL_FONT: {
font_ = lyxRead(lex, inherit_font);
bool isDisplay() const { return display_; }
///
bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
+ ///
+ docstring const & obsoleted_by() const { return obsoleted_by_; }
private:
///
void makeDefaultCSS() const;
bool display_;
///
bool forcelocalfontswitch_;
+ /** Name of an insetlayout that has replaced this insetlayout.
+ This is used to rename an insetlayout, while keeping backward
+ compatibility
+ */
+ docstring obsoleted_by_;
///
Layout::LaTeXArgMap latexargs_;
///