summaryrefslogtreecommitdiffstats
path: root/sfx2
diff options
context:
space:
mode:
authorAkshay Deep <akshaydeepiitr@gmail.com>2016-06-10 09:02:26 +0530
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-06-10 12:05:09 +0000
commitef9e713f6a06191d327dbf236fcc7607d16f61e3 (patch)
tree8662f09ce72b11b20bb8bc84b4148420ebc32218 /sfx2
parentsw: implement per-view LOK_CALLBACK_HYPERLINK_CLICKED (diff)
downloadcore-ef9e713f6a06191d327dbf236fcc7607d16f61e3.tar.gz
core-ef9e713f6a06191d327dbf236fcc7607d16f61e3.zip
GSoC: Template Manager: Add respones for User Interaction
1. Success message when templates are successfully exported 2. Query message before copy executes when moving templates Change-Id: I11048aa7946d623840e45130affe1b848a3da357 Reviewed-on: https://gerrit.libreoffice.org/26143 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/templateabstractview.cxx2
-rw-r--r--sfx2/source/control/templatelocalview.cxx19
-rw-r--r--sfx2/source/doc/doc.hrc4
-rw-r--r--sfx2/source/doc/doc.src12
-rw-r--r--sfx2/source/doc/templatedlg.cxx43
5 files changed, 45 insertions, 35 deletions
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index 9f828f3b3abd..117c11e8c2cb 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -133,7 +133,7 @@ void TemplateAbstractView::insertItems(const std::vector<TemplateItemProperties>
else
{
OUString sHelpText = SfxResId(STR_TEMPLATE_TOOLTIP).toString();
- sHelpText = (sHelpText.replaceFirst("$1", pCur->aName)).replaceFirst("$1", pCur->aRegionName);
+ sHelpText = (sHelpText.replaceFirst("$1", pCur->aName)).replaceFirst("$2", pCur->aRegionName);
pChild->setHelpText(sHelpText);
}
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index ededed4a7768..5b1365468860 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -464,6 +464,12 @@ bool TemplateLocalView::moveTemplate (const ThumbnailViewItem *pItem, const sal_
if (bCopy)
{
+ OUString sQuery = (OUString(SfxResId(STR_MSG_QUERY_COPY).toString()).replaceFirst("$1", pViewItem->maTitle)).replaceFirst("$2",
+ getRegionName(nTargetRegion));
+ ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, sQuery, VclMessageType::Question, VCL_BUTTONS_YES_NO);
+ if ( aQueryDlg->Execute() != RET_YES )
+ return false;
+
if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId))
return false;
}
@@ -559,6 +565,19 @@ bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s
if (bCopy)
{
+ OUString sQuery = (OUString(SfxResId(STR_MSG_QUERY_COPY).toString()).replaceFirst("$1", pViewItem->maTitle)).replaceFirst("$2",
+ getRegionName(nTargetRegion));
+ ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, sQuery, VclMessageType::Question, VCL_BUTTONS_YES_NO);
+
+ if ( aQueryDlg->Execute() != RET_YES )
+ {
+ OUString sMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE).toString());
+ sMsg = sMsg.replaceFirst("$1",getRegionName(nTargetRegion));
+ ScopedVclPtrInstance<MessageDialog>::Create(this, sMsg.replaceFirst( "$2",pViewItem->maTitle))->Execute();
+
+ return false; //return if any single move operation fails
+ }
+
if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId))
{
ret = false;
diff --git a/sfx2/source/doc/doc.hrc b/sfx2/source/doc/doc.hrc
index e938ab6692ea..19f77fefaca9 100644
--- a/sfx2/source/doc/doc.hrc
+++ b/sfx2/source/doc/doc.hrc
@@ -126,9 +126,11 @@
#define STR_TEMPLATE_SELECTION (RID_SFX_DOC_START+120)
#define STR_RESET_DEFAULT (RID_SFX_DOC_START+122)
#define STR_TEMPLATE_TOOLTIP (RID_SFX_DOC_START+169)
+#define STR_MSG_EXPORT_SUCCESS (RID_SFX_DOC_START+170)
+#define STR_MSG_QUERY_COPY (RID_SFX_DOC_START+171)
// please update to the last id
-#define ACT_SFX_DOC_END IMG_ACTION_REFRESH
+#define ACT_SFX_DOC_END STR_MSG_QUERY_COPY
#if ACT_SFX_DOC_END > RID_SFX_DOC_END
#error resource overflow in #line, #file
#endif
diff --git a/sfx2/source/doc/doc.src b/sfx2/source/doc/doc.src
index 2ed6bcd655c3..ef60bfff390e 100644
--- a/sfx2/source/doc/doc.src
+++ b/sfx2/source/doc/doc.src
@@ -86,7 +86,7 @@ String STR_RENAME_TEMPLATE
};
String STR_TEMPLATE_TOOLTIP
{
- Text [ en-US ] = "Title: $1\nCategory: $1" ;
+ Text [ en-US ] = "Title: $1\nCategory: $2" ;
};
String STR_TEMPLATE_SELECTION
{
@@ -266,6 +266,16 @@ String STR_CATEGORY_SELECT
Text [ en-US ] = "Select Category";
};
+String STR_MSG_EXPORT_SUCCESS
+{
+ Text [ en-US ] = "$1 templates successfully exported." ;
+};
+
+String STR_MSG_QUERY_COPY
+{
+ Text [ en-US ] = "$1 could not be moved to the category \"$2\". Do you want to copy the template instead?";
+};
+
String STR_CREATE_ERROR
{
Text [ en-US ] = "Cannot create category: $1";
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index e0668fe68675..1eba875f2526 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1090,6 +1090,7 @@ void SfxTemplateManagerDlg::OnTemplateExport()
xFolderPicker->setDisplayDirectory(SvtPathOptions().GetWorkPath());
sal_Int16 nResult = xFolderPicker->execute();
+ sal_Int16 nCount = maSelTemplates.size();
if( nResult == ExecutableDialogResults::OK )
{
@@ -1165,6 +1166,11 @@ void SfxTemplateManagerDlg::OnTemplateExport()
OUString aText( SfxResId(STR_MSG_ERROR_EXPORT).toString() );
ScopedVclPtrInstance<MessageDialog>::Create(this, aText.replaceFirst("$1",aTemplateList))->Execute();
}
+ else
+ {
+ OUString sText( SfxResId(STR_MSG_EXPORT_SUCCESS).toString() );
+ ScopedVclPtrInstance<MessageDialog>::Create(this, sText.replaceFirst("$1", OUString::number(nCount)), VclMessageType::Info)->Execute();
+ }
}
}
@@ -1358,24 +1364,7 @@ void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nItemId)
{
// Move templates to desired folder if for some reason move fails
// try copying them.
- if (!mpLocalView->moveTemplates(maSelTemplates,nItemId))
- {
- OUString aTemplateList;
-
- std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter;
- for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end(); ++pIter)
- {
- if (aTemplateList.isEmpty())
- aTemplateList = (*pIter)->maTitle;
- else
- aTemplateList = aTemplateList + "\n" + (*pIter)->maTitle;
- }
-
- OUString aDst = mpLocalView->getRegionItemName(nItemId);
- OUString aMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE).toString());
- aMsg = aMsg.replaceFirst("$1",aDst);
- ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst( "$2",aTemplateList))->Execute();
- }
+ mpLocalView->moveTemplates(maSelTemplates,nItemId);
}
}
@@ -1416,8 +1405,6 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nItemId)
{
if (nItemId)
{
- OUString aTemplateList;
-
// Move templates to desired folder if for some reason move fails
// try copying them.
std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator aIter;
@@ -1430,20 +1417,12 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nItemId)
if(!mpLocalView->moveTemplate(pItem,pItem->mnRegionId,nItemId))
{
- if (aTemplateList.isEmpty())
- aTemplateList = (*aIter)->maTitle;
- else
- aTemplateList = aTemplateList + "\n" + (*aIter)->maTitle;
+ OUString sDst = mpLocalView->getRegionItemName(nItemId);
+ OUString sMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE).toString());
+ sMsg = sMsg.replaceFirst("$1",sDst);
+ ScopedVclPtrInstance<MessageDialog>::Create(this, sMsg.replaceFirst( "$2",pItem->maTitle))->Execute();
}
}
-
- if (!aTemplateList.isEmpty())
- {
- OUString aDst = mpLocalView->getRegionItemName(nItemId);
- OUString aMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE).toString());
- aMsg = aMsg.replaceFirst("$1",aDst);
- ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst( "$2",aTemplateList))->Execute();
- }
}
// Deselect all items and update search results