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"
19 #include "TextClass.h"
21 #include "support/debug.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,
142 IL_PARBREAKISNEWLINE,
154 LexerKeyword elementTags[] = {
155 { "addtotoc", IL_ADDTOTOC },
156 { "allowedininsets", IL_ALLOWED_IN_INSET },
157 { "allowedinlayouts", IL_ALLOWED_IN_LAYOUT },
158 { "allowedoccurrences", IL_ALLOWED_OCCURRENCES },
159 { "allowedoccurrencesperitem", IL_ALLOWED_OCCURRENCES_PER_ITEM },
160 { "argument", IL_ARGUMENT },
161 { "babelpreamble", IL_BABELPREAMBLE },
162 { "bgcolor", IL_BGCOLOR },
163 { "contentaslabel", IL_CONTENTASLABEL },
164 { "copystyle", IL_COPYSTYLE },
165 { "counter", IL_COUNTER},
166 { "custompars", IL_CUSTOMPARS },
167 { "decoration", IL_DECORATION },
168 { "display", IL_DISPLAY },
169 { "docbookargumentaftermaintag", IL_DOCBOOKARGUMENTAFTERMAINTAG },
170 { "docbookargumentbeforemaintag", IL_DOCBOOKARGUMENTBEFOREMAINTAG },
171 { "docbookattr", IL_DOCBOOKATTR },
172 { "docbookininfo", IL_DOCBOOKININFO },
173 { "docbookinnerattr", IL_DOCBOOKINNERATTR },
174 { "docbookinnertag", IL_DOCBOOKINNERTAG },
175 { "docbookinnertagtype", IL_DOCBOOKINNERTAGTYPE },
176 { "docbookitemattr", IL_DOCBOOKITEMATTR },
177 { "docbookitemtag", IL_DOCBOOKITEMTAG },
178 { "docbookitemtagtype", IL_DOCBOOKITEMTAGTYPE },
179 { "docbookitemwrapperattr", IL_DOCBOOKITEMWRAPPERATTR },
180 { "docbookitemwrappertag", IL_DOCBOOKITEMWRAPPERTAG },
181 { "docbookitemwrappertagtype", IL_DOCBOOKITEMWRAPPERTAGTYPE },
182 { "docbooknofontinside", IL_DOCBOOKNOFONTINSIDE },
183 { "docbooknotinpara", IL_DOCBOOKNOTINPARA },
184 { "docbookrenderasimage", IL_DOCBOOKRENDERASIMAGE },
185 { "docbooksection", IL_DOCBOOKSECTION },
186 { "docbooktag", IL_DOCBOOKTAG },
187 { "docbooktagtype", IL_DOCBOOKTAGTYPE },
188 { "docbookwrapperattr", IL_DOCBOOKWRAPPERATTR },
189 { "docbookwrappertag", IL_DOCBOOKWRAPPERTAG },
190 { "docbookwrappertagtype", IL_DOCBOOKWRAPPERTAGTYPE },
191 { "editexternal", IL_EDITEXTERNAL },
193 { "fixedwidthpreambleencoding", IL_FIXEDWIDTH_PREAMBLE_ENCODING },
195 { "forcelocalfontswitch", IL_FORCE_LOCAL_FONT_SWITCH },
196 { "forceltr", IL_FORCELTR },
197 { "forceownlines", IL_FORCEOWNLINES },
198 { "forceplain", IL_FORCEPLAIN },
199 { "freespacing", IL_FREESPACING },
200 { "htmlattr", IL_HTMLATTR },
201 { "htmlclass", IL_HTMLCLASS },
202 { "htmlforcecss", IL_HTMLFORCECSS },
203 { "htmlinnerattr", IL_HTMLINNERATTR},
204 { "htmlinnertag", IL_HTMLINNERTAG},
205 { "htmlisblock", IL_HTMLISBLOCK},
206 { "htmllabel", IL_HTMLLABEL },
207 { "htmlpreamble", IL_HTMLPREAMBLE },
208 { "htmlstyle", IL_HTMLSTYLE },
209 { "htmltag", IL_HTMLTAG },
210 { "inheritfont", IL_INHERITFONT },
211 { "intoc", IL_INTOC },
212 { "istoccaption", IL_ISTOCCAPTION },
213 { "keepempty", IL_KEEPEMPTY },
214 { "labelfont", IL_LABELFONT },
215 { "labelstring", IL_LABELSTRING },
216 { "langpreamble", IL_LANGPREAMBLE },
217 { "latexname", IL_LATEXNAME },
218 { "latexparam", IL_LATEXPARAM },
219 { "latextype", IL_LATEXTYPE },
220 { "leftdelim", IL_LEFTDELIM },
221 { "lyxtype", IL_LYXTYPE },
222 { "menustring", IL_MENUSTRING },
223 { "multipar", IL_MULTIPAR },
224 { "needcprotect", IL_NEEDCPROTECT },
225 { "needmboxprotect", IL_NEEDMBOXPROTECT },
226 { "needprotect", IL_NEEDPROTECT },
227 { "newlinecmd", IL_NEWLINE_CMD },
228 { "obsoletedby", IL_OBSOLETEDBY },
229 { "parbreakignored", IL_PARBREAKIGNORED },
230 { "parbreakisnewline", IL_PARBREAKISNEWLINE },
231 { "passthru", IL_PASSTHRU },
232 { "passthruchars", IL_PASSTHRU_CHARS },
233 { "preamble", IL_PREAMBLE },
234 { "refprefix", IL_REFPREFIX },
235 { "requires", IL_REQUIRES },
236 { "resetargs", IL_RESETARGS },
237 { "resetsfont", IL_RESETSFONT },
238 { "rightdelim", IL_RIGHTDELIM },
239 { "spellcheck", IL_SPELLCHECK }
242 lex.pushTable(elementTags);
244 if (labelfont_ == sane_font)
245 labelfont_ = inherit_font;
246 if (bgcolor_ == Color_error)
247 bgcolor_ = Color_none;
249 // whether we've read the CustomPars or ForcePlain tag
250 // for issuing a warning in case MultiPars comes later
251 bool readCustomOrPlain = false;
254 while (!getout && lex.isOK()) {
257 case Lexer::LEX_UNDEF:
258 lex.printError("Unknown InsetLayout tag");
267 // Perhaps a more elegant way to deal with the next two would be the
268 // way this sort of thing is handled in Layout::read(), namely, by
271 // make sure that we have the right sort of name.
272 if (name_ != from_ascii("undefined")
273 && name_.substr(0,5) != from_ascii("Flex:")) {
274 LYXERR0("Flex insets must have names of the form `Flex:<name>'.\n"
275 "This one has the name `" << to_utf8(name_) << "'\n"
276 "Ignoring LyXType declaration.");
277 // this is not really a reason to abort
284 lyxtype_ = translateLyXType(lt);
285 if (lyxtype_ == InsetLyXType::NOLYXTYPE) {
286 LYXERR0("Unknown LyXType `" << lt << "'.");
287 // this is not really a reason to abort
291 if (lyxtype_ == InsetLyXType::CHARSTYLE) {
292 // by default, charstyles force the plain layout
301 latextype_ = translateLaTeXType(lt);
302 if (latextype_ == InsetLaTeXType::ILT_ERROR) {
303 LYXERR0("Unknown LaTeXType `" << lt << "'.");
304 // this is not really a reason to abort
318 decoration_ = translateDecoration(tmp);
325 latexparam_ = subst(tmp, """, "\"");
329 leftdelim_ = subst(leftdelim_, from_ascii("<br/>"),
332 case IL_FIXEDWIDTH_PREAMBLE_ENCODING:
333 lex >> fixedwidthpreambleencoding_;
335 case IL_FORCE_LOCAL_FONT_SWITCH:
336 lex >> forcelocalfontswitch_;
340 rightdelim_ = subst(rightdelim_, from_ascii("<br/>"),
344 labelfont_ = lyxRead(lex, inherit_font);
349 case IL_FORCEOWNLINES:
350 lex >> forceownlines_;
360 // the defaults for these depend upon multipar_
361 if (readCustomOrPlain)
362 LYXERR0("Warning: Read MultiPar after CustomPars or ForcePlain. "
363 "Previous value may be overwritten!");
364 readCustomOrPlain = false;
365 custompars_ = multipar_;
366 forceplain_ = !multipar_;
373 readCustomOrPlain = true;
377 readCustomOrPlain = true;
382 case IL_PASSTHRU_CHARS:
383 lex >> passthru_chars_;
388 case IL_PARBREAKIGNORED:
389 lex >> parbreakignored_;
391 case IL_PARBREAKISNEWLINE:
392 lex >> parbreakisnewline_;
403 case IL_NEEDCPROTECT:
404 lex >> needcprotect_;
406 case IL_NEEDMBOXPROTECT:
407 lex >> needmboxprotect_;
409 case IL_CONTENTASLABEL:
410 lex >> contentaslabel_;
413 // initialize with a known style
416 style = subst(style, '_', ' ');
418 // We don't want to apply the algorithm in DocumentClass::insetLayout()
419 // here. So we do it the long way.
420 TextClass::InsetLayouts::const_iterator it =
421 tclass.insetLayouts().find(style);
422 if (it != tclass.insetLayouts().end()) {
423 docstring const tmpname = name_;
424 this->operator=(it->second);
427 LYXERR0("Cannot copy unknown InsetLayout `"
428 << style << "' to InsetLayout `"
430 << "All InsetLayouts so far:");
431 TextClass::InsetLayouts::const_iterator lit =
432 tclass.insetLayouts().begin();
433 TextClass::InsetLayouts::const_iterator len =
434 tclass.insetLayouts().end();
435 for (; lit != len; ++lit)
436 lyxerr << lit->second.name() << "\n";
437 // this is not really a reason to abort
443 case IL_OBSOLETEDBY: {
446 style = subst(style, '_', ' ');
448 // We don't want to apply the algorithm in DocumentClass::insetLayout()
449 // here. So we do it the long way.
450 TextClass::InsetLayouts::const_iterator it =
451 tclass.insetLayouts().find(style);
452 if (it != tclass.insetLayouts().end()) {
453 docstring const tmpname = name_;
454 this->operator=(it->second);
456 if (obsoleted_by().empty())
457 obsoleted_by_ = style;
459 LYXERR0("Cannot replace InsetLayout `"
461 << "' with unknown InsetLayout `"
463 << "All InsetLayouts so far:");
464 TextClass::InsetLayouts::const_iterator lit =
465 tclass.insetLayouts().begin();
466 TextClass::InsetLayouts::const_iterator len =
467 tclass.insetLayouts().end();
468 for (; lit != len; ++lit)
469 lyxerr << lit->second.name() << "\n";
470 // this is not really a reason to abort
478 font_ = lyxRead(lex, inherit_font);
479 // If you want to define labelfont, you need to do so after
489 postcommandargs_.clear();
497 bgcolor_ = lcolor.getFromLyXName(tmp);
500 preamble_ = lex.getLongString(from_ascii("EndPreamble"));
502 case IL_BABELPREAMBLE:
503 babelpreamble_ = lex.getLongString(from_ascii("EndBabelPreamble"));
505 case IL_LANGPREAMBLE:
506 langpreamble_ = lex.getLongString(from_ascii("EndLangPreamble"));
520 case IL_HTMLFORCECSS:
521 lex >> htmlforcecss_;
523 case IL_HTMLINNERTAG:
524 lex >> htmlinnertag_;
526 case IL_HTMLINNERATTR:
527 lex >> htmlinnerattr_;
536 htmlstyle_ = lex.getLongString(from_ascii("EndHTMLStyle"));
538 case IL_HTMLPREAMBLE:
539 htmlpreamble_ = lex.getLongString(from_ascii("EndPreamble"));
547 case IL_DOCBOOKTAGTYPE:
548 lex >> docbooktagtype_;
550 case IL_DOCBOOKINNERTAG:
551 lex >> docbookinnertag_;
553 case IL_DOCBOOKINNERATTR:
554 lex >> docbookinnerattr_;
556 case IL_DOCBOOKINNERTAGTYPE:
557 lex >> docbookinnertagtype_;
559 case IL_DOCBOOKININFO:
560 lex >> docbookininfo_;
562 case IL_DOCBOOKARGUMENTBEFOREMAINTAG:
563 lex >> docbookargumentbeforemaintag_;
565 case IL_DOCBOOKARGUMENTAFTERMAINTAG:
566 lex >> docbookargumentaftermaintag_;
568 case IL_DOCBOOKNOTINPARA:
569 lex >> docbooknotinpara_;
571 case IL_DOCBOOKSECTION:
572 lex >> docbooksection_;
574 case IL_DOCBOOKITEMTAG:
575 lex >> docbookitemtag_;
577 case IL_DOCBOOKITEMTAGTYPE:
578 lex >> docbookitemtagtype_;
580 case IL_DOCBOOKITEMATTR:
581 lex >> docbookitemattr_;
583 case IL_DOCBOOKITEMWRAPPERTAG:
584 lex >> docbookitemwrappertag_;
586 case IL_DOCBOOKITEMWRAPPERTAGTYPE:
587 lex >> docbookitemwrappertagtype_;
589 case IL_DOCBOOKITEMWRAPPERATTR:
590 lex >> docbookitemwrapperattr_;
592 case IL_DOCBOOKWRAPPERTAG:
593 lex >> docbookwrappertag_;
595 case IL_DOCBOOKWRAPPERTAGTYPE:
596 lex >> docbookwrappertagtype_;
598 case IL_DOCBOOKWRAPPERATTR:
599 lex >> docbookwrapperattr_;
601 case IL_DOCBOOKNOFONTINSIDE:
602 lex >> docbooknofontinside_;
604 case IL_DOCBOOKRENDERASIMAGE:
605 lex >> docbookrenderasimage_;
609 vector<string> const req
610 = getVectorFromString(lex.getString(true));
611 required_.insert(req.begin(), req.end());
625 add_to_toc_ = !toc_type_.empty();
627 case IL_ISTOCCAPTION:
628 lex >> is_toc_caption_;
630 case IL_EDITEXTERNAL:
631 lex >> edit_external_;
633 case IL_ALLOWED_IN_INSET: {
634 docstring allowed = lex.getLongString(from_ascii("EndAllowedInInsets"));
635 allowed = subst(allowed, from_ascii("\n"), docstring());
636 allowed = subst(allowed, from_ascii("\t"), docstring());
637 allowed = subst(allowed, from_ascii("\""), docstring());
638 allowed = subst(allowed, '_', ' ');
639 vector<docstring> const allowances =
640 getVectorFromString(allowed, from_ascii(","), false, true);
641 allowed_in_insets_.clear();
642 allowed_in_insets_.insert(allowances.begin(), allowances.end());
646 case IL_ALLOWED_IN_LAYOUT: {
647 docstring allowed = lex.getLongString(from_ascii("EndAllowedInLayouts"));
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_layouts_.clear();
655 allowed_in_layouts_.insert(allowances.begin(), allowances.end());
658 case IL_ALLOWED_OCCURRENCES:
659 lex >> allowed_occurrences_;
661 case IL_ALLOWED_OCCURRENCES_PER_ITEM:
662 lex >> allowed_occurrences_per_item_;
670 // Here add element to list if getout == true
674 // The label font is generally used as-is without
675 // any realization against a given context.
676 labelfont_.realize(sane_font);
683 InsetLyXType translateLyXType(std::string const & str)
685 if (compare_ascii_no_case(str, "charstyle") == 0)
686 return InsetLyXType::CHARSTYLE;
687 if (compare_ascii_no_case(str, "custom") == 0)
688 return InsetLyXType::CUSTOM;
689 if (compare_ascii_no_case(str, "end") == 0)
690 return InsetLyXType::END;
691 if (compare_ascii_no_case(str, "standard") == 0)
692 return InsetLyXType::STANDARD;
693 return InsetLyXType::NOLYXTYPE;
697 string const & InsetLayout::htmltag() const
699 if (htmltag_.empty())
700 htmltag_ = multipar_ ? "div" : "span";
705 string const & InsetLayout::htmlclass() const
707 if (htmlclass_.empty())
708 htmlclass_ = defaultCSSClass();
713 std::string const & InsetLayout::htmlGetAttrString() const {
714 if (!htmlfullattrs_.empty())
715 return htmlfullattrs_;
716 htmlfullattrs_ = htmlclass();
717 if (!htmlfullattrs_.empty())
718 htmlfullattrs_ = "class='" + htmlfullattrs_ + "'";
719 if (!htmlattr_.empty())
720 htmlfullattrs_ += " " + htmlattr_;
721 return htmlfullattrs_;
725 string const & InsetLayout::htmlinnerattr() const
727 if (htmlinnerattr_.empty())
728 htmlinnerattr_ = "class=\"" + defaultCSSClass() + "_inner\"";
729 return htmlinnerattr_;
733 string InsetLayout::defaultCSSClass() const
735 if (!defaultcssclass_.empty())
736 return defaultcssclass_;
738 string n = to_utf8(name());
739 string::const_iterator it = n.begin();
740 string::const_iterator en = n.end();
741 for (; it != en; ++it) {
742 if (!isAlphaASCII(*it))
744 else if (isLower(*it))
749 // are there other characters we need to remove?
750 defaultcssclass_ = d;
751 return defaultcssclass_;
755 void InsetLayout::makeDefaultCSS() const
757 if (!htmldefaultstyle_.empty())
759 docstring const mainfontCSS = font_.asCSS();
760 if (!mainfontCSS.empty())
762 from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") +
763 mainfontCSS + from_ascii("\n}\n");
767 docstring InsetLayout::htmlstyle() const
769 if (!htmlstyle_.empty() && !htmlforcecss_)
771 if (htmldefaultstyle_.empty())
773 docstring retval = htmldefaultstyle_;
774 if (!htmlstyle_.empty())
775 retval += '\n' + htmlstyle_ + '\n';
780 std::string const & InsetLayout::docbookininfo() const
782 // Same as Layout::docbookininfo.
783 // Indeed, a trilean. Only titles should be "maybe": otherwise, metadata is "always", content is "never".
784 if (docbookininfo_.empty() || (docbookininfo_ != "never" && docbookininfo_ != "always" && docbookininfo_ != "maybe"))
785 docbookininfo_ = "never";
786 return docbookininfo_;
790 std::string InsetLayout::docbooktagtype() const
792 if (docbooktagtype_ != "block" && docbooktagtype_ != "paragraph" && docbooktagtype_ != "inline")
793 docbooktagtype_ = "block";
794 return docbooktagtype_;
798 std::string InsetLayout::docbookinnertagtype() const
800 if (docbookinnertagtype_ != "block" && docbookinnertagtype_ != "paragraph" && docbookinnertagtype_ != "inline")
801 docbookinnertagtype_ = "block";
802 return docbookinnertagtype_;
806 std::string InsetLayout::docbookwrappertagtype() const
808 if (docbookwrappertagtype_ != "block" && docbookwrappertagtype_ != "paragraph" && docbookwrappertagtype_ != "inline")
809 docbookwrappertagtype_ = "block";
810 return docbookwrappertagtype_;
814 std::string InsetLayout::docbookitemtagtype() const
816 if (docbookitemtagtype_ != "block" && docbookitemtagtype_ != "paragraph" && docbookitemtagtype_ != "inline")
817 docbookitemtagtype_ = "block";
818 return docbookitemtagtype_;
822 std::string InsetLayout::docbookitemwrappertagtype() const
824 if (docbookitemwrappertagtype_ != "block" && docbookitemwrappertagtype_ != "paragraph" && docbookitemwrappertagtype_ != "inline")
825 docbookitemwrappertagtype_ = "block";
826 return docbookitemwrappertagtype_;
830 void InsetLayout::readArgument(Lexer & lex)
832 Layout::latexarg arg;
833 arg.mandatory = false;
834 arg.autoinsert = false;
835 arg.insertcotext = false;
836 arg.insertonnewline = false;
838 bool finished = false;
839 arg.font = inherit_font;
840 arg.labelfont = inherit_font;
841 arg.is_toc_caption = false;
842 arg.free_spacing = false;
843 arg.passthru = PT_INHERITED;
844 arg.nodelims = false;
847 bool const postcmd = prefixIs(nr, "post:");
848 while (!finished && lex.isOK() && !error) {
850 string const tok = ascii_lowercase(lex.getString());
854 } else if (tok == "endargument") {
856 } else if (tok == "labelstring") {
858 arg.labelstring = lex.getDocString();
859 } else if (tok == "menustring") {
861 arg.menustring = lex.getDocString();
862 } else if (tok == "mandatory") {
864 arg.mandatory = lex.getBool();
865 } else if (tok == "autoinsert") {
867 arg.autoinsert = lex.getBool();
868 } else if (tok == "insertcotext") {
870 arg.insertcotext = lex.getBool();
871 } else if (tok == "insertonnewline") {
873 arg.insertonnewline = lex.getBool();
874 } else if (tok == "leftdelim") {
876 arg.ldelim = lex.getDocString();
877 arg.ldelim = subst(arg.ldelim,
878 from_ascii("<br/>"), from_ascii("\n"));
879 } else if (tok == "rightdelim") {
881 arg.rdelim = lex.getDocString();
882 arg.rdelim = subst(arg.rdelim,
883 from_ascii("<br/>"), from_ascii("\n"));
884 } else if (tok == "defaultarg") {
886 arg.defaultarg = lex.getDocString();
887 } else if (tok == "presetarg") {
889 arg.presetarg = lex.getDocString();
890 } else if (tok == "tooltip") {
892 arg.tooltip = lex.getDocString();
893 } else if (tok == "requires") {
895 arg.required = trim(lex.getString(true));
896 } else if (tok == "decoration") {
898 arg.decoration = lex.getString();
899 } else if (tok == "newlinecmd") {
901 arg.newlinecmd = lex.getString();
902 } else if (tok == "font") {
903 arg.font = lyxRead(lex, arg.font);
904 } else if (tok == "labelfont") {
905 arg.labelfont = lyxRead(lex, arg.labelfont);
906 } else if (tok == "passthruchars") {
908 arg.pass_thru_chars = lex.getDocString();
909 } else if (tok == "passthru") {
911 docstring value = lex.getDocString();
912 if (value == "true" || value == "1")
913 arg.passthru = PT_TRUE;
914 else if (value == "false" || value == "0")
915 arg.passthru = PT_FALSE;
917 arg.passthru = PT_INHERITED;
918 } else if (tok == "istoccaption") {
920 arg.is_toc_caption = lex.getBool();
921 } else if (tok == "freespacing") {
923 arg.free_spacing = lex.getBool();
924 } else if (tok == "docbooktag") {
926 arg.docbooktag = lex.getDocString();
927 } else if (tok == "docbookattr") {
929 arg.docbookattr = lex.getDocString();
930 } else if (tok == "docbooktagtype") {
932 arg.docbooktagtype = lex.getDocString();
933 } else if (tok == "docbookargumentbeforemaintag") {
935 arg.docbookargumentbeforemaintag = lex.getBool();
936 } else if (tok == "docbookargumentaftermaintag") {
938 arg.docbookargumentaftermaintag = lex.getBool();
940 lex.printError("Unknown tag");
944 if (arg.labelstring.empty())
945 LYXERR0("Incomplete Argument definition!");
947 postcommandargs_[nr] = arg;
949 latexargs_[nr] = arg;
953 Layout::LaTeXArgMap InsetLayout::args() const
955 Layout::LaTeXArgMap args = latexargs_;
956 if (!postcommandargs_.empty())
957 args.insert(postcommandargs_.begin(), postcommandargs_.end());
962 int InsetLayout::optArgs() const
965 Layout::LaTeXArgMap const args = InsetLayout::args();
966 Layout::LaTeXArgMap::const_iterator it = args.begin();
967 for (; it != args.end(); ++it) {
968 if (!(*it).second.mandatory)
975 int InsetLayout::requiredArgs() 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)