summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2013-03-28 20:40:48 -0430
committerMiklos Vajna <vmiklos@suse.cz>2013-04-08 07:38:58 +0000
commit17a9ea9ede3ff48d7c98f7b69d4ef63b1dc57b7a (patch)
tree8d2a1070a2d9d23ece5df7c8a823715bdde66c33 /sfx2
parente2f27811c404f29691f8c1158f3102fc5b18ae90 (diff)
Dont reload template information after saving.
Change-Id: Ib75bd4561581254f690e6dd4a2b83343c99d65af Reviewed-on: https://gerrit.libreoffice.org/3255 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/doctempl.hxx2
-rw-r--r--sfx2/inc/sfx2/templatelocalview.hxx2
-rw-r--r--sfx2/source/control/templatelocalview.cxx58
-rw-r--r--sfx2/source/doc/doctempl.cxx18
-rw-r--r--sfx2/source/doc/templatedlg.cxx2
5 files changed, 74 insertions, 8 deletions
diff --git a/sfx2/inc/sfx2/doctempl.hxx b/sfx2/inc/sfx2/doctempl.hxx
index b9ca56d70137..add39df0d603 100644
--- a/sfx2/inc/sfx2/doctempl.hxx
+++ b/sfx2/inc/sfx2/doctempl.hxx
@@ -96,6 +96,8 @@ public:
sal_Bool InsertDir(const String &rText, sal_uInt16 nRegion);
sal_Bool SetName(const String &rName, sal_uInt16 nRegion, sal_uInt16 nIdx);
+ 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 f17f0f897376..8490e374fce4 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 c6d32af162be..012fdba3d6d2 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 6678600c5cb4..dd09be0d640e 100644
--- a/sfx2/source/doc/doctempl.cxx
+++ b/sfx2/source/doc/doctempl.cxx
@@ -1098,6 +1098,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 94bbea654ab7..9cf663c71a7b 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1274,8 +1274,6 @@ void SfxTemplateManagerDlg::OnTemplateSaveAs()
}
}
- maView->reload();
-
if (!aFolderList.isEmpty())
{
}