]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Remove unused Counters::copy
[lyx.git] / src / Buffer.cpp
index acda58f46fc4a4ab7f2f586fec6c1458ac95fefe..058fb44fd50663da3f4d5eaccefa410b23b5fe42 100644 (file)
@@ -1275,9 +1275,9 @@ void Buffer::updatePreviews() const
        if (!ploader)
                return;
 
-       InsetIterator it = inset_iterator_begin(*d->inset);
-       InsetIterator const end = inset_iterator_end(*d->inset);
-       for (; it != end; ++it)
+       InsetIterator it = begin(*d->inset);
+       InsetIterator const itend = end(*d->inset);
+       for (; it != itend; ++it)
                it->addPreview(it, *ploader);
 
        ploader->startLoading();
@@ -2581,7 +2581,7 @@ void Buffer::collectBibKeys(FileNameList & checkedFiles) const
        if (!parent())
                clearIncludeList();
 
-       for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
+       for (InsetIterator it = begin(inset()); it; ++it) {
                it->collectBibKeys(it, checkedFiles);
                if (it->lyxCode() == BIBITEM_CODE) {
                        if (parent() != nullptr)
@@ -2959,10 +2959,10 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
 
                docstring const oldname = from_utf8(func.getArg(0));
                docstring const newname = from_utf8(func.getArg(1));
-               InsetIterator it  = inset_iterator_begin(inset());
-               InsetIterator const end = inset_iterator_end(inset());
+               InsetIterator it  = begin(inset());
+               InsetIterator const itend = end(inset());
                bool success = false;
-               for (; it != end; ++it) {
+               for (; it != itend; ++it) {
                        if (it->lyxCode() == BRANCH_CODE) {
                                InsetBranch & ins = static_cast<InsetBranch &>(*it);
                                if (ins.branch() == oldname) {
@@ -3730,11 +3730,10 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
                for (auto const & insit : par.insetList()) {
                        it.pos() = insit.pos;
 
-                       switch (insit.inset->lyxCode()) {
                        // is it a nested text inset?
-                       case TEXT_CODE: {
-                               InsetText const * itext = insit.inset->asInsetText();
+                       if (insit.inset->asInsetText()) {
                                // Inset needs its own scope?
+                               InsetText const * itext = insit.inset->asInsetText();
                                bool newScope = itext->isMacroScope();
 
                                // scope which ends just behind the inset
@@ -3745,9 +3744,10 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
                                it.push_back(CursorSlice(*insit.inset));
                                updateMacros(it, newScope ? insetScope : scope);
                                it.pop_back();
-                               break;
+                               continue;
                        }
-                       case TABULAR_CODE: {
+
+                       if (insit.inset->asInsetTabular()) {
                                CursorSlice slice(*insit.inset);
                                size_t const numcells = slice.nargs();
                                for (; slice.idx() < numcells; slice.forwardIdx()) {
@@ -3755,10 +3755,11 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
                                        updateMacros(it, scope);
                                        it.pop_back();
                                }
-                               break;
+                               continue;
                        }
+
                        // is it an external file?
-                       case INCLUDE_CODE: {
+                       if (insit.inset->lyxCode() == INCLUDE_CODE) {
                                // get buffer of external file
                                InsetInclude const & incinset =
                                        static_cast<InsetInclude const &>(*insit.inset);
@@ -3766,7 +3767,7 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
                                Buffer * child = incinset.loadIfNeeded();
                                macro_lock = false;
                                if (!child)
-                                       break;
+                                       continue;
 
                                // register its position, but only when it is
                                // included first in the buffer
@@ -3774,40 +3775,38 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
 
                                // register child with its scope
                                position_to_children[it] = Impl::ScopeBuffer(scope, child);
-                               break;
-                       }
-                       case MATH_HULL_CODE: {
-                               if (!doing_export)
-                                       break;
-                               InsetMathHull * hull = insit.inset->asInsetMath()->asHullInset();
-                               hull->recordLocation(it);
-                               break;
-                       }
-                       case MATHMACRO_CODE: {
-                               // get macro data
-                               InsetMathMacroTemplate & macroTemplate =
-                                       *insit.inset->asInsetMath()->asMacroTemplate();
-                               MacroContext mc(owner_, it);
-                               macroTemplate.updateToContext(mc);
-       
-                               // valid?
-                               bool valid = macroTemplate.validMacro();
-                               // FIXME: Should be fixNameAndCheckIfValid() in fact,
-                               // then the BufferView's cursor will be invalid in
-                               // some cases which leads to crashes.
-                               if (!valid)
-                                       break;
-       
-                               // register macro
-                               // FIXME (Abdel), I don't understand why we pass 'it' here
-                               // instead of 'macroTemplate' defined above... is this correct?
-                               macros[macroTemplate.name()][it] =
-                                       Impl::ScopeMacro(scope, MacroData(owner_, it));
-                               break;
+                               continue;
                        }
-                       default:
-                               break;
+
+                       InsetMath * im = insit.inset->asInsetMath();
+                       if (doing_export && im)  {
+                               InsetMathHull * hull = im->asHullInset();
+                               if (hull)
+                                       hull->recordLocation(it);
                        }
+
+                       if (insit.inset->lyxCode() != MATHMACRO_CODE)
+                               continue;
+
+                       // get macro data
+                       InsetMathMacroTemplate & macroTemplate =
+                               *insit.inset->asInsetMath()->asMacroTemplate();
+                       MacroContext mc(owner_, it);
+                       macroTemplate.updateToContext(mc);
+
+                       // valid?
+                       bool valid = macroTemplate.validMacro();
+                       // FIXME: Should be fixNameAndCheckIfValid() in fact,
+                       // then the BufferView's cursor will be invalid in
+                       // some cases which leads to crashes.
+                       if (!valid)
+                               continue;
+
+                       // register macro
+                       // FIXME (Abdel), I don't understand why we pass 'it' here
+                       // instead of 'macroTemplate' defined above... is this correct?
+                       macros[macroTemplate.name()][it] =
+                               Impl::ScopeMacro(scope, MacroData(const_cast<Buffer *>(owner_), it));
                }
 
                // next paragraph
@@ -3842,11 +3841,9 @@ void Buffer::updateMacros() const
 
 void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_master) const
 {
-       InsetIterator it  = inset_iterator_begin(inset());
-       InsetIterator const end = inset_iterator_end(inset());
-       for (; it != end; ++it) {
-               if (it->lyxCode() == BRANCH_CODE) {
-                       InsetBranch & br = static_cast<InsetBranch &>(*it);
+       for (Inset const & it : inset()) {
+               if (it.lyxCode() == BRANCH_CODE) {
+                       InsetBranch const & br = static_cast<InsetBranch const &>(it);
                        docstring const name = br.branch();
                        if (!from_master && !params().branchlist().find(name))
                                result.push_back(name);
@@ -3854,10 +3851,10 @@ void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_mast
                                result.push_back(name);
                        continue;
                }
-               if (it->lyxCode() == INCLUDE_CODE) {
+               if (it.lyxCode() == INCLUDE_CODE) {
                        // get buffer of external file
                        InsetInclude const & ins =
-                               static_cast<InsetInclude const &>(*it);
+                               static_cast<InsetInclude const &>(it);
                        Buffer * child = ins.loadIfNeeded();
                        if (!child)
                                continue;
@@ -3883,9 +3880,9 @@ void Buffer::updateMacroInstances(UpdateType utype) const
                        continue;
 
                // update macro in all cells of the InsetMathNest
-               DocIterator::idx_type n = minset->nargs();
+               idx_type n = minset->nargs();
                MacroContext mc = MacroContext(this, it);
-               for (DocIterator::idx_type i = 0; i < n; ++i) {
+               for (idx_type i = 0; i < n; ++i) {
                        MathData & data = minset->cell(i);
                        data.updateMacros(nullptr, mc, utype, 0);
                }
@@ -4028,7 +4025,7 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
 
        string const paramName = "key";
        UndoGroupHelper ugh(this);
-       InsetIterator it = inset_iterator_begin(inset());
+       InsetIterator it = begin(inset());
        for (; it; ++it) {
                if (it->lyxCode() != CITE_CODE)
                        continue;