Attached is a patch that gets rid of the ancient docbook "htmlurl" type (bug
1520).
With the patch the checkbox in the URL-dialog uses now \href, so people can now switch between a
printed URL and a hyperlinked URL (bug 2268).
regards Uwe
Index: development/FORMAT
===================================================================
--- development/FORMAT (revision 20933)
+++ development/FORMAT (working copy)
@@ -1,6 +1,10 @@
LyX file-format changes
-----------------------
+2007-10-12 Uwe Stöhr <[EMAIL PROTECTED]>
+ * Format incremented to 295: get rid of the htmlurl command that was
+ needed for docbook, add the option to create a hyperlink instead
+
2007-10-12 Pavel Sanda <[EMAIL PROTECTED]>
* Format incremented to 294: PDFOptions: add usetitle,
fix leftovers
Index: lib/lyx2lyx/LyX.py
===================================================================
--- lib/lyx2lyx/LyX.py (revision 20933)
+++ lib/lyx2lyx/LyX.py (working copy)
@@ -80,7 +80,7 @@
("1_3", [221], minor_versions("1.3" , 7)),
("1_4", range(222,246), minor_versions("1.4" , 5)),
("1_5", range(246,277), minor_versions("1.5" , 2)),
- ("1_6", range(277,295), minor_versions("1.6" , 0))] # Pavel pdfoptions
+ ("1_6", range(277,296), minor_versions("1.6" , 0))] # Uwe: htmlurl, href
def formats_list():
Index: lib/lyx2lyx/lyx_1_6.py
===================================================================
--- lib/lyx2lyx/lyx_1_6.py (revision 20934)
+++ lib/lyx2lyx/lyx_1_6.py (working copy)
@@ -508,6 +508,28 @@
document.header[i] = ''.join(values)
+def convert_htmlurl(document):
+ 'Convert "htmlurl" (docbook) to "url" insets'
+ i = 0
+ while True:
+ i = find_token(document.body, "LatexCommand htmlurl", i)
+ if i == -1:
+ return
+ document.body[i] = "LatexCommand url"
+ i = i + 1
+
+
+def revert_href(document):
+ 'Reverts hyperlink insets (href) to url insets (url)'
+ i = 0
+ while True:
+ i = find_token(document.body, "LatexCommand href", i)
+ if i == -1:
+ return
+ document.body[i] = "LatexCommand url"
+ i = i + 1
+
+
##
# Conversion hub
#
@@ -530,10 +552,12 @@
[291, []],
[292, []],
[293, []],
- [294, [convert_pdf_options]]
+ [294, [convert_pdf_options]],
+ [295, [convert_htmlurl]]
]
-revert = [[293, [revert_pdf_options_2]],
+revert = [[294, [revert_href]],
+ [293, [revert_pdf_options_2]],
[292, [revert_inset_info]],
[291, [revert_japanese, revert_japanese_encoding]],
[290, [revert_vietnamese]],
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp (revision 20933)
+++ src/Buffer.cpp (working copy)
@@ -154,7 +154,7 @@
namespace {
-int const LYX_FORMAT = 294; //pavel pdfoptions
+int const LYX_FORMAT = 295; //Uwe: htmlurl, href
} // namespace anon
Index: src/BufferParams.cpp
===================================================================
--- src/BufferParams.cpp (revision 20931)
+++ src/BufferParams.cpp (working copy)
@@ -1168,7 +1168,11 @@
// * Has to be loaded before the "LyX specific LaTeX commands" to
// avoid errors with algorithm floats.
odocstringstream oss;
- pdfoptions().writeLaTeX(oss);
+ // use hyperref explicitely when it is required
+ if (features.isRequired("hyperref"))
+ pdfoptions().writeLaTeX(oss, true);
+ else
+ pdfoptions().writeLaTeX(oss, false);
lyxpreamble += oss.str();
// this might be useful...
Index: src/frontends/qt4/GuiURL.cpp
===================================================================
--- src/frontends/qt4/GuiURL.cpp (revision 20931)
+++ src/frontends/qt4/GuiURL.cpp (working copy)
@@ -24,7 +24,7 @@
#include <QPushButton>
-namespace lyx {
+namespace lyx {
namespace frontend {
GuiURL::GuiURL(LyXView & lv)
@@ -44,7 +44,6 @@
setFocusProxy(urlED);
- bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
bc().addReadOnly(urlED);
@@ -66,7 +65,6 @@
}
-
void GuiURL::updateContents()
{
urlED->setText(toqstr(params_["target"]));
@@ -82,8 +80,8 @@
params_["target"] = qstring_to_ucs4(urlED->text());
params_["name"] = qstring_to_ucs4(nameED->text());
- if (hyperlinkCB->isChecked())
- params_.setCmdName("htmlurl");
+ if (hyperlinkCB->checkState() == Qt::Checked)
+ params_.setCmdName("href");
else
params_.setCmdName("url");
}
Index: src/insets/InsetUrl.cpp
===================================================================
--- src/insets/InsetUrl.cpp (revision 20931)
+++ src/insets/InsetUrl.cpp (working copy)
@@ -39,13 +39,12 @@
docstring const InsetUrl::getScreenLabel(Buffer const &) const
{
docstring const temp =
- (getCmdName() == "url") ? _("Url: ") : _("HtmlUrl: ");
+ (getCmdName() == "url") ? _("Url: ") : _("Hyperlink: ");
docstring url;
- if (!getParam("name").empty())
url += getParam("name");
- else
+ if (url.empty())
url += getParam("target");
// elide if long
@@ -61,11 +60,18 @@
OutputParams const & runparams) const
{
docstring const & name = getParam("name");
- if (!name.empty())
+ if (!name.empty() && getCmdName() == "url")
os << name + ' ';
if (runparams.moving_arg)
os << "\\protect";
- os << "\\url{" << getParam("target") << '}';
+ if (getCmdName() == "href") {
+ //set the target for the name when no name is given
+ if (!getParam("name").empty())
+ os << "\\href{" << getParam("target") << "}{" << getParam("name") << '}';
+ else
+ os << "\\href{" << getParam("target") << "}{" << getParam("target") << '}';
+ } else
+ os << "\\url{" << getParam("target") << '}';
return 0;
}
@@ -87,18 +93,6 @@
}
-int InsetUrl::docbook(Buffer const &, odocstream & os,
- OutputParams const &) const
-{
- os << "<ulink url=\""
- << subst(getParam("target"), from_ascii("&"), from_ascii("&"))
- << "\">"
- << getParam("name")
- << "</ulink>";
- return 0;
-}
-
-
int InsetUrl::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
@@ -108,7 +102,10 @@
void InsetUrl::validate(LaTeXFeatures & features) const
{
- features.require("url");
+ if (getCmdName() == "href")
+ features.require("hyperref");
+ else
+ features.require("url");
}
Index: src/insets/InsetUrl.h
===================================================================
--- src/insets/InsetUrl.h (revision 20931)
+++ src/insets/InsetUrl.h (working copy)
@@ -43,9 +43,6 @@
///
int plaintext(Buffer const &, odocstream &,
OutputParams const &) const;
- ///
- int docbook(Buffer const &, odocstream &,
- OutputParams const &) const;
/// the string that is passed to the TOC
virtual int textString(Buffer const &, odocstream &,
OutputParams const &) const;
Index: src/PDFOptions.cpp
===================================================================
--- src/PDFOptions.cpp (revision 20933)
+++ src/PDFOptions.cpp (working copy)
@@ -86,9 +86,9 @@
os << "\\pdf_quoted_options \"" << quoted_options << "\"\n";
}
-void PDFOptions::writeLaTeX(odocstringstream &os) const
+void PDFOptions::writeLaTeX(odocstringstream &os, bool hyper) const
{
- if (!use_hyperref)
+ if (!use_hyperref && !hyper)
return;
string opt;
Index: src/PDFOptions.h
===================================================================
--- src/PDFOptions.h (revision 20931)
+++ src/PDFOptions.h (working copy)
@@ -28,7 +28,7 @@
/// output to lyx header
void writeFile(std::ostream &) const;
/// output to tex header
- void writeLaTeX(odocstringstream &) const;
+ void writeLaTeX(odocstringstream &, bool hyper) const;
/// read tokens from lyx header
std::string readToken(Lexer &lex, std::string const & token);
/// set implicit settings for hyperref