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
This commit is contained in:
André Pönitz 2002-01-11 15:23:10 +00:00
parent 9a7ba0c534
commit 90f8bbec90
4 changed files with 18 additions and 8 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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_;

View File

@ -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;
}