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