From 397afb607f9e6c9dcf9f8f904ef286ce46a96345 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Tue, 24 Jun 2008 07:18:06 +0000 Subject: [PATCH] Move LFUN_NOTES_MUTATE dispatch to BufferView. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25368 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 15 +++++++++++++++ src/LyXFunc.cpp | 18 ------------------ src/insets/InsetNote.cpp | 6 +++--- src/insets/InsetNote.h | 4 +--- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 8998405e84..71bed740c5 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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 + // 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; } diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 03f87ff2b2..af78edef97 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -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 - // 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(); diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 14701429bf..70278a9794 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -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(*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; } } diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index 70faf4c03d..2f3fe51ae7 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -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 -- 2.39.2