sw/qa/extras/layout/layout2.cxx | 5 ++--- sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 6 ++++++ sw/source/core/inc/frame.hxx | 1 + sw/source/core/layout/calcmove.cxx | 6 ++++++ sw/source/core/layout/flowfrm.cxx | 9 +++++++++ sw/source/core/layout/sectfrm.cxx | 2 +- sw/source/core/layout/tabfrm.cxx | 13 +++++++++++++ sw/source/core/layout/trvlfrm.cxx | 16 ++++++++++++++++ 8 files changed, 54 insertions(+), 4 deletions(-)
New commits: commit fc1e6a64bd0517a7e67f08860c29b44d030220eb Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue May 28 09:04:51 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed May 29 13:17:30 2024 +0200 tdf#161202: lowers shouldn't move forward because of lack of space ... in hidden section. So make sure to set heights of lowers to zero, too. testOldComplexMergeTableInTable turned out to be a nice test for this. Change-Id: I334aaaf2becf0ac1ff61faed2e5f697f344c78d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168151 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 56c6991fce5e..dc81b5e2296e 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -858,7 +858,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152872) assertXPath(pXmlDoc, "/root/page[1]/body/txt"_ostr, 2); assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout"_ostr, "portion"_ostr, "C DE"); - assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion"_ostr, 0); // 5 is empty and hidden + // 5 is empty and hidden assertXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds"_ostr, "height"_ostr, "0"); dispatchCommand(mxComponent, ".uno:ControlCodes", {}); @@ -880,7 +880,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152872) // 5 is an empty paragraph with RES_CHRATR_HIDDEN which results in 0-height // frame; ideally it should only be hidden when control codes are hidden // and be a full-height frame now, but that needs more work... - assertXPath(pXmlDoc, "/root/page/body/txt[5]/SwParaPortion"_ostr, 0); // 5 is empty assertXPath(pXmlDoc, "/root/page/body/txt[5]/infos/bounds"_ostr, "height"_ostr, "0"); dispatchCommand(mxComponent, ".uno:ControlCodes", {}); @@ -891,7 +890,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152872) assertXPath(pXmlDoc, "/root/page[1]/body/txt"_ostr, 2); assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout"_ostr, "portion"_ostr, "C DE"); - assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion"_ostr, 0); // 5 is empty and hidden + // 5 is empty and hidden assertXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds"_ostr, "height"_ostr, "0"); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index db504be317c1..4a2ac4bbbfd2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -319,6 +319,12 @@ CPPUNIT_TEST_FIXTURE(Test, testOldComplexMergeTableInTable) { loadAndSave("ooo96040-2.odt"); parseExport("word/document.xml"); + + // Check tdf#161202 - this document has all kinds of tables inside hidden sections. + // The page count must be 13, but for unclear reason, it is 12 in some tests on Linux + // (maybe the layout hasn't finished?). + // Without the fix, it was 52. + CPPUNIT_ASSERT_LESSEQUAL(13, getPages()); } CPPUNIT_TEST_FIXTURE(Test, testHyperlinkContainingPlaceholderField) diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index 4f0df45e2d30..9972248e9744 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -903,6 +903,7 @@ public: bool IsProtected() const; virtual bool IsHiddenNow() const; + void MakeValidZeroHeight(); bool IsColLocked() const { return mbColLocked; } virtual bool IsDeleteForbidden() const { return mnForbidDelete > 0; } diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 6e8112308002..dbd6ffe88b91 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -965,6 +965,9 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) const SwLayNotify aNotify( this ); bool bVert = IsVertical(); + if (IsHiddenNow()) + MakeValidZeroHeight(); + SwRectFn fnRect = ( IsNeighbourFrame() == bVert )? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ); std::optional<SwBorderAttrAccess> oAccess; @@ -1281,6 +1284,9 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) return; } + if (IsHiddenNow()) + MakeValidZeroHeight(); + std::optional<SwFrameDeleteGuard> oDeleteGuard(std::in_place, this); LockJoin(); tools::Long nFormatCount = 0; diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 1cb5cf7bf47a..66ec8ea9e7c2 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -1498,6 +1498,9 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs, const SwFrame* pPr, const bool _bConsiderGrid ) const { + if (m_rThis.IsHiddenNow()) + return 0; + const SwFrame* pPrevFrame = GetPrevFrameForUpperSpaceCalc_( pPr ); std::optional<SwBorderAttrAccess> oAccess; @@ -1803,6 +1806,9 @@ SwTwips SwFlowFrame::GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() cons SwTwips SwFlowFrame::CalcLowerSpace( const SwBorderAttrs* _pAttrs ) const { + if (m_rThis.IsHiddenNow()) + return 0; + SwTwips nLowerSpace = 0; std::optional<SwBorderAttrAccess> oAttrAccess; @@ -1853,6 +1859,9 @@ SwTwips SwFlowFrame::CalcLowerSpace( const SwBorderAttrs* _pAttrs ) const SwTwips SwFlowFrame::CalcAddLowerSpaceAsLastInTableCell( const SwBorderAttrs* _pAttrs ) const { + if (m_rThis.IsHiddenNow()) + return 0; + SwTwips nAdditionalLowerSpace = 0; IDocumentSettingAccess const& rIDSA(m_rThis.GetUpper()->GetFormat()->getIDocumentSettingAccess()); diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index 78278da9cb38..23b427c1507b 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -1211,7 +1211,7 @@ void SwSectionFrame::SimpleFormat() SwTwips nDeadLine = aRectFnSet.GetPrtBottom(*GetUpper()); // OD 22.10.2002 #97265# - call always method <lcl_ColumnRefresh(..)>, in // order to get calculated lowers, not only if there space left in its upper. - if( aRectFnSet.BottomDist( getFrameArea(), nDeadLine ) >= 0 ) + if (aRectFnSet.BottomDist(getFrameArea(), nDeadLine) >= 0) { { SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this); diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 8cd16b8d80ce..21012d31a28e 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -2251,6 +2251,9 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) } } + if (IsHiddenNow()) + MakeValidZeroHeight(); + int nUnSplitted = 5; // Just another loop control :-( int nThrowAwayValidLayoutLimit = 5; // And another one :-( SwRectFnSet aRectFnSet(this); @@ -3197,6 +3200,16 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, tools::Long& rRightOffset, SwTwips *const pSpaceBelowBottom) const { + if (IsHiddenNow()) + { + rUpper = 0; + rLeftOffset = 0; + rRightOffset = 0; + if (pSpaceBelowBottom) + *pSpaceBelowBottom = 0; + return false; + } + bool bInvalidatePrtArea = false; const SwPageFrame *pPage = FindPageFrame(); const SwFlyFrame* pMyFly = FindFlyFrame(); diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index fdbf55110ccd..00144c36e6d5 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -1730,6 +1730,22 @@ bool SwFrame::IsHiddenNow() const return false; } +void SwFrame::MakeValidZeroHeight() +{ + SwRectFnSet aRectFnSet(this); + { + SwFrameAreaDefinition::FrameAreaWriteAccess area(*this); + aRectFnSet.SetHeight(area, 0); + } + { + SwFrameAreaDefinition::FramePrintAreaWriteAccess area(*this); + aRectFnSet.SetHeight(area, 0); + } + setFrameAreaSizeValid(true); + setFramePrintAreaValid(true); + setFrameAreaPositionValid(false); +} + /** @return the physical page number */ sal_uInt16 SwFrame::GetPhyPageNum() const {