From 92e71f01ee52074192910d959fe1ef438273d31d Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 23 Apr 2008 10:55:51 +0000 Subject: [PATCH] * Inset.h (producesOutput): new mvirtual method, returning true by default * InsetNote.h (producesOutput): always return false. * InsetBranch.h (producesOutput): returns true if the branch is selected. * InsetBranch.cpp (updateLabels): * InsetNote.cpp (updateLabels): remove * InsetText.cpp (updateLabels): honor producesOutput(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24475 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/Inset.h | 3 +++ src/insets/InsetBranch.cpp | 13 ------------- src/insets/InsetBranch.h | 9 +++++++-- src/insets/InsetNote.cpp | 9 --------- src/insets/InsetNote.h | 9 +++++++-- src/insets/InsetText.cpp | 9 ++++++++- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 5d21a0fe1d..be04893b45 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -361,6 +361,9 @@ public: /// Is the width forced to some value? virtual bool hasFixedWidth() const { return false; } + /// Is the content of this inset part of the output document? + virtual bool producesOutput() const { return true; } + /// \return Tool tip for this inset. /// This default implementation returns an empty string. virtual docstring toolTip(BufferView const & bv, int x, int y) const; diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 9a420f016d..050a3c9c5d 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -205,19 +205,6 @@ bool InsetBranch::isBranchSelected() const } -void InsetBranch::updateLabels(ParIterator const & it) -{ - if (isBranchSelected()) - InsetCollapsable::updateLabels(it); - else { - DocumentClass const & tclass = buffer().params().documentClass(); - Counters savecnt = tclass.counters(); - InsetCollapsable::updateLabels(it); - tclass.counters() = savecnt; - } -} - - int InsetBranch::latex(odocstream & os, OutputParams const & runparams) const { return isBranchSelected() ? InsetText::latex(os, runparams) : 0; diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index ca24e99980..4d54cfd4df 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -86,11 +86,16 @@ private: \c buffer. This handles the case of child documents. */ bool isBranchSelected() const; + /*! + * Is the content of this inset part of the output document? + * + * Note that Branch insets are only considered part of the + * document when they are selected. + */ + bool producesOutput() const { return isBranchSelected(); } /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; /// - void updateLabels(ParIterator const &); - /// bool isMacroScope() const; /// docstring toolTip(BufferView const & bv, int x, int y) const; diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 5f642a34a5..133f14d478 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -221,15 +221,6 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd, } -void InsetNote::updateLabels(ParIterator const & it) -{ - DocumentClass const & tclass = buffer().params().documentClass(); - Counters savecnt = tclass.counters(); - InsetCollapsable::updateLabels(it); - tclass.counters() = savecnt; -} - - void InsetNote::addToToc(ParConstIterator const & cpit) const { ParConstIterator pit = cpit; diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index 15b416a1f8..bf5ca70a3f 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -67,6 +67,13 @@ private: DisplayType display() const; /// bool noFontChange() const { return params_.type != InsetNoteParams::Note; } + /*! + * Is the content of this inset part of the output document? + * + * Note that Note insets are not considered part of the + * document, even in their 'greyed out' incarnation. + */ + bool producesOutput() const { return false; } /// void write(std::ostream &) const; /// @@ -87,8 +94,6 @@ private: void validate(LaTeXFeatures &) const; /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; - // Update the counters of this inset and of its contents - void updateLabels(ParIterator const &); /// void addToToc(ParConstIterator const &) const; /// diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 410e84c21f..60abdf79b8 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -433,7 +433,14 @@ void InsetText::updateLabels(ParIterator const & it) ParIterator it2 = it; it2.forwardPos(); LASSERT(&it2.inset() == this && it2.pit() == 0, /**/); - lyx::updateLabels(buffer(), it2); + if (producesOutput()) + lyx::updateLabels(buffer(), it2); + else { + DocumentClass const & tclass = buffer().params().documentClass(); + Counters const savecnt = tclass.counters(); + lyx::updateLabels(buffer(), it2); + tclass.counters() = savecnt; + } } -- 2.39.2