Changeset 27562

Show
Ignore:
Timestamp:
11/16/08 17:43:49 (2 months ago)
Author:
poenitz
Message:

move updateLables to buffer

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lyx-devel/trunk/src/Buffer.cpp

    r27530 r27562  
    26442644 
    26452645 
     2646// FIXME: buf should should be const because updateLabels() modifies 
     2647// the contents of the paragraphs. 
     2648void 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 
    26462698} // namespace lyx 
  • lyx-devel/trunk/src/Buffer.h

    r27530 r27562  
    467467        InsetLabel const * insetLabel(docstring const & label) const; 
    468468 
     469        // FIXME: buf should should be const because updateLabels() modifies 
     470        // the contents of the paragraphs. 
     471        void updateLabels(bool childonly = false) const; 
     472 
    469473private: 
    470474        /// search for macro in local (buffer) table or in children 
  • lyx-devel/trunk/src/BufferView.cpp

    r27521 r27562  
    18591859        d->cursor_ = cur; 
    18601860 
    1861         updateLabels(buffer_); 
     1861        buffer_.updateLabels(); 
    18621862 
    18631863        updateMetrics(); 
  • lyx-devel/trunk/src/CutAndPaste.cpp

    r27425 r27562  
    659659                // need a valid cursor. (Lgb) 
    660660                cur.clearSelection(); 
    661                 updateLabels(cur.buffer()); 
     661                cur.buffer().updateLabels(); 
    662662 
    663663                // tell tabular that a recent copy happened 
     
    819819                boost::tie(ppp, endpit) = 
    820820                        pasteSelectionHelper(cur, parlist, docclass, errorList); 
    821                 updateLabels(cur.buffer()); 
     821                cur.buffer().updateLabels(); 
    822822                cur.clearSelection(); 
    823823                text->setCursor(cur, ppp.first, ppp.second); 
  • lyx-devel/trunk/src/LyXFunc.cpp

    r27521 r27562  
    10451045                        Buffer * buf = lyx_view_->loadDocument(fname, false); 
    10461046                        if (buf) { 
    1047                                 updateLabels(*buf); 
     1047                                buf->updateLabels(); 
    10481048                                lyx_view_->setBuffer(buf); 
    10491049                                buf->errors("Parse"); 
     
    11411141                        } 
    11421142 
    1143                         updateLabels(*buf); 
     1143                        buf->updateLabels(); 
    11441144                        lyx_view_->setBuffer(buf); 
    11451145                        view()->setCursorFromRow(row); 
     
    12951295                                // when the target is in the parent or another child document. 
    12961296                                child->setParent(buffer); 
    1297                                 updateLabels(*child->masterBuffer()); 
     1297                                child->masterBuffer()->updateLabels(); 
    12981298                                lyx_view_->setBuffer(child); 
    12991299                                if (parsed) 
     
    17361736        docstring str; 
    17371737        if (buf) { 
    1738                 updateLabels(*buf); 
     1738                buf->updateLabels(); 
    17391739                lyx_view_->setBuffer(buf); 
    17401740                buf->errors("Parse"); 
     
    18101810 
    18111811        buffer->errors("Class Switch"); 
    1812         updateLabels(*buffer); 
     1812        buffer->updateLabels(); 
    18131813} 
    18141814 
  • lyx-devel/trunk/src/Text.cpp

    r27425 r27562  
    396396        } 
    397397 
    398         updateLabels(cur.buffer()); 
     398        cur.buffer().updateLabels(); 
    399399 
    400400        // A singlePar update is not enough in this case. 
     
    870870        setCursorIntern(cur, begPit, begPos); 
    871871        cur.updateFlags(Update::Force); 
    872         updateLabels(cur.buffer()); 
     872        cur.buffer().updateLabels(); 
    873873} 
    874874 
     
    10191019                mergeParagraph(bufparams, cur.text()->paragraphs(), 
    10201020                                                        prevcur.pit()); 
    1021                 updateLabels(cur.buffer()); 
     1021                cur.buffer().updateLabels(); 
    10221022                setCursorIntern(cur, prevcur.pit(), prevcur.pos()); 
    10231023                cur.updateFlags(Update::Force); 
     
    10471047 
    10481048                if (was_inset) 
    1049                         updateLabels(cur.buffer()); 
     1049                        cur.buffer().updateLabels(); 
    10501050                else 
    10511051                        cur.checkBufferStructure(); 
     
    11231123 
    11241124        if (needsUpdate) { 
    1125                 updateLabels(cur.buffer()); 
     1125                cur.buffer().updateLabels(); 
    11261126                setCursorIntern(cur, prevcur.pit(), prevcur.pos()); 
    11271127        } 
     
    11631163                cur.paragraph().eraseChar(cur.pos(), cur.buffer().params().trackChanges); 
    11641164                if (was_inset) 
    1165                         updateLabels(cur.buffer()); 
     1165                        cur.buffer().updateLabels(); 
    11661166                else 
    11671167                        cur.checkBufferStructure(); 
  • lyx-devel/trunk/src/Text2.cpp

    r27425 r27562  
    236236        recUndo(cur, start, undopit - 1); 
    237237        setLayout(cur.buffer(), start, end, layout); 
    238         updateLabels(cur.buffer()); 
     238        cur.buffer().updateLabels(); 
    239239} 
    240240 
     
    295295        // this handles the counter labels, and also fixes up 
    296296        // depth values for follow-on (child) paragraphs 
    297         updateLabels(cur.buffer()); 
     297        cur.buffer().updateLabels(); 
    298298} 
    299299 
  • lyx-devel/trunk/src/Text3.cpp

    r27521 r27562  
    11/** 
    2  * \file text3.cpp 
     2 * \file Text3.cpp 
    33 * This file is part of LyX, the document processor. 
    44 * Licence details can be found in the file COPYING. 
     
    474474                cur.finishUndo(); 
    475475                swap(pars_[pit], pars_[pit + 1]); 
    476                 updateLabels(cur.buffer()); 
     476                cur.buffer().updateLabels(); 
    477477                needsUpdate = true; 
    478478                ++cur.pit(); 
     
    485485                cur.finishUndo(); 
    486486                swap(pars_[pit], pars_[pit - 1]); 
    487                 updateLabels(cur.buffer()); 
     487                cur.buffer().updateLabels(); 
    488488                --cur.pit(); 
    489489                needsUpdate = true; 
     
    511511 
    512512                // we can set the refreshing parameters now 
    513                 updateLabels(cur.buffer()); 
     513                cur.buffer().updateLabels(); 
    514514                break; 
    515515        } 
    516516 
    517517        case LFUN_WORD_DELETE_FORWARD: 
    518                 if (cur.selection()) { 
     518                if (cur.selection()) 
    519519                        cutSelection(cur, true, false); 
    520                 } else 
     520                else 
    521521                        deleteWordForward(cur); 
    522522                finishChange(cur, false); 
     
    14181418                // Some insets are numbered, others are shown in the outline pane so 
    14191419                // let's update the labels and the toc backend. 
    1420                 updateLabels(bv->buffer()); 
     1420                bv->buffer().updateLabels(); 
    14211421                break; 
    14221422 
     
    14721472                FuncRequest cmd_caption(LFUN_CAPTION_INSERT); 
    14731473                doInsertInset(cur, cur.text(), cmd_caption, true, false); 
    1474                 updateLabels(bv->buffer()); 
     1474                bv->buffer().updateLabels(); 
    14751475                cur.updateFlags(Update::Force); 
    14761476                // FIXME: When leaving the Float (or Wrap) inset we should 
     
    18331833                outline(OutlineUp, cur); 
    18341834                setCursor(cur, cur.pit(), 0); 
    1835                 updateLabels(cur.buffer()); 
     1835                cur.buffer().updateLabels(); 
    18361836                needsUpdate = true; 
    18371837                break; 
     
    18401840                outline(OutlineDown, cur); 
    18411841                setCursor(cur, cur.pit(), 0); 
    1842                 updateLabels(cur.buffer()); 
     1842                cur.buffer().updateLabels(); 
    18431843                needsUpdate = true; 
    18441844                break; 
     
    18461846        case LFUN_OUTLINE_IN: 
    18471847                outline(OutlineIn, cur); 
    1848                 updateLabels(cur.buffer()); 
     1848                cur.buffer().updateLabels(); 
    18491849                needsUpdate = true; 
    18501850                break; 
     
    18521852        case LFUN_OUTLINE_OUT: 
    18531853                outline(OutlineOut, cur); 
    1854                 updateLabels(cur.buffer()); 
     1854                cur.buffer().updateLabels(); 
    18551855                needsUpdate = true; 
    18561856                break; 
  • lyx-devel/trunk/src/TextMetrics.cpp

    r27425 r27562  
    391391                        << " Going through the buffer again and hope" 
    392392                        << " the context is better then."); 
    393                 updateLabels(bv_->buffer()); 
     393                bv_->buffer().updateLabels(); 
    394394                parPos = text_->macrocontextPosition(); 
    395395                LASSERT(!parPos.empty(), /**/); 
  • lyx-devel/trunk/src/Undo.cpp

    r27425 r27562  
    428428 
    429429        // Addapt the new material to current buffer. 
    430         updateLabels(buffer_); 
     430        buffer_.updateLabels(); 
    431431        return true; 
    432432} 
  • lyx-devel/trunk/src/buffer_funcs.cpp

    r27425 r27562  
    472472} 
    473473 
    474  
    475 // FIXME: buf should should be const because updateLabels() modifies 
    476 // the contents of the paragraphs. 
    477 void updateLabels(Buffer const & buf, bool childonly) 
    478 { 
    479         // Use the master text class also for child documents 
    480         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 the 
    484         // 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 master 
    489                 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 master 
    499                 textclass.counters().reset(); 
    500         } 
    501  
    502         // update will be done below for buf 
    503         bufToUpdate.erase(&buf); 
    504  
    505         // update all caches 
    506         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 work 
    515         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  
    528474} // namespace lyx 
  • lyx-devel/trunk/src/buffer_funcs.h

    r27425 r27562  
    4848int countChars(DocIterator const & from, DocIterator const & to, bool with_blanks); 
    4949 
    50 /// updates all counters 
    51 void updateLabels(Buffer const &, bool childonly = false); 
    52  
    5350/// 
    5451void updateLabels(Buffer const &, ParIterator &); 
  • lyx-devel/trunk/src/frontends/qt4/GuiInfo.cpp

    r27420 r27562  
    100100        dispatch(FuncRequest(LFUN_INSET_MODIFY, argument)); 
    101101        // FIXME: update the inset contents 
    102         updateLabels(bufferview()->buffer()); 
     102        bufferview()->buffer().updateLabels(false); 
    103103        BufferView * bv = const_cast<BufferView *>(bufferview()); 
    104104        bv->updateMetrics(); 
  • lyx-devel/trunk/src/frontends/qt4/GuiView.cpp

    r27561 r27562  
    10671067        GuiWorkArea * wa = workArea(*newBuffer); 
    10681068        if (wa == 0) { 
    1069                 updateLabels(*newBuffer->masterBuffer()); 
     1069                newBuffer->masterBuffer()->updateLabels(); 
    10701070                wa = addWorkArea(*newBuffer); 
    10711071        } else { 
     
    14391439        Buffer * buf = loadDocument(fullname); 
    14401440        if (buf) { 
    1441                 updateLabels(*buf); 
    1442                  
     1441                buf->updateLabels(); 
    14431442                setBuffer(buf); 
    14441443                buf->errors("Parse"); 
     
    14891488                if (!buf) 
    14901489                        return false; 
    1491                 updateLabels(*buf); 
     1490                buf->updateLabels(); 
    14921491                lv->setBuffer(buf); 
    14931492                buf->errors("Parse"); 
  • lyx-devel/trunk/src/insets/Inset.cpp

    r27425 r27562  
    164164{ 
    165165        if (isLabeled()) 
    166                 lyx::updateLabels(buffer()); 
     166                buffer().updateLabels(); 
    167167} 
    168168 
  • lyx-devel/trunk/src/insets/InsetBibitem.cpp

    r27481 r27562  
    9191        setParam("key", key); 
    9292 
    93         lyx::updateLabels(buffer()); 
     93        buffer().updateLabels(); 
    9494} 
    9595 
  • lyx-devel/trunk/src/insets/InsetInclude.cpp

    r27425 r27562  
    912912        Buffer const * const childbuffer = getChildBuffer(buffer(), params()); 
    913913        if (childbuffer) { 
    914                 lyx::updateLabels(*childbuffer, true); 
     914                childbuffer->updateLabels(true); 
    915915                return; 
    916916        } 
  • lyx-devel/trunk/src/insets/InsetLabel.cpp

    r27425 r27562  
    8282 
    8383        // We need an update of the Buffer reference cache. This is achieved by 
    84         // updateLabel(). 
    85         lyx::updateLabels(buffer()); 
     84        // updateLabels(). 
     85        buffer().updateLabels(); 
    8686} 
    8787 
     
    9090{ 
    9191        static ParamInfo param_info_; 
    92         if (param_info_.empty()) { 
     92        if (param_info_.empty()) 
    9393                param_info_.add("name", ParamInfo::LATEX_REQUIRED); 
    94         } 
    9594        return param_info_; 
    9695} 
  • lyx-devel/trunk/src/lyxfind.cpp

    r27543 r27562  
    183183        } 
    184184 
    185         updateLabels(buf); 
     185        buf.updateLabels(); 
    186186        bv->putSelectionAt(doc_iterator_begin(buf.inset()), 0, false); 
    187187        if (num) 
  • lyx-devel/trunk/src/mathed/InsetMathHull.cpp

    r27553 r27562  
    512512                        // We need an update of the Buffer reference cache. 
    513513                        // This is achieved by updateLabels(). 
    514                         lyx::updateLabels(buffer()); 
    515                 } else 
     514                        buffer().updateLabels(); 
     515                } else { 
    516516                        label_[row]->updateCommand(label); 
     517                } 
    517518                return; 
    518519        } 
     
    533534                // We need an update of the Buffer reference cache. 
    534535                // This is achieved by updateLabels(). 
    535                 lyx::updateLabels(buffer()); 
     536                buffer().updateLabels(); 
    536537        } 
    537538}