diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-04-05 18:27:35 +0200 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2022-04-08 00:48:27 +0200 |
commit | 855e2af1bf6eb216d63ca7baeb9161c7cd501a42 (patch) | |
tree | 10560f1023ad6784ecad8e34f932bb25d132ac70 /sw/source/core/doc/DocumentFieldsManager.cxx | |
parent | e342185c4650ca2678ccbea92770e1ae147d08bc (diff) |
sw: fix expansion of SetGetExpField in headers with split table rows
The problem is that a get field in a header on page N may calculate and
show values that do not take into account a set field on page N-1.
This happens if a table row with multiple columns is split across the
pages: SwGetExpField::ChangeExpansion() calls GetBodyTextNode(), which
returns the first node in the first column that is on page N, but in the
SwNodes array this node is *before* any node in columns 2..M, any of
which may be on page N-1 in the layout.
So try to fix this by adding a page number to SetGetExpField and using
that as the highest priority in operator<().
This is a bit risky because some of the places that create
SetGetExpField don't have a frame to get the page number from; try to
adapt all that call into MakeFieldList(), while leaving unrelated ones
such as in MakeSetList() unchanged.
Change-Id: Ied2a897ad34f0faf1ef3d50baad07b23fafd49bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132641
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 9dc6e2c9062725ef1f9d7e321cae5f4dbe8ca749)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132645
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sw/source/core/doc/DocumentFieldsManager.cxx')
-rw-r--r-- | sw/source/core/doc/DocumentFieldsManager.cxx | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index c7915021be87..59f3b0b0fefa 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -34,6 +34,7 @@ #include <SwUndoField.hxx> #include <flddat.hxx> #include <cntfrm.hxx> +#include <node2lay.hxx> #include <section.hxx> #include <docufld.hxx> #include <calbck.hxx> @@ -725,9 +726,12 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) { SwPosition aPos( *pTableNd ); if( GetBodyTextNode( m_rDoc, aPos, *pFrame ) ) + { FieldsToCalc( *pCalc, SetGetExpField( - aPos.nNode, pFormatField->GetTextField(), - &aPos.nContent), pLayout); + aPos.nNode, pFormatField->GetTextField(), + &aPos.nContent, pFrame->GetPhyPageNum()), + pLayout); + } else pFrame = nullptr; } @@ -736,8 +740,11 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) { // create index to determine the TextNode SwNodeIndex aIdx( rTextNd ); + SwFrame const*const pFrame2 = ::sw::FindNeighbourFrameForNode(rTextNd); FieldsToCalc( *pCalc, - SetGetExpField(aIdx, pFormatField->GetTextField()), + SetGetExpField(aIdx, pFormatField->GetTextField(), + nullptr, + pFrame2 ? pFrame2->GetPhyPageNum() : 0), pLayout); } @@ -797,8 +804,11 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) { SwPosition aPos( *pCNd ); if( GetBodyTextNode( m_rDoc, aPos, *pFrame ) ) - FieldsToCalc(*pCalc, SetGetExpField(aPos.nNode), - pLayout); + { + FieldsToCalc(*pCalc, SetGetExpField(aPos.nNode, + nullptr, nullptr, pFrame->GetPhyPageNum()), + pLayout); + } else pFrame = nullptr; } @@ -808,7 +818,10 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) { // create index to determine the TextNode SwNodeIndex aIdx( *pTableNd ); - FieldsToCalc(*pCalc, SetGetExpField(aIdx), pLayout); + SwFrame const*const pFrame2 = ::sw::FindNeighbourFrameForNode(*pTableNd); + FieldsToCalc(*pCalc, SetGetExpField(aIdx, nullptr, nullptr, + pFrame2 ? pFrame2->GetPhyPageNum() : 0), + pLayout); } SwTableCalcPara aPara(*pCalc, pTableNd->GetTable(), pLayout); |