sw/inc/IDocumentFieldsAccess.hxx | 3 ++- sw/source/core/doc/DocumentFieldsManager.cxx | 12 +++++++----- sw/source/core/inc/DocumentFieldsManager.hxx | 2 +- sw/source/core/layout/newfrm.cxx | 3 +-- sw/source/core/layout/pagechg.cxx | 9 +++------ sw/source/core/layout/tabfrm.cxx | 3 +-- sw/source/core/layout/wsfrm.cxx | 3 +-- sw/source/core/view/viewsh.cxx | 3 +-- 8 files changed, 17 insertions(+), 21 deletions(-)
New commits: commit b4b3f281443fc64b420156eed11af773f80a4e2a Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Sun Feb 19 17:45:41 2023 +0100 Commit: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Fri Feb 24 07:33:59 2023 +0000 Use just plain straight-forward params for UpdatePageFields - dont wrap parameters in a useless hint as superfluous indirection - note: SwDocPosUpdate receives a special kind of abuse here: * it is used as pNew with pOld being nullptr when send to the document field manager * it is sneakily modified to be the pOld when it is forwarded by the field to the frame via the node - full path of the message before this change: -> passed to the UpdatePageFields as parameter -> wrapped as the pNew there and send to the field types -> passed by the fieldtypes to the fields -> tweaked to be the pOld with pNew being the field itselfby the fields when passed from the field to the node -> passed from the node to the frames Change-Id: I084c3a1abe6871abdb82655cc413902dd16071cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147302 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/inc/IDocumentFieldsAccess.hxx b/sw/inc/IDocumentFieldsAccess.hxx index ee3e2536b921..c31e6a646ed0 100644 --- a/sw/inc/IDocumentFieldsAccess.hxx +++ b/sw/inc/IDocumentFieldsAccess.hxx @@ -23,6 +23,7 @@ #include <rtl/ustring.hxx> #include <sal/types.h> +#include "swtypes.hxx" #include "nodeoffset.hxx" class SwFieldTypes; @@ -100,7 +101,7 @@ namespace com::sun::star::uno { class Any; } virtual void UpdateUsrFields() = 0; - virtual void UpdatePageFields(SfxPoolItem*) = 0; + virtual void UpdatePageFields(const SwTwips) = 0; virtual void LockExpFields() = 0; diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index 79852fa52ce0..4d6486bca262 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -1335,18 +1335,20 @@ sal_Int32 DocumentFieldsManager::GetRecordsPerDocument() const return nRecords; } -void DocumentFieldsManager::UpdatePageFields( SfxPoolItem* pMsgHint ) +void DocumentFieldsManager::UpdatePageFields(const SwTwips nDocPos) { - for( SwFieldTypes::size_type i = 0; i < INIT_FLDTYPES; ++i ) + SwDocPosUpdate aDosPosUpdate(nDocPos); + sw::LegacyModifyHint aHint(nullptr, &aDosPosUpdate); + for(SwFieldTypes::size_type i = 0; i < INIT_FLDTYPES; ++i) { - SwFieldType* pFieldType = (*mpFieldTypes)[ i ].get(); - switch( pFieldType->Which() ) + SwFieldType* pFieldType = (*mpFieldTypes)[i].get(); + switch(pFieldType->Which()) { case SwFieldIds::PageNumber: case SwFieldIds::Chapter: case SwFieldIds::GetExp: case SwFieldIds::RefPageGet: - pFieldType->CallSwClientNotify(sw::LegacyModifyHint(nullptr, pMsgHint)); + pFieldType->CallSwClientNotify(aHint); break; case SwFieldIds::DocStat: pFieldType->CallSwClientNotify(sw::LegacyModifyHint(nullptr, nullptr)); diff --git a/sw/source/core/inc/DocumentFieldsManager.hxx b/sw/source/core/inc/DocumentFieldsManager.hxx index 2b661604b8de..0f1aede584cb 100644 --- a/sw/source/core/inc/DocumentFieldsManager.hxx +++ b/sw/source/core/inc/DocumentFieldsManager.hxx @@ -48,7 +48,7 @@ public: virtual void UpdateTableFields(SfxPoolItem* pHt) override; virtual void UpdateExpFields(SwTextField* pField, bool bUpdateRefFields) override; virtual void UpdateUsrFields() override; - virtual void UpdatePageFields(SfxPoolItem*) override; + virtual void UpdatePageFields(const SwTwips) override; virtual void LockExpFields() override; virtual void UnlockExpFields() override; virtual bool IsExpFieldsLocked() const override; diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx index 5ca11e34138b..95af08baa6e3 100644 --- a/sw/source/core/layout/newfrm.cxx +++ b/sw/source/core/layout/newfrm.cxx @@ -512,8 +512,7 @@ void SwRootFrame::Init( SwFrameFormat* pFormat ) //b6433357: Update page fields after loading if ( !mpCurrShell || !mpCurrShell->Imp()->IsUpdateExpFields() ) { - SwDocPosUpdate aMsgHint( pPage->getFrameArea().Top() ); - rFieldsAccess.UpdatePageFields( &aMsgHint ); + rFieldsAccess.UpdatePageFields(pPage->getFrameArea().Top()); } rTimerAccess.StartIdling(); diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index da4c2fb81c5d..adbcd85f4b37 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -1278,8 +1278,7 @@ void SwFrame::CheckPageDescs( SwPageFrame *pStart, bool bNotifyFields, SwPageFra if ( bNotifyFields && (!pImp || !pImp->IsUpdateExpFields()) ) { - SwDocPosUpdate aMsgHint( nDocPos ); - pDoc->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint ); + pDoc->getIDocumentFieldsAccess().UpdatePageFields(nDocPos); } #if OSL_DEBUG_LEVEL > 0 @@ -1443,8 +1442,7 @@ SwPageFrame *SwFrame::InsertPage( SwPageFrame *pPrevPage, bool bFootnote ) SwViewShell *pSh = getRootFrame()->GetCurrShell(); if ( !pSh || !pSh->Imp()->IsUpdateExpFields() ) { - SwDocPosUpdate aMsgHint( pPrevPage->getFrameArea().Top() ); - pDoc->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint ); + pDoc->getIDocumentFieldsAccess().UpdatePageFields(pPrevPage->getFrameArea().Top()); } return pPage; } @@ -1548,8 +1546,7 @@ void SwRootFrame::RemoveSuperfluous() if ( nDocPos != LONG_MAX && (!pSh || !pSh->Imp()->IsUpdateExpFields()) ) { - SwDocPosUpdate aMsgHint( nDocPos ); - GetFormat()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint ); + GetFormat()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFields(nDocPos); } } diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 177bfa947fb2..78005c0699e8 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -3465,8 +3465,7 @@ void SwTabFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew, CheckPageDescs( pPage ); if (GetFormat()->GetPageDesc().GetNumOffset()) static_cast<SwRootFrame*>(pPage->GetUpper())->SetVirtPageNum( true ); - SwDocPosUpdate aMsgHint( pPage->getFrameArea().Top() ); - GetFormat()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint ); + GetFormat()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFields(pPage->getFrameArea().Top()); } } break; diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 7484db742c7c..971918632752 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -2452,8 +2452,7 @@ void SwContentFrame::UpdateAttr_( const SfxPoolItem* pOld, const SfxPoolItem* pN CheckPageDescs( pPage ); if (GetPageDescItem().GetNumOffset()) static_cast<SwRootFrame*>(pPage->GetUpper())->SetVirtPageNum( true ); - SwDocPosUpdate aMsgHint( pPage->getFrameArea().Top() ); - pPage->GetFormat()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint ); + pPage->GetFormat()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFields(pPage->getFrameArea().Top()); } break; diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 1fe1ae2c9e22..51559c606146 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1106,8 +1106,7 @@ void SwViewShell::CalcLayout() aAction.SetStatBar( true ); aAction.SetReschedule( true ); - SwDocPosUpdate aMsgHint( 0 ); - GetDoc()->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint ); + GetDoc()->getIDocumentFieldsAccess().UpdatePageFields(0); GetDoc()->getIDocumentFieldsAccess().UpdateExpFields(nullptr, true); aAction.Action(GetOut());