From 90f8bbec900a45a66101acc56a22b4ef023e59c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 11 Jan 2002 15:23:10 +0000 Subject: [PATCH] Angus: 'WriteStream::addlines' is now the only way to change 'lines_' git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3335 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_inset.h | 4 ++-- src/mathed/math_mathmlstream.C | 10 ++++++++-- src/mathed/math_mathmlstream.h | 10 +++++++--- src/mathed/math_streamstr.C | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 8f607e319f..6c14437e82 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -97,8 +97,6 @@ public: /// draw the object virtual void draw(Painter &, int x, int y) const; - /// write LaTeX and Lyx code - virtual void write(WriteStream & os) const; /// reproduce itself virtual MathInset * clone() const = 0; /// substitutes macro arguments if necessary @@ -226,6 +224,8 @@ public: /// replace things by other things virtual void replace(ReplaceData &) {} + /// write LaTeX and Lyx code + virtual void write(WriteStream & os) const; /// write normalized content virtual void normalize(NormalStream &) const; /// write content as something readable by Maple diff --git a/src/mathed/math_mathmlstream.C b/src/mathed/math_mathmlstream.C index 1f3319ba1a..8aed771f0b 100644 --- a/src/mathed/math_mathmlstream.C +++ b/src/mathed/math_mathmlstream.C @@ -195,6 +195,12 @@ WriteStream::WriteStream(std::ostream & os) {} +void WriteStream::addlines(unsigned int n) +{ + line_ += n; +} + + WriteStream & operator<<(WriteStream & ws, MathInset const * p) { if (p) @@ -215,7 +221,7 @@ WriteStream & operator<<(WriteStream & ws, MathArray const & ar) WriteStream & operator<<(WriteStream & ws, char const * s) { ws.os() << s; - ws.line() += std::count(s, s + strlen(s), '\n'); + ws.addlines(std::count(s, s + strlen(s), '\n')); return ws; } @@ -224,7 +230,7 @@ WriteStream & operator<<(WriteStream & ws, char c) { ws.os() << c; if (c == '\n') - ++ws.line(); + ws.addlines(1); return ws; } diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h index 4efd2c95e8..bdcf4751ca 100644 --- a/src/mathed/math_mathmlstream.h +++ b/src/mathed/math_mathmlstream.h @@ -39,9 +39,11 @@ public: /// std::ostream & os() { return os_; } /// - int & line() { return line_; } + int line() const { return line_; } /// int & tab() { return tab_; } + /// + friend MathMLStream & operator<<(MathMLStream &, char const *); private: /// std::ostream & os_; @@ -161,14 +163,16 @@ public: WriteStream(std::ostream & os, bool fragile); /// explicit WriteStream(std::ostream & os_); - /// yes... the references will be removed some day... - int & line() { return line_; } + /// + int line() const { return line_; } /// bool fragile() const { return fragile_; } /// std::ostream & os() { return os_; } /// bool & firstitem() { return firstitem_; } + /// + void addlines(unsigned int); private: /// std::ostream & os_; diff --git a/src/mathed/math_streamstr.C b/src/mathed/math_streamstr.C index 1675f0fe24..6e47e2b572 100644 --- a/src/mathed/math_streamstr.C +++ b/src/mathed/math_streamstr.C @@ -10,7 +10,7 @@ WriteStream & operator<<(WriteStream & ws, string const & s) { ws.os() << s; - ws.line() += std::count(s.begin(), s.end(), '\n'); + ws.addlines(std::count(s.begin(), s.end(), '\n')); return ws; }