]> git.lyx.org Git - features.git/blobdiff - src/buffer.C
Introducing a number of tags parametrizing various
[features.git] / src / buffer.C
index 7f8d0b033faa87f84be29141f2049b384b1e4917..ce10f735432be8abe1ecbaf78612e02074510c01 100644 (file)
@@ -16,6 +16,7 @@
 #include "buffer_funcs.h"
 #include "bufferlist.h"
 #include "bufferparams.h"
+#include "counters.h"
 #include "Bullet.h"
 #include "Chktex.h"
 #include "debug.h"
 #include "lyxrc.h"
 #include "lyxvc.h"
 #include "messages.h"
+#include "output.h"
+#include "output_docbook.h"
+#include "output_latex.h"
+#include "output_linuxdoc.h"
 #include "paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
+#include "PosIterator.h"
 #include "sgml.h"
 #include "texrow.h"
 #include "undo.h"
@@ -127,19 +133,6 @@ namespace {
 
 const int LYX_FORMAT = 225;
 
-bool openFileWrite(ofstream & ofs, string const & fname)
-{
-       ofs.open(fname.c_str());
-       if (!ofs) {
-               string const file = MakeDisplayPath(fname, 50);
-               string text = bformat(_("Could not open the specified "
-                                       "document\n%1$s."), file);
-               Alert::error(_("Could not open file"), text);
-               return false;
-       }
-       return true;
-}
-
 } // namespace anon
 
 
@@ -883,36 +876,15 @@ bool Buffer::do_writeFile(ostream & ofs) const
 }
 
 
-void Buffer::writeFileAscii(string const & fname, LatexRunParams const & runparams)
-{
-       ofstream ofs;
-       if (!::openFileWrite(ofs, fname))
-               return;
-       writeFileAscii(ofs, runparams);
-}
-
-
-void Buffer::writeFileAscii(ostream & os, LatexRunParams const & runparams)
-{
-       ParagraphList::iterator beg = paragraphs().begin();
-       ParagraphList::iterator end = paragraphs().end();
-       ParagraphList::iterator it = beg;
-       for (; it != end; ++it) {
-               asciiParagraph(*this, *it, os, runparams, it == beg);
-       }
-       os << "\n";
-}
-
-
 void Buffer::makeLaTeXFile(string const & fname,
                           string const & original_path,
-                          LatexRunParams const & runparams,
+                          OutputParams const & runparams,
                           bool output_preamble, bool output_body)
 {
        lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
 
        ofstream ofs;
-       if (!::openFileWrite(ofs, fname))
+       if (!openFileWrite(ofs, fname))
                return;
 
        makeLaTeXFile(ofs, original_path,
@@ -927,10 +899,10 @@ void Buffer::makeLaTeXFile(string const & fname,
 
 void Buffer::makeLaTeXFile(ostream & os,
                           string const & original_path,
-                          LatexRunParams const & runparams_in,
+                          OutputParams const & runparams_in,
                           bool output_preamble, bool output_body)
 {
-       LatexRunParams runparams = runparams_in;
+       OutputParams runparams = runparams_in;
        niceFile() = runparams.nice; // this will be used by Insetincludes.
 
        // validate the buffer.
@@ -1067,11 +1039,11 @@ bool Buffer::isSGML() const
 
 
 void Buffer::makeLinuxDocFile(string const & fname,
-                             LatexRunParams const & runparams,
+                             OutputParams const & runparams,
                              bool body_only )
 {
        ofstream ofs;
-       if (!::openFileWrite(ofs, fname))
+       if (!openFileWrite(ofs, fname))
                return;
 
        niceFile() = runparams.nice; // this will be used by included files.
@@ -1130,11 +1102,11 @@ void Buffer::makeLinuxDocFile(string const & fname,
 
 
 void Buffer::makeDocBookFile(string const & fname,
-                            LatexRunParams const & runparams,
+                            OutputParams const & runparams,
                             bool only_body)
 {
        ofstream ofs;
-       if (!::openFileWrite(ofs, fname))
+       if (!openFileWrite(ofs, fname))
                return;
 
        niceFile() = runparams.nice; // this will be used by Insetincludes.
@@ -1177,6 +1149,7 @@ void Buffer::makeDocBookFile(string const & fname,
        ofs << "<!-- DocBook file was created by LyX " << lyx_version
            << "\n  See http://www.lyx.org/ for more information -->\n";
 
+       params().getLyXTextClass().counters().reset();
        docbookParagraphs(*this, paragraphs(), ofs, runparams);
 
        ofs << "\n\n";
@@ -1209,8 +1182,8 @@ int Buffer::runChktex()
        message(_("Running chktex..."));
 
        // Generate the LaTeX file if neccessary
-       LatexRunParams runparams;
-       runparams.flavor = LatexRunParams::LATEX;
+       OutputParams runparams;
+       runparams.flavor = OutputParams::LATEX;
        runparams.nice = false;
        makeLaTeXFile(name, org_path, runparams);
 
@@ -1417,21 +1390,6 @@ void Buffer::inset_iterator::setParagraph()
 }
 
 
-InsetOld * Buffer::getInsetFromID(int id_arg) const
-{
-       for (inset_iterator it = inset_const_iterator_begin();
-                it != inset_const_iterator_end(); ++it)
-       {
-               if (it->id() == id_arg)
-                       return &(*it);
-               InsetOld * in = it->getInsetFromID(id_arg);
-               if (in)
-                       return in;
-       }
-       return 0;
-}
-
-
 ParIterator Buffer::getParFromID(int id) const
 {
 #warning FIXME: const correctness! (Andre)
@@ -1472,6 +1430,18 @@ bool Buffer::hasParWithID(int id) const
 }
 
 
+PosIterator Buffer::pos_iterator_begin()
+{
+       return PosIterator(&paragraphs(), paragraphs().begin(), 0);
+}
+
+
+PosIterator Buffer::pos_iterator_end()
+{
+       return PosIterator(&paragraphs(), paragraphs().end(), 0);
+}
+
+
 ParIterator Buffer::par_iterator_begin()
 {
        return ParIterator(paragraphs().begin(), paragraphs());