#include "insets/InsetGraphics.h"
#include "insets/InsetRef.h"
#include "insets/InsetText.h"
+#include "insets/InsetNote.h"
#include "frontends/alert.h"
#include "frontends/Application.h"
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;
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;
}
#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"
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:
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();
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);
// 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) {
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;
}
}
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