diff options
author | Justin Luth <jluth@mail.com> | 2022-11-28 14:16:57 -0500 |
---|---|---|
committer | Justin Luth <jluth@mail.com> | 2022-12-01 21:26:49 +0100 |
commit | 64ad923652a11dc68a93f41044df9719c15dec86 (patch) | |
tree | 94487586b0c4cebeb9f1516253e5909f7ae39318 /sw/source/ui | |
parent | d7e80e272a83f960b06521595bd494f2dc84038a (diff) |
tdf#151548 ContentControls: improve GetSelectedListItem
Before there was only an option to get the temporarily
selected list item that had not yet been committed to text.
Add a function that checks whether there is a valid
selected item, regardless of whether it has been
written out or not.
Change-Id: I1199bdccd2e665089750eefa5c3a445d56935556
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143420
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'sw/source/ui')
-rw-r--r-- | sw/source/ui/vba/vbacontentcontrollistentry.cxx | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/sw/source/ui/vba/vbacontentcontrollistentry.cxx b/sw/source/ui/vba/vbacontentcontrollistentry.cxx index 61d2a1faf6a8..80603df21309 100644 --- a/sw/source/ui/vba/vbacontentcontrollistentry.cxx +++ b/sw/source/ui/vba/vbacontentcontrollistentry.cxx @@ -63,19 +63,17 @@ void SwVbaContentControlListEntry::setText(const OUString& rSet) return; } - bool bNeedsInvalidation = false; - if (!pCC->GetShowingPlaceHolder()) - { - // TODO: implement bCheckDocModel - std::optional<size_t> oSel(pCC->GetSelectedListItem(/*bCheckDocModel=true*/)); - bNeedsInvalidation = oSel && *oSel == m_nZIndex; - } + const std::optional<size_t> oSel(pCC->GetSelectedListItem(/*bCheckDocModel=*/true)); + const bool bNeedsInvalidation = pCC->GetDropDown() && oSel && *oSel == m_nZIndex; vListItems[m_nZIndex].m_aDisplayText = rSet; pCC->SetListItems(vListItems); if (bNeedsInvalidation) + { + pCC->SetSelectedListItem(m_nZIndex); m_rCC.Invalidate(); + } } OUString SwVbaContentControlListEntry::getValue() @@ -114,7 +112,7 @@ void SwVbaContentControlListEntry::MoveDown() if (m_nZIndex >= pCC->GetListItems().size() - 1) return; - const std::optional<size_t>& oSelected = pCC->GetSelectedListItem(); + const std::optional<size_t> oSelected = pCC->GetSelectedListItem(/*bCheckDocModel=*/false); if (oSelected) { if (*oSelected == m_nZIndex) @@ -135,7 +133,7 @@ void SwVbaContentControlListEntry::MoveUp() if (!m_nZIndex || m_nZIndex >= pCC->GetListItems().size()) return; - const std::optional<size_t>& oSelected = pCC->GetSelectedListItem(); + const std::optional<size_t> oSelected = pCC->GetSelectedListItem(/*bCheckDocModel=*/false); if (oSelected) { if (*oSelected == m_nZIndex) |