sw/source/core/fields/expfld.cxx |    1 -
 sw/source/ui/fldui/fldpage.cxx   |    9 ++++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

New commits:
commit 0056bfa3fccc4f50ae0dccf70be01aed55583e93
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Oct 7 16:11:37 2025 +0200
Commit:     Adolfo Jayme Barrientos <[email protected]>
CommitDate: Sun Oct 19 15:47:31 2025 +0200

    tdf#168744 editting format of writer input field asserts
    
    Fixing two bugs here. To trigger these bugs, try to do:
      open bugdoc
      right-click -> edit fields
      and then change the selected date format
      and then click OK
    
    First I have to remove an assert added in:
       commit 99055ae98ef1fe67b8db4a8c3167a8acaeaac02f
       Author: Michael Stahl <[email protected]>
       Date:   Fri Feb 2 20:10:24 2024 +0100
       tdf#123968 sw: fix assert on importing ooo62823-1.sxw
    Which makes no sense, because we use those values all over
    the place in  SwSetExpField, and this assert does not
    seem to be related to the rest of that bugfix.
    
    Secondly, we have to fix a cast and then a check in
    SwFieldPage::InsertField.
    SwFieldTypesEnum::Input can, for better or worse, either
    refere to an SwInputField or an SwSetExpField, so we
    cannot cast to an SwInputField BEFORE we have checked if
    it is actually an SwInputField.
    Also the condition we were checking here is the wrong way
    to determine what kind of subclass this is.
    
    Change-Id: I92c0047a2a3662d3184aad2ec06f565e306d5407
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192067
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 388af2c059533adb773fa9a4ebda577da523509c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192089
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>

diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index 12abe6e4114e..015ceff0559c 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -882,7 +882,6 @@ std::unique_ptr<SwField> SwSetExpField::Copy() const
 
 void SwSetExpField::SetSubType(sal_uInt16 nSub)
 {
-    assert((nSub & 0xff) != 
(nsSwGetSetExpType::GSE_STRING|nsSwGetSetExpType::GSE_EXPR) && "SubType is 
illegal!");
     static_cast<SwSetExpFieldType*>(GetTyp())->SetType(nSub & 0xff);
     mnSubType = nSub & 0xff00;
 }
diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx
index e4c0102f5659..585a55b53181 100644
--- a/sw/source/ui/fldui/fldpage.cxx
+++ b/sw/source/ui/fldui/fldpage.cxx
@@ -232,13 +232,12 @@ void SwFieldPage::InsertField(SwFieldTypesEnum nTypeId, 
sal_uInt16 nSubType, con
 
         case SwFieldTypesEnum::Input:
             {
-                // User- or SetField ?
+                // User- or SetExp- Field ?
                 if (m_aMgr.GetFieldType(SwFieldIds::User, sPar1) == nullptr &&
-                !(pTmpField->GetSubType() & INP_TXT)) // SETEXPFLD
+                    SwFieldIds::SetExp != pTmpField->Which()) // SETEXPFLD
                 {
-                    SwSetExpField* pField = 
static_cast<SwSetExpField*>(pTmpField.get());
-                    pField->SetPromptText(sPar2);
-                    sPar2 = pField->GetPar2();
+                    SwInputField* pField = 
static_cast<SwInputField*>(pTmpField.get());
+                    pField->SetPar2(sPar2); // Par2 is prompt for SwInputField
                 }
             }
             break;

Reply via email to