]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
don't rm emergency saves ever
[lyx.git] / src / buffer.C
index 3e1841f0e39e2799afde65f34200f37be0277b99..731e538c1c756f3e3345ebea7db34efdbd7a957a 100644 (file)
@@ -1037,7 +1037,7 @@ void Buffer::makeLaTeXFile(ostream & os,
        texrow.reset();
        // The starting paragraph of the coming rows is the
        // first paragraph of the document. (Asger)
-       texrow.start(&*(paragraphs.begin()), 0);
+       texrow.start(paragraphs.begin()->id(), 0);
 
        if (!only_body && nice) {
                os << "%% " << lyx_docversion << " created this file.  "
@@ -1319,7 +1319,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                        break;
                }
 
-               simpleLinuxDocOnePar(ofs, &*pit, depth);
+               simpleLinuxDocOnePar(ofs, pit, depth);
 
                ofs << "\n";
                // write closing SGML tags
@@ -1412,8 +1412,8 @@ void reset(PAR_TAG & p1, PAR_TAG const & p2)
 
 // Handle internal paragraph parsing -- layout already processed.
 void Buffer::simpleLinuxDocOnePar(ostream & os,
-       Paragraph * par,
-       Paragraph::depth_type /*depth*/)
+       ParagraphList::iterator par,
+       Paragraph::depth_type /*depth*/) const
 {
        LyXLayout_ptr const & style = par->layout();
 
@@ -2293,6 +2293,25 @@ ParagraphList::iterator Buffer::getParFromID(int id) const
 }
 
 
+bool Buffer::hasParWithID(int id) const
+{
+       ParIterator it(const_cast<Buffer*>(this)->par_iterator_begin());
+       ParIterator end(const_cast<Buffer*>(this)->par_iterator_end());
+
+       if (id < 0) {
+               // John says this is called with id == -1 from undo
+               lyxerr << "hasParWithID(), id: " << id << endl;
+               return 0;
+       }
+
+       for (; it != end; ++it)
+               if ((*it)->id() == id)
+                       return true;
+
+       return false;
+}
+
+
 ParIterator Buffer::par_iterator_begin()
 {
        return ParIterator(&*(paragraphs.begin()));
@@ -2479,9 +2498,9 @@ Buffer::inset_iterator::pointer Buffer::inset_iterator::operator->()
 }
 
 
-Paragraph * Buffer::inset_iterator::getPar()
+ParagraphList::iterator Buffer::inset_iterator::getPar() const
 {
-       return &(*pit);
+       return pit;
 }