sd/source/ui/dlg/sdtreelb.cxx |   22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

New commits:
commit ec60d354359067f8c5c686ef2239ee705916de43
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Sat Jun 10 17:16:29 2023 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Wed Jun 14 03:54:21 2023 +0200

    SdNavigator: Improve unique name detection
    
    Commit ace75043781b5fe36546ec75574a14617f4feb30 added the ability to
    rename page and object names from the Navigator. An approach that
    searches entry names in the tree was used to check for unique naming.
    This does not guarantee uniquess as the name may already be used
    for an object in another view, for example, Notes view. This
    patch guarantees name uniqueness by checking the document model to
    see if an object with the name already exists.
    
    Change-Id: Iad419420d6010b94380c55b7dc71a8d4abbec784
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152843
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 45b078df0cb0..56e93bd7dfe0 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -783,27 +783,9 @@ IMPL_LINK(SdPageObjsTLV, EditedEntryHdl, const 
IterString&, rIterString, bool)
         return true;
 
     // If the new name is empty or not unique, start editing again.
-    bool bUniqueName = true;
-    std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
-    if (!rIterString.second.isEmpty())
-    {
-        if (m_xTreeView->get_iter_first(*xEntry))
-        {
-            do
-            {
-                // skip self!
-                if (m_xTreeView->iter_compare(*xEntry, rIterString.first) != 0 
&&
-                        m_xTreeView->get_text(*xEntry) == rIterString.second)
-                {
-                    bUniqueName = false;
-                    break;
-                }
-            } while(m_xTreeView->iter_next(*xEntry));
-        }
-    }
-    if (rIterString.second.isEmpty() || !bUniqueName)
+    if (rIterString.second.isEmpty() || m_pDoc->GetObj(rIterString.second))
     {
-        m_xTreeView->copy_iterator(rIterString.first, *xEntry);
+        std::unique_ptr<weld::TreeIter> 
xEntry(m_xTreeView->make_iterator(&rIterString.first));
         Application::PostUserEvent(LINK(this, SdPageObjsTLV, EditEntryAgain), 
xEntry.release());
         return false;
     }

Reply via email to