Moves idetical code from InsetText and Buffer to LyXText

Andre'

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)
Index: buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.546
diff -u -p -r1.546 buffer.C
--- buffer.C    1 Dec 2003 13:35:37 -0000       1.546
+++ buffer.C    2 Dec 2003 12:24:23 -0000
@@ -839,19 +839,13 @@ bool Buffer::do_writeFile(ostream & ofs)
            << " 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;
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.265
diff -u -p -r1.265 lyxtext.h
--- lyxtext.h   1 Dec 2003 13:35:39 -0000       1.265
+++ lyxtext.h   2 Dec 2003 12:24:23 -0000
@@ -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:
        ///
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.505
diff -u -p -r1.505 text.C
--- text.C      2 Dec 2003 07:15:40 -0000       1.505
+++ text.C      2 Dec 2003 12:24:24 -0000
@@ -1757,3 +1757,13 @@ void LyXText::getWord(LyXCursor & from, 
                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);
+}
Index: insets/insetcaption.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcaption.C,v
retrieving revision 1.51
diff -u -p -r1.51 insetcaption.C
--- insets/insetcaption.C       5 Nov 2003 12:06:07 -0000       1.51
+++ insets/insetcaption.C       2 Dec 2003 12:24:24 -0000
@@ -52,7 +52,7 @@ InsetCaption::InsetCaption(BufferParams 
 void InsetCaption::write(Buffer const & buf, ostream & os) const
 {
        os << "Caption\n";
-       writeParagraphData(buf, os);
+       text_.write(buf, os);
 }
 
 
Index: insets/insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.219
diff -u -p -r1.219 insetcollapsable.C
--- insets/insetcollapsable.C   2 Dec 2003 07:15:42 -0000       1.219
+++ insets/insetcollapsable.C   2 Dec 2003 12:24:24 -0000
@@ -79,7 +79,7 @@ bool InsetCollapsable::insertInset(Buffe
 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);
 }
 
 
Index: insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.557
diff -u -p -r1.557 insettext.C
--- insets/insettext.C  1 Dec 2003 13:35:46 -0000       1.557
+++ insets/insettext.C  2 Dec 2003 12:24:24 -0000
@@ -143,18 +143,7 @@ auto_ptr<InsetBase> InsetText::clone() c
 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);
 }
 
 
Index: insets/insettext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v
retrieving revision 1.236
diff -u -p -r1.236 insettext.h
--- insets/insettext.h  1 Dec 2003 13:35:47 -0000       1.236
+++ insets/insettext.h  2 Dec 2003 12:24:24 -0000
@@ -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);

Reply via email to