Convert CharStyle to Flex also in file format

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20138 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Martin Vermeer 2007-09-08 13:01:29 +00:00
parent cf84439502
commit 2e5355e4c2
5 changed files with 33 additions and 7 deletions

View File

@ -1,6 +1,11 @@
LyX file-format changes LyX file-format changes
----------------------- -----------------------
2007-09-08 Martin Vermeer
* format incremented to 283: CharStyle insets are now
called Flex.
2007-08-31 Bo Peng 2007-08-31 Bo Peng
* format incremented to 282: lyx files can be zipfiles with * format incremented to 282: lyx files can be zipfiles with

View File

@ -78,7 +78,7 @@ format_relation = [("0_06", [200], generate_minor_versions("0.6" , 4)),
("1_3", [221], generate_minor_versions("1.3" , 7)), ("1_3", [221], generate_minor_versions("1.3" , 7)),
("1_4", range(222,246), generate_minor_versions("1.4" , 5)), ("1_4", range(222,246), generate_minor_versions("1.4" , 5)),
("1_5", range(246,277), generate_minor_versions("1.5" , 1)), ("1_5", range(246,277), generate_minor_versions("1.5" , 1)),
("1_6", range(277,283), generate_minor_versions("1.6" , 0))] ("1_6", range(277,284), generate_minor_versions("1.6" , 0))]
def formats_list(): def formats_list():

View File

@ -155,6 +155,25 @@ def revert_begin_modules(document):
break break
document.header[i : j + 1] = [] document.header[i : j + 1] = []
def convert_flex(document):
"Convert CharStyle to Flex"
i = 0
while True:
i = find_token(document.body, "\\begin_inset CharStyle", i)
if i == -1:
return
document.body[i] = document.body[i].replace('\\begin_inset CharStyle', '\\begin_inset Flex')
def revert_flex(document):
"Convert Flex to CharStyle"
i = 0
while True:
i = find_token(document.body, "\\begin_inset Flex", i)
if i == -1:
return
document.body[i] = document.body[i].replace('\\begin_inset Flex', '\\begin_inset CharStyle')
## ##
# Conversion hub # Conversion hub
@ -167,10 +186,12 @@ convert = [
[279, [long_charstyle_names]], [279, [long_charstyle_names]],
[280, [axe_show_label]], [280, [axe_show_label]],
[281, []], [281, []],
[282, []] [282, []],
[283, [convert_flex]]
] ]
revert = [ revert = [
[282, [revert_flex]],
[281, []], [281, []],
[280, [revert_begin_modules]], [280, [revert_begin_modules]],
[279, [revert_show_label]], [279, [revert_show_label]],

View File

@ -142,7 +142,7 @@ namespace fs = boost::filesystem;
namespace { namespace {
int const LYX_FORMAT = 282; int const LYX_FORMAT = 283;
} // namespace anon } // namespace anon

View File

@ -78,7 +78,7 @@ void InsetFlex::setLayout(InsetLayout il)
docstring const InsetFlex::editMessage() const docstring const InsetFlex::editMessage() const
{ {
return _("Opened CharStyle Inset"); return _("Opened Flex Inset");
} }
@ -137,7 +137,7 @@ bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & status) const FuncStatus & status) const
{ {
switch (cmd.action) { switch (cmd.action) {
// paragraph breaks not allowed in charstyle insets // paragraph breaks not allowed in flex insets
case LFUN_BREAK_PARAGRAPH: case LFUN_BREAK_PARAGRAPH:
case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT: case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
case LFUN_BREAK_PARAGRAPH_SKIP: case LFUN_BREAK_PARAGRAPH_SKIP:
@ -190,7 +190,7 @@ void InsetFlex::textString(Buffer const & buf, odocstream & os) const
void InsetFlexParams::write(ostream & os) const void InsetFlexParams::write(ostream & os) const
{ {
os << "CharStyle " << name << "\n"; os << "Flex " << name << "\n";
} }
@ -200,7 +200,7 @@ void InsetFlexParams::read(Lexer & lex)
lex.next(); lex.next();
string token = lex.getString(); string token = lex.getString();
if (token == "CharStyle") { if (token == "Flex") {
lex.next(); lex.next();
name = lex.getString(); name = lex.getString();
} }