]> git.lyx.org Git - lyx.git/commitdiff
Advaced search: check for toString() before using it.
authorKornel Benko <kornel@lyx.org>
Thu, 18 May 2023 16:07:40 +0000 (18:07 +0200)
committerKornel Benko <kornel@lyx.org>
Thu, 18 May 2023 16:07:40 +0000 (18:07 +0200)
(#12783)

12 files changed:
src/Paragraph.cpp
src/insets/Inset.h
src/insets/InsetBranch.h
src/insets/InsetCitation.h
src/insets/InsetCounter.h
src/insets/InsetHyperlink.h
src/insets/InsetIPAMacro.h
src/insets/InsetQuotes.h
src/insets/InsetRef.h
src/insets/InsetSpace.h
src/insets/InsetSpecialChar.h
src/insets/InsetText.h

index b8819fdf1b195c139ec2636463087523d89a6902..fed5a741ee885a4f37db191c1ac024d3de8ba3b8 100644 (file)
@@ -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);
index fa9214d705870652563de1424c3af14de51925e4..0ee6b12685d8356035476a8cda732d5b1fbd92f6 100644 (file)
@@ -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.
index 6106ce5a5c3babbd8923c8783d5e2a2d59cf9b6b..16e5524e236c86e22bdef8bbb32df0b129fe4d68 100644 (file)
@@ -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;
index 0adf0d4c3a24589f858946c1f9f2edec4a25dd11..56ad45a9b6a599d06c6540ff0c3c87aa37d9130c 100644 (file)
@@ -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;
index 92d6f5b0613d68e3a7dfa1f5d073a6fe4aa54a46..eb6338dde2a22624b46e06e8fe3d49886ab4d452 100644 (file)
@@ -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;
index 974f2f431af5bfd4727e8501fd1c0911f4835593..59615b0d5bbe6ed1632505a2db6b66b0e79d5766 100644 (file)
@@ -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;
index 3305e6bf6e0f1f282dd3e01c5d79f5d58eca7507..5855da9e95497a76c34e293174ba45bded99ab44 100644 (file)
@@ -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;
index bebe9f1ec002157b95e499bef0ff68a7beb4ba9e..41bad175b8157c342829b302e17e038bfdd4baa6 100644 (file)
@@ -154,6 +154,8 @@ public:
        ///
        docstring xhtml(XMLStream &, OutputParams const &) const override;
 
+       ///
+       bool hasToString() const override { return true; }
        ///
        void toString(odocstream &) const override;
        ///
index 57377e1fd6f5377f50c115f6da92be6cda00c0d5..6286652f4de97f5357d15a473827a3aade1a8ff5 100644 (file)
@@ -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;
index e401d6d9ae7586624cfbd1abe910d239a8aa519b..0b1bd7bfe513c9364ce64d3c34ac2da1f6fc7011 100644 (file)
@@ -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;
index 0c8cc3630447081134991337fd590eb179d153a0..36afa15fed610372bd67133970d046cecd1f46af 100644 (file)
@@ -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; }
index bbff948c83fcc88e131e1b708e7db7cccd4d3e2b..e271478114747bfcbe296af51e273ec862c63969 100644 (file)
@@ -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;