mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
parent
f47361c4db
commit
cfeddb9293
@ -17951,6 +17951,76 @@ InsetLayout
|
||||
\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
|
||||
|
@ -174,6 +174,9 @@ import os, re, string, sys
|
||||
# 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").
|
||||
|
||||
@ -181,7 +184,7 @@ import os, re, string, sys
|
||||
# development/tools/updatelayouts.py script to update all
|
||||
# layout files to the new format.
|
||||
|
||||
currentFormat = 52
|
||||
currentFormat = 53
|
||||
|
||||
|
||||
def usage(prog_name):
|
||||
@ -405,7 +408,7 @@ def convert(lines):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if format == 50 or format == 51:
|
||||
if format >= 50 and format <= 52:
|
||||
# nothing to do.
|
||||
i += 1
|
||||
continue
|
||||
|
@ -61,7 +61,7 @@ namespace lyx {
|
||||
// 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 {
|
||||
|
||||
@ -1422,13 +1422,20 @@ InsetLayout const & DocumentClass::insetLayout(docstring const & name) const
|
||||
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_;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "TextClass.h"
|
||||
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
@ -66,8 +67,20 @@ InsetLayout::InsetDecoration InsetFlex::decoration() const
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
IL_LATEXTYPE,
|
||||
IL_LEFTDELIM,
|
||||
IL_LYXTYPE,
|
||||
IL_OBSOLETEDBY,
|
||||
IL_KEEPEMPTY,
|
||||
IL_MULTIPAR,
|
||||
IL_NEEDPROTECT,
|
||||
@ -164,6 +165,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
{ "lyxtype", IL_LYXTYPE },
|
||||
{ "multipar", IL_MULTIPAR },
|
||||
{ "needprotect", IL_NEEDPROTECT },
|
||||
{ "obsoletedby", IL_OBSOLETEDBY },
|
||||
{ "parbreakisnewline", IL_PARBREAKISNEWLINE },
|
||||
{ "passthru", IL_PASSTHRU },
|
||||
{ "preamble", IL_PREAMBLE },
|
||||
@ -330,6 +332,27 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
}
|
||||
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);
|
||||
|
@ -175,6 +175,8 @@ public:
|
||||
bool isDisplay() const { return display_; }
|
||||
///
|
||||
bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
|
||||
///
|
||||
docstring const & obsoleted_by() const { return obsoleted_by_; }
|
||||
private:
|
||||
///
|
||||
void makeDefaultCSS() const;
|
||||
@ -277,6 +279,11 @@ private:
|
||||
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_;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user