From 597d0e2146c5756c18ba3f9c37d9ff7aa0ec47a6 Mon Sep 17 00:00:00 2001 From: Michael Schmitt Date: Sat, 24 Feb 2007 15:06:04 +0000 Subject: [PATCH] * 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 --- src/mathed/InsetFormulaMacro.C | 14 +++++++++----- src/mathed/InsetFormulaMacro.h | 10 +++++----- src/mathed/InsetMath.C | 6 +++--- src/mathed/InsetMathDim.h | 7 +++++++ src/mathed/InsetMathHull.C | 12 ++++++++---- src/mathed/InsetMathHull.h | 4 ++-- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/mathed/InsetFormulaMacro.C b/src/mathed/InsetFormulaMacro.C index fed292047b..3020b2c824 100644 --- a/src/mathed/InsetFormulaMacro.C +++ b/src/mathed/InsetFormulaMacro.C @@ -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); } diff --git a/src/mathed/InsetFormulaMacro.h b/src/mathed/InsetFormulaMacro.h index b32bd033c6..ecb73960c3 100644 --- a/src/mathed/InsetFormulaMacro.h +++ b/src/mathed/InsetFormulaMacro.h @@ -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 clone() const; diff --git a/src/mathed/InsetMath.C b/src/mathed/InsetMath.C index c88d0e3659..9b203d2f59 100644 --- a/src/mathed/InsetMath.C +++ b/src/mathed/InsetMath.C @@ -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; } diff --git a/src/mathed/InsetMathDim.h b/src/mathed/InsetMathDim.h index 30f13eb20f..59773c0310 100644 --- a/src/mathed/InsetMathDim.h +++ b/src/mathed/InsetMathDim.h @@ -12,6 +12,7 @@ #ifndef MATH_DIMINSET_H #define MATH_DIMINSET_H +#include #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; } }; diff --git a/src/mathed/InsetMathHull.C b/src/mathed/InsetMathHull.C index 09ac010b27..17887b681c 100644 --- a/src/mathed/InsetMathHull.C +++ b/src/mathed/InsetMathHull.C @@ -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; diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index daef652c25..b36c09c455 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -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;