3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
10 * Full author contact details are available in file CREDITS.
19 #include "output_xhtml.h"
20 #include "TextClass.h"
22 #include "support/debug.h"
23 #include "support/lassert.h"
24 #include "support/lstrings.h"
25 #include "support/Messages.h"
26 #include "support/textutils.h"
30 using namespace lyx::support;
34 /// Special value of toclevel for layouts that do not belong to a TOC
35 const int Layout::NOT_IN_TOC = -1000;
37 // The order of the LayoutTags enum is no more important. [asierra300396]
57 LT_PARBREAK_IS_NEWLINE,
67 LT_LABELSTRING_APPENDIX,
111 LT_DOCBOOKWRAPPERTAG,
112 LT_DOCBOOKWRAPPERATTR,
113 LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS,
114 LT_DOCBOOKSECTIONTAG,
115 LT_DOCBOOKITEMWRAPPERTAG,
116 LT_DOCBOOKITEMWRAPPERATTR,
119 LT_DOCBOOKITEMLABELTAG,
120 LT_DOCBOOKITEMLABELATTR,
121 LT_DOCBOOKITEMINNERTAG,
122 LT_DOCBOOKITEMINNERATTR,
123 LT_DOCBOOKFORCEABSTRACTTAG,
130 LT_STEPMASTERCOUNTER,
136 LT_INTITLE // keep this last!
139 /////////////////////
142 : add_to_toc_(false), is_toc_caption_(true)
145 margintype = MARGIN_STATIC;
146 latextype = LATEX_PARAGRAPH;
147 resumecounter = false;
148 stepmastercounter = false;
152 needcprotect = false;
153 needmboxprotect = false;
156 labelfont = inherit_font;
158 reslabelfont = sane_font;
159 nextnoindent = false;
164 labelbottomsep = 0.0;
166 align = LYX_ALIGN_BLOCK;
167 alignpossible = LYX_ALIGN_NONE | LYX_ALIGN_LAYOUT;
168 labeltype = LABEL_NO_LABEL;
169 endlabeltype = END_LABEL_NO_LABEL;
170 // Should or should not. That is the question.
171 // spacing.set(Spacing::OneHalf);
172 newline_allowed = true;
173 free_spacing = false;
175 parbreak_is_newline = false;
176 toclevel = NOT_IN_TOC;
178 htmllabelfirst_ = false;
179 htmlforcecss_ = false;
181 docbookabstract_ = false;
182 docbookwrappermergewithprevious_ = false;
185 itemcommand_ = "item";
186 toggle_indent = ITOGGLE_DOCUMENT_DEFAULT;
191 bool Layout::read(Lexer & lex, TextClass const & tclass)
193 // If this is an empty layout, or if no force local version is set,
194 // we know that we will not discard the stuff to read
196 return readIgnoreForcelocal(lex, tclass);
199 bool const ret = tmp.readIgnoreForcelocal(lex, tclass);
201 // - the read version is higher
202 // - both versions are infinity (arbitrary decision)
203 // - the file did not contain any local version (needed for not
204 // skipping user defined local layouts)
205 if (tmp.forcelocal <= 0 || tmp.forcelocal > forcelocal)
211 bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
213 // This table is sorted alphabetically [asierra 30March96]
214 LexerKeyword layoutTags[] = {
215 { "addtotoc", LT_ADDTOTOC },
216 { "align", LT_ALIGN },
217 { "alignpossible", LT_ALIGNPOSSIBLE },
218 { "argument", LT_ARGUMENT },
219 { "autonests", LT_AUTONESTS },
220 { "babelpreamble", LT_BABELPREAMBLE },
221 { "bottomsep", LT_BOTTOMSEP },
222 { "category", LT_CATEGORY },
223 { "commanddepth", LT_COMMANDDEPTH },
224 { "copystyle", LT_COPYSTYLE },
225 { "dependson", LT_DEPENDSON },
226 { "docbookabstract", LT_DOCBOOKABSTRACT },
227 { "docbookattr", LT_DOCBOOKATTR },
228 { "docbookforceabstracttag", LT_DOCBOOKFORCEABSTRACTTAG },
229 { "docbookininfo", LT_DOCBOOKININFO },
230 { "docbookitemattr", LT_DOCBOOKITEMATTR },
231 { "docbookiteminnerattr", LT_DOCBOOKITEMINNERATTR },
232 { "docbookiteminnertag", LT_DOCBOOKITEMINNERTAG },
233 { "docbookitemlabelattr", LT_DOCBOOKITEMLABELATTR },
234 { "docbookitemlabeltag", LT_DOCBOOKITEMLABELTAG },
235 { "docbookitemtag", LT_DOCBOOKITEMTAG },
236 { "docbookitemwrapperattr", LT_DOCBOOKITEMWRAPPERATTR },
237 { "docbookitemwrappertag", LT_DOCBOOKITEMWRAPPERTAG },
238 { "docbooksectiontag", LT_DOCBOOKSECTIONTAG },
239 { "docbooktag", LT_DOCBOOKTAG },
240 { "docbookwrapperattr", LT_DOCBOOKWRAPPERATTR },
241 { "docbookwrappermergewithprevious", LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS },
242 { "docbookwrappertag", LT_DOCBOOKWRAPPERTAG },
244 { "endlabelstring", LT_ENDLABELSTRING },
245 { "endlabeltype", LT_ENDLABELTYPE },
247 { "forcelocal", LT_FORCELOCAL },
248 { "freespacing", LT_FREE_SPACING },
249 { "htmlattr", LT_HTMLATTR },
250 { "htmlforcecss", LT_HTMLFORCECSS },
251 { "htmlitem", LT_HTMLITEM },
252 { "htmlitemattr", LT_HTMLITEMATTR },
253 { "htmllabel", LT_HTMLLABEL },
254 { "htmllabelattr", LT_HTMLLABELATTR },
255 { "htmllabelfirst", LT_HTMLLABELFIRST },
256 { "htmlpreamble", LT_HTMLPREAMBLE },
257 { "htmlstyle", LT_HTMLSTYLE },
258 { "htmltag", LT_HTMLTAG },
259 { "htmltitle", LT_HTMLTITLE },
260 { "innertag", LT_INNERTAG },
261 { "inpreamble", LT_INPREAMBLE },
262 { "intitle", LT_INTITLE },
263 { "isautonestedby", LT_AUTONESTEDBY },
264 { "istoccaption", LT_ISTOCCAPTION },
265 { "itemcommand", LT_ITEMCOMMAND },
266 { "itemsep", LT_ITEMSEP },
267 { "itemtag", LT_ITEMTAG },
268 { "keepempty", LT_KEEPEMPTY },
269 { "labelbottomsep", LT_LABEL_BOTTOMSEP },
270 { "labelcounter", LT_LABELCOUNTER },
271 { "labelfont", LT_LABELFONT },
272 { "labelindent", LT_LABELINDENT },
273 { "labelsep", LT_LABELSEP },
274 { "labelstring", LT_LABELSTRING },
275 { "labelstringappendix", LT_LABELSTRING_APPENDIX },
276 { "labeltag", LT_LABELTAG },
277 { "labeltype", LT_LABELTYPE },
278 { "langpreamble", LT_LANGPREAMBLE },
279 { "latexname", LT_LATEXNAME },
280 { "latexparam", LT_LATEXPARAM },
281 { "latextype", LT_LATEXTYPE },
282 { "leftdelim", LT_LEFTDELIM },
283 { "leftmargin", LT_LEFTMARGIN },
284 { "margin", LT_MARGIN },
285 { "needcprotect", LT_NEED_CPROTECT },
286 { "needmboxprotect", LT_NEED_MBOXPROTECT },
287 { "needprotect", LT_NEED_PROTECT },
288 { "newline", LT_NEWLINE },
289 { "nextnoindent", LT_NEXTNOINDENT },
290 { "obsoletedby", LT_OBSOLETEDBY },
291 { "paragraphgroup", LT_PAR_GROUP },
292 { "parbreakisnewline", LT_PARBREAK_IS_NEWLINE },
293 { "parindent", LT_PARINDENT },
294 { "parsep", LT_PARSEP },
295 { "parskip", LT_PARSKIP },
296 { "passthru", LT_PASS_THRU },
297 { "passthruchars", LT_PASS_THRU_CHARS },
298 { "preamble", LT_PREAMBLE },
299 { "refprefix", LT_REFPREFIX },
300 { "requires", LT_REQUIRES },
301 { "resetargs", LT_RESETARGS },
302 { "resumecounter", LT_RESUMECOUNTER },
303 { "rightdelim", LT_RIGHTDELIM },
304 { "rightmargin", LT_RIGHTMARGIN },
305 { "spacing", LT_SPACING },
306 { "spellcheck", LT_SPELLCHECK },
307 { "stepmastercounter", LT_STEPMASTERCOUNTER },
308 { "textfont", LT_TEXTFONT },
309 { "toclevel", LT_TOCLEVEL },
310 { "toggleindent", LT_TOGGLE_INDENT },
311 { "topsep", LT_TOPSEP }
315 bool finished = false;
316 lex.pushTable(layoutTags);
318 // parse style section
319 while (!finished && lex.isOK() && !error) {
321 // See comment in LyXRC.cpp.
323 case Lexer::LEX_FEOF:
326 case Lexer::LEX_UNDEF:
328 lex.printError("Unknown layout tag `$$Token'");
335 switch (static_cast<LayoutTags>(le)) {
347 style = subst(style, '_', ' ');
349 if (tclass.hasLayout(style)) {
350 docstring const tmpname = name_;
351 this->operator=(tclass[style]);
354 LYXERR0("Cannot copy unknown style `"
356 << "All layouts so far:");
357 DocumentClass::const_iterator lit = tclass.begin();
358 DocumentClass::const_iterator len = tclass.end();
359 for (; lit != len; ++lit)
360 LYXERR0(lit->name());
365 case LT_OBSOLETEDBY: {
368 style = subst(style, '_', ' ');
370 if (tclass.hasLayout(style)) {
371 docstring const tmpname = name_;
372 this->operator=(tclass[style]);
374 if (obsoleted_by().empty())
375 obsoleted_by_ = style;
377 LYXERR0("Cannot replace with unknown style `"
380 //lex.printError("Cannot replace with"
389 depends_on_ = subst(depends_on_, '_', ' ');
418 postcommandargs_.clear();
419 listpreamble_.clear();
423 case LT_RESUMECOUNTER:
424 lex >> resumecounter;
427 case LT_STEPMASTERCOUNTER:
428 lex >> stepmastercounter;
435 case LT_NEED_PROTECT:
439 case LT_NEED_CPROTECT:
443 case LT_NEED_MBOXPROTECT:
444 lex >> needmboxprotect;
452 font = lyxRead(lex, font);
457 font = lyxRead(lex, font);
461 labelfont = lyxRead(lex, labelfont);
464 case LT_NEXTNOINDENT:
468 case LT_TOGGLE_INDENT: {
471 tog = support::ascii_lowercase(tog);
473 toggle_indent = ITOGGLE_ALWAYS;
474 else if (tog == "never")
475 toggle_indent = ITOGGLE_NEVER;
477 toggle_indent = ITOGGLE_DOCUMENT_DEFAULT;
481 case LT_COMMANDDEPTH:
491 latexparam_ = subst(latexparam_, """, "\"");
496 leftdelim_ = support::subst(leftdelim_, from_ascii("<br/>"),
502 rightdelim_ = support::subst(rightdelim_, from_ascii("<br/>"),
523 preamble_ = lex.getLongString(from_ascii("EndPreamble"));
526 case LT_LANGPREAMBLE:
527 langpreamble_ = lex.getLongString(from_ascii("EndLangPreamble"));
530 case LT_BABELPREAMBLE:
531 babelpreamble_ = lex.getLongString(from_ascii("EndBabelPreamble"));
538 case LT_ENDLABELTYPE:
539 readEndLabelType(lex);
574 case LT_LABEL_BOTTOMSEP:
575 lex >> labelbottomsep;
580 labelsep = subst(labelsep, 'x', ' ');
588 lex >> newline_allowed;
595 case LT_ALIGNPOSSIBLE:
596 readAlignPossible(lex);
600 // FIXME: this means LT_LABELSTRING_APPENDIX may only
601 // occur after LT_LABELSTRING
603 labelstring_appendix_ = labelstring_;
606 case LT_ENDLABELSTRING:
607 lex >> endlabelstring_;
610 case LT_LABELSTRING_APPENDIX:
611 lex >> labelstring_appendix_;
614 case LT_LABELCOUNTER:
622 case LT_FREE_SPACING:
630 case LT_PASS_THRU_CHARS:
631 lex >> pass_thru_chars;
634 case LT_PARBREAK_IS_NEWLINE:
635 lex >> parbreak_is_newline;
644 vector<string> const req =
645 getVectorFromString(lex.getString(true));
646 required_.insert(req.begin(), req.end());
651 docstring autonest = lex.getLongString(from_ascii("EndAutoNests"));
652 autonest = subst(autonest, from_ascii("\n"), docstring());
653 autonest = subst(autonest, from_ascii("\t"), docstring());
654 autonest = subst(autonest, from_ascii("\""), docstring());
655 autonest = subst(autonest, '_', ' ');
656 vector<docstring> const autonests =
657 getVectorFromString(autonest, from_ascii(","), false, true);
658 autonests_.insert(autonests.begin(), autonests.end());
662 case LT_AUTONESTEDBY: {
663 docstring autonest = lex.getLongString(from_ascii("EndIsAutoNestedBy"));
664 autonest = subst(autonest, from_ascii("\n"), docstring());
665 autonest = subst(autonest, from_ascii("\t"), docstring());
666 autonest = subst(autonest, from_ascii("\""), docstring());
667 autonest = subst(autonest, '_', ' ');
668 vector<docstring> const autonests =
669 getVectorFromString(autonest, from_ascii(","), false, true);
670 autonested_by_.insert(autonests.begin(), autonests.end());
696 case LT_HTMLITEMATTR:
697 lex >> htmlitemattr_;
701 lex >> htmllabeltag_;
704 case LT_HTMLLABELATTR:
705 lex >> htmllabelattr_;
708 case LT_HTMLLABELFIRST:
709 lex >> htmllabelfirst_;
713 htmlstyle_ = lex.getLongString(from_ascii("EndHTMLStyle"));
716 case LT_HTMLFORCECSS:
717 lex >> htmlforcecss_;
720 case LT_HTMLPREAMBLE:
721 htmlpreamble_ = lex.getLongString(from_ascii("EndPreamble"));
736 case LT_DOCBOOKFORCEABSTRACTTAG:
737 lex >> docbookforceabstracttag_;
740 case LT_DOCBOOKININFO:
741 lex >> docbookininfo_;
744 case LT_DOCBOOKABSTRACT:
745 lex >> docbookabstract_;
748 case LT_DOCBOOKWRAPPERTAG:
749 lex >> docbookwrappertag_;
752 case LT_DOCBOOKWRAPPERATTR:
753 lex >> docbookwrapperattr_;
756 case LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS:
757 lex >> docbookwrappermergewithprevious_;
760 case LT_DOCBOOKSECTIONTAG:
761 lex >> docbooksectiontag_;
764 case LT_DOCBOOKITEMWRAPPERTAG:
765 lex >> docbookitemwrappertag_;
768 case LT_DOCBOOKITEMWRAPPERATTR:
769 lex >> docbookitemwrapperattr_;
772 case LT_DOCBOOKITEMTAG:
773 lex >> docbookitemtag_;
776 case LT_DOCBOOKITEMATTR:
777 lex >> docbookitemattr_;
780 case LT_DOCBOOKITEMLABELTAG:
781 lex >> docbookitemlabeltag_;
784 case LT_DOCBOOKITEMLABELATTR:
785 lex >> docbookitemlabelattr_;
788 case LT_DOCBOOKITEMINNERTAG:
789 lex >> docbookiteminnertag_;
792 case LT_DOCBOOKITEMINNERATTR:
793 lex >> docbookiteminnerattr_;
806 add_to_toc_ = !toc_type_.empty();
809 case LT_ISTOCCAPTION:
810 lex >> is_toc_caption_;
816 // make sure we only have inpreamble = true for commands
817 if (inpreamble && latextype != LATEX_COMMAND && latextype != LATEX_PARAGRAPH) {
818 LYXERR0("InPreamble not permitted except with command and paragraph layouts.");
819 LYXERR0("Layout name: " << name());
823 return finished && !error;
836 LexerKeyword alignTags[] = {
837 { "block", AT_BLOCK },
838 { "center", AT_CENTER },
839 { "layout", AT_LAYOUT },
841 { "right", AT_RIGHT }
845 void Layout::readAlign(Lexer & lex)
847 PushPopHelper pph(lex, alignTags);
850 case Lexer::LEX_UNDEF:
851 lex.printError("Unknown alignment `$$Token'");
857 align = LYX_ALIGN_BLOCK;
860 align = LYX_ALIGN_LEFT;
863 align = LYX_ALIGN_RIGHT;
866 align = LYX_ALIGN_CENTER;
869 align = LYX_ALIGN_LAYOUT;
875 void Layout::readAlignPossible(Lexer & lex)
877 lex.pushTable(alignTags);
878 alignpossible = LYX_ALIGN_NONE | LYX_ALIGN_LAYOUT;
879 int lineno = lex.lineNumber();
883 case Lexer::LEX_UNDEF:
884 lex.printError("Unknown alignment `$$Token'");
890 alignpossible |= LYX_ALIGN_BLOCK;
893 alignpossible |= LYX_ALIGN_LEFT;
896 alignpossible |= LYX_ALIGN_RIGHT;
899 alignpossible |= LYX_ALIGN_CENTER;
902 alignpossible |= LYX_ALIGN_LAYOUT;
905 } while (lineno == lex.lineNumber());
910 void Layout::readLabelType(Lexer & lex)
925 LexerKeyword labelTypeTags[] = {
926 { "above", LA_ABOVE },
927 { "bibliography", LA_BIBLIO },
928 { "centered", LA_CENTERED },
929 { "enumerate", LA_ENUMERATE },
930 { "itemize", LA_ITEMIZE },
931 { "manual", LA_MANUAL },
932 { "no_label", LA_NO_LABEL },
933 { "sensitive", LA_SENSITIVE },
934 { "static", LA_STATIC }
937 PushPopHelper pph(lex, labelTypeTags);
940 case Lexer::LEX_UNDEF:
941 lex.printError("Unknown labeltype tag `$$Token'");
947 labeltype = LABEL_NO_LABEL;
950 labeltype = LABEL_MANUAL;
953 labeltype = LABEL_ABOVE;
956 labeltype = LABEL_CENTERED;
959 labeltype = LABEL_STATIC;
962 labeltype = LABEL_SENSITIVE;
965 labeltype = LABEL_ENUMERATE;
968 labeltype = LABEL_ITEMIZE;
971 labeltype = LABEL_BIBLIO;
977 void Layout::readEndLabelType(Lexer & lex)
979 // this should be const, but can't be because
981 static LexerKeyword endlabelTypeTags[] = {
982 { "box", END_LABEL_BOX },
983 { "filled_box", END_LABEL_FILLED_BOX },
984 { "no_label", END_LABEL_NO_LABEL },
985 { "static", END_LABEL_STATIC }
988 PushPopHelper pph(lex, endlabelTypeTags);
991 case Lexer::LEX_UNDEF:
992 lex.printError("Unknown labeltype tag `$$Token'");
994 case END_LABEL_STATIC:
996 case END_LABEL_FILLED_BOX:
997 case END_LABEL_NO_LABEL:
998 endlabeltype = static_cast<EndLabelType>(le);
1001 LYXERR0("Unhandled value " << le);
1007 void Layout::readMargin(Lexer & lex)
1009 LexerKeyword marginTags[] = {
1010 { "dynamic", MARGIN_DYNAMIC },
1011 { "first_dynamic", MARGIN_FIRST_DYNAMIC },
1012 { "manual", MARGIN_MANUAL },
1013 { "right_address_box", MARGIN_RIGHT_ADDRESS_BOX },
1014 { "static", MARGIN_STATIC }
1017 PushPopHelper pph(lex, marginTags);
1021 case Lexer::LEX_UNDEF:
1022 lex.printError("Unknown margin type tag `$$Token'");
1026 case MARGIN_DYNAMIC:
1027 case MARGIN_FIRST_DYNAMIC:
1028 case MARGIN_RIGHT_ADDRESS_BOX:
1029 margintype = static_cast<MarginType>(le);
1032 LYXERR0("Unhandled value " << le);
1038 void Layout::readLatexType(Lexer & lex)
1040 LexerKeyword latexTypeTags[] = {
1041 { "bib_environment", LATEX_BIB_ENVIRONMENT },
1042 { "command", LATEX_COMMAND },
1043 { "environment", LATEX_ENVIRONMENT },
1044 { "item_environment", LATEX_ITEM_ENVIRONMENT },
1045 { "list_environment", LATEX_LIST_ENVIRONMENT },
1046 { "paragraph", LATEX_PARAGRAPH }
1049 PushPopHelper pph(lex, latexTypeTags);
1052 case Lexer::LEX_UNDEF:
1053 lex.printError("Unknown latextype tag `$$Token'");
1055 case LATEX_PARAGRAPH:
1057 case LATEX_ITEM_ENVIRONMENT:
1058 case LATEX_LIST_ENVIRONMENT:
1059 latextype = static_cast<LatexType>(le);
1061 case LATEX_ENVIRONMENT:
1062 case LATEX_BIB_ENVIRONMENT:
1063 latextype = static_cast<LatexType>(le);
1067 LYXERR0("Unhandled value " << le);
1073 void Layout::readSpacing(Lexer & lex)
1076 ST_SPACING_SINGLE = 1,
1082 LexerKeyword spacingTags[] = {
1083 {"double", ST_SPACING_DOUBLE },
1084 {"onehalf", ST_SPACING_ONEHALF },
1085 {"other", ST_OTHER },
1086 {"single", ST_SPACING_SINGLE }
1089 PushPopHelper pph(lex, spacingTags);
1092 case Lexer::LEX_UNDEF:
1093 lex.printError("Unknown spacing token `$$Token'");
1098 case ST_SPACING_SINGLE:
1099 spacing.set(Spacing::Single);
1101 case ST_SPACING_ONEHALF:
1102 spacing.set(Spacing::Onehalf);
1104 case ST_SPACING_DOUBLE:
1105 spacing.set(Spacing::Double);
1109 spacing.set(Spacing::Other, lex.getString());
1115 void Layout::readArgument(Lexer & lex)
1118 // writeArgument() makes use of these default values
1119 arg.mandatory = false;
1120 arg.nodelims = false;
1121 arg.autoinsert = false;
1122 arg.insertcotext = false;
1123 arg.insertonnewline = false;
1125 bool finished = false;
1126 arg.font = inherit_font;
1127 arg.labelfont = inherit_font;
1128 arg.is_toc_caption = false;
1129 arg.passthru = PT_INHERITED;
1130 arg.free_spacing = false;
1133 bool const itemarg = prefixIs(id, "item:");
1134 bool const postcmd = prefixIs(id, "post:");
1135 bool const listpreamble = prefixIs(id, "listpreamble:");
1137 while (!finished && lex.isOK() && !error) {
1139 string const tok = ascii_lowercase(lex.getString());
1143 } else if (tok == "endargument") {
1145 } else if (tok == "labelstring") {
1147 arg.labelstring = lex.getDocString();
1148 } else if (tok == "menustring") {
1150 arg.menustring = lex.getDocString();
1151 } else if (tok == "mandatory") {
1153 arg.mandatory = lex.getBool();
1154 } else if (tok == "autoinsert") {
1156 arg.autoinsert = lex.getBool();
1157 } else if (tok == "insertcotext") {
1159 arg.insertcotext = lex.getBool();
1160 } else if (tok == "leftdelim") {
1162 arg.ldelim = lex.getDocString();
1163 arg.ldelim = support::subst(arg.ldelim, from_ascii("<br/>"),
1165 } else if (tok == "rightdelim") {
1167 arg.rdelim = lex.getDocString();
1168 arg.rdelim = support::subst(arg.rdelim, from_ascii("<br/>"),
1170 } else if (tok == "defaultarg") {
1172 arg.defaultarg = lex.getDocString();
1173 } else if (tok == "presetarg") {
1175 arg.presetarg = lex.getDocString();
1176 } else if (tok == "tooltip") {
1178 arg.tooltip = lex.getDocString();
1179 } else if (tok == "requires") {
1181 arg.required = lex.getString();
1182 } else if (tok == "decoration") {
1184 arg.decoration = lex.getString();
1185 } else if (tok == "newlinecmd") {
1187 arg.newlinecmd = lex.getString();
1188 } else if (tok == "font") {
1189 arg.font = lyxRead(lex, arg.font);
1190 } else if (tok == "labelfont") {
1191 arg.labelfont = lyxRead(lex, arg.labelfont);
1192 } else if (tok == "passthruchars") {
1194 arg.pass_thru_chars = lex.getDocString();
1195 } else if (tok == "passthru") {
1197 docstring value = lex.getDocString();
1198 if (value == "true" || value == "1")
1199 arg.passthru = PT_TRUE;
1200 else if (value == "false" || value == "0")
1201 arg.passthru = PT_FALSE;
1203 arg.passthru = PT_INHERITED;
1204 } else if (tok == "istoccaption") {
1206 arg.is_toc_caption = lex.getBool();
1207 } else if (tok == "freespacing") {
1209 arg.free_spacing = lex.getBool();
1211 lex.printError("Unknown tag");
1215 if (arg.labelstring.empty())
1216 LYXERR0("Incomplete Argument definition!");
1218 itemargs_[id] = arg;
1220 postcommandargs_[id] = arg;
1221 else if (listpreamble) {
1222 // list preamble has no delimiters by default
1223 arg.nodelims = true;
1224 listpreamble_[id] = arg;
1226 latexargs_[id] = arg;
1230 void writeArgument(ostream & os, string const & id, Layout::latexarg const & arg)
1232 os << "\tArgument " << id << '\n';
1233 if (!arg.labelstring.empty())
1234 os << "\t\tLabelString \"" << to_utf8(arg.labelstring) << "\"\n";
1235 if (!arg.menustring.empty())
1236 os << "\t\tMenuString \"" << to_utf8(arg.menustring) << "\"\n";
1238 os << "\t\tMandatory " << arg.mandatory << '\n';
1240 os << "\t\tAutoinsert " << arg.autoinsert << '\n';
1241 if (arg.insertcotext)
1242 os << "\t\tInsertCotext " << arg.insertcotext << '\n';
1243 if (!arg.ldelim.empty())
1244 os << "\t\tLeftDelim \""
1245 << to_utf8(subst(arg.ldelim, from_ascii("\n"), from_ascii("<br/>")))
1247 if (!arg.rdelim.empty())
1248 os << "\t\tRightDelim \""
1249 << to_utf8(subst(arg.rdelim, from_ascii("\n"), from_ascii("<br/>")))
1251 if (!arg.defaultarg.empty())
1252 os << "\t\tDefaultArg \"" << to_utf8(arg.defaultarg) << "\"\n";
1253 if (!arg.presetarg.empty())
1254 os << "\t\tPresetArg \"" << to_utf8(arg.presetarg) << "\"\n";
1255 if (!arg.tooltip.empty())
1256 os << "\t\tToolTip \"" << to_utf8(arg.tooltip) << "\"\n";
1257 if (!arg.required.empty())
1258 os << "\t\tRequires \"" << arg.required << "\"\n";
1259 if (!arg.decoration.empty())
1260 os << "\t\tDecoration \"" << arg.decoration << "\"\n";
1261 if (!arg.newlinecmd.empty())
1262 os << "\t\tNewlineCmd \"" << arg.newlinecmd << "\"\n";
1263 if (arg.font != inherit_font)
1264 lyxWrite(os, arg.font, "Font", 2);
1265 if (arg.labelfont != inherit_font)
1266 lyxWrite(os, arg.labelfont, "LabelFont", 2);
1267 switch (arg.passthru) {
1269 os << "\t\tPassThru true\n";
1272 os << "\t\tPassThru false\n";
1275 os << "\t\tPassThru inherited\n";
1278 if (!arg.pass_thru_chars.empty())
1279 os << "\t\tPassThruChars \"" << to_utf8(arg.pass_thru_chars) << "\"\n";
1280 if (arg.free_spacing)
1281 os << "\t\tFreeSpacing " << arg.free_spacing << "\n";
1282 os << "\tEndArgument\n";
1286 void Layout::write(ostream & os) const
1288 os << "Style \"" << to_utf8(name_) << "\"\n";
1289 if (!category_.empty() && obsoleted_by_.empty())
1290 os << "\tCategory \"" << to_utf8(category_) << "\"\n";
1291 // Can't deduce Copystyle here :-(
1292 if (!obsoleted_by_.empty()) {
1293 os << "\tObsoletedBy \"" << to_utf8(obsoleted_by_)
1297 if (!depends_on_.empty())
1298 os << "\tDependsOn " << to_utf8(depends_on_) << '\n';
1299 switch (margintype) {
1300 case MARGIN_DYNAMIC:
1301 os << "\tMargin Dynamic\n";
1303 case MARGIN_FIRST_DYNAMIC:
1304 os << "\tMargin First_Dynamic\n";
1307 os << "\tMargin Manual\n";
1309 case MARGIN_RIGHT_ADDRESS_BOX:
1310 os << "\tMargin Right_Address_Box\n";
1313 os << "\tMargin Static\n";
1316 switch (latextype) {
1317 case LATEX_BIB_ENVIRONMENT:
1318 os << "\tLatexType Bib_Environment\n";
1321 os << "\tLatexType Command\n";
1323 case LATEX_ENVIRONMENT:
1324 os << "\tLatexType Environment\n";
1326 case LATEX_ITEM_ENVIRONMENT:
1327 os << "\tLatexType Item_Environment\n";
1329 case LATEX_LIST_ENVIRONMENT:
1330 os << "\tLatexType List_Environment\n";
1332 case LATEX_PARAGRAPH:
1333 os << "\tLatexType Paragraph\n";
1336 os << "\tInTitle " << intitle << "\n"
1337 "\tInPreamble " << inpreamble << "\n"
1338 "\tTocLevel " << toclevel << "\n"
1339 "\tResumeCounter " << resumecounter << "\n"
1340 "\tStepMasterCounter " << stepmastercounter << '\n';
1341 // ResetArgs does not make sense here
1342 for (LaTeXArgMap::const_iterator it = latexargs_.begin();
1343 it != latexargs_.end(); ++it)
1344 writeArgument(os, it->first, it->second);
1345 for (LaTeXArgMap::const_iterator it = itemargs_.begin();
1346 it != itemargs_.end(); ++it)
1347 writeArgument(os, it->first, it->second);
1348 for (LaTeXArgMap::const_iterator it = postcommandargs_.begin();
1349 it != postcommandargs_.end(); ++it)
1350 writeArgument(os, it->first, it->second);
1351 for (LaTeXArgMap::const_iterator it = listpreamble_.begin();
1352 it != listpreamble_.end(); ++it)
1353 writeArgument(os, it->first, it->second);
1354 os << "\tNeedProtect " << needprotect << "\n"
1355 "\tNeedCProtect " << needcprotect << "\n"
1356 "\tNeedMBoxProtect " << needmboxprotect << "\n"
1357 "\tKeepEmpty " << keepempty << '\n';
1358 if (labelfont == font)
1359 lyxWrite(os, font, "Font", 1);
1361 lyxWrite(os, font, "TextFont", 1);
1362 lyxWrite(os, labelfont, "LabelFont", 1);
1364 os << "\tNextNoIndent " << nextnoindent << "\n"
1365 "\tCommandDepth " << commanddepth << '\n';
1366 if (!latexname_.empty())
1367 os << "\tLatexName \"" << latexname_ << "\"\n";
1368 if (!latexparam_.empty())
1369 os << "\tLatexParam \"" << subst(latexparam_, "\"", """)
1371 if (!leftdelim_.empty())
1372 os << "\tLeftDelim "
1373 << to_utf8(subst(leftdelim_, from_ascii("\n"), from_ascii("<br/>")))
1375 if (!rightdelim_.empty())
1376 os << "\tRightDelim "
1377 << to_utf8(subst(rightdelim_, from_ascii("\n"), from_ascii("<br/>")))
1379 if (!innertag_.empty())
1380 os << "\tInnerTag \"" << innertag_ << "\"\n";
1381 if (!labeltag_.empty())
1382 os << "\tLabelTag \"" << labeltag_ << "\"\n";
1383 if (!itemtag_.empty())
1384 os << "\tItemTag \"" << itemtag_ << "\"\n";
1385 if (!itemcommand_.empty())
1386 os << "\tItemCommand " << itemcommand_ << '\n';
1387 if (!preamble_.empty())
1388 os << "\tPreamble\n\t"
1389 << to_utf8(subst(rtrim(preamble_, "\n"),
1390 from_ascii("\n"), from_ascii("\n\t")))
1391 << "\n\tEndPreamble\n";
1392 if (!langpreamble_.empty())
1393 os << "\tLangPreamble\n\t"
1394 << to_utf8(subst(rtrim(langpreamble_, "\n"),
1395 from_ascii("\n"), from_ascii("\n\t")))
1396 << "\n\tEndLangPreamble\n";
1397 if (!babelpreamble_.empty())
1398 os << "\tBabelPreamble\n\t"
1399 << to_utf8(subst(rtrim(babelpreamble_, "\n"),
1400 from_ascii("\n"), from_ascii("\n\t")))
1401 << "\n\tEndBabelPreamble\n";
1402 switch (labeltype) {
1404 os << "\tLabelType Above\n";
1407 os << "\tLabelType Bibliography\n";
1409 case LABEL_CENTERED:
1410 os << "\tLabelType Centered\n";
1412 case LABEL_ENUMERATE:
1413 os << "\tLabelType Enumerate\n";
1416 os << "\tLabelType Itemize\n";
1419 os << "\tLabelType Manual\n";
1421 case LABEL_NO_LABEL:
1422 os << "\tLabelType No_Label\n";
1424 case LABEL_SENSITIVE:
1425 os << "\tLabelType Sensitive\n";
1428 os << "\tLabelType Static\n";
1431 switch (endlabeltype) {
1433 os << "\tEndLabelType Box\n";
1435 case END_LABEL_FILLED_BOX:
1436 os << "\tEndLabelType Filled_Box\n";
1438 case END_LABEL_NO_LABEL:
1439 os << "\tEndLabelType No_Label\n";
1441 case END_LABEL_STATIC:
1442 os << "\tEndLabelType Static\n";
1445 os << "\tParagraphGroup \"" << par_group_ << "\"\n";
1446 if (!leftmargin.empty())
1447 os << "\tLeftMargin \"" << to_utf8(leftmargin) << "\"\n";
1448 if (!rightmargin.empty())
1449 os << "\tRightMargin \"" << to_utf8(rightmargin) << "\"\n";
1450 if (!labelindent.empty())
1451 os << "\tLabelIndent " << to_utf8(labelindent) << '\n';
1452 if (!parindent.empty())
1453 os << "\tParIndent " << to_utf8(parindent) << '\n';
1454 os << "\tParSkip " << parskip << "\n"
1455 "\tItemSep " << itemsep << "\n"
1456 "\tTopSep " << topsep << "\n"
1457 "\tBottomSep " << bottomsep << "\n"
1458 "\tLabelBottomSep " << labelbottomsep << '\n';
1459 if (!labelsep.empty())
1460 os << "\tLabelSep " << to_utf8(subst(labelsep, ' ', 'x'))
1462 os << "\tParSep " << parsep << "\n"
1463 "\tNewLine " << newline_allowed << '\n';
1465 case LYX_ALIGN_BLOCK:
1466 os << "\tAlign Block\n";
1468 case LYX_ALIGN_CENTER:
1469 os << "\tAlign Center\n";
1471 case LYX_ALIGN_LAYOUT:
1472 os << "\tAlign Layout\n";
1474 case LYX_ALIGN_LEFT:
1475 os << "\tAlign Left\n";
1477 case LYX_ALIGN_RIGHT:
1478 os << "\tAlign Right\n";
1480 case LYX_ALIGN_DECIMAL:
1481 case LYX_ALIGN_SPECIAL:
1482 case LYX_ALIGN_NONE:
1485 if (alignpossible & (LYX_ALIGN_BLOCK | LYX_ALIGN_CENTER |
1486 LYX_ALIGN_LAYOUT | LYX_ALIGN_LEFT | LYX_ALIGN_RIGHT)) {
1488 os << "\tAlignPossible";
1489 if (alignpossible & LYX_ALIGN_BLOCK) {
1493 if (alignpossible & LYX_ALIGN_CENTER) {
1499 if (alignpossible & LYX_ALIGN_LAYOUT) {
1505 if (alignpossible & LYX_ALIGN_LEFT) {
1511 if (alignpossible & LYX_ALIGN_RIGHT) {
1519 // LabelString must come before LabelStringAppendix
1520 if (!labelstring_.empty())
1521 os << "\tLabelString \"" << to_utf8(labelstring_) << "\"\n";
1522 if (!endlabelstring_.empty())
1523 os << "\tEndLabelString \"" << to_utf8(endlabelstring_) << "\"\n";
1524 if (!labelstring_appendix_.empty() && labelstring_appendix_ != labelstring_)
1525 os << "\tLabelStringAppendix \""
1526 << to_utf8(labelstring_appendix_) << "\"\n";
1527 if (!counter.empty())
1528 os << "\tLabelCounter \"" << to_utf8(counter) << "\"\n";
1529 os << "\tFreeSpacing " << free_spacing << '\n';
1530 os << "\tPassThru " << pass_thru << '\n';
1531 if (!pass_thru_chars.empty())
1532 os << "\tPassThruChars " << to_utf8(pass_thru_chars) << '\n';
1533 os << "\tParbreakIsNewline " << parbreak_is_newline << '\n';
1534 switch (spacing.getSpace()) {
1535 case Spacing::Double:
1536 os << "\tSpacing Double\n";
1538 case Spacing::Onehalf:
1539 os << "\tSpacing Onehalf\n";
1541 case Spacing::Other:
1542 os << "\tSpacing Other " << spacing.getValueAsString() << '\n';
1544 case Spacing::Single:
1545 os << "\tSpacing Single\n";
1547 case Spacing::Default:
1550 if (!required_.empty()) {
1551 os << "\tRequires ";
1552 for (set<string>::const_iterator it = required_.begin();
1553 it != required_.end(); ++it) {
1554 if (it != required_.begin())
1560 if (!autonests_.empty()) {
1561 os << "\tAutoNests\n\t";
1562 for (set<docstring>::const_iterator it = autonests_.begin();
1563 it != autonests_.end(); ++it) {
1564 if (it != autonests_.begin())
1568 os << "\n\tEndAutoNests\n";
1570 if (!autonested_by_.empty()) {
1571 os << "\tIsAutoNestedBy\n\t\t";
1572 for (set<docstring>::const_iterator it = autonested_by_.begin();
1573 it != autonested_by_.end(); ++it) {
1574 if (it != autonested_by_.begin())
1578 os << "\n\tEndIsAutoNestedBy\n";
1580 if (refprefix.empty())
1581 os << "\tRefPrefix OFF\n";
1583 os << "\tRefPrefix " << to_utf8(refprefix) << '\n';
1584 if (!htmltag_.empty())
1585 os << "\tHTMLTag " << htmltag_ << '\n';
1586 if (!htmlattr_.empty())
1587 os << "\tHTMLAttr " << htmlattr_ << '\n';
1588 if (!htmlitemtag_.empty())
1589 os << "\tHTMLItem " << htmlitemtag_ << '\n';
1590 if (!htmlitemattr_.empty())
1591 os << "\tHTMLItemAttr " << htmlitemattr_ << '\n';
1592 if (!htmllabeltag_.empty())
1593 os << "\tHTMLLabel " << htmllabeltag_ << '\n';
1594 if (!htmllabelattr_.empty())
1595 os << "\tHTMLLabelAttr " << htmllabelattr_ << '\n';
1596 os << "\tHTMLLabelFirst " << htmllabelfirst_ << '\n';
1597 if (!htmlstyle_.empty())
1598 os << "\tHTMLStyle\n"
1599 << to_utf8(rtrim(htmlstyle_, "\n"))
1600 << "\n\tEndHTMLStyle\n";
1601 os << "\tHTMLForceCSS " << htmlforcecss_ << '\n';
1602 if (!htmlpreamble_.empty())
1603 os << "\tHTMLPreamble\n"
1604 << to_utf8(rtrim(htmlpreamble_, "\n"))
1605 << "\n\tEndPreamble\n";
1606 os << "\tHTMLTitle " << htmltitle_ << "\n";
1607 if(!docbooktag_.empty())
1608 os << "\tDocBookTag " << docbooktag_ << '\n';
1609 if(!docbookattr_.empty())
1610 os << "\tDocBookAttr " << docbookattr_ << '\n';
1611 if(!docbookininfo_.empty())
1612 os << "\tDocBookInInfo " << docbookininfo_ << '\n';
1613 os << "\tDocBookAbstract " << docbookabstract_ << '\n';
1614 if(!docbookwrappertag_.empty())
1615 os << "\tDocBookWrapperTag " << docbookwrappertag_ << '\n';
1616 if(!docbookwrapperattr_.empty())
1617 os << "\tDocBookWrapperAttr " << docbookwrapperattr_ << '\n';
1618 if(!docbooksectiontag_.empty())
1619 os << "\tDocBookSectionTag " << docbooksectiontag_ << '\n';
1620 if(!docbookitemtag_.empty())
1621 os << "\tDocBookItemTag " << docbookitemtag_ << '\n';
1622 if(!docbookitemattr_.empty())
1623 os << "\tDocBookItemAttr " << docbookitemattr_ << '\n';
1624 if(!docbookitemwrappertag_.empty())
1625 os << "\tDocBookItemWrapperTag " << docbookitemwrappertag_ << '\n';
1626 if(!docbookitemwrapperattr_.empty())
1627 os << "\tDocBookItemWrapperAttr " << docbookitemwrapperattr_ << '\n';
1628 os << "\tDocBookItemWrapperMergeWithPrevious " << docbookwrappermergewithprevious_ << '\n';
1629 if(!docbookitemlabeltag_.empty())
1630 os << "\tDocBookItemLabelTag " << docbookitemlabeltag_ << '\n';
1631 if(!docbookitemlabelattr_.empty())
1632 os << "\tDocBookItemLabelAttr " << docbookitemlabelattr_ << '\n';
1633 if(!docbookiteminnertag_.empty())
1634 os << "\tDocBookItemInnerTag " << docbookiteminnertag_ << '\n';
1635 if(!docbookiteminnerattr_.empty())
1636 os << "\tDocBookItemInnerAttr " << docbookiteminnerattr_ << '\n';
1637 if(!docbookforceabstracttag_.empty())
1638 os << "\tDocBookForceAbstractTag " << docbookforceabstracttag_ << '\n';
1639 os << "\tSpellcheck " << spellcheck << "\n"
1640 "\tForceLocal " << forcelocal << "\n"
1645 bool Layout::hasArgs() const
1647 return !latexargs_.empty() || !postcommandargs_.empty() ||
1648 !itemargs_.empty() || !listpreamble_.empty();
1652 Layout::LaTeXArgMap Layout::args() const
1654 LaTeXArgMap args = latexargs_;
1655 if (!postcommandargs_.empty())
1656 args.insert(postcommandargs_.begin(), postcommandargs_.end());
1657 if (!listpreamble_.empty())
1658 args.insert(listpreamble_.begin(), listpreamble_.end());
1659 if (!itemargs_.empty())
1660 args.insert(itemargs_.begin(), itemargs_.end());
1665 int Layout::optArgs() const
1668 LaTeXArgMap::const_iterator it = latexargs_.begin();
1669 for (; it != latexargs_.end(); ++it) {
1670 if (!(*it).second.mandatory)
1673 LaTeXArgMap::const_iterator iit = postcommandargs_.begin();
1674 for (; iit != postcommandargs_.end(); ++iit) {
1675 if (!(*iit).second.mandatory)
1682 int Layout::requiredArgs() const
1685 LaTeXArgMap::const_iterator it = latexargs_.begin();
1686 for (; it != latexargs_.end(); ++it) {
1687 if ((*it).second.mandatory)
1690 LaTeXArgMap::const_iterator iit = postcommandargs_.begin();
1691 for (; iit != postcommandargs_.end(); ++iit) {
1692 if (!(*iit).second.mandatory)
1699 string const & Layout::htmltag() const
1701 if (htmltag_.empty())
1707 string const & Layout::htmlattr() const
1709 if (htmlattr_.empty())
1710 htmlattr_ = "class=\"" + defaultCSSClass() + "\"";
1715 string const & Layout::htmlitemtag() const
1717 if (htmlitemtag_.empty())
1718 htmlitemtag_ = "div";
1719 return htmlitemtag_;
1723 string const & Layout::htmlitemattr() const
1725 if (htmlitemattr_.empty())
1726 htmlitemattr_ = "class=\"" + defaultCSSItemClass() + "\"";
1727 return htmlitemattr_;
1731 string const & Layout::htmllabeltag() const
1733 if (htmllabeltag_.empty())
1734 htmllabeltag_ = "span";
1735 return htmllabeltag_;
1739 string const & Layout::htmllabelattr() const
1741 if (htmllabelattr_.empty())
1742 htmllabelattr_ = "class=\"" + defaultCSSLabelClass() + "\"";
1743 return htmllabelattr_;
1747 docstring Layout::htmlstyle() const
1749 if (!htmlstyle_.empty() && !htmlforcecss_)
1751 if (htmldefaultstyle_.empty())
1753 docstring retval = htmldefaultstyle_;
1754 if (!htmlstyle_.empty())
1755 retval += '\n' + htmlstyle_;
1760 string Layout::defaultCSSClass() const
1762 if (!defaultcssclass_.empty())
1763 return defaultcssclass_;
1765 docstring::const_iterator it = name().begin();
1766 docstring::const_iterator en = name().end();
1767 for (; it != en; ++it) {
1768 char_type const c = *it;
1769 if (!isAlphaASCII(c)) {
1771 // make sure we don't start with an underscore,
1772 // as that sometimes causes problems.
1773 d = from_ascii("lyx_");
1776 } else if (isLower(c))
1779 // this is slow, so do it only if necessary
1782 defaultcssclass_ = to_utf8(d);
1783 return defaultcssclass_;
1787 string const & Layout::docbooktag() const
1789 // No sensible default value, unhappily...
1790 if (docbooktag_.empty())
1791 docbooktag_ = to_utf8(name_);
1796 string const & Layout::docbookattr() const
1798 // Perfectly OK to return no attributes, so docbookattr_ does not need to be filled.
1799 return docbookattr_;
1803 string const & Layout::docbookininfo() const
1805 // Indeed, a trilean. Only titles should be "maybe": otherwise, metadata is "always", content is "never".
1806 if (docbookininfo_.empty() || (docbookininfo_ != "never" && docbookininfo_ != "always" && docbookininfo_ != "maybe"))
1807 docbookininfo_ = "never";
1808 return docbookininfo_;
1812 string const & Layout::docbookwrappertag() const
1814 if (docbookwrappertag_.empty())
1815 docbookwrappertag_ = "NONE";
1816 return docbookwrappertag_;
1820 string const & Layout::docbookwrapperattr() const
1822 return docbookwrapperattr_;
1826 string const & Layout::docbooksectiontag() const
1828 if (docbooksectiontag_.empty())
1829 docbooksectiontag_ = "section";
1830 return docbooksectiontag_;
1834 string const & Layout::docbookitemwrappertag() const
1836 if (docbookitemwrappertag_.empty())
1837 docbookitemwrappertag_ = "NONE";
1838 return docbookitemwrappertag_;
1842 string const & Layout::docbookitemwrapperattr() const
1844 return docbookitemwrapperattr_;
1848 string const & Layout::docbookitemtag() const
1850 return docbookitemtag_;
1854 string const & Layout::docbookitemattr() const
1856 return docbookitemattr_;
1860 string const & Layout::docbookitemlabeltag() const
1862 if (docbookitemlabeltag_.empty())
1863 docbookitemlabeltag_ = "NONE";
1864 return docbookitemlabeltag_;
1868 string const & Layout::docbookitemlabelattr() const
1870 return docbookitemlabelattr_;
1874 string const & Layout::docbookiteminnertag() const
1876 if (docbookiteminnertag_.empty())
1877 docbookiteminnertag_ = "NONE";
1878 return docbookiteminnertag_;
1882 string const & Layout::docbookiteminnerattr() const
1884 return docbookiteminnerattr_;
1888 std::string const & Layout::docbookforceabstracttag() const
1890 if (docbookforceabstracttag_.empty())
1891 docbookforceabstracttag_ = "NONE";
1892 return docbookforceabstracttag_;
1899 string makeMarginValue(char const * side, double d)
1902 os << "margin-" << side << ": " << d << "ex;\n";
1909 void Layout::makeDefaultCSS() const
1911 // this never needs to be redone, since reloading layouts will
1912 // wipe out what we did before.
1913 if (!htmldefaultstyle_.empty())
1917 htmldefaultstyle_ = font.asCSS();
1922 tmp += makeMarginValue("top", topsep);
1924 tmp += makeMarginValue("bottom", bottomsep);
1925 if (!leftmargin.empty()) {
1926 // we can't really do what LyX does with the margin, so
1927 // we'll just figure out how many characters it is
1928 int const len = leftmargin.length();
1929 tmp += makeMarginValue("left", len);
1931 if (!rightmargin.empty()) {
1932 int const len = rightmargin.length();
1933 tmp += makeMarginValue("right", len);
1937 if (!htmldefaultstyle_.empty())
1938 htmldefaultstyle_ += from_ascii("\n");
1939 htmldefaultstyle_ += from_ascii(tmp);
1943 string where = alignmentToCSS(align);
1944 if (!where.empty()) {
1945 htmldefaultstyle_ += from_ascii("text-align: " + where + ";\n");
1948 // wrap up what we have, if anything
1949 if (!htmldefaultstyle_.empty())
1951 from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") +
1952 htmldefaultstyle_ + from_ascii("\n}\n");
1954 if (labeltype == LABEL_NO_LABEL || htmllabeltag() == "NONE")
1960 if (labelfont != font)
1961 labelCSS = labelfont.asCSS() + from_ascii("\n");
1962 if (labeltype == LABEL_CENTERED)
1963 labelCSS += from_ascii("text-align: center;\n");
1965 if (!labelCSS.empty())
1966 htmldefaultstyle_ +=
1967 from_ascii(htmllabeltag() + "." + defaultCSSLabelClass() + " {\n") +
1968 labelCSS + from_ascii("\n}\n");
1972 bool Layout::operator==(Layout const & rhs) const
1974 // This is enough for the applications we actually make,
1975 // at least at the moment. But we could check more.
1976 return name() == rhs.name()
1977 && latexname() == rhs.latexname()
1978 && latextype == rhs.latextype;