]> git.lyx.org Git - lyx.git/blob - src/lyxtextclass.C
the spellcheck cleanup
[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                                                         );
239
240                                         if (defaultlayout_.empty()) {
241                                                 // We do not have a default
242                                                 // layout yet, so we choose
243                                                 // the first layout we
244                                                 // encounter.
245                                                 defaultlayout_ = name;
246                                         }
247                                 }
248                         }
249                         else {
250                                 lexrc.printError("No name given for style: `$$Token'.");
251                                 error = true;
252                         }
253                         break;
254
255                 case TC_NOSTYLE:
256                         if (lexrc.next()) {
257                                 string const style = subst(lexrc.getString(),
258                                                      '_', ' ');
259                                 if (!delete_layout(style))
260                                         lyxerr << "Cannot delete style `"
261                                                << style << '\'' << endl;
262 //                                      lexrc.printError("Cannot delete style"
263 //                                                       " `$$Token'");
264                         }
265                         break;
266
267                 case TC_COLUMNS:
268                         if (lexrc.next())
269                                 columns_ = lexrc.getInteger();
270                         break;
271
272                 case TC_SIDES:
273                         if (lexrc.next()) {
274                                 switch (lexrc.getInteger()) {
275                                 case 1: sides_ = OneSide; break;
276                                 case 2: sides_ = TwoSides; break;
277                                 default:
278                                         lyxerr << "Impossible number of page"
279                                                 " sides, setting to one."
280                                                << endl;
281                                         sides_ = OneSide;
282                                         break;
283                                 }
284                         }
285                         break;
286
287                 case TC_PAGESTYLE:
288                         lexrc.next();
289                         pagestyle_ = rtrim(lexrc.getString());
290                         break;
291
292                 case TC_DEFAULTFONT:
293                         defaultfont_.lyxRead(lexrc);
294                         if (!defaultfont_.resolved()) {
295                                 lexrc.printError("Warning: defaultfont should "
296                                                  "be fully instantiated!");
297                                 defaultfont_.realize(LyXFont(LyXFont::ALL_SANE));
298                         }
299                         break;
300
301                 case TC_SECNUMDEPTH:
302                         lexrc.next();
303                         secnumdepth_ = lexrc.getInteger();
304                         break;
305
306                 case TC_TOCDEPTH:
307                         lexrc.next();
308                         tocdepth_ = lexrc.getInteger();
309                         break;
310
311                         // First step to support options
312                 case TC_CLASSOPTIONS:
313                         readClassOptions(lexrc);
314                         break;
315
316                 case TC_PREAMBLE:
317                         preamble_ = lexrc.getLongString("EndPreamble");
318                         break;
319
320                 case TC_PROVIDESAMSMATH:
321                         if (lexrc.next() && lexrc.getInteger())
322                                 provides_ |= amsmath;
323                         break;
324
325                 case TC_PROVIDESNATBIB:
326                         if (lexrc.next() && lexrc.getInteger())
327                                 provides_ |= natbib;
328                         break;
329
330                 case TC_PROVIDESMAKEIDX:
331                         if (lexrc.next() && lexrc.getInteger())
332                                 provides_ |= makeidx;
333                         break;
334
335                 case TC_PROVIDESURL:
336                         if (lexrc.next() && lexrc.getInteger())
337                                 provides_ |= url;
338                         break;
339
340                 case TC_LEFTMARGIN:     // left margin type
341                         if (lexrc.next())
342                                 leftmargin_ = lexrc.getString();
343                         break;
344
345                 case TC_RIGHTMARGIN:    // right margin type
346                         if (lexrc.next())
347                                 rightmargin_ = lexrc.getString();
348                         break;
349                 case TC_FLOAT:
350                         readFloat(lexrc);
351                         break;
352                 case TC_COUNTER:
353                         readCounter(lexrc);
354                         break;
355                 case TC_TITLELATEXTYPE:
356                         readTitleType(lexrc);
357                         break;
358                 case TC_TITLELATEXNAME:
359                         if (lexrc.next())
360                                 titlename_ = lexrc.getString();
361                         break;
362                 case TC_NOFLOAT:
363                         if (lexrc.next()) {
364                                 string const nofloat = lexrc.getString();
365                                 floatlist_->erase(nofloat);
366                         }
367                         break;
368                 }
369         }
370
371         if (!merge) { // we are at top level here.
372                 lyxerr[Debug::TCLASS] << "Finished reading textclass "
373                                       << MakeDisplayPath(filename)
374                                       << endl;
375                 if (defaultlayout_.empty()) {
376                         lyxerr << "Error: Textclass '" << name_
377                                << "' is missing a defaultstyle." << endl;
378                         error = true;
379                 }
380         } else
381                 lyxerr[Debug::TCLASS] << "Finished reading input file "
382                                       << MakeDisplayPath(filename)
383                                       << endl;
384
385         return error;
386 }
387
388
389 void LyXTextClass::readTitleType(LyXLex & lexrc)
390 {
391         keyword_item titleTypeTags[] = {
392                 { "commandafter", TITLE_COMMAND_AFTER },
393                 { "environment", TITLE_ENVIRONMENT }
394         };
395
396         pushpophelper pph(lexrc, titleTypeTags, TITLE_ENVIRONMENT);
397
398         int le = lexrc.lex();
399         switch (le) {
400         case LyXLex::LEX_UNDEF:
401                 lexrc.printError("Unknown output type `$$Token'");
402                 return;
403         case TITLE_COMMAND_AFTER:
404         case TITLE_ENVIRONMENT:
405                 titletype_ = static_cast<LYX_TITLE_LATEX_TYPES>(le);
406                 break;
407         default:
408                 lyxerr << "Unhandled value " << le
409                        << " in LyXTextClass::readTitleType." << endl;
410
411                 break;
412         }
413 }
414
415
416 void LyXTextClass::readOutputType(LyXLex & lexrc)
417 {
418         keyword_item outputTypeTags[] = {
419                 { "docbook", DOCBOOK },
420                 { "latex", LATEX },
421                 { "linuxdoc", LINUXDOC },
422                 { "literate", LITERATE }
423         };
424
425         pushpophelper pph(lexrc, outputTypeTags, LITERATE);
426
427         int le = lexrc.lex();
428         switch (le) {
429         case LyXLex::LEX_UNDEF:
430                 lexrc.printError("Unknown output type `$$Token'");
431                 return;
432         case LATEX:
433         case LINUXDOC:
434         case DOCBOOK:
435         case LITERATE:
436                 outputType_ = static_cast<OutputType>(le);
437                 break;
438         default:
439                 lyxerr << "Unhandled value " << le
440                        << " in LyXTextClass::readOutputType." << endl;
441
442                 break;
443         }
444 }
445
446
447 enum MaxCounterTags {
448         MC_COUNTER_CHAPTER = 1,
449         MC_COUNTER_SECTION,
450         MC_COUNTER_SUBSECTION,
451         MC_COUNTER_SUBSUBSECTION,
452         MC_COUNTER_PARAGRAPH,
453         MC_COUNTER_SUBPARAGRAPH,
454         MC_COUNTER_ENUMI,
455         MC_COUNTER_ENUMII,
456         MC_COUNTER_ENUMIII,
457         MC_COUNTER_ENUMIV
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 counter 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
697 LyXLayout_ptr const & LyXTextClass::operator[](string const & name) const
698 {
699         BOOST_ASSERT(!name.empty());
700
701         LayoutList::const_iterator cit =
702                 find_if(layoutlist_.begin(),
703                         layoutlist_.end(),
704                         compare_name(name));
705
706         if (cit == layoutlist_.end()) {
707                 lyxerr << "We failed to find the layout '" << name
708                        << "' in the layout list. You MUST investigate!"
709                        << endl;
710                 for (LayoutList::const_iterator it = layoutlist_.begin();
711                          it != layoutlist_.end(); ++it)
712                         lyxerr  << " " << it->get()->name() << endl;
713
714                 // we require the name to exist
715                 BOOST_ASSERT(false);
716         }
717
718         return (*cit);
719 }
720
721
722
723 bool LyXTextClass::delete_layout(string const & name)
724 {
725         if (name == defaultLayoutName())
726                 return false;
727
728         LayoutList::iterator it =
729                 remove_if(layoutlist_.begin(), layoutlist_.end(),
730                           compare_name(name));
731
732         LayoutList::iterator end = layoutlist_.end();
733         bool const ret = (it != end);
734         layoutlist_.erase(it, end);
735         return ret;
736 }
737
738
739 // Load textclass info if not loaded yet
740 bool LyXTextClass::load() const
741 {
742         if (loaded)
743                 return true;
744
745         // Read style-file
746         string const real_file = LibFileSearch("layouts", name_, "layout");
747
748         if (const_cast<LyXTextClass*>(this)->Read(real_file)) {
749                 lyxerr << "Error reading `"
750                        << MakeDisplayPath(real_file)
751                        << "'\n(Check `" << name_
752                        << "')\nCheck your installation and "
753                         "try Options/Reconfigure..." << endl;
754                 loaded = false;
755         }
756         loaded = true;
757         return loaded;
758 }
759
760
761 FloatList & LyXTextClass::floats()
762 {
763         return *floatlist_.get();
764 }
765
766
767 FloatList const & LyXTextClass::floats() const
768 {
769         return *floatlist_.get();
770 }
771
772
773 Counters & LyXTextClass::counters() const
774 {
775         return *ctrs_.get();
776 }
777
778
779 string const & LyXTextClass::defaultLayoutName() const
780 {
781         // This really should come from the actual layout... (Lgb)
782         return defaultlayout_;
783 }
784
785
786 LyXLayout_ptr const & LyXTextClass::defaultLayout() const
787 {
788         return operator[](defaultLayoutName());
789 }
790
791
792 string const & LyXTextClass::name() const
793 {
794         return name_;
795 }
796
797
798 string const & LyXTextClass::latexname() const
799 {
800         const_cast<LyXTextClass*>(this)->load();
801         return latexname_;
802 }
803
804
805 string const & LyXTextClass::description() const
806 {
807         return description_;
808 }
809
810
811 string const & LyXTextClass::opt_fontsize() const
812 {
813         return opt_fontsize_;
814 }
815
816
817 string const & LyXTextClass::opt_pagestyle() const
818 {
819         return opt_pagestyle_;
820 }
821
822
823 string const & LyXTextClass::options() const
824 {
825         return options_;
826 }
827
828
829 string const & LyXTextClass::pagestyle() const
830 {
831         return pagestyle_;
832 }
833
834
835 string const & LyXTextClass::preamble() const
836 {
837         return preamble_;
838 }
839
840
841 LyXTextClass::PageSides LyXTextClass::sides() const
842 {
843         return sides_;
844 }
845
846
847 int LyXTextClass::secnumdepth() const
848 {
849         return secnumdepth_;
850 }
851
852
853 int LyXTextClass::tocdepth() const
854 {
855         return tocdepth_;
856 }
857
858
859 OutputType LyXTextClass::outputType() const
860 {
861         return outputType_;
862 }
863
864
865 bool LyXTextClass::provides(LyXTextClass::Provides p) const
866 {
867         return provides_ & p;
868 }
869
870
871 unsigned int LyXTextClass::columns() const
872 {
873         return columns_;
874 }
875
876
877 LYX_TITLE_LATEX_TYPES LyXTextClass::titletype() const
878 {
879         return titletype_;
880 }
881
882
883 string const & LyXTextClass::titlename() const
884 {
885         return titlename_;
886 }
887
888
889 int LyXTextClass::size() const
890 {
891         return layoutlist_.size();
892 }
893
894
895 ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
896 {
897         switch (p) {
898         case LyXTextClass::OneSide:
899                 os << '1';
900                 break;
901         case LyXTextClass::TwoSides:
902                 os << '2';
903                 break;
904         }
905         return os;
906 }