diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-05-27 17:13:27 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-05-27 13:21:49 +0000 |
commit | 37b4163ce16a6171bd25653494e58bc03daedc2b (patch) | |
tree | 89abde4b2613b2ab75caed819e55315107906261 /sfx2 | |
parent | 850a8d27ca696f18ce0c529346f8bb8505499545 (diff) |
Template Manager: Option to rename category
Change-Id: I7a9a0a42afbf5f8a293a130a0b84e72a54540579
Reviewed-on: https://gerrit.libreoffice.org/25539
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 | 13 | ||||
-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 | 53 |
4 files changed, 68 insertions, 3 deletions
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index f985d3cfffad..fdc4ca3f6b2d 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -331,6 +331,19 @@ sal_uInt16 TemplateLocalView::createRegion(const OUString &rName) return pItem->mnId; } +bool TemplateLocalView::renameRegion(const OUString &rTitle, const OUString &rNewTitle) +{ + sal_uInt16 nDocId = USHRT_MAX; + TemplateContainerItem *pRegion = getRegion(rTitle); + + if(pRegion) + { + sal_uInt16 nRegionId = pRegion->mnRegionId; + return mpDocTemplates->SetName( rNewTitle, nRegionId, nDocId ); + } + return false; +} + bool TemplateLocalView::removeRegion(const sal_uInt16 nItemId) { sal_uInt16 nRegionId = USHRT_MAX; diff --git a/sfx2/source/doc/doc.hrc b/sfx2/source/doc/doc.hrc index a8abbe57e261..6d501ca35fac 100644 --- a/sfx2/source/doc/doc.hrc +++ b/sfx2/source/doc/doc.hrc @@ -124,6 +124,7 @@ #define STR_CATEGORY_DELETE (RID_SFX_DOC_START+101) #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) // 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 cab02ce0e62f..ed7f8db4a52e 100644 --- a/sfx2/source/doc/doc.src +++ b/sfx2/source/doc/doc.src @@ -68,6 +68,10 @@ String STR_RENAME { Text [ en-US ] = "Rename" ; }; +String STR_CATEGORY_RENAME +{ + Text [ en-US ] = "Rename Category" ; +}; String STR_PROPERTIES { Text [ en-US ] = "Properties" ; diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 156e0c2b5948..b2b7b75d7177 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -71,9 +71,10 @@ const char VIEWBAR_REPOSITORY[] = "repository"; const char ACTIONBAR_ACTION[] = "action_menu"; #define MNI_ACTION_NEW_FOLDER 1 -#define MNI_ACTION_DELETE_FOLDER 2 -#define MNI_ACTION_REFRESH 3 -#define MNI_ACTION_DEFAULT 3 +#define MNI_ACTION_RENAME_FOLDER 2 +#define MNI_ACTION_DELETE_FOLDER 3 +#define MNI_ACTION_REFRESH 4 +#define MNI_ACTION_DEFAULT 5 #define MNI_REPOSITORY_LOCAL 1 #define MNI_REPOSITORY_NEW 2 #define MNI_REPOSITORY_BASE 3 @@ -185,6 +186,8 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent) mpActionMenu->InsertItem(MNI_ACTION_NEW_FOLDER, SfxResId(STR_CATEGORY_NEW).toString(), Image(SfxResId(IMG_ACTION_REFRESH))); + mpActionMenu->InsertItem(MNI_ACTION_RENAME_FOLDER, + SfxResId(STR_CATEGORY_RENAME).toString()); mpActionMenu->InsertItem(MNI_ACTION_DELETE_FOLDER, SfxResId(STR_CATEGORY_DELETE).toString()); mpActionMenu->InsertSeparator(); @@ -567,6 +570,9 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, MenuSelectHdl, Menu*, pMenu, bool) case MNI_ACTION_NEW_FOLDER: OnCategoryNew(); break; + case MNI_ACTION_RENAME_FOLDER: + OnCategoryRename(); + break; case MNI_ACTION_DELETE_FOLDER: OnCategoryDelete(); break; @@ -1207,6 +1213,47 @@ void SfxTemplateManagerDlg::OnCategoryNew() } } +void SfxTemplateManagerDlg::OnCategoryRename() +{ + ScopedVclPtrInstance< SfxTemplateCategoryDialog > aDlg; + aDlg->SetCategoryLBEntries(mpLocalView->getFolderNames()); + aDlg->HideNewCategoryOption(); + aDlg->SetText(SfxResId(STR_CATEGORY_RENAME).toString()); + aDlg->SetSelectLabelText(SfxResId(STR_CATEGORY_SELECT).toString()); + + if(aDlg->Execute() == RET_OK) + { + OUString sCategory = aDlg->GetSelectedCategory(); + ScopedVclPtrInstance< InputDialog > dlg(SfxResId(STR_INPUT_NEW).toString(),this); + + dlg->SetEntryText(sCategory); + int ret = dlg->Execute(); + + if (ret) + { + OUString aName = dlg->GetEntryText(); + + if(mpLocalView->renameRegion(sCategory, aName)) + { + sal_Int32 nPos = mpCBFolder->GetEntryPos(sCategory); + mpCBFolder->RemoveEntry(nPos); + mpCBFolder->InsertEntry(aName, nPos); + + mpLocalView->reload(); + mpLocalView->showAllTemplates(); + mpLocalView->ShowTooltips(true); + mpCBApp->SelectEntryPos(0); + mpCBFolder->SelectEntryPos(0); + } + else + { + OUString aMsg( SfxResId(STR_CREATE_ERROR).toString() ); + ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst("$1", aName))->Execute(); + } + } + } +} + void SfxTemplateManagerDlg::OnCategoryDelete() { ScopedVclPtrInstance< SfxTemplateCategoryDialog > aDlg; |