]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
"Inter-word Space"
[lyx.git] / src / BufferView_pimpl.C
index bb611da49130763c1f3a3f020c5368c70c3a1f5b..d167010f8ed9f39a8cbb46a3863c64f421d6eff5 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "BufferView_pimpl.h"
 #include "bufferlist.h"
+#include "buffer.h"
 #include "bufferview_funcs.h"
 #include "lfuns.h"
 #include "debug.h"
@@ -53,7 +54,7 @@
 #include "graphics/Previews.h"
 
 #include "support/LAssert.h"
-#include "support/lstrings.h"
+#include "support/tostr.h"
 #include "support/filetools.h"
 
 #include <boost/bind.hpp>
@@ -259,9 +260,9 @@ int BufferView::Pimpl::resizeCurrentBuffer()
 {
        lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
 
-       Paragraph * par = 0;
-       Paragraph * selstartpar = 0;
-       Paragraph * selendpar = 0;
+       ParagraphList::iterator par;
+       ParagraphList::iterator selstartpar;
+       ParagraphList::iterator selendpar;
        UpdatableInset * the_locking_inset = 0;
 
        pos_type pos = 0;
@@ -275,11 +276,11 @@ int BufferView::Pimpl::resizeCurrentBuffer()
        owner_->message(_("Formatting document..."));
 
        if (bv_->text) {
-               par = &*bv_->text->cursor.par();
+               par = bv_->text->cursor.par();
                pos = bv_->text->cursor.pos();
-               selstartpar = &*bv_->text->selection.start.par();
+               selstartpar = bv_->text->selection.start.par();
                selstartpos = bv_->text->selection.start.pos();
-               selendpar = &*bv_->text->selection.end.par();
+               selendpar = bv_->text->selection.end.par();
                selendpos = bv_->text->selection.end.pos();
                selection = bv_->text->selection.set();
                mark_set = bv_->text->selection.mark();
@@ -310,9 +311,13 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                        bv_->text->init(bv_);
                        //buffer_->resizeInsets(bv_);
                }
+
+               par = bv_->text->ownerParagraphs().end();
+               selstartpar = bv_->text->ownerParagraphs().end();
+               selendpar = bv_->text->ownerParagraphs().end();
        }
 
-       if (par) {
+       if (par != bv_->text->ownerParagraphs().end()) {
                bv_->text->selection.set(true);
                // At this point just to avoid the Delete-Empty-Paragraph-
                // Mechanism when setting the cursor.
@@ -642,12 +647,12 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
                if (b != 0) buffer(b);
        }
 
-       Paragraph * par = &*buffer_->getParFromID(saved_positions[i].par_id);
-       if (!par)
+       ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
+       if (par == buffer_->par_iterator_end())
                return;
 
-       bv_->text->setCursor(par,
-                            min(par->size(), saved_positions[i].par_pos));
+       bv_->text->setCursor(*par,
+                            min((*par)->size(), saved_positions[i].par_pos));
 
        update(BufferView::SELECT);
        if (i > 0)
@@ -842,9 +847,9 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
        string const disp_fn = MakeDisplayPath(filename);
        owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
        bool const res = bv_->insertLyXFile(filename);
-       if (res) 
+       if (res)
                owner_->message(bformat(_("Document %1$s inserted."), disp_fn));
-       else 
+       else
                owner_->message(bformat(_("Could not insert document %1$s"), disp_fn));
 }