> Well, I'm not sure José's gonna love you for simply killing docbook here (and
> also for attributing docbook "ancient").
>
> Seriously, why do you touch docbook at all?

Oops, yes indeed I mixed this up with the removal of linuxdoc/sgml. Richard also havent't touched docbook in his patch for bug 1520. Take the attached patch instead.

The patch will go in when nobody objects because with this we are now also able to solve the long standing URL bug 449 (patch for this follows later today).

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,8 @@
 	// * 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
+	pdfoptions().writeLaTeX(oss, features.isRequired("hyperref"));
 	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)
@@ -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
+	url += getParam("name");
+	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;
 }
 
@@ -108,7 +114,10 @@
 
 void InsetUrl::validate(LaTeXFeatures & features) const
 {
-	features.require("url");
+	if (getCmdName() == "href")
+		features.require("hyperref");
+	else
+		features.require("url");
 }
 
 
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_required) const
 {
-	if (!use_hyperref)
+	if (!use_hyperref && !hyper_required)
 		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_required) const;
 	/// read tokens from lyx header
 	std::string readToken(Lexer &lex, std::string const & token);
 	/// set implicit settings for hyperref

Reply via email to