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