summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorAkshay Deep <akshaydeepiitr@gmail.com>2016-05-27 17:13:27 +0530
committerAkshay Deep <akshaydeepiitr@gmail.com>2016-05-30 17:36:37 +0000
commit9386b652f1cb0d5ab696ac81d1e9a01eafce96aa (patch)
tree21fc152cb8ed2f21328d566909b8a1809d0e79ae /sfx2/source
parent800920a7b0600b1677d231c514345fe9f6687d82 (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> (cherry picked from commit 37b4163ce16a6171bd25653494e58bc03daedc2b) Reviewed-on: https://gerrit.libreoffice.org/25544 Reviewed-by: Akshay Deep <akshaydeepiitr@gmail.com> Tested-by: Akshay Deep <akshaydeepiitr@gmail.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/control/templatelocalview.cxx13
-rw-r--r--sfx2/source/doc/doc.hrc1
-rw-r--r--sfx2/source/doc/doc.src4
-rw-r--r--sfx2/source/doc/templatedlg.cxx53
4 files changed, 68 insertions, 3 deletions
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 2070a4836396..c28e66580310 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -342,6 +342,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 ee43d48c77b2..4d23086fd251 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;