[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sfx2/source

Akshay Deep akshaydeepiitr at gmail.com
Fri Jun 10 14:58:45 UTC 2016


 sfx2/source/control/templateabstractview.cxx |    2 -
 sfx2/source/control/templatelocalview.cxx    |   20 ++++++++++++
 sfx2/source/doc/doc.hrc                      |    4 +-
 sfx2/source/doc/doc.src                      |   12 ++++++-
 sfx2/source/doc/templatedlg.cxx              |   43 ++++++---------------------
 5 files changed, 46 insertions(+), 35 deletions(-)

New commits:
commit 82889bf59f0e455d877cf2a6d5c9f4ec243e36cf
Author: Akshay Deep <akshaydeepiitr at gmail.com>
Date:   Fri Jun 10 09:02:26 2016 +0530

    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 at cib.de>
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    (cherry picked from commit ef9e713f6a06191d327dbf236fcc7607d16f61e3)
    
    Change-Id: I11048aa7946d623840e45130affe1b848a3da357
    Reviewed-on: https://gerrit.libreoffice.org/26162
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Akshay Deep <akshaydeepiitr at gmail.com>

diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index 6c7fcae..8440d01 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 83d0e47b..e988bfd 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 1f516c2..8f12146 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 9b7c0a5..2e7f999 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 23b9458..6a1a144 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


More information about the Libreoffice-commits mailing list