]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetNote.cpp
Move isMultiCell() to Cursor, and use it.
[lyx.git] / src / insets / InsetNote.cpp
index c44d637a56ca55a1e2ba718ebca2233f71a52d80..70278a9794a0156edd76e3040bd2f6591d4b7c3e 100644 (file)
@@ -24,7 +24,7 @@
 #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"
@@ -35,6 +35,7 @@
 
 #include "support/debug.h"
 #include "support/docstream.h"
+#include "support/gettext.h"
 #include "support/Translator.h"
 
 #include "frontends/Application.h"
@@ -231,6 +232,8 @@ void InsetNote::addToToc(DocIterator const & cpit)
        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);
 }
 
 
@@ -367,5 +370,34 @@ void InsetNote::string2params(string const & in, InsetNoteParams & params)
        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