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