loplugin:useuniqueptr in tools/inetmsg.hxx
Change-Id: Ifdf0da7f59af1777f214cbafeb75b46136775f67 Reviewed-on: https://gerrit.libreoffice.org/43450 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -938,10 +938,8 @@ void ODatabaseForm::Encode( OUString& rString )
|
||||
void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, const OUString& rName,
|
||||
const OUString& rData )
|
||||
{
|
||||
|
||||
// Create part as MessageChild
|
||||
INetMIMEMessage* pChild = new INetMIMEMessage();
|
||||
|
||||
std::unique_ptr<INetMIMEMessage> pChild(new INetMIMEMessage);
|
||||
|
||||
// Header
|
||||
//TODO: Encode rName into a properly formatted Content-Disposition header
|
||||
@@ -965,7 +963,7 @@ void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, const OUString& rN
|
||||
pStream->Flush();
|
||||
pStream->Seek( 0 );
|
||||
pChild->SetDocumentLB( new SvLockBytes(pStream, true) );
|
||||
rParent.AttachChild( *pChild );
|
||||
rParent.AttachChild( std::move(pChild) );
|
||||
}
|
||||
|
||||
|
||||
@@ -1005,7 +1003,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const OUString& rN
|
||||
|
||||
|
||||
// Create part as MessageChild
|
||||
INetMIMEMessage* pChild = new INetMIMEMessage;
|
||||
std::unique_ptr<INetMIMEMessage> pChild(new INetMIMEMessage);
|
||||
|
||||
|
||||
// Header
|
||||
@@ -1025,7 +1023,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const OUString& rN
|
||||
|
||||
// Body
|
||||
pChild->SetDocumentLB( new SvLockBytes(pStream, true) );
|
||||
rParent.AttachChild( *pChild );
|
||||
rParent.AttachChild( std::move(pChild) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
class DateTime;
|
||||
|
||||
@@ -72,14 +73,15 @@ enum class InetMessageMime
|
||||
|
||||
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC INetMIMEMessage
|
||||
{
|
||||
::std::vector< INetMessageHeader* >
|
||||
::std::vector< std::unique_ptr<INetMessageHeader> >
|
||||
m_aHeaderList;
|
||||
|
||||
SvLockBytesRef m_xDocLB;
|
||||
|
||||
::std::map<InetMessageMime, sal_uIntPtr> m_nMIMEIndex;
|
||||
INetMIMEMessage* pParent;
|
||||
::std::vector< INetMIMEMessage* > aChildren;
|
||||
::std::vector< std::unique_ptr<INetMIMEMessage> >
|
||||
aChildren;
|
||||
OString m_aBoundary;
|
||||
|
||||
OUString GetHeaderValue_Impl (
|
||||
@@ -99,12 +101,11 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC INetMIMEMessage
|
||||
if (m_aHeaderList.size() <= rnIndex)
|
||||
{
|
||||
rnIndex = m_aHeaderList.size();
|
||||
m_aHeaderList.push_back( p );
|
||||
m_aHeaderList.emplace_back( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
delete m_aHeaderList[ rnIndex ];
|
||||
m_aHeaderList[ rnIndex ] = p;
|
||||
m_aHeaderList[ rnIndex ].reset(p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,12 +171,12 @@ public:
|
||||
|
||||
INetMIMEMessage* GetChild (sal_uIntPtr nIndex) const
|
||||
{
|
||||
return ( nIndex < aChildren.size() ) ? aChildren[ nIndex ] : nullptr;
|
||||
return ( nIndex < aChildren.size() ) ? aChildren[ nIndex ].get() : nullptr;
|
||||
}
|
||||
INetMIMEMessage* GetParent() const { return pParent; }
|
||||
|
||||
void EnableAttachMultipartFormDataChild();
|
||||
void AttachChild( INetMIMEMessage& rChildMsg );
|
||||
void AttachChild( std::unique_ptr<INetMIMEMessage> pChildMsg );
|
||||
|
||||
const OString& GetMultipartBoundary() const { return m_aBoundary; }
|
||||
};
|
||||
|
@@ -218,12 +218,6 @@ INetMIMEMessage::INetMIMEMessage()
|
||||
|
||||
INetMIMEMessage::~INetMIMEMessage()
|
||||
{
|
||||
for (auto i: m_aHeaderList) {
|
||||
delete i;
|
||||
}
|
||||
for (auto i: aChildren) {
|
||||
delete i;
|
||||
}
|
||||
}
|
||||
|
||||
void INetMIMEMessage::SetMIMEVersion (const OUString& rVersion)
|
||||
@@ -293,12 +287,13 @@ void INetMIMEMessage::EnableAttachMultipartFormDataChild()
|
||||
SetContentTransferEncoding("7bit");
|
||||
}
|
||||
|
||||
void INetMIMEMessage::AttachChild(INetMIMEMessage& rChildMsg)
|
||||
void INetMIMEMessage::AttachChild(std::unique_ptr<INetMIMEMessage> pChildMsg)
|
||||
{
|
||||
assert(IsContainer());
|
||||
if (IsContainer())
|
||||
{
|
||||
rChildMsg.pParent = this;
|
||||
aChildren.push_back( &rChildMsg );
|
||||
pChildMsg->pParent = this;
|
||||
aChildren.push_back( std::move(pChildMsg) );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user