]> git.lyx.org Git - lyx.git/blob - src/insets/insettabular.h
* src/insets/insettabular.h: return true for allowSpellcheck (bug 2675)
[lyx.git] / src / insets / insettabular.h
1 // -*- C++ -*-
2 /**
3  * \file insettabular.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Vigna
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12
13 // This is Juergen's rewrite of the tabular (table) support.
14
15 // Things to think of when designing the new tabular support:
16 // - color support (colortbl, color)
17 // - decimal alignment (dcloumn)
18 // - custom lines (hhline)
19 // - rotation
20 // - multicolumn
21 // - multirow
22 // - column styles
23
24 // This is what I have written about tabular support in the LyX3-Tasks file:
25 //
26 //  o rewrite of table code. Should probably be written as some
27 //    kind of an inset. [Done]
28 // o enhance longtable support
29
30 // Lgb
31
32 #ifndef INSETTABULAR_H
33 #define INSETTABULAR_H
34
35 #include "inset.h"
36 #include "tabular.h"
37
38 class FuncStatus;
39 class LyXLex;
40 class BufferView;
41 class Buffer;
42 class BufferParams;
43 class Paragraph;
44 class CursorSlice;
45
46 namespace lyx {
47 namespace frontend {
48 class Painter;
49 }
50 }
51
52
53 class InsetTabular : public InsetOld {
54 public:
55         ///
56         InsetTabular(Buffer const &, row_type rows = 1,
57                      col_type columns = 1);
58         ///
59         ~InsetTabular();
60         ///
61         void read(Buffer const &, LyXLex &);
62         ///
63         void write(Buffer const &, std::ostream &) const;
64         ///
65         void metrics(MetricsInfo &, Dimension &) const;
66         ///
67         void draw(PainterInfo & pi, int x, int y) const;
68         ///
69         void drawSelection(PainterInfo & pi, int x, int y) const;
70         ///
71         std::string const editMessage() const;
72         ///
73         EDITABLE editable() const { return HIGHLY_EDITABLE; }
74         ///
75         bool insetAllowed(InsetBase::Code) const { return true; }
76         ///
77         bool allowSpellCheck() const { return true; }
78         ///
79         bool canTrackChanges() const { return true; }
80         /** returns true if, when outputing LaTeX, font changes should
81             be closed before generating this inset. This is needed for
82             insets that may contain several paragraphs */
83         bool noFontChange() const { return true; }
84         ///
85         bool display() const { return tabular.isLongTabular(); }
86         ///
87         int latex(Buffer const &, std::ostream &,
88                   OutputParams const &) const;
89         ///
90         int plaintext(Buffer const &, std::ostream &,
91                   OutputParams const &) const;
92         ///
93         int linuxdoc(Buffer const &, std::ostream &,
94                      OutputParams const &) const;
95         ///
96         int docbook(Buffer const &, std::ostream &,
97                     OutputParams const &) const;
98         ///
99         void validate(LaTeXFeatures & features) const;
100         ///
101         Code lyxCode() const { return InsetBase::TABULAR_CODE; }
102         /// get offset of this cursor slice relative to our upper left corner
103         void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
104         ///
105         bool tabularFeatures(LCursor & cur, std::string const & what);
106         ///
107         void tabularFeatures(LCursor & cur, LyXTabular::Feature feature,
108                              std::string const & val = std::string());
109         ///
110         void openLayoutDialog(BufferView *) const;
111         ///
112         bool showInsetDialog(BufferView *) const;
113         /// number of cells
114         size_t nargs() const { return tabular.getNumberOfCells(); }
115         ///
116         boost::shared_ptr<InsetText const> cell(idx_type) const;
117         ///
118         boost::shared_ptr<InsetText> cell(idx_type);
119         ///
120         LyXText * getText(int) const;
121
122         ///
123         void markErased(bool);
124
125         // this should return true if we have a "normal" cell, otherwise false.
126         // "normal" means without width set!
127         /// should all paragraphs be output with "Standard" layout?
128         bool forceDefaultParagraphs(idx_type cell = 0) const;
129
130         ///
131         void addPreview(lyx::graphics::PreviewLoader &) const;
132
133         ///
134         Buffer const & buffer() const;
135
136         /// set the owning buffer
137         void buffer(Buffer const * buf);
138         /// lock cell with given index
139         void edit(LCursor & cur, bool left);
140         ///
141         InsetBase * editXY(LCursor & cur, int x, int y);
142         /// can we go further down on mouse click?
143         bool descendable() const { return true; }
144
145         //
146         // Public structures and variables
147         ///
148         mutable LyXTabular tabular;
149
150 protected:
151         ///
152         InsetTabular(InsetTabular const &);
153         ///
154         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
155         ///
156         bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
157         ///
158         int scroll() const { return scx_; }
159
160 private:
161         virtual std::auto_ptr<InsetBase> doClone() const;
162
163         ///
164         void drawCellLines(lyx::frontend::Painter &, int x, int y, row_type row,
165                            idx_type cell, bool erased) const;
166         ///
167         void setCursorFromCoordinates(LCursor & cur, int x, int y) const;
168
169         ///
170         void moveNextCell(LCursor & cur);
171         ///
172         void movePrevCell(LCursor & cur);
173         ///
174         int getCellXPos(idx_type cell) const;
175         ///
176         void resetPos(LCursor & cur) const;
177         ///
178         void removeTabularRow();
179         ///
180         bool hasPasteBuffer() const;
181         ///
182         bool copySelection(LCursor & cur);
183         ///
184         bool pasteSelection(LCursor & cur);
185         ///
186         void cutSelection(LCursor & cur);
187         ///
188         bool isRightToLeft(LCursor & cur) const;
189         ///
190         void getSelection(LCursor & cur, row_type & rs, row_type & re,
191                           col_type & cs, col_type & ce) const;
192         ///
193         bool insertAsciiString(BufferView &, std::string const & buf, bool usePaste);
194         /// are we operating on several cells?
195         bool tablemode(LCursor & cur) const;
196
197         /// return the "Manhattan distance" to nearest corner
198         int dist(idx_type cell, int x, int y) const;
199         /// return the cell nearest to x, y
200         idx_type getNearestCell(int x, int y) const;
201
202         ///
203         Buffer const * buffer_;
204         ///
205         mutable idx_type first_visible_cell;
206         ///
207         mutable int scx_;
208 };
209
210
211 #include "mailinset.h"
212
213
214 class InsetTabularMailer : public MailInset {
215 public:
216         ///
217         InsetTabularMailer(InsetTabular const & inset);
218         ///
219         virtual InsetBase & inset() const { return inset_; }
220         ///
221         virtual std::string const & name() const { return name_; }
222         ///
223         virtual std::string const inset2string(Buffer const &) const;
224         ///
225         static void string2params(std::string const &, InsetTabular &);
226         ///
227         static std::string const params2string(InsetTabular const &);
228 private:
229         ///
230         static std::string const name_;
231         ///
232         InsetTabular & inset_;
233 };
234
235 std::string const featureAsString(LyXTabular::Feature feature);
236
237 #endif