*/
#include <config.h>
-#include <output_docbook.h>
-
#include "InsetHyperlink.h"
#include "Buffer.h"
-#include "DispatchResult.h"
-#include "Encoding.h"
#include "Format.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "LaTeXFeatures.h"
-#include "OutputParams.h"
+#include "output_docbook.h"
#include "output_xhtml.h"
#include "xml.h"
#include "texstream.h"
+#include "support/debug.h"
#include "support/docstream.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lstrings.h"
+#include "support/qstring_helpers.h"
#include "frontends/alert.h"
+#include <QtGui/QDesktopServices>
+#include <QUrl>
+
using namespace std;
using namespace lyx::support;
FuncStatus & flag) const
{
switch (cmd.action()) {
- case LFUN_INSET_EDIT:
- flag.setEnabled(getParam("type").empty() || getParam("type") == "file:");
+ case LFUN_INSET_EDIT: {
+ QUrl url(toqstr(getParam("target")),QUrl::StrictMode);
+ bool url_valid = getParam("type").empty() && url.isValid();
+
+ flag.setEnabled(url_valid || getParam("type") == "file:");
return true;
+ }
default:
return InsetCommand::getStatus(cur, cmd, flag);
void InsetHyperlink::viewTarget() const
{
- if (getParam("type") == "file:") {
+ if (getParam("type").empty()) { //==Web
+ QUrl url(toqstr(getParam("target")),QUrl::StrictMode);
+ if (!QDesktopServices::openUrl(url))
+ LYXERR0("Unable to open URL!");
+
+ } else if (getParam("type") == "file:") {
FileName url = makeAbsPath(to_utf8(getParam("target")), buffer().filePath());
string const format = theFormats().getFormatFromFile(url);
theFormats().view(buffer(), url, format);
docstring InsetHyperlink::xhtml(XMLStream & xs, OutputParams const &) const
{
docstring const & target =
- xml::xmlize(getParam("target"), XMLStream::ESCAPE_AND);
+ xml::escapeString(getParam("target"), XMLStream::ESCAPE_AND);
docstring const & name = getParam("name");
xs << xml::StartTag("a", to_utf8("href=\"" + target + "\""));
xs << (name.empty() ? target : name);
}
+pair<int, int> InsetHyperlink::isWords() const
+{
+ docstring const label = getParam("name");
+ return pair<int, int>(label.size(), wordCount(label));
+}
+
+
string InsetHyperlink::contextMenuName() const
{
return "context-hyperlink";