sc/source/ui/vba/vbaaxis.cxx        |   27 +++++++++++++++++----------
 sc/source/ui/vba/vbaaxis.hxx        |    3 ++-
 sc/source/ui/vba/vbachartobject.cxx |    2 +-
 sc/source/ui/vba/vbachartobject.hxx |    4 ++--
 sc/source/ui/vba/vbatitle.hxx       |   18 ++++++++++--------
 5 files changed, 32 insertions(+), 22 deletions(-)

New commits:
commit bbc473ce49a3a15d2696327d5ca66f3fe85a0671
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 2 09:16:41 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Mar 2 09:07:08 2023 +0000

    allocate ShapeHelper inline
    
    it is only one pointer big
    
    Change-Id: I116bd3713dab8568de56bb32c1ddbb83a1827f6f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148085
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/ui/vba/vbaaxis.cxx b/sc/source/ui/vba/vbaaxis.cxx
index c5eccd697dd1..4751ef85d4f2 100644
--- a/sc/source/ui/vba/vbaaxis.cxx
+++ b/sc/source/ui/vba/vbaaxis.cxx
@@ -53,9 +53,16 @@ ScVbaAxis::isValueAxis()
     return true;
 }
 
-ScVbaAxis::ScVbaAxis( const uno::Reference< XHelperInterface >& xParent,const 
uno::Reference< uno::XComponentContext > & xContext, uno::Reference< 
beans::XPropertySet >  _xPropertySet, sal_Int32 _nType, sal_Int32 _nGroup  ) : 
ScVbaAxis_BASE( xParent, xContext ), mxPropertySet(std::move( _xPropertySet )), 
mnType( _nType ), mnGroup( _nGroup ), bCrossesAreCustomized( false )
+ScVbaAxis::ScVbaAxis( const uno::Reference< XHelperInterface >& xParent,
+                      const uno::Reference< uno::XComponentContext > & 
xContext,
+                      uno::Reference< beans::XPropertySet >  _xPropertySet,
+                      sal_Int32 _nType, sal_Int32 _nGroup )
+  : ScVbaAxis_BASE( xParent, xContext ),
+    mxPropertySet(std::move( _xPropertySet )),
+    mnType( _nType ), mnGroup( _nGroup ),
+    maShapeHelper( uno::Reference< drawing::XShape >( mxPropertySet, 
uno::UNO_QUERY ) ),
+    bCrossesAreCustomized( false )
 {
-    oShapeHelper.reset( new ShapeHelper( uno::Reference< drawing::XShape >( 
mxPropertySet, uno::UNO_QUERY ) ) );
     moChartParent.set( xParent, uno::UNO_QUERY_THROW  );
     setType(_nType);
     setCrosses(xlAxisCrossesAutomatic);
@@ -606,36 +613,36 @@ ScVbaAxis::getScaleType(  )
 double SAL_CALL
 ScVbaAxis::getHeight(  )
 {
-    return oShapeHelper->getHeight();
+    return maShapeHelper.getHeight();
 }
 
 void SAL_CALL ScVbaAxis::setHeight( double height )
 {
-    oShapeHelper->setHeight( height );
+    maShapeHelper.setHeight( height );
 }
 double SAL_CALL ScVbaAxis::getWidth(  )
 {
-    return oShapeHelper->getWidth( );
+    return maShapeHelper.getWidth( );
 }
 void SAL_CALL ScVbaAxis::setWidth( double width )
 {
-    oShapeHelper->setWidth( width );
+    maShapeHelper.setWidth( width );
 }
 double SAL_CALL ScVbaAxis::getTop(  )
 {
-    return oShapeHelper->getTop( );
+    return maShapeHelper.getTop( );
 }
 void SAL_CALL ScVbaAxis::setTop( double top )
 {
-    oShapeHelper->setTop( top );
+    maShapeHelper.setTop( top );
 }
 double SAL_CALL ScVbaAxis::getLeft(  )
 {
-    return oShapeHelper->getLeft( );
+    return maShapeHelper.getLeft( );
 }
 void SAL_CALL ScVbaAxis::setLeft( double left )
 {
-    oShapeHelper->setLeft( left );
+    maShapeHelper.setLeft( left );
 }
 
 OUString
diff --git a/sc/source/ui/vba/vbaaxis.hxx b/sc/source/ui/vba/vbaaxis.hxx
index cf5958895426..787d2e03763a 100644
--- a/sc/source/ui/vba/vbaaxis.hxx
+++ b/sc/source/ui/vba/vbaaxis.hxx
@@ -30,12 +30,13 @@ class ScVbaAxis : public ScVbaAxis_BASE
     css::uno::Reference< css::beans::XPropertySet > mxPropertySet;
     sal_Int32 mnType;
     sal_Int32 mnGroup;
+    ov::ShapeHelper maShapeHelper;
+
     bool bCrossesAreCustomized;
     /// @throws css::uno::RuntimeException
     ScVbaChart* getChartPtr();
     /// @throws css::script::BasicErrorException
     bool isValueAxis();
-    std::unique_ptr<ov::ShapeHelper> oShapeHelper;
 
 public:
     ScVbaAxis( const css::uno::Reference< ov::XHelperInterface >& xParent, 
const css::uno::Reference< css::uno::XComponentContext > & xContext, 
css::uno::Reference< css::beans::XPropertySet >  _xPropertySet, sal_Int32 
_nType, sal_Int32 _nGroup );
diff --git a/sc/source/ui/vba/vbachartobject.cxx 
b/sc/source/ui/vba/vbachartobject.cxx
index 5a45d29a52d7..0395da35e06d 100644
--- a/sc/source/ui/vba/vbachartobject.cxx
+++ b/sc/source/ui/vba/vbachartobject.cxx
@@ -40,7 +40,7 @@ ScVbaChartObject::ScVbaChartObject( const 
css::uno::Reference< ov::XHelperInterf
         sPersistName = getPersistName();
         xShape = setShape();
         setName(sPersistName);
-        oShapeHelper.reset(new ShapeHelper(xShape));
+        oShapeHelper.emplace(xShape);
 }
 
 OUString const & ScVbaChartObject::getPersistName()
diff --git a/sc/source/ui/vba/vbachartobject.hxx 
b/sc/source/ui/vba/vbachartobject.hxx
index 59cc5aea8f20..34a20d48db05 100644
--- a/sc/source/ui/vba/vbachartobject.hxx
+++ b/sc/source/ui/vba/vbachartobject.hxx
@@ -26,7 +26,7 @@
 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
 #include <ooo/vba/excel/XChartObject.hpp>
 #include <vbahelper/vbahelperinterface.hxx>
-#include <memory>
+#include <optional>
 
 typedef InheritedHelperInterfaceWeakImpl<ov::excel::XChartObject > 
ChartObjectImpl_BASE;
 
@@ -40,7 +40,7 @@ class ScVbaChartObject : public ChartObjectImpl_BASE
     css::uno::Reference< css::drawing::XShape > xShape;
     css::uno::Reference< css::container::XNamed > xNamed;
     OUString sPersistName;
-    std::unique_ptr<ov::ShapeHelper> oShapeHelper;
+    std::optional<ov::ShapeHelper> oShapeHelper;
     css::uno::Reference< css::container::XNamed > xNamedShape;
     OUString const & getPersistName();
     /// @throws css::script::BasicErrorException
diff --git a/sc/source/ui/vba/vbatitle.hxx b/sc/source/ui/vba/vbatitle.hxx
index 8834ca90c8b2..bb017f0bfb0c 100644
--- a/sc/source/ui/vba/vbatitle.hxx
+++ b/sc/source/ui/vba/vbatitle.hxx
@@ -36,16 +36,18 @@ typedef InheritedHelperInterfaceImpl< Ifc... > BaseClass;
 
     css::uno::Reference< css::drawing::XShape > xTitleShape;
     css::uno::Reference< css::beans::XPropertySet > xShapePropertySet;
-    std::unique_ptr<ov::ShapeHelper> oShapeHelper;
+    ov::ShapeHelper maShapeHelper;
     ScVbaPalette m_Palette;
 public:
     TitleImpl(  const css::uno::Reference< ov::XHelperInterface >& xParent,
                 const css::uno::Reference< css::uno::XComponentContext >& 
xContext,
                 css::uno::Reference< css::drawing::XShape >  _xTitleShape )
-        : BaseClass( xParent, xContext ), xTitleShape(std::move( _xTitleShape 
)), m_Palette(nullptr)
+        : BaseClass( xParent, xContext ),
+        xTitleShape(std::move( _xTitleShape )),
+        xShapePropertySet( xTitleShape, css::uno::UNO_QUERY_THROW ),
+        maShapeHelper( xTitleShape ),
+        m_Palette(nullptr)
     {
-        xShapePropertySet.set( xTitleShape, css::uno::UNO_QUERY_THROW );
-        oShapeHelper.reset( new ov::ShapeHelper(xTitleShape) );
     }
     css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior(  ) override
     {
@@ -89,19 +91,19 @@ public:
 
     void SAL_CALL setTop( double Top ) override
     {
-        oShapeHelper->setTop( Top );
+        maShapeHelper.setTop( Top );
     }
     double SAL_CALL getTop(  ) override
     {
-        return oShapeHelper->getTop();
+        return maShapeHelper.getTop();
     }
     void SAL_CALL setLeft( double Left ) override
     {
-        oShapeHelper->setLeft( Left );
+        maShapeHelper.setLeft( Left );
     }
     double SAL_CALL getLeft(  ) override
     {
-        return oShapeHelper->getLeft();
+        return maShapeHelper.getLeft();
     }
     void SAL_CALL setOrientation( ::sal_Int32 _nOrientation ) override
     {

Reply via email to