diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2012-08-14 21:17:51 -0430 |
---|---|---|
committer | Rafael Dominguez <venccsralph@gmail.com> | 2012-08-15 07:18:27 -0430 |
commit | e7721a2312b6bc81dbb33919feb065f33e2e61f6 (patch) | |
tree | eb74aef6cf4e1a50dd8d33d2ab1c99f8ff5f9a3a /sfx2 | |
parent | Show error message when trying to save without a destination folder (diff) | |
download | core-e7721a2312b6bc81dbb33919feb065f33e2e61f6.tar.gz core-e7721a2312b6bc81dbb33919feb065f33e2e61f6.zip |
Save a template to selected folders.
Change-Id: I16969fa0b28ff5f1e5abe7e58ad8522c03b3ea4e
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/templatelocalview.hxx | 10 | ||||
-rw-r--r-- | sfx2/inc/templatedlg.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 22 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 33 |
5 files changed, 70 insertions, 0 deletions
diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx index d59519699600..207e1e4f701c 100644 --- a/sfx2/inc/sfx2/templatelocalview.hxx +++ b/sfx2/inc/sfx2/templatelocalview.hxx @@ -18,6 +18,12 @@ class SfxDocumentTemplates; class TemplateLocalViewItem; +namespace com { + namespace sun { namespace star { namespace frame { + class XModel; + } } } +} + class SFX2_DLLPUBLIC TemplateLocalView : public TemplateAbstractView { public: @@ -57,6 +63,10 @@ public: bool exportTo (const sal_uInt16 nItemId, const sal_uInt16 nRegionItemId, const OUString &rName); + bool saveTemplateAs (const TemplateLocalViewItem *pDstItem, + com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel, + const OUString &rName); + private: virtual void OnItemDblClicked (ThumbnailViewItem *pRegionItem); diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx index 17596d924021..75fc4cff0cf3 100644 --- a/sfx2/inc/templatedlg.hxx +++ b/sfx2/inc/templatedlg.hxx @@ -29,6 +29,7 @@ class ToolBox; namespace com { namespace sun { namespace star { namespace frame { class XComponentLoader; + class XModel; } } } } @@ -40,6 +41,8 @@ public: ~SfxTemplateManagerDlg (); + void setDocumentModel (const com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel); + DECL_LINK(ViewAllHdl, void*); DECL_LINK(ViewDocsHdl, void*); DECL_LINK(ViewPresentsHdl, void*); @@ -135,6 +138,7 @@ private: std::set<const ThumbnailViewItem*> maSelTemplates; std::set<const ThumbnailViewItem*> maSelFolders; + com::sun::star::uno::Reference< com::sun::star::frame::XModel > m_xModel; com::sun::star::uno::Reference< com::sun::star::frame::XComponentLoader > mxDesktop; }; diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 4e47e1f071e6..ec8b3dc97eb4 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -22,10 +22,15 @@ #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/frame/DocumentTemplates.hpp> #include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/frame/XDocumentTemplates.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> +using namespace ::com::sun::star; +using namespace ::com::sun::star::frame; + void lcl_updateThumbnails (TemplateLocalViewItem *pItem); class FolderFilter_Application @@ -639,6 +644,23 @@ bool TemplateLocalView::exportTo(const sal_uInt16 nItemId, const sal_uInt16 nReg return false; } +bool TemplateLocalView::saveTemplateAs(const TemplateLocalViewItem *pDstItem, + com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel, + const OUString &rName) +{ + uno::Reference< frame::XStorable > xStorable(rModel, uno::UNO_QUERY_THROW ); + + uno::Reference< frame::XDocumentTemplates > xTemplates( + frame::DocumentTemplates::create(comphelper::getProcessComponentContext()) ); + + sal_uInt16 nRegionId = pDstItem->mnId-1; + + if (!xTemplates->storeTemplate(mpDocTemplates->GetRegionName(nRegionId),rName, xStorable )) + return false; + + return true; +} + void TemplateLocalView::OnItemDblClicked (ThumbnailViewItem *pRegionItem) { // Fill templates diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 352245a25dce..5f6bd77a06f1 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -804,6 +804,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) if ( aMiscOptions.IsExperimentalMode() ) { SfxTemplateManagerDlg aDlg(NULL); + aDlg.setDocumentModel(GetModel()); aDlg.Execute(); } else diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index f392feb426f7..c99cec385120 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -271,6 +271,11 @@ SfxTemplateManagerDlg::~SfxTemplateManagerDlg () delete mpTemplateDefaultMenu; } +void SfxTemplateManagerDlg::setDocumentModel(const uno::Reference<frame::XModel> &rModel) +{ + m_xModel = rModel; +} + IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewAllHdl) { mpCurView->filterTemplatesByApp(FILTER_APP_NONE); @@ -1101,6 +1106,8 @@ void SfxTemplateManagerDlg::OnRepositoryDelete() void SfxTemplateManagerDlg::OnTemplateSaveAs() { + assert(m_xModel); + if (!maView->isOverlayVisible() && maSelFolders.empty()) { ErrorBox(this, WB_OK,SfxResId(STR_MSG_ERROR_SELECT_FOLDER).toString()).Execute(); @@ -1115,6 +1122,32 @@ void SfxTemplateManagerDlg::OnTemplateSaveAs() if (!aName.isEmpty()) { + OUString aFolderList; + + if (maView->isOverlayVisible()) + { + } + else + { + std::set<const ThumbnailViewItem*>::const_iterator pIter; + for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter) + { + TemplateLocalViewItem *pItem = (TemplateLocalViewItem*)(*pIter); + if (!maView->saveTemplateAs(pItem,m_xModel,aName)) + { + if (aFolderList.isEmpty()) + aFolderList = (*pIter)->maTitle; + else + aFolderList = aFolderList + "\n" + (*pIter)->maTitle; + } + } + } + + maView->reload(); + + if (!aFolderList.isEmpty()) + { + } } } } |