]> git.lyx.org Git - lyx.git/blob - src/lyxlayout.C
don't draw invisible things...
[lyx.git] / src / lyxlayout.C
1
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1995 Matthias Ettrich
8  *          Copyright 1995-2001 The LyX Team.
9  *
10  * ======================================================
11  */
12
13 #include <config.h>
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "lyxlayout.h"
20 #include "lyxtextclass.h"
21 #include "lyxlex.h"
22 #include "debug.h"
23
24 #include "support/lstrings.h"
25
26 using std::endl;
27
28 //  The order of the LayoutTags enum is no more important. [asierra300396]
29 // Tags indexes.
30 enum LayoutTags {
31         LT_ALIGN = 1, 
32         LT_ALIGNPOSSIBLE, 
33         LT_MARGIN, 
34         LT_BOTTOMSEP, 
35         LT_COPYSTYLE, 
36         LT_OBSOLETEDBY, 
37         //LT_EMPTY,
38         LT_END, 
39         //LT_ENVIRONMENT_DEFAULT, 
40         //LT_FANCYHDR,
41         LT_FILL_BOTTOM, 
42         LT_FILL_TOP, 
43         //LT_FIRST_COUNTER,
44         LT_FONT, 
45         LT_FREE_SPACING, 
46         LT_PASS_THRU,
47         //LT_HEADINGS,
48         LT_ITEMSEP, 
49         LT_KEEPEMPTY, 
50         LT_LABEL_BOTTOMSEP, 
51         LT_LABELFONT, 
52         LT_TEXTFONT,
53         LT_LABELINDENT, 
54         LT_LABELSEP, 
55         LT_LABELSTRING, 
56         LT_LABELSTRING_APPENDIX, 
57         LT_LABELTYPE,
58         LT_ENDLABELSTRING,
59         LT_ENDLABELTYPE,
60         LT_LATEXNAME, 
61         LT_LATEXPARAM, 
62         LT_LATEXTYPE, 
63         LT_LEFTMARGIN, 
64         LT_NEED_PROTECT, 
65         LT_NEWLINE, 
66         LT_NEXTNOINDENT, 
67         LT_PARINDENT, 
68         LT_PARSEP, 
69         LT_PARSKIP, 
70         //LT_PLAIN,
71         LT_PREAMBLE, 
72         LT_RIGHTMARGIN, 
73         LT_SPACING, 
74         LT_TOPSEP, 
75         LT_INTITLE 
76 };
77
78 /////////////////////
79
80 // Constructor for layout
81 LyXLayout::LyXLayout ()
82 {
83         margintype = MARGIN_STATIC;
84         latextype = LATEX_PARAGRAPH;
85         intitle = false;
86         needprotect = false;
87         keepempty = false;
88         font = LyXFont(LyXFont::ALL_INHERIT);
89         labelfont = LyXFont(LyXFont::ALL_INHERIT);
90         resfont = LyXFont(LyXFont::ALL_SANE);
91         reslabelfont = LyXFont(LyXFont::ALL_SANE);
92         nextnoindent = false;
93         parskip = 0.0;
94         itemsep = 0;
95         topsep = 0.0;
96         bottomsep = 0.0;
97         labelbottomsep = 0.0;
98         parsep = 0;
99         align = LYX_ALIGN_BLOCK;
100         alignpossible = LYX_ALIGN_BLOCK;
101         labeltype = LABEL_NO_LABEL;
102         endlabeltype = END_LABEL_NO_LABEL;
103         // Should or should not. That is the question.
104         // spacing.set(Spacing::OneHalf);
105         fill_top = false;
106         fill_bottom = false;
107         newline_allowed = true;
108         free_spacing = false;
109         pass_thru = false;
110 }
111
112
113 // Reads a layout definition from file
114 bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
115 {
116         // This table is sorted alphabetically [asierra 30March96]
117         keyword_item layoutTags[] = {
118                 { "align",                      LT_ALIGN },
119                 { "alignpossible",              LT_ALIGNPOSSIBLE },
120                 { "bottomsep",                  LT_BOTTOMSEP },
121                 { "copystyle",                  LT_COPYSTYLE },
122                 { "end",                        LT_END },
123                 { "endlabelstring",             LT_ENDLABELSTRING },
124                 { "endlabeltype",               LT_ENDLABELTYPE },
125                 { "fill_bottom",                LT_FILL_BOTTOM },
126                 { "fill_top",                   LT_FILL_TOP },
127                 { "font",                       LT_FONT },
128                 { "freespacing",                LT_FREE_SPACING },
129                 { "intitle",                    LT_INTITLE },
130                 { "itemsep",                    LT_ITEMSEP },
131                 { "keepempty",                  LT_KEEPEMPTY },
132                 { "labelbottomsep",             LT_LABEL_BOTTOMSEP },
133                 { "labelfont",                  LT_LABELFONT },
134                 { "labelindent",                LT_LABELINDENT },
135                 { "labelsep",                   LT_LABELSEP },
136                 { "labelstring",                LT_LABELSTRING },
137                 { "labelstringappendix",        LT_LABELSTRING_APPENDIX },
138                 { "labeltype",                  LT_LABELTYPE },
139                 { "latexname",                  LT_LATEXNAME },
140                 { "latexparam",                 LT_LATEXPARAM },
141                 { "latextype",                  LT_LATEXTYPE },
142                 { "leftmargin",                 LT_LEFTMARGIN },
143                 { "margin",                     LT_MARGIN },
144                 { "needprotect",                LT_NEED_PROTECT },
145                 { "newline",                    LT_NEWLINE },
146                 { "nextnoindent",               LT_NEXTNOINDENT },
147                 { "obsoletedby",                LT_OBSOLETEDBY },
148                 { "parindent",                  LT_PARINDENT },
149                 { "parsep",                     LT_PARSEP },
150                 { "parskip",                    LT_PARSKIP },
151                 { "passthru",                   LT_PASS_THRU },
152                 { "preamble",                   LT_PREAMBLE },
153                 { "rightmargin",                LT_RIGHTMARGIN },
154                 { "spacing",                    LT_SPACING },
155                 { "textfont",                   LT_TEXTFONT },
156                 { "topsep",                     LT_TOPSEP }
157         };
158
159         bool error = false;
160         bool finished = false;
161         lexrc.pushTable(layoutTags, LT_INTITLE);
162         // parse style section
163         while (!finished && lexrc.isOK() && !error) {
164                 int le = lexrc.lex();
165                 // See comment in lyxrc.C.
166                 switch (le) {
167                 case LyXLex::LEX_FEOF:
168                         continue; 
169
170                 case LyXLex::LEX_UNDEF:         // parse error
171                         lexrc.printError("Unknown layout tag `$$Token'");
172                         error = true;
173                         continue; 
174                 default: break;
175                 }
176                 switch (static_cast<LayoutTags>(le)) {
177                 case LT_END:            // end of structure
178                         finished = true;
179                         break;
180
181                 case LT_COPYSTYLE:     // initialize with a known style
182                         if (lexrc.next()) {
183                                 string const style = lexrc.getString();
184                         
185                                 if (tclass.hasLayout(style)) {
186                                         string const tmpname = name_;
187                                         this->operator=(tclass[style]);
188                                         name_ = tmpname;
189                                 } else {
190                                         lyxerr << "Cannot copy unknown style `" << style << "'" << endl;
191                                         LyXTextClass::const_iterator it = tclass.begin();
192                                         LyXTextClass::const_iterator end = tclass.end();
193                                         lyxerr << "All layouts so far:" << endl;
194                                         for (; it != end; ++it) {
195                                                 lyxerr << it->name() << endl;
196                                         }
197                                         
198                                         //lexrc.printError("Cannot copy known "
199                                         //               "style `$$Token'");
200                                 }
201                         }
202                         break;
203
204                 case LT_OBSOLETEDBY:     // replace with a known style
205                         if (lexrc.next()) {
206                                 string const style = lexrc.getString();
207                                 
208                                 if (tclass.hasLayout(style)) {
209                                         string const tmpname = name_;
210                                         this->operator=(tclass[style]);
211                                         name_ = tmpname;
212                                         if (obsoleted_by().empty())
213                                                 obsoleted_by_ = style;
214                                 } else {
215                                         lyxerr << "Cannot replace with unknown style `" << style << "'" << endl;
216                                         
217                                         //lexrc.printError("Cannot replace with" 
218                                         //               " unknown style "
219                                         //               "`$$Token'");
220                                 }
221                         }
222                         break;
223
224                 case LT_MARGIN:         // Margin style definition.
225                         readMargin(lexrc);
226                         break;
227
228                 case LT_LATEXTYPE:      // Latex style definition.
229                         readLatexType(lexrc);
230                         break;
231
232                 case LT_INTITLE:
233                         intitle = lexrc.next() && lexrc.getInteger();
234                         break;
235                         
236                 case LT_NEED_PROTECT:
237                         needprotect = lexrc.next() && lexrc.getInteger();
238                         break;
239                         
240                 case LT_KEEPEMPTY:
241                         keepempty = lexrc.next() && lexrc.getInteger();
242                         break;
243
244                 case LT_FONT:
245                         font.lyxRead(lexrc);
246                         labelfont= font;
247                         break;
248
249                 case LT_TEXTFONT:
250                         font.lyxRead(lexrc);
251                         break;
252
253                 case LT_LABELFONT:
254                         labelfont.lyxRead(lexrc);
255                         break;
256
257                 case LT_NEXTNOINDENT:   // Indent next paragraph?
258                         if (lexrc.next() && lexrc.getInteger())
259                                 nextnoindent = true;
260                         else
261                                 nextnoindent = false;
262                         break;
263
264                 case LT_LATEXNAME:
265                         if (lexrc.next())
266                                 latexname_ = lexrc.getString();
267                         break;
268                         
269                 case LT_LATEXPARAM:
270                         if (lexrc.next())
271                                 latexparam_ = lexrc.getString();
272                         break;
273
274                 case LT_PREAMBLE:
275                         preamble_ = lexrc.getLongString("EndPreamble");
276                         break;
277
278                 case LT_LABELTYPE:
279                         readLabelType(lexrc);
280                         break;
281
282                 case LT_ENDLABELTYPE:
283                         readEndLabelType(lexrc);
284                         break;
285                         
286                 case LT_LEFTMARGIN:     // left margin type
287                         if (lexrc.next())
288                                 leftmargin = lexrc.getString();
289                         break;                  
290
291                 case LT_RIGHTMARGIN:    // right margin type
292                         if (lexrc.next())
293                                 rightmargin = lexrc.getString();
294                         break;
295
296                 case LT_LABELINDENT:    // label indenting flag
297                         if (lexrc.next())
298                                 labelindent = lexrc.getString();
299                         break;
300
301                 case LT_PARINDENT:      // paragraph indent. flag
302                         if (lexrc.next())
303                                 parindent = lexrc.getString();
304                         break;
305
306                 case LT_PARSKIP:        // paragraph skip size
307                         if (lexrc.next())
308                                 parskip = lexrc.getFloat();
309                         break;
310
311                 case LT_ITEMSEP:        // item separation size
312                         if (lexrc.next())
313                                 itemsep = lexrc.getFloat();
314                         break;
315
316                 case LT_TOPSEP:         // top separation size
317                         if (lexrc.next())
318                                 topsep = lexrc.getFloat();
319                         break;
320
321                 case LT_BOTTOMSEP:      // bottom separation size
322                         if (lexrc.next())
323                                 bottomsep = lexrc.getFloat();
324                         break;
325
326                 case LT_LABEL_BOTTOMSEP: // label bottom separation size
327                         if (lexrc.next())
328                                 labelbottomsep = lexrc.getFloat();
329                         break;
330
331                 case LT_LABELSEP:       // label separator
332                         if (lexrc.next()) {
333                                 labelsep = subst(lexrc.getString(), 'x', ' ');
334                         }
335                         break;
336
337                 case LT_PARSEP:         // par. separation size
338                         if (lexrc.next())
339                                 parsep = lexrc.getFloat();
340                         break;
341
342                 case LT_FILL_TOP:       // fill top flag
343                         if (lexrc.next())
344                                 fill_top = lexrc.getInteger();
345                         break;
346
347                 case LT_FILL_BOTTOM:    // fill bottom flag
348                         if (lexrc.next())
349                                 fill_bottom = lexrc.getInteger();
350                         break;
351
352                 case LT_NEWLINE:        // newlines allowed?
353                         if (lexrc.next())
354                                 newline_allowed = lexrc.getInteger();
355                         break;
356
357                 case LT_ALIGN:          // paragraph align
358                         readAlign(lexrc);
359                         break;
360                 case LT_ALIGNPOSSIBLE:  // paragraph allowed align
361                         readAlignPossible(lexrc);
362                         break;
363
364                 case LT_LABELSTRING:    // label string definition
365                         if (lexrc.next())
366                                 labelstring_ = lexrc.getString();
367                         break;
368
369                 case LT_ENDLABELSTRING: // endlabel string definition
370                         if (lexrc.next())
371                                 endlabelstring_ = lexrc.getString();
372                         break;
373
374                 case LT_LABELSTRING_APPENDIX: // label string appendix definition
375                         if (lexrc.next())
376                                 labelstring_appendix_ = lexrc.getString();
377                         break;
378
379                 case LT_FREE_SPACING:   // Allow for free spacing.
380                         if (lexrc.next())
381                                 free_spacing = lexrc.getInteger();
382                         break;
383
384                 case LT_PASS_THRU:      // Allow for pass thru.
385                         if (lexrc.next())
386                                 pass_thru = lexrc.getInteger();
387                         break;
388
389                 case LT_SPACING: // setspace.sty
390                         readSpacing(lexrc);
391                         break;
392                 }
393         }
394         lexrc.popTable();
395         return error;
396 }
397
398
399 enum AlignTags {
400         AT_BLOCK = 1,
401         AT_LEFT,
402         AT_RIGHT,
403         AT_CENTER,
404         AT_LAYOUT
405 };
406
407
408 void LyXLayout::readAlign(LyXLex & lexrc)
409 {
410         keyword_item alignTags[] = {
411                 { "block",  AT_BLOCK },
412                 { "center", AT_CENTER },
413                 { "layout", AT_LAYOUT },
414                 { "left",   AT_LEFT },
415                 { "right",  AT_RIGHT }
416         };
417
418         pushpophelper pph(lexrc, alignTags, AT_LAYOUT);
419         int le = lexrc.lex();
420         switch (le) {
421         case LyXLex::LEX_UNDEF:
422                 lexrc.printError("Unknown alignment `$$Token'");
423                 return; 
424         default: break;
425         };
426         switch (static_cast<AlignTags>(le)) {
427         case AT_BLOCK:
428                 align = LYX_ALIGN_BLOCK;
429                 break;
430         case AT_LEFT:
431                 align = LYX_ALIGN_LEFT;
432                 break;
433         case AT_RIGHT:
434                 align = LYX_ALIGN_RIGHT;
435                 break;
436         case AT_CENTER:
437                 align = LYX_ALIGN_CENTER;
438                 break;
439         case AT_LAYOUT:
440                 align = LYX_ALIGN_LAYOUT;
441                 break;
442         }
443 }
444
445
446 void LyXLayout::readAlignPossible(LyXLex & lexrc)
447 {
448         keyword_item alignTags[] = {
449                 { "block",  AT_BLOCK },
450                 { "center", AT_CENTER },
451                 { "layout", AT_LAYOUT },
452                 { "left",   AT_LEFT },
453                 { "right",  AT_RIGHT }
454         };
455
456         lexrc.pushTable(alignTags, AT_LAYOUT);
457         alignpossible = LYX_ALIGN_NONE;
458         int lineno = lexrc.getLineNo();
459         do {
460                 int le = lexrc.lex();
461                 switch (le) {
462                 case LyXLex::LEX_UNDEF:
463                         lexrc.printError("Unknown alignment `$$Token'");
464                         continue; 
465                 default: break;
466                 };
467                 switch (static_cast<AlignTags>(le)) {
468                 case AT_BLOCK:
469                         alignpossible |= LYX_ALIGN_BLOCK;
470                         break;
471                 case AT_LEFT:
472                         alignpossible |= LYX_ALIGN_LEFT;
473                         break;
474                 case AT_RIGHT:
475                         alignpossible |= LYX_ALIGN_RIGHT;
476                         break;
477                 case AT_CENTER:
478                         alignpossible |= LYX_ALIGN_CENTER;
479                         break;
480                 case AT_LAYOUT:
481                         alignpossible |= LYX_ALIGN_LAYOUT;
482                         break;
483                 }
484         } while (lineno == lexrc.getLineNo());
485         lexrc.popTable();
486 }
487
488
489 enum LabelTypeTags {
490         LA_NO_LABEL = 1,
491         LA_MANUAL,
492         LA_TOP_ENVIRONMENT,
493         LA_CENTERED_TOP_ENVIRONMENT,
494         LA_STATIC,
495         LA_SENSITIVE,
496         LA_COUNTER_CHAPTER,
497         LA_COUNTER_SECTION,
498         LA_COUNTER_SUBSECTION,
499         LA_COUNTER_SUBSUBSECTION,
500         LA_COUNTER_PARAGRAPH,
501         LA_COUNTER_SUBPARAGRAPH,
502         LA_COUNTER_ENUMI,
503         LA_COUNTER_ENUMII,
504         LA_COUNTER_ENUMIII,
505         LA_COUNTER_ENUMIV,
506         LA_BIBLIO
507 };
508
509
510 void LyXLayout::readLabelType(LyXLex & lexrc)
511 {
512         keyword_item labelTypeTags[] = {
513         { "bibliography",             LA_BIBLIO },
514         { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
515         { "counter_chapter",          LA_COUNTER_CHAPTER },
516         { "counter_enumi",            LA_COUNTER_ENUMI },
517         { "counter_enumii",           LA_COUNTER_ENUMII },
518         { "counter_enumiii",          LA_COUNTER_ENUMIII },
519         { "counter_enumiv",           LA_COUNTER_ENUMIV },
520         { "counter_paragraph",        LA_COUNTER_PARAGRAPH },
521         { "counter_section",          LA_COUNTER_SECTION },
522         { "counter_subparagraph",     LA_COUNTER_SUBPARAGRAPH },
523         { "counter_subsection",       LA_COUNTER_SUBSECTION },
524         { "counter_subsubsection",    LA_COUNTER_SUBSUBSECTION },
525         { "manual",                   LA_MANUAL },
526         { "no_label",                 LA_NO_LABEL },
527         { "sensitive",                LA_SENSITIVE },
528         { "static",                   LA_STATIC },
529         { "top_environment",          LA_TOP_ENVIRONMENT }
530 };
531
532         pushpophelper pph(lexrc, labelTypeTags, LA_BIBLIO);
533         int le = lexrc.lex();
534         switch (le) {
535         case LyXLex::LEX_UNDEF:
536                 lexrc.printError("Unknown labeltype tag `$$Token'");
537                 return; 
538         default: break;
539         }
540         switch (static_cast<LabelTypeTags>(le)) {
541         case LA_NO_LABEL:
542                 labeltype = LABEL_NO_LABEL;
543                 break;
544         case LA_MANUAL:
545                 labeltype = LABEL_MANUAL;
546                 break;
547         case LA_TOP_ENVIRONMENT:
548                 labeltype = LABEL_TOP_ENVIRONMENT;
549                 break;
550         case LA_CENTERED_TOP_ENVIRONMENT:
551                 labeltype = LABEL_CENTERED_TOP_ENVIRONMENT;
552                 break;
553         case LA_STATIC:
554                 labeltype = LABEL_STATIC;
555                 break;
556         case LA_SENSITIVE:
557                 labeltype = LABEL_SENSITIVE;
558                 break;
559         case LA_COUNTER_CHAPTER:
560                 labeltype = LABEL_COUNTER_CHAPTER;
561                 break;
562         case LA_COUNTER_SECTION:
563                 labeltype = LABEL_COUNTER_SECTION;
564                 break;
565         case LA_COUNTER_SUBSECTION:
566                 labeltype = LABEL_COUNTER_SUBSECTION;
567                 break;
568         case LA_COUNTER_SUBSUBSECTION:
569                 labeltype = LABEL_COUNTER_SUBSUBSECTION;
570                 break;
571         case LA_COUNTER_PARAGRAPH:
572                 labeltype = LABEL_COUNTER_PARAGRAPH;
573                 break;
574         case LA_COUNTER_SUBPARAGRAPH:
575                 labeltype = LABEL_COUNTER_SUBPARAGRAPH;
576                 break;
577         case LA_COUNTER_ENUMI:
578                 labeltype = LABEL_COUNTER_ENUMI;
579                 break;
580         case LA_COUNTER_ENUMII:
581                 labeltype = LABEL_COUNTER_ENUMII;
582                 break;
583         case LA_COUNTER_ENUMIII:
584                 labeltype = LABEL_COUNTER_ENUMIII;
585                 break;
586         case LA_COUNTER_ENUMIV:
587                 labeltype = LABEL_COUNTER_ENUMIV;
588                 break;
589         case LA_BIBLIO:
590                 labeltype = LABEL_BIBLIO;
591                 break;
592         }
593 }
594
595
596 namespace {
597
598 keyword_item endlabelTypeTags[] = {
599         { "box",        END_LABEL_BOX },
600         { "filled_box", END_LABEL_FILLED_BOX },
601         { "no_label",   END_LABEL_NO_LABEL },
602         { "static",     END_LABEL_STATIC }
603 };
604
605 } // namespace anon
606
607
608 void LyXLayout::readEndLabelType(LyXLex & lexrc)
609 {
610         pushpophelper pph(lexrc, endlabelTypeTags,
611                           END_LABEL_ENUM_LAST-END_LABEL_ENUM_FIRST+1);
612         int le = lexrc.lex();
613         switch (le) {
614         case LyXLex::LEX_UNDEF:
615                 lexrc.printError("Unknown labeltype tag `$$Token'");
616                 break;
617         case END_LABEL_STATIC:
618         case END_LABEL_BOX:
619         case END_LABEL_FILLED_BOX:
620         case END_LABEL_NO_LABEL:
621                 endlabeltype = static_cast<LYX_END_LABEL_TYPES>(le);
622                 break;
623         default:
624                 lyxerr << "Unhandled value " << le
625                        << " in LyXLayout::readEndLabelType." << endl;
626                 break;
627         }
628 }
629
630
631 void LyXLayout::readMargin(LyXLex & lexrc)
632 {
633         keyword_item marginTags[] = {
634                 { "dynamic",           MARGIN_DYNAMIC },
635                 { "first_dynamic",     MARGIN_FIRST_DYNAMIC },
636                 { "manual",            MARGIN_MANUAL },
637                 { "right_address_box", MARGIN_RIGHT_ADDRESS_BOX },
638                 { "static",            MARGIN_STATIC }
639         };
640
641         pushpophelper pph(lexrc, marginTags, MARGIN_RIGHT_ADDRESS_BOX);
642
643         int le = lexrc.lex();
644         switch (le) {
645         case LyXLex::LEX_UNDEF:
646                 lexrc.printError("Unknown margin type tag `$$Token'");
647                 return;
648         case MARGIN_STATIC:
649         case MARGIN_MANUAL:
650         case MARGIN_DYNAMIC:
651         case MARGIN_FIRST_DYNAMIC:
652         case MARGIN_RIGHT_ADDRESS_BOX:
653                 margintype = static_cast<LYX_MARGIN_TYPE>(le);
654                 break;
655         default:
656                 lyxerr << "Unhandled value " << le
657                        << " in LyXLayout::readMargin." << endl;
658                 break;
659         }
660 }
661
662
663 void LyXLayout::readLatexType(LyXLex & lexrc)
664 {
665         keyword_item latexTypeTags[] = {
666                 { "command",          LATEX_COMMAND },
667                 { "environment",      LATEX_ENVIRONMENT },
668                 { "item_environment", LATEX_ITEM_ENVIRONMENT },
669                 { "list_environment", LATEX_LIST_ENVIRONMENT },
670                 { "paragraph",        LATEX_PARAGRAPH }
671         };
672
673         pushpophelper pph(lexrc, latexTypeTags, LATEX_LIST_ENVIRONMENT);
674         int le = lexrc.lex();
675         switch (le) {
676         case LyXLex::LEX_UNDEF:
677                 lexrc.printError("Unknown latextype tag `$$Token'");
678                 return;
679         case LATEX_PARAGRAPH:
680         case LATEX_COMMAND:
681         case LATEX_ENVIRONMENT:
682         case LATEX_ITEM_ENVIRONMENT:
683         case LATEX_LIST_ENVIRONMENT:
684                 latextype = static_cast<LYX_LATEX_TYPES>(le);
685                 break;
686         default:
687                 lyxerr << "Unhandled value " << le
688                        << " in LyXLayout::readLatexType." << endl;
689                 break;
690         }
691 }
692
693
694 enum SpacingTags {
695         ST_SPACING_SINGLE = 1,
696         ST_SPACING_ONEHALF,
697         ST_SPACING_DOUBLE,
698         ST_OTHER
699 };
700
701
702 void LyXLayout::readSpacing(LyXLex & lexrc)
703 {
704         keyword_item spacingTags[] = {
705                 {"double",  ST_SPACING_DOUBLE },
706                 {"onehalf", ST_SPACING_ONEHALF },
707                 {"other",   ST_OTHER },
708                 {"single",  ST_SPACING_SINGLE }
709         };
710
711         pushpophelper pph(lexrc, spacingTags, ST_OTHER);
712         int le = lexrc.lex();
713         switch (le) {
714         case LyXLex::LEX_UNDEF:
715                 lexrc.printError("Unknown spacing token `$$Token'");
716                 return;
717         default: break;
718         }
719         switch (static_cast<SpacingTags>(le)) {
720         case ST_SPACING_SINGLE:
721                 spacing.set(Spacing::Single);
722                 break;
723         case ST_SPACING_ONEHALF:
724                 spacing.set(Spacing::Onehalf);
725                 break;
726         case ST_SPACING_DOUBLE:
727                 spacing.set(Spacing::Double);
728                 break;
729         case ST_OTHER:
730                 lexrc.next();
731                 spacing.set(Spacing::Other, lexrc.getFloat());
732                 break;
733         }
734 }
735
736
737 string const & LyXLayout::name() const
738 {
739         return name_;
740 }
741
742
743 void LyXLayout::setName(string const & n)
744 {
745         name_ = n;
746 }
747
748
749 string const & LyXLayout::obsoleted_by() const
750 {
751         return obsoleted_by_;
752 }