- fl_hide_object(fd_form_toc->browser_toc);
- /* get the table of contents */
- LyXParagraph * par = current_view->buffer()->paragraph;
- char labeltype;
- char * line = new char[200];
- int pos = 0;
- unsigned char c;
- int topline = 0;
-
- if (stapar == par)
- topline = fl_get_browser_topline(fd_form_toc->browser_toc);
- stapar = par;
-
- while (par) {
- labeltype = textclasslist.Style(current_view->buffer()->params.textclass,
- par->GetLayout()).labeltype;
-
- if (labeltype >= LABEL_COUNTER_CHAPTER
- && labeltype <= LABEL_COUNTER_CHAPTER +
- current_view->buffer()->params.tocdepth) {
- /* insert this into the table of contents */
- /* first indent a little bit */
-
- for (pos = 0;
- pos < (labeltype -
- textclasslist.TextClass(current_view->buffer()->
- params.textclass).maxcounter()) * 4 + 2;
- ++pos)
- line[pos] = ' ';
-
- // Then the labestring
- if (!par->labelstring.empty()) {
- string::size_type i = 0;
- while (pos < 199 && i < par->labelstring.length()) {
- line[pos] = par->labelstring[i];
- ++i;
- ++pos;
- }
- }
-
- line[pos] = ' ';
- ++pos;
-
- /* now the contents */
- LyXParagraph::size_type i = 0;
- while (pos < 199 && i < par->size()) {
- c = par->GetChar(i);
- if (isprint(c) || c >= 128) {
- line[pos] = c;
- ++pos;
- }
- ++i;
- }
- line[pos] = '\0';
- fl_add_browser_line(fd_form_toc->browser_toc, line);
-
- /* make a toclist entry */
- if (!tmptoclist){
- tmptoclist = new TocList;
- toclist = tmptoclist;
- } else {
- tmptoclist->next = new TocList;
- tmptoclist = tmptoclist->next;
- }
-
- tmptoclist->next = 0;
- int a = 0;
- for (a = 0; a < 6; ++a) {
- tmptoclist->counter[a] = par->GetFirstCounter(a);
- }
- tmptoclist->appendix = par->appendix;
+
+ vector<vector<Buffer::TocItem> > tmp =
+ current_view->buffer()->getTocList();
+ int type = fl_get_choice(fd_form_toc->toctype)-1;
+ //if (toclist == tmp[type])
+ // return;
+ if (toclist.size() == tmp[type].size()) {
+ // Check if all elements are the same.
+ unsigned int i = 0;
+ for (; i < toclist.size(); ++i) {
+ if (toclist[i] != tmp[type][i])
+ break;