]> git.lyx.org Git - features.git/commitdiff
Move LFUN_NOTES_MUTATE dispatch to BufferView.
authorPavel Sanda <sanda@lyx.org>
Tue, 24 Jun 2008 07:18:06 +0000 (07:18 +0000)
committerPavel Sanda <sanda@lyx.org>
Tue, 24 Jun 2008 07:18:06 +0000 (07:18 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25368 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/LyXFunc.cpp
src/insets/InsetNote.cpp
src/insets/InsetNote.h

index 8998405e847b320d85710b158bbf62dc20fdd7b6..71bed740c5448f462c04253bb314dde78c442b6b 100644 (file)
@@ -59,6 +59,7 @@
 #include "insets/InsetGraphics.h"
 #include "insets/InsetRef.h"
 #include "insets/InsetText.h"
+#include "insets/InsetNote.h"
 
 #include "frontends/alert.h"
 #include "frontends/Application.h"
@@ -864,6 +865,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
        case LFUN_SCREEN_RECENTER:
        case LFUN_BIBTEX_DATABASE_ADD:
        case LFUN_BIBTEX_DATABASE_DEL:
+       case LFUN_NOTES_MUTATE:
        case LFUN_STATISTICS:
                flag.setEnabled(true);
                break;
@@ -1401,6 +1403,19 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                processUpdateFlags(Update::Force);
                break;
 
+       // Could be rewriten using some command like forall <insetname> <command>
+       // once the insets refactoring is done.
+       case LFUN_NOTES_MUTATE: {
+               if (cmd.argument().empty())
+                       break;
+               cur.recordUndoFullDocument();
+
+               if (mutateNotes(cur, cmd.getArg(0), cmd.getArg(1))) {
+                       processUpdateFlags(Update::Force);
+               }
+               break;
+       }
+
        default:
                return false;
        }
index 03f87ff2b255b479b4eb7bbb2d4db277ae3ceda8..af78edef979187005626820a1113f487fcf9d10a 100644 (file)
@@ -65,7 +65,6 @@
 #include "insets/InsetListings.h"
 #include "insets/InsetGraphics.h"
 #include "insets/InsetInclude.h"
-#include "insets/InsetNote.h"
 #include "insets/InsetSpace.h"
 #include "insets/InsetTabular.h"
 #include "insets/InsetVSpace.h"
@@ -583,7 +582,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_INSET_EDIT:
        case LFUN_ALL_INSETS_TOGGLE:
        case LFUN_GRAPHICS_GROUPS_UNIFY:
-       case LFUN_NOTES_MUTATE:
        case LFUN_BUFFER_LANGUAGE:
        case LFUN_TEXTCLASS_APPLY:
        case LFUN_TEXTCLASS_LOAD:
@@ -1416,22 +1414,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        break;
                }
 
-               // BOTH GRAPHICS_GROUPS_UNIFY and NOTES_MUTATE should be in Buffer dispatch once
-               // view->cursor() is not needed.
-               // Also they could be rewriten using some command like forall <insetname> <command>
-               // once the insets refactoring is done.
-               case LFUN_NOTES_MUTATE: {
-                       LASSERT(lyx_view_ && lyx_view_->view(), /**/);
-                       if (argument.empty())
-                               break;
-                       view()->cursor().recordUndoFullDocument();
-
-                       if (mutateNotes(view(), cmd.getArg(0), cmd.getArg(1))) {
-                               updateFlags = Update::Force;
-                       }
-                       break;
-               }
-
                case LFUN_BUFFER_LANGUAGE: {
                        LASSERT(lyx_view_, /**/);
                        Buffer & buffer = *lyx_view_->buffer();
index 14701429bfa11001026abdce7df43e61392bfc0b..70278a9794a0156edd76e3040bd2f6591d4b7c3e 100644 (file)
@@ -370,7 +370,7 @@ void InsetNote::string2params(string const & in, InsetNoteParams & params)
        params.read(lex);
 }
 
-bool mutateNotes(lyx::BufferView * view, string const & source, string const &target)
+bool mutateNotes(Cursor & cur, string const & source, string const &target)
 {
        InsetNoteParams::Type typeSrc = notetranslator().find(source);
        InsetNoteParams::Type typeTrt = notetranslator().find(target);
@@ -383,7 +383,7 @@ bool mutateNotes(lyx::BufferView * view, string const & source, string const &ta
        // did we found some conforming inset?
        bool ret = false;
 
-       Inset & inset = view->buffer().inset();
+       Inset & inset = cur.buffer().inset();
        InsetIterator it  = inset_iterator_begin(inset);
        InsetIterator const end = inset_iterator_end(inset);
        for (; it != end; ++it) {
@@ -391,7 +391,7 @@ bool mutateNotes(lyx::BufferView * view, string const & source, string const &ta
                        InsetNote & ins = static_cast<InsetNote &>(*it);
                        if (ins.params().type == typeSrc) {
                                FuncRequest fr(LFUN_INSET_MODIFY, "note Note " + target);
-                               ins.dispatch(view->cursor(), fr);
+                               ins.dispatch(cur, fr);
                                ret = true;
                        }
                }
index 70faf4c03df691be7fe3c2b8d8682684eaaba266..2f3fe51ae7ab92b28cc4f8619aeec1aebeaedfe2 100644 (file)
@@ -111,13 +111,11 @@ private:
        InsetNoteParams params_;
 };
 
-class BufferView;
-
 /**
  * Mutate all NoteInsets of "source" type to the "target" type in the document.
  * Returns true when some inset was changed.
  */
-bool mutateNotes(lyx::BufferView * view, std::string const & source, std::string const &target);
+bool mutateNotes(lyx::Cursor & cur, std::string const & source, std::string const &target);
 
 } // namespace lyx