sfx2/inc/sfx2/templateabstractview.hxx | 4 + sfx2/inc/sfx2/templateonlineview.hxx | 2 sfx2/source/control/templateabstractview.cxx | 12 +++ sfx2/source/control/templateonlineview.cxx | 9 ++ sfx2/source/doc/templatedlg.cxx | 96 +++++++++++++++++++++++++-- sfx2/source/doc/templatedlg.hrc | 7 + sfx2/source/doc/templatedlg.src | 30 ++++++++ 7 files changed, 154 insertions(+), 6 deletions(-)
New commits: commit c49fbe94d4f704ea0c574047e9b6cc03992835b4 Author: Rafael Dominguez <[email protected]> Date: Sun Aug 12 13:32:12 2012 -0430 Dont let user create a repository with a duplicated name. Change-Id: I4175515b72f0e9aac8e4cf2905757381539cab1e diff --git a/sfx2/inc/sfx2/templateonlineview.hxx b/sfx2/inc/sfx2/templateonlineview.hxx index 0d88d0b..78f6233 100644 --- a/sfx2/inc/sfx2/templateonlineview.hxx +++ b/sfx2/inc/sfx2/templateonlineview.hxx @@ -40,7 +40,7 @@ public: const std::vector<TemplateOnlineViewItem*>& getRepositories () const { return maRepositories; } - void insertRepository (const OUString &rName, const OUString &rURL); + bool insertRepository (const OUString &rName, const OUString &rURL); bool deleteRepository (const sal_uInt16 nRepositoryId); diff --git a/sfx2/source/control/templateonlineview.cxx b/sfx2/source/control/templateonlineview.cxx index 2133752..de74ab5 100644 --- a/sfx2/source/control/templateonlineview.cxx +++ b/sfx2/source/control/templateonlineview.cxx @@ -259,8 +259,14 @@ bool TemplateOnlineView::loadRepository (const sal_uInt16 nRepositoryId, bool bR return true; } -void TemplateOnlineView::insertRepository(const OUString &rName, const OUString &rURL) +bool TemplateOnlineView::insertRepository(const OUString &rName, const OUString &rURL) { + for (size_t i = 0, n = maRepositories.size(); i < n; ++i) + { + if (maRepositories[i]->maTitle == rName) + return false; + } + TemplateOnlineViewItem *pItem = new TemplateOnlineViewItem(*this,this); pItem->mnId = maRepositories.size()+1; @@ -270,6 +276,7 @@ void TemplateOnlineView::insertRepository(const OUString &rName, const OUString maRepositories.push_back(pItem); mbIsSynced = false; + return true; } bool TemplateOnlineView::deleteRepository(const sal_uInt16 nRepositoryId) diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index a025427..b0461e7 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -583,10 +583,17 @@ IMPL_LINK(SfxTemplateManagerDlg, RepositoryMenuSelectHdl, Menu*, pMenu) { boost::shared_ptr<Place> pPlace = dlg.GetPlace(); - mpOnlineView->insertRepository(pPlace->GetName(),pPlace->GetUrl()); - - // update repository list menu. - createRepositoryMenu(); + if (mpOnlineView->insertRepository(pPlace->GetName(),pPlace->GetUrl())) + { + // update repository list menu. + createRepositoryMenu(); + } + else + { + OUString aMsg(SfxResId(STR_MSG_ERROR_REPOSITORY_NAME).toString()); + aMsg = aMsg.replaceFirst("$1",pPlace->GetName()); + ErrorBox(this,WB_OK,aMsg).Execute(); + } } } else diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc index a5d361e..0b82219 100644 --- a/sfx2/source/doc/templatedlg.hrc +++ b/sfx2/source/doc/templatedlg.hrc @@ -61,6 +61,7 @@ #define STR_MSG_ERROR_EXPORT 281 #define STR_MSG_ERROR_DELETE_TEMPLATE 282 #define STR_MSG_ERROR_DELETE_FOLDER 283 +#define STR_MSG_ERROR_REPOSITORY_NAME 284 #define IMG_ACTION_SORT 304 #define IMG_ACTION_REFRESH 305 diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src index c0bc39c..9024851 100644 --- a/sfx2/source/doc/templatedlg.src +++ b/sfx2/source/doc/templatedlg.src @@ -70,6 +70,11 @@ String STR_MSG_ERROR_DELETE_FOLDER Text [ en-US ] = "The following folders cannot be deleted:\n$1"; }; +String STR_MSG_ERROR_REPOSITORY_NAME +{ + Text [ en-US ] = "Failed to create repository \"$1\".\nA repository with this name may already exist."; +}; + ModelessDialog DLG_TEMPLATE_MANAGER { OutputSize = TRUE; commit 26502c4f51a22e2aaea25c10d484b1c163c4f004 Author: Rafael Dominguez <[email protected]> Date: Sun Aug 12 12:16:25 2012 -0430 Display error message for failed operations with templates. - Move, export and delete templates. - Delete template folder. Change-Id: I0c9f5ad299182ce0038695d78eb2e5e09afee1c5 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index bc83ecf..a025427 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -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 diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc index 9bdedae..a5d361e 100644 --- a/sfx2/source/doc/templatedlg.hrc +++ b/sfx2/source/doc/templatedlg.hrc @@ -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 diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src index 900b481..c0bc39c 100644 --- a/sfx2/source/doc/templatedlg.src +++ b/sfx2/source/doc/templatedlg.src @@ -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; commit 0670dc3f6017530bd0583e9947c071cd7640109b Author: Rafael Dominguez <[email protected]> Date: Sat Aug 11 22:36:52 2012 -0430 Perform template view paint operation when overlay is hidden. Change-Id: Iff0bb308fea93fe12cba030becae3da1ca5f1a96 diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index 9bd7594..24edcd7 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -102,6 +102,10 @@ protected: virtual void Resize(); + virtual void Paint( const Rectangle& rRect ); + + virtual void DrawItem (ThumbnailViewItem *pItem); + virtual void OnSelectionMode (bool bMode); DECL_LINK(OverlayItemStateHdl, const ThumbnailViewItem*); diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index 375012a..4ce28f6 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -243,6 +243,18 @@ void TemplateAbstractView::Resize() mpItemView->SetSizePixel(GetSizePixel()); } +void TemplateAbstractView::Paint(const Rectangle &rRect) +{ + if (!mpItemView->IsVisible()) + ThumbnailView::Paint(rRect); +} + +void TemplateAbstractView::DrawItem(ThumbnailViewItem *pItem) +{ + if (!mpItemView->IsVisible()) + ThumbnailView::DrawItem(pItem); +} + void TemplateAbstractView::OnSelectionMode (bool bMode) { if (mpItemView->IsVisible()) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
