]> git.lyx.org Git - lyx.git/blob - src/lyxlayout.C
redraw fix 1.
[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 `"
190                                                << style << "'\n"
191                                                << "All layouts so far:"
192                                                << endl;
193                                         LyXTextClass::const_iterator it =
194                                                 tclass.begin();
195                                         LyXTextClass::const_iterator end =
196                                                 tclass.end();
197                                         for (; it != end; ++it) {
198                                                 lyxerr << (*it)->name()
199                                                        << endl;
200                                         }
201
202                                         //lexrc.printError("Cannot copy known "
203                                         //               "style `$$Token'");
204                                 }
205                         }
206                         break;
207
208                 case LT_OBSOLETEDBY:     // replace with a known style
209                         if (lexrc.next()) {
210                                 string const style = lexrc.getString();
211
212                                 if (tclass.hasLayout(style)) {
213                                         string const tmpname = name_;
214                                         this->operator=(*tclass[style]);
215                                         name_ = tmpname;
216                                         if (obsoleted_by().empty())
217                                                 obsoleted_by_ = style;
218                                 } else {
219                                         lyxerr << "Cannot replace with unknown style `" << style << "'" << endl;
220
221                                         //lexrc.printError("Cannot replace with"
222                                         //               " unknown style "
223                                         //               "`$$Token'");
224                                 }
225                         }
226                         break;
227
228                 case LT_MARGIN:         // Margin style definition.
229                         readMargin(lexrc);
230                         break;
231
232                 case LT_LATEXTYPE:      // Latex style definition.
233                         readLatexType(lexrc);
234                         break;
235
236                 case LT_INTITLE:
237                         intitle = lexrc.next() && lexrc.getInteger();
238                         break;
239
240                 case LT_NEED_PROTECT:
241                         needprotect = lexrc.next() && lexrc.getInteger();
242                         break;
243
244                 case LT_KEEPEMPTY:
245                         keepempty = lexrc.next() && lexrc.getInteger();
246                         break;
247
248                 case LT_FONT:
249                         font.lyxRead(lexrc);
250                         labelfont= font;
251                         break;
252
253                 case LT_TEXTFONT:
254                         font.lyxRead(lexrc);
255                         break;
256
257                 case LT_LABELFONT:
258                         labelfont.lyxRead(lexrc);
259                         break;
260
261                 case LT_NEXTNOINDENT:   // Indent next paragraph?
262                         if (lexrc.next() && lexrc.getInteger())
263                                 nextnoindent = true;
264                         else
265                                 nextnoindent = false;
266                         break;
267
268                 case LT_LATEXNAME:
269                         if (lexrc.next())
270                                 latexname_ = lexrc.getString();
271                         break;
272
273                 case LT_LATEXPARAM:
274                         if (lexrc.next())
275                                 latexparam_ = lexrc.getString();
276                         break;
277
278                 case LT_PREAMBLE:
279                         preamble_ = lexrc.getLongString("EndPreamble");
280                         break;
281
282                 case LT_LABELTYPE:
283                         readLabelType(lexrc);
284                         break;
285
286                 case LT_ENDLABELTYPE:
287                         readEndLabelType(lexrc);
288                         break;
289
290                 case LT_LEFTMARGIN:     // left margin type
291                         if (lexrc.next())
292                                 leftmargin = lexrc.getString();
293                         break;
294
295                 case LT_RIGHTMARGIN:    // right margin type
296                         if (lexrc.next())
297                                 rightmargin = lexrc.getString();
298                         break;
299
300                 case LT_LABELINDENT:    // label indenting flag
301                         if (lexrc.next())
302                                 labelindent = lexrc.getString();
303                         break;
304
305                 case LT_PARINDENT:      // paragraph indent. flag
306                         if (lexrc.next())
307                                 parindent = lexrc.getString();
308                         break;
309
310                 case LT_PARSKIP:        // paragraph skip size
311                         if (lexrc.next())
312                                 parskip = lexrc.getFloat();
313                         break;
314
315                 case LT_ITEMSEP:        // item separation size
316                         if (lexrc.next())
317                                 itemsep = lexrc.getFloat();
318                         break;
319
320                 case LT_TOPSEP:         // top separation size
321                         if (lexrc.next())
322                                 topsep = lexrc.getFloat();
323                         break;
324
325                 case LT_BOTTOMSEP:      // bottom separation size
326                         if (lexrc.next())
327                                 bottomsep = lexrc.getFloat();
328                         break;
329
330                 case LT_LABEL_BOTTOMSEP: // label bottom separation size
331                         if (lexrc.next())
332                                 labelbottomsep = lexrc.getFloat();
333                         break;
334
335                 case LT_LABELSEP:       // label separator
336                         if (lexrc.next()) {
337                                 labelsep = subst(lexrc.getString(), 'x', ' ');
338                         }
339                         break;
340
341                 case LT_PARSEP:         // par. separation size
342                         if (lexrc.next())
343                                 parsep = lexrc.getFloat();
344                         break;
345
346                 case LT_FILL_TOP:       // fill top flag
347                         if (lexrc.next())
348                                 fill_top = lexrc.getInteger();
349                         break;
350
351                 case LT_FILL_BOTTOM:    // fill bottom flag
352                         if (lexrc.next())
353                                 fill_bottom = lexrc.getInteger();
354                         break;
355
356                 case LT_NEWLINE:        // newlines allowed?
357                         if (lexrc.next())
358                                 newline_allowed = lexrc.getInteger();
359                         break;
360
361                 case LT_ALIGN:          // paragraph align
362                         readAlign(lexrc);
363                         break;
364                 case LT_ALIGNPOSSIBLE:  // paragraph allowed align
365                         readAlignPossible(lexrc);
366                         break;
367
368                 case LT_LABELSTRING:    // label string definition
369                         if (lexrc.next())
370                                 labelstring_ = lexrc.getString();
371                         break;
372
373                 case LT_ENDLABELSTRING: // endlabel string definition
374                         if (lexrc.next())
375                                 endlabelstring_ = lexrc.getString();
376                         break;
377
378                 case LT_LABELSTRING_APPENDIX: // label string appendix definition
379                         if (lexrc.next())
380                                 labelstring_appendix_ = lexrc.getString();
381                         break;
382
383                 case LT_FREE_SPACING:   // Allow for free spacing.
384                         if (lexrc.next())
385                                 free_spacing = lexrc.getInteger();
386                         break;
387
388                 case LT_PASS_THRU:      // Allow for pass thru.
389                         if (lexrc.next())
390                                 pass_thru = lexrc.getInteger();
391                         break;
392
393                 case LT_SPACING: // setspace.sty
394                         readSpacing(lexrc);
395                         break;
396                 }
397         }
398         lexrc.popTable();
399         return error;
400 }
401
402
403 enum AlignTags {
404         AT_BLOCK = 1,
405         AT_LEFT,
406         AT_RIGHT,
407         AT_CENTER,
408         AT_LAYOUT
409 };
410
411
412 void LyXLayout::readAlign(LyXLex & lexrc)
413 {
414         keyword_item alignTags[] = {
415                 { "block",  AT_BLOCK },
416                 { "center", AT_CENTER },
417                 { "layout", AT_LAYOUT },
418                 { "left",   AT_LEFT },
419                 { "right",  AT_RIGHT }
420         };
421
422         pushpophelper pph(lexrc, alignTags, AT_LAYOUT);
423         int le = lexrc.lex();
424         switch (le) {
425         case LyXLex::LEX_UNDEF:
426                 lexrc.printError("Unknown alignment `$$Token'");
427                 return;
428         default: break;
429         };
430         switch (static_cast<AlignTags>(le)) {
431         case AT_BLOCK:
432                 align = LYX_ALIGN_BLOCK;
433                 break;
434         case AT_LEFT:
435                 align = LYX_ALIGN_LEFT;
436                 break;
437         case AT_RIGHT:
438                 align = LYX_ALIGN_RIGHT;
439                 break;
440         case AT_CENTER:
441                 align = LYX_ALIGN_CENTER;
442                 break;
443         case AT_LAYOUT:
444                 align = LYX_ALIGN_LAYOUT;
445                 break;
446         }
447 }
448
449
450 void LyXLayout::readAlignPossible(LyXLex & lexrc)
451 {
452         keyword_item alignTags[] = {
453                 { "block",  AT_BLOCK },
454                 { "center", AT_CENTER },
455                 { "layout", AT_LAYOUT },
456                 { "left",   AT_LEFT },
457                 { "right",  AT_RIGHT }
458         };
459
460         lexrc.pushTable(alignTags, AT_LAYOUT);
461         alignpossible = LYX_ALIGN_NONE;
462         int lineno = lexrc.getLineNo();
463         do {
464                 int le = lexrc.lex();
465                 switch (le) {
466                 case LyXLex::LEX_UNDEF:
467                         lexrc.printError("Unknown alignment `$$Token'");
468                         continue;
469                 default: break;
470                 };
471                 switch (static_cast<AlignTags>(le)) {
472                 case AT_BLOCK:
473                         alignpossible |= LYX_ALIGN_BLOCK;
474                         break;
475                 case AT_LEFT:
476                         alignpossible |= LYX_ALIGN_LEFT;
477                         break;
478                 case AT_RIGHT:
479                         alignpossible |= LYX_ALIGN_RIGHT;
480                         break;
481                 case AT_CENTER:
482                         alignpossible |= LYX_ALIGN_CENTER;
483                         break;
484                 case AT_LAYOUT:
485                         alignpossible |= LYX_ALIGN_LAYOUT;
486                         break;
487                 }
488         } while (lineno == lexrc.getLineNo());
489         lexrc.popTable();
490 }
491
492
493 enum LabelTypeTags {
494         LA_NO_LABEL = 1,
495         LA_MANUAL,
496         LA_TOP_ENVIRONMENT,
497         LA_CENTERED_TOP_ENVIRONMENT,
498         LA_STATIC,
499         LA_SENSITIVE,
500         LA_COUNTER_CHAPTER,
501         LA_COUNTER_SECTION,
502         LA_COUNTER_SUBSECTION,
503         LA_COUNTER_SUBSUBSECTION,
504         LA_COUNTER_PARAGRAPH,
505         LA_COUNTER_SUBPARAGRAPH,
506         LA_COUNTER_ENUMI,
507         LA_COUNTER_ENUMII,
508         LA_COUNTER_ENUMIII,
509         LA_COUNTER_ENUMIV,
510         LA_BIBLIO
511 };
512
513
514 void LyXLayout::readLabelType(LyXLex & lexrc)
515 {
516         keyword_item labelTypeTags[] = {
517         { "bibliography",             LA_BIBLIO },
518         { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
519         { "counter_chapter",          LA_COUNTER_CHAPTER },
520         { "counter_enumi",            LA_COUNTER_ENUMI },
521         { "counter_enumii",           LA_COUNTER_ENUMII },
522         { "counter_enumiii",          LA_COUNTER_ENUMIII },
523         { "counter_enumiv",           LA_COUNTER_ENUMIV },
524         { "counter_paragraph",        LA_COUNTER_PARAGRAPH },
525         { "counter_section",          LA_COUNTER_SECTION },
526         { "counter_subparagraph",     LA_COUNTER_SUBPARAGRAPH },
527         { "counter_subsection",       LA_COUNTER_SUBSECTION },
528         { "counter_subsubsection",    LA_COUNTER_SUBSUBSECTION },
529         { "manual",                   LA_MANUAL },
530         { "no_label",                 LA_NO_LABEL },
531         { "sensitive",                LA_SENSITIVE },
532         { "static",                   LA_STATIC },
533         { "top_environment",          LA_TOP_ENVIRONMENT }
534 };
535
536         pushpophelper pph(lexrc, labelTypeTags, LA_BIBLIO);
537         int le = lexrc.lex();
538         switch (le) {
539         case LyXLex::LEX_UNDEF:
540                 lexrc.printError("Unknown labeltype tag `$$Token'");
541                 return;
542         default: break;
543         }
544         switch (static_cast<LabelTypeTags>(le)) {
545         case LA_NO_LABEL:
546                 labeltype = LABEL_NO_LABEL;
547                 break;
548         case LA_MANUAL:
549                 labeltype = LABEL_MANUAL;
550                 break;
551         case LA_TOP_ENVIRONMENT:
552                 labeltype = LABEL_TOP_ENVIRONMENT;
553                 break;
554         case LA_CENTERED_TOP_ENVIRONMENT:
555                 labeltype = LABEL_CENTERED_TOP_ENVIRONMENT;
556                 break;
557         case LA_STATIC:
558                 labeltype = LABEL_STATIC;
559                 break;
560         case LA_SENSITIVE:
561                 labeltype = LABEL_SENSITIVE;
562                 break;
563         case LA_COUNTER_CHAPTER:
564                 labeltype = LABEL_COUNTER_CHAPTER;
565                 break;
566         case LA_COUNTER_SECTION:
567                 labeltype = LABEL_COUNTER_SECTION;
568                 break;
569         case LA_COUNTER_SUBSECTION:
570                 labeltype = LABEL_COUNTER_SUBSECTION;
571                 break;
572         case LA_COUNTER_SUBSUBSECTION:
573                 labeltype = LABEL_COUNTER_SUBSUBSECTION;
574                 break;
575         case LA_COUNTER_PARAGRAPH:
576                 labeltype = LABEL_COUNTER_PARAGRAPH;
577                 break;
578         case LA_COUNTER_SUBPARAGRAPH:
579                 labeltype = LABEL_COUNTER_SUBPARAGRAPH;
580                 break;
581         case LA_COUNTER_ENUMI:
582                 labeltype = LABEL_COUNTER_ENUMI;
583                 break;
584         case LA_COUNTER_ENUMII:
585                 labeltype = LABEL_COUNTER_ENUMII;
586                 break;
587         case LA_COUNTER_ENUMIII:
588                 labeltype = LABEL_COUNTER_ENUMIII;
589                 break;
590         case LA_COUNTER_ENUMIV:
591                 labeltype = LABEL_COUNTER_ENUMIV;
592                 break;
593         case LA_BIBLIO:
594                 labeltype = LABEL_BIBLIO;
595                 break;
596         }
597 }
598
599
600 namespace {
601
602 keyword_item endlabelTypeTags[] = {
603         { "box",        END_LABEL_BOX },
604         { "filled_box", END_LABEL_FILLED_BOX },
605         { "no_label",   END_LABEL_NO_LABEL },
606         { "static",     END_LABEL_STATIC }
607 };
608
609 } // namespace anon
610
611
612 void LyXLayout::readEndLabelType(LyXLex & lexrc)
613 {
614         pushpophelper pph(lexrc, endlabelTypeTags,
615                           END_LABEL_ENUM_LAST-END_LABEL_ENUM_FIRST+1);
616         int le = lexrc.lex();
617         switch (le) {
618         case LyXLex::LEX_UNDEF:
619                 lexrc.printError("Unknown labeltype tag `$$Token'");
620                 break;
621         case END_LABEL_STATIC:
622         case END_LABEL_BOX:
623         case END_LABEL_FILLED_BOX:
624         case END_LABEL_NO_LABEL:
625                 endlabeltype = static_cast<LYX_END_LABEL_TYPES>(le);
626                 break;
627         default:
628                 lyxerr << "Unhandled value " << le
629                        << " in LyXLayout::readEndLabelType." << endl;
630                 break;
631         }
632 }
633
634
635 void LyXLayout::readMargin(LyXLex & lexrc)
636 {
637         keyword_item marginTags[] = {
638                 { "dynamic",           MARGIN_DYNAMIC },
639                 { "first_dynamic",     MARGIN_FIRST_DYNAMIC },
640                 { "manual",            MARGIN_MANUAL },
641                 { "right_address_box", MARGIN_RIGHT_ADDRESS_BOX },
642                 { "static",            MARGIN_STATIC }
643         };
644
645         pushpophelper pph(lexrc, marginTags, MARGIN_RIGHT_ADDRESS_BOX);
646
647         int le = lexrc.lex();
648         switch (le) {
649         case LyXLex::LEX_UNDEF:
650                 lexrc.printError("Unknown margin type tag `$$Token'");
651                 return;
652         case MARGIN_STATIC:
653         case MARGIN_MANUAL:
654         case MARGIN_DYNAMIC:
655         case MARGIN_FIRST_DYNAMIC:
656         case MARGIN_RIGHT_ADDRESS_BOX:
657                 margintype = static_cast<LYX_MARGIN_TYPE>(le);
658                 break;
659         default:
660                 lyxerr << "Unhandled value " << le
661                        << " in LyXLayout::readMargin." << endl;
662                 break;
663         }
664 }
665
666
667 void LyXLayout::readLatexType(LyXLex & lexrc)
668 {
669         keyword_item latexTypeTags[] = {
670                 { "command",          LATEX_COMMAND },
671                 { "environment",      LATEX_ENVIRONMENT },
672                 { "item_environment", LATEX_ITEM_ENVIRONMENT },
673                 { "list_environment", LATEX_LIST_ENVIRONMENT },
674                 { "paragraph",        LATEX_PARAGRAPH }
675         };
676
677         pushpophelper pph(lexrc, latexTypeTags, LATEX_LIST_ENVIRONMENT);
678         int le = lexrc.lex();
679         switch (le) {
680         case LyXLex::LEX_UNDEF:
681                 lexrc.printError("Unknown latextype tag `$$Token'");
682                 return;
683         case LATEX_PARAGRAPH:
684         case LATEX_COMMAND:
685         case LATEX_ENVIRONMENT:
686         case LATEX_ITEM_ENVIRONMENT:
687         case LATEX_LIST_ENVIRONMENT:
688                 latextype = static_cast<LYX_LATEX_TYPES>(le);
689                 break;
690         default:
691                 lyxerr << "Unhandled value " << le
692                        << " in LyXLayout::readLatexType." << endl;
693                 break;
694         }
695 }
696
697
698 enum SpacingTags {
699         ST_SPACING_SINGLE = 1,
700         ST_SPACING_ONEHALF,
701         ST_SPACING_DOUBLE,
702         ST_OTHER
703 };
704
705
706 void LyXLayout::readSpacing(LyXLex & lexrc)
707 {
708         keyword_item spacingTags[] = {
709                 {"double",  ST_SPACING_DOUBLE },
710                 {"onehalf", ST_SPACING_ONEHALF },
711                 {"other",   ST_OTHER },
712                 {"single",  ST_SPACING_SINGLE }
713         };
714
715         pushpophelper pph(lexrc, spacingTags, ST_OTHER);
716         int le = lexrc.lex();
717         switch (le) {
718         case LyXLex::LEX_UNDEF:
719                 lexrc.printError("Unknown spacing token `$$Token'");
720                 return;
721         default: break;
722         }
723         switch (static_cast<SpacingTags>(le)) {
724         case ST_SPACING_SINGLE:
725                 spacing.set(Spacing::Single);
726                 break;
727         case ST_SPACING_ONEHALF:
728                 spacing.set(Spacing::Onehalf);
729                 break;
730         case ST_SPACING_DOUBLE:
731                 spacing.set(Spacing::Double);
732                 break;
733         case ST_OTHER:
734                 lexrc.next();
735                 spacing.set(Spacing::Other, lexrc.getFloat());
736                 break;
737         }
738 }
739
740
741 string const & LyXLayout::name() const
742 {
743         return name_;
744 }
745
746
747 void LyXLayout::setName(string const & n)
748 {
749         name_ = n;
750 }
751
752
753 string const & LyXLayout::obsoleted_by() const
754 {
755         return obsoleted_by_;
756 }