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

Dont let user create a repository with a duplicated name.

Change-Id: I4175515b72f0e9aac8e4cf2905757381539cab1e
üst 26502c4f
......@@ -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);
......
......@@ -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)
......
......@@ -583,11 +583,18 @@ IMPL_LINK(SfxTemplateManagerDlg, RepositoryMenuSelectHdl, Menu*, pMenu)
{
boost::shared_ptr<Place> pPlace = dlg.GetPlace();
mpOnlineView->insertRepository(pPlace->GetName(),pPlace->GetUrl());
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
{
......
......@@ -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
......@@ -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;
......
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