Kaydet (Commit) 7068b56b authored tarafından Michael Stahl's avatar Michael Stahl

vcl: replace boost::ptr_vector with std::vector<std::unique_ptr>

Change-Id: I11bd73ff134895d05c7ce054b5ef26829a3bf8c3
üst 218be53f
...@@ -20,11 +20,13 @@ ...@@ -20,11 +20,13 @@
#ifndef INCLUDED_VCL_BTNDLG_HXX #ifndef INCLUDED_VCL_BTNDLG_HXX
#define INCLUDED_VCL_BTNDLG_HXX #define INCLUDED_VCL_BTNDLG_HXX
#include <boost/ptr_container/ptr_vector.hpp>
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <vcl/dialog.hxx> #include <vcl/dialog.hxx>
#include <o3tl/typed_flags_set.hxx> #include <o3tl/typed_flags_set.hxx>
#include <vector>
#include <memory>
struct ImplBtnDlgItem; struct ImplBtnDlgItem;
class PushButton; class PushButton;
...@@ -81,7 +83,7 @@ private: ...@@ -81,7 +83,7 @@ private:
ButtonDialog& operator=( const ButtonDialog& ) SAL_DELETED_FUNCTION; ButtonDialog& operator=( const ButtonDialog& ) SAL_DELETED_FUNCTION;
private: private:
boost::ptr_vector<ImplBtnDlgItem> maItemList; std::vector<std::unique_ptr<ImplBtnDlgItem>> m_ItemList;
Size maPageSize; Size maPageSize;
Size maCtrlSize; Size maCtrlSize;
long mnButtonSize; long mnButtonSize;
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#include <vcl/button.hxx> #include <vcl/button.hxx>
#include <vcl/btndlg.hxx> #include <vcl/btndlg.hxx>
typedef boost::ptr_vector<ImplBtnDlgItem>::iterator btn_iterator;
typedef boost::ptr_vector<ImplBtnDlgItem>::const_iterator btn_const_iterator;
struct ImplBtnDlgItem struct ImplBtnDlgItem
{ {
...@@ -64,12 +62,12 @@ ButtonDialog::~ButtonDialog() ...@@ -64,12 +62,12 @@ ButtonDialog::~ButtonDialog()
void ButtonDialog::dispose() void ButtonDialog::dispose()
{ {
for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it) for (auto & it : m_ItemList)
{ {
if ( it->mbOwnButton ) if ( it->mbOwnButton )
it->mpPushButton.disposeAndClear(); it->mpPushButton.disposeAndClear();
} }
maItemList.clear(); m_ItemList.clear();
Dialog::dispose(); Dialog::dispose();
} }
...@@ -97,7 +95,7 @@ VclPtr<PushButton> ButtonDialog::ImplCreatePushButton( ButtonDialogFlags nBtnFla ...@@ -97,7 +95,7 @@ VclPtr<PushButton> ButtonDialog::ImplCreatePushButton( ButtonDialogFlags nBtnFla
ImplBtnDlgItem* ButtonDialog::ImplGetItem( sal_uInt16 nId ) const ImplBtnDlgItem* ButtonDialog::ImplGetItem( sal_uInt16 nId ) const
{ {
for ( btn_const_iterator it = maItemList.begin(); it != maItemList.end(); ++it) for (auto & it : m_ItemList)
{ {
if (it->mnId == nId) if (it->mnId == nId)
return const_cast<ImplBtnDlgItem*>(&(*it)); return const_cast<ImplBtnDlgItem*>(&(*it));
...@@ -116,7 +114,7 @@ long ButtonDialog::ImplGetButtonSize() ...@@ -116,7 +114,7 @@ long ButtonDialog::ImplGetButtonSize()
long nSepSize = 0; long nSepSize = 0;
maCtrlSize = Size( IMPL_MINSIZE_BUTTON_WIDTH, IMPL_MINSIZE_BUTTON_HEIGHT ); maCtrlSize = Size( IMPL_MINSIZE_BUTTON_WIDTH, IMPL_MINSIZE_BUTTON_HEIGHT );
for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it) for (auto & it : m_ItemList)
{ {
nSepSize += nLastSepSize; nSepSize += nLastSepSize;
...@@ -140,7 +138,7 @@ long ButtonDialog::ImplGetButtonSize() ...@@ -140,7 +138,7 @@ long ButtonDialog::ImplGetButtonSize()
nLastSepSize = IMPL_SEP_BUTTON_Y; nLastSepSize = IMPL_SEP_BUTTON_Y;
} }
long nButtonCount = maItemList.size(); size_t const nButtonCount = m_ItemList.size();
if ( GetStyle() & WB_HORZ ) if ( GetStyle() & WB_HORZ )
mnButtonSize = nSepSize + (nButtonCount*maCtrlSize.Width()); mnButtonSize = nSepSize + (nButtonCount*maCtrlSize.Width());
...@@ -192,7 +190,7 @@ void ButtonDialog::ImplPosControls() ...@@ -192,7 +190,7 @@ void ButtonDialog::ImplPosControls()
} }
// Arrange PushButtons // Arrange PushButtons
for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it) for (auto & it : m_ItemList)
{ {
if ( GetStyle() & WB_HORZ ) if ( GetStyle() & WB_HORZ )
nX += it->mnSepSize; nX += it->mnSepSize;
...@@ -215,7 +213,7 @@ void ButtonDialog::ImplPosControls() ...@@ -215,7 +213,7 @@ void ButtonDialog::ImplPosControls()
IMPL_LINK( ButtonDialog, ImplClickHdl, PushButton*, pBtn ) IMPL_LINK( ButtonDialog, ImplClickHdl, PushButton*, pBtn )
{ {
for ( btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it) for (auto & it : m_ItemList)
{ {
if ( it->mpPushButton == pBtn ) if ( it->mpPushButton == pBtn )
{ {
...@@ -237,7 +235,7 @@ void ButtonDialog::StateChanged( StateChangedType nType ) ...@@ -237,7 +235,7 @@ void ButtonDialog::StateChanged( StateChangedType nType )
if ( nType == StateChangedType::InitShow ) if ( nType == StateChangedType::InitShow )
{ {
ImplPosControls(); ImplPosControls();
for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it) for (auto & it : m_ItemList)
{ {
if ( it->mpPushButton && it->mbOwnButton ) if ( it->mpPushButton && it->mbOwnButton )
it->mpPushButton->SetZOrder(0, ZOrderFlags::Last); it->mpPushButton->SetZOrder(0, ZOrderFlags::Last);
...@@ -246,7 +244,7 @@ void ButtonDialog::StateChanged( StateChangedType nType ) ...@@ -246,7 +244,7 @@ void ButtonDialog::StateChanged( StateChangedType nType )
// Set focus on default button. // Set focus on default button.
if ( mnFocusButtonId != BUTTONDIALOG_BUTTON_NOTFOUND ) if ( mnFocusButtonId != BUTTONDIALOG_BUTTON_NOTFOUND )
{ {
for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it) for (auto & it : m_ItemList)
{ {
if (it->mnId == mnFocusButtonId ) if (it->mnId == mnFocusButtonId )
{ {
...@@ -277,7 +275,7 @@ void ButtonDialog::AddButton( const OUString& rText, sal_uInt16 nId, ...@@ -277,7 +275,7 @@ void ButtonDialog::AddButton( const OUString& rText, sal_uInt16 nId,
ButtonDialogFlags nBtnFlags, long nSepPixel ) ButtonDialogFlags nBtnFlags, long nSepPixel )
{ {
// PageItem anlegen // PageItem anlegen
ImplBtnDlgItem* pItem = new ImplBtnDlgItem; std::unique_ptr<ImplBtnDlgItem> pItem(new ImplBtnDlgItem);
pItem->mnId = nId; pItem->mnId = nId;
pItem->mbOwnButton = true; pItem->mbOwnButton = true;
pItem->mnSepSize = nSepPixel; pItem->mnSepSize = nSepPixel;
...@@ -286,7 +284,7 @@ void ButtonDialog::AddButton( const OUString& rText, sal_uInt16 nId, ...@@ -286,7 +284,7 @@ void ButtonDialog::AddButton( const OUString& rText, sal_uInt16 nId,
if (!rText.isEmpty()) if (!rText.isEmpty())
pItem->mpPushButton->SetText( rText ); pItem->mpPushButton->SetText( rText );
maItemList.push_back(pItem); m_ItemList.push_back(std::move(pItem));
if ( nBtnFlags & ButtonDialogFlags::Focus ) if ( nBtnFlags & ButtonDialogFlags::Focus )
mnFocusButtonId = nId; mnFocusButtonId = nId;
...@@ -298,7 +296,7 @@ void ButtonDialog::AddButton( StandardButtonType eType, sal_uInt16 nId, ...@@ -298,7 +296,7 @@ void ButtonDialog::AddButton( StandardButtonType eType, sal_uInt16 nId,
ButtonDialogFlags nBtnFlags, long nSepPixel ) ButtonDialogFlags nBtnFlags, long nSepPixel )
{ {
// PageItem anlegen // PageItem anlegen
ImplBtnDlgItem* pItem = new ImplBtnDlgItem; std::unique_ptr<ImplBtnDlgItem> pItem(new ImplBtnDlgItem);
pItem->mnId = nId; pItem->mnId = nId;
pItem->mbOwnButton = true; pItem->mbOwnButton = true;
pItem->mnSepSize = nSepPixel; pItem->mnSepSize = nSepPixel;
...@@ -322,23 +320,24 @@ void ButtonDialog::AddButton( StandardButtonType eType, sal_uInt16 nId, ...@@ -322,23 +320,24 @@ void ButtonDialog::AddButton( StandardButtonType eType, sal_uInt16 nId,
if ( nBtnFlags & ButtonDialogFlags::Focus ) if ( nBtnFlags & ButtonDialogFlags::Focus )
mnFocusButtonId = nId; mnFocusButtonId = nId;
maItemList.push_back(pItem); m_ItemList.push_back(std::move(pItem));
mbFormat = true; mbFormat = true;
} }
void ButtonDialog::RemoveButton( sal_uInt16 nId ) void ButtonDialog::RemoveButton( sal_uInt16 nId )
{ {
for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it) for (std::vector<std::unique_ptr<ImplBtnDlgItem>>::iterator it
= m_ItemList.begin(); it != m_ItemList.end(); ++it)
{ {
if (it->mnId == nId) if ((*it)->mnId == nId)
{ {
it->mpPushButton->Hide(); (*it)->mpPushButton->Hide();
if (it->mbOwnButton) if ((*it)->mbOwnButton)
it->mpPushButton.disposeAndClear(); (*it)->mpPushButton.disposeAndClear();
else else
it->mpPushButton.clear(); (*it)->mpPushButton.clear();
maItemList.erase(it); m_ItemList.erase(it);
return; return;
} }
} }
...@@ -348,21 +347,21 @@ void ButtonDialog::RemoveButton( sal_uInt16 nId ) ...@@ -348,21 +347,21 @@ void ButtonDialog::RemoveButton( sal_uInt16 nId )
void ButtonDialog::Clear() void ButtonDialog::Clear()
{ {
for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it) for (auto & it : m_ItemList)
{ {
it->mpPushButton->Hide(); it->mpPushButton->Hide();
if (it->mbOwnButton) if (it->mbOwnButton)
it->mpPushButton.disposeAndClear(); it->mpPushButton.disposeAndClear();
} }
maItemList.clear(); m_ItemList.clear();
mbFormat = true; mbFormat = true;
} }
sal_uInt16 ButtonDialog::GetButtonId( sal_uInt16 nButton ) const sal_uInt16 ButtonDialog::GetButtonId( sal_uInt16 nButton ) const
{ {
if ( nButton < maItemList.size() ) if ( nButton < m_ItemList.size() )
return maItemList[nButton].mnId; return m_ItemList[nButton]->mnId;
else else
return BUTTONDIALOG_BUTTON_NOTFOUND; return BUTTONDIALOG_BUTTON_NOTFOUND;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment