summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sfx2/inc/sfx2/templateonlineview.hxx2
-rw-r--r--sfx2/source/control/templateonlineview.cxx9
-rw-r--r--sfx2/source/doc/templatedlg.cxx15
-rw-r--r--sfx2/source/doc/templatedlg.hrc1
-rw-r--r--sfx2/source/doc/templatedlg.src5
5 files changed, 26 insertions, 6 deletions
diff --git a/sfx2/inc/sfx2/templateonlineview.hxx b/sfx2/inc/sfx2/templateonlineview.hxx
index 0d88d0bc3d71..78f623383749 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 213375286d31..de74ab5ea965 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 a0254278dd33..b0461e7be82b 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 a5d361e81829..0b82219d2505 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 c0bc39c9931d..902485173a87 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;