3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup Nielsen
7 * \author Jean-Marc Lasgouttes
8 * \author Lars Gullik Bjønnes
9 * \author Jürgen Spitzmüller
11 * Full author contact details are available in file CREDITS.
16 #include "InsetSpace.h"
18 #include "BufferView.h"
20 #include "Dimension.h"
21 #include "FuncRequest.h"
22 #include "FuncStatus.h"
24 #include "LaTeXFeatures.h"
27 #include "MetricsInfo.h"
28 #include "OutputParams.h"
29 #include "output_xhtml.h"
31 #include "support/debug.h"
32 #include "support/docstream.h"
33 #include "support/gettext.h"
34 #include "support/lassert.h"
35 #include "support/lstrings.h"
37 #include "frontends/Application.h"
38 #include "frontends/FontMetrics.h"
39 #include "frontends/Painter.h"
46 InsetSpace::InsetSpace(InsetSpaceParams const & params)
47 : Inset(0), params_(params)
51 InsetSpaceParams::Kind InsetSpace::kind() const
57 GlueLength InsetSpace::length() const
59 return params_.length;
63 docstring InsetSpace::toolTip(BufferView const &, int, int) const
66 switch (params_.kind) {
67 case InsetSpaceParams::NORMAL:
68 message = _("Interword Space");
70 case InsetSpaceParams::PROTECTED:
71 message = _("Protected Space");
73 case InsetSpaceParams::THIN:
74 message = _("Thin Space");
76 case InsetSpaceParams::MEDIUM:
77 message = _("Medium Space");
79 case InsetSpaceParams::THICK:
80 message = _("Thick Space");
82 case InsetSpaceParams::QUAD:
83 message = _("Quad Space");
85 case InsetSpaceParams::QQUAD:
86 message = _("Double Quad Space");
88 case InsetSpaceParams::ENSPACE:
89 message = _("Enspace");
91 case InsetSpaceParams::ENSKIP:
92 message = _("Enskip");
94 case InsetSpaceParams::NEGTHIN:
95 message = _("Negative Thin Space");
97 case InsetSpaceParams::NEGMEDIUM:
98 message = _("Negative Medium Space");
100 case InsetSpaceParams::NEGTHICK:
101 message = _("Negative Thick Space");
103 case InsetSpaceParams::HFILL:
104 message = _("Horizontal Fill");
106 case InsetSpaceParams::HFILL_PROTECTED:
107 message = _("Protected Horizontal Fill");
109 case InsetSpaceParams::DOTFILL:
110 message = _("Horizontal Fill (Dots)");
112 case InsetSpaceParams::HRULEFILL:
113 message = _("Horizontal Fill (Rule)");
115 case InsetSpaceParams::LEFTARROWFILL:
116 message = _("Horizontal Fill (Left Arrow)");
118 case InsetSpaceParams::RIGHTARROWFILL:
119 message = _("Horizontal Fill (Right Arrow)");
121 case InsetSpaceParams::UPBRACEFILL:
122 message = _("Horizontal Fill (Up Brace)");
124 case InsetSpaceParams::DOWNBRACEFILL:
125 message = _("Horizontal Fill (Down Brace)");
127 case InsetSpaceParams::CUSTOM:
129 message = support::bformat(_("Horizontal Space (%1$s)"),
130 from_ascii(params_.length.asString()));
132 case InsetSpaceParams::CUSTOM_PROTECTED:
134 message = support::bformat(_("Protected Horizontal Space (%1$s)"),
135 from_ascii(params_.length.asString()));
142 void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
144 switch (cmd.action()) {
146 case LFUN_INSET_MODIFY:
148 string2params(to_utf8(cmd.argument()), params_);
151 case LFUN_INSET_DIALOG_UPDATE:
152 cur.bv().updateDialog("space", params2string(params()));
156 Inset::doDispatch(cur, cmd);
162 bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
163 FuncStatus & status) const
165 switch (cmd.action()) {
167 case LFUN_INSET_MODIFY:
168 if (cmd.getArg(0) == "space") {
169 InsetSpaceParams params;
170 string2params(to_utf8(cmd.argument()), params);
171 status.setOnOff(params_.kind == params.kind);
172 status.setEnabled(true);
174 status.setEnabled(false);
177 case LFUN_INSET_DIALOG_UPDATE:
178 status.setEnabled(true);
181 return Inset::getStatus(cur, cmd, status);
187 int const arrow_size = 8;
191 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
193 if (isStretchableSpace()) {
194 // The metrics for this kinds are calculated externally in
195 // \c TextMetrics::computeRowMetrics. Those are dummy value:
196 dim = Dimension(10, 10, 10);
200 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
201 dim.asc = fm.maxAscent();
202 dim.des = fm.maxDescent();
204 switch (params_.kind) {
205 case InsetSpaceParams::THIN:
206 case InsetSpaceParams::NEGTHIN:
207 dim.wid = fm.width(char_type('M')) / 6;
209 case InsetSpaceParams::MEDIUM:
210 case InsetSpaceParams::NEGMEDIUM:
211 dim.wid = fm.width(char_type('M')) / 4;
213 case InsetSpaceParams::THICK:
214 case InsetSpaceParams::NEGTHICK:
215 dim.wid = fm.width(char_type('M')) / 2;
217 case InsetSpaceParams::PROTECTED:
218 case InsetSpaceParams::NORMAL:
219 dim.wid = fm.width(char_type(' '));
221 case InsetSpaceParams::QUAD:
222 dim.wid = fm.width(char_type('M'));
224 case InsetSpaceParams::QQUAD:
225 dim.wid = 2 * fm.width(char_type('M'));
227 case InsetSpaceParams::ENSPACE:
228 case InsetSpaceParams::ENSKIP:
229 dim.wid = int(0.5 * fm.width(char_type('M')));
231 case InsetSpaceParams::CUSTOM:
232 case InsetSpaceParams::CUSTOM_PROTECTED: {
234 params_.length.len().inPixels(mi.base.textwidth,
235 fm.width(char_type('M')));
236 int const minw = (w < 0) ? 3 * arrow_size : 4;
237 dim.wid = max(minw, abs(w));
240 case InsetSpaceParams::HFILL:
241 case InsetSpaceParams::HFILL_PROTECTED:
242 case InsetSpaceParams::DOTFILL:
243 case InsetSpaceParams::HRULEFILL:
244 case InsetSpaceParams::LEFTARROWFILL:
245 case InsetSpaceParams::RIGHTARROWFILL:
246 case InsetSpaceParams::UPBRACEFILL:
247 case InsetSpaceParams::DOWNBRACEFILL:
251 // Cache the inset dimension.
252 setDimCache(mi, dim);
256 void InsetSpace::draw(PainterInfo & pi, int x, int y) const
258 Dimension const dim = dimension(*pi.base.bv);
260 if (isStretchableSpace() || params_.length.len().value() < 0) {
261 int const asc = theFontMetrics(pi.base.font).ascent('M');
262 int const desc = theFontMetrics(pi.base.font).descent('M');
263 // Pixel height divisible by 2 for prettier fill graphics:
264 int const oddheight = (asc ^ desc) & 1;
265 int const x0 = x + 1;
266 int const x1 = x + dim.wid - 2;
267 int const y0 = y + desc - 1;
268 int const y1 = y - asc + oddheight - 1;
269 int const y2 = (y0 + y1) / 2;
270 int xoffset = (y0 - y1) / 2;
272 // Two tests for very narrow insets
273 if (xoffset > x1 - x0
274 && (params_.kind == InsetSpaceParams::LEFTARROWFILL
275 || params_.kind == InsetSpaceParams::RIGHTARROWFILL))
277 if (xoffset * 6 > (x1 - x0)
278 && (params_.kind == InsetSpaceParams::UPBRACEFILL
279 || params_.kind == InsetSpaceParams::DOWNBRACEFILL))
280 xoffset = (x1 - x0) / 6;
282 int const x2 = x0 + xoffset;
283 int const x3 = x1 - xoffset;
284 int const xm = (x0 + x1) / 2;
285 int const xml = xm - xoffset;
286 int const xmr = xm + xoffset;
288 if (params_.kind == InsetSpaceParams::HFILL) {
289 pi.pain.line(x0, y1, x0, y0, Color_added_space);
290 pi.pain.line(x0, y2, x1, y2, Color_added_space,
291 frontend::Painter::line_onoffdash);
292 pi.pain.line(x1, y1, x1, y0, Color_added_space);
293 } else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
294 pi.pain.line(x0, y1, x0, y0, Color_latex);
295 pi.pain.line(x0, y2, x1, y2, Color_latex,
296 frontend::Painter::line_onoffdash);
297 pi.pain.line(x1, y1, x1, y0, Color_latex);
298 } else if (params_.kind == InsetSpaceParams::DOTFILL) {
299 pi.pain.line(x0, y1, x0, y0, Color_special);
300 pi.pain.line(x0, y0, x1, y0, Color_special,
301 frontend::Painter::line_onoffdash);
302 pi.pain.line(x1, y1, x1, y0, Color_special);
303 } else if (params_.kind == InsetSpaceParams::HRULEFILL) {
304 pi.pain.line(x0, y1, x0, y0, Color_special);
305 pi.pain.line(x0, y0, x1, y0, Color_special);
306 pi.pain.line(x1, y1, x1, y0, Color_special);
307 } else if (params_.kind == InsetSpaceParams::LEFTARROWFILL) {
308 pi.pain.line(x2, y1 + 1 , x0 + 1, y2, Color_special);
309 pi.pain.line(x0 + 1, y2 + 1 , x2, y0, Color_special);
310 pi.pain.line(x0, y2 , x1, y2, Color_special);
311 } else if (params_.kind == InsetSpaceParams::RIGHTARROWFILL) {
312 pi.pain.line(x3 + 1, y1 + 1 , x1, y2, Color_special);
313 pi.pain.line(x1, y2 + 1 , x3 + 1, y0, Color_special);
314 pi.pain.line(x0, y2 , x1, y2, Color_special);
315 } else if (params_.kind == InsetSpaceParams::UPBRACEFILL) {
316 pi.pain.line(x0 + 1, y1 + 1 , x2, y2, Color_special);
317 pi.pain.line(x2, y2 , xml, y2, Color_special);
318 pi.pain.line(xml + 1, y2 + 1 , xm, y0, Color_special);
319 pi.pain.line(xm + 1, y0 , xmr, y2 + 1, Color_special);
320 pi.pain.line(xmr, y2 , x3, y2, Color_special);
321 pi.pain.line(x3 + 1, y2 , x1, y1 + 1, Color_special);
322 } else if (params_.kind == InsetSpaceParams::DOWNBRACEFILL) {
323 pi.pain.line(x0 + 1, y0 , x2, y2 + 1, Color_special);
324 pi.pain.line(x2, y2 , xml, y2, Color_special);
325 pi.pain.line(xml + 1, y2 , xm, y1 + 1, Color_special);
326 pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special);
327 pi.pain.line(xmr, y2 , x3, y2, Color_special);
328 pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special);
329 } else if (params_.kind == InsetSpaceParams::CUSTOM) {
330 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_special);
331 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_special);
332 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_special);
333 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_special);
334 pi.pain.line(x2, y2 , x3, y2, Color_special);
335 } else if (params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) {
336 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_latex);
337 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_latex);
338 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_latex);
339 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_latex);
340 pi.pain.line(x2, y2 , x3, y2, Color_latex);
345 int const w = dim.wid;
346 int const h = theFontMetrics(pi.base.font).ascent('x');
350 yp[0] = y - max(h / 4, 1);
351 if (params_.kind == InsetSpaceParams::NORMAL ||
352 params_.kind == InsetSpaceParams::PROTECTED) {
353 xp[1] = x; yp[1] = y;
354 xp[2] = x + w; yp[2] = y;
356 xp[1] = x; yp[1] = y + max(h / 4, 1);
357 xp[2] = x + w; yp[2] = y + max(h / 4, 1);
360 yp[3] = y - max(h / 4, 1);
362 if (params_.kind == InsetSpaceParams::PROTECTED ||
363 params_.kind == InsetSpaceParams::ENSPACE ||
364 params_.kind == InsetSpaceParams::NEGTHIN ||
365 params_.kind == InsetSpaceParams::NEGMEDIUM ||
366 params_.kind == InsetSpaceParams::NEGTHICK ||
367 params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
368 pi.pain.lines(xp, yp, 4, Color_latex);
370 pi.pain.lines(xp, yp, 4, Color_special);
374 void InsetSpaceParams::write(ostream & os) const
378 case InsetSpaceParams::NORMAL:
381 case InsetSpaceParams::PROTECTED:
384 case InsetSpaceParams::THIN:
385 os << "\\thinspace{}";
387 case InsetSpaceParams::MEDIUM:
388 os << "\\medspace{}";
390 case InsetSpaceParams::THICK:
391 os << "\\thickspace{}";
393 case InsetSpaceParams::QUAD:
396 case InsetSpaceParams::QQUAD:
399 case InsetSpaceParams::ENSPACE:
402 case InsetSpaceParams::ENSKIP:
405 case InsetSpaceParams::NEGTHIN:
406 os << "\\negthinspace{}";
408 case InsetSpaceParams::NEGMEDIUM:
409 os << "\\negmedspace{}";
411 case InsetSpaceParams::NEGTHICK:
412 os << "\\negthickspace{}";
414 case InsetSpaceParams::HFILL:
417 case InsetSpaceParams::HFILL_PROTECTED:
418 os << "\\hspace*{\\fill}";
420 case InsetSpaceParams::DOTFILL:
423 case InsetSpaceParams::HRULEFILL:
424 os << "\\hrulefill{}";
426 case InsetSpaceParams::LEFTARROWFILL:
427 os << "\\leftarrowfill{}";
429 case InsetSpaceParams::RIGHTARROWFILL:
430 os << "\\rightarrowfill{}";
432 case InsetSpaceParams::UPBRACEFILL:
433 os << "\\upbracefill{}";
435 case InsetSpaceParams::DOWNBRACEFILL:
436 os << "\\downbracefill{}";
438 case InsetSpaceParams::CUSTOM:
441 case InsetSpaceParams::CUSTOM_PROTECTED:
446 if (!length.len().empty())
447 os << "\n\\length " << length.asString();
451 void InsetSpaceParams::read(Lexer & lex)
453 lex.setContext("InsetSpaceParams::read");
457 // The tests for math might be disabled after a file format change
458 if (command == "\\space{}")
459 kind = InsetSpaceParams::NORMAL;
460 else if (command == "~")
461 kind = InsetSpaceParams::PROTECTED;
462 else if (command == "\\thinspace{}")
463 kind = InsetSpaceParams::THIN;
464 else if (math && command == "\\medspace{}")
465 kind = InsetSpaceParams::MEDIUM;
466 else if (math && command == "\\thickspace{}")
467 kind = InsetSpaceParams::THICK;
468 else if (command == "\\quad{}")
469 kind = InsetSpaceParams::QUAD;
470 else if (command == "\\qquad{}")
471 kind = InsetSpaceParams::QQUAD;
472 else if (command == "\\enspace{}")
473 kind = InsetSpaceParams::ENSPACE;
474 else if (command == "\\enskip{}")
475 kind = InsetSpaceParams::ENSKIP;
476 else if (command == "\\negthinspace{}")
477 kind = InsetSpaceParams::NEGTHIN;
478 else if (math && command == "\\negmedspace{}")
479 kind = InsetSpaceParams::NEGMEDIUM;
480 else if (math && command == "\\negthickspace{}")
481 kind = InsetSpaceParams::NEGTHICK;
482 else if (command == "\\hfill{}")
483 kind = InsetSpaceParams::HFILL;
484 else if (command == "\\hspace*{\\fill}")
485 kind = InsetSpaceParams::HFILL_PROTECTED;
486 else if (command == "\\dotfill{}")
487 kind = InsetSpaceParams::DOTFILL;
488 else if (command == "\\hrulefill{}")
489 kind = InsetSpaceParams::HRULEFILL;
490 else if (command == "\\hspace{}")
491 kind = InsetSpaceParams::CUSTOM;
492 else if (command == "\\leftarrowfill{}")
493 kind = InsetSpaceParams::LEFTARROWFILL;
494 else if (command == "\\rightarrowfill{}")
495 kind = InsetSpaceParams::RIGHTARROWFILL;
496 else if (command == "\\upbracefill{}")
497 kind = InsetSpaceParams::UPBRACEFILL;
498 else if (command == "\\downbracefill{}")
499 kind = InsetSpaceParams::DOWNBRACEFILL;
500 else if (command == "\\hspace*{}")
501 kind = InsetSpaceParams::CUSTOM_PROTECTED;
503 lex.printError("InsetSpace: Unknown kind: `$$Token'");
505 if (lex.checkFor("\\length"))
510 void InsetSpace::write(ostream & os) const
517 void InsetSpace::read(Lexer & lex)
520 lex >> "\\end_inset";
524 int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
526 switch (params_.kind) {
527 case InsetSpaceParams::NORMAL:
528 os << (runparams.free_spacing ? " " : "\\ ");
530 case InsetSpaceParams::PROTECTED:
531 if (runparams.local_font &&
532 runparams.local_font->language()->lang() == "polutonikogreek")
533 // in babel's polutonikogreek, ~ is active
534 os << (runparams.free_spacing ? " " : "\\nobreakspace{}");
536 os << (runparams.free_spacing ? ' ' : '~');
538 case InsetSpaceParams::THIN:
539 os << (runparams.free_spacing ? " " : "\\,");
541 case InsetSpaceParams::MEDIUM:
542 os << (runparams.free_spacing ? " " : "\\:");
544 case InsetSpaceParams::THICK:
545 os << (runparams.free_spacing ? " " : "\\;");
547 case InsetSpaceParams::QUAD:
548 os << (runparams.free_spacing ? " " : "\\quad{}");
550 case InsetSpaceParams::QQUAD:
551 os << (runparams.free_spacing ? " " : "\\qquad{}");
553 case InsetSpaceParams::ENSPACE:
554 os << (runparams.free_spacing ? " " : "\\enspace{}");
556 case InsetSpaceParams::ENSKIP:
557 os << (runparams.free_spacing ? " " : "\\enskip{}");
559 case InsetSpaceParams::NEGTHIN:
560 os << (runparams.free_spacing ? " " : "\\negthinspace{}");
562 case InsetSpaceParams::NEGMEDIUM:
563 os << (runparams.free_spacing ? " " : "\\negmedspace{}");
565 case InsetSpaceParams::NEGTHICK:
566 os << (runparams.free_spacing ? " " : "\\negthickspace{}");
568 case InsetSpaceParams::HFILL:
569 os << (runparams.free_spacing ? " " : "\\hfill{}");
571 case InsetSpaceParams::HFILL_PROTECTED:
572 os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
574 case InsetSpaceParams::DOTFILL:
575 os << (runparams.free_spacing ? " " : "\\dotfill{}");
577 case InsetSpaceParams::HRULEFILL:
578 os << (runparams.free_spacing ? " " : "\\hrulefill{}");
580 case InsetSpaceParams::LEFTARROWFILL:
581 os << (runparams.free_spacing ? " " : "\\leftarrowfill{}");
583 case InsetSpaceParams::RIGHTARROWFILL:
584 os << (runparams.free_spacing ? " " : "\\rightarrowfill{}");
586 case InsetSpaceParams::UPBRACEFILL:
587 os << (runparams.free_spacing ? " " : "\\upbracefill{}");
589 case InsetSpaceParams::DOWNBRACEFILL:
590 os << (runparams.free_spacing ? " " : "\\downbracefill{}");
592 case InsetSpaceParams::CUSTOM:
593 if (runparams.free_spacing)
596 os << "\\hspace{" << from_ascii(params_.length.asLatexString()) << "}";
598 case InsetSpaceParams::CUSTOM_PROTECTED:
599 if (runparams.free_spacing)
602 os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
609 int InsetSpace::plaintext(odocstream & os, OutputParams const &) const
611 switch (params_.kind) {
612 case InsetSpaceParams::HFILL:
613 case InsetSpaceParams::HFILL_PROTECTED:
616 case InsetSpaceParams::DOTFILL:
619 case InsetSpaceParams::HRULEFILL:
622 case InsetSpaceParams::LEFTARROWFILL:
625 case InsetSpaceParams::RIGHTARROWFILL:
628 case InsetSpaceParams::UPBRACEFILL:
631 case InsetSpaceParams::DOWNBRACEFILL:
641 int InsetSpace::docbook(odocstream & os, OutputParams const &) const
643 switch (params_.kind) {
644 case InsetSpaceParams::NORMAL:
645 case InsetSpaceParams::QUAD:
646 case InsetSpaceParams::QQUAD:
647 case InsetSpaceParams::ENSKIP:
650 case InsetSpaceParams::PROTECTED:
651 case InsetSpaceParams::ENSPACE:
652 case InsetSpaceParams::THIN:
653 case InsetSpaceParams::MEDIUM:
654 case InsetSpaceParams::THICK:
655 case InsetSpaceParams::NEGTHIN:
656 case InsetSpaceParams::NEGMEDIUM:
657 case InsetSpaceParams::NEGTHICK:
660 case InsetSpaceParams::HFILL:
661 case InsetSpaceParams::HFILL_PROTECTED:
663 case InsetSpaceParams::DOTFILL:
666 case InsetSpaceParams::HRULEFILL:
669 case InsetSpaceParams::LEFTARROWFILL:
670 case InsetSpaceParams::RIGHTARROWFILL:
671 case InsetSpaceParams::UPBRACEFILL:
672 case InsetSpaceParams::DOWNBRACEFILL:
673 case InsetSpaceParams::CUSTOM:
674 case InsetSpaceParams::CUSTOM_PROTECTED:
682 docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
685 switch (params_.kind) {
686 case InsetSpaceParams::NORMAL:
689 case InsetSpaceParams::ENSKIP:
690 case InsetSpaceParams::ENSPACE:
693 case InsetSpaceParams::QQUAD:
695 case InsetSpaceParams::THICK:
696 case InsetSpaceParams::QUAD:
699 case InsetSpaceParams::THIN:
702 case InsetSpaceParams::PROTECTED:
703 case InsetSpaceParams::MEDIUM:
704 case InsetSpaceParams::NEGTHIN:
705 case InsetSpaceParams::NEGMEDIUM:
706 case InsetSpaceParams::NEGTHICK:
709 case InsetSpaceParams::HFILL:
710 case InsetSpaceParams::HFILL_PROTECTED:
711 case InsetSpaceParams::DOTFILL:
712 case InsetSpaceParams::HRULEFILL:
713 case InsetSpaceParams::LEFTARROWFILL:
714 case InsetSpaceParams::RIGHTARROWFILL:
715 case InsetSpaceParams::UPBRACEFILL:
716 case InsetSpaceParams::DOWNBRACEFILL:
718 // Can we do anything with those in HTML?
720 case InsetSpaceParams::CUSTOM:
721 case InsetSpaceParams::CUSTOM_PROTECTED:
723 // Probably we could do some sort of blank span?
726 // don't escape the entities!
727 xs << XHTMLStream::ESCAPE_NONE << from_ascii(output);
732 void InsetSpace::validate(LaTeXFeatures & features) const
734 if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
735 params_.kind == InsetSpaceParams::NEGTHICK)
736 features.require("amsmath");
740 void InsetSpace::toString(odocstream & os) const
742 plaintext(os, OutputParams(0));
746 void InsetSpace::forToc(docstring & os, size_t) const
748 // There's no need to be cute here.
753 bool InsetSpace::isStretchableSpace() const
755 return params_.kind == InsetSpaceParams::HFILL
756 || params_.kind == InsetSpaceParams::HFILL_PROTECTED
757 || params_.kind == InsetSpaceParams::DOTFILL
758 || params_.kind == InsetSpaceParams::HRULEFILL
759 || params_.kind == InsetSpaceParams::LEFTARROWFILL
760 || params_.kind == InsetSpaceParams::RIGHTARROWFILL
761 || params_.kind == InsetSpaceParams::UPBRACEFILL
762 || params_.kind == InsetSpaceParams::DOWNBRACEFILL;
766 docstring InsetSpace::contextMenuName() const
768 return from_ascii("context-space");
772 void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
774 params = InsetSpaceParams();
778 istringstream data(in);
781 lex.setContext("InsetSpace::string2params");
783 string const name = lex.getString();
784 if (name == "mathspace")
788 LASSERT(name == "space", /**/);
791 // There are cases, such as when we are called via getStatus() from
792 // Dialog::canApply(), where we are just called with "space" rather
793 // than a full "space \type{}\n\\end_inset".
799 string InsetSpace::params2string(InsetSpaceParams const & params)
804 data << "space" << ' ';