+void InsetHyperlink::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+ switch (cmd.action()) {
+
+ case LFUN_INSET_EDIT:
+ viewTarget();
+ break;
+
+ default:
+ InsetCommand::doDispatch(cur, cmd);
+ break;
+ }
+}
+
+
+bool InsetHyperlink::getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus & flag) const
+{
+ switch (cmd.action()) {
+ case LFUN_INSET_EDIT:
+ flag.setEnabled(getParam("type").empty() || getParam("type") == "file:");
+ return true;
+
+ default:
+ return InsetCommand::getStatus(cur, cmd, flag);
+ }
+}
+
+
+void InsetHyperlink::viewTarget() const
+{
+ if (getParam("type") == "file:") {
+ FileName url = makeAbsPath(to_utf8(getParam("target")), buffer().filePath());
+ string const format = formats.getFormatFromFile(url);
+ formats.view(buffer(), url, format);
+ }
+}
+