]> git.lyx.org Git - lyx.git/blob - src/lyxtextclass.C
fix preamble dialog
[lyx.git] / src / lyxtextclass.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 "lyxtextclass.h"
19 #include "debug.h"
20 #include "lyxlex.h"
21 #include "counters.h"
22 #include "FloatList.h"
23
24 #include "support/lstrings.h"
25 #include "support/LAssert.h"
26 #include "support/lyxfunctional.h"
27 #include "support/filetools.h"
28
29 #include <algorithm>
30
31 using std::endl;
32 using std::find_if;
33 using std::remove_if;
34 using std::ostream;
35
36 namespace { // anon
37
38 struct compare_name {
39         compare_name(string const & name)
40                 : name_(name) {}
41         template <class C>
42         bool operator()(C & c) {
43                 return c->name() == name_;
44         }
45         string name_;
46 };
47
48 } // anon
49
50
51 LyXTextClass::LyXTextClass(string const & fn, string const & cln,
52                            string const & desc)
53         : name_(fn), latexname_(cln), description_(desc),
54           floatlist_(new FloatList), ctrs_(new Counters)
55 {
56         outputType_ = LATEX;
57         columns_ = 1;
58         sides_ = OneSide;
59         secnumdepth_ = 3;
60         tocdepth_ = 3;
61         pagestyle_ = "default";
62         maxcounter_ = LABEL_COUNTER_CHAPTER;
63         defaultfont_ = LyXFont(LyXFont::ALL_SANE);
64         opt_fontsize_ = "10|11|12";
65         opt_pagestyle_ = "empty|plain|headings|fancy";
66         provides_ = nothing;
67         loaded = false;
68 }
69
70
71 bool LyXTextClass::do_readStyle(LyXLex & lexrc, LyXLayout & lay)
72 {
73         lyxerr[Debug::TCLASS] << "Reading style " << lay.name() << endl;
74         if (!lay.Read(lexrc, *this)) {
75                 // Resolve fonts
76                 lay.resfont = lay.font;
77                 lay.resfont.realize(defaultfont());
78                 lay.reslabelfont = lay.labelfont;
79                 lay.reslabelfont.realize(defaultfont());
80                 return false; // no errors
81         }
82         lyxerr << "Error parsing style `" << lay.name() << "'" << endl;
83         return true;
84 }
85
86
87 enum TextClassTags {
88         TC_OUTPUTTYPE = 1,
89         TC_INPUT,
90         TC_STYLE,
91         TC_DEFAULTSTYLE,
92         TC_NOSTYLE,
93         TC_COLUMNS,
94         TC_SIDES,
95         TC_PAGESTYLE,
96         TC_DEFAULTFONT,
97         TC_MAXCOUNTER,
98         TC_SECNUMDEPTH,
99         TC_TOCDEPTH,
100         TC_CLASSOPTIONS,
101         TC_PREAMBLE,
102         TC_PROVIDESAMSMATH,
103         TC_PROVIDESNATBIB,
104         TC_PROVIDESMAKEIDX,
105         TC_PROVIDESURL,
106         TC_LEFTMARGIN,
107         TC_RIGHTMARGIN,
108         TC_FLOAT,
109         TC_COUNTER,
110         TC_NOFLOAT
111 };
112
113
114 // Reads a textclass structure from file.
115 bool LyXTextClass::Read(string const & filename, bool merge)
116 {
117         keyword_item textClassTags[] = {
118                 { "classoptions",    TC_CLASSOPTIONS },
119                 { "columns",         TC_COLUMNS },
120                 { "counter",         TC_COUNTER },
121                 { "defaultfont",     TC_DEFAULTFONT },
122                 { "defaultstyle",    TC_DEFAULTSTYLE },
123                 { "float",           TC_FLOAT },
124                 { "input",           TC_INPUT },
125                 { "leftmargin",      TC_LEFTMARGIN },
126                 { "maxcounter",      TC_MAXCOUNTER },
127                 { "nofloat",         TC_NOFLOAT },
128                 { "nostyle",         TC_NOSTYLE },
129                 { "outputtype",      TC_OUTPUTTYPE },
130                 { "pagestyle",       TC_PAGESTYLE },
131                 { "preamble",        TC_PREAMBLE },
132                 { "providesamsmath", TC_PROVIDESAMSMATH },
133                 { "providesmakeidx", TC_PROVIDESMAKEIDX },
134                 { "providesnatbib",  TC_PROVIDESNATBIB },
135                 { "providesurl",     TC_PROVIDESURL },
136                 { "rightmargin",     TC_RIGHTMARGIN },
137                 { "secnumdepth",     TC_SECNUMDEPTH },
138                 { "sides",           TC_SIDES },
139                 { "style",           TC_STYLE },
140                 { "tocdepth",        TC_TOCDEPTH }
141         };
142
143         if (!merge)
144                 lyxerr[Debug::TCLASS] << "Reading textclass "
145                                       << MakeDisplayPath(filename)
146                                       << endl;
147         else
148                 lyxerr[Debug::TCLASS] << "Reading input file "
149                                      << MakeDisplayPath(filename)
150                                      << endl;
151
152         LyXLex lexrc(textClassTags, TC_NOFLOAT);
153         bool error = false;
154
155         lexrc.setFile(filename);
156         if (!lexrc.isOK()) error = true;
157
158         // parsing
159         while (lexrc.isOK() && !error) {
160                 int le = lexrc.lex();
161                 switch (le) {
162                 case LyXLex::LEX_FEOF:
163                         continue;
164
165                 case LyXLex::LEX_UNDEF:
166                         lexrc.printError("Unknown TextClass tag `$$Token'");
167                         error = true;
168                         continue;
169                 default: break;
170                 }
171                 switch (static_cast<TextClassTags>(le)) {
172                 case TC_OUTPUTTYPE:   // output type definition
173                         readOutputType(lexrc);
174                         break;
175
176                 case TC_INPUT: // Include file
177                         if (lexrc.next()) {
178                                 string tmp = LibFileSearch("layouts",
179                                                             lexrc.getString(),
180                                                             "layout");
181
182                                 if (Read(tmp, true)) {
183                                         lexrc.printError("Error reading input"
184                                                          "file: "+tmp);
185                                         error = true;
186                                 }
187                         }
188                         break;
189
190                 case TC_DEFAULTSTYLE:
191                         if (lexrc.next()) {
192                                 string const name = subst(lexrc.getString(),
193                                                           '_', ' ');
194                                 defaultlayout_ = name;
195                         }
196                         break;
197
198                 case TC_STYLE:
199                         if (lexrc.next()) {
200                                 string const name = subst(lexrc.getString(),
201                                                     '_', ' ');
202                                 if (hasLayout(name)) {
203                                         LyXLayout * lay =
204                                                 operator[](name).get();
205                                         error = do_readStyle(lexrc, *lay);
206                                 } else {
207                                         LyXLayout lay;
208                                         lay.setName(name);
209                                         if (!(error = do_readStyle(lexrc, lay)))
210                                                 layoutlist_.push_back(boost::shared_ptr<LyXLayout>(new LyXLayout(lay)));
211                                         if (defaultlayout_.empty()) {
212                                                 // We do not have a default
213                                                 // layout yet, so we choose
214                                                 // the first layout we
215                                                 // encounter.
216                                                 defaultlayout_ = name;
217                                         }
218                                 }
219                         }
220                         else {
221                                 lexrc.printError("No name given for style: `$$Token'.");
222                                 error = true;
223                         }
224                         break;
225
226                 case TC_NOSTYLE:
227                         if (lexrc.next()) {
228                                 string const style = subst(lexrc.getString(),
229                                                      '_', ' ');
230                                 if (!delete_layout(style))
231                                         lyxerr << "Cannot delete style `" << style << "'" << endl;
232 //                                      lexrc.printError("Cannot delete style"
233 //                                                       " `$$Token'");
234                         }
235                         break;
236
237                 case TC_COLUMNS:
238                         if (lexrc.next())
239                                 columns_ = lexrc.getInteger();
240                         break;
241
242                 case TC_SIDES:
243                         if (lexrc.next()) {
244                                 switch (lexrc.getInteger()) {
245                                 case 1: sides_ = OneSide; break;
246                                 case 2: sides_ = TwoSides; break;
247                                 default:
248                                         lyxerr << "Impossible number of page"
249                                                 " sides, setting to one."
250                                                << endl;
251                                         sides_ = OneSide;
252                                         break;
253                                 }
254                         }
255                         break;
256
257                 case TC_PAGESTYLE:
258                         lexrc.next();
259                         pagestyle_ = rtrim(lexrc.getString());
260                         break;
261
262                 case TC_DEFAULTFONT:
263                         defaultfont_.lyxRead(lexrc);
264                         if (!defaultfont_.resolved()) {
265                                 lexrc.printError("Warning: defaultfont should "
266                                                  "be fully instantiated!");
267                                 defaultfont_.realize(LyXFont(LyXFont::ALL_SANE));
268                         }
269                         break;
270
271                 case TC_MAXCOUNTER:
272                         readMaxCounter(lexrc);
273                         break;
274
275                 case TC_SECNUMDEPTH:
276                         lexrc.next();
277                         secnumdepth_ = lexrc.getInteger();
278                         break;
279
280                 case TC_TOCDEPTH:
281                         lexrc.next();
282                         tocdepth_ = lexrc.getInteger();
283                         break;
284
285                         // First step to support options
286                 case TC_CLASSOPTIONS:
287                         readClassOptions(lexrc);
288                         break;
289
290                 case TC_PREAMBLE:
291                         preamble_ = lexrc.getLongString("EndPreamble");
292                         break;
293
294                 case TC_PROVIDESAMSMATH:
295                         if (lexrc.next() && lexrc.getInteger())
296                                 provides_ |= amsmath;
297                         break;
298
299                 case TC_PROVIDESNATBIB:
300                         if (lexrc.next() && lexrc.getInteger())
301                                 provides_ |= natbib;
302                         break;
303
304                 case TC_PROVIDESMAKEIDX:
305                         if (lexrc.next() && lexrc.getInteger())
306                                 provides_ |= makeidx;
307                         break;
308
309                 case TC_PROVIDESURL:
310                         if (lexrc.next() && lexrc.getInteger())
311                                 provides_ |= url;
312                         break;
313
314                 case TC_LEFTMARGIN:     // left margin type
315                         if (lexrc.next())
316                                 leftmargin_ = lexrc.getString();
317                         break;
318
319                 case TC_RIGHTMARGIN:    // right margin type
320                         if (lexrc.next())
321                                 rightmargin_ = lexrc.getString();
322                         break;
323                 case TC_FLOAT:
324                         readFloat(lexrc);
325                         break;
326                 case TC_COUNTER:
327                         readCounter(lexrc);
328                         break;
329                 case TC_NOFLOAT:
330                         if (lexrc.next()) {
331                                 string const nofloat = lexrc.getString();
332                                 floatlist_->erase(nofloat);
333                         }
334                         break;
335
336                 }
337         }
338
339         if (!merge) { // we are at top level here.
340                 lyxerr[Debug::TCLASS] << "Finished reading textclass "
341                                       << MakeDisplayPath(filename)
342                                       << endl;
343                 if (defaultlayout_.empty()) {
344                         lyxerr << "Error: Textclass '" << name_
345                                << "' is missing a defaultstyle." << endl;
346                         error = true;
347                 }
348         } else
349                 lyxerr[Debug::TCLASS] << "Finished reading input file "
350                                       << MakeDisplayPath(filename)
351                                       << endl;
352
353         return error;
354 }
355
356
357 void LyXTextClass::readOutputType(LyXLex & lexrc)
358 {
359         keyword_item outputTypeTags[] = {
360                 { "docbook", DOCBOOK },
361                 { "latex", LATEX },
362                 { "linuxdoc", LINUXDOC },
363                 { "literate", LITERATE }
364         };
365
366         pushpophelper pph(lexrc, outputTypeTags, LITERATE);
367
368         int le = lexrc.lex();
369         switch (le) {
370         case LyXLex::LEX_UNDEF:
371                 lexrc.printError("Unknown output type `$$Token'");
372                 return;
373         case LATEX:
374         case LINUXDOC:
375         case DOCBOOK:
376         case LITERATE:
377                 outputType_ = static_cast<OutputType>(le);
378                 break;
379         default:
380                 lyxerr << "Unhandled value " << le
381                        << " in LyXTextClass::readOutputType." << endl;
382
383                 break;
384         }
385 }
386
387
388 enum MaxCounterTags {
389         MC_COUNTER_CHAPTER = 1,
390         MC_COUNTER_SECTION,
391         MC_COUNTER_SUBSECTION,
392         MC_COUNTER_SUBSUBSECTION,
393         MC_COUNTER_PARAGRAPH,
394         MC_COUNTER_SUBPARAGRAPH,
395         MC_COUNTER_ENUMI,
396         MC_COUNTER_ENUMII,
397         MC_COUNTER_ENUMIII,
398         MC_COUNTER_ENUMIV
399 };
400
401
402 void LyXTextClass::readMaxCounter(LyXLex & lexrc)
403 {
404         keyword_item maxCounterTags[] = {
405                 {"counter_chapter", MC_COUNTER_CHAPTER },
406                 {"counter_enumi", MC_COUNTER_ENUMI },
407                 {"counter_enumii", MC_COUNTER_ENUMII },
408                 {"counter_enumiii", MC_COUNTER_ENUMIII },
409                 {"counter_enumiv", MC_COUNTER_ENUMIV },
410                 {"counter_paragraph", MC_COUNTER_PARAGRAPH },
411                 {"counter_section", MC_COUNTER_SECTION },
412                 {"counter_subparagraph", MC_COUNTER_SUBPARAGRAPH },
413                 {"counter_subsection", MC_COUNTER_SUBSECTION },
414                 {"counter_subsubsection", MC_COUNTER_SUBSUBSECTION }
415         };
416
417         pushpophelper pph(lexrc, maxCounterTags, MC_COUNTER_ENUMIV);
418         int le = lexrc.lex();
419         switch (le) {
420         case LyXLex::LEX_UNDEF:
421                 lexrc.printError("Unknown MaxCounter tag `$$Token'");
422                 return;
423         default: break;
424         }
425         switch (static_cast<MaxCounterTags>(le)) {
426         case MC_COUNTER_CHAPTER:
427                 maxcounter_ = LABEL_COUNTER_CHAPTER;
428                 break;
429         case MC_COUNTER_SECTION:
430                 maxcounter_ = LABEL_COUNTER_SECTION;
431                 break;
432         case MC_COUNTER_SUBSECTION:
433                 maxcounter_ = LABEL_COUNTER_SUBSECTION;
434                 break;
435         case MC_COUNTER_SUBSUBSECTION:
436                 maxcounter_ = LABEL_COUNTER_SUBSUBSECTION;
437                 break;
438         case MC_COUNTER_PARAGRAPH:
439                 maxcounter_ = LABEL_COUNTER_PARAGRAPH;
440                 break;
441         case MC_COUNTER_SUBPARAGRAPH:
442                 maxcounter_ = LABEL_COUNTER_SUBPARAGRAPH;
443                 break;
444         case MC_COUNTER_ENUMI:
445                 maxcounter_ = LABEL_COUNTER_ENUMI;
446                 break;
447         case MC_COUNTER_ENUMII:
448                 maxcounter_ = LABEL_COUNTER_ENUMII;
449                 break;
450         case MC_COUNTER_ENUMIII:
451                 maxcounter_ = LABEL_COUNTER_ENUMIII;
452                 break;
453         case MC_COUNTER_ENUMIV:
454                 maxcounter_ = LABEL_COUNTER_ENUMIV;
455                 break;
456         }
457 }
458
459
460 enum ClassOptionsTags {
461         CO_FONTSIZE = 1,
462         CO_PAGESTYLE,
463         CO_OTHER,
464         CO_END
465 };
466
467
468 void LyXTextClass::readClassOptions(LyXLex & lexrc)
469 {
470         keyword_item classOptionsTags[] = {
471                 {"end", CO_END },
472                 {"fontsize", CO_FONTSIZE },
473                 {"other", CO_OTHER },
474                 {"pagestyle", CO_PAGESTYLE }
475         };
476
477         lexrc.pushTable(classOptionsTags, CO_END);
478         bool getout = false;
479         while (!getout && lexrc.isOK()) {
480                 int le = lexrc.lex();
481                 switch (le) {
482                 case LyXLex::LEX_UNDEF:
483                         lexrc.printError("Unknown ClassOption tag `$$Token'");
484                         continue;
485                 default: break;
486                 }
487                 switch (static_cast<ClassOptionsTags>(le)) {
488                 case CO_FONTSIZE:
489                         lexrc.next();
490                         opt_fontsize_ = rtrim(lexrc.getString());
491                         break;
492                 case CO_PAGESTYLE:
493                         lexrc.next();
494                         opt_pagestyle_ = rtrim(lexrc.getString());
495                         break;
496                 case CO_OTHER:
497                         lexrc.next();
498                         options_ = lexrc.getString();
499                         break;
500                 case CO_END:
501                         getout = true;
502                         break;
503                 }
504         }
505         lexrc.popTable();
506 }
507
508
509 enum FloatTags {
510         FT_TYPE = 1,
511         FT_NAME,
512         FT_PLACEMENT,
513         FT_EXT,
514         FT_WITHIN,
515         FT_STYLE,
516         FT_LISTNAME,
517         FT_BUILTIN,
518         FT_END
519 };
520
521 void LyXTextClass::readFloat(LyXLex & lexrc)
522 {
523         keyword_item floatTags[] = {
524                 { "end", FT_END },
525                 { "extension", FT_EXT },
526                 { "guiname", FT_NAME },
527                 { "latexbuiltin", FT_BUILTIN },
528                 { "listname", FT_LISTNAME },
529                 { "numberwithin", FT_WITHIN },
530                 { "placement", FT_PLACEMENT },
531                 { "style", FT_STYLE },
532                 { "type", FT_TYPE }
533         };
534
535         lexrc.pushTable(floatTags, FT_END);
536
537         string type;
538         string placement;
539         string ext;
540         string within;
541         string style;
542         string name;
543         string listname;
544         bool builtin = false;
545
546         bool getout = false;
547         while (!getout && lexrc.isOK()) {
548                 int le = lexrc.lex();
549                 switch (le) {
550                 case LyXLex::LEX_UNDEF:
551                         lexrc.printError("Unknown ClassOption tag `$$Token'");
552                         continue;
553                 default: break;
554                 }
555                 switch (static_cast<FloatTags>(le)) {
556                 case FT_TYPE:
557                         lexrc.next();
558                         type = lexrc.getString();
559                         // Here we could check if this type is already defined
560                         // and modify it with the rest of the vars instead.
561                         break;
562                 case FT_NAME:
563                         lexrc.next();
564                         name = lexrc.getString();
565                         break;
566                 case FT_PLACEMENT:
567                         lexrc.next();
568                         placement = lexrc.getString();
569                         break;
570                 case FT_EXT:
571                         lexrc.next();
572                         ext = lexrc.getString();
573                         break;
574                 case FT_WITHIN:
575                         lexrc.next();
576                         within = lexrc.getString();
577                         if (within == "none")
578                                 within.erase();
579                         break;
580                 case FT_STYLE:
581                         lexrc.next();
582                         style = lexrc.getString();
583                         break;
584                 case FT_LISTNAME:
585                         lexrc.next();
586                         listname = lexrc.getString();
587                         break;
588                 case FT_BUILTIN:
589                         lexrc.next();
590                         builtin = lexrc.getBool();
591                         break;
592                 case FT_END:
593                         getout = true;
594                         break;
595                 }
596         }
597
598         // Here if have a full float if getout == true
599         if (getout) {
600                 Floating newfloat(type, placement, ext, within,
601                                   style, name, listname, builtin);
602                 floatlist_->newFloat(newfloat);
603         }
604
605         lexrc.popTable();
606 }
607
608
609 enum CounterTags {
610         CT_NAME = 1,
611         CT_WITHIN,
612         CT_END
613 };
614
615 void LyXTextClass::readCounter(LyXLex & lexrc)
616 {
617         keyword_item counterTags[] = {
618                 { "end", CT_END },
619                 { "name", CT_NAME },
620                 { "within", CT_WITHIN }
621         };
622
623         lexrc.pushTable(counterTags, CT_END);
624
625         string name;
626         string within;
627
628         bool getout = false;
629         while (!getout && lexrc.isOK()) {
630                 int le = lexrc.lex();
631                 switch (le) {
632                 case LyXLex::LEX_UNDEF:
633                         lexrc.printError("Unknown ClassOption tag `$$Token'");
634                         continue;
635                 default: break;
636                 }
637                 switch (static_cast<CounterTags>(le)) {
638                 case CT_NAME:
639                         lexrc.next();
640                         name = lexrc.getString();
641                         break;
642                 case CT_WITHIN:
643                         lexrc.next();
644                         within = lexrc.getString();
645                         if (within == "none")
646                                 within.erase();
647                         break;
648                 case CT_END:
649                         getout = true;
650                         break;
651                 }
652         }
653
654         // Here if have a full float if getout == true
655         if (getout) {
656                 if (within.empty()) {
657                         ctrs_->newCounter(name);
658                 } else {
659                         ctrs_->newCounter(name, within);
660                 }
661         }
662
663         lexrc.popTable();
664 }
665
666
667 LyXFont const & LyXTextClass::defaultfont() const
668 {
669         return defaultfont_;
670 }
671
672
673 string const & LyXTextClass::leftmargin() const
674 {
675         return leftmargin_;
676 }
677
678
679 string const & LyXTextClass::rightmargin() const
680 {
681         return rightmargin_;
682 }
683
684
685 bool LyXTextClass::hasLayout(string const & n) const
686 {
687         string const name = (n.empty() ? defaultLayoutName() : n);
688
689         return find_if(layoutlist_.begin(), layoutlist_.end(),
690                        compare_name(name))
691                 != layoutlist_.end();
692 }
693
694
695 LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
696 {
697         lyx::Assert(!n.empty());
698
699         if (n.empty())
700                 lyxerr << "Operator[] called with empty n" << endl;
701
702         string const name = (n.empty() ? defaultLayoutName() : n);
703
704         static string lastLayoutName;
705         static LayoutList::difference_type lastLayoutIndex;
706
707         if (name == lastLayoutName)
708                 return layoutlist_[lastLayoutIndex];
709
710         LayoutList::const_iterator cit =
711                 find_if(layoutlist_.begin(),
712                         layoutlist_.end(),
713                         compare_name(name));
714
715         if (cit == layoutlist_.end()) {
716                 lyxerr << "We failed to find the layout '" << name
717                        << "' in the layout list. You MUST investigate!"
718                        << endl;
719
720                 // we require the name to exist
721                 lyx::Assert(false);
722         }
723
724         lastLayoutName = name;
725         lastLayoutIndex = std::distance(layoutlist_.begin(), cit);
726
727         return (*cit);
728 }
729
730
731 bool LyXTextClass::delete_layout(string const & name)
732 {
733         if (name == defaultLayoutName())
734                 return false;
735
736         LayoutList::iterator it =
737                 remove_if(layoutlist_.begin(), layoutlist_.end(),
738                           compare_name(name));
739
740         LayoutList::iterator end = layoutlist_.end();
741         bool const ret = (it != end);
742         layoutlist_.erase(it, end);
743         return ret;
744 }
745
746
747 // Load textclass info if not loaded yet
748 bool LyXTextClass::load() const
749 {
750         if (loaded)
751                 return true;
752
753         // Read style-file
754         string const real_file = LibFileSearch("layouts", name_, "layout");
755
756         if (const_cast<LyXTextClass*>(this)->Read(real_file)) {
757                 lyxerr << "Error reading `"
758                        << MakeDisplayPath(real_file)
759                        << "'\n(Check `" << name_
760                        << "')\nCheck your installation and "
761                         "try Options/Reconfigure..." << endl;
762                 loaded = false;
763         }
764         loaded = true;
765         return loaded;
766 }
767
768
769 FloatList & LyXTextClass::floats()
770 {
771         return *floatlist_.get();
772 }
773
774
775 FloatList const & LyXTextClass::floats() const
776 {
777         return *floatlist_.get();
778 }
779
780
781 Counters & LyXTextClass::counters() const
782 {
783         return *ctrs_.get();
784 }
785
786
787 string const & LyXTextClass::defaultLayoutName() const
788 {
789         // This really should come from the actual layout... (Lgb)
790         return defaultlayout_;
791 }
792
793
794 LyXLayout_ptr const & LyXTextClass::defaultLayout() const
795 {
796         return operator[](defaultLayoutName());
797 }
798
799
800 string const & LyXTextClass::name() const
801 {
802         return name_;
803 }
804
805
806 string const & LyXTextClass::latexname() const
807 {
808         const_cast<LyXTextClass*>(this)->load();
809         return latexname_;
810 }
811
812
813 string const & LyXTextClass::description() const
814 {
815         return description_;
816 }
817
818
819 string const & LyXTextClass::opt_fontsize() const
820 {
821         return opt_fontsize_;
822 }
823
824
825 string const & LyXTextClass::opt_pagestyle() const
826 {
827         return opt_pagestyle_;
828 }
829
830
831 string const & LyXTextClass::options() const
832 {
833         return options_;
834 }
835
836
837 string const & LyXTextClass::pagestyle() const
838 {
839         return pagestyle_;
840 }
841
842
843 string const & LyXTextClass::preamble() const
844 {
845         return preamble_;
846 }
847
848
849 LyXTextClass::PageSides LyXTextClass::sides() const
850 {
851         return sides_;
852 }
853
854
855 int LyXTextClass::secnumdepth() const
856 {
857         return secnumdepth_;
858 }
859
860
861 int LyXTextClass::tocdepth() const
862 {
863         return tocdepth_;
864 }
865
866
867 OutputType LyXTextClass::outputType() const
868 {
869         return outputType_;
870 }
871
872
873 bool LyXTextClass::provides(LyXTextClass::Provides p) const
874 {
875         return provides_ & p;
876 }
877
878
879 unsigned int LyXTextClass::columns() const
880 {
881         return columns_;
882 }
883
884
885 int LyXTextClass::maxcounter() const
886 {
887         return maxcounter_;
888 }
889
890
891 int LyXTextClass::size() const
892 {
893         return layoutlist_.size();
894 }
895
896
897 ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
898 {
899         switch (p) {
900         case LyXTextClass::OneSide:
901                 os << "1";
902                 break;
903         case LyXTextClass::TwoSides:
904                 os << "2";
905                 break;
906         }
907         return os;
908 }