* src/mathed/InsetMath.C: plaintext(): assert that this

method is never invoked (and tell why)
	* src/mathed/InsetMathFormulaMacro.C:
	* src/mathed/InsetMathHull.C: plaintext(): fix return value
	(= number of output characters)
	* src/mathed/InsetMathFormulaMacro.h
	* src/mathed/InsetMathHull.h: WS changes
	* src/mathed/InsetMathDim.C: implement plaintext() for math macros
	and add a FIXME that this code shouldn't needed!


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17319 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Michael Schmitt 2007-02-24 15:06:04 +00:00
parent 74aced7791
commit 597d0e2146
6 changed files with 34 additions and 19 deletions

View File

@ -79,7 +79,7 @@ void InsetFormulaMacro::write(Buffer const &, ostream & os) const
int InsetFormulaMacro::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
OutputParams const & runparams) const
{
//lyxerr << "InsetFormulaMacro::latex" << endl;
WriteStream wi(os, runparams.moving_arg, true);
@ -89,16 +89,20 @@ int InsetFormulaMacro::latex(Buffer const &, odocstream & os,
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 const str = oss.str();
os << str;
return str.size();
}
int InsetFormulaMacro::docbook(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
OutputParams const & runparams) const
{
return plaintext(buf, os, runparams);
}

View File

@ -44,14 +44,14 @@ public:
///
void write(Buffer const &, std::ostream & os) const;
///
int plaintext(Buffer const &, odocstream &,
OutputParams const &) const;
///
int latex(Buffer const &, odocstream & os,
OutputParams const &) const;
OutputParams const &) const;
///
int plaintext(Buffer const &, odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, odocstream &,
OutputParams const &) const;
OutputParams const &) const;
///
std::auto_ptr<InsetBase> clone() const;

View File

@ -85,9 +85,9 @@ void InsetMath::write(WriteStream & os) const
int InsetMath::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
docstring str = _("math");
os << "[" << str << "]";
return 2 + str.size();
// all math plain text output shall take place in InsetMathHull
BOOST_ASSERT(false);
return 0;
}

View File

@ -12,6 +12,7 @@
#ifndef MATH_DIMINSET_H
#define MATH_DIMINSET_H
#include <boost/assert.hpp>
#include "InsetMath.h"
namespace lyx {
@ -36,6 +37,12 @@ public:
///
void setPosCache(PainterInfo const & pi, int x, int y) const;
///
int plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{ // FIXME: math macros are output here but
// should be handled in InsetMathHull
os << "[math macro]"; return 12; }
};

View File

@ -1433,7 +1433,7 @@ void InsetMathHull::read(Buffer const &, LyXLex & lex)
int InsetMathHull::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
OutputParams const &) const
{
if (0 && display()) {
Dimension dim;
@ -1446,15 +1446,19 @@ int InsetMathHull::plaintext(Buffer const &, odocstream & os,
//metrics();
return tpain.textheight();
} else {
WriteStream wi(os, false, true);
odocstringstream oss;
WriteStream wi(oss, false, true);
wi << cell(0);
return wi.line();
docstring const 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;

View File

@ -104,10 +104,10 @@ public:
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;