#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::updateLabels(ParIterator const & it)
-{
- DocumentClass const & tclass = buffer().params().documentClass();
- Counters savecnt = tclass.counters();
- InsetCollapsable::updateLabels(it);
- tclass.counters() = savecnt;
-}
-
-
-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);
}
return;
istringstream data(in);
- Lexer lex(0,0);
+ Lexer lex;
lex.setStream(data);
+ lex.setContext("InsetNote::string2params");
+ lex >> "note" >> "Note";
- string name;
- lex >> name;
- if (!lex || name != "note") {
- LYXERR0("Expected arg 1 to be \"note\" in " << in);
- return;
- }
+ params.read(lex);
+}
- // This is part of the inset proper that is usually swallowed
- // by Text::readInset
- string id;
- lex >> id;
- if (!lex || id != "Note") {
- LYXERR0("Expected arg 1 to be \"Note\" in " << in);
- return;
+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;
+ }
+ }
}
- params.read(lex);
+ return ret;
}
-
} // namespace lyx