]> git.lyx.org Git - lyx.git/blob - src/paragraph_pimpl.C
merge decDepth(), killing some non-parlist code
[lyx.git] / src / paragraph_pimpl.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2001 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #include "paragraph_pimpl.h"
14 #include "LaTeXFeatures.h"
15 #include "texrow.h"
16 #include "language.h"
17 #include "bufferparams.h"
18 #include "encoding.h"
19 #include "lyxrc.h"
20 #include "debug.h"
21
22 #include "support/LAssert.h"
23
24 using lyx::pos_type;
25 using std::endl;
26 using std::ostream;
27 using std::upper_bound;
28 using std::lower_bound;
29
30 // Initialize static member.
31 ShareContainer<LyXFont> Paragraph::Pimpl::FontTable::container;
32 // Initialization of the counter for the paragraph id's,
33 unsigned int Paragraph::Pimpl::paragraph_id = 0;
34
35 namespace {
36
37 struct special_phrase {
38         string phrase;
39         string macro;
40         bool builtin;
41 };
42
43 special_phrase special_phrases[] = {
44         { "LyX", "\\LyX{}", false },
45         { "TeX", "\\TeX{}", true },
46         { "LaTeX2e", "\\LaTeXe{}", true },
47         { "LaTeX", "\\LaTeX{}", true },
48 };
49
50 size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase);
51
52 } // namespace anon
53
54
55 Paragraph::Pimpl::Pimpl(Paragraph * owner)
56         : owner_(owner)
57 {
58         inset_owner = 0;
59         id_ = paragraph_id++;
60 }
61
62
63 Paragraph::Pimpl::Pimpl(Pimpl const & p, Paragraph * owner, bool same_ids)
64         : params(p.params), owner_(owner)
65 {
66         inset_owner = p.inset_owner;
67         text = p.text;
68         fontlist = p.fontlist;
69         if (same_ids)
70                 id_ = p.id_;
71         else
72                 id_ = paragraph_id++;
73
74         if (p.tracking())
75                 changes_.reset(new Changes(*p.changes_.get()));
76 }
77
78
79 void Paragraph::Pimpl::clear()
80 {
81         text.clear();
82 #warning changes ?
83 }
84
85
86 void Paragraph::Pimpl::setContentsFromPar(Paragraph const * par)
87 {
88         lyx::Assert(par);
89         text = par->pimpl_->text;
90         if (par->pimpl_->tracking()) {
91                 changes_.reset(new Changes(*(par->pimpl_->changes_.get())));
92         }
93 }
94
95
96 void Paragraph::Pimpl::trackChanges(Change::Type type)
97 {
98         if (tracking()) {
99                 lyxerr[Debug::CHANGES] << "already tracking for par " << id_ << endl;
100                 return;
101         }
102
103         lyxerr[Debug::CHANGES] << "track changes for par "
104                 << id_ << " type " << type << endl;
105         changes_.reset(new Changes(type));
106         changes_->set(type, 0, size());
107 }
108
109
110 void Paragraph::Pimpl::untrackChanges()
111 {
112         changes_.reset(0);
113 }
114
115
116 void Paragraph::Pimpl::cleanChanges()
117 {
118         // if we're not tracking, we don't want to reset...
119         if (!tracking())
120                 return;
121
122         changes_.reset(new Changes(Change::INSERTED));
123         changes_->set(Change::INSERTED, 0, size());
124 }
125
126
127 bool Paragraph::Pimpl::isChanged(pos_type start, pos_type end) const
128 {
129         if (!tracking())
130                 return false;
131
132         return changes_->isChange(start, end);
133 }
134
135
136 bool Paragraph::Pimpl::isChangeEdited(pos_type start, pos_type end) const
137 {
138         if (!tracking())
139                 return false;
140
141         return changes_->isChangeEdited(start, end);
142 }
143
144
145 void Paragraph::Pimpl::setChange(pos_type pos, Change::Type type)
146 {
147         if (!tracking())
148                 return;
149
150         changes_->set(type, pos);
151 }
152
153
154 Change::Type Paragraph::Pimpl::lookupChange(pos_type pos) const
155 {
156         if (!tracking())
157                 return Change::UNCHANGED;
158
159         return changes_->lookup(pos);
160 }
161
162
163 Change const Paragraph::Pimpl::lookupChangeFull(pos_type pos) const
164 {
165         if (!tracking())
166                 return Change(Change::UNCHANGED);
167
168         return changes_->lookupFull(pos);
169 }
170
171
172 void Paragraph::Pimpl::markErased()
173 {
174         lyx::Assert(tracking());
175
176         // FIXME: we should actually remove INSERTED chars.
177         // difficult because owning insettexts/tabulars need
178         // to update themselves when rows etc. change
179         changes_->set(Change::DELETED, 0, size());
180         changes_->reset(Change::DELETED);
181 }
182
183
184 void Paragraph::Pimpl::acceptChange(pos_type start, pos_type end)
185 {
186         if (!tracking())
187                 return;
188
189         if (!size()) {
190                 changes_.reset(new Changes(Change::UNCHANGED));
191                 return;
192         }
193
194         lyxerr << "acceptchange" << endl;
195         pos_type i = start;
196
197         for (; i < end; ++i) {
198                 switch (lookupChange(i)) {
199                         case Change::UNCHANGED:
200                                 break;
201
202                         case Change::INSERTED:
203                                 changes_->set(Change::UNCHANGED, i);
204                                 break;
205
206                         case Change::DELETED:
207                                 eraseIntern(i);
208                                 changes_->erase(i);
209                                 --end;
210                                 --i;
211                                 break;
212                 }
213         }
214
215         lyxerr << "endacceptchange" << endl;
216         changes_->reset(Change::UNCHANGED);
217 }
218
219
220 void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end)
221 {
222         if (!tracking())
223                 return;
224
225         if (!size()) {
226                 changes_.reset(new Changes(Change::UNCHANGED));
227                 return;
228         }
229
230         pos_type i = start;
231
232         for (; i < end; ++i) {
233                 switch (lookupChange(i)) {
234                         case Change::UNCHANGED:
235                                 break;
236
237                         case Change::INSERTED:
238                                 eraseIntern(i);
239                                 changes_->erase(i);
240                                 --end;
241                                 --i;
242                                 break;
243
244                         case Change::DELETED:
245                                 changes_->set(Change::UNCHANGED, i);
246                                 break;
247                 }
248         }
249         changes_->reset(Change::UNCHANGED);
250 }
251
252
253 Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
254 {
255 #if 1
256         // This is in the critical path for loading!
257         pos_type const siz = size();
258
259         lyx::Assert(pos <= siz);
260
261         if (pos == siz) {
262                 lyxerr << "getChar() on pos " << pos << " in par id "
263                        << owner_->id() << " of size " << siz
264                        << "  is a bit silly !" << endl;
265                 return '\0';
266         }
267
268         return text[pos];
269 #else
270         lyx::Assert(pos < size());
271         return text[pos];
272 #endif
273 }
274
275
276 void Paragraph::Pimpl::setChar(pos_type pos, value_type c)
277 {
278 #warning changes
279         text[pos] = c;
280 }
281
282
283 void Paragraph::Pimpl::insertChar(pos_type pos, value_type c,
284                                   LyXFont const & font, Change change)
285 {
286         lyx::Assert(pos <= size());
287
288         if (tracking()) {
289                 changes_->record(change, pos);
290         }
291
292         // This is actually very common when parsing buffers (and
293         // maybe inserting ascii text)
294         if (pos == size()) {
295                 // when appending characters, no need to update tables
296                 text.push_back(c);
297                 owner_->setFont(pos, font);
298                 return;
299         }
300
301         text.insert(text.begin() + pos, c);
302
303         // Update the font table.
304         FontTable search_font(pos, LyXFont());
305         for (FontList::iterator it = lower_bound(fontlist.begin(),
306                                                       fontlist.end(),
307                                                       search_font, matchFT());
308              it != fontlist.end(); ++it)
309         {
310                 it->pos(it->pos() + 1);
311         }
312
313         // Update the insets
314         owner_->insetlist.increasePosAfterPos(pos);
315
316         owner_->setFont(pos, font);
317 }
318
319
320 void Paragraph::Pimpl::insertInset(pos_type pos,
321                                    Inset * inset, LyXFont const & font, Change change)
322 {
323         lyx::Assert(inset);
324         lyx::Assert(pos <= size());
325
326         insertChar(pos, META_INSET, font, change);
327         lyx::Assert(text[pos] == META_INSET);
328
329         // Add a new entry in the insetlist.
330         owner_->insetlist.insert(inset, pos);
331         inset->parOwner(owner_);
332
333         if (inset_owner)
334                 inset->setOwner(inset_owner);
335 }
336
337
338 bool Paragraph::Pimpl::erasePos(pos_type pos)
339 {
340         lyx::Assert(pos < size());
341
342         if (tracking()) {
343                 Change::Type changetype(changes_->lookup(pos));
344                 changes_->record(Change(Change::DELETED), pos);
345
346                 // only allow the actual removal if it was /new/ text
347                 if (changetype != Change::INSERTED) {
348                         if (text[pos] == Paragraph::META_INSET) {
349                                 Inset * i(owner_->getInset(pos));
350                                 i->markErased();
351                         }
352                         return false;
353                 }
354         }
355
356         eraseIntern(pos);
357         return true;
358 }
359
360
361 void Paragraph::Pimpl::eraseIntern(pos_type pos)
362 {
363         // if it is an inset, delete the inset entry
364         if (text[pos] == Paragraph::META_INSET) {
365                 owner_->insetlist.erase(pos);
366         }
367
368         text.erase(text.begin() + pos);
369
370         // Erase entries in the tables.
371         FontTable search_font(pos, LyXFont());
372
373         FontList::iterator it =
374                 lower_bound(fontlist.begin(),
375                             fontlist.end(),
376                             search_font, matchFT());
377         if (it != fontlist.end() && it->pos() == pos &&
378             (pos == 0 ||
379              (it != fontlist.begin()
380               && boost::prior(it)->pos() == pos - 1))) {
381                 // If it is a multi-character font
382                 // entry, we just make it smaller
383                 // (see update below), otherwise we
384                 // should delete it.
385                 unsigned int const i = it - fontlist.begin();
386                 fontlist.erase(fontlist.begin() + i);
387                 it = fontlist.begin() + i;
388                 if (i > 0 && i < fontlist.size() &&
389                     fontlist[i - 1].font() == fontlist[i].font()) {
390                         fontlist.erase(fontlist.begin() + i - 1);
391                         it = fontlist.begin() + i - 1;
392                 }
393         }
394
395         // Update all other entries.
396         FontList::iterator fend = fontlist.end();
397         for (; it != fend; ++it)
398                 it->pos(it->pos() - 1);
399
400         // Update the insetlist.
401         owner_->insetlist.decreasePosAfterPos(pos);
402 }
403
404
405 void Paragraph::Pimpl::erase(pos_type pos)
406 {
407         erasePos(pos);
408 }
409
410
411 bool Paragraph::Pimpl::erase(pos_type start, pos_type end)
412 {
413         pos_type i = start;
414         pos_type count = end - start;
415         bool any_erased = false;
416
417         while (count) {
418                 if (!erasePos(i)) {
419                         ++i;
420                 } else {
421                         any_erased = true;
422                 }
423                 --count;
424         }
425         return any_erased;
426 }
427
428
429 void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow,
430                                        pos_type const i,
431                                        unsigned int & column,
432                                        LyXFont const & font,
433                                        LyXLayout const & style)
434 {
435         if (style.pass_thru)
436                 return;
437
438         if (column > lyxrc.ascii_linelen
439             && i
440             && getChar(i - 1) != ' '
441             && (i < size() - 1)
442             // same in FreeSpacing mode
443             && !style.free_spacing
444                 && !owner_->isFreeSpacing()
445             // In typewriter mode, we want to avoid
446             // ! . ? : at the end of a line
447             && !(font.family() == LyXFont::TYPEWRITER_FAMILY
448                  && (getChar(i - 1) == '.'
449                      || getChar(i - 1) == '?'
450                      || getChar(i - 1) == ':'
451                      || getChar(i - 1) == '!'))) {
452                 os << '\n';
453                 texrow.newline();
454                 texrow.start(owner_, i + 1);
455                 column = 0;
456         } else if (style.free_spacing) {
457                 os << '~';
458         } else {
459                 os << ' ';
460         }
461 }
462
463
464 bool Paragraph::Pimpl::isTextAt(string const & str, pos_type pos) const
465 {
466         pos_type const len = str.length();
467
468         // is the paragraph large enough?
469         if (pos + len > size())
470                 return false;
471
472         // does the wanted text start at point?
473         for (string::size_type i = 0; i < str.length(); ++i) {
474                 if (str[i] != text[pos + i])
475                         return false;
476         }
477
478         // is there a font change in middle of the word?
479         FontList::const_iterator cit = fontlist.begin();
480         FontList::const_iterator end = fontlist.end();
481         for (; cit != end; ++cit) {
482                 if (cit->pos() >= pos)
483                         break;
484         }
485         if (cit != end && pos + len - 1 > cit->pos())
486                 return false;
487
488         return true;
489 }
490
491
492 void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
493                                              BufferParams const & bparams,
494                                              ostream & os,
495                                              TexRow & texrow,
496                                              bool moving_arg,
497                                              LyXFont & font,
498                                              LyXFont & running_font,
499                                              LyXFont & basefont,
500                                              bool & open_font,
501                                              Change::Type & running_change,
502                                              LyXLayout const & style,
503                                              pos_type & i,
504                                              unsigned int & column,
505                                              value_type const c)
506 {
507         if (style.pass_thru) {
508                 if (c != Paragraph::META_INSET) {
509                         if (c != '\0')
510                                 os << c;
511                 } else {
512                         Inset const * inset = owner_->getInset(i);
513                         inset->ascii(buf, os, 0);
514                 }
515                 return;
516         }
517
518         // Two major modes:  LaTeX or plain
519         // Handle here those cases common to both modes
520         // and then split to handle the two modes separately.
521         switch (c) {
522         case Paragraph::META_INSET: {
523                 Inset * inset = owner_->getInset(i);
524
525                 // FIXME: remove this check
526                 if (!inset)
527                         break;
528
529                 // FIXME: move this to InsetNewline::latex
530                 if (inset->lyxCode() == Inset::NEWLINE_CODE) {
531                         // newlines are handled differently here than
532                         // the default in simpleTeXSpecialChars().
533                         if (!style.newline_allowed) {
534                                 os << '\n';
535                         } else {
536                                 if (open_font) {
537                                         column += running_font.latexWriteEndChanges(os, basefont, basefont);
538                                         open_font = false;
539                                 }
540                                 basefont = owner_->getLayoutFont(bparams);
541                                 running_font = basefont;
542
543                                 if (font.family() == LyXFont::TYPEWRITER_FAMILY)
544                                         os << '~';
545
546                                 if (moving_arg)
547                                         os << "\\protect ";
548
549                                 os << "\\\\\n";
550                         }
551                         texrow.newline();
552                         texrow.start(owner_, i + 1);
553                         column = 0;
554                         break;
555                 }
556
557                 if (inset->isTextInset()) {
558                         column += Changes::latexMarkChange(os, running_change,
559                                 Change::UNCHANGED);
560                         running_change = Change::UNCHANGED;
561                 }
562
563                 bool close = false;
564                 int const len = os.tellp();
565                 //ostream::pos_type const len = os.tellp();
566                 if ((inset->lyxCode() == Inset::GRAPHICS_CODE
567                      || inset->lyxCode() == Inset::MATH_CODE
568                      || inset->lyxCode() == Inset::URL_CODE)
569                     && running_font.isRightToLeft()) {
570                         os << "\\L{";
571                         close = true;
572                 }
573
574 #ifdef WITH_WARNINGS
575 #warning Bug: we can have an empty font change here!
576 // if there has just been a font change, we are going to close it
577 // right now, which means stupid latex code like \textsf{}. AFAIK,
578 // this does not harm dvi output. A minor bug, thus (JMarc)
579 #endif
580                 // some insets cannot be inside a font change command
581                 if (open_font && inset->noFontChange()) {
582                         column +=running_font.
583                                 latexWriteEndChanges(os,
584                                                      basefont,
585                                                      basefont);
586                         open_font = false;
587                         basefont = owner_->getLayoutFont(bparams);
588                         running_font = basefont;
589                 }
590
591                 int tmp = inset->latex(buf, os, moving_arg,
592                                        style.free_spacing);
593
594                 if (close)
595                         os << '}';
596
597                 if (tmp) {
598                         for (int j = 0; j < tmp; ++j) {
599                                 texrow.newline();
600                         }
601                         texrow.start(owner_, i + 1);
602                         column = 0;
603                 } else {
604                         column += int(os.tellp()) - len;
605                 }
606         }
607         break;
608
609         default:
610                 // And now for the special cases within each mode
611
612                 switch (c) {
613                 case '\\':
614                         os << "\\textbackslash{}";
615                         column += 15;
616                         break;
617
618                 case '±': case '²': case '³':
619                 case '×': case '÷': case '¹':
620                 case '¬': case 'µ':
621                         if ((bparams.inputenc == "latin1" ||
622                              bparams.inputenc == "latin9") ||
623                             (bparams.inputenc == "auto" &&
624                              (font.language()->encoding()->LatexName()
625                               == "latin1" ||
626                               font.language()->encoding()->LatexName()
627                               == "latin9"))) {
628                                 os << "\\ensuremath{"
629                                    << c
630                                    << '}';
631                                 column += 13;
632                         } else {
633                                 os << c;
634                         }
635                         break;
636
637                 case '|': case '<': case '>':
638                         // In T1 encoding, these characters exist
639                         if (lyxrc.fontenc == "T1") {
640                                 os << c;
641                                 //... but we should avoid ligatures
642                                 if ((c == '>' || c == '<')
643                                     && i <= size() - 2
644                                     && getChar(i + 1) == c) {
645                                         //os << "\\textcompwordmark{}";
646                                         // Jean-Marc, have a look at
647                                         // this. I think this works
648                                         // equally well:
649                                         os << "\\,{}";
650                                         // Lgb
651                                         column += 19;
652                                 }
653                                 break;
654                         }
655                         // Typewriter font also has them
656                         if (font.family() == LyXFont::TYPEWRITER_FAMILY) {
657                                 os << c;
658                                 break;
659                         }
660                         // Otherwise, we use what LaTeX
661                         // provides us.
662                         switch (c) {
663                         case '<':
664                                 os << "\\textless{}";
665                                 column += 10;
666                                 break;
667                         case '>':
668                                 os << "\\textgreater{}";
669                                 column += 13;
670                                 break;
671                         case '|':
672                                 os << "\\textbar{}";
673                                 column += 9;
674                                 break;
675                         }
676                         break;
677
678                 case '-': // "--" in Typewriter mode -> "-{}-"
679                         if (i <= size() - 2
680                             && getChar(i + 1) == '-'
681                             && font.family() == LyXFont::TYPEWRITER_FAMILY) {
682                                 os << "-{}";
683                                 column += 2;
684                         } else {
685                                 os << '-';
686                         }
687                         break;
688
689                 case '\"':
690                         os << "\\char`\\\"{}";
691                         column += 9;
692                         break;
693
694                 case '£':
695                         if (bparams.inputenc == "default") {
696                                 os << "\\pounds{}";
697                                 column += 8;
698                         } else {
699                                 os << c;
700                         }
701                         break;
702
703                 case '$': case '&':
704                 case '%': case '#': case '{':
705                 case '}': case '_':
706                         os << '\\' << c;
707                         column += 1;
708                         break;
709
710                 case '~':
711                         os << "\\textasciitilde{}";
712                         column += 16;
713                         break;
714
715                 case '^':
716                         os << "\\textasciicircum{}";
717                         column += 17;
718                         break;
719
720                 case '*': case '[': case ']':
721                         // avoid being mistaken for optional arguments
722                         os << '{' << c << '}';
723                         column += 2;
724                         break;
725
726                 case ' ':
727                         // Blanks are printed before font switching.
728                         // Sure? I am not! (try nice-latex)
729                         // I am sure it's correct. LyX might be smarter
730                         // in the future, but for now, nothing wrong is
731                         // written. (Asger)
732                         break;
733
734                 default:
735
736                         // I assume this is hack treating typewriter as verbatim
737                         if (font.family() == LyXFont::TYPEWRITER_FAMILY) {
738                                 if (c != '\0') {
739                                         os << c;
740                                 }
741                                 break;
742                         }
743
744                         // LyX, LaTeX etc.
745
746                         // FIXME: if we have "LaTeX" with a font
747                         // change in the middle (before the 'T', then
748                         // the "TeX" part is still special cased.
749                         // Really we should only operate this on
750                         // "words" for some definition of word
751
752                         size_t pnr = 0;
753
754                         for (; pnr < phrases_nr; ++pnr) {
755                                 if (isTextAt(special_phrases[pnr].phrase, i)) {
756                                         os << special_phrases[pnr].macro;
757                                         i += special_phrases[pnr].phrase.length() - 1;
758                                         column += special_phrases[pnr].macro.length() - 1;
759                                         break;
760                                 }
761                         }
762
763                         if (pnr == phrases_nr && c != '\0') {
764                                 os << c;
765                         }
766                         break;
767                 }
768         }
769 }
770
771
772 void Paragraph::Pimpl::validate(LaTeXFeatures & features,
773                                 LyXLayout const & layout) const
774 {
775         BufferParams const & bparams = features.bufferParams();
776
777         // check the params.
778         if (params.lineTop() || params.lineBottom())
779                 features.require("lyxline");
780         if (!params.spacing().isDefault())
781                 features.require("setspace");
782
783         // then the layouts
784         features.useLayout(layout.name());
785
786         // then the fonts
787         Language const * doc_language = bparams.language;
788
789         FontList::const_iterator fcit = fontlist.begin();
790         FontList::const_iterator fend = fontlist.end();
791         for (; fcit != fend; ++fcit) {
792                 if (fcit->font().noun() == LyXFont::ON) {
793                         lyxerr[Debug::LATEX] << "font.noun: "
794                                              << fcit->font().noun()
795                                              << endl;
796                         features.require("noun");
797                         lyxerr[Debug::LATEX] << "Noun enabled. Font: "
798                                              << fcit->font().stateText(0)
799                                              << endl;
800                 }
801                 switch (fcit->font().color()) {
802                 case LColor::none:
803                 case LColor::inherit:
804                 case LColor::ignore:
805                         // probably we should put here all interface colors used for
806                         // font displaying! For now I just add this ones I know of (Jug)
807                 case LColor::latex:
808                 case LColor::note:
809                         break;
810                 default:
811                         features.require("color");
812                         lyxerr[Debug::LATEX] << "Color enabled. Font: "
813                                              << fcit->font().stateText(0)
814                                              << endl;
815                 }
816
817                 Language const * language = fcit->font().language();
818                 if (language->babel() != doc_language->babel() &&
819                     language != ignore_language &&
820                     language != latex_language)
821                 {
822                         features.useLanguage(language);
823                         lyxerr[Debug::LATEX] << "Found language "
824                                              << language->babel() << endl;
825                 }
826         }
827
828         if (!params.leftIndent().zero())
829                 features.require("ParagraphLeftIndent");
830
831         // then the insets
832         InsetList::iterator icit = owner_->insetlist.begin();
833         InsetList::iterator iend = owner_->insetlist.end();
834         for (; icit != iend; ++icit) {
835                 if (icit.getInset()) {
836                         icit.getInset()->validate(features);
837                         if (layout.needprotect &&
838                             icit.getInset()->lyxCode() == Inset::FOOT_CODE)
839                                 features.require("NeedLyXFootnoteCode");
840                 }
841         }
842
843         // then the contents
844         for (pos_type i = 0; i < size() ; ++i) {
845                 for (size_t pnr = 0; pnr < phrases_nr; ++pnr) {
846                         if (!special_phrases[pnr].builtin
847                             && isTextAt(special_phrases[pnr].phrase, i)) {
848                                 features.require(special_phrases[pnr].phrase);
849                                 break;
850                         }
851                 }
852         }
853 }
854
855
856 LyXFont const Paragraph::Pimpl::realizeFont(LyXFont const & font,
857                                             BufferParams const & bparams) const
858 {
859         LyXFont tmpfont(font);
860
861         // check for environment font information
862         char par_depth = owner_->getDepth();
863         Paragraph const * par = owner_;
864         LyXTextClass const & tclass = bparams.getLyXTextClass();
865
866         while (par && par->getDepth() && !tmpfont.resolved()) {
867                 par = par->outerHook();
868                 if (par) {
869                         tmpfont.realize(par->layout()->font);
870                         par_depth = par->getDepth();
871                 }
872         }
873
874         tmpfont.realize(tclass.defaultfont());
875         return tmpfont;
876 }