include/svl/hint.hxx              |    1 +
 sw/inc/hintids.hxx                |    1 -
 sw/inc/hints.hxx                  |    5 +++++
 sw/source/core/fields/fldbas.cxx  |    3 +--
 sw/source/core/txtnode/atrfld.cxx |   28 ++++++++++++++++++++++------
 5 files changed, 29 insertions(+), 9 deletions(-)

New commits:
commit 7b5fc53e1378ab26c3d8cf6402351737ffd7b144
Author:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
AuthorDate: Sun Dec 22 15:23:06 2024 +0100
Commit:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
CommitDate: Tue Dec 24 17:18:00 2024 +0100

    move HiddenParaPrint to SfxHint
    
    Change-Id: I94ab48328de791bb9e879b489cc9cb4e140b97de
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179170
    Tested-by: Jenkins
    Reviewed-by: Bjoern Michaelsen <bjoern.michael...@libreoffice.org>

diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index 76749341f41b..744f14c3a2d9 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -230,6 +230,7 @@ enum class SfxHintId {
     SwFindUnoTextTableRowInstance,
     SwFindUnoCellInstance,
     SwRemoveUnoObject,
+    SwHiddenParaPrint,
 
     ThisIsAnSdrHint,
     ThisIsAnSfxEventHint
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index dd231fa41392..042a403553e4 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -431,7 +431,6 @@ inline constexpr TypedWhichId<SwPtrMsgPoolItem> 
RES_OBJECTDYING(RES_FORMAT_MSG_B
 inline constexpr TypedWhichId<SwFormatChg> RES_FMT_CHG(168);
 inline constexpr TypedWhichId<SwAttrSetChg> RES_ATTRSET_CHG(169);
 inline constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(170);
-inline constexpr TypedWhichId<SwMsgPoolItem> RES_HIDDENPARA_PRINT(178);
 // empty
 inline constexpr sal_uInt16 RES_FORMAT_MSG_END(190);
 
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index b38ccae0089e..3140eb2cb4f2 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -316,6 +316,11 @@ public:
     const BroadcastingModify* m_pObject;
     RemoveUnoObjectHint(const BroadcastingModify* pObject) : 
SfxHint(SfxHintId::SwRemoveUnoObject), m_pObject(pObject) {}
 };
+class PrintHiddenParaHint final : public SfxHint
+{
+public:
+    PrintHiddenParaHint() : SfxHint(SfxHintId::SwHiddenParaPrint) {}
+};
 }
 
 class SwUpdateAttr final : public SwMsgPoolItem
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 4751da68dd47..574e8a1ba79d 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -149,8 +149,7 @@ void SwFieldType::PutValue( const uno::Any& , sal_uInt16 )
 
 void SwFieldType::PrintHiddenPara()
 {
-    const SwMsgPoolItem aHint(RES_HIDDENPARA_PRINT);
-    SwClientNotify(*this, sw::LegacyModifyHint(&aHint, nullptr));
+    SwClientNotify(*this, sw::PrintHiddenParaHint());
 }
 
 void SwFieldType::dumpAsXml(xmlTextWriterPtr pWriter) const
diff --git a/sw/source/core/txtnode/atrfld.cxx 
b/sw/source/core/txtnode/atrfld.cxx
index f6e8387c9879..e9086f5ffed3 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -316,12 +316,10 @@ void SwFormatField::SwClientNotify( const SwModify& 
rModify, const SfxHint& rHin
 
 namespace
 {
-    bool lcl_ExpandField(const SwFieldIds eId, const bool bHiddenParaPrint)
+    bool lcl_ExpandField(const SwFieldIds eId)
     {
         switch(eId)
         {
-            case SwFieldIds::HiddenPara:
-                return !bHiddenParaPrint;
             case SwFieldIds::DbSetNumber:
             case SwFieldIds::DbNumSet:
             case SwFieldIds::DbNextSet:
@@ -385,7 +383,7 @@ void SwFormatField::ForceUpdateTextNode()
     lcl_EnsureUserFieldValid(*pType);
     if(lcl_TriggerNode(pType->Which()))
         pTextNd->TriggerNodeUpdate(sw::LegacyModifyHint(nullptr, nullptr));
-    if(!lcl_ExpandField(pType->Which(), false))
+    if(!lcl_ExpandField(pType->Which()))
         return;
 
     // Force notify was added for conditional text fields,
@@ -403,7 +401,25 @@ void SwFormatField::UpdateDocPos(const SwTwips nDocPos)
 }
 void SwFormatField::UpdateTextNode(const SfxHint& rHint)
 {
-    if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
+    if(SfxHintId::SwHiddenParaPrint == rHint.GetId())
+    {
+        if (!IsFieldInDoc())
+            return;
+        auto pType = mpField->GetTyp();
+        lcl_EnsureUserFieldValid(*pType);
+        bool bTriggerNode = lcl_TriggerNode(pType->Which());
+        bool bExpand = lcl_ExpandField(pType->Which());
+        if(bTriggerNode)
+        {
+            SwTextNode* pTextNd = &mpTextField->GetTextNode();
+            OSL_ENSURE(pTextNd, "Where is my Node?");
+            pTextNd->TriggerNodeUpdate(sw::LegacyModifyHint(nullptr, nullptr));
+        }
+        if(bExpand)
+            mpTextField->ExpandTextField(false);
+        return;
+    }
+    else if(SfxHintId::SwRemoveUnoObject == rHint.GetId())
     {   // invalidate cached UNO object
         m_wXTextField.clear();
         // ??? why does this Modify method not already do this?
@@ -445,7 +461,7 @@ void SwFormatField::UpdateTextNode(const SfxHint& rHint)
                 auto pType = mpField->GetTyp();
                 lcl_EnsureUserFieldValid(*pType);
                 bTriggerNode = lcl_TriggerNode(pType->Which());
-                bExpand = lcl_ExpandField(pType->Which(), pOld && 
pOld->Which() == RES_HIDDENPARA_PRINT);
+                bExpand = lcl_ExpandField(pType->Which());
                 pOld = nullptr;
             }
         }

Reply via email to