diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-06-07 08:44:18 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-06-07 06:10:03 +0000 |
commit | 916b3e30099ee01f6c33ba01c7a8adc24cf965cc (patch) | |
tree | 07f7e666d257483b8e4e53cee385ab7f2e5ee244 /sfx2 | |
parent | 397ad4d4b844d0c1a24fceb20cde460554b9910f (diff) |
Reset Default in Context Menu for default templates
Change-Id: Ifedb4f5b4dada0e9e0ac40ffcaed4c2821df501d
Reviewed-on: https://gerrit.libreoffice.org/25995
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
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 | 1 | ||||
-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, 45 insertions, 16 deletions
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 5174778f6c9f..7b93c79f1cf3 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_DELETE,SfxResId(STR_DELETE).toString()); pItemMenu->InsertItem(MNI_RENAME,SfxResId(STR_RENAME).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 c802ccc7fce6..830435d423f0 100644 --- a/sfx2/source/doc/doc.hrc +++ b/sfx2/source/doc/doc.hrc @@ -124,6 +124,7 @@ #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 84c94560e48d..ca4a1329fbff 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 fbd89673aa4d..fe51702eaa12 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -752,9 +752,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()); } } } @@ -854,19 +854,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, |