]> git.lyx.org Git - lyx.git/blob - src/insets/inseturl.C
patch from Angus
[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
14 using std::ostream;
15
16
17 InsetUrl::InsetUrl(InsetCommandParams const & p)
18                 : InsetCommand(p)
19 {}
20
21
22 void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
23 {
24         bv->owner()->getDialogs()->showUrl( this );
25 }
26
27
28 string InsetUrl::getScreenLabel() const
29 {
30         string temp;
31         if( getCmdName() == "url" )
32                 temp = _("Url: ");
33         else 
34                 temp = _("HtmlUrl: ");
35
36         if(!getOptions().empty())
37                 temp += getOptions();
38         else
39                 temp += getContents();
40
41         return temp;
42 }
43
44
45 int InsetUrl::Latex(Buffer const *, ostream & os,
46                     bool fragile, bool /*free_spc*/) const
47 {
48         if (!getOptions().empty())
49                 os << getOptions() + ' ';
50         if (fragile)
51                 os << "\\protect";
52         os << "\\url{" << getContents() << '}';
53         return 0;
54 }
55
56
57 int InsetUrl::Ascii(Buffer const *, ostream & os) const
58 {
59         if (getOptions().empty())
60                 os << "[" << getContents() << "]";
61         else
62                 os << "[" << getContents() << "||" <<  getOptions() << "]";
63         return 0;
64 }
65
66
67 int InsetUrl::Linuxdoc(Buffer const *, ostream & os) const
68 {
69         os << "<" << getCmdName()
70            << " url=\""  << getContents() << "\""
71            << " name=\"" << getOptions() << "\">";
72
73         return 0;
74 }
75
76
77 int InsetUrl::DocBook(Buffer const *, ostream & os) const
78 {
79         os << "<ulink url=\"" << getContents() << "\">"
80            << getOptions() << "</ulink>";
81         return 0;
82 }
83
84
85 void InsetUrl::Validate(LaTeXFeatures & features) const
86 {
87         features.url = true;
88 }