Modify the InsetBox format to always start 'Box'.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8229 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-12-10 21:48:40 +00:00
parent f31f149037
commit d43da3679e
12 changed files with 137 additions and 25 deletions

View File

@ -1,6 +1,6 @@
2003-12-10 Angus Leeming <leeming@lyx.org> 2003-12-10 Angus Leeming <leeming@lyx.org>
* FORMAT: document format 226. * FORMAT: document formats 226 and 227
2003-12-01 André Pönitz <poenitz@gmx.net> 2003-12-01 André Pönitz <poenitz@gmx.net>

View File

@ -1,6 +1,16 @@
LyX file-format changes LyX file-format changes
----------------------- -----------------------
2003-12-10 Angus Leeming <leeming@lyx.org>
* Change the output of InsetBox:
\begin_inset Boxed -> \begin_inset Box Boxed
\begin_inset Doublebox -> \begin_inset Box Doublebox
\begin_inset Frameless -> \begin_inset Box Frameless
\begin_inset ovalbox -> \begin_inset Box ovalbox
\begin_inset Ovalbox -> \begin_inset Box Ovalbox
\begin_inset Shadowbox -> \begin_inset Box Shadowbox
2003-12-10 Angus Leeming <leeming@lyx.org> 2003-12-10 Angus Leeming <leeming@lyx.org>
* Change the output of InsetNote: * Change the output of InsetNote:

View File

@ -1,3 +1,12 @@
2003-12-10 Angus Leeming <leeming@lyx.org>
* lyx2lyx: up the format to 227.
(lyxformat): squash latent bug when reporting an inability to convert
to the desired format.
* lyxconvert_226.py:
* lyxrevert_227.py: convert the Box inset between formats 226 and 227.
2003-12-10 Angus Leeming <leeming@lyx.org> 2003-12-10 Angus Leeming <leeming@lyx.org>
* lyx2lyx: up the format to 226. * lyx2lyx: up the format to 226.

View File

@ -40,7 +40,7 @@ opt.quiet = 0
format = re.compile(r"(\d)[\.,]?(\d\d)") format = re.compile(r"(\d)[\.,]?(\d\d)")
fileformat = re.compile(r"\\lyxformat\s*(\S*)") fileformat = re.compile(r"\\lyxformat\s*(\S*)")
lst_ft = [210, 215, 216, 217, 218, 220, 221, 223, 224, 225, 226] lst_ft = [210, 215, 216, 217, 218, 220, 221, 223, 224, 225, 226, 227]
def usage(): def usage():
print """Usage: lyx2lyx [options] [file] print """Usage: lyx2lyx [options] [file]
@ -115,7 +115,7 @@ def lyxformat(fmt):
if fmt in lst_ft: if fmt in lst_ft:
return fmt return fmt
opt.err.write(fmt + ": " + error.format_not_supported) opt.err.write(str(fmt) + ": " + error.format_not_supported)
sys.exit(1) sys.exit(1)
def read_file(file, header, body): def read_file(file, header, body):

View File

@ -0,0 +1,39 @@
# This file is part of lyx2lyx
# Copyright (C) 2003 José Matos <jamatos@fep.up.pt>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from parser_tools import find_tokens
def convert_box(lines):
i = 0
while 1:
i = find_tokens(lines, ["\\begin_inset Boxed",
"\\begin_inset Doublebox",
"\\begin_inset Frameless",
"\\begin_inset ovalbox",
"\\begin_inset Ovalbox",
"\\begin_inset Shadowbox"], i)
if i == -1:
break
lines[i] = lines[i][0:13] + 'Box ' + lines[i][13:]
i = i + 1
def convert(header, body):
convert_box(body)
if __name__ == "__main__":
pass

View File

@ -0,0 +1,35 @@
# This file is part of lyx2lyx
# Copyright (C) 2003 Jos<6F>é Matos <jamatos@fep.up.pt>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from parser_tools import find_token
def convert_box(lines):
box_header = "\\begin_inset Box "
i = 0
while 1:
i = find_token(lines, box_header, i)
if i == -1:
break
lines[i] = "\\begin_inset " + lines[i][len(box_header):]
i = i + 1
def convert(header, body):
convert_box(body)
if __name__ == "__main__":
pass

View File

@ -1,3 +1,9 @@
2003-12-10 Angus Leeming <leeming@lyx.org>
* buffer.C: up the format to 227.
* factory.C: the box inset is now identified simply by 'Box'.
2003-12-10 Angus Leeming <leeming@lyx.org> 2003-12-10 Angus Leeming <leeming@lyx.org>
* buffer.C: up the format to 226. * buffer.C: up the format to 226.

View File

@ -132,7 +132,7 @@ extern BufferList bufferlist;
namespace { namespace {
const int LYX_FORMAT = 226; const int LYX_FORMAT = 227;
} // namespace anon } // namespace anon

View File

@ -404,9 +404,7 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
inset.reset(new InsetGraphics); inset.reset(new InsetGraphics);
} else if (tmptok == "Note") { } else if (tmptok == "Note") {
inset.reset(new InsetNote(buf.params(), tmptok)); inset.reset(new InsetNote(buf.params(), tmptok));
} else if (tmptok == "Boxed" || tmptok == "ovalbox" } else if (tmptok == "Box") {
|| tmptok == "Shadowbox" || tmptok == "Doublebox"
|| tmptok == "Ovalbox" || tmptok == "Frameless") {
inset.reset(new InsetBox(buf.params(), tmptok)); inset.reset(new InsetBox(buf.params(), tmptok));
} else if (tmptok == "CharStyle") { } else if (tmptok == "CharStyle") {
lex.next(); lex.next();

View File

@ -1,3 +1,10 @@
2003-12-10 Angus Leeming <leeming@lyx.org>
* insetbox.C: (read, write): now prepend the inset contents with
'Box' to identify the inset as a box inset.
* insetbox.h: move the translators out of sight.
2003-12-10 Angus Leeming <leeming@lyx.org> 2003-12-10 Angus Leeming <leeming@lyx.org>
* insetert.C (string2params): clean-up using the new lyxlex interface. * insetert.C (string2params): clean-up using the new lyxlex interface.
@ -36,7 +43,8 @@
* insetexternal.C (draw): update the xo_, yo_ cache. * insetexternal.C (draw): update the xo_, yo_ cache.
* ExternalTransforms.[Ch] (ResizeData): add a usingScale member function. * ExternalTransforms.[Ch] (ResizeData): add a usingScale member
function.
(RotationDataType): new helper struct wrapping the (RotationDataType): new helper struct wrapping the
RotationData::OriginType enum. RotationData::OriginType enum.

View File

@ -26,6 +26,7 @@
#include "paragraph.h" #include "paragraph.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
#include "support/translator.h"
using std::auto_ptr; using std::auto_ptr;
using std::string; using std::string;
@ -37,6 +38,8 @@ using std::endl;
namespace { namespace {
typedef Translator<std::string, InsetBox::BoxType> BoxTranslator;
BoxTranslator const init_boxtranslator() { BoxTranslator const init_boxtranslator() {
BoxTranslator translator("Boxed", InsetBox::Boxed); BoxTranslator translator("Boxed", InsetBox::Boxed);
translator.addPair("Frameless", InsetBox::Frameless); translator.addPair("Frameless", InsetBox::Frameless);
@ -418,7 +421,7 @@ string const InsetBoxMailer::params2string(InsetBoxParams const & params)
void InsetBoxMailer::string2params(string const & in, void InsetBoxMailer::string2params(string const & in,
InsetBoxParams & params) InsetBoxParams & params)
{ {
params = InsetBoxParams(string()); params = InsetBoxParams(string());
@ -429,10 +432,20 @@ void InsetBoxMailer::string2params(string const & in,
LyXLex lex(0,0); LyXLex lex(0,0);
lex.setStream(data); lex.setStream(data);
string token; string name;
lex.next(); lex >> name;
token = lex.getString(); if (!lex || name != name_) {
lex.next(); lyxerr << "InsetBoxMailer::string2params(" << in << ")\n"
<< "Missing identifier \"" << name_ << '"' << std::endl;
return;
}
// This is part of the inset proper that is usually swallowed
// by LyXText::readInset
string inset_id;
lex >> inset_id;
if (!lex || inset_id != "Box")
return;
params.read(lex); params.read(lex);
} }
@ -454,7 +467,7 @@ InsetBoxParams::InsetBoxParams(string const & label)
void InsetBoxParams::write(ostream & os) const void InsetBoxParams::write(ostream & os) const
{ {
os << type << "\n"; os << "Box " << type << "\n";
os << "position \"" << pos << "\"\n"; os << "position \"" << pos << "\"\n";
os << "hor_pos \"" << hor_pos << "\"\n"; os << "hor_pos \"" << hor_pos << "\"\n";
os << "has_inner_box " << inner_box << "\n"; os << "has_inner_box " << inner_box << "\n";
@ -469,13 +482,17 @@ void InsetBoxParams::write(ostream & os) const
void InsetBoxParams::read(LyXLex & lex) void InsetBoxParams::read(LyXLex & lex)
{ {
if (!lex.isOK())
return;
if (lex.isOK()) { if (lex.isOK()) {
lex.next();
type = lex.getString(); type = lex.getString();
} }
string token;
if (!lex.isOK()) if (!lex.isOK())
return; return;
lex.next(); lex.next();
string token;
token = lex.getString(); token = lex.getString();
if (token == "position") { if (token == "position") {
lex.next(); lex.next();

View File

@ -16,7 +16,6 @@
#include "insetcollapsable.h" #include "insetcollapsable.h"
#include "lyxlength.h" #include "lyxlength.h"
#include "support/translator.h"
struct InsetBoxParams { struct InsetBoxParams {
@ -119,15 +118,6 @@ private:
}; };
namespace {
typedef Translator<std::string, InsetBox::BoxType> BoxTranslator;
BoxTranslator const & boxtranslator();
BoxTranslator const & boxtranslator_loc();
} // anon
#include "mailinset.h" #include "mailinset.h"
class InsetBoxMailer : public MailInset { class InsetBoxMailer : public MailInset {