Kaydet (Commit) c83bf01e authored tarafından Noel Grandin's avatar Noel Grandin

cui: boost::ptr_vector->std::vector<unique_ptr>

Change-Id: If2e8e7eddd5e75a211940416b4370c8f7768849e
üst d5f19eb6
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include "dialmgr.hxx" #include "dialmgr.hxx"
#include <svl/stritem.hxx> #include <svl/stritem.hxx>
#include <vcl/builderfactory.hxx> #include <vcl/builderfactory.hxx>
#include <o3tl/make_unique.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
...@@ -292,7 +293,7 @@ void SfxConfigFunctionListBox::ClearAll() ...@@ -292,7 +293,7 @@ void SfxConfigFunctionListBox::ClearAll()
sal_uInt16 nCount = aArr.size(); sal_uInt16 nCount = aArr.size();
for ( sal_uInt16 i=0; i<nCount; ++i ) for ( sal_uInt16 i=0; i<nCount; ++i )
{ {
SfxGroupInfo_Impl *pData = &aArr[i]; SfxGroupInfo_Impl *pData = aArr[i].get();
if ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT ) if ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
{ {
...@@ -427,7 +428,7 @@ void SfxConfigGroupListBox::ClearAll() ...@@ -427,7 +428,7 @@ void SfxConfigGroupListBox::ClearAll()
sal_uInt16 nCount = aArr.size(); sal_uInt16 nCount = aArr.size();
for ( sal_uInt16 i=0; i<nCount; ++i ) for ( sal_uInt16 i=0; i<nCount; ++i )
{ {
SfxGroupInfo_Impl *pData = &aArr[i]; SfxGroupInfo_Impl *pData = aArr[i].get();
if (pData->nKind == SfxCfgKind::GROUP_SCRIPTCONTAINER) if (pData->nKind == SfxCfgKind::GROUP_SCRIPTCONTAINER)
{ {
XInterface* xi = static_cast<XInterface *>(pData->pObject); XInterface* xi = static_cast<XInterface *>(pData->pObject);
...@@ -583,15 +584,12 @@ void SfxConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent ...@@ -583,15 +584,12 @@ void SfxConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
//get autodestructed and become invalid when accessed later. //get autodestructed and become invalid when accessed later.
rootNode->acquire(); rootNode->acquire();
SfxGroupInfo_Impl *pInfo = aArr.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_SCRIPTCONTAINER, 0,
new SfxGroupInfo_Impl( SfxCfgKind::GROUP_SCRIPTCONTAINER, 0, static_cast<void *>(rootNode.get())));
static_cast<void *>(rootNode.get()));
OUString aTitle(pImp->m_sDlgMacros); OUString aTitle(pImp->m_sDlgMacros);
SvTreeListEntry *pNewEntry = InsertEntry( aTitle ); SvTreeListEntry *pNewEntry = InsertEntry( aTitle );
pNewEntry->SetUserData( pInfo ); pNewEntry->SetUserData( aArr.back().get() );
pNewEntry->EnableChildrenOnDemand(); pNewEntry->EnableChildrenOnDemand();
aArr.push_back( pInfo );
} }
else else
{ {
...@@ -654,18 +652,16 @@ void SfxConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent ...@@ -654,18 +652,16 @@ void SfxConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
// get autodestructed and become invalid when accessed later. // get autodestructed and become invalid when accessed later.
theChild->acquire(); theChild->acquire();
SfxGroupInfo_Impl* pInfo =
new SfxGroupInfo_Impl(SfxCfgKind::GROUP_SCRIPTCONTAINER,
0, static_cast<void *>( theChild.get()));
Image aImage = GetImage( theChild, xCtx, bIsRootNode ); Image aImage = GetImage( theChild, xCtx, bIsRootNode );
SvTreeListEntry* pNewEntry = SvTreeListEntry* pNewEntry =
InsertEntry( uiName ); InsertEntry( uiName );
SetExpandedEntryBmp( pNewEntry, aImage ); SetExpandedEntryBmp( pNewEntry, aImage );
SetCollapsedEntryBmp( pNewEntry, aImage ); SetCollapsedEntryBmp( pNewEntry, aImage );
pNewEntry->SetUserData( pInfo ); aArr.push_back( o3tl::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_SCRIPTCONTAINER,
aArr.push_back( pInfo ); 0, static_cast<void *>( theChild.get())));
pNewEntry->SetUserData( aArr.back().get() );
if ( children[n]->hasChildNodes() ) if ( children[n]->hasChildNodes() )
{ {
...@@ -696,9 +692,8 @@ void SfxConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent ...@@ -696,9 +692,8 @@ void SfxConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
{ {
OUString sStyle( pImp->m_aStrGroupStyles ); OUString sStyle( pImp->m_aStrGroupStyles );
SvTreeListEntry *pEntry = InsertEntry( sStyle ); SvTreeListEntry *pEntry = InsertEntry( sStyle );
SfxGroupInfo_Impl *pInfo = new SfxGroupInfo_Impl( SfxCfgKind::GROUP_STYLES, 0, nullptr ); // TODO last parameter should contain user data aArr.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, nullptr ) ); // TODO last parameter should contain user data
aArr.push_back( pInfo ); pEntry->SetUserData( aArr.back().get() );
pEntry->SetUserData( pInfo );
pEntry->EnableChildrenOnDemand(); pEntry->EnableChildrenOnDemand();
} }
...@@ -899,7 +894,6 @@ void SfxConfigGroupListBox::GroupSelected() ...@@ -899,7 +894,6 @@ void SfxConfigGroupListBox::GroupSelected()
value >>= uri; value >>= uri;
OUString* pScriptURI = new OUString( uri ); OUString* pScriptURI = new OUString( uri );
SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl( SfxCfgKind::FUNCTION_SCRIPT, 0, pScriptURI );
Image aImage = GetImage( children[n], Reference< XComponentContext >(), false ); Image aImage = GetImage( children[n], Reference< XComponentContext >(), false );
SvTreeListEntry* pNewEntry = SvTreeListEntry* pNewEntry =
...@@ -907,12 +901,10 @@ void SfxConfigGroupListBox::GroupSelected() ...@@ -907,12 +901,10 @@ void SfxConfigGroupListBox::GroupSelected()
pFunctionListBox->SetExpandedEntryBmp( pNewEntry, aImage ); pFunctionListBox->SetExpandedEntryBmp( pNewEntry, aImage );
pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage ); pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage );
pGrpInfo->sCommand = uri; pFunctionListBox->aArr.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::FUNCTION_SCRIPT, 0, pScriptURI ));
pGrpInfo->sLabel = children[n]->getName(); pFunctionListBox->aArr.back()->sCommand = uri;
pNewEntry->SetUserData( pGrpInfo ); pFunctionListBox->aArr.back()->sLabel = children[n]->getName();
pNewEntry->SetUserData( pFunctionListBox->aArr.back().get() );
pFunctionListBox->aArr.push_back( pGrpInfo );
} }
} }
} }
...@@ -937,11 +929,10 @@ void SfxConfigGroupListBox::GroupSelected() ...@@ -937,11 +929,10 @@ void SfxConfigGroupListBox::GroupSelected()
{ {
SfxStyleInfo_Impl* pStyle = new SfxStyleInfo_Impl(*pIt); SfxStyleInfo_Impl* pStyle = new SfxStyleInfo_Impl(*pIt);
SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry( pStyle->sLabel ); SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry( pStyle->sLabel );
SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SfxCfgKind::GROUP_STYLES, 0, pStyle ); pFunctionListBox->aArr.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, pStyle ) );
pFunctionListBox->aArr.push_back( pGrpInfo ); pFunctionListBox->aArr.back()->sCommand = pStyle->sCommand;
pGrpInfo->sCommand = pStyle->sCommand; pFunctionListBox->aArr.back()->sLabel = pStyle->sLabel;
pGrpInfo->sLabel = pStyle->sLabel; pFuncEntry->SetUserData( pFunctionListBox->aArr.back().get() );
pFuncEntry->SetUserData( pGrpInfo );
} }
} }
break; break;
...@@ -1051,18 +1042,17 @@ void SfxConfigGroupListBox::RequestingChildren( SvTreeListEntry *pEntry ) ...@@ -1051,18 +1042,17 @@ void SfxConfigGroupListBox::RequestingChildren( SvTreeListEntry *pEntry )
*/ */
theChild->acquire(); theChild->acquire();
SfxGroupInfo_Impl* pGrpInfo =
new SfxGroupInfo_Impl(SfxCfgKind::GROUP_SCRIPTCONTAINER,
0, static_cast<void *>( theChild.get()));
Image aImage = GetImage( theChild, Reference< XComponentContext >(), false ); Image aImage = GetImage( theChild, Reference< XComponentContext >(), false );
SvTreeListEntry* pNewEntry = SvTreeListEntry* pNewEntry =
InsertEntry( theChild->getName(), pEntry ); InsertEntry( theChild->getName(), pEntry );
SetExpandedEntryBmp( pNewEntry, aImage ); SetExpandedEntryBmp( pNewEntry, aImage );
SetCollapsedEntryBmp(pNewEntry, aImage ); SetCollapsedEntryBmp(pNewEntry, aImage );
pNewEntry->SetUserData( pGrpInfo ); aArr.push_back( o3tl::make_unique<SfxGroupInfo_Impl>(
aArr.push_back( pGrpInfo ); SfxCfgKind::GROUP_SCRIPTCONTAINER,
0, static_cast<void *>( theChild.get())));
pNewEntry->SetUserData( aArr.back().get() );
if ( children[n]->hasChildNodes() ) if ( children[n]->hasChildNodes() )
{ {
...@@ -1101,9 +1091,8 @@ void SfxConfigGroupListBox::RequestingChildren( SvTreeListEntry *pEntry ) ...@@ -1101,9 +1091,8 @@ void SfxConfigGroupListBox::RequestingChildren( SvTreeListEntry *pEntry )
{ {
SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(*pIt); SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(*pIt);
SvTreeListEntry* pStyleEntry = InsertEntry( pFamily->sLabel, pEntry ); SvTreeListEntry* pStyleEntry = InsertEntry( pFamily->sLabel, pEntry );
SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SfxCfgKind::GROUP_STYLES, 0, pFamily ); aArr.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, pFamily ));
aArr.push_back( pGrpInfo ); pStyleEntry->SetUserData( aArr.back().get() );
pStyleEntry->SetUserData( pGrpInfo );
pStyleEntry->EnableChildrenOnDemand( false ); pStyleEntry->EnableChildrenOnDemand( false );
} }
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#define INCLUDED_CUI_SOURCE_INC_CFGUTIL_HXX #define INCLUDED_CUI_SOURCE_INC_CFGUTIL_HXX
#include <vector> #include <vector>
#include <boost/ptr_container/ptr_vector.hpp> #include <memory>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
...@@ -96,7 +96,7 @@ struct SfxGroupInfo_Impl ...@@ -96,7 +96,7 @@ struct SfxGroupInfo_Impl
nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(false) {} nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(false) {}
}; };
typedef boost::ptr_vector<SfxGroupInfo_Impl> SfxGroupInfoArr_Impl; typedef std::vector<std::unique_ptr<SfxGroupInfo_Impl> > SfxGroupInfoArr_Impl;
class SfxConfigFunctionListBox : public SvTreeListBox class SfxConfigFunctionListBox : public SvTreeListBox
{ {
......
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