]> git.lyx.org Git - lyx.git/blob - src/buffer_funcs.cpp
fd0a4c32e0aa357d775e81920a0d518e30b41f11
[lyx.git] / src / buffer_funcs.cpp
1 /**
2  * \file buffer_funcs.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Alfredo Braunstein
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  */
12
13 #include <config.h>
14
15 #include "buffer_funcs.h"
16 #include "Buffer.h"
17 #include "BufferList.h"
18 #include "BufferParams.h"
19 #include "DocIterator.h"
20 #include "Counters.h"
21 #include "ErrorList.h"
22 #include "Floating.h"
23 #include "FloatList.h"
24 #include "gettext.h"
25 #include "Language.h"
26 #include "LaTeX.h"
27 #include "TextClass.h"
28 #include "Paragraph.h"
29 #include "paragraph_funcs.h"
30 #include "ParagraphList.h"
31 #include "ParagraphParameters.h"
32 #include "ParIterator.h"
33 #include "LyXVC.h"
34 #include "TexRow.h"
35 #include "TocBackend.h"
36 #include "VCBackend.h"
37
38 #include "frontends/alert.h"
39
40 #include "insets/InsetBibitem.h"
41 #include "insets/InsetCaption.h"
42 #include "insets/InsetInclude.h"
43 #include "insets/InsetTabular.h"
44
45 #include "support/filetools.h"
46 #include "support/fs_extras.h"
47 #include "support/lyxlib.h"
48
49 #include <boost/bind.hpp>
50 #include <boost/filesystem/operations.hpp>
51
52
53 namespace lyx {
54
55 using namespace std;
56
57 using support::bformat;
58 using support::FileName;
59 using support::libFileSearch;
60 using support::makeAbsPath;
61 using support::makeDisplayPath;
62 using support::onlyFilename;
63 using support::onlyPath;
64 using support::unlink;
65
66 using std::min;
67 using std::string;
68
69 namespace Alert = frontend::Alert;
70 namespace fs = boost::filesystem;
71
72 namespace {
73
74 bool readFile(Buffer * const b, FileName const & s)
75 {
76         BOOST_ASSERT(b);
77
78         // File information about normal file
79         if (!fs::exists(s.toFilesystemEncoding())) {
80                 docstring const file = makeDisplayPath(s.absFilename(), 50);
81                 docstring text = bformat(_("The specified document\n%1$s"
82                                                      "\ncould not be read."), file);
83                 Alert::error(_("Could not read document"), text);
84                 return false;
85         }
86
87         // Check if emergency save file exists and is newer.
88         FileName const e(s.absFilename() + ".emergency");
89
90         if (fs::exists(e.toFilesystemEncoding()) &&
91             fs::exists(s.toFilesystemEncoding()) &&
92             fs::last_write_time(e.toFilesystemEncoding()) > fs::last_write_time(s.toFilesystemEncoding()))
93         {
94                 docstring const file = makeDisplayPath(s.absFilename(), 20);
95                 docstring const text =
96                         bformat(_("An emergency save of the document "
97                                   "%1$s exists.\n\n"
98                                                "Recover emergency save?"), file);
99                 switch (Alert::prompt(_("Load emergency save?"), text, 0, 2,
100                                       _("&Recover"),  _("&Load Original"),
101                                       _("&Cancel")))
102                 {
103                 case 0:
104                         // the file is not saved if we load the emergency file.
105                         b->markDirty();
106                         return b->readFile(e);
107                 case 1:
108                         break;
109                 default:
110                         return false;
111                 }
112         }
113
114         // Now check if autosave file is newer.
115         FileName const a(onlyPath(s.absFilename()) + '#' + onlyFilename(s.absFilename()) + '#');
116
117         if (fs::exists(a.toFilesystemEncoding()) &&
118             fs::exists(s.toFilesystemEncoding()) &&
119             fs::last_write_time(a.toFilesystemEncoding()) > fs::last_write_time(s.toFilesystemEncoding()))
120         {
121                 docstring const file = makeDisplayPath(s.absFilename(), 20);
122                 docstring const text =
123                         bformat(_("The backup of the document "
124                                   "%1$s is newer.\n\nLoad the "
125                                                "backup instead?"), file);
126                 switch (Alert::prompt(_("Load backup?"), text, 0, 2,
127                                       _("&Load backup"), _("Load &original"),
128                                       _("&Cancel") ))
129                 {
130                 case 0:
131                         // the file is not saved if we load the autosave file.
132                         b->markDirty();
133                         return b->readFile(a);
134                 case 1:
135                         // Here we delete the autosave
136                         unlink(a);
137                         break;
138                 default:
139                         return false;
140                 }
141         }
142         return b->readFile(s);
143 }
144
145
146 } // namespace anon
147
148
149
150 bool loadLyXFile(Buffer * b, FileName const & s)
151 {
152         BOOST_ASSERT(b);
153
154         if (fs::is_readable(s.toFilesystemEncoding())) {
155                 if (readFile(b, s)) {
156                         b->lyxvc().file_found_hook(s);
157                         if (!fs::is_writable(s.toFilesystemEncoding()))
158                                 b->setReadonly(true);
159                         return true;
160                 }
161         } else {
162                 docstring const file = makeDisplayPath(s.absFilename(), 20);
163                 // Here we probably should run
164                 if (LyXVC::file_not_found_hook(s)) {
165                         docstring const text =
166                                 bformat(_("Do you want to retrieve the document"
167                                                        " %1$s from version control?"), file);
168                         int const ret = Alert::prompt(_("Retrieve from version control?"),
169                                 text, 0, 1, _("&Retrieve"), _("&Cancel"));
170
171                         if (ret == 0) {
172                                 // How can we know _how_ to do the checkout?
173                                 // With the current VC support it has to be,
174                                 // a RCS file since CVS do not have special ,v files.
175                                 RCS::retrieve(s);
176                                 return loadLyXFile(b, s);
177                         }
178                 }
179         }
180         return false;
181 }
182
183
184 Buffer * checkAndLoadLyXFile(FileName const & filename)
185 {
186         // File already open?
187         if (theBufferList().exists(filename.absFilename())) {
188                 docstring const file = makeDisplayPath(filename.absFilename(), 20);
189                 docstring text = bformat(_("The document %1$s is already "
190                                                      "loaded.\n\nDo you want to revert "
191                                                      "to the saved version?"), file);
192                 if (Alert::prompt(_("Revert to saved document?"),
193                                 text, 0, 1,  _("&Revert"), _("&Switch to document")))
194                         return theBufferList().getBuffer(filename.absFilename());
195
196                 // FIXME: should be LFUN_REVERT
197                 if (theBufferList().close(theBufferList().getBuffer(filename.absFilename()), false))
198                         // Load it again.
199                         return checkAndLoadLyXFile(filename);
200                 else
201                         // The file could not be closed.
202                         return 0;
203         }
204
205         if (isFileReadable(filename)) {
206                 Buffer * b = theBufferList().newBuffer(filename.absFilename());
207                 if (!lyx::loadLyXFile(b, filename)) {
208                         theBufferList().release(b);
209                         return 0;
210                 }
211                 return b;
212         }
213
214         docstring text = bformat(_("The document %1$s does not yet "
215                 "exist.\n\nDo you want to create a new document?"),
216                 from_utf8(filename.absFilename()));
217         if (!Alert::prompt(_("Create new document?"),
218                         text, 0, 1, _("&Create"), _("Cancel")))
219                 return newFile(filename.absFilename(), string(), true);
220
221         return 0;
222 }
223
224 // FIXME newFile() should probably be a member method of Application...
225 Buffer * newFile(string const & filename, string const & templatename,
226                  bool const isNamed)
227 {
228         // get a free buffer
229         Buffer * b = theBufferList().newBuffer(filename);
230         BOOST_ASSERT(b);
231
232         FileName tname;
233         // use defaults.lyx as a default template if it exists.
234         if (templatename.empty())
235                 tname = libFileSearch("templates", "defaults.lyx");
236         else
237                 tname = makeAbsPath(templatename);
238
239         if (!tname.empty()) {
240                 if (!b->readFile(tname)) {
241                         docstring const file = makeDisplayPath(tname.absFilename(), 50);
242                         docstring const text  = bformat(
243                                 _("The specified document template\n%1$s\ncould not be read."),
244                                 file);
245                         Alert::error(_("Could not read template"), text);
246                         theBufferList().release(b);
247                         return 0;
248                 }
249         }
250
251         if (!isNamed) {
252                 b->setUnnamed();
253                 b->setFileName(filename);
254         }
255
256         b->setReadonly(false);
257         b->fully_loaded(true);
258
259         return b;
260 }
261
262
263 void bufferErrors(Buffer const & buf, TeXErrors const & terr,
264                                   ErrorList & errorList)
265 {
266         TeXErrors::Errors::const_iterator cit = terr.begin();
267         TeXErrors::Errors::const_iterator end = terr.end();
268
269         for (; cit != end; ++cit) {
270                 int id_start = -1;
271                 int pos_start = -1;
272                 int errorrow = cit->error_in_line;
273                 bool found = buf.texrow().getIdFromRow(errorrow, id_start,
274                                                        pos_start);
275                 int id_end = -1;
276                 int pos_end = -1;
277                 do {
278                         ++errorrow;
279                         found = buf.texrow().getIdFromRow(errorrow, id_end,
280                                                           pos_end);
281                 } while (found && id_start == id_end && pos_start == pos_end);
282
283                 errorList.push_back(ErrorItem(cit->error_desc,
284                         cit->error_text, id_start, pos_start, pos_end));
285         }
286 }
287
288
289 string const bufferFormat(Buffer const & buffer)
290 {
291         if (buffer.isDocBook())
292                 return "docbook";
293         else if (buffer.isLiterate())
294                 return "literate";
295         else
296                 return "latex";
297 }
298
299
300 int countWords(DocIterator const & from, DocIterator const & to)
301 {
302         int count = 0;
303         bool inword = false;
304         for (DocIterator dit = from ; dit != to ; dit.forwardPos()) {
305                 // Copied and adapted from isLetter() in ControlSpellChecker
306                 if (dit.inTexted()
307                     && dit.pos() != dit.lastpos()
308                     && dit.paragraph().isLetter(dit.pos())
309                     && !dit.paragraph().isDeleted(dit.pos())) {
310                         if (!inword) {
311                                 ++count;
312                                 inword = true;
313                         }
314                 } else if (inword)
315                         inword = false;
316         }
317
318         return count;
319 }
320
321
322 namespace {
323
324 depth_type getDepth(DocIterator const & it)
325 {
326         depth_type depth = 0;
327         for (size_t i = 0 ; i < it.depth() ; ++i)
328                 if (!it[i].inset().inMathed())
329                         depth += it[i].paragraph().getDepth() + 1;
330         // remove 1 since the outer inset does not count
331         return depth - 1;
332 }
333
334 depth_type getItemDepth(ParIterator const & it)
335 {
336         Paragraph const & par = *it;
337         LYX_LABEL_TYPES const labeltype = par.layout()->labeltype;
338
339         if (labeltype != LABEL_ENUMERATE && labeltype != LABEL_ITEMIZE)
340                 return 0;
341
342         // this will hold the lowest depth encountered up to now.
343         depth_type min_depth = getDepth(it);
344         ParIterator prev_it = it;
345         while (true) {
346                 if (prev_it.pit())
347                         --prev_it.top().pit();
348                 else {
349                         // start of nested inset: go to outer par
350                         prev_it.pop_back();
351                         if (prev_it.empty()) {
352                                 // start of document: nothing to do
353                                 return 0;
354                         }
355                 }
356
357                 // We search for the first paragraph with same label
358                 // that is not more deeply nested.
359                 Paragraph & prev_par = *prev_it;
360                 depth_type const prev_depth = getDepth(prev_it);
361                 if (labeltype == prev_par.layout()->labeltype) {
362                         if (prev_depth < min_depth) {
363                                 return prev_par.itemdepth + 1;
364                         }
365                         else if (prev_depth == min_depth) {
366                                 return prev_par.itemdepth;
367                         }
368                 }
369                 min_depth = std::min(min_depth, prev_depth);
370                 // small optimization: if we are at depth 0, we won't
371                 // find anything else
372                 if (prev_depth == 0) {
373                         return 0;
374                 }
375         }
376 }
377
378
379 bool needEnumCounterReset(ParIterator const & it)
380 {
381         Paragraph const & par = *it;
382         BOOST_ASSERT(par.layout()->labeltype == LABEL_ENUMERATE);
383         depth_type const cur_depth = par.getDepth();
384         ParIterator prev_it = it;
385         while (prev_it.pit()) {
386                 --prev_it.top().pit();
387                 Paragraph const & prev_par = *prev_it;
388                 if (prev_par.getDepth() <= cur_depth)
389                         return  prev_par.layout()->labeltype != LABEL_ENUMERATE;
390         }
391         // start of nested inset: reset
392         return true;
393 }
394
395
396 void setCaptionLabels(Inset & inset, string const & type,
397                 docstring const label, Counters & counters)
398 {
399         Text * text = inset.getText(0);
400         if (!text)
401                 return;
402
403         ParagraphList & pars = text->paragraphs();
404         if (pars.empty())
405                 return;
406
407         docstring const counter = from_ascii(type);
408
409         ParagraphList::iterator p = pars.begin();
410         for (; p != pars.end(); ++p) {
411                 InsetList::iterator it2 = p->insetlist.begin();
412                 InsetList::iterator end2 = p->insetlist.end();
413                 // Any caption within this float should have the same
414                 // label prefix but different numbers.
415                 for (; it2 != end2; ++it2) {
416                         Inset & icap = *it2->inset;
417                         // Look deeper just in case.
418                         setCaptionLabels(icap, type, label, counters);
419                         if (icap.lyxCode() == Inset::CAPTION_CODE) {
420                                 // We found a caption!
421                                 counters.step(counter);
422                                 int number = counters.value(counter);
423                                 InsetCaption & ic = static_cast<InsetCaption &>(icap);
424                                 ic.setType(type);
425                                 ic.setCount(number);
426                                 ic.setCustomLabel(label);
427                         }
428                 }
429         }
430 }
431
432
433 void setCaptions(Paragraph & par, TextClass const & textclass)
434 {
435         if (par.insetlist.empty())
436                 return;
437
438         Counters & counters = textclass.counters();
439
440         InsetList::iterator it = par.insetlist.begin();
441         InsetList::iterator end = par.insetlist.end();
442         for (; it != end; ++it) {
443                 Inset & inset = *it->inset;
444                 if (inset.lyxCode() == Inset::FLOAT_CODE
445                         || inset.lyxCode() == Inset::WRAP_CODE) {
446                         docstring const name = inset.name();
447                         if (name.empty())
448                                 continue;
449
450                         Floating const & fl = textclass.floats().getType(to_ascii(name));
451                         // FIXME UNICODE
452                         string const & type = fl.type();
453                         docstring const label = from_utf8(fl.name());
454                         setCaptionLabels(inset, type, label, counters);
455                 }
456                 else if (inset.lyxCode() == Inset::TABULAR_CODE
457                         &&  static_cast<InsetTabular &>(inset).tabular.isLongTabular()) {
458                         // FIXME: are "table" and "Table" the correct type and label?
459                         setCaptionLabels(inset, "table", from_ascii("Table"), counters);
460                 }
461                 else if (inset.lyxCode() == Inset::LISTINGS_CODE)
462                         setCaptionLabels(inset, "listing", from_ascii("Listing"), counters);
463                 else if (inset.lyxCode() == Inset::INCLUDE_CODE)
464                         // if this include inset contains lstinputlisting, and has a caption
465                         // it will increase the 'listing' counter by one
466                         static_cast<InsetInclude &>(inset).updateCounter(counters);
467         }
468 }
469
470 // set the label of a paragraph. This includes the counters.
471 void setLabel(Buffer const & buf, ParIterator & it, TextClass const & textclass)
472 {
473         Paragraph & par = *it;
474         Layout_ptr const & layout = par.layout();
475         Counters & counters = textclass.counters();
476
477         if (it.pit() == 0) {
478                 par.params().appendix(par.params().startOfAppendix());
479         } else {
480                 par.params().appendix(it.plist()[it.pit() - 1].params().appendix());
481                 if (!par.params().appendix() &&
482                     par.params().startOfAppendix()) {
483                         par.params().appendix(true);
484                         textclass.counters().reset();
485                 }
486         }
487
488         // Compute the item depth of the paragraph
489         par.itemdepth = getItemDepth(it);
490
491         if (layout->margintype == MARGIN_MANUAL) {
492                 if (par.params().labelWidthString().empty())
493                         par.params().labelWidthString(par.translateIfPossible(layout->labelstring(), buf.params()));
494         } else {
495                 par.params().labelWidthString(docstring());
496         }
497
498         // Optimisation: setLabel() can be called for each for each
499         // paragraph of the document. So we make the string static to
500         // avoid the repeated instanciation.
501         static docstring itemlabel;
502
503         // is it a layout that has an automatic label?
504         if (layout->labeltype == LABEL_COUNTER) {
505                 if (layout->toclevel <= buf.params().secnumdepth
506                     && (layout->latextype != LATEX_ENVIRONMENT
507                         || isFirstInSequence(it.pit(), it.plist()))) {
508                         counters.step(layout->counter);
509                         par.params().labelString(
510                                 par.expandLabel(layout, buf.params()));
511                 } else
512                         par.params().labelString(docstring());
513
514         } else if (layout->labeltype == LABEL_ITEMIZE) {
515                 // At some point of time we should do something more
516                 // clever here, like:
517                 //   par.params().labelString(
518                 //    buf.params().user_defined_bullet(par.itemdepth).getText());
519                 // for now, use a simple hardcoded label
520                 switch (par.itemdepth) {
521                 case 0:
522                         itemlabel = char_type(0x2022);
523                         break;
524                 case 1:
525                         itemlabel = char_type(0x2013);
526                         break;
527                 case 2:
528                         itemlabel = char_type(0x2217);
529                         break;
530                 case 3:
531                         itemlabel = char_type(0x2219); // or 0x00b7
532                         break;
533                 }
534                 par.params().labelString(itemlabel);
535
536         } else if (layout->labeltype == LABEL_ENUMERATE) {
537                 // FIXME
538                 // Yes I know this is a really, really! bad solution
539                 // (Lgb)
540                 docstring enumcounter = from_ascii("enum");
541
542                 switch (par.itemdepth) {
543                 case 2:
544                         enumcounter += 'i';
545                 case 1:
546                         enumcounter += 'i';
547                 case 0:
548                         enumcounter += 'i';
549                         break;
550                 case 3:
551                         enumcounter += "iv";
552                         break;
553                 default:
554                         // not a valid enumdepth...
555                         break;
556                 }
557
558                 // Maybe we have to reset the enumeration counter.
559                 if (needEnumCounterReset(it))
560                         counters.reset(enumcounter);
561
562                 counters.step(enumcounter);
563
564                 string format;
565
566                 switch (par.itemdepth) {
567                 case 0:
568                         format = N_("\\arabic{enumi}.");
569                         break;
570                 case 1:
571                         format = N_("(\\alph{enumii})");
572                         break;
573                 case 2:
574                         format = N_("\\roman{enumiii}.");
575                         break;
576                 case 3:
577                         format = N_("\\Alph{enumiv}.");
578                         break;
579                 default:
580                         // not a valid enumdepth...
581                         break;
582                 }
583
584                 par.params().labelString(counters.counterLabel(
585                         par.translateIfPossible(from_ascii(format), buf.params())));
586
587         } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
588                 counters.step(from_ascii("bibitem"));
589                 int number = counters.value(from_ascii("bibitem"));
590                 if (par.bibitem())
591                         par.bibitem()->setCounter(number);
592
593                 par.params().labelString(
594                         par.translateIfPossible(layout->labelstring(), buf.params()));
595                 // In biblio shouldn't be following counters but...
596         } else if (layout->labeltype == LABEL_SENSITIVE) {
597                 // Search for the first float or wrap inset in the iterator
598                 size_t i = it.depth();
599                 Inset * in = 0;
600                 while (i > 0) {
601                         --i;
602                         Inset::Code const code = it[i].inset().lyxCode();
603                         if (code == Inset::FLOAT_CODE ||
604                             code == Inset::WRAP_CODE) {
605                                 in = &it[i].inset();
606                                 break;
607                         }
608                 }
609                 // FIXME Can Inset::name() return an empty name for wide or
610                 // float insets? If not we can put the definition of type
611                 // inside the if (in) clause and use that instead of
612                 // if (!type.empty()).
613                 docstring type;
614                 if (in)
615                         type = in->name();
616
617                 if (!type.empty()) {
618                         Floating const & fl = textclass.floats().getType(to_ascii(type));
619                         // FIXME UNICODE
620                         counters.step(from_ascii(fl.type()));
621
622                         // Doesn't work... yet.
623                         par.params().labelString(par.translateIfPossible(
624                                 bformat(from_ascii("%1$s #:"), from_utf8(fl.name())),
625                                 buf.params()));
626                 } else {
627                         // par->SetLayout(0);
628                         par.params().labelString(par.translateIfPossible(
629                                 layout->labelstring(), buf.params()));
630                 }
631
632         } else if (layout->labeltype == LABEL_NO_LABEL)
633                 par.params().labelString(docstring());
634         else
635                 par.params().labelString(
636                         par.translateIfPossible(layout->labelstring(), buf.params()));
637 }
638
639 } // anon namespace
640
641
642 bool updateCurrentLabel(Buffer const & buf,
643         ParIterator & it)
644 {
645     if (it == par_iterator_end(buf.inset()))
646         return false;
647
648 //      if (it.lastpit == 0 && Text::isMainText(buf))
649 //              return false;
650
651         switch (it->layout()->labeltype) {
652
653         case LABEL_NO_LABEL:
654         case LABEL_MANUAL:
655         case LABEL_BIBLIO:
656         case LABEL_TOP_ENVIRONMENT:
657         case LABEL_CENTERED_TOP_ENVIRONMENT:
658         case LABEL_STATIC:
659         case LABEL_ITEMIZE:
660                 setLabel(buf, it, buf.params().getTextClass());
661                 return true;
662
663         case LABEL_SENSITIVE:
664         case LABEL_COUNTER:
665         // do more things with enumerate later
666         case LABEL_ENUMERATE:
667                 return false;
668         }
669
670         // This is dead code which get rid of a warning:
671         return true;
672 }
673
674
675 void updateLabels(Buffer const & buf,
676         ParIterator & from, ParIterator & to, bool childonly)
677 {
678         for (ParIterator it = from; it != to; ++it) {
679                 if (it.pit() > it.lastpit())
680                         return;
681                 if (!updateCurrentLabel (buf, it)) {
682                         updateLabels(buf, childonly);
683                         return;
684                 }
685         }
686 }
687
688
689 void updateLabels(Buffer const & buf, ParIterator & iter, bool childonly)
690 {
691         if (updateCurrentLabel(buf, iter))
692                 return;
693
694         updateLabels(buf, childonly);
695 }
696
697
698 void updateLabels(Buffer const & buf, bool childonly)
699 {
700         // Use the master text class also for child documents
701         TextClass const & textclass = buf.params().getTextClass();
702
703         if (!childonly) {
704                 // If this is a child document start with the master
705                 Buffer const * const master = buf.getMasterBuffer();
706                 if (master != &buf) {
707                         updateLabels(*master);
708                         return;
709                 }
710
711                 // start over the counters
712                 textclass.counters().reset();
713         }
714
715         ParIterator const end = par_iterator_end(buf.inset());
716
717         for (ParIterator it = par_iterator_begin(buf.inset()); it != end; ++it) {
718                 // reduce depth if necessary
719                 if (it.pit()) {
720                         Paragraph const & prevpar = it.plist()[it.pit() - 1];
721                         it->params().depth(min(it->params().depth(),
722                                                prevpar.getMaxDepthAfter()));
723                 } else
724                         it->params().depth(0);
725
726                 // set the counter for this paragraph
727                 setLabel(buf, it, textclass);
728
729                 // It is better to set the captions after setLabel because
730                 // the caption number might need the section number in the
731                 // future.
732                 setCaptions(*it, textclass);
733
734                 // Now included docs
735                 InsetList::const_iterator iit = it->insetlist.begin();
736                 InsetList::const_iterator end = it->insetlist.end();
737                 for (; iit != end; ++iit) {
738                         if (iit->inset->lyxCode() == Inset::INCLUDE_CODE)
739                                 static_cast<InsetInclude const *>(iit->inset)
740                                         ->updateLabels(buf);
741                 }
742         }
743
744         Buffer & cbuf = const_cast<Buffer &>(buf);
745         cbuf.tocBackend().update();
746         if (!childonly)
747                 cbuf.structureChanged();
748 }
749
750
751 void checkBufferStructure(Buffer & buffer, ParIterator const & par_it)
752 {
753         if (par_it->layout()->toclevel != Layout::NOT_IN_TOC) {
754                 Buffer * master = buffer.getMasterBuffer();
755                 master->tocBackend().updateItem(par_it);
756                 master->structureChanged();
757         }
758 }
759
760 } // namespace lyx