diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-06-10 09:02:26 +0530 |
---|---|---|
committer | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-06-10 14:58:22 +0000 |
commit | 82889bf59f0e455d877cf2a6d5c9f4ec243e36cf (patch) | |
tree | 990daa9d2434cab484a9ba2ea946090ec6c489b3 /sfx2 | |
parent | 61a98b7bb14986f6c7c218effacabbe4b925f6b6 (diff) |
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
Reviewed-on: https://gerrit.libreoffice.org/26143
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
(cherry picked from commit ef9e713f6a06191d327dbf236fcc7607d16f61e3)
Change-Id: I11048aa7946d623840e45130affe1b848a3da357
Reviewed-on: https://gerrit.libreoffice.org/26162
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Akshay Deep <akshaydeepiitr@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/templateabstractview.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 20 | ||||
-rw-r--r-- | sfx2/source/doc/doc.hrc | 4 | ||||
-rw-r--r-- | sfx2/source/doc/doc.src | 12 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 43 |
5 files changed, 46 insertions, 35 deletions
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index 6c7fcae37b04..8440d01028a3 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -155,7 +155,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 83d0e47b06ca..e988bfddc00b 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -21,6 +21,7 @@ #include <unotools/ucbstreamhelper.hxx> #include <vcl/builderfactory.hxx> #include <vcl/pngread.hxx> +#include <vcl/layout.hxx> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XStorage.hpp> @@ -468,6 +469,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::VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); + if ( aQueryDlg->Execute() != RET_YES ) + return false; + if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId)) return false; } @@ -563,6 +570,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::VCL_MESSAGE_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 1f516c29aaeb..8f12146ab30e 100644 --- a/sfx2/source/doc/doc.hrc +++ b/sfx2/source/doc/doc.hrc @@ -127,9 +127,11 @@ #define STR_CATEGORY_RENAME (RID_SFX_DOC_START+109) #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 9b7c0a5d122b..2e7f999983e4 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_AUTOMATICVERSION { @@ -262,6 +262,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 23b9458adabf..6a1a1442f4b7 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -1096,6 +1096,7 @@ void SfxTemplateManagerDlg::OnTemplateExport() xFolderPicker->setDisplayDirectory(SvtPathOptions().GetWorkPath()); sal_Int16 nResult = xFolderPicker->execute(); + sal_Int16 nCount = maSelTemplates.size(); if( nResult == ExecutableDialogResults::OK ) { @@ -1171,6 +1172,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::VCL_MESSAGE_INFO)->Execute(); + } } } @@ -1375,24 +1381,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); } } @@ -1433,8 +1422,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; @@ -1447,20 +1434,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 |