summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-04-11 12:58:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-04-12 12:42:22 +0200
commite722564d40143fa029fe10d22a625539c795ee04 (patch)
tree5b4aab88bfa6d35917707d4d8ebe92e78a30c0e5 /svtools
parent5dd762ddc1829a86e7b4e23076143bc01d6073ad (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>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/contnr/svlbitm.cxx37
-rw-r--r--svtools/source/contnr/treelistentry.cxx3
-rw-r--r--svtools/source/uno/treecontrolpeer.cxx22
3 files changed, 22 insertions, 40 deletions
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());
}