[Libreoffice-commits] core.git: include/sfx2 sfx2/source
Akshay Deep
akshaydeepiitr at gmail.com
Tue Jun 7 06:10:24 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 | 1
sfx2/source/doc/doc.src | 4 +++
sfx2/source/doc/templatedlg.cxx | 33 +++++++++++++++++++----------
sfx2/source/inc/templatesearchview.hxx | 2 -
9 files changed, 49 insertions(+), 17 deletions(-)
New commits:
commit 916b3e30099ee01f6c33ba01c7a8adc24cf965cc
Author: Akshay Deep <akshaydeepiitr at gmail.com>
Date: Tue Jun 7 08:44:18 2016 +0530
Reset Default in Context Menu for default templates
Change-Id: Ifedb4f5b4dada0e9e0ac40ffcaed4c2821df501d
Reviewed-on: https://gerrit.libreoffice.org/25995
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/include/sfx2/templateabstractview.hxx b/include/sfx2/templateabstractview.hxx
index e6029685..a220f5a 100644
--- a/include/sfx2/templateabstractview.hxx
+++ b/include/sfx2/templateabstractview.hxx
@@ -124,6 +124,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 d05f338..db5c1b6 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 5174778..7b93c79 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 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 c802ccc..830435d 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 84c9456..ca4a132 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 fbd8967..fe51702 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 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