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