diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2013-03-28 20:40:48 -0430 |
---|---|---|
committer | Rafael Dominguez <venccsralph@gmail.com> | 2013-03-28 20:47:58 -0430 |
commit | ba632715b0a2f610f4146e950898625481cb8d9c (patch) | |
tree | 9f5bb0d46a8f50c532fdabdb21baa26678d0900e /sfx2 | |
parent | 0d3906aa95e06f96efcf698d8926be0aae267b04 (diff) |
Dont reload template information after saving.
Change-Id: Id4170e500d92dc912087eac137f38d243c3c1372
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/doctempl.hxx | 2 | ||||
-rw-r--r-- | sfx2/inc/sfx2/templatelocalview.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 58 | ||||
-rw-r--r-- | sfx2/source/doc/doctempl.cxx | 18 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 2 |
5 files changed, 74 insertions, 8 deletions
diff --git a/sfx2/inc/sfx2/doctempl.hxx b/sfx2/inc/sfx2/doctempl.hxx index ee91fd4e916e..a84ac1195542 100644 --- a/sfx2/inc/sfx2/doctempl.hxx +++ b/sfx2/inc/sfx2/doctempl.hxx @@ -92,6 +92,8 @@ public: sal_Bool Delete(sal_uInt16 nRegion, sal_uInt16 nIdx); sal_Bool InsertDir(const String &rText, sal_uInt16 nRegion); + sal_Bool InsertTemplate (sal_uInt16 nSourceRegion, sal_uInt16 nIdx, const OUString &rName, const OUString &rPath); + /** Change the name of an entry or a directory \param rName diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx index b0d86aefbacc..2837ecab1be6 100644 --- a/sfx2/inc/sfx2/templatelocalview.hxx +++ b/sfx2/inc/sfx2/templatelocalview.hxx @@ -81,7 +81,7 @@ public: com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel, const OUString &rName); - bool saveTemplateAs (const TemplateContainerItem *pDstItem, + bool saveTemplateAs (TemplateContainerItem *pDstItem, com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel, const OUString &rName); diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index b6fcc50b44d0..90f928b4c0cd 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -695,21 +695,50 @@ bool TemplateLocalView::saveTemplateAs (sal_uInt16 nItemId, com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel, const OUString &rName) { - bool bRet = false; for (size_t i = 0, n = maRegions.size(); i < n; ++i) { if (maRegions[i]->mnId == nItemId) { - bRet = saveTemplateAs((const TemplateContainerItem*)maRegions[i],rModel,rName); - break; + uno::Reference< frame::XStorable > xStorable(rModel, uno::UNO_QUERY_THROW ); + + uno::Reference< frame::XDocumentTemplates > xTemplates( + frame::DocumentTemplates::create(comphelper::getProcessComponentContext()) ); + + if (!xTemplates->storeTemplate(mpDocTemplates->GetRegionName(maRegions[i]->mnRegionId),rName, xStorable )) + return false; + + sal_uInt16 nDocId = maRegions[i]->maTemplates.size(); + + OUString aURL = mpDocTemplates->GetTemplateTargetURLFromComponent(mpDocTemplates->GetRegionName(maRegions[i]->mnRegionId),rName); + + if(!mpDocTemplates->InsertTemplate(maRegions[i]->mnRegionId,nDocId,rName,aURL)) + return false; + + + TemplateItemProperties aTemplate; + aTemplate.aIsFolder = false; + aTemplate.nId = getNextItemId(); + aTemplate.nDocId = nDocId; + aTemplate.nRegionId = maRegions[i]->mnRegionId; + aTemplate.aName = rName; + aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(aURL, + TEMPLATE_THUMBNAIL_MAX_WIDTH, + TEMPLATE_THUMBNAIL_MAX_HEIGHT); + aTemplate.aPath = aURL; + + maRegions[i]->maTemplates.push_back(aTemplate); + + insertItem(aTemplate); + + return true; } } - return bRet; + return false; } -bool TemplateLocalView::saveTemplateAs(const TemplateContainerItem *pDstItem, +bool TemplateLocalView::saveTemplateAs(TemplateContainerItem *pDstItem, com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel, const OUString &rName) { @@ -721,6 +750,25 @@ bool TemplateLocalView::saveTemplateAs(const TemplateContainerItem *pDstItem, if (!xTemplates->storeTemplate(mpDocTemplates->GetRegionName(pDstItem->mnRegionId),rName, xStorable )) return false; + sal_uInt16 nDocId = pDstItem->maTemplates.size(); + OUString aURL = mpDocTemplates->GetTemplateTargetURLFromComponent(mpDocTemplates->GetRegionName(pDstItem->mnRegionId),rName); + + if(!mpDocTemplates->InsertTemplate(pDstItem->mnRegionId,nDocId,rName,aURL)) + return false; + + TemplateItemProperties aTemplate; + aTemplate.aIsFolder = false; + aTemplate.nId = pDstItem->maTemplates.empty() ? 1 : pDstItem->maTemplates.back().nId+1; + aTemplate.nDocId = nDocId; + aTemplate.nRegionId = pDstItem->mnRegionId; + aTemplate.aName = rName; + aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(aURL, + TEMPLATE_THUMBNAIL_MAX_WIDTH, + TEMPLATE_THUMBNAIL_MAX_HEIGHT); + aTemplate.aPath = aURL; + + pDstItem->maTemplates.push_back(aTemplate); + return true; } diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx index 8faa60a8cbc7..5132e70384d0 100644 --- a/sfx2/source/doc/doctempl.cxx +++ b/sfx2/source/doc/doctempl.cxx @@ -1037,6 +1037,24 @@ sal_Bool SfxDocumentTemplates::InsertDir return sal_False; } +sal_Bool SfxDocumentTemplates::InsertTemplate(sal_uInt16 nSourceRegion, sal_uInt16 nIdx, const OUString &rName, const OUString &rPath) +{ + DocTemplLocker_Impl aLocker( *pImp ); + + if ( ! pImp->Construct() ) + return sal_False; + + RegionData_Impl *pRegion = pImp->GetRegion( nSourceRegion ); + + if ( !pRegion ) + return sal_False; + + size_t pos = nIdx; + pRegion->AddEntry( rName, rPath, &pos ); + + return sal_True; +} + sal_Bool SfxDocumentTemplates::SetName( const OUString& rName, sal_uInt16 nRegion, sal_uInt16 nIdx ) { diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 5f13254385fd..f9e1d552c668 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -1286,8 +1286,6 @@ void SfxTemplateManagerDlg::OnTemplateSaveAs() } } - maView->reload(); - if (!aFolderList.isEmpty()) { } |