Georg,
it turned out that InsetMathHull is not the only place where plaintext()
is needed. Math macros are output in - surprise, surprise -
InsetMathDim. Does this make sense to you?
I am tempted to commit the following patch (with a slightly improved
plaintext() in InsetMathDim.C).
Any comments? I have no idea about all this mathed stuff...
Michael
Index: InsetMathNumber.h
===================================================================
--- InsetMathNumber.h (Revision 17306)
+++ InsetMathNumber.h (Arbeitskopie)
@@ -12,6 +12,7 @@
#ifndef MATH_NUMBERINSET_H
#define MATH_NUMBERINSET_H
+#include <boost/assert.hpp>
#include "InsetMath.h"
@@ -33,8 +34,11 @@
docstring str() const { return str_; }
///
InsetMathNumber * asNumberInset() { return this; }
-
///
+ int plaintext(Buffer const &, odocstream &,
+ OutputParams const &) const
+ { BOOST_ASSERT(false); return 0; }
+ ///
void normalize(NormalStream &) const;
///
void octave(OctaveStream &) const;
Index: InsetMathKern.h
===================================================================
--- InsetMathKern.h (Revision 17306)
+++ InsetMathKern.h (Arbeitskopie)
@@ -12,6 +12,7 @@
#ifndef MATH_CHEATINSET_H
#define MATH_CHEATINSET_H
+#include <boost/assert.hpp>
#include "InsetMath.h"
#include "lyxlength.h"
@@ -37,6 +38,10 @@
///
void write(WriteStream & os) const;
///
+ int plaintext(Buffer const &, odocstream &,
+ OutputParams const &) const
+ { BOOST_ASSERT(false); return 0; }
+ ///
void normalize(NormalStream & ns) const;
///
int width() const;
Index: InsetMathChar.h
===================================================================
--- InsetMathChar.h (Revision 17306)
+++ InsetMathChar.h (Arbeitskopie)
@@ -12,6 +12,7 @@
#ifndef MATH_CHARINSET_H
#define MATH_CHARINSET_H
+#include <boost/assert.hpp>
#include "InsetMath.h"
@@ -36,6 +37,10 @@
///
void write(WriteStream & os) const;
///
+ int plaintext(Buffer const &, odocstream &,
+ OutputParams const &) const
+ { BOOST_ASSERT(false); return 0; }
+ ///
void normalize(NormalStream & ns) const;
///
void octave(OctaveStream & os) const;
Index: InsetMath.C
===================================================================
--- InsetMath.C (Revision 17306)
+++ InsetMath.C (Arbeitskopie)
@@ -82,15 +82,6 @@
}
-int InsetMath::plaintext(Buffer const &, odocstream & os,
- OutputParams const &) const
-{
- docstring str = _("math");
- os << "[" << str << "]";
- return 2 + str.size();
-}
-
-
void InsetMath::normalize(NormalStream & os) const
{
os << '[' << name() << "] ";
Index: InsetMathHull.C
===================================================================
--- InsetMathHull.C (Revision 17306)
+++ InsetMathHull.C (Arbeitskopie)
@@ -1433,7 +1433,7 @@
int InsetMathHull::plaintext(Buffer const &, odocstream & os,
- OutputParams const &) const
+ OutputParams const &) const
{
if (0 && display()) {
Dimension dim;
@@ -1446,15 +1446,19 @@
//metrics();
return tpain.textheight();
} else {
- WriteStream wi(os, false, true);
+ odocstringstream oss;
+ WriteStream wi(oss, false, true);
wi << cell(0);
- return wi.line();
+
+ docstring str = oss.str();
+ os << str;
+ return str.size();
}
}
int InsetMathHull::docbook(Buffer const & buf, odocstream & os,
- OutputParams const & runparams) const
+ OutputParams const & runparams) const
{
MathStream ms(os);
int res = 0;
Index: InsetMath.h
===================================================================
--- InsetMath.h (Revision 17306)
+++ InsetMath.h (Arbeitskopie)
@@ -182,10 +182,6 @@
/// write content as something readable by Octave
virtual void octave(OctaveStream &) const;
- /// plain text output in ucs4 encoding
- int plaintext(Buffer const &, odocstream &,
- OutputParams const &) const;
-
/// dump content to stderr for debugging
virtual void dump() const;
Index: InsetMathHull.h
===================================================================
--- InsetMathHull.h (Revision 17306)
+++ InsetMathHull.h (Arbeitskopie)
@@ -104,10 +104,10 @@
void read(Buffer const &, LyXLex & lex);
///
int plaintext(Buffer const &, odocstream &,
- OutputParams const &) const;
+ OutputParams const &) const;
///
int docbook(Buffer const &, odocstream &,
- OutputParams const &) const;
+ OutputParams const &) const;
/// the string that is passed to the TOC
virtual void textString(Buffer const &, odocstream &) const;
Index: InsetFormulaMacro.C
===================================================================
--- InsetFormulaMacro.C (Revision 17306)
+++ InsetFormulaMacro.C (Arbeitskopie)
@@ -89,11 +89,15 @@
int InsetFormulaMacro::plaintext(Buffer const &, odocstream & os,
- OutputParams const &) const
+ OutputParams const &) const
{
- WriteStream wi(os, false, true);
+ odocstringstream oss;
+ WriteStream wi(oss, false, true);
tmpl()->write(wi);
- return 0;
+
+ docstring str = oss.str();
+ os << str;
+ return str.size();
}
Index: InsetMathSpace.h
===================================================================
--- InsetMathSpace.h (Revision 17306)
+++ InsetMathSpace.h (Arbeitskopie)
@@ -12,6 +12,7 @@
#ifndef MATH_SPACEINSET_H
#define MATH_SPACEINSET_H
+#include <boost/assert.hpp>
#include "InsetMath.h"
@@ -41,8 +42,11 @@
bool metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
-
///
+ int plaintext(Buffer const &, odocstream &,
+ OutputParams const &) const
+ { BOOST_ASSERT(false); return 0; }
+ ///
void normalize(NormalStream &) const;
///
void validate(LaTeXFeatures & features) const;
Index: InsetFormulaMacro.h
===================================================================
--- InsetFormulaMacro.h (Revision 17306)
+++ InsetFormulaMacro.h (Arbeitskopie)
@@ -44,14 +44,14 @@
///
void write(Buffer const &, std::ostream & os) const;
///
+ int latex(Buffer const &, odocstream & os,
+ OutputParams const &) const;
+ ///
int plaintext(Buffer const &, odocstream &,
- OutputParams const &) const;
+ OutputParams const &) const;
///
- int latex(Buffer const &, odocstream & os,
- OutputParams const &) const;
- ///
int docbook(Buffer const &, odocstream &,
- OutputParams const &) const;
+ OutputParams const &) const;
///
std::auto_ptr<InsetBase> clone() const;
Index: InsetMathSymbol.h
===================================================================
--- InsetMathSymbol.h (Revision 17306)
+++ InsetMathSymbol.h (Arbeitskopie)
@@ -12,6 +12,7 @@
#ifndef MATH_SYMBOLINSET_H
#define MATH_SYMBOLINSET_H
+#include <boost/assert.hpp>
#include "InsetMath.h"
@@ -50,8 +51,11 @@
docstring name() const;
/// request "external features"
void validate(LaTeXFeatures & features) const;
-
///
+ int plaintext(Buffer const &, odocstream &,
+ OutputParams const &) const
+ { BOOST_ASSERT(false); return 0; }
+ ///
void normalize(NormalStream &) const;
///
void maple(MapleStream &) const;
Index: InsetMathString.h
===================================================================
--- InsetMathString.h (Revision 17306)
+++ InsetMathString.h (Arbeitskopie)
@@ -12,6 +12,7 @@
#ifndef MATH_STRINGINSET_H
#define MATH_STRINGINSET_H
+#include <boost/assert.hpp>
#include "InsetMath.h"
@@ -35,8 +36,11 @@
InsetMathString * asStringInset() { return this; }
///
InsetMathString const * asStringInset() const { return this; }
-
///
+ int plaintext(Buffer const &, odocstream &,
+ OutputParams const &) const
+ { BOOST_ASSERT(false); return 0; }
+ ///
void normalize(NormalStream &) const;
///
void octave(OctaveStream &) const;
Index: InsetMathDim.h
===================================================================
--- InsetMathDim.h (Revision 17306)
+++ InsetMathDim.h (Arbeitskopie)
@@ -12,6 +12,7 @@
#ifndef MATH_DIMINSET_H
#define MATH_DIMINSET_H
+#include <boost/assert.hpp>
#include "InsetMath.h"
namespace lyx {
@@ -36,6 +37,10 @@
///
void setPosCache(PainterInfo const & pi, int x, int y) const;
+ ///
+ int plaintext(Buffer const &, odocstream & os,
+ OutputParams const &) const
+ { os << "[math]"; return 6; }
};