]> git.lyx.org Git - lyx.git/blob - src/insets/inseturl.C
layout as string
[lyx.git] / src / insets / inseturl.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "inseturl.h"
8 #include "BufferView.h"
9 #include "LaTeXFeatures.h"
10 #include "LyXView.h"
11 #include "debug.h"
12 #include "frontends/Dialogs.h"
13 #include "support/lstrings.h"
14 #include "gettext.h"
15
16 using std::ostream;
17
18
19 InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
20                 : InsetCommand(p)
21 {}
22
23
24 void InsetUrl::edit(BufferView * bv, int, int, unsigned int)
25 {
26         bv->owner()->getDialogs()->showUrl(this);
27 }
28
29
30 void InsetUrl::edit(BufferView * bv, bool)
31 {
32         edit(bv, 0, 0, 0);
33 }
34
35
36 string const InsetUrl::getScreenLabel(Buffer const *) const
37 {
38         string temp;
39         if (getCmdName() == "url")
40                 temp = _("Url: ");
41         else 
42                 temp = _("HtmlUrl: ");
43
44         if (!getOptions().empty())
45                 temp += getOptions();
46         else
47                 temp += getContents();
48
49         return temp;
50 }
51
52
53 int InsetUrl::latex(Buffer const *, ostream & os,
54                     bool fragile, bool /*free_spc*/) const
55 {
56         if (!getOptions().empty())
57                 os << getOptions() + ' ';
58         if (fragile)
59                 os << "\\protect";
60         os << "\\url{" << getContents() << '}';
61         return 0;
62 }
63
64
65 int InsetUrl::ascii(Buffer const *, ostream & os, int) const
66 {
67         if (getOptions().empty())
68                 os << "[" << getContents() << "]";
69         else
70                 os << "[" << getContents() << "||" <<  getOptions() << "]";
71         return 0;
72 }
73
74
75 int InsetUrl::linuxdoc(Buffer const *, ostream & os) const
76 {
77         os << "<" << getCmdName()
78            << " url=\""  << getContents() << "\""
79            << " name=\"" << getOptions() << "\">";
80
81         return 0;
82 }
83
84
85 int InsetUrl::docbook(Buffer const *, ostream & os) const
86 {
87         os << "<ulink url=\"" << subst(getContents(),"&","&amp;")
88            << "\">" << getOptions() << "</ulink>";
89         return 0;
90 }
91
92
93 void InsetUrl::validate(LaTeXFeatures & features) const
94 {
95         features.require("url");
96 }