diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-06-05 07:53:03 +0530 |
---|---|---|
committer | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-06-06 09:36:26 +0000 |
commit | cf81f59455ec0aa73f8d3e71ba7f39725ca77139 (patch) | |
tree | 9e5d1981f7109f347fb75bc5cef9df1450629193 /sfx2 | |
parent | 7d351e021aadbf2c75be35a9b1db5185b7f2a7c6 (diff) |
tdf#94131 Easier access to set a default template when saving a template
Change-Id: I2a3732a178f47ce49c77089a6e0865b609efd499
Reviewed-on: https://gerrit.libreoffice.org/25916
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
(cherry picked from commit f944195baabfda068cc37bd4e8ddf60e6cc990b7)
Reviewed-on: https://gerrit.libreoffice.org/25957
Reviewed-by: Akshay Deep <akshaydeepiitr@gmail.com>
Tested-by: Akshay Deep <akshaydeepiitr@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/saveastemplatedlg.cxx | 33 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/saveastemplatedlg.ui | 18 |
2 files changed, 48 insertions, 3 deletions
diff --git a/sfx2/source/doc/saveastemplatedlg.cxx b/sfx2/source/doc/saveastemplatedlg.cxx index beef6e60b3e8..315f8978ce48 100644 --- a/sfx2/source/doc/saveastemplatedlg.cxx +++ b/sfx2/source/doc/saveastemplatedlg.cxx @@ -11,13 +11,20 @@ #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> +#include <comphelper/storagehelper.hxx> #include <sfx2/sfxresid.hxx> +#include <sfx2/app.hxx> +#include <sfx2/fcontnr.hxx> +#include <sfx2/docfac.hxx> #include <sfx2/doctempl.hxx> +#include <sfx2/docfilt.hxx> #include <vcl/edit.hxx> #include <vcl/layout.hxx> #include <vcl/lstbox.hxx> +#include <sot/storage.hxx> #include <com/sun/star/frame/DocumentTemplates.hpp> +#include <com/sun/star/frame/XStorable.hpp> #include "doc.hrc" @@ -34,6 +41,7 @@ SfxSaveAsTemplateDialog::SfxSaveAsTemplateDialog( vcl::Window* pParent): mpDocTemplates(new SfxDocumentTemplates) { get(mpLBCategory, "categorylb"); + get(mpCBXDefault, "defaultcb"); get(mpTemplateNameEdit, "name_entry"); get(mpOKButton, "ok"); @@ -158,10 +166,33 @@ bool SfxSaveAsTemplateDialog::SaveTemplate() sal_uInt16 nDocId = mpDocTemplates->GetCount(mnRegionPos); OUString sURL = mpDocTemplates->GetTemplateTargetURLFromComponent(msSelectedCategory, msTemplateName); + bool bIsSaved = mpDocTemplates->InsertTemplate( mnRegionPos, nDocId, msTemplateName, sURL); - if(!mpDocTemplates->InsertTemplate( mnRegionPos, nDocId, msTemplateName, sURL)) + if (!bIsSaved) return false; + if ( !sURL.isEmpty() && mpCBXDefault->IsChecked() ) + { + OUString aServiceName; + try + { + uno::Reference< embed::XStorage > xStorage = + comphelper::OStorageHelper::GetStorageFromURL( sURL, embed::ElementModes::READ ); + + SotClipboardFormatId nFormat = SotStorage::GetFormatID( xStorage ); + + std::shared_ptr<const SfxFilter> pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4ClipBoardId( nFormat ); + + if ( pFilter ) + aServiceName = pFilter->GetServiceName(); + } + catch( uno::Exception& ) + {} + + if(!aServiceName.isEmpty()) + SfxObjectFactory::SetStandardTemplate(aServiceName, sURL); + } + mpDocTemplates->Update(); return true; } diff --git a/sfx2/uiconfig/ui/saveastemplatedlg.ui b/sfx2/uiconfig/ui/saveastemplatedlg.ui index da673a318b71..d8ff31ce728b 100644 --- a/sfx2/uiconfig/ui/saveastemplatedlg.ui +++ b/sfx2/uiconfig/ui/saveastemplatedlg.ui @@ -113,9 +113,9 @@ </child> <child> <object class="GtkEntry" id="name_entry"> + <property name="width_request">300</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="width_request">300</property> </object> <packing> <property name="expand">False</property> @@ -153,8 +153,8 @@ </child> <child> <object class="GtkTreeView" id="categorylb:border"> - <property name="height_request">150</property> <property name="width_request">300</property> + <property name="height_request">150</property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">2</property> @@ -175,6 +175,20 @@ <property name="top_attach">1</property> </packing> </child> + <child> + <object class="GtkCheckButton" id="defaultcb"> + <property name="label" translatable="yes">Set as Default Template</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> |