#include "MathSupport.h"
#include "OutputParams.h"
#include "ParIterator.h"
-#include "sgml.h"
+#include "xml.h"
#include "insets/InsetCommand.h"
namespace lyx {
InsetMathRef::InsetMathRef(Buffer * buf)
- : CommandInset(buf, from_ascii("ref"), false)
+ : InsetMathCommand(buf, from_ascii("ref"), false)
{}
InsetMathRef::InsetMathRef(Buffer * buf, docstring const & data)
- : CommandInset(buf, data, false)
+ : InsetMathCommand(buf, data, false)
{}
switch (cmd.action()) {
case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "ref") {
+ if (cmd.getArg(1) == "changetarget") {
+ string const oldtarget = cmd.getArg(2);
+ string const newtarget = cmd.getArg(3);
+ if (!oldtarget.empty() && !newtarget.empty()
+ && asString(cell(0)) == from_utf8(oldtarget))
+ changeTarget(from_utf8(newtarget));
+ cur.forceBufferUpdate();
+ break;
+ }
MathData ar;
if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
cur.recordUndo();
break;
default:
- CommandInset::doDispatch(cur, cmd);
+ InsetMathCommand::doDispatch(cur, cmd);
break;
}
}
status.setEnabled(true);
return true;
default:
- return CommandInset::getStatus(cur, cmd, status);
+ return InsetMathCommand::getStatus(cur, cmd, status);
}
}
features.require("prettyref");
else if (commandname() == "eqref")
features.require("amsmath");
+ else if (commandname() == "nameref")
+ features.require("nameref");
}
-int InsetMathRef::docbook(odocstream & os, OutputParams const & runparams) const
+void InsetMathRef::docbook(XMLStream & xs, OutputParams const &) const
{
if (cell(1).empty()) {
- os << "<xref linkend=\""
- << sgml::cleanID(buffer(), runparams, asString(cell(0)));
- if (runparams.flavor == OutputParams::XML)
- os << "\"/>";
- else
- os << "\">";
+ docstring attr = from_utf8("linkend=\"") + xml::cleanID(asString(cell(0))) + from_utf8("\"");
+ xs << xml::CompTag("xref", to_utf8(attr));
} else {
- os << "<link linkend=\""
- << sgml::cleanID(buffer(), runparams, asString(cell(0)))
- << "\">"
+ // Link with linkend, as is it within the document (not outside, in which case xlink:href is better suited).
+ docstring attr = from_utf8("linkend=\"") + xml::cleanID(asString(cell(0))) + from_utf8("\"");
+ xs << xml::StartTag("link", to_utf8(attr))
<< asString(cell(1))
- << "</link>";
+ << xml::EndTag("link");
}
-
- return 0;
}
-void InsetMathRef::updateBuffer(ParIterator const & it, UpdateType /*utype*/)
+void InsetMathRef::updateBuffer(ParIterator const & it, UpdateType /*utype*/, bool const /*deleted*/)
{
if (!buffer_) {
LYXERR0("InsetMathRef::updateBuffer: no buffer_!");
{ from_ascii("vpageref"), from_ascii(N_("Textual Page Number")), from_ascii(N_("TextPage: "))},
{ from_ascii("vref"), from_ascii(N_("Standard+Textual Page")), from_ascii(N_("Ref+Text: "))},
{ from_ascii("prettyref"), from_ascii(N_("PrettyRef")), from_ascii(N_("FormatRef: "))},
+ { from_ascii("nameref"), from_ascii(N_("Reference to Name")), from_ascii(N_("NameRef: "))},
{ from_ascii(""), from_ascii(""), from_ascii("") }
};