]> git.lyx.org Git - lyx.git/blob - src/lyxtextclass.C
update no.po
[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 `"
232                                                << style << '\'' << endl;
233 //                                      lexrc.printError("Cannot delete style"
234 //                                                       " `$$Token'");
235                         }
236                         break;
237
238                 case TC_COLUMNS:
239                         if (lexrc.next())
240                                 columns_ = lexrc.getInteger();
241                         break;
242
243                 case TC_SIDES:
244                         if (lexrc.next()) {
245                                 switch (lexrc.getInteger()) {
246                                 case 1: sides_ = OneSide; break;
247                                 case 2: sides_ = TwoSides; break;
248                                 default:
249                                         lyxerr << "Impossible number of page"
250                                                 " sides, setting to one."
251                                                << endl;
252                                         sides_ = OneSide;
253                                         break;
254                                 }
255                         }
256                         break;
257
258                 case TC_PAGESTYLE:
259                         lexrc.next();
260                         pagestyle_ = rtrim(lexrc.getString());
261                         break;
262
263                 case TC_DEFAULTFONT:
264                         defaultfont_.lyxRead(lexrc);
265                         if (!defaultfont_.resolved()) {
266                                 lexrc.printError("Warning: defaultfont should "
267                                                  "be fully instantiated!");
268                                 defaultfont_.realize(LyXFont(LyXFont::ALL_SANE));
269                         }
270                         break;
271
272                 case TC_MAXCOUNTER:
273                         readMaxCounter(lexrc);
274                         break;
275
276                 case TC_SECNUMDEPTH:
277                         lexrc.next();
278                         secnumdepth_ = lexrc.getInteger();
279                         break;
280
281                 case TC_TOCDEPTH:
282                         lexrc.next();
283                         tocdepth_ = lexrc.getInteger();
284                         break;
285
286                         // First step to support options
287                 case TC_CLASSOPTIONS:
288                         readClassOptions(lexrc);
289                         break;
290
291                 case TC_PREAMBLE:
292                         preamble_ = lexrc.getLongString("EndPreamble");
293                         break;
294
295                 case TC_PROVIDESAMSMATH:
296                         if (lexrc.next() && lexrc.getInteger())
297                                 provides_ |= amsmath;
298                         break;
299
300                 case TC_PROVIDESNATBIB:
301                         if (lexrc.next() && lexrc.getInteger())
302                                 provides_ |= natbib;
303                         break;
304
305                 case TC_PROVIDESMAKEIDX:
306                         if (lexrc.next() && lexrc.getInteger())
307                                 provides_ |= makeidx;
308                         break;
309
310                 case TC_PROVIDESURL:
311                         if (lexrc.next() && lexrc.getInteger())
312                                 provides_ |= url;
313                         break;
314
315                 case TC_LEFTMARGIN:     // left margin type
316                         if (lexrc.next())
317                                 leftmargin_ = lexrc.getString();
318                         break;
319
320                 case TC_RIGHTMARGIN:    // right margin type
321                         if (lexrc.next())
322                                 rightmargin_ = lexrc.getString();
323                         break;
324                 case TC_FLOAT:
325                         readFloat(lexrc);
326                         break;
327                 case TC_COUNTER:
328                         readCounter(lexrc);
329                         break;
330                 case TC_NOFLOAT:
331                         if (lexrc.next()) {
332                                 string const nofloat = lexrc.getString();
333                                 floatlist_->erase(nofloat);
334                         }
335                         break;
336
337                 }
338         }
339
340         if (!merge) { // we are at top level here.
341                 lyxerr[Debug::TCLASS] << "Finished reading textclass "
342                                       << MakeDisplayPath(filename)
343                                       << endl;
344                 if (defaultlayout_.empty()) {
345                         lyxerr << "Error: Textclass '" << name_
346                                << "' is missing a defaultstyle." << endl;
347                         error = true;
348                 }
349         } else
350                 lyxerr[Debug::TCLASS] << "Finished reading input file "
351                                       << MakeDisplayPath(filename)
352                                       << endl;
353
354         return error;
355 }
356
357
358 void LyXTextClass::readOutputType(LyXLex & lexrc)
359 {
360         keyword_item outputTypeTags[] = {
361                 { "docbook", DOCBOOK },
362                 { "latex", LATEX },
363                 { "linuxdoc", LINUXDOC },
364                 { "literate", LITERATE }
365         };
366
367         pushpophelper pph(lexrc, outputTypeTags, LITERATE);
368
369         int le = lexrc.lex();
370         switch (le) {
371         case LyXLex::LEX_UNDEF:
372                 lexrc.printError("Unknown output type `$$Token'");
373                 return;
374         case LATEX:
375         case LINUXDOC:
376         case DOCBOOK:
377         case LITERATE:
378                 outputType_ = static_cast<OutputType>(le);
379                 break;
380         default:
381                 lyxerr << "Unhandled value " << le
382                        << " in LyXTextClass::readOutputType." << endl;
383
384                 break;
385         }
386 }
387
388
389 enum MaxCounterTags {
390         MC_COUNTER_CHAPTER = 1,
391         MC_COUNTER_SECTION,
392         MC_COUNTER_SUBSECTION,
393         MC_COUNTER_SUBSUBSECTION,
394         MC_COUNTER_PARAGRAPH,
395         MC_COUNTER_SUBPARAGRAPH,
396         MC_COUNTER_ENUMI,
397         MC_COUNTER_ENUMII,
398         MC_COUNTER_ENUMIII,
399         MC_COUNTER_ENUMIV
400 };
401
402
403 void LyXTextClass::readMaxCounter(LyXLex & lexrc)
404 {
405         keyword_item maxCounterTags[] = {
406                 {"counter_chapter", MC_COUNTER_CHAPTER },
407                 {"counter_enumi", MC_COUNTER_ENUMI },
408                 {"counter_enumii", MC_COUNTER_ENUMII },
409                 {"counter_enumiii", MC_COUNTER_ENUMIII },
410                 {"counter_enumiv", MC_COUNTER_ENUMIV },
411                 {"counter_paragraph", MC_COUNTER_PARAGRAPH },
412                 {"counter_section", MC_COUNTER_SECTION },
413                 {"counter_subparagraph", MC_COUNTER_SUBPARAGRAPH },
414                 {"counter_subsection", MC_COUNTER_SUBSECTION },
415                 {"counter_subsubsection", MC_COUNTER_SUBSUBSECTION }
416         };
417
418         pushpophelper pph(lexrc, maxCounterTags, MC_COUNTER_ENUMIV);
419         int le = lexrc.lex();
420         switch (le) {
421         case LyXLex::LEX_UNDEF:
422                 lexrc.printError("Unknown MaxCounter tag `$$Token'");
423                 return;
424         default: break;
425         }
426         switch (static_cast<MaxCounterTags>(le)) {
427         case MC_COUNTER_CHAPTER:
428                 maxcounter_ = LABEL_COUNTER_CHAPTER;
429                 break;
430         case MC_COUNTER_SECTION:
431                 maxcounter_ = LABEL_COUNTER_SECTION;
432                 break;
433         case MC_COUNTER_SUBSECTION:
434                 maxcounter_ = LABEL_COUNTER_SUBSECTION;
435                 break;
436         case MC_COUNTER_SUBSUBSECTION:
437                 maxcounter_ = LABEL_COUNTER_SUBSUBSECTION;
438                 break;
439         case MC_COUNTER_PARAGRAPH:
440                 maxcounter_ = LABEL_COUNTER_PARAGRAPH;
441                 break;
442         case MC_COUNTER_SUBPARAGRAPH:
443                 maxcounter_ = LABEL_COUNTER_SUBPARAGRAPH;
444                 break;
445         case MC_COUNTER_ENUMI:
446                 maxcounter_ = LABEL_COUNTER_ENUMI;
447                 break;
448         case MC_COUNTER_ENUMII:
449                 maxcounter_ = LABEL_COUNTER_ENUMII;
450                 break;
451         case MC_COUNTER_ENUMIII:
452                 maxcounter_ = LABEL_COUNTER_ENUMIII;
453                 break;
454         case MC_COUNTER_ENUMIV:
455                 maxcounter_ = LABEL_COUNTER_ENUMIV;
456                 break;
457         }
458 }
459
460
461 enum ClassOptionsTags {
462         CO_FONTSIZE = 1,
463         CO_PAGESTYLE,
464         CO_OTHER,
465         CO_END
466 };
467
468
469 void LyXTextClass::readClassOptions(LyXLex & lexrc)
470 {
471         keyword_item classOptionsTags[] = {
472                 {"end", CO_END },
473                 {"fontsize", CO_FONTSIZE },
474                 {"other", CO_OTHER },
475                 {"pagestyle", CO_PAGESTYLE }
476         };
477
478         lexrc.pushTable(classOptionsTags, CO_END);
479         bool getout = false;
480         while (!getout && lexrc.isOK()) {
481                 int le = lexrc.lex();
482                 switch (le) {
483                 case LyXLex::LEX_UNDEF:
484                         lexrc.printError("Unknown ClassOption tag `$$Token'");
485                         continue;
486                 default: break;
487                 }
488                 switch (static_cast<ClassOptionsTags>(le)) {
489                 case CO_FONTSIZE:
490                         lexrc.next();
491                         opt_fontsize_ = rtrim(lexrc.getString());
492                         break;
493                 case CO_PAGESTYLE:
494                         lexrc.next();
495                         opt_pagestyle_ = rtrim(lexrc.getString());
496                         break;
497                 case CO_OTHER:
498                         lexrc.next();
499                         options_ = lexrc.getString();
500                         break;
501                 case CO_END:
502                         getout = true;
503                         break;
504                 }
505         }
506         lexrc.popTable();
507 }
508
509
510 enum FloatTags {
511         FT_TYPE = 1,
512         FT_NAME,
513         FT_PLACEMENT,
514         FT_EXT,
515         FT_WITHIN,
516         FT_STYLE,
517         FT_LISTNAME,
518         FT_BUILTIN,
519         FT_END
520 };
521
522 void LyXTextClass::readFloat(LyXLex & lexrc)
523 {
524         keyword_item floatTags[] = {
525                 { "end", FT_END },
526                 { "extension", FT_EXT },
527                 { "guiname", FT_NAME },
528                 { "latexbuiltin", FT_BUILTIN },
529                 { "listname", FT_LISTNAME },
530                 { "numberwithin", FT_WITHIN },
531                 { "placement", FT_PLACEMENT },
532                 { "style", FT_STYLE },
533                 { "type", FT_TYPE }
534         };
535
536         lexrc.pushTable(floatTags, FT_END);
537
538         string type;
539         string placement;
540         string ext;
541         string within;
542         string style;
543         string name;
544         string listname;
545         bool builtin = false;
546
547         bool getout = false;
548         while (!getout && lexrc.isOK()) {
549                 int le = lexrc.lex();
550                 switch (le) {
551                 case LyXLex::LEX_UNDEF:
552                         lexrc.printError("Unknown ClassOption tag `$$Token'");
553                         continue;
554                 default: break;
555                 }
556                 switch (static_cast<FloatTags>(le)) {
557                 case FT_TYPE:
558                         lexrc.next();
559                         type = lexrc.getString();
560                         // Here we could check if this type is already defined
561                         // and modify it with the rest of the vars instead.
562                         break;
563                 case FT_NAME:
564                         lexrc.next();
565                         name = lexrc.getString();
566                         break;
567                 case FT_PLACEMENT:
568                         lexrc.next();
569                         placement = lexrc.getString();
570                         break;
571                 case FT_EXT:
572                         lexrc.next();
573                         ext = lexrc.getString();
574                         break;
575                 case FT_WITHIN:
576                         lexrc.next();
577                         within = lexrc.getString();
578                         if (within == "none")
579                                 within.erase();
580                         break;
581                 case FT_STYLE:
582                         lexrc.next();
583                         style = lexrc.getString();
584                         break;
585                 case FT_LISTNAME:
586                         lexrc.next();
587                         listname = lexrc.getString();
588                         break;
589                 case FT_BUILTIN:
590                         lexrc.next();
591                         builtin = lexrc.getBool();
592                         break;
593                 case FT_END:
594                         getout = true;
595                         break;
596                 }
597         }
598
599         // Here if have a full float if getout == true
600         if (getout) {
601                 Floating newfloat(type, placement, ext, within,
602                                   style, name, listname, builtin);
603                 floatlist_->newFloat(newfloat);
604         }
605
606         lexrc.popTable();
607 }
608
609
610 enum CounterTags {
611         CT_NAME = 1,
612         CT_WITHIN,
613         CT_END
614 };
615
616 void LyXTextClass::readCounter(LyXLex & lexrc)
617 {
618         keyword_item counterTags[] = {
619                 { "end", CT_END },
620                 { "name", CT_NAME },
621                 { "within", CT_WITHIN }
622         };
623
624         lexrc.pushTable(counterTags, CT_END);
625
626         string name;
627         string within;
628
629         bool getout = false;
630         while (!getout && lexrc.isOK()) {
631                 int le = lexrc.lex();
632                 switch (le) {
633                 case LyXLex::LEX_UNDEF:
634                         lexrc.printError("Unknown ClassOption tag `$$Token'");
635                         continue;
636                 default: break;
637                 }
638                 switch (static_cast<CounterTags>(le)) {
639                 case CT_NAME:
640                         lexrc.next();
641                         name = lexrc.getString();
642                         break;
643                 case CT_WITHIN:
644                         lexrc.next();
645                         within = lexrc.getString();
646                         if (within == "none")
647                                 within.erase();
648                         break;
649                 case CT_END:
650                         getout = true;
651                         break;
652                 }
653         }
654
655         // Here if have a full float if getout == true
656         if (getout) {
657                 if (within.empty()) {
658                         ctrs_->newCounter(name);
659                 } else {
660                         ctrs_->newCounter(name, within);
661                 }
662         }
663
664         lexrc.popTable();
665 }
666
667
668 LyXFont const & LyXTextClass::defaultfont() const
669 {
670         return defaultfont_;
671 }
672
673
674 string const & LyXTextClass::leftmargin() const
675 {
676         return leftmargin_;
677 }
678
679
680 string const & LyXTextClass::rightmargin() const
681 {
682         return rightmargin_;
683 }
684
685
686 bool LyXTextClass::hasLayout(string const & n) const
687 {
688         string const name = (n.empty() ? defaultLayoutName() : n);
689
690         return find_if(layoutlist_.begin(), layoutlist_.end(),
691                        compare_name(name))
692                 != layoutlist_.end();
693 }
694
695
696 LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
697 {
698         lyx::Assert(!n.empty());
699
700         if (n.empty())
701                 lyxerr << "Operator[] called with empty n" << endl;
702
703         string const name = (n.empty() ? defaultLayoutName() : n);
704
705         static string lastLayoutName;
706         static LayoutList::difference_type lastLayoutIndex;
707
708         if (name == lastLayoutName)
709                 return layoutlist_[lastLayoutIndex];
710
711         LayoutList::const_iterator cit =
712                 find_if(layoutlist_.begin(),
713                         layoutlist_.end(),
714                         compare_name(name));
715
716         if (cit == layoutlist_.end()) {
717                 lyxerr << "We failed to find the layout '" << name
718                        << "' in the layout list. You MUST investigate!"
719                        << endl;
720
721                 // we require the name to exist
722                 lyx::Assert(false);
723         }
724
725         lastLayoutName = name;
726         lastLayoutIndex = std::distance(layoutlist_.begin(), cit);
727
728         return (*cit);
729 }
730
731
732 bool LyXTextClass::delete_layout(string const & name)
733 {
734         if (name == defaultLayoutName())
735                 return false;
736
737         LayoutList::iterator it =
738                 remove_if(layoutlist_.begin(), layoutlist_.end(),
739                           compare_name(name));
740
741         LayoutList::iterator end = layoutlist_.end();
742         bool const ret = (it != end);
743         layoutlist_.erase(it, end);
744         return ret;
745 }
746
747
748 // Load textclass info if not loaded yet
749 bool LyXTextClass::load() const
750 {
751         if (loaded)
752                 return true;
753
754         // Read style-file
755         string const real_file = LibFileSearch("layouts", name_, "layout");
756
757         if (const_cast<LyXTextClass*>(this)->Read(real_file)) {
758                 lyxerr << "Error reading `"
759                        << MakeDisplayPath(real_file)
760                        << "'\n(Check `" << name_
761                        << "')\nCheck your installation and "
762                         "try Options/Reconfigure..." << endl;
763                 loaded = false;
764         }
765         loaded = true;
766         return loaded;
767 }
768
769
770 FloatList & LyXTextClass::floats()
771 {
772         return *floatlist_.get();
773 }
774
775
776 FloatList const & LyXTextClass::floats() const
777 {
778         return *floatlist_.get();
779 }
780
781
782 Counters & LyXTextClass::counters() const
783 {
784         return *ctrs_.get();
785 }
786
787
788 string const & LyXTextClass::defaultLayoutName() const
789 {
790         // This really should come from the actual layout... (Lgb)
791         return defaultlayout_;
792 }
793
794
795 LyXLayout_ptr const & LyXTextClass::defaultLayout() const
796 {
797         return operator[](defaultLayoutName());
798 }
799
800
801 string const & LyXTextClass::name() const
802 {
803         return name_;
804 }
805
806
807 string const & LyXTextClass::latexname() const
808 {
809         const_cast<LyXTextClass*>(this)->load();
810         return latexname_;
811 }
812
813
814 string const & LyXTextClass::description() const
815 {
816         return description_;
817 }
818
819
820 string const & LyXTextClass::opt_fontsize() const
821 {
822         return opt_fontsize_;
823 }
824
825
826 string const & LyXTextClass::opt_pagestyle() const
827 {
828         return opt_pagestyle_;
829 }
830
831
832 string const & LyXTextClass::options() const
833 {
834         return options_;
835 }
836
837
838 string const & LyXTextClass::pagestyle() const
839 {
840         return pagestyle_;
841 }
842
843
844 string const & LyXTextClass::preamble() const
845 {
846         return preamble_;
847 }
848
849
850 LyXTextClass::PageSides LyXTextClass::sides() const
851 {
852         return sides_;
853 }
854
855
856 int LyXTextClass::secnumdepth() const
857 {
858         return secnumdepth_;
859 }
860
861
862 int LyXTextClass::tocdepth() const
863 {
864         return tocdepth_;
865 }
866
867
868 OutputType LyXTextClass::outputType() const
869 {
870         return outputType_;
871 }
872
873
874 bool LyXTextClass::provides(LyXTextClass::Provides p) const
875 {
876         return provides_ & p;
877 }
878
879
880 unsigned int LyXTextClass::columns() const
881 {
882         return columns_;
883 }
884
885
886 int LyXTextClass::maxcounter() const
887 {
888         return maxcounter_;
889 }
890
891
892 int LyXTextClass::size() const
893 {
894         return layoutlist_.size();
895 }
896
897
898 ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
899 {
900         switch (p) {
901         case LyXTextClass::OneSide:
902                 os << '1';
903                 break;
904         case LyXTextClass::TwoSides:
905                 os << '2';
906                 break;
907         }
908         return os;
909 }