svx/inc/sdr/properties/textproperties.hxx    |    2 +-
 svx/source/sdr/properties/textproperties.cxx |   10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

New commits:
commit b2d742faa062d3656f751b32acfe089ffa2dca3f
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jan 7 16:29:38 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jan 8 07:12:37 2022 +0100

    reduce cost of Sdr properties for text-derived objects
    
    when they have no text in them
    
    Change-Id: I70c18898abf21141f3b30b7dee9c931c9b27cffb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128124
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/svx/inc/sdr/properties/textproperties.hxx 
b/svx/inc/sdr/properties/textproperties.hxx
index 4a6d59f61972..719cf838ed89 100644
--- a/svx/inc/sdr/properties/textproperties.hxx
+++ b/svx/inc/sdr/properties/textproperties.hxx
@@ -41,7 +41,7 @@ namespace sdr::properties
 
             // react on ItemSet changes
             virtual void ItemSetChanged(const SfxItemSet*) override;
-            virtual bool WantItemSetInItemSetChanged() const override final { 
return true; }
+            virtual bool WantItemSetInItemSetChanged() const override final;
 
             /// Get the TextProvider related to our SdrObject
             virtual const svx::ITextProvider& getTextProvider() const;
diff --git a/svx/source/sdr/properties/textproperties.cxx 
b/svx/source/sdr/properties/textproperties.cxx
index d361080e2062..c21111892923 100644
--- a/svx/source/sdr/properties/textproperties.cxx
+++ b/svx/source/sdr/properties/textproperties.cxx
@@ -81,6 +81,14 @@ namespace sdr::properties
             return std::unique_ptr<BaseProperties>(new TextProperties(*this, 
rObj));
         }
 
+        bool TextProperties::WantItemSetInItemSetChanged() const
+        {
+            // The itemset construction is fairly expensive, and we only need 
it
+            // if this text (or sub-type of text, eg. rectangle) actually has 
text.
+            const svx::ITextProvider& rTextProvider(getTextProvider());
+            return rTextProvider.getTextCount() != 0;
+        }
+
         void TextProperties::ItemSetChanged(const SfxItemSet* pSet)
         {
             SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject());
@@ -145,7 +153,7 @@ namespace sdr::properties
             }
 
             // Extra-Repaint for radical layout changes (#43139#)
-            if(SfxItemState::SET == 
pSet->GetItemState(SDRATTR_TEXT_CONTOURFRAME))
+            if(pSet && SfxItemState::SET == 
pSet->GetItemState(SDRATTR_TEXT_CONTOURFRAME))
             {
                 // Here only repaint wanted
                 rObj.ActionChanged();

Reply via email to