Georg Baum wrote:
> Why do you remove these files?
Ok, you convinced me. See attached patch (also committed).
> I get this one if I try to read a 225 file with lyx with your box
> patch:
Should no longer be the case.
Roll on tomorrow and the discussion with José.
--
Angus
Index: development/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/development/ChangeLog,v
retrieving revision 1.37
diff -u -p -r1.37 ChangeLog
--- development/ChangeLog 10 Dec 2003 17:28:10 -0000 1.37
+++ development/ChangeLog 10 Dec 2003 21:43:35 -0000
@@ -1,6 +1,6 @@
2003-12-10 Angus Leeming <[EMAIL PROTECTED]>
- * FORMAT: document format 226.
+ * FORMAT: document formats 226 and 227
2003-12-01 André Pönitz <[EMAIL PROTECTED]>
Index: development/FORMAT
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/development/FORMAT,v
retrieving revision 1.17
diff -u -p -r1.17 FORMAT
--- development/FORMAT 10 Dec 2003 17:28:11 -0000 1.17
+++ development/FORMAT 10 Dec 2003 21:43:35 -0000
@@ -3,6 +3,16 @@ LyX file-format changes
2003-12-10 Angus Leeming <[EMAIL PROTECTED]>
+ * 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 <[EMAIL PROTECTED]>
+
* Change the output of InsetNote:
\begin_inset Note -> \begin_inset Note Note
\begin_inset Comment -> \begin_inset Note Comment
Index: lib/lyx2lyx/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/ChangeLog,v
retrieving revision 1.8
diff -u -p -r1.8 ChangeLog
--- lib/lyx2lyx/ChangeLog 10 Dec 2003 21:42:53 -0000 1.8
+++ lib/lyx2lyx/ChangeLog 10 Dec 2003 21:43:35 -0000
@@ -1,5 +1,14 @@
2003-12-10 Angus Leeming <[EMAIL PROTECTED]>
+ * 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 <[EMAIL PROTECTED]>
+
* lyx2lyx: up the format to 226.
* lyxconvert_225.py:
Index: lib/lyx2lyx/lyx2lyx
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/lyx2lyx,v
retrieving revision 1.18
diff -u -p -r1.18 lyx2lyx
--- lib/lyx2lyx/lyx2lyx 10 Dec 2003 17:28:11 -0000 1.18
+++ lib/lyx2lyx/lyx2lyx 10 Dec 2003 21:43:35 -0000
@@ -40,7 +40,7 @@ opt.quiet = 0
format = re.compile(r"(\d)[\.,]?(\d\d)")
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():
print """Usage: lyx2lyx [options] [file]
@@ -115,7 +115,7 @@ def lyxformat(fmt):
if fmt in lst_ft:
return fmt
- opt.err.write(fmt + ": " + error.format_not_supported)
+ opt.err.write(str(fmt) + ": " + error.format_not_supported)
sys.exit(1)
def read_file(file, header, body):
Index: lib/lyx2lyx/lyxconvert_226.py
===================================================================
RCS file: lib/lyx2lyx/lyxconvert_226.py
diff -N lib/lyx2lyx/lyxconvert_226.py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/lyx2lyx/lyxconvert_226.py 10 Dec 2003 21:43:35 -0000
@@ -0,0 +1,39 @@
+# This file is part of lyx2lyx
+# Copyright (C) 2003 José Matos <[EMAIL PROTECTED]>
+#
+# 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
Index: lib/lyx2lyx/lyxrevert_227.py
===================================================================
RCS file: lib/lyx2lyx/lyxrevert_227.py
diff -N lib/lyx2lyx/lyxrevert_227.py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/lyx2lyx/lyxrevert_227.py 10 Dec 2003 21:43:35 -0000
@@ -0,0 +1,35 @@
+# This file is part of lyx2lyx
+# Copyright (C) 2003 José Matos <[EMAIL PROTECTED]>
+#
+# 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
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1743
diff -u -p -r1.1743 ChangeLog
--- src/ChangeLog 10 Dec 2003 17:28:11 -0000 1.1743
+++ src/ChangeLog 10 Dec 2003 21:43:48 -0000
@@ -1,5 +1,11 @@
2003-12-10 Angus Leeming <[EMAIL PROTECTED]>
+ * buffer.C: up the format to 227.
+
+ * factory.C: the box inset is now identified simply by 'Box'.
+
+2003-12-10 Angus Leeming <[EMAIL PROTECTED]>
+
* buffer.C: up the format to 226.
* factory.C: the note inset is now identified simply by 'Note'.
Index: src/buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.549
diff -u -p -r1.549 buffer.C
--- src/buffer.C 10 Dec 2003 17:28:12 -0000 1.549
+++ src/buffer.C 10 Dec 2003 21:43:49 -0000
@@ -132,7 +132,7 @@ extern BufferList bufferlist;
namespace {
-const int LYX_FORMAT = 226;
+const int LYX_FORMAT = 227;
} // namespace anon
Index: src/factory.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/factory.C,v
retrieving revision 1.75
diff -u -p -r1.75 factory.C
--- src/factory.C 10 Dec 2003 17:28:12 -0000 1.75
+++ src/factory.C 10 Dec 2003 21:43:50 -0000
@@ -404,9 +404,7 @@ InsetOld * readInset(LyXLex & lex, Buffe
inset.reset(new InsetGraphics);
} else if (tmptok == "Note") {
inset.reset(new InsetNote(buf.params(), tmptok));
- } else if (tmptok == "Boxed" || tmptok == "ovalbox"
- || tmptok == "Shadowbox" || tmptok == "Doublebox"
- || tmptok == "Ovalbox" || tmptok == "Frameless") {
+ } else if (tmptok == "Box") {
inset.reset(new InsetBox(buf.params(), tmptok));
} else if (tmptok == "CharStyle") {
lex.next();
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.942
diff -u -p -r1.942 ChangeLog
--- src/insets/ChangeLog 10 Dec 2003 21:32:04 -0000 1.942
+++ src/insets/ChangeLog 10 Dec 2003 21:43:56 -0000
@@ -1,5 +1,12 @@
2003-12-10 Angus Leeming <[EMAIL PROTECTED]>
+ * 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 <[EMAIL PROTECTED]>
+
* insetert.C (string2params): clean-up using the new lyxlex interface.
* insetexternal.C: ensure that InsetExternalParams has a default
@@ -36,7 +43,8 @@
* 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
RotationData::OriginType enum.
Index: src/insets/insetbox.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbox.C,v
retrieving revision 1.12
diff -u -p -r1.12 insetbox.C
--- src/insets/insetbox.C 28 Nov 2003 17:13:41 -0000 1.12
+++ src/insets/insetbox.C 10 Dec 2003 21:43:57 -0000
@@ -26,6 +26,7 @@
#include "paragraph.h"
#include "support/std_sstream.h"
+#include "support/translator.h"
using std::auto_ptr;
using std::string;
@@ -37,6 +38,8 @@ using std::endl;
namespace {
+typedef Translator<std::string, InsetBox::BoxType> BoxTranslator;
+
BoxTranslator const init_boxtranslator() {
BoxTranslator translator("Boxed", InsetBox::Boxed);
translator.addPair("Frameless", InsetBox::Frameless);
@@ -418,7 +421,7 @@ string const InsetBoxMailer::params2stri
void InsetBoxMailer::string2params(string const & in,
- InsetBoxParams & params)
+ InsetBoxParams & params)
{
params = InsetBoxParams(string());
@@ -429,10 +432,20 @@ void InsetBoxMailer::string2params(strin
LyXLex lex(0,0);
lex.setStream(data);
- string token;
- lex.next();
- token = lex.getString();
- lex.next();
+ string name;
+ lex >> name;
+ if (!lex || name != name_) {
+ 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);
}
@@ -454,7 +467,7 @@ InsetBoxParams::InsetBoxParams(string co
void InsetBoxParams::write(ostream & os) const
{
- os << type << "\n";
+ os << "Box " << type << "\n";
os << "position \"" << pos << "\"\n";
os << "hor_pos \"" << hor_pos << "\"\n";
os << "has_inner_box " << inner_box << "\n";
@@ -469,13 +482,17 @@ void InsetBoxParams::write(ostream & os)
void InsetBoxParams::read(LyXLex & lex)
{
+ if (!lex.isOK())
+ return;
+
if (lex.isOK()) {
+ lex.next();
type = lex.getString();
}
- string token;
if (!lex.isOK())
return;
lex.next();
+ string token;
token = lex.getString();
if (token == "position") {
lex.next();
Index: src/insets/insetbox.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbox.h,v
retrieving revision 1.8
diff -u -p -r1.8 insetbox.h
--- src/insets/insetbox.h 10 Nov 2003 09:06:41 -0000 1.8
+++ src/insets/insetbox.h 10 Dec 2003 21:43:57 -0000
@@ -16,7 +16,6 @@
#include "insetcollapsable.h"
#include "lyxlength.h"
-#include "support/translator.h"
struct InsetBoxParams {
@@ -117,15 +116,6 @@ private:
///
InsetBoxParams params_;
};
-
-
-namespace {
-
-typedef Translator<std::string, InsetBox::BoxType> BoxTranslator;
-BoxTranslator const & boxtranslator();
-BoxTranslator const & boxtranslator_loc();
-
-} // anon
#include "mailinset.h"