diff options
author | Jim Raykowski <raykowj@gmail.com> | 2023-06-10 17:16:29 -0800 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-15 08:56:16 +0200 |
commit | 2ce4de98f4d0226e8f7e43f8cd1b5f4b4901c230 (patch) | |
tree | 7bc94da50f0ef21be5894b9266b122bef9b74bdc /sd/source | |
parent | 4b1f2e3b7fb106091873dc59dd756473a78363da (diff) |
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 <raykowj@gmail.com>
(cherry picked from commit ec60d354359067f8c5c686ef2239ee705916de43)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153018
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/dlg/sdtreelb.cxx | 22 |
1 files changed, 2 insertions, 20 deletions
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; } |