commit f13808939b9ae6d8d467538d17157a87e8a1a37c Author: Kornel Benko <kor...@lyx.org> Date: Thu May 18 18:07:40 2023 +0200
Advaced search: check for toString() before using it. (#12783) --- src/Paragraph.cpp | 2 +- src/insets/Inset.h | 2 ++ src/insets/InsetBranch.h | 2 ++ src/insets/InsetCitation.h | 2 ++ src/insets/InsetCounter.h | 2 ++ src/insets/InsetHyperlink.h | 2 ++ src/insets/InsetIPAMacro.h | 2 ++ src/insets/InsetQuotes.h | 2 ++ src/insets/InsetRef.h | 2 ++ src/insets/InsetSpace.h | 2 ++ src/insets/InsetSpecialChar.h | 2 ++ src/insets/InsetText.h | 2 ++ 12 files changed, 23 insertions(+), 1 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index b8819fd..fed5a74 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -4314,7 +4314,7 @@ docstring Paragraph::asString(pos_type beg, pos_type end, int options, const Out else if (c == META_INSET && (options & AS_STR_INSETS)) { if (c == META_INSET && (options & AS_STR_PLAINTEXT)) { LASSERT(runparams != nullptr, return docstring()); - if (runparams->find_effective()) + if (runparams->find_effective() && getInset(i)->hasToString()) getInset(i)->toString(os); else getInset(i)->plaintext(os, *runparams); diff --git a/src/insets/Inset.h b/src/insets/Inset.h index fa9214d..0ee6b12 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -348,6 +348,8 @@ public: /// paragraph closes. this is appropriate e.g. for floats. virtual docstring xhtml(XMLStream &, OutputParams const &) const; + /// + virtual bool hasToString() const { return false; } /// Writes a string representation of the inset to the odocstream. /// This one should be called when you want the whole contents of /// the inset. diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index 6106ce5..16e5524 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -80,6 +80,8 @@ private: /// docstring xhtml(XMLStream &, OutputParams const &) const override; /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// void forOutliner(docstring &, size_t const, bool const) const override; diff --git a/src/insets/InsetCitation.h b/src/insets/InsetCitation.h index 0adf0d4..56ad45a 100644 --- a/src/insets/InsetCitation.h +++ b/src/insets/InsetCitation.h @@ -62,6 +62,8 @@ public: /// docstring xhtml(XMLStream &, OutputParams const &) const override; /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// void forOutliner(docstring &, size_t const, bool const) const override; diff --git a/src/insets/InsetCounter.h b/src/insets/InsetCounter.h index 92d6f5b..eb6338d 100644 --- a/src/insets/InsetCounter.h +++ b/src/insets/InsetCounter.h @@ -43,6 +43,8 @@ public: /// docstring xhtml(XMLStream &, OutputParams const &) const override; /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// void validate(LaTeXFeatures & features) const override; diff --git a/src/insets/InsetHyperlink.h b/src/insets/InsetHyperlink.h index 974f2f4..59615b0 100644 --- a/src/insets/InsetHyperlink.h +++ b/src/insets/InsetHyperlink.h @@ -34,6 +34,8 @@ public: /// bool isInToc() const override { return true; } /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// void forOutliner(docstring &, size_t const, bool const) const override; diff --git a/src/insets/InsetIPAMacro.h b/src/insets/InsetIPAMacro.h index 3305e6b..5855da9 100644 --- a/src/insets/InsetIPAMacro.h +++ b/src/insets/InsetIPAMacro.h @@ -154,6 +154,8 @@ public: /// docstring xhtml(XMLStream &, OutputParams const &) const override; /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// void forOutliner(docstring &, size_t const, bool const) const override; diff --git a/src/insets/InsetQuotes.h b/src/insets/InsetQuotes.h index bebe9f1..41bad17 100644 --- a/src/insets/InsetQuotes.h +++ b/src/insets/InsetQuotes.h @@ -155,6 +155,8 @@ public: docstring xhtml(XMLStream &, OutputParams const &) const override; /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// void forOutliner(docstring &, size_t const maxlen, bool const) const override; diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index 57377e1..6286652 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -65,6 +65,8 @@ public: /// docstring xhtml(XMLStream &, OutputParams const &) const override; /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// void forOutliner(docstring &, size_t const, bool const) const override; diff --git a/src/insets/InsetSpace.h b/src/insets/InsetSpace.h index e401d6d..0b1bd7b 100644 --- a/src/insets/InsetSpace.h +++ b/src/insets/InsetSpace.h @@ -136,6 +136,8 @@ public: /// void validate(LaTeXFeatures & features) const override; /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// void forOutliner(docstring &, size_t const, bool const) const override; diff --git a/src/insets/InsetSpecialChar.h b/src/insets/InsetSpecialChar.h index 0c8cc36..36afa15 100644 --- a/src/insets/InsetSpecialChar.h +++ b/src/insets/InsetSpecialChar.h @@ -82,6 +82,8 @@ public: /// docstring xhtml(XMLStream &, OutputParams const &) const override; /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// bool isInToc() const override { return true; } diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index bbff948..e271478 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -180,6 +180,8 @@ public: /// void setMacrocontextPositionRecursive(DocIterator const & pos); /// + bool hasToString() const override { return true; } + /// void toString(odocstream &) const override; /// void forOutliner(docstring &, size_t const, bool const) const override; -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs