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

New commits:
commit 388af2c059533adb773fa9a4ebda577da523509c
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Oct 7 16:11:37 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Oct 9 09:03:10 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

diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index 17fe0ef0f260..456bf436c46f 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -884,7 +884,6 @@ std::unique_ptr<SwField> SwSetExpField::Copy() const
 
 void SwSetExpField::SetSubType(SwGetSetExpType nSub)
 {
-    assert((nSub & SwGetSetExpType::LowerMask) != (SwGetSetExpType::String | 
SwGetSetExpType::Expr) && "SubType is illegal!");
     static_cast<SwSetExpFieldType*>(GetTyp())->SetType(nSub & 
SwGetSetExpType::LowerMask);
     mnSubType = nSub & SwGetSetExpType::UpperMask;
 }
diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx
index dd30971ecb29..9c8a2074ce3d 100644
--- a/sw/source/ui/fldui/fldpage.cxx
+++ b/sw/source/ui/fldui/fldpage.cxx
@@ -235,11 +235,11 @@ void SwFieldPage::InsertField(SwFieldTypesEnum nTypeId, 
sal_uInt16 nSubType, con
 
         case SwFieldTypesEnum::Input:
             {
-                SwInputField* pField = 
static_cast<SwInputField*>(pTmpField.get());
-                // User- or SetField ?
+                // User- or SetExp- Field ?
                 if (m_aMgr.GetFieldType(SwFieldIds::User, sPar1) == nullptr &&
-                    !(pField->GetSubType() & SwInputFieldSubType::Text)) // 
SETEXPFLD
+                    SwFieldIds::SetExp != pTmpField->Which()) // SETEXPFLD
                 {
+                    SwInputField* pField = 
static_cast<SwInputField*>(pTmpField.get());
                     pField->SetPar2(sPar2); // Par2 is prompt for SwInputField
                 }
             }

Reply via email to