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