sw/inc/txatbase.hxx                |    2 +-
 sw/source/core/txtnode/atrref.cxx  |    3 +++
 sw/source/uibase/fldui/fldmgr.cxx  |    1 +
 sw/source/uibase/shells/basesh.cxx |    1 +
 4 files changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 362b544a137504e52d2dfec30f93b6435fc42d53
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Wed May 14 19:24:15 2025 +0530
Commit:     Pranam Lashkari <lpra...@collabora.com>
CommitDate: Wed May 14 21:17:51 2025 +0200

    sw: avoid front expansion of field with NeverExpand flag
    
    improvment on d6b8e20c9cdca69d684390c264e775a708777846
    
    Change-Id: I572090466f4df7c93099244d7f07e62c1468176e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185316
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx
index 33702e952a58..9dff838e6d65 100644
--- a/sw/inc/txatbase.hxx
+++ b/sw/inc/txatbase.hxx
@@ -73,7 +73,6 @@ protected:
     void SetDontMoveAttr( bool bFlag )      { m_bDontMoveAttr = bFlag; }
     void SetCharFormatAttr( bool bFlag )       { m_bCharFormatAttr = bFlag; }
     void SetOverlapAllowedAttr( bool bFlag ){ m_bOverlapAllowedAttr = bFlag; }
-    void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; }
     void SetNesting(const bool bFlag)       { m_bNesting = bFlag; }
     void SetHasDummyChar(const bool bFlag)  { m_bHasDummyChar = bFlag; }
     void SetHasContent( const bool bFlag )  { m_bHasContent = bFlag; }
@@ -111,6 +110,7 @@ public:
     void SetFormatIgnoreEnd  (bool bFlag)   { m_bFormatIgnoreEnd   = bFlag; }
     bool HasContent() const                 { return m_bHasContent; }
     void SetLockExpandFlag(bool bFlag)      { m_bLockExpandFlag = bFlag; }
+    void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; }
 
     inline const SfxPoolItem& GetAttr() const;
     inline       SfxPoolItem& GetAttr();
diff --git a/sw/source/core/txtnode/atrref.cxx 
b/sw/source/core/txtnode/atrref.cxx
index 66cd252f54b8..b13a52a11a0d 100644
--- a/sw/source/core/txtnode/atrref.cxx
+++ b/sw/source/core/txtnode/atrref.cxx
@@ -175,8 +175,10 @@ void SwTextRefMark::UpdateFieldContent(SwDoc* pDoc, 
SwWrtShell& rWrtSh, const OU
 
     bool oldLockValue = this->IsLockExpandFlag();
     bool oldDontExpandValue = this->DontExpand();
+    bool oldDontExpandStartAttr = this->IsDontExpandStartAttr();
     this->SetLockExpandFlag(false);
     this->SetDontExpand(false);
+    this->SetDontExpandStartAttr(false);
     if (rIDCO.InsertString(aMarkers, u"XY"_ustr))
     {
         SwPaM aPasteEnd(SwPosition(rTextNode, *this->End()));
@@ -207,6 +209,7 @@ void SwTextRefMark::UpdateFieldContent(SwDoc* pDoc, 
SwWrtShell& rWrtSh, const OU
     }
     this->SetDontExpand(oldDontExpandValue);
     this->SetLockExpandFlag(oldLockValue);
+    this->SetDontExpandStartAttr(oldDontExpandStartAttr);
 
 }
 
diff --git a/sw/source/uibase/fldui/fldmgr.cxx 
b/sw/source/uibase/fldui/fldmgr.cxx
index e36806605a5f..b2a3b250f07d 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -1095,6 +1095,7 @@ bool SwFieldMgr::InsertField(
                         
pCurShell->GetRefMark(rData.m_sPar1)->GetTextRefMark());
                     xTextRefMark->SetDontExpand(true);
                     xTextRefMark->SetLockExpandFlag(true);
+                    xTextRefMark->SetDontExpandStartAttr(true);
                 }
 
                 if (!bHadMark && !rRefmarkText.isEmpty())
diff --git a/sw/source/uibase/shells/basesh.cxx 
b/sw/source/uibase/shells/basesh.cxx
index 16d738d023ed..3d0447067fc2 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -846,6 +846,7 @@ bool UpdateFieldContents(SfxRequest& rReq, SwWrtShell& 
rWrtSh)
         {
             pTextRefMark->SetDontExpand(true);
             pTextRefMark->SetLockExpandFlag(true);
+            pTextRefMark->SetDontExpandStartAttr(true);
         }
 
         if (nFieldIndex >= aFields.getLength())

Reply via email to