diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-21 07:51:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-01 08:26:24 +0200 |
commit | ed8152b1ed9baf859966fd21d6641dfba9c4467c (patch) | |
tree | b4f7b372433c5da3b8df41d026ff95fecece9ce6 /sd/source | |
parent | 6cb9b06432434fb3257118743780828b3b57326a (diff) |
improve loplugin:makeshared
to find places where we are converting stuff to unique_ptr
instead of using std::make_shared.
As a bonus, this tends to find places where we are using shared_ptr
where we can instead be using unique_ptr avoiding the locking overhead.
Change-Id: I1b57bbc4a6c766b48bba8e25a55161800e149f62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93207
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/dlg/sddlgfact.cxx | 14 | ||||
-rw-r--r-- | sd/source/ui/dlg/sddlgfact.hxx | 8 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx | 8 |
3 files changed, 15 insertions, 15 deletions
diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx index 117064161ec5..8db686217c86 100644 --- a/sd/source/ui/dlg/sddlgfact.cxx +++ b/sd/source/ui/dlg/sddlgfact.cxx @@ -638,12 +638,12 @@ VclPtr<AbstractSdCustomShowDlg> SdAbstractDialogFactory_Impl::CreateSdCustomShow VclPtr<SfxAbstractTabDialog> SdAbstractDialogFactory_Impl::CreateSdTabCharDialog(weld::Window* pParent, const SfxItemSet* pAttr, SfxObjectShell* pDocShell) { - return VclPtr<SdAbstractTabController_Impl>::Create(std::make_unique<SdCharDlg>(pParent, pAttr, pDocShell)); + return VclPtr<SdAbstractTabController_Impl>::Create(std::make_shared<SdCharDlg>(pParent, pAttr, pDocShell)); } VclPtr<SfxAbstractTabDialog> SdAbstractDialogFactory_Impl::CreateSdTabPageDialog(weld::Window* pParent, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage, bool bIsImpressDoc ) { - return VclPtr<SdAbstractTabController_Impl>::Create(std::make_unique<SdPageDlg>(pDocShell, pParent, pAttr, bAreaPage, bIsImpressDoc)); + return VclPtr<SdAbstractTabController_Impl>::Create(std::make_shared<SdPageDlg>(pDocShell, pParent, pAttr, bAreaPage, bIsImpressDoc)); } VclPtr<AbstractSdModifyFieldDlg> SdAbstractDialogFactory_Impl::CreateSdModifyFieldDlg(weld::Window* pParent, const SvxFieldData* pInField, const SfxItemSet& rSet) @@ -673,12 +673,12 @@ VclPtr<AbstractMorphDlg> SdAbstractDialogFactory_Impl::CreateMorphDlg(weld::Wind VclPtr<SfxAbstractTabDialog> SdAbstractDialogFactory_Impl::CreateSdOutlineBulletTabDlg(weld::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView) { - return VclPtr<AbstractBulletDialog_Impl>::Create(std::make_unique<::sd::OutlineBulletDlg>(pParent, pAttr, pView)); + return VclPtr<AbstractBulletDialog_Impl>::Create(std::make_shared<::sd::OutlineBulletDlg>(pParent, pAttr, pView)); } VclPtr<SfxAbstractTabDialog> SdAbstractDialogFactory_Impl::CreateSdParagraphTabDlg(weld::Window* pParent, const SfxItemSet* pAttr ) { - return VclPtr<SdAbstractTabController_Impl>::Create(std::make_unique<SdParagraphDlg>(pParent, pAttr)); + return VclPtr<SdAbstractTabController_Impl>::Create(std::make_shared<SdParagraphDlg>(pParent, pAttr)); } VclPtr<AbstractSdStartPresDlg> SdAbstractDialogFactory_Impl::CreateSdStartPresentationDlg(weld::Window* pParent, @@ -694,7 +694,7 @@ VclPtr<VclAbstractDialog> SdAbstractDialogFactory_Impl::CreateRemoteDialog(weld: VclPtr<SfxAbstractTabDialog> SdAbstractDialogFactory_Impl::CreateSdPresLayoutTemplateDlg(SfxObjectShell* pDocSh, weld::Window* pParent, bool bBackgroundDlg, SfxStyleSheetBase& rStyleBase, PresentationObjects ePO, SfxStyleSheetBasePool* pSSPool) { - return VclPtr<SdPresLayoutTemplateDlg_Impl>::Create(std::make_unique<SdPresLayoutTemplateDlg>(pDocSh, pParent, bBackgroundDlg, rStyleBase, ePO, pSSPool)); + return VclPtr<SdPresLayoutTemplateDlg_Impl>::Create(std::make_shared<SdPresLayoutTemplateDlg>(pDocSh, pParent, bBackgroundDlg, rStyleBase, ePO, pSSPool)); } VclPtr<AbstractSdPresLayoutDlg> SdAbstractDialogFactory_Impl::CreateSdPresLayoutDlg(weld::Window* pParent, ::sd::DrawDocShell* pDocShell, const SfxItemSet& rInAttrs) @@ -704,7 +704,7 @@ VclPtr<AbstractSdPresLayoutDlg> SdAbstractDialogFactory_Impl::CreateSdPresLayout VclPtr<SfxAbstractTabDialog> SdAbstractDialogFactory_Impl::CreateSdTabTemplateDlg(weld::Window* pParent, const SfxObjectShell* pDocShell, SfxStyleSheetBase& rStyleBase, SdrModel* pModel, SdrView* pView) { - return VclPtr<SdAbstractTabController_Impl>::Create(std::make_unique<SdTabTemplateDlg>(pParent, pDocShell, rStyleBase, pModel, pView)); + return VclPtr<SdAbstractTabController_Impl>::Create(std::make_shared<SdTabTemplateDlg>(pParent, pDocShell, rStyleBase, pModel, pView)); } VclPtr<SfxAbstractDialog> SdAbstractDialogFactory_Impl::CreatSdActionDialog(weld::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView ) @@ -751,7 +751,7 @@ VclPtr<VclAbstractDialog> SdAbstractDialogFactory_Impl::CreateMasterLayoutDialog VclPtr<AbstractHeaderFooterDialog> SdAbstractDialogFactory_Impl::CreateHeaderFooterDialog(sd::ViewShell* pViewShell, weld::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage) { - return VclPtr<AbstractHeaderFooterDialog_Impl>::Create(std::make_unique<::sd::HeaderFooterDialog>(pViewShell, pParent, pDoc, pCurrentPage)); + return VclPtr<AbstractHeaderFooterDialog_Impl>::Create(std::make_shared<::sd::HeaderFooterDialog>(pViewShell, pParent, pDoc, pCurrentPage)); } VclPtr<VclAbstractDialog> SdAbstractDialogFactory_Impl::CreateSdPhotoAlbumDialog(weld::Window* pParent, SdDrawDocument* pDoc) diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx index 257a1614dc6d..75071a54f07a 100644 --- a/sd/source/ui/dlg/sddlgfact.hxx +++ b/sd/source/ui/dlg/sddlgfact.hxx @@ -146,7 +146,7 @@ class SdAbstractTabController_Impl : public SfxAbstractTabDialog { std::shared_ptr<SfxTabDialogController> m_xDlg; public: - explicit SdAbstractTabController_Impl(std::unique_ptr<SfxTabDialogController> p) + explicit SdAbstractTabController_Impl(std::shared_ptr<SfxTabDialogController> p) : m_xDlg(std::move(p)) { } @@ -167,7 +167,7 @@ class AbstractBulletDialog_Impl : public SfxAbstractTabDialog { std::shared_ptr<SfxTabDialogController> m_xDlg; public: - explicit AbstractBulletDialog_Impl(std::unique_ptr<SfxTabDialogController> p) + explicit AbstractBulletDialog_Impl(std::shared_ptr<SfxTabDialogController> p) : m_xDlg(std::move(p)) { } @@ -188,7 +188,7 @@ class SdPresLayoutTemplateDlg_Impl : public SfxAbstractTabDialog { std::shared_ptr<SdPresLayoutTemplateDlg> m_xDlg; public: - explicit SdPresLayoutTemplateDlg_Impl(std::unique_ptr<SdPresLayoutTemplateDlg> p) + explicit SdPresLayoutTemplateDlg_Impl(std::shared_ptr<SdPresLayoutTemplateDlg> p) : m_xDlg(std::move(p)) { } @@ -388,7 +388,7 @@ class AbstractHeaderFooterDialog_Impl :public AbstractHeaderFooterDialog private: std::shared_ptr<::sd::HeaderFooterDialog> m_xDlg; public: - AbstractHeaderFooterDialog_Impl(std::unique_ptr<::sd::HeaderFooterDialog> pDlg) + AbstractHeaderFooterDialog_Impl(std::shared_ptr<::sd::HeaderFooterDialog> pDlg) : m_xDlg(std::move(pDlg)) { } diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx index da5a440dd882..04b99dbf6c15 100644 --- a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx +++ b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx @@ -102,7 +102,7 @@ sal_Int32 ResolutionReduction::ResolutionReducedReplacement::GetMemorySize() con std::shared_ptr<BitmapReplacement> ResolutionReduction::Compress ( const BitmapEx& rBitmap) const { - ResolutionReducedReplacement* pResult = new ResolutionReducedReplacement; + auto pResult = std::make_shared<ResolutionReducedReplacement>(); pResult->maPreview = rBitmap; Size aSize (rBitmap.GetSizePixel()); pResult->maOriginalSize = aSize; @@ -112,7 +112,7 @@ std::shared_ptr<BitmapReplacement> ResolutionReduction::Compress ( pResult->maPreview.Scale(Size(mnWidth,nHeight)); } - return std::shared_ptr<BitmapReplacement>(pResult); + return pResult; } BitmapEx ResolutionReduction::Decompress (const BitmapReplacement& rBitmapData) const @@ -164,12 +164,12 @@ std::shared_ptr<BitmapReplacement> PngCompression::Compress (const BitmapEx& rBi SvMemoryStream aStream (32768, 32768); aWriter.Write(aStream); - PngReplacement* pResult = new PngReplacement(); + auto pResult = std::make_shared<PngReplacement>(); pResult->mnDataSize = aStream.Tell(); pResult->mpData = new char[pResult->mnDataSize]; memcpy(pResult->mpData, aStream.GetData(), pResult->mnDataSize); - return std::shared_ptr<BitmapReplacement>(pResult); + return pResult; } BitmapEx PngCompression::Decompress ( |