sw/source/ui/vba/vbacontentcontrols.cxx |    9 +++++++++
 1 file changed, 9 insertions(+)

New commits:
commit 61604ecfcfe2a9fbe3057a9fc38bfc6cc3b22b08
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Fri Dec 16 12:41:39 2022 -0500
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Mon Dec 19 16:03:28 2022 +0000

    tdf#151548 vba ContentControls: don't always return a filtered value
    
    Searching for content controls can be filtered by tag, title, or Id.
    The function was erroneously returning the last control in the
    list if the specified control did not exist.
    
    Change-Id: I0cfbccadc134b64456d703f1e19db6e142f162fd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144346
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sw/source/ui/vba/vbacontentcontrols.cxx 
b/sw/source/ui/vba/vbacontentcontrols.cxx
index a53bb5801763..37199e2cec2d 100644
--- a/sw/source/ui/vba/vbacontentcontrols.cxx
+++ b/sw/source/ui/vba/vbacontentcontrols.cxx
@@ -59,14 +59,23 @@ lcl_getContentControl(std::u16string_view sName, 
std::u16string_view sTag,
         {
             pControl = 
rManager.Get(i)->GetContentControl().GetContentControl();
             if (!sTag.empty() && sTag != pControl->GetTag())
+            {
+                pControl = nullptr;
                 continue;
+            }
             if (!sTitle.empty() && sTitle != pControl->GetAlias())
+            {
+                pControl = nullptr;
                 continue;
+            }
 
             // When treated as a name, consider the integer ID to be unsigned
             const OUString sID = 
OUString::number(static_cast<sal_uInt32>(pControl->GetId()));
             if (!sName.empty() && sName != sID)
+            {
+                pControl = nullptr;
                 continue;
+            }
 
             if (pElementNames)
                 vElementNames.push_back(sID);

Reply via email to