diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-04 13:37:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-07 08:33:16 +0200 |
commit | a36d67240c303101fb6a56e40ff46aa1023089f3 (patch) | |
tree | f6ceb7a07c56f1bbc1f718bf6534f4dcd35d9060 | |
parent | 8f0167d0e005b2872bba966ab9d72f5cd0f5ad17 (diff) |
loplugin:useuniqueptr in SfxDocumentInfoItem and CustomPropertiesWindow
Change-Id: I535200a5b26725cdefc3e6e3ce5e1e925e7a7bfd
Reviewed-on: https://gerrit.libreoffice.org/53876
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/sfx2/dinfdlg.hxx | 11 | ||||
-rw-r--r-- | sfx2/source/dialog/dinfdlg.cxx | 46 |
2 files changed, 28 insertions, 29 deletions
diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx index 9516b74868d8..2e61a28583ee 100644 --- a/include/sfx2/dinfdlg.hxx +++ b/include/sfx2/dinfdlg.hxx @@ -46,6 +46,7 @@ #include <sfx2/tabdlg.hxx> #include <boost/optional/optional.hpp> +#include <memory> namespace com { namespace sun { namespace star { namespace document { @@ -81,7 +82,7 @@ private: bool m_bDeleteUserData; bool m_bUseUserData; bool m_bUseThumbnailSave; - std::vector< CustomProperty* > m_aCustomProperties; + std::vector< std::unique_ptr<CustomProperty> > m_aCustomProperties; css::uno::Sequence< css::document::CmisProperty > m_aCmisProperties; public: @@ -150,7 +151,7 @@ public: bool IsUseThumbnailSave() const { return m_bUseThumbnailSave;} - std::vector< CustomProperty* > GetCustomProperties() const; + std::vector< std::unique_ptr<CustomProperty> > GetCustomProperties() const; void ClearCustomProperties(); void AddCustomProperty( const OUString& sName, const css::uno::Any& rValue ); @@ -402,7 +403,7 @@ private: sal_Int32 m_nTypeBoxWidth; sal_Int32 m_nLineHeight; sal_Int32 m_nScrollPos; - std::vector<CustomProperty*> m_aCustomProperties; + std::vector<std::unique_ptr<CustomProperty>> m_aCustomProperties; std::vector<CustomPropertyLine*> m_aCustomPropertiesLines; CustomPropertyLine* m_pCurrentLine; SvNumberFormatter m_aNumberFormatter; @@ -455,7 +456,7 @@ public: css::uno::Sequence< css::beans::PropertyValue > GetCustomProperties(); - void SetCustomProperties(const std::vector<CustomProperty*>& rProperties); + void SetCustomProperties(std::vector< std::unique_ptr<CustomProperty> >&& rProperties); void SetRemovedHdl( const Link<void*,void>& rLink ) { m_aRemovedHdl = rLink; } }; @@ -488,7 +489,7 @@ public: css::uno::Sequence<css::beans::PropertyValue> GetCustomProperties() const { return m_pPropertiesWin->GetCustomProperties(); } - void SetCustomProperties(const std::vector<CustomProperty*>& rProperties); + void SetCustomProperties(std::vector< std::unique_ptr<CustomProperty> >&& rProperties); void Init(VclBuilderContainer& rParent); virtual void Resize() override; diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index f5d2ce07a86e..84ebee9d8c62 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -248,8 +248,8 @@ SfxDocumentInfoItem::SfxDocumentInfoItem( const OUString& rFile, } uno::Any aValue = xSet->getPropertyValue(pProps[i].Name); - CustomProperty* pProp = new CustomProperty( pProps[i].Name, aValue ); - m_aCustomProperties.push_back( pProp ); + std::unique_ptr<CustomProperty> pProp(new CustomProperty( pProps[i].Name, aValue )); + m_aCustomProperties.push_back( std::move(pProp) ); } } @@ -284,11 +284,11 @@ SfxDocumentInfoItem::SfxDocumentInfoItem( const SfxDocumentInfoItem& rItem ) , m_bUseUserData( rItem.m_bUseUserData ) , m_bUseThumbnailSave( rItem.m_bUseThumbnailSave ) { - for (const CustomProperty* pOtherProp : rItem.m_aCustomProperties) + for (auto const & pOtherProp : rItem.m_aCustomProperties) { - CustomProperty* pProp = new CustomProperty( pOtherProp->m_sName, - pOtherProp->m_aValue ); - m_aCustomProperties.push_back( pProp ); + std::unique_ptr<CustomProperty> pProp(new CustomProperty( pOtherProp->m_sName, + pOtherProp->m_aValue )); + m_aCustomProperties.push_back( std::move(pProp) ); } m_aCmisProperties = rItem.m_aCmisProperties; @@ -402,7 +402,7 @@ void SfxDocumentInfoItem::UpdateDocumentInfo( } } - for (const CustomProperty* pProp : m_aCustomProperties) + for (auto const & pProp : m_aCustomProperties) { try { @@ -438,14 +438,14 @@ void SfxDocumentInfoItem::SetUseThumbnailSave( bool bSet ) m_bUseThumbnailSave = bSet; } -std::vector< CustomProperty* > SfxDocumentInfoItem::GetCustomProperties() const +std::vector< std::unique_ptr<CustomProperty> > SfxDocumentInfoItem::GetCustomProperties() const { - std::vector< CustomProperty* > aRet; - for (CustomProperty* pOtherProp : m_aCustomProperties) + std::vector< std::unique_ptr<CustomProperty> > aRet; + for (auto const & pOtherProp : m_aCustomProperties) { - CustomProperty* pProp = new CustomProperty( pOtherProp->m_sName, - pOtherProp->m_aValue ); - aRet.push_back( pProp ); + std::unique_ptr<CustomProperty> pProp(new CustomProperty( pOtherProp->m_sName, + pOtherProp->m_aValue )); + aRet.push_back( std::move(pProp) ); } return aRet; @@ -453,15 +453,13 @@ std::vector< CustomProperty* > SfxDocumentInfoItem::GetCustomProperties() const void SfxDocumentInfoItem::ClearCustomProperties() { - for (CustomProperty* pProp : m_aCustomProperties) - delete pProp; m_aCustomProperties.clear(); } void SfxDocumentInfoItem::AddCustomProperty( const OUString& sName, const Any& rValue ) { - CustomProperty* pProp = new CustomProperty( sName, rValue ); - m_aCustomProperties.push_back( pProp ); + std::unique_ptr<CustomProperty> pProp(new CustomProperty( sName, rValue )); + m_aCustomProperties.push_back( std::move(pProp) ); } @@ -1702,7 +1700,7 @@ void CustomPropertiesWindow::SetVisibleLineCount(sal_uInt32 nCount) void CustomPropertiesWindow::AddLine(const OUString& sName, Any const & rAny) { - m_aCustomProperties.push_back(new CustomProperty(sName, rAny)); + m_aCustomProperties.push_back(std::unique_ptr<CustomProperty>(new CustomProperty(sName, rAny))); ReloadLinesContent(); } @@ -1864,9 +1862,9 @@ void CustomPropertiesWindow::StoreCustomProperties() } } -void CustomPropertiesWindow::SetCustomProperties(const std::vector<CustomProperty*>& rProperties) +void CustomPropertiesWindow::SetCustomProperties(std::vector< std::unique_ptr<CustomProperty> >&& rProperties) { - m_aCustomProperties = rProperties; + m_aCustomProperties = std::move(rProperties); ReloadLinesContent(); } @@ -2107,9 +2105,9 @@ void CustomPropertiesControl::AddLine( Any const & rAny ) m_pVertScroll->DoScroll(nLineCount + 1); } -void CustomPropertiesControl::SetCustomProperties(const std::vector<CustomProperty*>& rProperties) +void CustomPropertiesControl::SetCustomProperties(std::vector< std::unique_ptr<CustomProperty> >&& rProperties) { - m_pPropertiesWin->SetCustomProperties(rProperties); + m_pPropertiesWin->SetCustomProperties(std::move(rProperties)); long nLineCount = m_pPropertiesWin->GetTotalLineCount(); m_pVertScroll->SetRangeMax(nLineCount + 1); } @@ -2209,8 +2207,8 @@ void SfxCustomPropertiesPage::Reset( const SfxItemSet* rItemSet ) { m_pPropertiesCtrl->ClearAllLines(); const SfxDocumentInfoItem& rInfoItem = rItemSet->Get(SID_DOCINFO); - std::vector< CustomProperty* > aCustomProps = rInfoItem.GetCustomProperties(); - m_pPropertiesCtrl->SetCustomProperties(aCustomProps); + std::vector< std::unique_ptr<CustomProperty> > aCustomProps = rInfoItem.GetCustomProperties(); + m_pPropertiesCtrl->SetCustomProperties(std::move(aCustomProps)); } DeactivateRC SfxCustomPropertiesPage::DeactivatePage( SfxItemSet* /*pSet*/ ) |