2 * \file paragraph_funcs.C
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
8 * Full author contact details are available in file CREDITS
13 #include "paragraph_funcs.h"
14 #include "paragraph_pimpl.h"
16 #include "ParagraphParameters.h"
17 #include "lyxtextclasslist.h"
26 #include "support/lstrings.h"
27 #include "insets/insetoptarg.h"
28 #include "insets/insetcommandparams.h"
29 #include "insets/insetbibitem.h"
30 #include "insets/insetspecialchar.h"
31 #include "insets/insetlatexaccent.h"
32 #include "insets/insettabular.h"
33 #include "insets/insethfill.h"
34 #include "insets/inseterror.h"
35 #include "insets/insetnewline.h"
37 extern string bibitemWidest(Buffer const *);
40 //using lyx::layout_type;
44 void breakParagraph(BufferParams const & bparams,
45 ParagraphList & paragraphs,
46 ParagraphList::iterator par,
50 // create a new paragraph, and insert into the list
51 ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
54 // without doing that we get a crash when typing <Return> at the
56 tmp->layout(bparams.getLyXTextClass().defaultLayout());
57 // remember to set the inset_owner
58 tmp->setInsetOwner(par->inInset());
60 if (bparams.tracking_changes)
63 // this is an idea for a more userfriendly layout handling, I will
64 // see what the users say
66 // layout stays the same with latex-environments
68 tmp->layout(par->layout());
69 tmp->setLabelWidthString(par->params().labelWidthString());
72 bool const isempty = (par->layout()->keepempty && par->empty());
74 if (!isempty && (par->size() > pos || par->empty() || flag == 2)) {
75 tmp->layout(par->layout());
76 tmp->params().align(par->params().align());
77 tmp->setLabelWidthString(par->params().labelWidthString());
79 tmp->params().lineBottom(par->params().lineBottom());
80 par->params().lineBottom(false);
81 tmp->params().pagebreakBottom(par->params().pagebreakBottom());
82 par->params().pagebreakBottom(false);
83 tmp->params().spaceBottom(par->params().spaceBottom());
84 par->params().spaceBottom(VSpace(VSpace::NONE));
86 tmp->params().depth(par->params().depth());
87 tmp->params().noindent(par->params().noindent());
89 // copy everything behind the break-position
90 // to the new paragraph
93 #warning this seems wrong
95 /* FIXME: if !keepempty, empty() == true, then we reach
96 * here with size() == 0. So pos_end becomes - 1. Why
97 * doesn't this cause problems ???
99 pos_type pos_end = par->size() - 1;
103 for (; i <= pos_end; ++i) {
104 Change::Type change(par->lookupChange(i));
105 par->cutIntoMinibuffer(bparams, i);
106 if (tmp->insertFromMinibuffer(j - pos)) {
107 tmp->setChange(j - pos, change);
111 for (i = pos_end; i >= pos; --i) {
119 tmp->params().lineTop(par->params().lineTop());
120 tmp->params().pagebreakTop(par->params().pagebreakTop());
121 tmp->params().spaceTop(par->params().spaceTop());
122 par->params().clear();
124 par->layout(bparams.getLyXTextClass().defaultLayout());
126 // layout stays the same with latex-environments
128 par->layout(tmp->layout());
129 par->setLabelWidthString(tmp->params().labelWidthString());
130 par->params().depth(tmp->params().depth());
133 // subtle, but needed to get empty pars working right
134 if (bparams.tracking_changes) {
137 } else if (!tmp->size()) {
144 void breakParagraphConservative(BufferParams const & bparams,
145 ParagraphList & paragraphs,
146 ParagraphList::iterator par,
149 // create a new paragraph
150 ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
152 tmp->makeSameLayout(*par);
154 // When can pos > size()?
155 // I guess pos == size() is possible.
156 if (par->size() > pos) {
157 // copy everything behind the break-position to the new
159 pos_type pos_end = par->size() - 1;
161 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
162 par->cutIntoMinibuffer(bparams, i);
163 if (tmp->insertFromMinibuffer(j - pos))
167 for (pos_type k = pos_end; k >= pos; --k) {
174 void mergeParagraph(BufferParams const & bparams,
175 ParagraphList & paragraphs,
176 ParagraphList::iterator par)
178 ParagraphList::iterator the_next = boost::next(par);
180 // first the DTP-stuff
181 par->params().lineBottom(the_next->params().lineBottom());
182 par->params().spaceBottom(the_next->params().spaceBottom());
183 par->params().pagebreakBottom(the_next->params().pagebreakBottom());
185 pos_type pos_end = the_next->size() - 1;
186 pos_type pos_insert = par->size();
188 // ok, now copy the paragraph
189 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
190 the_next->cutIntoMinibuffer(bparams, i);
191 if (par->insertFromMinibuffer(pos_insert + j))
195 paragraphs.erase(the_next);
199 ParagraphList::iterator depthHook(ParagraphList::iterator pit,
200 ParagraphList const & plist,
201 Paragraph::depth_type depth)
203 ParagraphList::iterator newpit = pit;
204 ParagraphList::iterator beg = plist.begin();
209 while (newpit != beg && newpit->getDepth() > depth) {
213 if (newpit->getDepth() > depth)
220 ParagraphList::iterator outerHook(ParagraphList::iterator pit,
221 ParagraphList const & plist)
223 if (!pit->getDepth())
225 return depthHook(pit, plist,
226 Paragraph::depth_type(pit->getDepth() - 1));
230 bool isFirstInSequence(ParagraphList::iterator pit,
231 ParagraphList const & plist)
233 ParagraphList::iterator dhook = depthHook(pit, plist, pit->getDepth());
235 || dhook->layout() != pit->layout()
236 || dhook->getDepth() != pit->getDepth());
240 int getEndLabel(ParagraphList::iterator p,
241 ParagraphList const & plist)
243 ParagraphList::iterator pit = p;
244 Paragraph::depth_type par_depth = p->getDepth();
245 while (pit != plist.end()) {
246 LyXLayout_ptr const & layout = pit->layout();
247 int const endlabeltype = layout->endlabeltype;
249 if (endlabeltype != END_LABEL_NO_LABEL) {
250 if (boost::next(p) == plist.end())
253 Paragraph::depth_type const next_depth = boost::next(p)->getDepth();
254 if (par_depth > next_depth ||
255 (par_depth == next_depth &&
256 layout != boost::next(p)->layout()))
262 pit = outerHook(pit, plist);
263 if (pit != plist.end())
264 par_depth = pit->getDepth();
266 return END_LABEL_NO_LABEL;
272 ParagraphList::iterator
273 TeXEnvironment(Buffer const * buf,
274 ParagraphList const & paragraphs,
275 ParagraphList::iterator pit,
276 ostream & os, TexRow & texrow);
278 ParagraphList::iterator
279 TeXOnePar(Buffer const * buf,
280 ParagraphList const & paragraphs,
281 ParagraphList::iterator pit,
282 ostream & os, TexRow & texrow,
286 ParagraphList::iterator
287 TeXDeeper(Buffer const * buf,
288 ParagraphList const & paragraphs,
289 ParagraphList::iterator pit,
290 ostream & os, TexRow & texrow)
292 lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl;
293 ParagraphList::iterator par = pit;
295 while (par != paragraphs.end() &&
296 par->params().depth() == pit->params().depth()) {
297 if (par->layout()->isEnvironment()) {
298 par = TeXEnvironment(buf, paragraphs, par,
301 par = TeXOnePar(buf, paragraphs, par,
305 lyxerr[Debug::LATEX] << "TeXDeeper...done " << &*par << endl;
311 ParagraphList::iterator
312 TeXEnvironment(Buffer const * buf,
313 ParagraphList const & paragraphs,
314 ParagraphList::iterator pit,
315 ostream & os, TexRow & texrow)
317 lyxerr[Debug::LATEX] << "TeXEnvironment... " << &*pit << endl;
319 BufferParams const & bparams = buf->params;
321 LyXLayout_ptr const & style = pit->layout();
323 Language const * language = pit->getParLanguage(bparams);
324 Language const * doc_language = bparams.language;
325 Language const * previous_language =
326 (pit != paragraphs.begin())
327 ? boost::prior(pit)->getParLanguage(bparams)
329 if (language->babel() != previous_language->babel()) {
331 if (!lyxrc.language_command_end.empty() &&
332 previous_language->babel() != doc_language->babel()) {
333 os << subst(lyxrc.language_command_end, "$$lang",
334 previous_language->babel())
339 if (lyxrc.language_command_end.empty() ||
340 language->babel() != doc_language->babel()) {
341 os << subst(lyxrc.language_command_begin, "$$lang",
348 bool leftindent_open = false;
349 if (!pit->params().leftIndent().zero()) {
350 os << "\\begin{LyXParagraphLeftIndent}{" <<
351 pit->params().leftIndent().asLatexString() << "}\n";
353 leftindent_open = true;
356 if (style->isEnvironment()) {
357 if (style->latextype == LATEX_LIST_ENVIRONMENT) {
358 os << "\\begin{" << style->latexname() << "}{"
359 << pit->params().labelWidthString() << "}\n";
360 } else if (style->labeltype == LABEL_BIBLIO) {
362 os << "\\begin{" << style->latexname() << "}{"
363 << bibitemWidest(buf)
365 } else if (style->latextype == LATEX_ITEM_ENVIRONMENT) {
366 os << "\\begin{" << style->latexname() << '}'
367 << style->latexparam() << '\n';
369 os << "\\begin{" << style->latexname() << '}'
370 << style->latexparam() << '\n';
373 ParagraphList::iterator par = pit;
375 par = TeXOnePar(buf, paragraphs, par, os, texrow, false);
377 if (par != paragraphs.end()&& par->params().depth() > pit->params().depth()) {
378 if (par->layout()->isParagraph()) {
381 // How to handle this? (Lgb)
382 //&& !suffixIs(os, "\n\n")
384 // There should be at least one '\n' already
385 // but we need there to be two for Standard
386 // paragraphs that are depth-increment'ed to be
387 // output correctly. However, tables can
388 // also be paragraphs so don't adjust them.
391 // Will it ever harm to have one '\n' too
392 // many? i.e. that we sometimes will have
393 // three in a row. (Lgb)
397 par = TeXDeeper(buf, paragraphs, par, os, texrow);
399 } while (par != paragraphs.end()
400 && par->layout() == pit->layout()
401 && par->params().depth() == pit->params().depth()
402 && par->params().leftIndent() == pit->params().leftIndent());
404 if (style->isEnvironment()) {
405 os << "\\end{" << style->latexname() << "}\n";
409 if (leftindent_open) {
410 os << "\\end{LyXParagraphLeftIndent}\n";
414 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << &*par << endl;
415 return par; // ale970302
419 InsetOptArg * optArgInset(Paragraph const & par)
422 InsetList::iterator it = par.insetlist.begin();
423 InsetList::iterator end = par.insetlist.end();
424 for (; it != end; ++it) {
425 Inset * ins = it.getInset();
426 if (ins->lyxCode() == Inset::OPTARG_CODE) {
427 return static_cast<InsetOptArg *>(ins);
434 ParagraphList::iterator
435 TeXOnePar(Buffer const * buf,
436 ParagraphList const & paragraphs,
437 ParagraphList::iterator pit,
438 ostream & os, TexRow & texrow,
441 lyxerr[Debug::LATEX] << "TeXOnePar... " << &*pit << endl;
442 BufferParams const & bparams = buf->params;
444 Inset const * in = pit->inInset();
445 bool further_blank_line = false;
448 // well we have to check if we are in an inset with unlimited
449 // lenght (all in one row) if that is true then we don't allow
450 // any special options in the paragraph and also we don't allow
451 // any environment other then "Standard" to be valid!
452 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
453 style = pit->layout();
455 if (pit->params().startOfAppendix()) {
456 os << "\\appendix\n";
460 if (!pit->params().spacing().isDefault()
461 && (pit == paragraphs.begin() || !boost::prior(pit)->hasSameLayout(*pit))) {
462 os << pit->params().spacing().writeEnvirBegin() << '\n';
466 if (style->isCommand()) {
471 if (pit->params().pagebreakTop()) {
473 further_blank_line = true;
475 if (pit->params().spaceTop().kind() != VSpace::NONE) {
476 os << pit->params().spaceTop().asLatexCommand(bparams);
477 further_blank_line = true;
480 if (pit->params().lineTop()) {
482 << pit->getFont(bparams, 0, outerFont(pit, paragraphs)).latexSize()
484 << "\\vspace{-1\\parskip}";
485 further_blank_line = true;
488 if (further_blank_line) {
493 style = bparams.getLyXTextClass().defaultLayout();
496 Language const * language = pit->getParLanguage(bparams);
497 Language const * doc_language = bparams.language;
498 Language const * previous_language =
499 (pit != paragraphs.begin())
500 ? boost::prior(pit)->getParLanguage(bparams)
503 if (language->babel() != previous_language->babel()
504 // check if we already put language command in TeXEnvironment()
505 && !(style->isEnvironment()
506 && (pit == paragraphs.begin() ||
507 (boost::prior(pit)->layout() != pit->layout() &&
508 boost::prior(pit)->getDepth() <= pit->getDepth())
509 || boost::prior(pit)->getDepth() < pit->getDepth())))
511 if (!lyxrc.language_command_end.empty() &&
512 previous_language->babel() != doc_language->babel())
514 os << subst(lyxrc.language_command_end, "$$lang",
515 previous_language->babel())
520 if (lyxrc.language_command_end.empty() ||
521 language->babel() != doc_language->babel())
523 os << subst(lyxrc.language_command_begin, "$$lang",
530 if (bparams.inputenc == "auto" &&
531 language->encoding() != previous_language->encoding()) {
532 os << "\\inputencoding{"
533 << language->encoding()->LatexName()
538 switch (style->latextype) {
540 os << '\\' << style->latexname();
542 // Separate handling of optional argument inset.
543 if (style->optionalargs == 1) {
544 InsetOptArg * it = optArgInset(*pit);
546 it->latexOptional(buf, os, false, false);
549 os << style->latexparam();
551 case LATEX_ITEM_ENVIRONMENT:
552 case LATEX_LIST_ENVIRONMENT:
555 case LATEX_BIB_ENVIRONMENT:
556 // ignore this, the inset will write itself
562 bool need_par = pit->simpleTeXOnePar(buf, bparams,
563 outerFont(pit, paragraphs),
564 os, texrow, moving_arg);
566 // Make sure that \\par is done with the font of the last
567 // character if this has another size as the default.
568 // This is necessary because LaTeX (and LyX on the screen)
569 // calculates the space between the baselines according
570 // to this font. (Matthias)
572 // Is this really needed ? (Dekel)
573 // We do not need to use to change the font for the last paragraph
575 LyXFont const outerfont(outerFont(pit, paragraphs));
579 ? pit->getLayoutFont(bparams, outerfont)
580 : pit->getFont(bparams, pit->size() - 1, outerfont));
582 bool is_command = style->isCommand();
584 if (style->resfont.size() != font.size()
585 && boost::next(pit) != paragraphs.end()
589 os << "\\" << font.latexSize() << " \\par}";
590 } else if (need_par) {
592 } else if (is_command)
595 switch (style->latextype) {
596 case LATEX_ITEM_ENVIRONMENT:
597 case LATEX_LIST_ENVIRONMENT:
598 if (boost::next(pit) != paragraphs.end()
599 && (pit->params().depth() < boost::next(pit)->params().depth())) {
604 case LATEX_ENVIRONMENT:
605 // if its the last paragraph of the current environment
606 // skip it otherwise fall through
607 if (boost::next(pit) != paragraphs.end()
608 && (boost::next(pit)->layout() != pit->layout()
609 || boost::next(pit)->params().depth() != pit->params().depth()))
611 // fall through possible
613 // we don't need it for the last paragraph!!!
614 if (boost::next(pit) != paragraphs.end()) {
620 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
621 further_blank_line = false;
622 if (pit->params().lineBottom()) {
623 os << "\\lyxline{\\" << font.latexSize() << '}';
624 further_blank_line = true;
627 if (pit->params().spaceBottom().kind() != VSpace::NONE) {
628 os << pit->params().spaceBottom().asLatexCommand(bparams);
629 further_blank_line = true;
632 if (pit->params().pagebreakBottom()) {
634 further_blank_line = true;
637 if (further_blank_line) {
642 if (!pit->params().spacing().isDefault()
643 && (boost::next(pit) == paragraphs.end()|| !boost::next(pit)->hasSameLayout(*pit))) {
644 os << pit->params().spacing().writeEnvirEnd() << '\n';
649 // we don't need it for the last paragraph!!!
650 if (boost::next(pit) != paragraphs.end()) {
654 // Since \selectlanguage write the language to the aux file,
655 // we need to reset the language at the end of footnote or
658 if (language->babel() != doc_language->babel()) {
659 if (lyxrc.language_command_end.empty())
660 os << subst(lyxrc.language_command_begin,
662 doc_language->babel())
665 os << subst(lyxrc.language_command_end,
673 lyxerr[Debug::LATEX] << "TeXOnePar...done " << &*boost::next(pit) << endl;
681 // LaTeX all paragraphs from par to endpar, if endpar == 0 then to the end
683 void latexParagraphs(Buffer const * buf,
684 ParagraphList const & paragraphs,
685 ParagraphList::iterator par,
686 ParagraphList::iterator endpar,
691 bool was_title = false;
692 bool already_title = false;
693 LyXTextClass const & tclass = buf->params.getLyXTextClass();
696 while (par != endpar) {
697 Inset * in = par->inInset();
698 // well we have to check if we are in an inset with unlimited
699 // length (all in one row) if that is true then we don't allow
700 // any special options in the paragraph and also we don't allow
701 // any environment other then "Standard" to be valid!
702 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
703 LyXLayout_ptr const & layout = par->layout();
705 if (layout->intitle) {
707 lyxerr <<"Error in latexParagraphs: You"
708 " should not mix title layouts"
709 " with normal ones." << endl;
710 } else if (!was_title) {
712 if (tclass.titletype() == TITLE_ENVIRONMENT) {
714 << tclass.titlename()
719 } else if (was_title && !already_title) {
720 if (tclass.titletype() == TITLE_ENVIRONMENT) {
721 ofs << "\\end{" << tclass.titlename()
725 ofs << "\\" << tclass.titlename()
729 already_title = true;
733 if (layout->isEnvironment() ||
734 !par->params().leftIndent().zero())
736 par = TeXEnvironment(buf, paragraphs, par, ofs, texrow);
738 par = TeXOnePar(buf, paragraphs, par, ofs, texrow, moving_arg);
741 par = TeXOnePar(buf, paragraphs, par, ofs, texrow, moving_arg);
744 // It might be that we only have a title in this document
745 if (was_title && !already_title) {
746 if (tclass.titletype() == TITLE_ENVIRONMENT) {
747 ofs << "\\end{" << tclass.titlename()
751 ofs << "\\" << tclass.titlename()
761 int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & token)
764 static Change change;
766 BufferParams const & bp = buf.params;
768 if (token[0] != '\\') {
769 string::const_iterator cit = token.begin();
770 for (; cit != token.end(); ++cit) {
771 par.insertChar(par.size(), (*cit), font, change);
773 } else if (token == "\\layout") {
775 string layoutname = lex.getString();
777 font = LyXFont(LyXFont::ALL_INHERIT, bp.language);
780 LyXTextClass const & tclass = bp.getLyXTextClass();
782 if (layoutname.empty()) {
783 layoutname = tclass.defaultLayoutName();
786 bool hasLayout = tclass.hasLayout(layoutname);
789 lyxerr << "Layout '" << layoutname << "' does not"
790 << " exist in textclass '" << tclass.name()
792 lyxerr << "Trying to use default layout instead."
794 layoutname = tclass.defaultLayoutName();
798 // The is the compability reading of layout caption.
799 if (compare_ascii_no_case(layoutname, "caption") == 0) {
800 // We expect that the par we are now working on is
801 // really inside a InsetText inside a InsetFloat.
802 // We also know that captions can only be
803 // one paragraph. (Lgb)
805 // We should now read until the next "\layout"
807 // This is probably not good enough, what if the
808 // caption is the last par in the document (Lgb)
809 istream & ist = lex.getStream();
815 if (prefixIs(line, "\\layout")) {
819 if (prefixIs(line, "\\begin_inset"))
821 if (prefixIs(line, "\\end_inset")) {
833 // Now we should have the whole layout in ss
834 // we should now be able to give this to the
836 ss << "\\end_inset\n";
838 // This seems like a bug in stringstream.
839 // We really should be able to use ss
841 istringstream is(ss.str());
843 tmplex.setStream(is);
844 Inset * inset = new InsetCaption;
845 inset->Read(this, tmplex);
846 par.insertInset(pos, inset, font);
850 par.layout(bp.getLyXTextClass()[layoutname]);
852 // Test whether the layout is obsolete.
853 LyXLayout_ptr const & layout = par.layout();
854 if (!layout->obsoleted_by().empty())
855 par.layout(bp.getLyXTextClass()[layout->obsoleted_by()]);
857 par.params().read(lex);
862 } else if (token == "\\end_inset") {
863 lyxerr << "Solitary \\end_inset in line " << lex.getLineNo() << "\n"
864 << "Missing \\begin_inset?.\n";
865 // Simply ignore this. The insets do not have
867 // But insets should read it, it is a part of
868 // the inset isn't it? Lgb.
869 } else if (token == "\\begin_inset") {
870 Inset * i = readInset(lex, buf);
871 par.insertInset(par.size(), i, font, change);
872 } else if (token == "\\family") {
874 font.setLyXFamily(lex.getString());
875 } else if (token == "\\series") {
877 font.setLyXSeries(lex.getString());
878 } else if (token == "\\shape") {
880 font.setLyXShape(lex.getString());
881 } else if (token == "\\size") {
883 font.setLyXSize(lex.getString());
884 } else if (token == "\\lang") {
886 string const tok = lex.getString();
887 Language const * lang = languages.getLanguage(tok);
889 font.setLanguage(lang);
891 font.setLanguage(bp.language);
892 lex.printError("Unknown language `$$Token'");
894 } else if (token == "\\numeric") {
896 font.setNumber(font.setLyXMisc(lex.getString()));
897 } else if (token == "\\emph") {
899 font.setEmph(font.setLyXMisc(lex.getString()));
900 } else if (token == "\\bar") {
902 string const tok = lex.getString();
905 font.setUnderbar(LyXFont::ON);
906 else if (tok == "no")
907 font.setUnderbar(LyXFont::OFF);
908 else if (tok == "default")
909 font.setUnderbar(LyXFont::INHERIT);
911 lex.printError("Unknown bar font flag "
913 } else if (token == "\\noun") {
915 font.setNoun(font.setLyXMisc(lex.getString()));
916 } else if (token == "\\color") {
918 font.setLyXColor(lex.getString());
919 } else if (token == "\\SpecialChar") {
920 LyXLayout_ptr const & layout = par.layout();
922 // Insets don't make sense in a free-spacing context! ---Kayvan
923 if (layout->free_spacing || par.isFreeSpacing()) {
926 string const next_token = lex.getString();
927 if (next_token == "\\-") {
928 par.insertChar(par.size(), '-', font, change);
929 } else if (next_token == "~") {
930 par.insertChar(par.size(), ' ', font, change);
932 lex.printError("Token `$$Token' "
934 "paragraph layout!");
938 Inset * inset = new InsetSpecialChar;
939 inset->read(&buf, lex);
940 par.insertInset(par.size(), inset, font, change);
942 } else if (token == "\\i") {
943 Inset * inset = new InsetLatexAccent;
944 inset->read(&buf, lex);
945 par.insertInset(par.size(), inset, font, change);
946 } else if (token == "\\backslash") {
947 par.insertChar(par.size(), '\\', font, change);
948 } else if (token == "\\newline") {
949 Inset * inset = new InsetNewline;
950 inset->read(&buf, lex);
951 par.insertInset(par.size(), inset, font, change);
952 } else if (token == "\\LyXTable") {
953 Inset * inset = new InsetTabular(buf);
954 inset->read(&buf, lex);
955 par.insertInset(par.size(), inset, font, change);
956 } else if (token == "\\bibitem") {
957 InsetCommandParams p("bibitem", "dummy");
958 InsetBibitem * inset = new InsetBibitem(p);
959 inset->read(&buf, lex);
960 par.insertInset(par.size(), inset, font, change);
961 } else if (token == "\\hfill") {
962 par.insertInset(par.size(), new InsetHFill(), font, change);
963 } else if (token == "\\change_unchanged") {
964 // Hack ! Needed for empty paragraphs :/
965 // FIXME: is it still ??
968 change = Change(Change::UNCHANGED);
969 } else if (token == "\\change_inserted") {
971 istringstream is(STRCONV(lex.getString()));
975 change = Change(Change::INSERTED, bp.author_map[aid], ct);
976 } else if (token == "\\change_deleted") {
978 istringstream is(STRCONV(lex.getString()));
982 change = Change(Change::DELETED, bp.author_map[aid], ct);
985 string const s = bformat(_("Unknown token: %1$s %2$s\n"),
986 token, lex.getString());
987 // we can do this here this way because we're actually reading
988 // the buffer and don't care about LyXText right now.
989 par.insertInset(par.size(), new InsetError(s), font);
998 int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex)
1003 string token = lex.getString();
1005 while (lex.isOK()) {
1007 unknown += readParToken(buf, par, lex, token);
1010 token = lex.getString();
1015 lyxerr[Debug::PARSER] << "Handling paragraph token: `"
1016 << token << '\'' << endl;
1018 // reached the next paragraph. FIXME: really we should
1019 // change the file format to indicate the end of a par
1020 // clearly, but for now, this hack will do
1021 if (token == "\\layout" || token == "\\the_end"
1022 || token == "\\end_inset" || token == "\\begin_deeper"
1023 || token == "\\end_deeper") {
1024 lex.pushToken(token);
1033 LyXFont const outerFont(ParagraphList::iterator pit,
1034 ParagraphList const & plist)
1036 Paragraph::depth_type par_depth = pit->getDepth();
1037 LyXFont tmpfont(LyXFont::ALL_INHERIT);
1039 // Resolve against environment font information
1040 while (pit != plist.end() &&
1041 par_depth && !tmpfont.resolved()) {
1042 pit = outerHook(pit, plist);
1043 if (pit != plist.end()) {
1044 tmpfont.realize(pit->layout()->font);
1045 par_depth = pit->getDepth();
1053 LyXFont const realizeFont(LyXFont const & font,
1054 BufferParams const & params)
1056 LyXTextClass const & tclass = params.getLyXTextClass();
1057 LyXFont tmpfont(font);
1058 tmpfont.realize(tclass.defaultfont());