]> git.lyx.org Git - features.git/blob - src/insets/InsetSpace.cpp
* src/insets/InsetSpace.cpp:
[features.git] / src / insets / InsetSpace.cpp
1 /**
2  * \file InsetSpace.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Asger Alstrup Nielsen
7  * \author Jean-Marc Lasgouttes
8  * \author Lars Gullik Bjønnes
9  * \author Jürgen Spitzmüller
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #include <config.h>
15
16 #include "InsetSpace.h"
17
18 #include "BufferView.h"
19 #include "Cursor.h"
20 #include "Dimension.h"
21 #include "FuncRequest.h"
22 #include "FuncStatus.h"
23 #include "Length.h"
24 #include "Lexer.h"
25 #include "MetricsInfo.h"
26 #include "OutputParams.h"
27
28 #include "support/debug.h"
29 #include "support/docstream.h"
30 #include "support/gettext.h"
31 #include "support/lstrings.h"
32
33 #include "frontends/Application.h"
34 #include "frontends/FontMetrics.h"
35 #include "frontends/Painter.h"
36
37 using namespace std;
38
39 namespace lyx {
40
41
42 InsetSpace::InsetSpace(InsetSpaceParams const & params)
43         : params_(params)
44 {}
45
46
47 InsetSpaceParams::Kind InsetSpace::kind() const
48 {
49         return params_.kind;
50 }
51
52
53 Length InsetSpace::length() const
54 {
55         return params_.length;
56 }
57
58
59 InsetSpace::~InsetSpace()
60 {
61         hideDialogs("space", this);
62 }
63
64
65 docstring InsetSpace::toolTip(BufferView const &, int, int) const
66 {
67         docstring message;
68         switch (params_.kind) {
69         case InsetSpaceParams::NORMAL:
70                 message = _("Interword Space");
71                 break;
72         case InsetSpaceParams::PROTECTED:
73                 message = _("Protected Space");
74                 break;
75         case InsetSpaceParams::THIN:
76                 message = _("Thin Space");
77                 break;
78         case InsetSpaceParams::QUAD:
79                 message = _("Quad Space");
80                 break;
81         case InsetSpaceParams::QQUAD:
82                 message = _("QQuad Space");
83                 break;
84         case InsetSpaceParams::ENSPACE:
85                 message = _("Enspace");
86                 break;
87         case InsetSpaceParams::ENSKIP:
88                 message = _("Enskip");
89                 break;
90         case InsetSpaceParams::NEGTHIN:
91                 message = _("Negative Thin Space");
92                 break;
93         case InsetSpaceParams::HFILL:
94                 message = _("Horizontal Fill");
95                 break;
96         case InsetSpaceParams::HFILL_PROTECTED:
97                 message = _("Protected Horizontal Fill");
98                 break;
99         case InsetSpaceParams::DOTFILL:
100                 message = _("Horizontal Fill (Dots)");
101                 break;
102         case InsetSpaceParams::HRULEFILL:
103                 message = _("Horizontal Fill (Rule)");
104                 break;
105         case InsetSpaceParams::LEFTARROWFILL:
106                 message = _("Horizontal Fill (Left Arrow)");
107                 break;
108         case InsetSpaceParams::RIGHTARROWFILL:
109                 message = _("Horizontal Fill (Right Arrow)");
110                 break;
111         case InsetSpaceParams::UPBRACEFILL:
112                 message = _("Horizontal Fill (Up Brace)");
113                 break;
114         case InsetSpaceParams::DOWNBRACEFILL:
115                 message = _("Horizontal Fill (Down Brace)");
116                 break;
117         case InsetSpaceParams::CUSTOM:
118                 message = support::bformat(_("Horizontal Space (%1$s)"),
119                                 params_.length.asDocstring());
120                 break;
121         case InsetSpaceParams::CUSTOM_PROTECTED:
122                 message = support::bformat(_("Protected Horizontal Space (%1$s)"),
123                                 params_.length.asDocstring());
124                 break;
125         }
126         return message;
127 }
128
129
130 void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
131 {
132         switch (cmd.action) {
133
134         case LFUN_INSET_MODIFY: {
135                 string2params(to_utf8(cmd.argument()), params_);
136                 break;
137         }
138
139         case LFUN_MOUSE_RELEASE:
140                 if (!cur.selection() && cmd.button() == mouse_button::button1)
141                         cur.bv().showDialog("space", params2string(params()), this);
142                 break;
143
144         default:
145                 Inset::doDispatch(cur, cmd);
146                 break;
147         }
148 }
149
150
151 bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
152         FuncStatus & status) const
153 {
154         switch (cmd.action) {
155         // we handle these
156         case LFUN_INSET_MODIFY:
157                 if (cmd.getArg(0) == "space") {
158                         InsetSpaceParams params;
159                         string2params(to_utf8(cmd.argument()), params);
160                         status.setOnOff(params_.kind == params.kind);
161                 }
162                 status.setEnabled(true);
163                 return true;
164         default:
165                 return Inset::getStatus(cur, cmd, status);
166         }
167 }
168
169
170 void InsetSpace::edit(Cursor & cur, bool, EntryDirection)
171 {
172         cur.bv().showDialog("space", params2string(params()), this);
173 }
174
175
176 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
177 {
178         if (isStretchableSpace()) {
179                 // The metrics for this kinds are calculated externally in
180                 // \c TextMetrics::computeRowMetrics. Those are dummy value:
181                 dim = Dimension(10, 10, 10);
182                 return;
183         }
184
185         frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
186         dim.asc = fm.maxAscent();
187         dim.des = fm.maxDescent();
188
189         switch (params_.kind) {
190                 case InsetSpaceParams::THIN:
191                 case InsetSpaceParams::NEGTHIN:
192                         dim.wid = fm.width(char_type('M')) / 6;
193                         break;
194                 case InsetSpaceParams::PROTECTED:
195                 case InsetSpaceParams::NORMAL:
196                         dim.wid = fm.width(char_type(' '));
197                         break;
198                 case InsetSpaceParams::QUAD:
199                         dim.wid = fm.width(char_type('M'));
200                         break;
201                 case InsetSpaceParams::QQUAD:
202                         dim.wid = 2 * fm.width(char_type('M'));
203                         break;
204                 case InsetSpaceParams::ENSPACE:
205                 case InsetSpaceParams::ENSKIP:
206                         dim.wid = int(0.5 * fm.width(char_type('M')));
207                         break;
208                 case InsetSpaceParams::CUSTOM:
209                 case InsetSpaceParams::CUSTOM_PROTECTED: {
210                         int length = params_.length.inBP();
211                         if (length < 0)
212                                 length = -1 * length;
213                         dim.wid = length;
214                         break;
215                 }
216                 case InsetSpaceParams::HFILL:
217                 case InsetSpaceParams::HFILL_PROTECTED:
218                 case InsetSpaceParams::DOTFILL:
219                 case InsetSpaceParams::HRULEFILL:
220                 case InsetSpaceParams::LEFTARROWFILL:
221                 case InsetSpaceParams::RIGHTARROWFILL:
222                 case InsetSpaceParams::UPBRACEFILL:
223                 case InsetSpaceParams::DOWNBRACEFILL:
224                         // shut up compiler
225                         break;
226         }
227         // Cache the inset dimension.
228         setDimCache(mi, dim);
229 }
230
231
232 void InsetSpace::draw(PainterInfo & pi, int x, int y) const
233 {
234         Dimension const dim = dimension(*pi.base.bv);
235
236         if (isStretchableSpace()) {
237                 int const asc = theFontMetrics(pi.base.font).ascent('M');
238                 int const desc = theFontMetrics(pi.base.font).descent('M');
239                 //Pixel height divisible by 2 for prettier fill graphics:
240                 int const oddheight = (asc ^ desc) & 1;
241                 int const x0 = x + 1;
242                 int const x1 = x + dim.wid - 2;
243                 int const y0 = y + desc - 1;
244                 int const y1 = y - asc + oddheight - 1;
245                 int const y2 = (y0 + y1) / 2;
246                 int xoffset = (y0 - y1) / 2;
247
248                 //Two tests for very narrow insets
249                 if (xoffset > x1 - x0
250                      && (params_.kind == InsetSpaceParams::LEFTARROWFILL
251                          || params_.kind == InsetSpaceParams::RIGHTARROWFILL))
252                                 xoffset = x1 - x0;
253                 if (xoffset * 6 > (x1 - x0)
254                      && (params_.kind == InsetSpaceParams::UPBRACEFILL
255                          || params_.kind == InsetSpaceParams::DOWNBRACEFILL))
256                                 xoffset = (x1 - x0) / 6;
257
258                 int const x2 = x0 + xoffset;
259                 int const x3 = x1 - xoffset;
260                 int const xm = (x0 + x1) / 2;
261                 int const xml = xm - xoffset;
262                 int const xmr = xm + xoffset;
263
264                 if (params_.kind == InsetSpaceParams::HFILL) {
265                         pi.pain.line(x0, y1, x0, y0, Color_added_space);
266                         pi.pain.line(x0, y2 , x1, y2, Color_added_space,
267                                 frontend::Painter::line_onoffdash);
268                         pi.pain.line(x1, y1, x1, y0, Color_added_space);
269                 } else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
270                         pi.pain.line(x0, y1, x0, y0, Color_latex);
271                         pi.pain.line(x0, y2 , x1, y2, Color_latex,
272                                 frontend::Painter::line_onoffdash);
273                         pi.pain.line(x1, y1, x1, y0, Color_latex);
274                 } else if (params_.kind == InsetSpaceParams::DOTFILL) {
275                         pi.pain.line(x0, y1, x0, y0, Color_special);
276                         pi.pain.line(x0, y0, x1, y0, Color_special,
277                                 frontend::Painter::line_onoffdash);
278                         pi.pain.line(x1, y1, x1, y0, Color_special);
279                 } else if (params_.kind == InsetSpaceParams::HRULEFILL) {
280                         pi.pain.line(x0, y1, x0, y0, Color_special);
281                         pi.pain.line(x0, y0, x1, y0, Color_special);
282                         pi.pain.line(x1, y1, x1, y0, Color_special);
283                 } else if (params_.kind == InsetSpaceParams::LEFTARROWFILL) {
284                         pi.pain.line(x2, y1 + 1 , x0 + 1, y2, Color_special);
285                         pi.pain.line(x0 + 1, y2 + 1 , x2, y0, Color_special);
286                         pi.pain.line(x0, y2 , x1, y2, Color_special);
287                 } else if (params_.kind == InsetSpaceParams::RIGHTARROWFILL) {
288                         pi.pain.line(x3 + 1, y1 + 1 , x1, y2, Color_special);
289                         pi.pain.line(x1, y2 + 1 , x3 + 1, y0, Color_special);
290                         pi.pain.line(x0, y2 , x1, y2, Color_special);
291                 } else if (params_.kind == InsetSpaceParams::UPBRACEFILL) {
292                         pi.pain.line(x0 + 1, y1 + 1 , x2, y2, Color_special);
293                         pi.pain.line(x2, y2 , xml, y2, Color_special);
294                         pi.pain.line(xml + 1, y2 + 1 , xm, y0, Color_special);
295                         pi.pain.line(xm + 1, y0 , xmr, y2 + 1, Color_special);
296                         pi.pain.line(xmr, y2 , x3, y2, Color_special);
297                         pi.pain.line(x3 + 1, y2 , x1, y1 + 1, Color_special);
298                 } else if (params_.kind == InsetSpaceParams::DOWNBRACEFILL) {
299                         pi.pain.line(x0 + 1, y0 , x2, y2 + 1, Color_special);
300                         pi.pain.line(x2, y2 , xml, y2, Color_special);
301                         pi.pain.line(xml + 1, y2 , xm, y1 + 1, Color_special);
302                         pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special);
303                         pi.pain.line(xmr, y2 , x3, y2, Color_special);
304                         pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special);
305                 }
306                 return;
307         }
308
309         int const w = dim.wid;
310         int const h = theFontMetrics(pi.base.font).ascent('x');
311         int xp[4], yp[4];
312
313         xp[0] = x;
314         yp[0] = y - max(h / 4, 1);
315         if (params_.kind == InsetSpaceParams::NORMAL ||
316             params_.kind == InsetSpaceParams::PROTECTED) {
317                 xp[1] = x;     yp[1] = y;
318                 xp[2] = x + w; yp[2] = y;
319         } else {
320                 xp[1] = x;     yp[1] = y + max(h / 4, 1);
321                 xp[2] = x + w; yp[2] = y + max(h / 4, 1);
322         }
323         xp[3] = x + w;
324         yp[3] = y - max(h / 4, 1);
325
326         if (params_.kind == InsetSpaceParams::PROTECTED ||
327             params_.kind == InsetSpaceParams::ENSPACE ||
328             params_.kind == InsetSpaceParams::NEGTHIN ||
329             params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
330                 pi.pain.lines(xp, yp, 4, Color_latex);
331         else
332                 pi.pain.lines(xp, yp, 4, Color_special);
333 }
334
335
336 void InsetSpaceParams::write(ostream & os) const
337 {
338         string command;
339         switch (kind) {
340         case InsetSpaceParams::NORMAL:
341                 os << "\\space{}";
342                 break;
343         case InsetSpaceParams::PROTECTED:
344                 os <<  "~";
345                 break;
346         case InsetSpaceParams::THIN:
347                 os <<  "\\thinspace{}";
348                 break;
349         case InsetSpaceParams::QUAD:
350                 os <<  "\\quad{}";
351                 break;
352         case InsetSpaceParams::QQUAD:
353                 os <<  "\\qquad{}";
354                 break;
355         case InsetSpaceParams::ENSPACE:
356                 os <<  "\\enspace{}";
357                 break;
358         case InsetSpaceParams::ENSKIP:
359                 os <<  "\\enskip{}";
360                 break;
361         case InsetSpaceParams::NEGTHIN:
362                 os <<  "\\negthinspace{}";
363                 break;
364         case InsetSpaceParams::HFILL:
365                 os <<  "\\hfill{}";
366                 break;
367         case InsetSpaceParams::HFILL_PROTECTED:
368                 os <<  "\\hspace*{\\fill}";
369                 break;
370         case InsetSpaceParams::DOTFILL:
371                 os <<  "\\dotfill{}";
372                 break;
373         case InsetSpaceParams::HRULEFILL:
374                 os <<  "\\hrulefill{}";
375                 break;
376         case InsetSpaceParams::LEFTARROWFILL:
377                 os <<  "\\leftarrowfill{}";
378                 break;
379         case InsetSpaceParams::RIGHTARROWFILL:
380                 os <<  "\\rightarrowfill{}";
381                 break;
382         case InsetSpaceParams::UPBRACEFILL:
383                 os <<  "\\upbracefill{}";
384                 break;
385         case InsetSpaceParams::DOWNBRACEFILL:
386                 os <<  "\\downbracefill{}";
387                 break;
388         case InsetSpaceParams::CUSTOM:
389                 os <<  "\\hspace{}";
390                 break;
391         case InsetSpaceParams::CUSTOM_PROTECTED:
392                 os <<  "\\hspace*{}";
393                 break;
394         }
395         
396         if (!length.empty())
397                 os << "\n\\length " << length.asString();
398 }
399
400
401 void InsetSpaceParams::read(Lexer & lex)
402 {
403         lex.setContext("InsetSpaceParams::read");
404         string command;
405         lex >> command;
406
407         if (command == "\\space{}")
408                 kind = InsetSpaceParams::NORMAL;
409         else if (command == "~")
410                 kind = InsetSpaceParams::PROTECTED;
411         else if (command == "\\thinspace{}")
412                 kind = InsetSpaceParams::THIN;
413         else if (command == "\\quad{}")
414                 kind = InsetSpaceParams::QUAD;
415         else if (command == "\\qquad{}")
416                 kind = InsetSpaceParams::QQUAD;
417         else if (command == "\\enspace{}")
418                 kind = InsetSpaceParams::ENSPACE;
419         else if (command == "\\enskip{}")
420                 kind = InsetSpaceParams::ENSKIP;
421         else if (command == "\\negthinspace{}")
422                 kind = InsetSpaceParams::NEGTHIN;
423         else if (command == "\\hfill{}")
424                 kind = InsetSpaceParams::HFILL;
425         else if (command == "\\hspace*{\\fill}")
426                 kind = InsetSpaceParams::HFILL_PROTECTED;
427         else if (command == "\\dotfill{}")
428                 kind = InsetSpaceParams::DOTFILL;
429         else if (command == "\\hrulefill{}")
430                 kind = InsetSpaceParams::HRULEFILL;
431         else if (command == "\\hspace{}")
432                 kind = InsetSpaceParams::CUSTOM;
433         else if (command == "\\leftarrowfill{}")
434                 kind = InsetSpaceParams::LEFTARROWFILL;
435         else if (command == "\\rightarrowfill{}")
436                 kind = InsetSpaceParams::RIGHTARROWFILL;
437         else if (command == "\\upbracefill{}")
438                 kind = InsetSpaceParams::UPBRACEFILL;
439         else if (command == "\\downbracefill{}")
440                 kind = InsetSpaceParams::DOWNBRACEFILL;
441         else if (command == "\\hspace*{}")
442                 kind = InsetSpaceParams::CUSTOM_PROTECTED;
443         else
444                 lex.printError("InsetSpace: Unknown kind: `$$Token'");
445
446         if (lex.checkFor("\\length"))
447                 lex >> length;
448 }
449
450
451 void InsetSpace::write(ostream & os) const
452 {
453         os << "space ";
454         params_.write(os);
455 }
456
457
458 void InsetSpace::read(Lexer & lex)
459 {
460         params_.read(lex);
461         lex >> "\\end_inset";
462 }
463
464
465 int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
466 {
467         switch (params_.kind) {
468         case InsetSpaceParams::NORMAL:
469                 os << (runparams.free_spacing ? " " : "\\ ");
470                 break;
471         case InsetSpaceParams::PROTECTED:
472                 os << (runparams.free_spacing ? ' ' : '~');
473                 break;
474         case InsetSpaceParams::THIN:
475                 os << (runparams.free_spacing ? " " : "\\,");
476                 break;
477         case InsetSpaceParams::QUAD:
478                 os << (runparams.free_spacing ? " " : "\\quad{}");
479                 break;
480         case InsetSpaceParams::QQUAD:
481                 os << (runparams.free_spacing ? " " : "\\qquad{}");
482                 break;
483         case InsetSpaceParams::ENSPACE:
484                 os << (runparams.free_spacing ? " " : "\\enspace{}");
485                 break;
486         case InsetSpaceParams::ENSKIP:
487                 os << (runparams.free_spacing ? " " : "\\enskip{}");
488                 break;
489         case InsetSpaceParams::NEGTHIN:
490                 os << (runparams.free_spacing ? " " : "\\negthinspace{}");
491                 break;
492         case InsetSpaceParams::HFILL:
493                 os << (runparams.free_spacing ? " " : "\\hfill{}");
494                 break;
495         case InsetSpaceParams::HFILL_PROTECTED:
496                 os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
497                 break;
498         case InsetSpaceParams::DOTFILL:
499                 os << (runparams.free_spacing ? " " : "\\dotfill{}");
500                 break;
501         case InsetSpaceParams::HRULEFILL:
502                 os << (runparams.free_spacing ? " " : "\\hrulefill{}");
503                 break;
504         case InsetSpaceParams::LEFTARROWFILL:
505                 os << (runparams.free_spacing ? " " : "\\leftarrowfill{}");
506                 break;
507         case InsetSpaceParams::RIGHTARROWFILL:
508                 os << (runparams.free_spacing ? " " : "\\rightarrowfill{}");
509                 break;
510         case InsetSpaceParams::UPBRACEFILL:
511                 os << (runparams.free_spacing ? " " : "\\upbracefill{}");
512                 break;
513         case InsetSpaceParams::DOWNBRACEFILL:
514                 os << (runparams.free_spacing ? " " : "\\downbracefill{}");
515                 break;
516         case InsetSpaceParams::CUSTOM:
517                 if (runparams.free_spacing)
518                         os << " ";
519                 else
520                         os << "\\hspace{" << from_ascii(params_.length.asLatexString()) << "}";
521                 break;
522         case InsetSpaceParams::CUSTOM_PROTECTED:
523                 if (runparams.free_spacing)
524                         os << " ";
525                 else
526                         os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
527                 break;
528         }
529         return 0;
530 }
531
532
533 int InsetSpace::plaintext(odocstream & os, OutputParams const &) const
534 {
535         switch (params_.kind) {
536         case InsetSpaceParams::HFILL:
537         case InsetSpaceParams::HFILL_PROTECTED:
538                 os << "     ";
539                 return 5;
540         case InsetSpaceParams::DOTFILL:
541                 os << ".....";
542                 return 5;
543         case InsetSpaceParams::HRULEFILL:
544                 os << "_____";
545                 return 5;
546         case InsetSpaceParams::LEFTARROWFILL:
547                 os << "<----";
548                 return 5;
549         case InsetSpaceParams::RIGHTARROWFILL:
550                 os << "---->";
551                 return 5;
552         case InsetSpaceParams::UPBRACEFILL:
553                 os << "\\-v-/";
554                 return 5;
555         case InsetSpaceParams::DOWNBRACEFILL:
556                 os << "/-^-\\";
557                 return 5;
558         default:
559                 os << ' ';
560                 return 1;
561         }
562 }
563
564
565 int InsetSpace::docbook(odocstream & os, OutputParams const &) const
566 {
567         switch (params_.kind) {
568         case InsetSpaceParams::NORMAL:
569         case InsetSpaceParams::QUAD:
570         case InsetSpaceParams::QQUAD:
571         case InsetSpaceParams::ENSKIP:
572                 os << " ";
573                 break;
574         case InsetSpaceParams::PROTECTED:
575         case InsetSpaceParams::ENSPACE:
576         case InsetSpaceParams::THIN:
577         case InsetSpaceParams::NEGTHIN:
578                 os << "&nbsp;";
579                 break;
580         case InsetSpaceParams::HFILL:
581         case InsetSpaceParams::HFILL_PROTECTED:
582                 os << '\n';
583         case InsetSpaceParams::DOTFILL:
584                 // FIXME
585                 os << '\n';
586         case InsetSpaceParams::HRULEFILL:
587                 // FIXME
588                 os << '\n';
589         case InsetSpaceParams::LEFTARROWFILL:
590         case InsetSpaceParams::RIGHTARROWFILL:
591         case InsetSpaceParams::UPBRACEFILL:
592         case InsetSpaceParams::DOWNBRACEFILL:
593         case InsetSpaceParams::CUSTOM:
594         case InsetSpaceParams::CUSTOM_PROTECTED:
595                 // FIXME
596                 os << '\n';
597         }
598         return 0;
599 }
600
601
602 void InsetSpace::textString(odocstream & os) const
603 {
604         plaintext(os, OutputParams(0));
605 }
606
607
608 bool InsetSpace::isStretchableSpace() const
609 {
610         return params_.kind == InsetSpaceParams::HFILL
611                 || params_.kind == InsetSpaceParams::HFILL_PROTECTED
612                 || params_.kind == InsetSpaceParams::DOTFILL
613                 || params_.kind == InsetSpaceParams::HRULEFILL
614                 || params_.kind == InsetSpaceParams::LEFTARROWFILL
615                 || params_.kind == InsetSpaceParams::RIGHTARROWFILL
616                 || params_.kind == InsetSpaceParams::UPBRACEFILL
617                 || params_.kind == InsetSpaceParams::DOWNBRACEFILL;
618 }
619
620
621 docstring InsetSpace::contextMenu(BufferView const &, int, int) const
622 {
623         return from_ascii("context-space");
624 }
625
626
627 void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
628 {
629         params = InsetSpaceParams();
630         if (in.empty())
631                 return;
632
633         istringstream data(in);
634         Lexer lex;
635         lex.setStream(data);
636         lex.setContext("InsetSpace::string2params");
637         lex >> "space";
638
639         // There are cases, such as when we are called via getStatus() from
640         // Dialog::canApply(), where we are just called with "space" rather
641         // than a full "space \type{}\n\\end_inset".
642         if (lex.isOK())
643                 params.read(lex);
644 }
645
646
647 string InsetSpace::params2string(InsetSpaceParams const & params)
648 {
649         ostringstream data;
650         data << "space" << ' ';
651         params.write(data);
652         return data.str();
653 }
654
655
656 } // namespace lyx