]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.C
make redoParagraph more independent of current cursor
[lyx.git] / src / BufferView.C
index a71a3b01d33fdbffa6310a6f66725c86d424f842..8a7bee84b17775a0551cb9843ed534cf10371ba5 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright 1995-2002 the LyX Team
  * Read the file COPYING
  *
- * \author unknown
+ * \author Lars Gullik Bjønnes
  * \author John Levon <moz@compsoc.man.ac.uk>
  */
 
@@ -40,7 +40,6 @@
 
 #include "support/FileInfo.h"
 #include "support/filetools.h"
-#include "support/lyxfunctional.h" // equal_1st_in_pair
 #include "support/types.h"
 #include "support/lyxalgo.h" // lyx_count
 
@@ -49,6 +48,7 @@
 extern BufferList bufferlist;
 
 using lyx::pos_type;
+using namespace lyx::support;
 
 using std::pair;
 using std::endl;
@@ -103,6 +103,12 @@ void BufferView::buffer(Buffer * b)
 }
 
 
+bool BufferView::newFile(string const & fn, string const & tn, bool named)
+{
+       return pimpl_->newFile(fn, tn, named);
+}
+
+
 bool BufferView::loadLyXFile(string const & fn, bool tl)
 {
        return pimpl_->loadLyXFile(fn, tl);
@@ -119,9 +125,8 @@ void BufferView::reload()
 
 void BufferView::resize()
 {
-       if (pimpl_->buffer_) {
+       if (pimpl_->buffer_)
                pimpl_->resizeCurrentBuffer();
-       }
 }
 
 
@@ -233,12 +238,6 @@ void BufferView::toggleSelection(bool b)
 }
 
 
-void BufferView::toggleToggle()
-{
-       pimpl_->toggleToggle();
-}
-
-
 void BufferView::center()
 {
        pimpl_->center();
@@ -321,6 +320,8 @@ bool BufferView::insertLyXFile(string const & filen)
 
        bool res = true;
 
+       text->breakParagraph(buffer()->paragraphs);
+
        if (c == '#') {
                // FIXME: huh ? No we won't !
                lyxerr[Debug::INFO] << "Will insert file with header" << endl;
@@ -372,7 +373,7 @@ void BufferView::setCursorFromRow(int row)
 }
 
 
-bool BufferView::insertInset(Inset * inset, string const & lout)
+bool BufferView::insertInset(InsetOld * inset, string const & lout)
 {
        return pimpl_->insertInset(inset, lout);
 }
@@ -509,7 +510,7 @@ bool BufferView::lockInset(UpdatableInset * inset)
                if (text->cursor.pos() < text->cursor.par()->size()
                    && text->cursor.par()->getChar(text->cursor.pos()) ==
                    Paragraph::META_INSET) {
-                       Inset * in = text->cursor.par()->getInset(text->cursor.pos());
+                       InsetOld * in = text->cursor.par()->getInset(text->cursor.pos());
                        if (inset == in) {
                                theLockingInset(inset);
                                return true;
@@ -586,23 +587,13 @@ int BufferView::unlockInset(UpdatableInset * inset)
 }
 
 
-void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind)
-{
-       if (!theLockingInset())
-               return; // shouldn't happen
-       if (kind == Undo::EDIT) // in this case insets would not be stored!
-               kind = Undo::FINISH;
-       setUndo(this, kind, text->cursor.par());
-}
-
-
-void BufferView::updateInset(Inset * inset)
+void BufferView::updateInset(InsetOld * inset)
 {
        pimpl_->updateInset(inset);
 }
 
 
-bool BufferView::ChangeInsets(Inset::Code code,
+bool BufferView::ChangeInsets(InsetOld::Code code,
                              string const & from, string const & to)
 {
        bool need_update = false;
@@ -634,9 +625,8 @@ bool BufferView::ChangeInsets(Inset::Code code,
                        // How to set the cursor corretly when it.size()>1 ??
                        if (it.size() == 1) {
                                text->setCursorIntern(it.pit(), 0);
-                               text->redoParagraphs(text->cursor,
-                                                    boost::next(text->cursor.par()));
-                               text->fullRebreak();
+                               text->redoParagraph(text->cursor.par());
+                               text->partialRebreak();
                        }
                }
        }
@@ -654,22 +644,7 @@ bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
        if (lyx::count(labels.begin(), labels.end(), from) > 1)
                return false;
 
-       return ChangeInsets(Inset::REF_CODE, from, to);
-}
-
-
-bool BufferView::ChangeCitationsIfUnique(string const & from, string const & to)
-{
-       typedef pair<string, string> StringPair;
-
-       vector<StringPair> keys;
-       buffer()->fillWithBibKeys(keys);
-       if (count_if(keys.begin(), keys.end(),
-                    lyx::equal_1st_in_pair<StringPair>(from))
-           > 1)
-               return false;
-
-       return ChangeInsets(Inset::CITE_CODE, from, to);
+       return ChangeInsets(InsetOld::REF_CODE, from, to);
 }
 
 
@@ -699,7 +674,7 @@ LyXText * BufferView::getLyXText() const
 }
 
 
-LyXText * BufferView::getParentText(Inset * inset) const
+LyXText * BufferView::getParentText(InsetOld * inset) const
 {
        if (inset->owner()) {
                LyXText * txt = inset->getLyXText(this);
@@ -713,7 +688,7 @@ LyXText * BufferView::getParentText(Inset * inset) const
 }
 
 
-Language const * BufferView::getParentLanguage(Inset * inset) const
+Language const * BufferView::getParentLanguage(InsetOld * inset) const
 {
        LyXText * text = getParentText(inset);
        return text->cursor.par()->getFontSettings(buffer()->params,