[Libreoffice-commits] core.git: oox/inc oox/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 14 16:33:07 UTC 2021


 oox/inc/drawingml/textliststyle.hxx             |    2 +-
 oox/inc/drawingml/textparagraph.hxx             |    2 +-
 oox/inc/drawingml/textparagraphproperties.hxx   |    4 ----
 oox/source/drawingml/shape.cxx                  |    4 ++--
 oox/source/drawingml/textbody.cxx               |    2 +-
 oox/source/drawingml/textliststyle.cxx          |   17 ++++++-----------
 oox/source/drawingml/textliststylecontext.cxx   |   24 ++++++++++++------------
 oox/source/drawingml/textparagraph.cxx          |   12 ++++++------
 oox/source/ppt/presentationfragmenthandler.cxx  |    4 ++--
 oox/source/ppt/slidemastertextstylescontext.cxx |    2 +-
 oox/source/ppt/slidepersist.cxx                 |    2 +-
 11 files changed, 33 insertions(+), 42 deletions(-)

New commits:
commit 94afb3663b1618b66daa7cc7199cbd5c9f387e0f
Author:     Noel Grandin <noel at peralex.com>
AuthorDate: Wed Apr 14 13:11:22 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Apr 14 18:32:26 2021 +0200

    reduce allocation in TextListStyle some more
    
    These child objects do not need to use shared_ptr, since no-one
    else holds a pointer to them, and we always allocate them, so
    just allocate them inline the parent object.
    
    Change-Id: I96ab644a3a2f1e962df02d590c6a9944ef4a9ce3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114085
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/oox/inc/drawingml/textliststyle.hxx b/oox/inc/drawingml/textliststyle.hxx
index ac84cc9d903d..cd770457575f 100644
--- a/oox/inc/drawingml/textliststyle.hxx
+++ b/oox/inc/drawingml/textliststyle.hxx
@@ -27,7 +27,7 @@
 namespace oox::drawingml
 {
 constexpr int NUM_TEXT_LIST_STYLE_ENTRIES = 9;
-typedef std::array<std::shared_ptr<TextParagraphProperties>, NUM_TEXT_LIST_STYLE_ENTRIES>
+typedef std::array<TextParagraphProperties, NUM_TEXT_LIST_STYLE_ENTRIES>
     TextParagraphPropertiesArray;
 
 class TextListStyle
diff --git a/oox/inc/drawingml/textparagraph.hxx b/oox/inc/drawingml/textparagraph.hxx
index 5139c51b9b26..df39f8841c76 100644
--- a/oox/inc/drawingml/textparagraph.hxx
+++ b/oox/inc/drawingml/textparagraph.hxx
@@ -61,7 +61,7 @@ public:
         const TextCharacterProperties& rTextStyleProperties,
         const TextListStyle& rTextListStyle) const;
 
-    TextParagraphPropertiesPtr      getParagraphStyle(
+    TextParagraphProperties*      getParagraphStyle(
         const TextListStyle& rTextListStyle) const;
 
     void                        insertAt(
diff --git a/oox/inc/drawingml/textparagraphproperties.hxx b/oox/inc/drawingml/textparagraphproperties.hxx
index 7dd41610024b..dd508179c13d 100644
--- a/oox/inc/drawingml/textparagraphproperties.hxx
+++ b/oox/inc/drawingml/textparagraphproperties.hxx
@@ -33,10 +33,6 @@ namespace com::sun::star {
 
 namespace oox::drawingml {
 
-class TextParagraphProperties;
-
-typedef std::shared_ptr< TextParagraphProperties > TextParagraphPropertiesPtr;
-
 class BulletList
 {
 public:
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 819d117d4fa9..729fb3c3712f 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1050,8 +1050,8 @@ Reference< XShape > const & Shape::createAndInsert(
             mpTextBody->getTextProperties().pushRotationAdjustments();
             aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap );
             // Push char properties as well - specifically useful when this is a placeholder
-            if( mpMasterTextListStyle &&  mpMasterTextListStyle->getListStyle()[0]->getTextCharacterProperties().moHeight.has() )
-                aShapeProps.setProperty(PROP_CharHeight, GetFontHeight( mpMasterTextListStyle->getListStyle()[0]->getTextCharacterProperties().moHeight.get() ));
+            if( mpMasterTextListStyle &&  mpMasterTextListStyle->getListStyle()[0].getTextCharacterProperties().moHeight.has() )
+                aShapeProps.setProperty(PROP_CharHeight, GetFontHeight( mpMasterTextListStyle->getListStyle()[0].getTextCharacterProperties().moHeight.get() ));
         }
 
         // applying properties
diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx
index 4c5495e6c040..c6abacf7d485 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -119,7 +119,7 @@ void TextBody::ApplyStyleEmpty(
     aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase);
 
     // Apply paragraph properties
-    TextParagraphPropertiesPtr pTextParagraphStyle = maParagraphs[0]->getParagraphStyle(aCombinedTextStyle);
+    TextParagraphProperties* pTextParagraphStyle = maParagraphs[0]->getParagraphStyle(aCombinedTextStyle);
     if (pTextParagraphStyle)
     {
         Reference< XPropertySet > xProps(xText, UNO_QUERY);
diff --git a/oox/source/drawingml/textliststyle.cxx b/oox/source/drawingml/textliststyle.cxx
index da170cae03eb..0b757159e5bc 100644
--- a/oox/source/drawingml/textliststyle.cxx
+++ b/oox/source/drawingml/textliststyle.cxx
@@ -24,11 +24,6 @@ namespace oox::drawingml {
 
 TextListStyle::TextListStyle()
 {
-    for ( int i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
-    {
-        maListStyle[i] = std::make_shared<TextParagraphProperties>( );
-        maAggregationListStyle[i] = std::make_shared<TextParagraphProperties>( );
-    }
 }
 
 TextListStyle::~TextListStyle()
@@ -39,8 +34,8 @@ TextListStyle::TextListStyle(const TextListStyle& rStyle)
 {
     for ( size_t i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
     {
-        maListStyle[i] = std::make_shared<TextParagraphProperties>( *rStyle.maListStyle[i] );
-        maAggregationListStyle[i] = std::make_shared<TextParagraphProperties>( *rStyle.maAggregationListStyle[i] );
+        maListStyle[i] = rStyle.maListStyle[i];
+        maAggregationListStyle[i] = rStyle.maAggregationListStyle[i];
     }
 }
 
@@ -50,8 +45,8 @@ TextListStyle& TextListStyle::operator=(const TextListStyle& rStyle)
     {
         for ( size_t i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
         {
-            *maListStyle[i] = *rStyle.maListStyle[i];
-            *maAggregationListStyle[i] = *rStyle.maAggregationListStyle[i];
+            maListStyle[i] = rStyle.maListStyle[i];
+            maAggregationListStyle[i] = rStyle.maAggregationListStyle[i];
         }
     }
     return *this;
@@ -60,7 +55,7 @@ TextListStyle& TextListStyle::operator=(const TextListStyle& rStyle)
 static void applyStyleList( const TextParagraphPropertiesArray& rSourceListStyle, TextParagraphPropertiesArray& rDestListStyle )
 {
     for ( size_t i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
-        rDestListStyle[i]->apply(*rSourceListStyle[i]);
+        rDestListStyle[i].apply(rSourceListStyle[i]);
 }
 
 void TextListStyle::apply( const TextListStyle& rTextListStyle )
@@ -75,7 +70,7 @@ void TextListStyle::dump() const
     for ( int i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
     {
         SAL_INFO("oox.drawingml", "text list style level: " << i);
-        maListStyle[i]->dump();
+        maListStyle[i].dump();
     }
 }
 #endif
diff --git a/oox/source/drawingml/textliststylecontext.cxx b/oox/source/drawingml/textliststylecontext.cxx
index c1d865b2adc9..f2abd9b91c21 100644
--- a/oox/source/drawingml/textliststylecontext.cxx
+++ b/oox/source/drawingml/textliststylecontext.cxx
@@ -44,29 +44,29 @@ ContextHandlerRef TextListStyleContext::onCreateContext( sal_Int32 aElementToken
     switch( aElementToken )
     {
         case A_TOKEN( defPPr ):     // CT_TextParagraphProperties
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 0 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 0 ] );
         case A_TOKEN( outline1pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getAggregationListStyle()[ 0 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getAggregationListStyle()[ 0 ] );
         case A_TOKEN( outline2pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getAggregationListStyle()[ 1 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getAggregationListStyle()[ 1 ] );
         case A_TOKEN( lvl1pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 0 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 0 ] );
         case A_TOKEN( lvl2pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 1 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 1 ] );
         case A_TOKEN( lvl3pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 2 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 2 ] );
         case A_TOKEN( lvl4pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 3 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 3 ] );
         case A_TOKEN( lvl5pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 4 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 4 ] );
         case A_TOKEN( lvl6pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 5 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 5 ] );
         case A_TOKEN( lvl7pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 6 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 6 ] );
         case A_TOKEN( lvl8pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 7 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 7 ] );
         case A_TOKEN( lvl9pPr ):
-            return new TextParagraphPropertiesContext( *this, rAttribs, *mrTextListStyle.getListStyle()[ 8 ] );
+            return new TextParagraphPropertiesContext( *this, rAttribs, mrTextListStyle.getListStyle()[ 8 ] );
     }
 
     return this;
diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx
index ca33caa9f767..88c086b0c07f 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -49,7 +49,7 @@ TextCharacterProperties TextParagraph::getCharacterStyle (
     const TextCharacterProperties& rTextStyleProperties,
     const TextListStyle& rTextListStyle) const
 {
-    TextParagraphPropertiesPtr pTextParagraphStyle = getParagraphStyle(rTextListStyle);
+    const TextParagraphProperties* pTextParagraphStyle = getParagraphStyle(rTextListStyle);
 
     TextCharacterProperties aTextCharacterStyle;
     if (pTextParagraphStyle)
@@ -59,7 +59,7 @@ TextCharacterProperties TextParagraph::getCharacterStyle (
     return aTextCharacterStyle;
 }
 
-TextParagraphPropertiesPtr TextParagraph::getParagraphStyle(
+TextParagraphProperties* TextParagraph::getParagraphStyle(
     const TextListStyle& rTextListStyle) const
 {
     sal_Int16 nLevel = maProperties.getLevel();
@@ -69,11 +69,11 @@ TextParagraphPropertiesPtr TextParagraph::getParagraphStyle(
     const TextParagraphPropertiesArray& rListStyle = rTextListStyle.getListStyle();
     if (nLevel >= static_cast< sal_Int16 >(rListStyle.size()))
         nLevel = 0;
-    TextParagraphPropertiesPtr pTextParagraphStyle;
+    const TextParagraphProperties* pTextParagraphStyle = nullptr;
     if (!rListStyle.empty())
-        pTextParagraphStyle = rListStyle[nLevel];
+        pTextParagraphStyle = &rListStyle[nLevel];
 
-    return pTextParagraphStyle;
+    return const_cast<TextParagraphProperties*>(pTextParagraphStyle);
 }
 
 void TextParagraph::insertAt(
@@ -126,7 +126,7 @@ void TextParagraph::insertAt(
         PropertyMap aioBulletList;
         Reference< XPropertySet > xProps( xAt, UNO_QUERY);
 
-        TextParagraphPropertiesPtr pTextParagraphStyle = getParagraphStyle(rTextListStyle);
+        TextParagraphProperties* pTextParagraphStyle = getParagraphStyle(rTextListStyle);
         if ( pTextParagraphStyle )
         {
             TextParagraphProperties aParaProp;
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index 9e14a260b846..1c737952872f 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -87,11 +87,11 @@ PresentationFragmentHandler::PresentationFragmentHandler(XmlFilterBase& rFilter,
     , mbCommentAuthorsRead(false)
 {
     TextParagraphPropertiesArray& rParagraphDefaultsVector( mpTextListStyle->getListStyle() );
-    for (auto const& elem : rParagraphDefaultsVector)
+    for (auto & elem : rParagraphDefaultsVector)
     {
         // ppt is having zero bottom margin per default, whereas OOo is 0,5cm,
         // so this attribute needs to be set always
-        elem->getParaBottomMargin() = TextSpacing( 0 );
+        elem.getParaBottomMargin() = TextSpacing( 0 );
     }
 }
 
diff --git a/oox/source/ppt/slidemastertextstylescontext.cxx b/oox/source/ppt/slidemastertextstylescontext.cxx
index 4d98fd5a5839..de326c9bb8a1 100644
--- a/oox/source/ppt/slidemastertextstylescontext.cxx
+++ b/oox/source/ppt/slidemastertextstylescontext.cxx
@@ -67,7 +67,7 @@ SlideMasterTextStylesContext::~SlideMasterTextStylesContext()
     if ( aTextListStylePtr )            // sj: the master list style is the last instance of from where properties
     {                                   // are obtained. i got some documents without having the textsize set at
         for ( int i = 0; i < 9; i++ )   // any point, the master reference application is using 18pt then
-            aTextListStylePtr->getListStyle()[ i ]->getTextCharacterProperties().moHeight = 1800;
+            aTextListStylePtr->getListStyle()[ i ].getTextCharacterProperties().moHeight = 1800;
         return new oox::drawingml::TextListStyleContext( *this, *aTextListStylePtr );
     }
 
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 2b4169bf6062..fae4e5541d96 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -215,7 +215,7 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase )
 static void setTextStyle( Reference< beans::XPropertySet > const & rxPropSet, const XmlFilterBase& rFilter,
     oox::drawingml::TextListStylePtr const & pTextListStylePtr, int nLevel )
 {
-    ::oox::drawingml::TextParagraphPropertiesPtr pTextParagraphPropertiesPtr( pTextListStylePtr->getListStyle()[ nLevel ] );
+    ::oox::drawingml::TextParagraphProperties* pTextParagraphPropertiesPtr( &pTextListStylePtr->getListStyle()[ nLevel ] );
     if( pTextParagraphPropertiesPtr == nullptr )
     {
         // no properties. return


More information about the Libreoffice-commits mailing list