diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-11 12:58:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-12 12:42:22 +0200 |
commit | e722564d40143fa029fe10d22a625539c795ee04 (patch) | |
tree | 5b4aab88bfa6d35917707d4d8ebe92e78a30c0e5 | |
parent | 5dd762ddc1829a86e7b4e23076143bc01d6073ad (diff) |
make SvLBoxItem::Clone return a std::unique_ptr
and combine the Create/Clone methods into one
Change-Id: Ia982be6b50135b8d368d84070327689be6b3d890
Reviewed-on: https://gerrit.libreoffice.org/52745
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/svtools/svlbitm.hxx | 10 | ||||
-rw-r--r-- | include/svtools/treelistbox.hxx | 3 | ||||
-rw-r--r-- | include/svx/ctredlin.hxx | 2 | ||||
-rw-r--r-- | include/svx/fontlb.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationList.cxx | 18 | ||||
-rw-r--r-- | svtools/source/contnr/svlbitm.cxx | 37 | ||||
-rw-r--r-- | svtools/source/contnr/treelistentry.cxx | 3 | ||||
-rw-r--r-- | svtools/source/uno/treecontrolpeer.cxx | 22 | ||||
-rw-r--r-- | svx/source/dialog/ctredlin.cxx | 4 | ||||
-rw-r--r-- | svx/source/dialog/fontlb.cxx | 4 |
10 files changed, 36 insertions, 70 deletions
diff --git a/include/svtools/svlbitm.hxx b/include/svtools/svlbitm.hxx index 9bfe7e20e137..a6ca61dceef0 100644 --- a/include/svtools/svlbitm.hxx +++ b/include/svtools/svlbitm.hxx @@ -129,8 +129,7 @@ public: const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override; - virtual SvLBoxItem* Create() const override; - virtual void Clone(SvLBoxItem* pSource) override; + virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override; }; class SVT_DLLPUBLIC SvLBoxButton : public SvLBoxItem @@ -163,9 +162,8 @@ public: const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override; - virtual SvLBoxItem* Create() const override; + virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override; - virtual void Clone(SvLBoxItem* pSource) override; SvItemStateFlags GetButtonFlags() const { return nItemFlags; @@ -244,9 +242,7 @@ public: const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override; - virtual SvLBoxItem* Create() const override; - virtual void Clone(SvLBoxItem* pSource) override; - + virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override; void SetModeImages(const Image& rBitmap1, const Image& rBitmap2); diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx index a4f6baf2feb1..9907e4358397 100644 --- a/include/svtools/treelistbox.hxx +++ b/include/svtools/treelistbox.hxx @@ -153,9 +153,8 @@ public: // If != 0: this Pointer must be used! // If == 0: it needs to be retrieved via the View SvViewDataItem* pViewData = nullptr) = 0; - virtual SvLBoxItem* Create() const = 0; // View-dependent data is not cloned - virtual void Clone(SvLBoxItem* pSource) = 0; + virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const = 0; }; enum class DragDropMode diff --git a/include/svx/ctredlin.hxx b/include/svx/ctredlin.hxx index 693c0ba1b506..8c25a1a272ac 100644 --- a/include/svx/ctredlin.hxx +++ b/include/svx/ctredlin.hxx @@ -104,7 +104,7 @@ public: virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override; - SvLBoxItem* Create() const override; + virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override; }; class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxRedlinTable : public SvSimpleTable diff --git a/include/svx/fontlb.hxx b/include/svx/fontlb.hxx index 838d8defb20f..f0d7d75a1e8b 100644 --- a/include/svx/fontlb.hxx +++ b/include/svx/fontlb.hxx @@ -42,8 +42,7 @@ public: virtual ~SvLBoxFontString() override; - /** Creates a new empty list box item. */ - virtual SvLBoxItem* Create() const override; + virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override; void InitViewData( SvTreeListBox*, SvTreeListEntry*, SvViewDataItem* = nullptr ) override; diff --git a/sd/source/ui/animations/CustomAnimationList.cxx b/sd/source/ui/animations/CustomAnimationList.cxx index c2908041be6d..5008b9f631ea 100644 --- a/sd/source/ui/animations/CustomAnimationList.cxx +++ b/sd/source/ui/animations/CustomAnimationList.cxx @@ -202,8 +202,7 @@ public: CustomAnimationListEntryItem(const OUString& aDescription, const CustomAnimationEffectPtr& pEffect, CustomAnimationList* pParent); void InitViewData(SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* = nullptr) override; - SvLBoxItem* Create() const override; - void Clone(SvLBoxItem* pSource) override; + virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override; virtual void Paint(const Point&, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView,const SvTreeListEntry& rEntry) override; @@ -328,15 +327,11 @@ void CustomAnimationListEntryItem::Paint(const Point& rPos, SvTreeListBox& rDev, rRenderContext.DrawText(aPos, rRenderContext.GetEllipsisString(msEffectName, rDev.GetOutputSizePixel().Width() - aPos.X())); } -SvLBoxItem* CustomAnimationListEntryItem::Create() const +std::unique_ptr<SvLBoxItem> CustomAnimationListEntryItem::Clone(SvLBoxItem const *) const { return nullptr; } -void CustomAnimationListEntryItem::Clone( SvLBoxItem* ) -{ -} - class CustomAnimationListEntry : public SvTreeListEntry { public: @@ -364,8 +359,7 @@ public: explicit CustomAnimationTriggerEntryItem( const OUString& aDescription ); void InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* = nullptr ) override; - SvLBoxItem* Create() const override; - void Clone( SvLBoxItem* pSource ) override; + virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override; virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override; @@ -428,15 +422,11 @@ void CustomAnimationTriggerEntryItem::Paint(const Point& rPos, SvTreeListBox& rD rRenderContext.Pop(); } -SvLBoxItem* CustomAnimationTriggerEntryItem::Create() const +std::unique_ptr<SvLBoxItem> CustomAnimationTriggerEntryItem::Clone(SvLBoxItem const *) const { return nullptr; } -void CustomAnimationTriggerEntryItem::Clone( SvLBoxItem* ) -{ -} - CustomAnimationList::CustomAnimationList( vcl::Window* pParent ) : SvTreeListBox( pParent, WB_TABSTOP | WB_BORDER | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT ) , mbIgnorePaint(false) diff --git a/svtools/source/contnr/svlbitm.cxx b/svtools/source/contnr/svlbitm.cxx index c3aad1254602..f12c2911673f 100644 --- a/svtools/source/contnr/svlbitm.cxx +++ b/svtools/source/contnr/svlbitm.cxx @@ -199,14 +199,11 @@ void SvLBoxString::Paint( rRenderContext.DrawText(tools::Rectangle(rPos, aSize), maText, nStyle); } -SvLBoxItem* SvLBoxString::Create() const +std::unique_ptr<SvLBoxItem> SvLBoxString::Clone(SvLBoxItem const * pSource) const { - return new SvLBoxString; -} - -void SvLBoxString::Clone( SvLBoxItem* pSource ) -{ - maText = static_cast<SvLBoxString*>(pSource)->maText; + std::unique_ptr<SvLBoxString> pNew(new SvLBoxString); + pNew->maText = static_cast<SvLBoxString const *>(pSource)->maText; + return std::unique_ptr<SvLBoxItem>(pNew.release()); } void SvLBoxString::InitViewData( @@ -305,14 +302,11 @@ void SvLBoxButton::Paint( rRenderContext.DrawImage(rPos, pData->GetImage(nIndex), nStyle); } -SvLBoxItem* SvLBoxButton::Create() const +std::unique_ptr<SvLBoxItem> SvLBoxButton::Clone(SvLBoxItem const * pSource) const { - return new SvLBoxButton; -} - -void SvLBoxButton::Clone( SvLBoxItem* pSource ) -{ - pData = static_cast<SvLBoxButton*>(pSource)->pData; + std::unique_ptr<SvLBoxButton> pNew(new SvLBoxButton); + pNew->pData = static_cast<SvLBoxButton const *>(pSource)->pData; + return std::unique_ptr<SvLBoxItem>(pNew.release()); } void SvLBoxButton::ImplAdjustBoxSize(Size& io_rSize, ControlType i_eType, vcl::RenderContext const & rRenderContext) @@ -442,16 +436,13 @@ void SvLBoxContextBmp::Paint( rRenderContext.DrawImage(_rPos, rImage, nStyle); } -SvLBoxItem* SvLBoxContextBmp::Create() const -{ - return new SvLBoxContextBmp; -} - -void SvLBoxContextBmp::Clone( SvLBoxItem* pSource ) +std::unique_ptr<SvLBoxItem> SvLBoxContextBmp::Clone(SvLBoxItem const * pSource) const { - m_pImpl->m_aImage1 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage1; - m_pImpl->m_aImage2 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage2; - m_pImpl->m_bExpanded = static_cast<SvLBoxContextBmp*>(pSource)->m_pImpl->m_bExpanded; + std::unique_ptr<SvLBoxContextBmp> pNew(new SvLBoxContextBmp); + pNew->m_pImpl->m_aImage1 = static_cast< SvLBoxContextBmp const * >( pSource )->m_pImpl->m_aImage1; + pNew->m_pImpl->m_aImage2 = static_cast< SvLBoxContextBmp const * >( pSource )->m_pImpl->m_aImage2; + pNew->m_pImpl->m_bExpanded = static_cast<SvLBoxContextBmp const *>(pSource)->m_pImpl->m_bExpanded; + return std::unique_ptr<SvLBoxItem>(pNew.release()); } long SvLBoxButtonData::Width() diff --git a/svtools/source/contnr/treelistentry.cxx b/svtools/source/contnr/treelistentry.cxx index b96a2c8e479e..bbf8a49a11c9 100644 --- a/svtools/source/contnr/treelistentry.cxx +++ b/svtools/source/contnr/treelistentry.cxx @@ -97,8 +97,7 @@ void SvTreeListEntry::Clone(SvTreeListEntry* pSource) for (auto const& it : pSource->m_Items) { SvLBoxItem* pItem = &(*it); - std::unique_ptr<SvLBoxItem> pNewItem(pItem->Create()); - pNewItem->Clone(pItem); + std::unique_ptr<SvLBoxItem> pNewItem(pItem->Clone(pItem)); m_Items.push_back(std::move(pNewItem)); } diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index 4c068748fab5..b481ebfb7025 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -115,8 +115,7 @@ public: void SetGraphicURL( const OUString& rGraphicURL ); virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override; - SvLBoxItem* Create() const override; - void Clone( SvLBoxItem* pSource ) override; + std::unique_ptr<SvLBoxItem> Clone( SvLBoxItem const * pSource ) const override; private: OUString maGraphicURL; @@ -1510,20 +1509,13 @@ void UnoTreeListItem::Paint( } -SvLBoxItem* UnoTreeListItem::Create() const +std::unique_ptr<SvLBoxItem> UnoTreeListItem::Clone(SvLBoxItem const * pSource) const { - return new UnoTreeListItem; -} - - -void UnoTreeListItem::Clone( SvLBoxItem* pSource ) -{ - UnoTreeListItem* pSourceItem = dynamic_cast< UnoTreeListItem* >( pSource ); - if( pSourceItem ) - { - maText = pSourceItem->maText; - maImage = pSourceItem->maImage; - } + std::unique_ptr<UnoTreeListItem> pNew(new UnoTreeListItem); + UnoTreeListItem const * pSourceItem = static_cast< UnoTreeListItem const * >( pSource ); + pNew->maText = pSourceItem->maText; + pNew->maImage = pSourceItem->maImage; + return std::unique_ptr<SvLBoxItem>(pNew.release()); } diff --git a/svx/source/dialog/ctredlin.cxx b/svx/source/dialog/ctredlin.cxx index 8e2e68baafc4..be1e113c70c3 100644 --- a/svx/source/dialog/ctredlin.cxx +++ b/svx/source/dialog/ctredlin.cxx @@ -75,9 +75,9 @@ SvLBoxColorString::~SvLBoxColorString() { } -SvLBoxItem* SvLBoxColorString::Create() const +std::unique_ptr<SvLBoxItem> SvLBoxColorString::Clone(SvLBoxItem const *) const { - return new SvLBoxColorString; + return std::unique_ptr<SvLBoxItem>(new SvLBoxColorString); } void SvLBoxColorString::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, diff --git a/svx/source/dialog/fontlb.cxx b/svx/source/dialog/fontlb.cxx index 6ba989d88690..a2e4b6dde8c3 100644 --- a/svx/source/dialog/fontlb.cxx +++ b/svx/source/dialog/fontlb.cxx @@ -46,9 +46,9 @@ SvLBoxFontString::~SvLBoxFontString() { } -SvLBoxItem* SvLBoxFontString::Create() const +std::unique_ptr<SvLBoxItem> SvLBoxFontString::Clone(SvLBoxItem const *) const { - return new SvLBoxFontString; + return std::unique_ptr<SvLBoxItem>(new SvLBoxFontString); } void SvLBoxFontString::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, |