Changeset 27562
- Timestamp:
- 11/16/08 17:43:49 (2 months ago)
- Files:
-
- lyx-devel/trunk/src/Buffer.cpp (modified) (1 diff)
- lyx-devel/trunk/src/Buffer.h (modified) (1 diff)
- lyx-devel/trunk/src/BufferView.cpp (modified) (1 diff)
- lyx-devel/trunk/src/CutAndPaste.cpp (modified) (2 diffs)
- lyx-devel/trunk/src/LyXFunc.cpp (modified) (5 diffs)
- lyx-devel/trunk/src/Text.cpp (modified) (6 diffs)
- lyx-devel/trunk/src/Text2.cpp (modified) (2 diffs)
- lyx-devel/trunk/src/Text3.cpp (modified) (10 diffs)
- lyx-devel/trunk/src/TextMetrics.cpp (modified) (1 diff)
- lyx-devel/trunk/src/Undo.cpp (modified) (1 diff)
- lyx-devel/trunk/src/buffer_funcs.cpp (modified) (1 diff)
- lyx-devel/trunk/src/buffer_funcs.h (modified) (1 diff)
- lyx-devel/trunk/src/frontends/qt4/GuiInfo.cpp (modified) (1 diff)
- lyx-devel/trunk/src/frontends/qt4/GuiView.cpp (modified) (3 diffs)
- lyx-devel/trunk/src/insets/Inset.cpp (modified) (1 diff)
- lyx-devel/trunk/src/insets/InsetBibitem.cpp (modified) (1 diff)
- lyx-devel/trunk/src/insets/InsetInclude.cpp (modified) (1 diff)
- lyx-devel/trunk/src/insets/InsetLabel.cpp (modified) (2 diffs)
- lyx-devel/trunk/src/lyxfind.cpp (modified) (1 diff)
- lyx-devel/trunk/src/mathed/InsetMathHull.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lyx-devel/trunk/src/Buffer.cpp
r27530 r27562 2644 2644 2645 2645 2646 // FIXME: buf should should be const because updateLabels() modifies 2647 // the contents of the paragraphs. 2648 void Buffer::updateLabels(bool childonly) const 2649 { 2650 // Use the master text class also for child documents 2651 Buffer const * const master = masterBuffer(); 2652 DocumentClass const & textclass = master->params().documentClass(); 2653 2654 // keep the buffers to be children in this set. If the call from the 2655 // master comes back we can see which of them were actually seen (i.e. 2656 // via an InsetInclude). The remaining ones in the set need still be updated. 2657 static std::set<Buffer const *> bufToUpdate; 2658 if (!childonly) { 2659 // If this is a child document start with the master 2660 if (master != this) { 2661 bufToUpdate.insert(this); 2662 master->updateLabels(false); 2663 2664 // was buf referenced from the master (i.e. not in bufToUpdate anymore)? 2665 if (bufToUpdate.find(this) == bufToUpdate.end()) 2666 return; 2667 } 2668 2669 // start over the counters in the master 2670 textclass.counters().reset(); 2671 } 2672 2673 // update will be done below for this buffer 2674 bufToUpdate.erase(this); 2675 2676 // update all caches 2677 clearReferenceCache(); 2678 inset().setBuffer(const_cast<Buffer &>(*this)); 2679 updateMacros(); 2680 2681 Buffer & cbuf = const_cast<Buffer &>(*this); 2682 2683 LASSERT(!text().paragraphs().empty(), /**/); 2684 2685 // do the real work 2686 ParIterator parit = cbuf.par_iterator_begin(); 2687 lyx::updateLabels(*this, parit); 2688 2689 if (master != this) 2690 // TocBackend update will be done later. 2691 return; 2692 2693 cbuf.tocBackend().update(); 2694 if (!childonly) 2695 cbuf.structureChanged(); 2696 } 2697 2646 2698 } // namespace lyx lyx-devel/trunk/src/Buffer.h
r27530 r27562 467 467 InsetLabel const * insetLabel(docstring const & label) const; 468 468 469 // FIXME: buf should should be const because updateLabels() modifies 470 // the contents of the paragraphs. 471 void updateLabels(bool childonly = false) const; 472 469 473 private: 470 474 /// search for macro in local (buffer) table or in children lyx-devel/trunk/src/BufferView.cpp
r27521 r27562 1859 1859 d->cursor_ = cur; 1860 1860 1861 updateLabels(buffer_);1861 buffer_.updateLabels(); 1862 1862 1863 1863 updateMetrics(); lyx-devel/trunk/src/CutAndPaste.cpp
r27425 r27562 659 659 // need a valid cursor. (Lgb) 660 660 cur.clearSelection(); 661 updateLabels(cur.buffer());661 cur.buffer().updateLabels(); 662 662 663 663 // tell tabular that a recent copy happened … … 819 819 boost::tie(ppp, endpit) = 820 820 pasteSelectionHelper(cur, parlist, docclass, errorList); 821 updateLabels(cur.buffer());821 cur.buffer().updateLabels(); 822 822 cur.clearSelection(); 823 823 text->setCursor(cur, ppp.first, ppp.second); lyx-devel/trunk/src/LyXFunc.cpp
r27521 r27562 1045 1045 Buffer * buf = lyx_view_->loadDocument(fname, false); 1046 1046 if (buf) { 1047 updateLabels(*buf);1047 buf->updateLabels(); 1048 1048 lyx_view_->setBuffer(buf); 1049 1049 buf->errors("Parse"); … … 1141 1141 } 1142 1142 1143 updateLabels(*buf);1143 buf->updateLabels(); 1144 1144 lyx_view_->setBuffer(buf); 1145 1145 view()->setCursorFromRow(row); … … 1295 1295 // when the target is in the parent or another child document. 1296 1296 child->setParent(buffer); 1297 updateLabels(*child->masterBuffer());1297 child->masterBuffer()->updateLabels(); 1298 1298 lyx_view_->setBuffer(child); 1299 1299 if (parsed) … … 1736 1736 docstring str; 1737 1737 if (buf) { 1738 updateLabels(*buf);1738 buf->updateLabels(); 1739 1739 lyx_view_->setBuffer(buf); 1740 1740 buf->errors("Parse"); … … 1810 1810 1811 1811 buffer->errors("Class Switch"); 1812 updateLabels(*buffer);1812 buffer->updateLabels(); 1813 1813 } 1814 1814 lyx-devel/trunk/src/Text.cpp
r27425 r27562 396 396 } 397 397 398 updateLabels(cur.buffer());398 cur.buffer().updateLabels(); 399 399 400 400 // A singlePar update is not enough in this case. … … 870 870 setCursorIntern(cur, begPit, begPos); 871 871 cur.updateFlags(Update::Force); 872 updateLabels(cur.buffer());872 cur.buffer().updateLabels(); 873 873 } 874 874 … … 1019 1019 mergeParagraph(bufparams, cur.text()->paragraphs(), 1020 1020 prevcur.pit()); 1021 updateLabels(cur.buffer());1021 cur.buffer().updateLabels(); 1022 1022 setCursorIntern(cur, prevcur.pit(), prevcur.pos()); 1023 1023 cur.updateFlags(Update::Force); … … 1047 1047 1048 1048 if (was_inset) 1049 updateLabels(cur.buffer());1049 cur.buffer().updateLabels(); 1050 1050 else 1051 1051 cur.checkBufferStructure(); … … 1123 1123 1124 1124 if (needsUpdate) { 1125 updateLabels(cur.buffer());1125 cur.buffer().updateLabels(); 1126 1126 setCursorIntern(cur, prevcur.pit(), prevcur.pos()); 1127 1127 } … … 1163 1163 cur.paragraph().eraseChar(cur.pos(), cur.buffer().params().trackChanges); 1164 1164 if (was_inset) 1165 updateLabels(cur.buffer());1165 cur.buffer().updateLabels(); 1166 1166 else 1167 1167 cur.checkBufferStructure(); lyx-devel/trunk/src/Text2.cpp
r27425 r27562 236 236 recUndo(cur, start, undopit - 1); 237 237 setLayout(cur.buffer(), start, end, layout); 238 updateLabels(cur.buffer());238 cur.buffer().updateLabels(); 239 239 } 240 240 … … 295 295 // this handles the counter labels, and also fixes up 296 296 // depth values for follow-on (child) paragraphs 297 updateLabels(cur.buffer());297 cur.buffer().updateLabels(); 298 298 } 299 299 lyx-devel/trunk/src/Text3.cpp
r27521 r27562 1 1 /** 2 * \file text3.cpp2 * \file Text3.cpp 3 3 * This file is part of LyX, the document processor. 4 4 * Licence details can be found in the file COPYING. … … 474 474 cur.finishUndo(); 475 475 swap(pars_[pit], pars_[pit + 1]); 476 updateLabels(cur.buffer());476 cur.buffer().updateLabels(); 477 477 needsUpdate = true; 478 478 ++cur.pit(); … … 485 485 cur.finishUndo(); 486 486 swap(pars_[pit], pars_[pit - 1]); 487 updateLabels(cur.buffer());487 cur.buffer().updateLabels(); 488 488 --cur.pit(); 489 489 needsUpdate = true; … … 511 511 512 512 // we can set the refreshing parameters now 513 updateLabels(cur.buffer());513 cur.buffer().updateLabels(); 514 514 break; 515 515 } 516 516 517 517 case LFUN_WORD_DELETE_FORWARD: 518 if (cur.selection()) {518 if (cur.selection()) 519 519 cutSelection(cur, true, false); 520 }else520 else 521 521 deleteWordForward(cur); 522 522 finishChange(cur, false); … … 1418 1418 // Some insets are numbered, others are shown in the outline pane so 1419 1419 // let's update the labels and the toc backend. 1420 updateLabels(bv->buffer());1420 bv->buffer().updateLabels(); 1421 1421 break; 1422 1422 … … 1472 1472 FuncRequest cmd_caption(LFUN_CAPTION_INSERT); 1473 1473 doInsertInset(cur, cur.text(), cmd_caption, true, false); 1474 updateLabels(bv->buffer());1474 bv->buffer().updateLabels(); 1475 1475 cur.updateFlags(Update::Force); 1476 1476 // FIXME: When leaving the Float (or Wrap) inset we should … … 1833 1833 outline(OutlineUp, cur); 1834 1834 setCursor(cur, cur.pit(), 0); 1835 updateLabels(cur.buffer());1835 cur.buffer().updateLabels(); 1836 1836 needsUpdate = true; 1837 1837 break; … … 1840 1840 outline(OutlineDown, cur); 1841 1841 setCursor(cur, cur.pit(), 0); 1842 updateLabels(cur.buffer());1842 cur.buffer().updateLabels(); 1843 1843 needsUpdate = true; 1844 1844 break; … … 1846 1846 case LFUN_OUTLINE_IN: 1847 1847 outline(OutlineIn, cur); 1848 updateLabels(cur.buffer());1848 cur.buffer().updateLabels(); 1849 1849 needsUpdate = true; 1850 1850 break; … … 1852 1852 case LFUN_OUTLINE_OUT: 1853 1853 outline(OutlineOut, cur); 1854 updateLabels(cur.buffer());1854 cur.buffer().updateLabels(); 1855 1855 needsUpdate = true; 1856 1856 break; lyx-devel/trunk/src/TextMetrics.cpp
r27425 r27562 391 391 << " Going through the buffer again and hope" 392 392 << " the context is better then."); 393 updateLabels(bv_->buffer());393 bv_->buffer().updateLabels(); 394 394 parPos = text_->macrocontextPosition(); 395 395 LASSERT(!parPos.empty(), /**/); lyx-devel/trunk/src/Undo.cpp
r27425 r27562 428 428 429 429 // Addapt the new material to current buffer. 430 updateLabels(buffer_);430 buffer_.updateLabels(); 431 431 return true; 432 432 } lyx-devel/trunk/src/buffer_funcs.cpp
r27425 r27562 472 472 } 473 473 474 475 // FIXME: buf should should be const because updateLabels() modifies476 // the contents of the paragraphs.477 void updateLabels(Buffer const & buf, bool childonly)478 {479 // Use the master text class also for child documents480 Buffer const * const master = buf.masterBuffer();481 DocumentClass const & textclass = master->params().documentClass();482 483 // keep the buffers to be children in this set. If the call from the484 // master comes back we can see which of them were actually seen (i.e.485 // via an InsetInclude). The remaining ones in the set need still be updated.486 static std::set<Buffer const *> bufToUpdate;487 if (!childonly) {488 // If this is a child document start with the master489 if (master != &buf) {490 bufToUpdate.insert(&buf);491 updateLabels(*master);492 493 // was buf referenced from the master (i.e. not in bufToUpdate anymore)?494 if (bufToUpdate.find(&buf) == bufToUpdate.end())495 return;496 }497 498 // start over the counters in the master499 textclass.counters().reset();500 }501 502 // update will be done below for buf503 bufToUpdate.erase(&buf);504 505 // update all caches506 buf.clearReferenceCache();507 buf.inset().setBuffer(const_cast<Buffer &>(buf));508 buf.updateMacros();509 510 Buffer & cbuf = const_cast<Buffer &>(buf);511 512 BOOST_ASSERT(!buf.text().paragraphs().empty());513 514 // do the real work515 ParIterator parit = par_iterator_begin(buf.inset());516 updateLabels(buf, parit);517 518 if (master != &buf)519 // TocBackend update will be done later.520 return;521 522 cbuf.tocBackend().update();523 if (!childonly)524 cbuf.structureChanged();525 }526 527 528 474 } // namespace lyx lyx-devel/trunk/src/buffer_funcs.h
r27425 r27562 48 48 int countChars(DocIterator const & from, DocIterator const & to, bool with_blanks); 49 49 50 /// updates all counters51 void updateLabels(Buffer const &, bool childonly = false);52 53 50 /// 54 51 void updateLabels(Buffer const &, ParIterator &); lyx-devel/trunk/src/frontends/qt4/GuiInfo.cpp
r27420 r27562 100 100 dispatch(FuncRequest(LFUN_INSET_MODIFY, argument)); 101 101 // FIXME: update the inset contents 102 updateLabels(bufferview()->buffer());102 bufferview()->buffer().updateLabels(false); 103 103 BufferView * bv = const_cast<BufferView *>(bufferview()); 104 104 bv->updateMetrics(); lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
r27561 r27562 1067 1067 GuiWorkArea * wa = workArea(*newBuffer); 1068 1068 if (wa == 0) { 1069 updateLabels(*newBuffer->masterBuffer());1069 newBuffer->masterBuffer()->updateLabels(); 1070 1070 wa = addWorkArea(*newBuffer); 1071 1071 } else { … … 1439 1439 Buffer * buf = loadDocument(fullname); 1440 1440 if (buf) { 1441 updateLabels(*buf); 1442 1441 buf->updateLabels(); 1443 1442 setBuffer(buf); 1444 1443 buf->errors("Parse"); … … 1489 1488 if (!buf) 1490 1489 return false; 1491 updateLabels(*buf);1490 buf->updateLabels(); 1492 1491 lv->setBuffer(buf); 1493 1492 buf->errors("Parse"); lyx-devel/trunk/src/insets/Inset.cpp
r27425 r27562 164 164 { 165 165 if (isLabeled()) 166 lyx::updateLabels(buffer());166 buffer().updateLabels(); 167 167 } 168 168 lyx-devel/trunk/src/insets/InsetBibitem.cpp
r27481 r27562 91 91 setParam("key", key); 92 92 93 lyx::updateLabels(buffer());93 buffer().updateLabels(); 94 94 } 95 95 lyx-devel/trunk/src/insets/InsetInclude.cpp
r27425 r27562 912 912 Buffer const * const childbuffer = getChildBuffer(buffer(), params()); 913 913 if (childbuffer) { 914 lyx::updateLabels(*childbuffer,true);914 childbuffer->updateLabels(true); 915 915 return; 916 916 } lyx-devel/trunk/src/insets/InsetLabel.cpp
r27425 r27562 82 82 83 83 // We need an update of the Buffer reference cache. This is achieved by 84 // updateLabel ().85 lyx::updateLabels(buffer());84 // updateLabels(). 85 buffer().updateLabels(); 86 86 } 87 87 … … 90 90 { 91 91 static ParamInfo param_info_; 92 if (param_info_.empty()) {92 if (param_info_.empty()) 93 93 param_info_.add("name", ParamInfo::LATEX_REQUIRED); 94 }95 94 return param_info_; 96 95 } lyx-devel/trunk/src/lyxfind.cpp
r27543 r27562 183 183 } 184 184 185 updateLabels(buf);185 buf.updateLabels(); 186 186 bv->putSelectionAt(doc_iterator_begin(buf.inset()), 0, false); 187 187 if (num) lyx-devel/trunk/src/mathed/InsetMathHull.cpp
r27553 r27562 512 512 // We need an update of the Buffer reference cache. 513 513 // This is achieved by updateLabels(). 514 lyx::updateLabels(buffer());515 } else 514 buffer().updateLabels(); 515 } else { 516 516 label_[row]->updateCommand(label); 517 } 517 518 return; 518 519 } … … 533 534 // We need an update of the Buffer reference cache. 534 535 // This is achieved by updateLabels(). 535 lyx::updateLabels(buffer());536 buffer().updateLabels(); 536 537 } 537 538 }
