Delete selected templates when clicking delete toolbar button.

Change-Id: I4ad2ea913ab7a8f68b6010cedc8a2a2a72eea0bd
This commit is contained in:
Rafael Dominguez 2012-06-24 10:00:17 -04:30
parent 64f9aa20e2
commit 9cc086f462
3 changed files with 46 additions and 0 deletions

View file

@ -45,6 +45,8 @@ public:
void setTemplateStateHdl (const Link &aLink) { maTemplateStateHdl = aLink; }
bool removeTemplate (const sal_uInt16 nItemId);
void copyFrom (TemplateFolderViewItem *pItem, const rtl::OUString &rPath);
private:

View file

@ -342,6 +342,42 @@ void TemplateFolderView::filterTemplatesByApp (const FILTER_APPLICATION &eApp)
}
}
bool TemplateFolderView::removeTemplate (const sal_uInt16 nItemId)
{
sal_uInt16 nRegionId = mpItemView->getRegionId();
sal_uInt16 nItemRegionId = nRegionId + 1;
sal_uInt16 nTemplateId = nItemId - 1;
if (!mpDocTemplates->Delete(nRegionId,nTemplateId))
return false;
for (size_t i = 0, n = mItemList.size(); i < n; ++i)
{
if (mItemList[i]->mnId == nItemRegionId)
{
TemplateFolderViewItem *pItem = static_cast<TemplateFolderViewItem*>(mItemList[i]);
std::vector<TemplateViewItem*>::iterator pIter;
for (pIter = pItem->maTemplates.begin(); pIter != pItem->maTemplates.end(); ++pIter)
{
if ((*pIter)->mnId == nItemId)
{
delete *pIter;
pItem->maTemplates.erase(pIter);
mpItemView->RemoveItem(nItemId);
break;
}
}
break;
}
}
return true;
}
void TemplateFolderView::copyFrom (TemplateFolderViewItem *pItem, const rtl::OUString &rPath)
{
sal_uInt16 nId = 0;

View file

@ -381,6 +381,14 @@ void SfxTemplateManagerDlg::OnTemplateMove ()
void SfxTemplateManagerDlg::OnTemplateDelete ()
{
std::set<const ThumbnailViewItem*>::const_iterator pIter;
for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end();)
{
if (maView->removeTemplate((*pIter)->mnId))
maSelTemplates.erase(pIter++);
else
++pIter;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */