summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2012-08-10 20:28:40 -0430
committerRafael Dominguez <venccsralph@gmail.com>2012-08-11 19:57:42 -0430
commit4364513def9252cd57fac2585c72ba6ee6bf7248 (patch)
treeb67c0333443fc8ce12a347c89b92b4cd103897f7 /sfx2
parentcacba91215f22dad6ddaa055700f40da5b8e8811 (diff)
Delete template based on its document id.
- Update all document ids of the templates after it. Change-Id: I2ffc73882816360a03b8147c6ad24f8d87492ad7
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/templatelocalview.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 63a6739c8019..7049a947c26c 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -311,26 +311,28 @@ bool TemplateLocalView::removeRegion(const sal_uInt16 nItemId)
bool TemplateLocalView::removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId)
{
sal_uInt16 nRegionId = nSrcItemId - 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 == nSrcItemId)
{
-
TemplateLocalViewItem *pItem = static_cast<TemplateLocalViewItem*>(mItemList[i]);
std::vector<TemplateItemProperties>::iterator pIter;
for (pIter = pItem->maTemplates.begin(); pIter != pItem->maTemplates.end(); ++pIter)
{
if (pIter->nId == nItemId)
{
- pItem->maTemplates.erase(pIter);
+ if (!mpDocTemplates->Delete(nRegionId,pIter->nDocId))
+ return false;
+
+ pIter = pItem->maTemplates.erase(pIter);
mpItemView->RemoveItem(nItemId);
+ // Update Doc Idx for all templates that follow
+ for (; pIter != pItem->maTemplates.end(); ++pIter)
+ pIter->nDocId = pIter->nDocId - 1;
+
break;
}
}