]> git.lyx.org Git - features.git/commitdiff
Inset::addToToc(): change signature. Use DocIterator instead of ParConstIterator...
authorAbdelrazak Younes <younes@lyx.org>
Tue, 13 May 2008 08:23:44 +0000 (08:23 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 13 May 2008 08:23:44 +0000 (08:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24747 a592a061-630c-0410-9148-cb99ea01b6c8

27 files changed:
src/TocBackend.cpp
src/TocBackend.h
src/frontends/qt4/Menus.cpp
src/insets/Inset.h
src/insets/InsetCaption.cpp
src/insets/InsetCaption.h
src/insets/InsetCitation.cpp
src/insets/InsetCitation.h
src/insets/InsetFoot.cpp
src/insets/InsetFoot.h
src/insets/InsetGraphics.cpp
src/insets/InsetGraphics.h
src/insets/InsetInclude.cpp
src/insets/InsetInclude.h
src/insets/InsetIndex.cpp
src/insets/InsetIndex.h
src/insets/InsetLabel.cpp
src/insets/InsetLabel.h
src/insets/InsetMarginal.cpp
src/insets/InsetMarginal.h
src/insets/InsetNote.cpp
src/insets/InsetNote.h
src/insets/InsetRef.cpp
src/insets/InsetRef.h
src/insets/InsetText.cpp
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h

index 7f748e7fbd1d3e4a3ba3e911dee0fc87fb7e1d26..984eb1ab65863b3f273e7c25ccdf4c60e46f2c8f 100644 (file)
@@ -22,6 +22,7 @@
 #include "Layout.h"
 #include "LyXAction.h"
 #include "Paragraph.h"
+#include "ParIterator.h"
 #include "TextClass.h"
 
 #include "insets/InsetOptArg.h"
@@ -43,15 +44,15 @@ namespace lyx {
 //
 ///////////////////////////////////////////////////////////////////////////
 
-TocItem::TocItem(ParConstIterator const & par_it, int d, docstring const & s)
-       : par_it_(par_it), depth_(d), str_(s)
+TocItem::TocItem(DocIterator const & dit, int d, docstring const & s)
+       : dit_(dit), depth_(d), str_(s)
 {
 }
 
 
 int TocItem::id() const
 {
-       return par_it_->id();
+       return dit_.paragraph().id();
 }
 
 
@@ -101,7 +102,7 @@ Toc & TocBackend::toc(string const & type)
 }
 
 
-void TocBackend::updateItem(ParConstIterator const & par_it)
+void TocBackend::updateItem(DocIterator const & dit)
 {
        if (toc("tableofcontents").empty()) {
                // FIXME: should not happen, 
@@ -113,32 +114,33 @@ void TocBackend::updateItem(ParConstIterator const & par_it)
        BufferParams const & bufparams = buffer_->params();
        const int min_toclevel = bufparams.documentClass().min_toclevel();
 
-       TocIterator toc_item = item("tableofcontents", par_it);
+       TocIterator toc_item = item("tableofcontents", dit);
 
        docstring tocstring;
 
        // For each paragraph, traverse its insets and let them add
        // their toc items
-       InsetList::const_iterator it = toc_item->par_it_->insetList().begin();
-       InsetList::const_iterator end = toc_item->par_it_->insetList().end();
+       Paragraph & par = toc_item->dit_.paragraph();
+       InsetList::const_iterator it = par.insetList().begin();
+       InsetList::const_iterator end = par.insetList().end();
        for (; it != end; ++it) {
                Inset & inset = *it->inset;
                if (inset.lyxCode() == OPTARG_CODE) {
                        if (!tocstring.empty())
                                break;
-                       Paragraph const & par =
+                       Paragraph const & inset_par =
                                *static_cast<InsetOptArg&>(inset).paragraphs().begin();
-                       if (!toc_item->par_it_->labelString().empty())
-                               tocstring = toc_item->par_it_->labelString() + ' ';
-                       tocstring += par.asString(false);
+                       if (!par.labelString().empty())
+                               tocstring = par.labelString() + ' ';
+                       tocstring += inset_par.asString(false);
                        break;
                }
        }
 
-       int const toclevel = toc_item->par_it_->layout().toclevel;
+       int const toclevel = par.layout().toclevel;
        if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel
                && tocstring.empty())
-                       tocstring = toc_item->par_it_->asString(true);
+                       tocstring = par.asString(true);
 
        const_cast<TocItem &>(*toc_item).str_ = tocstring;
 }
@@ -165,6 +167,7 @@ void TocBackend::update()
                InsetList::const_iterator end = pit->insetList().end();
                for (; it != end; ++it) {
                        Inset & inset = *it->inset;
+                       pit.pos() = it->pos;
                        //lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
                        inset.addToToc(pit);
                        switch (inset.lyxCode()) {
@@ -198,7 +201,7 @@ void TocBackend::update()
 
 
 TocIterator TocBackend::item(string const & type,
-               ParConstIterator const & par_it) const
+               DocIterator const & dit) const
 {
        TocList::const_iterator toclist_it = tocs_.find(type);
        // Is the type supported?
@@ -212,7 +215,7 @@ TocIterator TocBackend::item(string const & type,
 
        --it;
 
-       ParConstIterator par_it_text = par_it;
+       ParConstIterator par_it_text(dit);
        if (par_it_text.inMathed()) {
                // We are only interested in text so remove the math CursorSlice.
                while (par_it_text.inMathed())
@@ -223,9 +226,9 @@ TocIterator TocBackend::item(string const & type,
                // We verify that we don't compare contents of two
                // different document. This happens when you
                // have parent and child documents.
-               if (&it->par_it_[0].inset() != &par_it_text[0].inset())
+               if (&it->dit_[0].inset() != &par_it_text[0].inset())
                        continue;
-               if (it->par_it_ <= par_it_text)
+               if (it->dit_ <= par_it_text)
                        return it;
        }
 
index 9704352922e8ef80bfe5261ab99de9e5144e9975..f9e700e379411c46706c8d884ffe8631cbf69fed 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef TOC_BACKEND_H
 #define TOC_BACKEND_H
 
-#include "ParIterator.h"
+#include "DocIterator.h"
 
 #include "support/strfwd.h"
 
@@ -39,7 +39,7 @@ public:
        /// Default constructor for STL containers.
        TocItem() {}
        ///
-       TocItem(ParConstIterator const & par_it,
+       TocItem(DocIterator const & dit,
                int depth,
                docstring const & s
                );
@@ -59,7 +59,7 @@ public:
 
 protected:
        /// Current position of item.
-       ParConstIterator par_it_;
+       DocIterator dit_;
 
        /// nesting depth
        int depth_;
@@ -92,7 +92,7 @@ public:
        ///
        void update();
        ///
-       void updateItem(ParConstIterator const & pit);
+       void updateItem(DocIterator const & pit);
 
        ///
        TocList const & tocs() const { return tocs_; }
@@ -105,7 +105,7 @@ public:
        /// Return the first Toc Item before the cursor
        TocIterator item(
                std::string const & type, ///< Type of Toc.
-               ParConstIterator const & ///< The cursor location in the document.
+               DocIterator const & dit ///< The cursor location in the document.
        ) const;
 
        ///
index 51ef148db949cd3228bfd556ad923011f86caa91..ee1a5b69c3d7c65b77ca01599ebe2ee5fc040dd2 100644 (file)
@@ -42,6 +42,7 @@
 #include "LyX.h" // for lastfiles
 #include "LyXFunc.h"
 #include "Paragraph.h"
+#include "ParIterator.h"
 #include "Session.h"
 #include "TextClass.h"
 #include "TocBackend.h"
index be04893b4593eccfc18b2f32faba61da06092dcc..620fc428e0e83a7c538082a26970b836b71eda64 100644 (file)
@@ -436,7 +436,7 @@ public:
        virtual void addPreview(graphics::PreviewLoader &) const {}
        /// Add an entry to the TocList
        /// pit is the ParConstIterator of the paragraph containing the inset
-       virtual void addToToc(ParConstIterator const &) const {}
+       virtual void addToToc(DocIterator const &) {}
        /// Fill keys with BibTeX information
        virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const {}
        /// Update the counters of this inset and of its contents
index 5697e5339772cef1d0ead742b50729be5fc4f134..dafaddef13740068d36c337105285c0934db5542 100644 (file)
@@ -102,16 +102,16 @@ void InsetCaption::setCustomLabel(docstring const & label)
 }
 
 
-void InsetCaption::addToToc(ParConstIterator const & cpit) const
+void InsetCaption::addToToc(DocIterator const & cpit)
 {
        if (type_.empty())
                return;
 
-       ParConstIterator pit = cpit;
-       pit.push_back(*this);
+       DocIterator pit = cpit;
+       pit.push_back(CursorSlice(*this));
 
        Toc & toc = buffer().tocBackend().toc(type_);
-       docstring const str = full_label_ + ". " + pit->asString(false);
+       docstring const str = full_label_ + ". " + text_.getPar(0).asString(false);
        toc.push_back(TocItem(pit, 0, str));
 }
 
index 4f7aa9a981f27ab5c8a186d375b3fbcd89e46136..f5b4bba0f227d9892dd1527e3a534c8311487150 100644 (file)
@@ -71,7 +71,7 @@ private:
        ///
        void setCustomLabel(docstring const & label);
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
        /// 
        virtual bool forceEmptyLayout(idx_type = 0) const { return true; }
        /// Captions don't accept alignment, spacing, etc.
index c41cd370eff2cfd9d69f2d53708e5d652bed8ef3..ea5700e55978c98d38bde0cdf3b8545bf81e0b79 100644 (file)
@@ -427,7 +427,7 @@ void InsetCitation::updateLabels(ParIterator const &)
 }
 
 
-void InsetCitation::addToToc(ParConstIterator const & cpit) const
+void InsetCitation::addToToc(DocIterator const & cpit)
 {
        Toc & toc = buffer().tocBackend().toc("citation");
        toc.push_back(TocItem(cpit, 0, cache.screen_label));
index a7c2ce02cc02478b2bc6beaa7495776d52779cb8..b0399d08981b3801fcdcc2f37db3c2061205395f 100644 (file)
@@ -54,7 +54,7 @@ public:
        ///
        void updateLabels(ParIterator const & it);
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
 
        ///
        static ParamInfo const & findInfo(std::string const &);
index 2785c51a68689ffb4e463a5acefe6d1ed5bdb124..9b5e1f65a8aed49c8801dc3cb73bd8168b310355 100644 (file)
@@ -64,13 +64,12 @@ void InsetFoot::updateLabels(ParIterator const & it)
 }
 
 
-void InsetFoot::addToToc(ParConstIterator const & cpit) const
+void InsetFoot::addToToc(DocIterator const & cpit)
 {
-       ParConstIterator pit = cpit;
-       pit.push_back(*this);
+       DocIterator pit = cpit;
+       pit.push_back(CursorSlice(*this));
 
        Toc & toc = buffer().tocBackend().toc("footnote");
-       // FIXME: we probably want the footnote number too.
        docstring str;
        str = custom_label_ + ": " + getNewLabel(str);
        toc.push_back(TocItem(pit, 0, str));
index 8e2e3989fb4d4f72f2e7d9786e81707581b1a979..64e6249711b37544549f017b6cb20cc83003a75e 100644 (file)
@@ -42,7 +42,7 @@ private:
        /// Update the counters of this inset and of its contents
        void updateLabels(ParIterator const &);
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
        ///
        docstring toolTip(BufferView const & bv, int x, int y) const;
        ///
index 62edf121f19fda37be992130e99041d389d35df0..d2ac809aa50f692fbe0326b8722d0f30a4a4b82b 100644 (file)
@@ -907,7 +907,7 @@ void InsetGraphics::editGraphics(InsetGraphicsParams const & p,
 }
 
 
-void InsetGraphics::addToToc(ParConstIterator const & cpit) const
+void InsetGraphics::addToToc(DocIterator const & cpit)
 {
        TocBackend & backend = buffer().tocBackend();
 
index cca885784f2814d76c9d779a6b88824466dea220..bfb4784aed5325a282bbffe1702f82a55a38e5c8 100644 (file)
@@ -105,7 +105,7 @@ private:
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
        ///
        docstring contextMenu(BufferView const & bv, int x, int y) const;
        /// Force inset into LTR environment if surroundings are RTL?
index f80913722fdd13b4a85413e6c8ca6b898b780692..f04f170b05a2a7862344f2aab40e6d013f36d039 100644 (file)
@@ -880,7 +880,7 @@ void InsetInclude::addPreview(graphics::PreviewLoader & ploader) const
 }
 
 
-void InsetInclude::addToToc(ParConstIterator const & cpit) const
+void InsetInclude::addToToc(DocIterator const & cpit)
 {
        TocBackend & backend = buffer().tocBackend();
 
@@ -895,8 +895,8 @@ void InsetInclude::addToToc(ParConstIterator const & cpit) const
                Toc & toc = backend.toc("listing");
                docstring str = convert<docstring>(toc.size() + 1)
                        + ". " +  from_utf8(caption);
-               ParConstIterator pit = cpit;
-               pit.push_back(*this);
+               DocIterator pit = cpit;
+               pit.push_back(CursorSlice(*this));
                toc.push_back(TocItem(pit, 0, str));
                return;
        }
index d06815100f1e94456b9aa643e42b2df547a60361..e2c3a8a2684d69534473d3aba17bf6e1e5e931e7 100644 (file)
@@ -84,7 +84,7 @@ public:
        ///
        void addPreview(graphics::PreviewLoader &) const;
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
        ///
        void updateLabels(ParIterator const &);
        ///
index c6a008c5f111b79792c95eab4e12a9cb6c67355e..9733467679e0d8c2ba355f15abc659ca76f6e8f9 100644 (file)
@@ -93,10 +93,10 @@ void InsetIndex::write(ostream & os) const
 }
 
 
-void InsetIndex::addToToc(ParConstIterator const & cpit) const
+void InsetIndex::addToToc(DocIterator const & cpit)
 {
-       ParConstIterator pit = cpit;
-       pit.push_back(*this);
+       DocIterator pit = cpit;
+       pit.push_back(CursorSlice(*this));
 
        Toc & toc = buffer().tocBackend().toc("index");
        docstring str;
index 513a0eb2d179feb11d35df0300c1fb706a6aec85..092311c64c269254bbc3fd009dab54d39f6a1c32 100644 (file)
@@ -41,7 +41,7 @@ private:
        /// should paragraph indendation be omitted in any case?
        bool neverIndent() const { return true; }
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
        ///
        Inset * clone() const { return new InsetIndex(*this); }
 };
index 65247a297102edb5abd5b62427b36d4e91d982ac..55ab479fa2efd38e829090ba2d722818a7c29fe8 100644 (file)
@@ -111,7 +111,7 @@ void InsetLabel::updateLabels(ParIterator const &)
 }
 
 
-void InsetLabel::addToToc(ParConstIterator const & cpit) const
+void InsetLabel::addToToc(DocIterator const & cpit)
 {
        docstring const & label = getParam("name");
        Toc & toc = buffer().tocBackend().toc("label");
@@ -124,7 +124,7 @@ void InsetLabel::addToToc(ParConstIterator const & cpit) const
        Buffer::References::const_iterator it = refs.begin();
        Buffer::References::const_iterator end = refs.end();
        for (; it != end; ++it) {
-               ParConstIterator const ref_pit(it->second);
+               DocIterator const ref_pit(it->second);
                toc.push_back(TocItem(ref_pit, 1, it->first->screenLabel()));
        }
 }
index d7daae3461973d6c91172236ff4d13fcefdc75f1..33ba32ebc27e6b0b4c61834b66e48082dbac6428 100644 (file)
@@ -53,7 +53,7 @@ public:
        ///
        void updateLabels(ParIterator const & it);
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
        ///
        void updateCommand(docstring const & new_label, bool updaterefs = true);
 protected:
index 46485e439486d917eb33df0817e44663b48c823f..d9deba880afb1d210403be8b8a08db8395acbfee 100644 (file)
@@ -66,10 +66,10 @@ int InsetMarginal::docbook(odocstream & os,
 }
 
 
-void InsetMarginal::addToToc(ParConstIterator const & cpit) const
+void InsetMarginal::addToToc(DocIterator const & cpit)
 {
-       ParConstIterator pit = cpit;
-       pit.push_back(*this);
+       DocIterator pit = cpit;
+       pit.push_back(CursorSlice(*this));
 
        Toc & toc = buffer().tocBackend().toc("marginalnote");
        docstring str;
index 1899cf8d726683a4a2f7f4df39f85922ed2fec3e..69b3bdec18f249ebde78e9c2b3661ee79e8abb80 100644 (file)
@@ -39,7 +39,7 @@ public:
        ///
        docstring editMessage() const;
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
 private:
        ///
        Inset * clone() const { return new InsetMarginal(*this); }
index 133f14d47806c9e00c15bbfffb834e60b7134d7f..c8dededc59efd2b55677973ab1e85fc4de771cff 100644 (file)
@@ -221,10 +221,10 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-void InsetNote::addToToc(ParConstIterator const & cpit) const
+void InsetNote::addToToc(DocIterator const & cpit)
 {
-       ParConstIterator pit = cpit;
-       pit.push_back(*this);
+       DocIterator pit = cpit;
+       pit.push_back(CursorSlice(*this));
 
        Toc & toc = buffer().tocBackend().toc("note");
        docstring str;
index bf5ca70a3fe0d08c48bee999723d56185231f62b..d588f011aa7c558d905991235fc4dd119407c60f 100644 (file)
@@ -95,7 +95,7 @@ private:
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
index b62839c162b1da7b67da76f37554d0b6500fd29d..f0c45db39ce97d25d979eaea836263ae4b0a882a 100644 (file)
@@ -142,7 +142,7 @@ void InsetRef::updateLabels(ParIterator const & it)
 }
 
 
-void InsetRef::addToToc(ParConstIterator const & cpit) const
+void InsetRef::addToToc(DocIterator const & cpit)
 {
        docstring const & label = getParam("reference");
        if (buffer().insetLabel(label))
index 1af31fa3f808d904b3fe7e8d55349bc436cbcf0f..78ddbbdbeb44a6615c3e9d23efe0b0e26886c935 100644 (file)
@@ -67,7 +67,7 @@ public:
        ///
        void updateLabels(ParIterator const & it);
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
 protected:
        ///
        InsetRef(InsetRef const &);
index 208f10f04df2f138b9a4810d979ae009c412b713..8231d2cb385755cf349406d95dc4413125cfe609 100644 (file)
@@ -423,7 +423,7 @@ ParagraphList & InsetText::paragraphs()
 }
 
 
-//void InsetInclude::addToToc(ParConstIterator const & cpit) const
+//void InsetInclude::addToToc(DocIterator const & cpit)
 //{
 //}
 
index dcb9e9a7a70b5419c630ba4f4b6fd70a07137db0..c9e540bed6ca8c88190728d2baf12277eccf39e3 100644 (file)
@@ -236,7 +236,7 @@ void InsetMathHull::updateLabels(ParIterator const & it)
 }
 
 
-void InsetMathHull::addToToc(ParConstIterator const & pit) const
+void InsetMathHull::addToToc(DocIterator const & pit)
 {
        if (!buffer_) {
                //FIXME: buffer_ should be set at creation for this inset! Problem is
@@ -245,10 +245,6 @@ void InsetMathHull::addToToc(ParConstIterator const & pit) const
                return;
        }
 
-       // FIXME: it would be way better to directly use InsetLabel instead of this
-       // label list. But it should be possible to copy&paste the code in
-       // InsetLabel::addToToc() anyway.
-
        Toc & toc = buffer().tocBackend().toc("equation");
 
        for (row_type row = 0; row != nrows(); ++row) {
index 927ef15db237945b058ada190ca0a82379cec7f7..f441687b5f2e99080bde86928090d5237614ada5 100644 (file)
@@ -38,7 +38,7 @@ public:
        ///
        void updateLabels(ParIterator const &);
        ///
-       void addToToc(ParConstIterator const &) const;
+       void addToToc(DocIterator const &);
        ///
        InsetMathHull & operator=(InsetMathHull const &);
        ///