[Libreoffice-commits] core.git: include/oox oox/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 22 16:52:57 UTC 2020
include/oox/drawingml/chart/modelbase.hxx | 14 ++++++++++----
include/oox/dump/dumperbase.hxx | 2 +-
oox/source/drawingml/shape.cxx | 2 +-
oox/source/dump/dumperbase.cxx | 4 ++--
oox/source/dump/oledumper.cxx | 6 +++---
oox/source/ppt/slidefragmenthandler.cxx | 10 ++++++++--
6 files changed, 25 insertions(+), 13 deletions(-)
New commits:
commit 688a520111a2dd3ab4cb3b846b561936d8a887bf
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Apr 21 12:41:45 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Apr 22 18:52:14 2020 +0200
use more make_shared in oox
Change-Id: I54c085a0720a381cf8bc27b2a4b4d2a3b2900918
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92620
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/oox/drawingml/chart/modelbase.hxx b/include/oox/drawingml/chart/modelbase.hxx
index ffac39507d63..f107075c9ff3 100644
--- a/include/oox/drawingml/chart/modelbase.hxx
+++ b/include/oox/drawingml/chart/modelbase.hxx
@@ -62,14 +62,20 @@ public:
ModelVector() {}
- ModelType& create() { return append( new ModelType ); }
+ ModelType& create() { return append( std::make_shared<ModelType>() ); }
template< typename Param1Type >
- ModelType& create( const Param1Type& rParam1 ) { return append( new ModelType( rParam1 ) ); }
+ ModelType& create( const Param1Type& rParam1 ) { return append( std::make_shared<ModelType>( rParam1 ) ); }
template< typename Param1Type, typename Param2Type >
- ModelType& create( const Param1Type& rParam1, const Param2Type& rParam2 ) { return append( new ModelType( rParam1, rParam2 ) ); }
+ ModelType& create( const Param1Type& rParam1, const Param2Type& rParam2 ) { return append( std::make_shared<ModelType>( rParam1, rParam2 ) ); }
private:
- ModelType& append( ModelType* pModel ) { this->push_back( value_type( pModel ) ); return *pModel; }
+ ModelType& append( std::shared_ptr<ModelType> pModel )
+ {
+ assert(pModel);
+ auto pTmp = pModel.get();
+ this->push_back( std::move(pModel) );
+ return *pTmp;
+ }
};
template< typename KeyType, typename ModelType >
diff --git a/include/oox/dump/dumperbase.hxx b/include/oox/dump/dumperbase.hxx
index 43a893105380..5ad5f948f4cf 100644
--- a/include/oox/dump/dumperbase.hxx
+++ b/include/oox/dump/dumperbase.hxx
@@ -138,7 +138,7 @@ class BinaryInputStreamRef : public ::oox::BinaryInputStreamRef
public:
BinaryInputStreamRef() {}
- /*implicit*/ BinaryInputStreamRef( BinaryInputStream* pInStrm ) :
+ /*implicit*/ BinaryInputStreamRef( std::shared_ptr<BinaryInputStream> const & pInStrm ) :
::oox::BinaryInputStreamRef( pInStrm ) {}
/*implicit*/ BinaryInputStreamRef( const css::uno::Reference< css::io::XInputStream >& rxInStrm ) :
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 7ffd1058fda9..d962f008f34e 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -329,7 +329,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
mpShapeRefLinePropPtr = std::make_shared<LineProperties>( rReferencedShape.getActualLineProperties(nullptr) );
mpShapeRefFillPropPtr = std::make_shared<FillProperties>( rReferencedShape.getActualFillProperties(nullptr, nullptr) );
mpCustomShapePropertiesPtr = std::make_shared<CustomShapeProperties>( *rReferencedShape.mpCustomShapePropertiesPtr );
- mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr ) : nullptr );
+ mpTablePropertiesPtr = rReferencedShape.mpTablePropertiesPtr ? std::make_shared<table::TableProperties>( *rReferencedShape.mpTablePropertiesPtr ) : nullptr;
mpShapeRefEffectPropPtr = std::make_shared<EffectProperties>( rReferencedShape.getActualEffectProperties(nullptr) );
mpMasterTextListStyle = std::make_shared<TextListStyle>( *rReferencedShape.mpMasterTextListStyle );
maSize = rReferencedShape.maSize;
diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx
index 1fdcd267edca..3f00248a26cc 100644
--- a/oox/source/dump/dumperbase.cxx
+++ b/oox/source/dump/dumperbase.cxx
@@ -1806,7 +1806,7 @@ void StorageObjectBase::implDump()
}
else if( xBaseStrm.is() )
{
- BinaryInputStreamRef xInStrm( new BinaryXInputStream( xBaseStrm, false ) );
+ BinaryInputStreamRef xInStrm( std::make_shared<BinaryXInputStream>( xBaseStrm, false ) );
xInStrm->seekToStart();
implDumpBaseStream( xInStrm, aSysOutPath );
}
@@ -2521,7 +2521,7 @@ void SequenceRecordObjectBase::construct( const ObjectBase& rParent,
const BinaryInputStreamRef& rxBaseStrm, const OUString& rSysFileName,
const String& rRecNames, const String& rSimpleRecs )
{
- BinaryInputStreamRef xRecStrm( new SequenceInputStream( *mxRecData ) );
+ BinaryInputStreamRef xRecStrm( std::make_shared<SequenceInputStream>( *mxRecData ) );
RecordObjectBase::construct( rParent, rxBaseStrm, rSysFileName, xRecStrm, rRecNames, rSimpleRecs );
}
diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx
index 4a9102bb7ccc..f8ce1ec59fa8 100644
--- a/oox/source/dump/oledumper.cxx
+++ b/oox/source/dump/oledumper.cxx
@@ -1726,7 +1726,7 @@ void VbaOStreamObject::implDump()
writeDecItem( "control-id", siteInfo.mnId );
writeInfoItem( "prog-id", siteInfo.maProgId );
IndentGuard aIndGuard( mxOut );
- BinaryInputStreamRef xRelStrm( new RelativeInputStream( *mxStrm, siteInfo.mnLength ) );
+ BinaryInputStreamRef xRelStrm( std::make_shared<RelativeInputStream>( *mxStrm, siteInfo.mnLength ) );
FormControlStreamObject( *this, xRelStrm, &siteInfo.maProgId ).dump();
}
}
@@ -1861,7 +1861,7 @@ VbaDirStreamObject::VbaDirStreamObject( const ObjectBase& rParent,
mxInStrm = rxStrm;
if( mxInStrm.get() )
{
- BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxInStrm ) );
+ BinaryInputStreamRef xVbaStrm( std::make_shared<::oox::ole::VbaInputStream>( *mxInStrm ) );
SequenceRecordObjectBase::construct( rParent, xVbaStrm, rSysFileName, "VBA-DIR-RECORD-NAMES", "VBA-DIR-SIMPLE-RECORDS" );
}
}
@@ -2006,7 +2006,7 @@ void VbaModuleStreamObject::implDump()
mxOut->emptyLine();
writeEmptyItem( "source-code" );
IndentGuard aIndGuard( mxOut );
- BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxStrm ) );
+ BinaryInputStreamRef xVbaStrm( std::make_shared<::oox::ole::VbaInputStream>( *mxStrm ) );
TextLineStreamObject( *this, xVbaStrm, mrVbaData.meTextEnc ).dump();
}
diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx
index 58a9a60c09f2..d316c53f3b49 100644
--- a/oox/source/ppt/slidefragmenthandler.cxx
+++ b/oox/source/ppt/slidefragmenthandler.cxx
@@ -164,7 +164,10 @@ SlideFragmentHandler::~SlideFragmentHandler()
const FillProperties *pFillProperties = nullptr;
if( mpSlidePersistPtr->getTheme() )
pFillProperties = mpSlidePersistPtr->getTheme()->getFillStyle( rAttribs.getInteger( XML_idx, -1 ) );
- FillPropertiesPtr pFillPropertiesPtr( pFillProperties ? new FillProperties( *pFillProperties ) : new FillProperties );
+ FillPropertiesPtr pFillPropertiesPtr =
+ pFillProperties
+ ? std::make_shared<FillProperties>( *pFillProperties )
+ : std::make_shared<FillProperties>();
mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr );
ContextHandlerRef ret = new ColorContext( *this, mpSlidePersistPtr->getBackgroundColor() );
return ret;
@@ -174,7 +177,10 @@ SlideFragmentHandler::~SlideFragmentHandler()
case A_TOKEN( overrideClrMapping ):
case PPT_TOKEN( clrMap ): // CT_ColorMapping
{
- oox::drawingml::ClrMapPtr pClrMapPtr( ( aElementToken == PPT_TOKEN( clrMap ) || !mpSlidePersistPtr.get() || !mpSlidePersistPtr->getClrMap().get() ) ? new oox::drawingml::ClrMap : new oox::drawingml::ClrMap( *mpSlidePersistPtr->getClrMap() ) );
+ oox::drawingml::ClrMapPtr pClrMapPtr =
+ ( aElementToken == PPT_TOKEN( clrMap ) || !mpSlidePersistPtr.get() || !mpSlidePersistPtr->getClrMap().get() )
+ ? std::make_shared<oox::drawingml::ClrMap>()
+ : std::make_shared<oox::drawingml::ClrMap>( *mpSlidePersistPtr->getClrMap() );
ContextHandlerRef ret = new oox::drawingml::clrMapContext( *this, rAttribs, *pClrMapPtr );
mpSlidePersistPtr->setClrMap( pClrMapPtr );
return ret;
More information about the Libreoffice-commits
mailing list