3 * \file InsetLayout.cpp
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Martin Vermeer
8 * \author Richard Kimberly Heck
10 * Full author contact details are available in file CREDITS.
15 #include "InsetLayout.h"
18 #include "TextClass.h"
20 #include "support/debug.h"
21 #include "support/Lexer.h"
22 #include "support/lstrings.h"
23 #include "support/textutils.h"
31 using namespace lyx::support;
35 InsetDecoration translateDecoration(std::string const & str)
37 if (compare_ascii_no_case(str, "classic") == 0)
38 return InsetDecoration::CLASSIC;
39 if (compare_ascii_no_case(str, "minimalistic") == 0)
40 return InsetDecoration::MINIMALISTIC;
41 if (compare_ascii_no_case(str, "conglomerate") == 0)
42 return InsetDecoration::CONGLOMERATE;
43 return InsetDecoration::DEFAULT;
48 InsetLaTeXType translateLaTeXType(std::string const & str)
50 if (compare_ascii_no_case(str, "command") == 0)
51 return InsetLaTeXType::COMMAND;
52 if (compare_ascii_no_case(str, "environment") == 0)
53 return InsetLaTeXType::ENVIRONMENT;
54 if (compare_ascii_no_case(str, "none") == 0)
55 return InsetLaTeXType::NOLATEXTYPE;
56 return InsetLaTeXType::ILT_ERROR;
62 bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
69 IL_ALLOWED_OCCURRENCES,
70 IL_ALLOWED_OCCURRENCES_PER_ITEM,
81 IL_FIXEDWIDTH_PREAMBLE_ENCODING,
83 IL_FORCE_LOCAL_FONT_SWITCH,
103 IL_DOCBOOKARGUMENTBEFOREMAINTAG,
104 IL_DOCBOOKARGUMENTAFTERMAINTAG,
106 IL_DOCBOOKWRAPPERTAG,
107 IL_DOCBOOKWRAPPERTAGTYPE,
108 IL_DOCBOOKWRAPPERATTR,
110 IL_DOCBOOKITEMTAGTYPE,
112 IL_DOCBOOKITEMWRAPPERTAG,
113 IL_DOCBOOKITEMWRAPPERTAGTYPE,
114 IL_DOCBOOKITEMWRAPPERATTR,
116 IL_DOCBOOKINNERTAGTYPE,
118 IL_DOCBOOKNOFONTINSIDE,
119 IL_DOCBOOKRENDERASIMAGE,
139 IL_NO_PASSTHRU_CHARS,
143 IL_PARBREAKISNEWLINE,
155 LexerKeyword elementTags[] = {
156 { "addtotoc", IL_ADDTOTOC },
157 { "allowedininsets", IL_ALLOWED_IN_INSET },
158 { "allowedinlayouts", IL_ALLOWED_IN_LAYOUT },
159 { "allowedoccurrences", IL_ALLOWED_OCCURRENCES },
160 { "allowedoccurrencesperitem", IL_ALLOWED_OCCURRENCES_PER_ITEM },
161 { "argument", IL_ARGUMENT },
162 { "babelpreamble", IL_BABELPREAMBLE },
163 { "bgcolor", IL_BGCOLOR },
164 { "contentaslabel", IL_CONTENTASLABEL },
165 { "copystyle", IL_COPYSTYLE },
166 { "counter", IL_COUNTER},
167 { "custompars", IL_CUSTOMPARS },
168 { "decoration", IL_DECORATION },
169 { "display", IL_DISPLAY },
170 { "docbookargumentaftermaintag", IL_DOCBOOKARGUMENTAFTERMAINTAG },
171 { "docbookargumentbeforemaintag", IL_DOCBOOKARGUMENTBEFOREMAINTAG },
172 { "docbookattr", IL_DOCBOOKATTR },
173 { "docbookininfo", IL_DOCBOOKININFO },
174 { "docbookinnerattr", IL_DOCBOOKINNERATTR },
175 { "docbookinnertag", IL_DOCBOOKINNERTAG },
176 { "docbookinnertagtype", IL_DOCBOOKINNERTAGTYPE },
177 { "docbookitemattr", IL_DOCBOOKITEMATTR },
178 { "docbookitemtag", IL_DOCBOOKITEMTAG },
179 { "docbookitemtagtype", IL_DOCBOOKITEMTAGTYPE },
180 { "docbookitemwrapperattr", IL_DOCBOOKITEMWRAPPERATTR },
181 { "docbookitemwrappertag", IL_DOCBOOKITEMWRAPPERTAG },
182 { "docbookitemwrappertagtype", IL_DOCBOOKITEMWRAPPERTAGTYPE },
183 { "docbooknofontinside", IL_DOCBOOKNOFONTINSIDE },
184 { "docbooknotinpara", IL_DOCBOOKNOTINPARA },
185 { "docbookrenderasimage", IL_DOCBOOKRENDERASIMAGE },
186 { "docbooksection", IL_DOCBOOKSECTION },
187 { "docbooktag", IL_DOCBOOKTAG },
188 { "docbooktagtype", IL_DOCBOOKTAGTYPE },
189 { "docbookwrapperattr", IL_DOCBOOKWRAPPERATTR },
190 { "docbookwrappertag", IL_DOCBOOKWRAPPERTAG },
191 { "docbookwrappertagtype", IL_DOCBOOKWRAPPERTAGTYPE },
192 { "editexternal", IL_EDITEXTERNAL },
194 { "fixedwidthpreambleencoding", IL_FIXEDWIDTH_PREAMBLE_ENCODING },
196 { "forcelocalfontswitch", IL_FORCE_LOCAL_FONT_SWITCH },
197 { "forceltr", IL_FORCELTR },
198 { "forceownlines", IL_FORCEOWNLINES },
199 { "forceplain", IL_FORCEPLAIN },
200 { "freespacing", IL_FREESPACING },
201 { "htmlattr", IL_HTMLATTR },
202 { "htmlclass", IL_HTMLCLASS },
203 { "htmlforcecss", IL_HTMLFORCECSS },
204 { "htmlinnerattr", IL_HTMLINNERATTR},
205 { "htmlinnertag", IL_HTMLINNERTAG},
206 { "htmlisblock", IL_HTMLISBLOCK},
207 { "htmllabel", IL_HTMLLABEL },
208 { "htmlpreamble", IL_HTMLPREAMBLE },
209 { "htmlstyle", IL_HTMLSTYLE },
210 { "htmltag", IL_HTMLTAG },
211 { "inheritfont", IL_INHERITFONT },
212 { "intoc", IL_INTOC },
213 { "istoccaption", IL_ISTOCCAPTION },
214 { "keepempty", IL_KEEPEMPTY },
215 { "labelfont", IL_LABELFONT },
216 { "labelstring", IL_LABELSTRING },
217 { "langpreamble", IL_LANGPREAMBLE },
218 { "latexname", IL_LATEXNAME },
219 { "latexparam", IL_LATEXPARAM },
220 { "latextype", IL_LATEXTYPE },
221 { "leftdelim", IL_LEFTDELIM },
222 { "lyxtype", IL_LYXTYPE },
223 { "menustring", IL_MENUSTRING },
224 { "multipar", IL_MULTIPAR },
225 { "needcprotect", IL_NEEDCPROTECT },
226 { "needmboxprotect", IL_NEEDMBOXPROTECT },
227 { "needprotect", IL_NEEDPROTECT },
228 { "newlinecmd", IL_NEWLINE_CMD },
229 { "nopassthruchars", IL_NO_PASSTHRU_CHARS },
230 { "obsoletedby", IL_OBSOLETEDBY },
231 { "parbreakignored", IL_PARBREAKIGNORED },
232 { "parbreakisnewline", IL_PARBREAKISNEWLINE },
233 { "passthru", IL_PASSTHRU },
234 { "passthruchars", IL_PASSTHRU_CHARS },
235 { "preamble", IL_PREAMBLE },
236 { "refprefix", IL_REFPREFIX },
237 { "requires", IL_REQUIRES },
238 { "resetargs", IL_RESETARGS },
239 { "resetsfont", IL_RESETSFONT },
240 { "rightdelim", IL_RIGHTDELIM },
241 { "spellcheck", IL_SPELLCHECK }
244 lex.pushTable(elementTags);
246 if (labelfont_ == sane_font)
247 labelfont_ = inherit_font;
248 if (bgcolor_ == Color_error)
249 bgcolor_ = Color_none;
251 // whether we've read the CustomPars or ForcePlain tag
252 // for issuing a warning in case MultiPars comes later
253 bool readCustomOrPlain = false;
256 while (!getout && lex.isOK()) {
259 case Lexer::LEX_UNDEF:
260 lex.printError("Unknown InsetLayout tag");
269 // Perhaps a more elegant way to deal with the next two would be the
270 // way this sort of thing is handled in Layout::read(), namely, by
273 // make sure that we have the right sort of name.
274 if (name_ != from_ascii("undefined")
275 && name_.substr(0,5) != from_ascii("Flex:")) {
276 LYXERR0("Flex insets must have names of the form `Flex:<name>'.\n"
277 "This one has the name `" << to_utf8(name_) << "'\n"
278 "Ignoring LyXType declaration.");
279 // this is not really a reason to abort
286 lyxtype_ = translateLyXType(lt);
287 if (lyxtype_ == InsetLyXType::NOLYXTYPE) {
288 LYXERR0("Unknown LyXType `" << lt << "'.");
289 // this is not really a reason to abort
293 if (lyxtype_ == InsetLyXType::CHARSTYLE) {
294 // by default, charstyles force the plain layout
303 latextype_ = translateLaTeXType(lt);
304 if (latextype_ == InsetLaTeXType::ILT_ERROR) {
305 LYXERR0("Unknown LaTeXType `" << lt << "'.");
306 // this is not really a reason to abort
320 decoration_ = translateDecoration(tmp);
327 latexparam_ = subst(tmp, """, "\"");
331 leftdelim_ = subst(leftdelim_, from_ascii("<br/>"),
334 case IL_FIXEDWIDTH_PREAMBLE_ENCODING:
335 lex >> fixedwidthpreambleencoding_;
337 case IL_FORCE_LOCAL_FONT_SWITCH:
338 lex >> forcelocalfontswitch_;
342 rightdelim_ = subst(rightdelim_, from_ascii("<br/>"),
346 labelfont_ = lyxRead(lex, inherit_font);
351 case IL_FORCEOWNLINES:
352 lex >> forceownlines_;
362 // the defaults for these depend upon multipar_
363 if (readCustomOrPlain)
364 LYXERR0("Warning: Read MultiPar after CustomPars or ForcePlain. "
365 "Previous value may be overwritten!");
366 readCustomOrPlain = false;
367 custompars_ = multipar_;
368 forceplain_ = !multipar_;
375 readCustomOrPlain = true;
379 readCustomOrPlain = true;
384 case IL_PASSTHRU_CHARS:
385 lex >> passthru_chars_;
387 case IL_NO_PASSTHRU_CHARS:
388 lex >> no_passthru_chars_;
393 case IL_PARBREAKIGNORED:
394 lex >> parbreakignored_;
396 case IL_PARBREAKISNEWLINE:
397 lex >> parbreakisnewline_;
408 case IL_NEEDCPROTECT: {
412 needcprotect_ = false;
415 else if (val == "1" || val == "true")
416 needcprotect_ = true;
419 case IL_NEEDMBOXPROTECT:
420 lex >> needmboxprotect_;
422 case IL_CONTENTASLABEL:
423 lex >> contentaslabel_;
426 // initialize with a known style
429 style = subst(style, '_', ' ');
431 // We don't want to apply the algorithm in DocumentClass::insetLayout()
432 // here. So we do it the long way.
433 TextClass::InsetLayouts::const_iterator it =
434 tclass.insetLayouts().find(style);
435 if (it != tclass.insetLayouts().end()) {
436 docstring const tmpname = name_;
437 this->operator=(it->second);
440 LYXERR0("Cannot copy unknown InsetLayout `"
441 << style << "' to InsetLayout `"
443 << "All InsetLayouts so far:");
444 TextClass::InsetLayouts::const_iterator lit =
445 tclass.insetLayouts().begin();
446 TextClass::InsetLayouts::const_iterator len =
447 tclass.insetLayouts().end();
448 for (; lit != len; ++lit)
449 lyxerr << lit->second.name() << "\n";
450 // this is not really a reason to abort
456 case IL_OBSOLETEDBY: {
459 style = subst(style, '_', ' ');
461 // We don't want to apply the algorithm in DocumentClass::insetLayout()
462 // here. So we do it the long way.
463 TextClass::InsetLayouts::const_iterator it =
464 tclass.insetLayouts().find(style);
465 if (it != tclass.insetLayouts().end()) {
466 docstring const tmpname = name_;
467 this->operator=(it->second);
469 if (obsoleted_by().empty())
470 obsoleted_by_ = style;
472 LYXERR0("Cannot replace InsetLayout `"
474 << "' with unknown InsetLayout `"
476 << "All InsetLayouts so far:");
477 TextClass::InsetLayouts::const_iterator lit =
478 tclass.insetLayouts().begin();
479 TextClass::InsetLayouts::const_iterator len =
480 tclass.insetLayouts().end();
481 for (; lit != len; ++lit)
482 lyxerr << lit->second.name() << "\n";
483 // this is not really a reason to abort
491 font_ = lyxRead(lex, inherit_font);
492 // If you want to define labelfont, you need to do so after
502 postcommandargs_.clear();
510 bgcolor_ = lcolor.getFromLyXName(tmp);
513 preamble_ = lex.getLongString(from_ascii("EndPreamble"));
515 case IL_BABELPREAMBLE:
516 babelpreamble_ = lex.getLongString(from_ascii("EndBabelPreamble"));
518 case IL_LANGPREAMBLE:
519 langpreamble_ = lex.getLongString(from_ascii("EndLangPreamble"));
533 case IL_HTMLFORCECSS:
534 lex >> htmlforcecss_;
536 case IL_HTMLINNERTAG:
537 lex >> htmlinnertag_;
539 case IL_HTMLINNERATTR:
540 lex >> htmlinnerattr_;
549 htmlstyle_ = lex.getLongString(from_ascii("EndHTMLStyle"));
551 case IL_HTMLPREAMBLE:
552 htmlpreamble_ = lex.getLongString(from_ascii("EndPreamble"));
560 case IL_DOCBOOKTAGTYPE:
561 lex >> docbooktagtype_;
563 case IL_DOCBOOKINNERTAG:
564 lex >> docbookinnertag_;
566 case IL_DOCBOOKINNERATTR:
567 lex >> docbookinnerattr_;
569 case IL_DOCBOOKINNERTAGTYPE:
570 lex >> docbookinnertagtype_;
572 case IL_DOCBOOKININFO:
573 lex >> docbookininfo_;
575 case IL_DOCBOOKARGUMENTBEFOREMAINTAG:
576 lex >> docbookargumentbeforemaintag_;
578 case IL_DOCBOOKARGUMENTAFTERMAINTAG:
579 lex >> docbookargumentaftermaintag_;
581 case IL_DOCBOOKNOTINPARA:
582 lex >> docbooknotinpara_;
584 case IL_DOCBOOKSECTION:
585 lex >> docbooksection_;
587 case IL_DOCBOOKITEMTAG:
588 lex >> docbookitemtag_;
590 case IL_DOCBOOKITEMTAGTYPE:
591 lex >> docbookitemtagtype_;
593 case IL_DOCBOOKITEMATTR:
594 lex >> docbookitemattr_;
596 case IL_DOCBOOKITEMWRAPPERTAG:
597 lex >> docbookitemwrappertag_;
599 case IL_DOCBOOKITEMWRAPPERTAGTYPE:
600 lex >> docbookitemwrappertagtype_;
602 case IL_DOCBOOKITEMWRAPPERATTR:
603 lex >> docbookitemwrapperattr_;
605 case IL_DOCBOOKWRAPPERTAG:
606 lex >> docbookwrappertag_;
608 case IL_DOCBOOKWRAPPERTAGTYPE:
609 lex >> docbookwrappertagtype_;
611 case IL_DOCBOOKWRAPPERATTR:
612 lex >> docbookwrapperattr_;
614 case IL_DOCBOOKNOFONTINSIDE:
615 lex >> docbooknofontinside_;
617 case IL_DOCBOOKRENDERASIMAGE:
618 lex >> docbookrenderasimage_;
622 vector<string> const req
623 = getVectorFromString(lex.getString(true));
624 required_.insert(req.begin(), req.end());
638 add_to_toc_ = !toc_type_.empty();
640 case IL_ISTOCCAPTION:
641 lex >> is_toc_caption_;
643 case IL_EDITEXTERNAL:
644 lex >> edit_external_;
646 case IL_ALLOWED_IN_INSET: {
647 docstring allowed = lex.getLongString(from_ascii("EndAllowedInInsets"));
648 allowed = subst(allowed, from_ascii("\n"), docstring());
649 allowed = subst(allowed, from_ascii("\t"), docstring());
650 allowed = subst(allowed, from_ascii("\""), docstring());
651 allowed = subst(allowed, '_', ' ');
652 vector<docstring> const allowances =
653 getVectorFromString(allowed, from_ascii(","), false, true);
654 allowed_in_insets_.clear();
655 allowed_in_insets_.insert(allowances.begin(), allowances.end());
659 case IL_ALLOWED_IN_LAYOUT: {
660 docstring allowed = lex.getLongString(from_ascii("EndAllowedInLayouts"));
661 allowed = subst(allowed, from_ascii("\n"), docstring());
662 allowed = subst(allowed, from_ascii("\t"), docstring());
663 allowed = subst(allowed, from_ascii("\""), docstring());
664 allowed = subst(allowed, '_', ' ');
665 vector<docstring> const allowances =
666 getVectorFromString(allowed, from_ascii(","), false, true);
667 allowed_in_layouts_.clear();
668 allowed_in_layouts_.insert(allowances.begin(), allowances.end());
671 case IL_ALLOWED_OCCURRENCES:
672 lex >> allowed_occurrences_;
674 case IL_ALLOWED_OCCURRENCES_PER_ITEM:
675 lex >> allowed_occurrences_per_item_;
683 // Here add element to list if getout == true
687 // The label font is generally used as-is without
688 // any realization against a given context.
689 labelfont_.realize(sane_font);
696 InsetLyXType translateLyXType(std::string const & str)
698 if (compare_ascii_no_case(str, "charstyle") == 0)
699 return InsetLyXType::CHARSTYLE;
700 if (compare_ascii_no_case(str, "custom") == 0)
701 return InsetLyXType::CUSTOM;
702 if (compare_ascii_no_case(str, "end") == 0)
703 return InsetLyXType::END;
704 if (compare_ascii_no_case(str, "standard") == 0)
705 return InsetLyXType::STANDARD;
706 return InsetLyXType::NOLYXTYPE;
710 string const & InsetLayout::htmltag() const
712 if (htmltag_.empty())
713 htmltag_ = multipar_ ? "div" : "span";
718 string const & InsetLayout::htmlclass() const
720 if (htmlclass_.empty())
721 htmlclass_ = defaultCSSClass();
726 std::string const & InsetLayout::htmlGetAttrString() const {
727 if (!htmlfullattrs_.empty())
728 return htmlfullattrs_;
729 htmlfullattrs_ = htmlclass();
730 if (!htmlfullattrs_.empty())
731 htmlfullattrs_ = "class='" + htmlfullattrs_ + "'";
732 if (!htmlattr_.empty())
733 htmlfullattrs_ += " " + htmlattr_;
734 return htmlfullattrs_;
738 string const & InsetLayout::htmlinnerattr() const
740 if (htmlinnerattr_.empty())
741 htmlinnerattr_ = "class=\"" + defaultCSSClass() + "_inner\"";
742 return htmlinnerattr_;
746 string InsetLayout::defaultCSSClass() const
748 if (!defaultcssclass_.empty())
749 return defaultcssclass_;
751 string n = to_utf8(name());
752 string::const_iterator it = n.begin();
753 string::const_iterator en = n.end();
754 for (; it != en; ++it) {
755 if (!isAlphaASCII(*it))
757 else if (isLower(*it))
762 // are there other characters we need to remove?
763 defaultcssclass_ = d;
764 return defaultcssclass_;
768 void InsetLayout::makeDefaultCSS() const
770 if (!htmldefaultstyle_.empty())
772 docstring const mainfontCSS = font_.asCSS();
773 if (!mainfontCSS.empty())
775 from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") +
776 mainfontCSS + from_ascii("\n}\n");
780 docstring InsetLayout::htmlstyle() const
782 if (!htmlstyle_.empty() && !htmlforcecss_)
784 if (htmldefaultstyle_.empty())
786 docstring retval = htmldefaultstyle_;
787 if (!htmlstyle_.empty())
788 retval += '\n' + htmlstyle_ + '\n';
793 std::string const & InsetLayout::docbookininfo() const
795 // Same as Layout::docbookininfo.
796 // Indeed, a trilean. Only titles should be "maybe": otherwise, metadata is "always", content is "never".
797 if (docbookininfo_.empty() || (docbookininfo_ != "never" && docbookininfo_ != "always" && docbookininfo_ != "maybe"))
798 docbookininfo_ = "never";
799 return docbookininfo_;
803 std::string InsetLayout::docbooktagtype() const
805 if (docbooktagtype_ != "block" && docbooktagtype_ != "paragraph" && docbooktagtype_ != "inline")
806 docbooktagtype_ = "block";
807 return docbooktagtype_;
811 std::string InsetLayout::docbookinnertagtype() const
813 if (docbookinnertagtype_ != "block" && docbookinnertagtype_ != "paragraph" && docbookinnertagtype_ != "inline")
814 docbookinnertagtype_ = "block";
815 return docbookinnertagtype_;
819 std::string InsetLayout::docbookwrappertagtype() const
821 if (docbookwrappertagtype_ != "block" && docbookwrappertagtype_ != "paragraph" && docbookwrappertagtype_ != "inline")
822 docbookwrappertagtype_ = "block";
823 return docbookwrappertagtype_;
827 std::string InsetLayout::docbookitemtagtype() const
829 if (docbookitemtagtype_ != "block" && docbookitemtagtype_ != "paragraph" && docbookitemtagtype_ != "inline")
830 docbookitemtagtype_ = "block";
831 return docbookitemtagtype_;
835 std::string InsetLayout::docbookitemwrappertagtype() const
837 if (docbookitemwrappertagtype_ != "block" && docbookitemwrappertagtype_ != "paragraph" && docbookitemwrappertagtype_ != "inline")
838 docbookitemwrappertagtype_ = "block";
839 return docbookitemwrappertagtype_;
843 void InsetLayout::readArgument(Lexer & lex)
845 Layout::latexarg arg;
846 arg.mandatory = false;
847 arg.autoinsert = false;
848 arg.insertcotext = false;
849 arg.insertonnewline = false;
851 bool finished = false;
852 arg.font = inherit_font;
853 arg.labelfont = inherit_font;
854 arg.is_toc_caption = false;
855 arg.free_spacing = false;
856 arg.passthru = PT_INHERITED;
857 arg.nodelims = false;
860 bool const postcmd = prefixIs(nr, "post:");
861 while (!finished && lex.isOK() && !error) {
863 string const tok = ascii_lowercase(lex.getString());
867 } else if (tok == "endargument") {
869 } else if (tok == "labelstring") {
871 arg.labelstring = lex.getDocString();
872 } else if (tok == "menustring") {
874 arg.menustring = lex.getDocString();
875 } else if (tok == "mandatory") {
877 arg.mandatory = lex.getBool();
878 } else if (tok == "autoinsert") {
880 arg.autoinsert = lex.getBool();
881 } else if (tok == "insertcotext") {
883 arg.insertcotext = lex.getBool();
884 } else if (tok == "insertonnewline") {
886 arg.insertonnewline = lex.getBool();
887 } else if (tok == "leftdelim") {
889 arg.ldelim = lex.getDocString();
890 arg.ldelim = subst(arg.ldelim,
891 from_ascii("<br/>"), from_ascii("\n"));
892 } else if (tok == "rightdelim") {
894 arg.rdelim = lex.getDocString();
895 arg.rdelim = subst(arg.rdelim,
896 from_ascii("<br/>"), from_ascii("\n"));
897 } else if (tok == "defaultarg") {
899 arg.defaultarg = lex.getDocString();
900 } else if (tok == "presetarg") {
902 arg.presetarg = lex.getDocString();
903 } else if (tok == "tooltip") {
905 arg.tooltip = lex.getDocString();
906 } else if (tok == "requires") {
908 arg.required = trim(lex.getString(true));
909 } else if (tok == "decoration") {
911 arg.decoration = lex.getString();
912 } else if (tok == "newlinecmd") {
914 arg.newlinecmd = lex.getString();
915 } else if (tok == "font") {
916 arg.font = lyxRead(lex, arg.font);
917 } else if (tok == "labelfont") {
918 arg.labelfont = lyxRead(lex, arg.labelfont);
919 } else if (tok == "passthruchars") {
921 arg.pass_thru_chars = lex.getDocString();
922 } else if (tok == "passthru") {
924 docstring value = lex.getDocString();
925 if (value == "true" || value == "1")
926 arg.passthru = PT_TRUE;
927 else if (value == "false" || value == "0")
928 arg.passthru = PT_FALSE;
930 arg.passthru = PT_INHERITED;
931 } else if (tok == "istoccaption") {
933 arg.is_toc_caption = lex.getBool();
934 } else if (tok == "freespacing") {
936 arg.free_spacing = lex.getBool();
937 } else if (tok == "docbooktag") {
939 arg.docbooktag = lex.getDocString();
940 } else if (tok == "docbookattr") {
942 arg.docbookattr = lex.getDocString();
943 } else if (tok == "docbooktagtype") {
945 arg.docbooktagtype = lex.getDocString();
946 } else if (tok == "docbookargumentbeforemaintag") {
948 arg.docbookargumentbeforemaintag = lex.getBool();
949 } else if (tok == "docbookargumentaftermaintag") {
951 arg.docbookargumentaftermaintag = lex.getBool();
953 lex.printError("Unknown tag");
957 if (arg.labelstring.empty())
958 LYXERR0("Incomplete Argument definition!");
960 postcommandargs_[nr] = arg;
962 latexargs_[nr] = arg;
966 Layout::LaTeXArgMap InsetLayout::args() const
968 Layout::LaTeXArgMap args = latexargs_;
969 if (!postcommandargs_.empty())
970 args.insert(postcommandargs_.begin(), postcommandargs_.end());
975 int InsetLayout::optArgs() const
978 Layout::LaTeXArgMap const args = InsetLayout::args();
979 Layout::LaTeXArgMap::const_iterator it = args.begin();
980 for (; it != args.end(); ++it) {
981 if (!(*it).second.mandatory)
988 int InsetLayout::requiredArgs() const
991 Layout::LaTeXArgMap const args = InsetLayout::args();
992 Layout::LaTeXArgMap::const_iterator it = args.begin();
993 for (; it != args.end(); ++it) {
994 if ((*it).second.mandatory)
1001 bool InsetLayout::requiresFeature(string const f) const
1003 return required_.find(f) != required_.end();