[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - include/sfx2 sfx2/source
Akshay Deep
akshaydeepiitr at gmail.com
Wed Jun 8 14:30:56 UTC 2016
include/sfx2/templateabstractview.hxx | 1
include/sfx2/templatelocalview.hxx | 2 -
include/sfx2/templateviewitem.hxx | 2 +
sfx2/source/control/templatelocalview.cxx | 9 ++++++-
sfx2/source/control/templatesearchview.cxx | 12 ++++++++--
sfx2/source/doc/doc.hrc | 2 +
sfx2/source/doc/doc.src | 4 +++
sfx2/source/doc/templatedlg.cxx | 33 +++++++++++++++++++----------
sfx2/source/inc/templatesearchview.hxx | 2 -
9 files changed, 50 insertions(+), 17 deletions(-)
New commits:
commit e14f7bcfafe951a6b59a6635865fb31ae9c259bd
Author: Akshay Deep <akshaydeepiitr at gmail.com>
Date: Tue Jun 7 08:44:18 2016 +0530
Reset Default in Context Menu for default templates
Reviewed-on: https://gerrit.libreoffice.org/25995
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at 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 at libreoffice.org>
Reviewed-by: Akshay Deep <akshaydeepiitr at gmail.com>
diff --git a/include/sfx2/templateabstractview.hxx b/include/sfx2/templateabstractview.hxx
index 611bc5e..55890c7 100644
--- a/include/sfx2/templateabstractview.hxx
+++ b/include/sfx2/templateabstractview.hxx
@@ -129,6 +129,7 @@ protected:
virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override;
+public:
static bool IsDefaultTemplate(const OUString& rPath);
protected:
diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx
index 304102e..f342645 100644
--- a/include/sfx2/templatelocalview.hxx
+++ b/include/sfx2/templatelocalview.hxx
@@ -47,7 +47,7 @@ public:
void showRegion (const OUString &rName);
- void createContextMenu();
+ void createContextMenu(const bool bIsDefault );
DECL_LINK_TYPED(ContextMenuSelectHdl, Menu*, bool);
diff --git a/include/sfx2/templateviewitem.hxx b/include/sfx2/templateviewitem.hxx
index 10d4634..c6bcbfb 100644
--- a/include/sfx2/templateviewitem.hxx
+++ b/include/sfx2/templateviewitem.hxx
@@ -26,6 +26,8 @@ public:
void showDefaultIcon(bool bVal) { mbIsDefaultTemplate = bVal; }
+ bool IsDefaultTemplate() const { return mbIsDefaultTemplate; }
+
Rectangle getDefaultIconArea() const;
virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index bd1245b..0722eb1 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 3075d40..e5754d9 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 6d501ca..ea4bc30 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 ed7f8db..eb8a5ae 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 7bc2dda..ad4683a 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 7a4fdb5..e6f75f4 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,
More information about the Libreoffice-commits
mailing list