From: André Pönitz Date: Tue, 2 Dec 2003 12:39:14 +0000 (+0000) Subject: merge common code X-Git-Tag: 1.6.10~15704 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5ea277209f9caa40798e71ef0545f55af9466ff8;p=features.git merge common code git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8183 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/buffer.C b/src/buffer.C index 96d5cc2519..d159f09568 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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; diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index 132af638fc..2b4d0bf7a0 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -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); } diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 285d8f4ae3..9f8cac0f42 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -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); } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index b1b61522ea..428533bbca 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -143,18 +143,7 @@ auto_ptr 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); } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 8085e615e3..46708539d0 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -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); diff --git a/src/lyxtext.h b/src/lyxtext.h index bf27dc44f9..d70eb49ea8 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -25,6 +25,8 @@ #include "insets/inset.h" +#include + 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: /// diff --git a/src/text.C b/src/text.C index 7b206d8ba9..a474fb7536 100644 --- a/src/text.C +++ b/src/text.C @@ -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); +}