tdf#149195: Impossible to change link of a DB and keep the same registered name

Just test nEntry to know if it's a new entry (and so the name must be different from an existing one)

Change-Id: I3bda6b1d3d9bae3d79fdfc2cb1323f20add410c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156785
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
(cherry picked from commit a410b8f1111c738604ad2f67c111f98d91761051)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156735
Reviewed-by: Lionel Mamane <lionel@mamane.lu>
diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx
index 143112c..92cbbd0 100644
--- a/cui/source/options/dbregister.cxx
+++ b/cui/source/options/dbregister.cxx
@@ -280,7 +280,10 @@ void DbRegistrationOptionsPage::openLinkDialog(const OUString& sOldName, const O
    ODocumentLinkDialog aDlg(GetFrameWeld(), nEntry == -1);

    aDlg.setLink(sOldName, sOldLocation);
    aDlg.setNameValidator(LINK( this, DbRegistrationOptionsPage, NameValidator ) );

    // tdf#149195: control the name (ie check duplicate) only if new entry case
    if (nEntry == -1)
        aDlg.setNameValidator(LINK( this, DbRegistrationOptionsPage, NameValidator ) );

    if (aDlg.run() != RET_OK)
        return;