Kaydet (Commit) 26502c4f authored tarafından Rafael Dominguez's avatar Rafael Dominguez

Display error message for failed operations with templates.

- Move, export and delete templates.
- Delete template folder.

Change-Id: I0c9f5ad299182ce0038695d78eb2e5e09afee1c5
üst 0670dc3f
......@@ -788,6 +788,7 @@ void SfxTemplateManagerDlg::OnTemplateExport()
if( nResult == ExecutableDialogResults::OK )
{
OUString aTemplateList;
INetURLObject aPathObj(xFolderPicker->getDirectory());
aPathObj.setFinalSlash();
......@@ -811,6 +812,10 @@ void SfxTemplateManagerDlg::OnTemplateExport()
if (!maView->exportTo(pItem->mnIdx+1,pItem->mnRegionId+1,aPath))
{
if (aTemplateList.isEmpty())
aTemplateList = pItem->maTitle;
else
aTemplateList = aTemplateList + "\n" + pItem->maTitle;
}
}
......@@ -839,11 +844,21 @@ void SfxTemplateManagerDlg::OnTemplateExport()
if (!maView->exportTo(pItem->mnId,nRegionItemId,aPath))
{
if (aTemplateList.isEmpty())
aTemplateList = pItem->maTitle;
else
aTemplateList = aTemplateList + "\n" + pItem->maTitle;
}
}
maView->deselectOverlayItems();
}
if (!aTemplateList.isEmpty())
{
OUString aText( SfxResId(STR_MSG_ERROR_EXPORT).toString() );
ErrorBox(this, WB_OK,aText.replaceFirst("$1",aTemplateList)).Execute();
}
}
}
......@@ -919,6 +934,8 @@ void SfxTemplateManagerDlg::OnTemplateProperties ()
void SfxTemplateManagerDlg::OnTemplateDelete ()
{
OUString aTemplateList;
if (mpSearchView->IsVisible())
{
std::set<const ThumbnailViewItem*>::const_iterator pIter;
......@@ -933,7 +950,14 @@ void SfxTemplateManagerDlg::OnTemplateDelete ()
if (maView->removeTemplate(nItemId,nItemRegionId))
maSelTemplates.erase(pIter++);
else
{
if (aTemplateList.isEmpty())
aTemplateList = pItem->maTitle;
else
aTemplateList = aTemplateList + "\n" + pItem->maTitle;
++pIter;
}
}
// Update search results
......@@ -954,7 +978,14 @@ void SfxTemplateManagerDlg::OnTemplateDelete ()
if (maView->removeTemplate((*pIter)->mnId,maView->getOverlayRegionId()+1))
maSelTemplates.erase(pIter++);
else
{
if (aTemplateList.isEmpty())
aTemplateList = (*pIter)->maTitle;
else
aTemplateList = aTemplateList + "\n" + (*pIter)->maTitle;
++pIter;
}
}
if (maSelTemplates.empty())
......@@ -965,6 +996,12 @@ void SfxTemplateManagerDlg::OnTemplateDelete ()
mpActionBar->Show();
}
}
if (!aTemplateList.isEmpty())
{
OUString aMsg( SfxResId(STR_MSG_ERROR_DELETE_TEMPLATE).toString() );
ErrorBox(this, WB_OK,aMsg.replaceFirst("$1",aTemplateList)).Execute();
}
}
void SfxTemplateManagerDlg::OnTemplateAsDefault ()
......@@ -987,13 +1024,22 @@ void SfxTemplateManagerDlg::OnTemplateAsDefault ()
void SfxTemplateManagerDlg::OnFolderDelete()
{
OUString aFolderList;
std::set<const ThumbnailViewItem*>::const_iterator pIter;
for (pIter = maSelFolders.begin(); pIter != maSelFolders.end();)
{
if (maView->removeRegion((*pIter)->mnId))
maSelFolders.erase(pIter++);
else
{
if (aFolderList.isEmpty())
aFolderList = (*pIter)->maTitle;
else
aFolderList = aFolderList + "\n" + (*pIter)->maTitle;
++pIter;
}
}
if (maSelFolders.empty())
......@@ -1001,6 +1047,12 @@ void SfxTemplateManagerDlg::OnFolderDelete()
mpViewBar->HideItem(TBI_TEMPLATE_IMPORT);
mpViewBar->HideItem(TBI_TEMPLATE_FOLDER_DEL);
}
if (!aFolderList.isEmpty())
{
OUString aMsg( SfxResId(STR_MSG_ERROR_DELETE_FOLDER).toString() );
ErrorBox(this, WB_OK,aMsg.replaceFirst("$1",aFolderList)).Execute();
}
}
void SfxTemplateManagerDlg::OnRepositoryDelete()
......@@ -1140,6 +1192,21 @@ void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nMenuId)
if (!maView->moveTemplates(maSelTemplates,nItemId,false) &&
!maView->moveTemplates(maSelTemplates,nItemId,true))
{
OUString aTemplateList;
std::set<const ThumbnailViewItem*>::const_iterator pIter;
for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter)
{
if (aTemplateList.isEmpty())
aTemplateList = (*pIter)->maTitle;
else
aTemplateList = aTemplateList + "\n" + (*pIter)->maTitle;
}
OUString aDst = maView->GetItemText(nItemId);
OUString aMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE).toString());
aMsg = aMsg.replaceFirst("$1",aDst);
ErrorBox(this, WB_OK,aMsg.replaceFirst( "$2",aTemplateList)).Execute();
}
}
}
......@@ -1207,6 +1274,8 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId)
if (nItemId)
{
OUString aTemplateList;
// Move templates to desired folder if for some reason move fails
// try copying them.
std::set<const ThumbnailViewItem*>::const_iterator aIter;
......@@ -1218,8 +1287,20 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId)
if(!maView->moveTemplate(pItem,pItem->mnRegionId+1,nItemId,false)
&& !maView->moveTemplate(pItem,pItem->mnRegionId+1,nItemId,true))
{
if (aTemplateList.isEmpty())
aTemplateList = (*aIter)->maTitle;
else
aTemplateList = aTemplateList + "\n" + (*aIter)->maTitle;
}
}
if (!aTemplateList.isEmpty())
{
OUString aDst = maView->GetItemText(nItemId);
OUString aMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE).toString());
aMsg = aMsg.replaceFirst("$1",aDst);
ErrorBox(this, WB_OK,aMsg.replaceFirst( "$2",aTemplateList)).Execute();
}
}
// Deselect all items and update search results
......
......@@ -55,6 +55,12 @@
#define MNI_REPOSITORY_BASE 276
#define STR_ACTION_DEFAULT 277
#define STR_MSG_ERROR_LOCAL_MOVE 278
#define STR_MSG_ERROR_REMOTE_MOVE 279
#define STR_MSG_ERROR_IMPORT 280
#define STR_MSG_ERROR_EXPORT 281
#define STR_MSG_ERROR_DELETE_TEMPLATE 282
#define STR_MSG_ERROR_DELETE_FOLDER 283
#define IMG_ACTION_SORT 304
#define IMG_ACTION_REFRESH 305
......@@ -45,6 +45,31 @@ String STR_REPOSITORY_NEW
Text [ en-US ] = "New Repository";
};
String STR_MSG_ERROR_LOCAL_MOVE
{
Text [ en-US ] = "Error moving the following templates to $1.\n$2" ;
};
String STR_MSG_ERROR_REMOTE_MOVE
{
Text [ en-US ] = "Error moving the following templates from repository $1 to folder $2.\n$3" ;
};
String STR_MSG_ERROR_EXPORT
{
Text [ en-US ] = "Error exporting the following templates:\n$1";
};
String STR_MSG_ERROR_DELETE_TEMPLATE
{
Text [ en-US ] = "The following templates cannot be deleted:\n$1";
};
String STR_MSG_ERROR_DELETE_FOLDER
{
Text [ en-US ] = "The following folders cannot be deleted:\n$1";
};
ModelessDialog DLG_TEMPLATE_MANAGER
{
OutputSize = TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment