merge common code

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8183 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-12-02 12:39:14 +00:00
parent 51fa9803d3
commit 5ea277209f
7 changed files with 20 additions and 25 deletions

View File

@ -839,19 +839,13 @@ bool Buffer::do_writeFile(ostream & ofs) const
<< " created this file. For more info see http://www.lyx.org/\n"
<< "\\lyxformat " << LYX_FORMAT << "\n";
// now write out the buffer paramters.
// now write out the buffer parameters.
params().writeFile(ofs);
ofs << "\\end_header\n";
Paragraph::depth_type depth = 0;
// this will write out all the paragraphs
// using recursive descent.
ParagraphList::const_iterator pit = paragraphs().begin();
ParagraphList::const_iterator pend = paragraphs().end();
for (; pit != pend; ++pit)
pit->write(*this, ofs, params(), depth);
// write the text
text().write(*this, ofs);
// Write marker that shows file is complete
ofs << "\n\\end_document" << endl;

View File

@ -52,7 +52,7 @@ InsetCaption::InsetCaption(BufferParams const & bp)
void InsetCaption::write(Buffer const & buf, ostream & os) const
{
os << "Caption\n";
writeParagraphData(buf, os);
text_.write(buf, os);
}

View File

@ -79,7 +79,7 @@ bool InsetCollapsable::insertInset(BufferView * bv, InsetOld * in)
void InsetCollapsable::write(Buffer const & buf, ostream & os) const
{
os << "collapsed " << (status_ == Collapsed ? "true" : "false") << "\n";
inset.writeParagraphData(buf, os);
inset.text_.write(buf, os);
}

View File

@ -143,18 +143,7 @@ auto_ptr<InsetBase> InsetText::clone() const
void InsetText::write(Buffer const & buf, ostream & os) const
{
os << "Text\n";
writeParagraphData(buf, os);
}
void InsetText::writeParagraphData(Buffer const & buf, ostream & os) const
{
ParagraphList::const_iterator it = paragraphs().begin();
ParagraphList::const_iterator end = paragraphs().end();
Paragraph::depth_type dth = 0;
for (; it != end; ++it) {
it->write(buf, os, buf.params(), dth);
}
text_.write(buf, os);
}

View File

@ -97,8 +97,6 @@ public:
bool toggleall = false,
bool selectall = false);
///
void writeParagraphData(Buffer const &, std::ostream &) const;
///
void setText(std::string const &, LyXFont const &);
///
void setAutoBreakRows(bool);

View File

@ -25,6 +25,8 @@
#include "insets/inset.h"
#include <iosfwd>
class Buffer;
class BufferParams;
class BufferView;
@ -389,6 +391,8 @@ public:
///
bool checkAndActivateInset(bool front);
///
void write(Buffer const & buf, std::ostream & os) const;
public:
///

View File

@ -1757,3 +1757,13 @@ void LyXText::getWord(LyXCursor & from, LyXCursor & to, word_location const loc)
to.pos(to.pos() + 1);
}
}
void LyXText::write(Buffer const & buf, std::ostream & os) const
{
ParagraphList::const_iterator pit = paragraphs().begin();
ParagraphList::const_iterator end = paragraphs().end();
Paragraph::depth_type dth = 0;
for (; pit != end; ++pit)
pit->write(buf, os, buf.params(), dth);
}