diff --git a/development/FORMAT b/development/FORMAT index 0a6adfcc38..373616ef21 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,12 +1,19 @@ LyX file-format changes ----------------------- +2007-11-01 Uwe Stöhr + * Format incremented to 299: support for hyperlink types + +2007-11-01 Stefan Schimanski + * Format incremented to 298: math-macro code has been rewritten, + now it supports definitions with optional parameters + 2007-10-29 Uwe Stöhr * Format incremented to 297: support for Albanian, lower Sorbian, fixed upper Sorbian language 2007-10-?? Richard Heck - * Format incremented to 296: ?? + * Format incremented to 296: ?Include insets are no longer insets? 2007-10-12 Uwe Stöhr * Format incremented to 295: get rid of the htmlurl command that was diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index 2b3f3726c5..377397f6b4 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)), ("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,299), minor_versions("1.6" , 0))] # Schimmi: Optional parameters for macros + ("1_6", range(277,300), minor_versions("1.6" , 0))] # Uwe: Hyperlink types def formats_list(): diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 86659f424a..c5fea14fef 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -689,12 +689,6 @@ def revert_lowersorbian(document): j = j + 1 -def revert_macro_optional_params(document): - "Convert macro definitions with optional parameters into ERTs" - # Stub to convert macro definitions with one or more optional parameters - # into uninterpreted ERT insets - - def revert_uppersorbian(document): "Set language uppersorbian to usorbian as this was used in LyX 1.5" # Set document language from uppersorbian to usorbian @@ -731,6 +725,28 @@ def convert_usorbian(document): j = j + 1 +def revert_macro_optional_params(document): + "Convert macro definitions with optional parameters into ERTs" + # Stub to convert macro definitions with one or more optional parameters + # into uninterpreted ERT insets + + +def revert_hyperlinktype(document): + 'Reverts hyperlink type' + i = 0 + j = 0 + while True: + i = find_token(document.body, "target", i) + if i == -1: + return + j = find_token(document.body, "type", i) + if j == -1: + return + if j == i + 1: + del document.body[j] + i = i + 1 + + ## # Conversion hub # @@ -757,10 +773,12 @@ convert = [[277, [fix_wrong_tables]], [295, [convert_htmlurl, convert_url]], [296, [convert_include]], [297, [convert_usorbian]], - [298, []] + [298, []], + [299, []] ] -revert = [[297, [revert_macro_optional_params]], +revert = [[298, [revert_hyperlinktype]], + [297, [revert_macro_optional_params]], [296, [revert_albanian, revert_lowersorbian, revert_uppersorbian]], [295, [revert_include]], [294, [revert_href]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 0e5288208e..2e2dc5fc4f 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -157,7 +157,7 @@ namespace fs = boost::filesystem; namespace { -int const LYX_FORMAT = 298; //Schimmi: Optional parameters in macros +int const LYX_FORMAT = 299; //Uwe: Hyperlink types } // namespace anon diff --git a/src/frontends/qt4/GuiHyperlink.cpp b/src/frontends/qt4/GuiHyperlink.cpp index 680aceba03..bd4b58b1ec 100644 --- a/src/frontends/qt4/GuiHyperlink.cpp +++ b/src/frontends/qt4/GuiHyperlink.cpp @@ -38,6 +38,12 @@ GuiHyperlink::GuiHyperlink(LyXView & lv) this, SLOT(changed_adaptor())); connect(nameED, SIGNAL(textChanged(const QString &)), this, SLOT(changed_adaptor())); + connect(WebRB, SIGNAL(clicked()), + this, SLOT(changed_adaptor())); + connect(EmailRB, SIGNAL(clicked()), + this, SLOT(changed_adaptor())); + connect(FileRB, SIGNAL(clicked()), + this, SLOT(changed_adaptor())); setFocusProxy(urlED); @@ -45,6 +51,9 @@ GuiHyperlink::GuiHyperlink(LyXView & lv) bc().setCancel(closePB); bc().addReadOnly(urlED); bc().addReadOnly(nameED); + bc().addReadOnly(WebRB); + bc().addReadOnly(EmailRB); + bc().addReadOnly(FileRB); } @@ -65,6 +74,12 @@ void GuiHyperlink::updateContents() { urlED->setText(toqstr(params_["target"])); nameED->setText(toqstr(params_["name"])); + if (params_["type"] == "") + WebRB->setChecked(true); + else if (params_["type"] == "mailto:") + EmailRB->setChecked(true); + else if (params_["type"] == "file:") + FileRB->setChecked(true); bc().setValid(isValid()); } @@ -73,6 +88,12 @@ void GuiHyperlink::applyView() { params_["target"] = qstring_to_ucs4(urlED->text()); params_["name"] = qstring_to_ucs4(nameED->text()); + if (WebRB->isChecked()) + params_["type"] = qstring_to_ucs4(""); + else if (EmailRB->isChecked()) + params_["type"] = qstring_to_ucs4("mailto:"); + else if (FileRB->isChecked()) + params_["type"] = qstring_to_ucs4("file:"); params_.setCmdName("href"); } diff --git a/src/frontends/qt4/ui/HyperlinkUi.ui b/src/frontends/qt4/ui/HyperlinkUi.ui index 529bae1de9..c3bc58b95b 100644 --- a/src/frontends/qt4/ui/HyperlinkUi.ui +++ b/src/frontends/qt4/ui/HyperlinkUi.ui @@ -5,8 +5,8 @@ 0 0 - 332 - 109 + 336 + 155 @@ -16,25 +16,26 @@ true - - 9 - - - 6 - URL - &URL: + &Target: urlED + + + + URL + + + @@ -48,28 +49,97 @@ - + Name associated with the URL - - + + - URL + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">specify the link target</p></body></html> + + Link type + + + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;">Link to the web or to every other target</p></body></html> + + + &Web + + + + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;">Link to an email address</p></body></html> + + + &Email + + + + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Link to a file</p></body></html> + + + &File + + + + - - - - 0 + + + + Qt::Horizontal + + + 40 + 20 + + + + + + 6 + + 0 + + + 0 + + + 0 + + + 0 + @@ -110,6 +180,9 @@ urlED nameED + WebRB + EmailRB + FileRB okPB closePB diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp index 213e7b59ad..488b68a42c 100644 --- a/src/insets/InsetHyperlink.cpp +++ b/src/insets/InsetHyperlink.cpp @@ -47,9 +47,9 @@ InsetHyperlink::InsetHyperlink(InsetCommandParams const & p) CommandInfo const * InsetHyperlink::findInfo(std::string const & /* cmdName */) { static const char * const paramnames[] = - {"name", "target", ""}; + {"name", "target", "type", ""}; static const bool isoptional[] = {true, false}; - static const CommandInfo info = {2, paramnames, isoptional}; + static const CommandInfo info = {3, paramnames, isoptional}; return &info; } @@ -124,13 +124,18 @@ int InsetHyperlink::latex(Buffer const &, odocstream & os, } // end if (!name.empty()) + //for the case there is no name given, the target is set as name + string urlname = url; + // set the hyperlink type + url = to_utf8(getParam("type")) + url; + if (runparams.moving_arg) os << "\\protect"; //set the target for the name when no name is given if (!name.empty()) os << "\\href{" << from_utf8(url) << "}{" << from_utf8(name) << '}'; else - os << "\\href{" << from_utf8(url) << "}{" << from_utf8(url) << '}'; + os << "\\href{" << from_utf8(url) << "}{" << from_utf8(urlname) << '}'; return 0; }