diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-06-07 08:44:18 +0530 |
---|---|---|
committer | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-06-08 14:30:34 +0000 |
commit | e14f7bcfafe951a6b59a6635865fb31ae9c259bd (patch) | |
tree | e4c7bc120edbbfa9d1dc95a65e67c09832a8aea3 /sfx2 | |
parent | 6efb6fa31270adc84b5884cd4a84e1a3296d535d (diff) |
Reset Default in Context Menu for default templates
Reviewed-on: https://gerrit.libreoffice.org/25995
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Conflicts:
include/sfx2/templateabstractview.hxx
sfx2/source/doc/doc.hrc
Conflicts:
include/sfx2/templateabstractview.hxx
Change-Id: Ifedb4f5b4dada0e9e0ac40ffcaed4c2821df501d
Reviewed-on: https://gerrit.libreoffice.org/26068
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Akshay Deep <akshaydeepiitr@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/control/templatesearchview.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/doc/doc.hrc | 2 | ||||
-rw-r--r-- | sfx2/source/doc/doc.src | 4 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 33 | ||||
-rw-r--r-- | sfx2/source/inc/templatesearchview.hxx | 2 |
6 files changed, 46 insertions, 16 deletions
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index bd1245b174ac..0722eb12db61 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -178,12 +178,17 @@ TemplateContainerItem* TemplateLocalView::getRegion(OUString const & rName) return nullptr; } -void TemplateLocalView::createContextMenu() +void TemplateLocalView::createContextMenu(const bool bIsDefault) { std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu); pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString()); pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString()); - pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString()); + + if(!bIsDefault) + pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString()); + else + pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_RESET_DEFAULT).toString()); + pItemMenu->InsertSeparator(); pItemMenu->InsertItem(MNI_RENAME,SfxResId(STR_RENAME).toString()); pItemMenu->InsertItem(MNI_DELETE,SfxResId(STR_DELETE).toString()); diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx index 3075d4087a67..e5754d998391 100644 --- a/sfx2/source/control/templatesearchview.cxx +++ b/sfx2/source/control/templatesearchview.cxx @@ -53,12 +53,17 @@ void TemplateSearchView::MouseButtonDown( const MouseEvent& rMEvt ) ThumbnailView::MouseButtonDown(rMEvt); } -void TemplateSearchView::createContextMenu() +void TemplateSearchView::createContextMenu( const bool bIsDefault) { std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu); pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString()); pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString()); - pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString()); + + if(!bIsDefault) + pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString()); + else + pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_RESET_DEFAULT).toString()); + pItemMenu->InsertSeparator(); pItemMenu->InsertItem(MNI_DELETE,SfxResId(STR_DELETE).toString()); maSelectedItem->setSelection(true); @@ -141,6 +146,9 @@ void TemplateSearchView::AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionI pItem->setHelpText(rSubtitle); pItem->setPath(rPath); + if(TemplateAbstractView::IsDefaultTemplate(rPath)) + pItem->showDefaultIcon(true); + ThumbnailView::AppendItem(pItem); CalculateItemPositions(); diff --git a/sfx2/source/doc/doc.hrc b/sfx2/source/doc/doc.hrc index 6d501ca35fac..ea4bc30c342f 100644 --- a/sfx2/source/doc/doc.hrc +++ b/sfx2/source/doc/doc.hrc @@ -125,6 +125,8 @@ #define STR_CREATE_ERROR (RID_SFX_DOC_START+103) #define STR_ERROR_SAVEAS (RID_SFX_DOC_START+105) #define STR_CATEGORY_RENAME (RID_SFX_DOC_START+109) +#define STR_TEMPLATE_SELECTION (RID_SFX_DOC_START+120) +#define STR_RESET_DEFAULT (RID_SFX_DOC_START+122) // please update to the last id #define ACT_SFX_DOC_END IMG_ACTION_REFRESH diff --git a/sfx2/source/doc/doc.src b/sfx2/source/doc/doc.src index ed7f8db4a52e..eb8a5ae14408 100644 --- a/sfx2/source/doc/doc.src +++ b/sfx2/source/doc/doc.src @@ -60,6 +60,10 @@ String STR_DEFAULT_TEMPLATE { Text [ en-US ] = "Set As Default" ; }; +String STR_RESET_DEFAULT +{ + Text [ en-US ] = "Reset Default" ; +}; String STR_DELETE { Text [ en-US ] = "Delete" ; diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 7bc2dda05fdc..ad4683a1e581 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -750,9 +750,9 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, RightClickHdl, ThumbnailViewItem*, pItem, if(mpCurView == mpLocalView) { if(mpSearchView->IsVisible()) - mpSearchView->createContextMenu(); + mpSearchView->createContextMenu(pViewItem->IsDefaultTemplate()); else - mpLocalView->createContextMenu(); + mpLocalView->createContextMenu(pViewItem->IsDefaultTemplate()); } } } @@ -852,19 +852,30 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, DeleteTemplateHdl, ThumbnailViewItem*, pI IMPL_LINK_TYPED(SfxTemplateManagerDlg, DefaultTemplateHdl, ThumbnailViewItem*, pItem, void) { TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem); - OUString aServiceName; - if (lcl_getServiceName(pViewItem->getPath(),aServiceName)) - { - OUString sPrevDefault = SfxObjectFactory::GetStandardTemplate( aServiceName ); - if(!sPrevDefault.isEmpty()) - mpLocalView->RemoveDefaultTemplateIcon(sPrevDefault); - SfxObjectFactory::SetStandardTemplate(aServiceName,pViewItem->getPath()); - pViewItem->showDefaultIcon(true); + if(!pViewItem->IsDefaultTemplate()) + { + if (lcl_getServiceName(pViewItem->getPath(),aServiceName)) + { + OUString sPrevDefault = SfxObjectFactory::GetStandardTemplate( aServiceName ); + if(!sPrevDefault.isEmpty()) + mpLocalView->RemoveDefaultTemplateIcon(sPrevDefault); - createDefaultTemplateMenu(); + SfxObjectFactory::SetStandardTemplate(aServiceName,pViewItem->getPath()); + pViewItem->showDefaultIcon(true); + } + } + else + { + if(lcl_getServiceName(pViewItem->getPath(),aServiceName)) + { + SfxObjectFactory::SetStandardTemplate( aServiceName, OUString() ); + pViewItem->showDefaultIcon(false); + } } + + createDefaultTemplateMenu(); } IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SearchUpdateHdl, Edit&, void) diff --git a/sfx2/source/inc/templatesearchview.hxx b/sfx2/source/inc/templatesearchview.hxx index 7a4fdb52d5e6..e6f75f4bb422 100644 --- a/sfx2/source/inc/templatesearchview.hxx +++ b/sfx2/source/inc/templatesearchview.hxx @@ -33,7 +33,7 @@ public: void setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); - void createContextMenu(); + void createContextMenu(const bool bIsDefault); void AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx, const OUString &rTitle, const OUString &rSubtitle, |