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