#include "Exporter.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
-#include "support/gettext.h"
+#include "InsetIterator.h"
#include "LaTeXFeatures.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "support/debug.h"
#include "support/docstream.h"
+#include "support/gettext.h"
#include "support/Translator.h"
#include "frontends/Application.h"
case LFUN_INSET_MODIFY:
// disallow comment and greyed out in commands
- flag.enabled(!cur.paragraph().layout().isCommand() ||
+ flag.setEnabled(!cur.paragraph().layout().isCommand() ||
cmd.getArg(2) == "Note");
if (cmd.getArg(0) == "note") {
InsetNoteParams params;
return true;
case LFUN_INSET_DIALOG_UPDATE:
- flag.enabled(true);
+ flag.setEnabled(true);
return true;
default:
}
-void InsetNote::addToToc(ParConstIterator const & cpit) const
+void InsetNote::addToToc(DocIterator const & cpit)
{
- ParConstIterator pit = cpit;
- pit.push_back(*this);
+ DocIterator pit = cpit;
+ pit.push_back(CursorSlice(*this));
Toc & toc = buffer().tocBackend().toc("note");
docstring str;
str = notetranslator_loc().find(params_.type) + from_ascii(": ")
+ getNewLabel(str);
toc.push_back(TocItem(pit, 0, str));
+ // Proceed with the rest of the inset.
+ InsetCollapsable::addToToc(cpit);
}
params.read(lex);
}
+bool mutateNotes(Cursor & cur, string const & source, string const &target)
+{
+ InsetNoteParams::Type typeSrc = notetranslator().find(source);
+ InsetNoteParams::Type typeTrt = notetranslator().find(target);
+ // syntax check of arguments
+ string sSrc = notetranslator().find(typeSrc);
+ string sTrt = notetranslator().find(typeTrt);
+ if ((sSrc != source) || (sTrt != target))
+ return false;
+
+ // did we found some conforming inset?
+ bool ret = false;
+
+ Inset & inset = cur.buffer().inset();
+ InsetIterator it = inset_iterator_begin(inset);
+ InsetIterator const end = inset_iterator_end(inset);
+ for (; it != end; ++it) {
+ if (it->lyxCode() == NOTE_CODE) {
+ InsetNote & ins = static_cast<InsetNote &>(*it);
+ if (ins.params().type == typeSrc) {
+ FuncRequest fr(LFUN_INSET_MODIFY, "note Note " + target);
+ ins.dispatch(cur, fr);
+ ret = true;
+ }
+ }
+ }
+
+ return ret;
+}
} // namespace lyx