]> git.lyx.org Git - lyx.git/blob - src/insets/InsetFlex.cpp
Pure HTML output for math macros.
[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 "Cursor.h"
20 #include "FuncRequest.h"
21 #include "FuncStatus.h"
22 #include "Lexer.h"
23
24 #include "support/gettext.h"
25
26 #include <ostream>
27
28 using namespace std;
29
30 namespace lyx {
31
32
33 InsetFlex::InsetFlex(Buffer * buf, string const & layoutName)
34         : InsetCollapsable(buf), name_(layoutName)
35 {
36         status_= Collapsed;
37 }
38
39
40 InsetFlex::InsetFlex(InsetFlex const & in)
41         : InsetCollapsable(in), name_(in.name_)
42 {}
43
44
45 InsetLayout::InsetDecoration InsetFlex::decoration() const
46 {
47         InsetLayout::InsetDecoration const dec = getLayout().decoration();
48         return dec == InsetLayout::DEFAULT ? InsetLayout::CONGLOMERATE : dec;
49 }
50
51
52 void InsetFlex::write(ostream & os) const
53 {
54         os << "Flex " <<
55                 (name_.empty() ? "undefined" : name_) << "\n";
56         InsetCollapsable::write(os);
57 }
58
59
60 bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
61                 FuncStatus & flag) const
62 {
63         switch (cmd.action) {
64         case LFUN_INSET_DISSOLVE:
65                 if (!cmd.argument().empty()) {
66                         InsetLayout const & il = getLayout();
67                         InsetLayout::InsetLyXType const type = 
68                                 translateLyXType(to_utf8(cmd.argument()));
69                         if (il.lyxtype() == type) {
70                                 FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
71                                 return InsetCollapsable::getStatus(cur, temp_cmd, flag);
72                         } else
73                                 return false;
74                 }
75                 // fall-through
76         default:
77                 return InsetCollapsable::getStatus(cur, cmd, flag);
78         }
79 }
80
81
82 void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
83 {
84         switch (cmd.action) {
85         case LFUN_INSET_DISSOLVE:
86                 if (!cmd.argument().empty()) {
87                         InsetLayout const & il = getLayout();
88                         InsetLayout::InsetLyXType const type = 
89                                 translateLyXType(to_utf8(cmd.argument()));
90                         
91                         if (il.lyxtype() == type) {
92                                 FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
93                                 InsetCollapsable::doDispatch(cur, temp_cmd);
94                         } else
95                                 cur.undispatched();
96                         break;
97                 }
98                 // fall-through
99         default:
100                 InsetCollapsable::doDispatch(cur, cmd);
101                 break;
102         }
103 }
104
105
106 } // namespace lyx