]> git.lyx.org Git - lyx.git/blob - src/insets/InsetFlex.cpp
5931bb4eba2584fdabe7b2a4b3b944257a25eff4
[lyx.git] / src / insets / InsetFlex.cpp
1 /**
2  * \file InsetFlex.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  * \author Martin Vermeer
8  * \author Jürgen Spitzmüller
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "InsetFlex.h"
16
17 #include "Buffer.h"
18 #include "BufferParams.h"
19 #include "LaTeXFeatures.h"
20 #include "Lexer.h"
21 #include "MetricsInfo.h"
22 #include "Paragraph.h"
23 #include "paragraph_funcs.h"
24 #include "sgml.h"
25 #include "Text.h"
26
27 #include "support/gettext.h"
28
29 #include <ostream>
30
31 using namespace std;
32
33 namespace lyx {
34
35
36 InsetFlex::InsetFlex(Buffer const & buf, string const & layoutName)
37         : InsetCollapsable(buf), name_(layoutName)
38 {
39         // again, because now the name is initialized
40         setLayout(buf.params().documentClassPtr());
41         status_= Collapsed;
42 }
43
44
45 InsetFlex::InsetFlex(InsetFlex const & in)
46         : InsetCollapsable(in), name_(in.name_)
47 {}
48
49
50 docstring InsetFlex::editMessage() const
51 {
52         return _("Opened Flex Inset");
53 }
54
55
56 void InsetFlex::write(ostream & os) const
57 {
58         os << "Flex " <<
59                 (name_.empty() ? "undefined" : name_) << "\n";
60         InsetCollapsable::write(os);
61 }
62
63
64 int InsetFlex::docbook(odocstream & os, OutputParams const & runparams) const
65 {
66         ParagraphList::const_iterator const beg = paragraphs().begin();
67         ParagraphList::const_iterator par = paragraphs().begin();
68         ParagraphList::const_iterator const end = paragraphs().end();
69
70         if (!undefined())
71                 sgml::openTag(os, getLayout().latexname(),
72                               par->getID(buffer(), runparams) + getLayout().latexparam());
73
74         for (; par != end; ++par) {
75                 par->simpleDocBookOnePar(buffer(), os, runparams,
76                                          outerFont(distance(beg, par),
77                                                    paragraphs()));
78         }
79
80         if (!undefined())
81                 sgml::closeTag(os, getLayout().latexname());
82
83         return 0;
84 }
85
86
87 void InsetFlex::tocString(odocstream & os) const
88 {
89         os << text().asString(0, 1, AS_STR_LABEL | AS_STR_INSETS);
90 }
91
92
93 } // namespace lyx