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 6d39e29e3f2ba63c797f4489446b5c6697b2fbfd
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Wed May 14 19:24:15 2025 +0530
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri May 16 12:25:32 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>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185351

diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx
index a3d8c22781fd..957e2dbd8686 100644
--- a/sw/inc/txatbase.hxx
+++ b/sw/inc/txatbase.hxx
@@ -72,7 +72,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; }
@@ -110,6 +109,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 f8335b7db484..075178a3d741 100644
--- a/sw/source/core/txtnode/atrref.cxx
+++ b/sw/source/core/txtnode/atrref.cxx
@@ -176,8 +176,10 @@ void SwTextRefMark::UpdateFieldContent(SwDoc* pDoc, 
SwWrtShell& rWrtSh, OUString
 
     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()));
@@ -208,6 +210,7 @@ void SwTextRefMark::UpdateFieldContent(SwDoc* pDoc, 
SwWrtShell& rWrtSh, OUString
     }
     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 790298dbab00..104f1aedfc66 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -1096,6 +1096,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 7c198d5409cb..c9b6675c064d 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -841,6 +841,7 @@ bool UpdateFieldContents(SfxRequest& rReq, SwWrtShell& 
rWrtSh)
         {
             pTextRefMark->SetDontExpand(true);
             pTextRefMark->SetLockExpandFlag(true);
+            pTextRefMark->SetDontExpandStartAttr(true);
         }
 
         if (nFieldIndex >= aFields.getLength())

Reply via email to