[Libreoffice-commits] core.git: include/sfx2 sfx2/source
Akshay Deep
akshaydeepiitr at gmail.com
Fri May 27 13:22:16 UTC 2016
include/sfx2/templatedlg.hxx | 1
include/sfx2/templatelocalview.hxx | 2 +
sfx2/source/control/templatelocalview.cxx | 13 +++++++
sfx2/source/doc/doc.hrc | 1
sfx2/source/doc/doc.src | 4 ++
sfx2/source/doc/templatedlg.cxx | 53 ++++++++++++++++++++++++++++--
6 files changed, 71 insertions(+), 3 deletions(-)
New commits:
commit 37b4163ce16a6171bd25653494e58bc03daedc2b
Author: Akshay Deep <akshaydeepiitr at gmail.com>
Date: Fri May 27 17:13:27 2016 +0530
Template Manager: Option to rename category
Change-Id: I7a9a0a42afbf5f8a293a130a0b84e72a54540579
Reviewed-on: https://gerrit.libreoffice.org/25539
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx
index 8521ca5..85d932d 100644
--- a/include/sfx2/templatedlg.hxx
+++ b/include/sfx2/templatedlg.hxx
@@ -97,6 +97,7 @@ private:
void OnTemplateState (const ThumbnailViewItem *pItem);
void OnCategoryNew ();
+ void OnCategoryRename();
void OnCategoryDelete();
void createRepositoryMenu ();
diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx
index 654f3d0..d05f338 100644
--- a/include/sfx2/templatelocalview.hxx
+++ b/include/sfx2/templatelocalview.hxx
@@ -68,6 +68,8 @@ public:
virtual sal_uInt16 createRegion (const OUString &rName) override;
+ bool renameRegion(const OUString &rTitle, const OUString &rNewTitle);
+
bool removeRegion (const sal_uInt16 nItemId);
bool removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId);
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index f985d3c..fdc4ca3 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 a8abbe5..6d501ca 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 cab02ce..ed7f8db 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 156e0c2..b2b7b75 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;
More information about the Libreoffice-commits
mailing list