* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author André Pönitz
+ * \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include "InsetMathRef.h"
#include "BufferView.h"
-#include "LaTeXFeatures.h"
#include "Buffer.h"
#include "Cursor.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
+#include "LaTeXFeatures.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"
namespace lyx {
-InsetMathRef::InsetMathRef()
- : CommandInset(from_ascii("ref"))
+InsetMathRef::InsetMathRef(Buffer * buf)
+ : CommandInset(buf, from_ascii("ref"), false)
{}
-InsetMathRef::InsetMathRef(docstring const & data)
- : CommandInset(data)
+InsetMathRef::InsetMathRef(Buffer * buf, docstring const & data)
+ : CommandInset(buf, data, false)
{}
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3) {
LYXERR0("trying to goto ref '" << to_utf8(asString(cell(0))) << "'");
- cur.bv().dispatch(FuncRequest(LFUN_LABEL_GOTO, asString(cell(0))));
+ //FIXME: use DispatchResult argument
+ lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, asString(cell(0))));
break;
}
if (cmd.button() == mouse_button::button1) {
}
+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()));
}
+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: "))},