From 2400b5b919a070fefef9576323075ded6a3430d5 Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Mon, 19 Nov 2001 19:06:05 +0000 Subject: [PATCH] Fix retrun value of InsetFormula::latex git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3042 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 4 ++++ src/mathed/formula.C | 4 ++-- src/mathed/math_hullinset.C | 8 ++++---- src/mathed/math_hullinset.h | 4 ++-- src/mathed/math_mathmlstream.C | 13 ++++++++----- src/mathed/math_mathmlstream.h | 2 ++ 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 1e550b9644..45639abc52 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,7 @@ +2001-11-19 Dekel Tsur + + * math_mathmlstream.C (operator<<): Count '\n' chars + 2001-11-11 Michael A. Koziarski * math_macro.C diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 0ef83f5d8b..8ddb1a0754 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -287,7 +287,7 @@ int InsetFormula::latex(Buffer const * buf, ostream & os, bool fragil, bool) { WriteStream wi(buf, os, fragil); par_->write(wi); - return 1; + return wi.line_; } @@ -295,7 +295,7 @@ int InsetFormula::ascii(Buffer const * buf, ostream & os, int) const { WriteStream wi(buf, os, false); par_->write(wi); - return 1; + return wi.line_; } diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 17d74c1079..0431b44f11 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -269,7 +269,7 @@ void MathHullInset::validate(LaTeXFeatures & features) const } -void MathHullInset::header_write(std::ostream & os) const +void MathHullInset::header_write(WriteStream & os) const { bool n = numberedType(); @@ -321,7 +321,7 @@ void MathHullInset::header_write(std::ostream & os) const } -void MathHullInset::footer_write(std::ostream & os) const +void MathHullInset::footer_write(WriteStream & os) const { bool n = numberedType(); @@ -642,7 +642,7 @@ void MathHullInset::mutate(MathInsetTypes newtype) void MathHullInset::write(WriteStream & os) const { - header_write(os.os); + header_write(os); bool n = numberedType(); @@ -658,7 +658,7 @@ void MathHullInset::write(WriteStream & os) const os << eolString(row).c_str(); } - footer_write(os.os); + footer_write(os); } diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index d3e4dea56a..43e7d9783c 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -87,9 +87,9 @@ private: /// void validate1(LaTeXFeatures & features); /// - void header_write(std::ostream &) const; + void header_write(WriteStream &) const; /// - void footer_write(std::ostream &) const; + void footer_write(WriteStream &) const; /// void glueall(); /// diff --git a/src/mathed/math_mathmlstream.C b/src/mathed/math_mathmlstream.C index 0ea5e316da..5df3372c40 100644 --- a/src/mathed/math_mathmlstream.C +++ b/src/mathed/math_mathmlstream.C @@ -1,4 +1,3 @@ - #include "math_inset.h" #include "math_mathmlstream.h" #include "math_extern.h" @@ -184,12 +183,12 @@ NormalStream & NormalStream::operator<<(char c) WriteStream::WriteStream (Buffer const * buffer_, std::ostream & os_, bool fragile_) - : buffer(buffer_), os(os_), fragile(fragile_) + : buffer(buffer_), os(os_), fragile(fragile_), line_(0) {} WriteStream::WriteStream(std::ostream & os_) - : buffer(0), os(os_), fragile(false) + : buffer(0), os(os_), fragile(false), line_(0) {} @@ -213,6 +212,10 @@ WriteStream & WriteStream::operator<<(MathArray const & ar) WriteStream & WriteStream::operator<<(char const * s) { os << s; + for ( ; *s ; ++s) { + if (*s == '\n') + ++line_; + } return *this; } @@ -220,7 +223,7 @@ WriteStream & WriteStream::operator<<(char const * s) WriteStream & WriteStream::operator<<(char c) { os << c; + if (c == '\n') + ++line_; return *this; } - - diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h index 9382b8d524..330086fdec 100644 --- a/src/mathed/math_mathmlstream.h +++ b/src/mathed/math_mathmlstream.h @@ -124,6 +124,8 @@ struct WriteStream { bool fragile; /// are we at the beginning of an MathArray? bool firstitem; + /// + int line_; }; -- 2.39.2