]> git.lyx.org Git - features.git/blobdiff - src/mathed/InsetMathRef.cpp
s/updateLabels/updateBuffer/g, per a suggestion of Abdel's.
[features.git] / src / mathed / InsetMathRef.cpp
index 9df6eaa04dd1fa9ba437593bed1094ed12e2815c..859845faaa2cccc4d4266c5278a2255096b9ba90 100644 (file)
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
-#include "LyXFunc.h"
+#include "LyX.h"
 #include "MathData.h"
 #include "MathFactory.h"
 #include "MathSupport.h"
 #include "OutputParams.h"
+#include "ParIterator.h"
 #include "sgml.h"
 
 #include "insets/InsetCommand.h"
@@ -175,6 +176,17 @@ int InsetMathRef::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
+void InsetMathRef::updateBuffer(ParIterator const & it, UpdateType /*utype*/)
+{
+       if (!buffer_) {
+               LYXERR0("InsetMathRef::updateBuffer: no buffer_!");
+               return;
+       }
+       // register this inset into the buffer reference cache.
+       buffer().references(getTarget()).push_back(make_pair(this, it));
+}
+
+
 string const InsetMathRef::createDialogStr(string const & name) const
 {
        InsetCommandParams icp(REF_CODE, to_ascii(commandname()));
@@ -185,6 +197,29 @@ string const InsetMathRef::createDialogStr(string const & name) const
 }
 
 
+docstring const InsetMathRef::getTarget() const
+{
+       return asString(cell(0));
+}
+
+
+void InsetMathRef::changeTarget(docstring const & target)
+{
+       InsetCommandParams icp(REF_CODE, to_ascii(commandname()));
+       icp["reference"] = target;
+       if (!cell(1).empty())
+               icp["name"] = asString(cell(1));
+       MathData ar;
+       Buffer & buf = buffer();
+       if (createInsetMath_fromDialogStr(
+           from_utf8(InsetCommand::params2string("ref", icp)), ar)) {
+               *this = *ar[0].nucleus()->asRefInset();
+               // FIXME audit setBuffer/updateBuffer calls
+               setBuffer(buf);
+       }
+}
+
+
 InsetMathRef::ref_type_info InsetMathRef::types[] = {
        { from_ascii("ref"),       from_ascii(N_("Standard[[mathref]]")),   from_ascii(N_("Ref: "))},
        { from_ascii("eqref"),     from_ascii(N_("Equation")),              from_ascii(N_("EqRef: "))},