diff options
author | Mark Hung <marklm9@gmail.com> | 2022-08-14 15:23:14 +0800 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-08-15 11:39:09 +0200 |
commit | 1bf82b26aea3a403920a64cdfcb4671c947c7a01 (patch) | |
tree | 1f6e00eed63fddf396455a24b501876bb9cc7047 /sw | |
parent | ae7efecd240eb5c035183b47c08b2ba6b1b78570 (diff) |
tdf#135991 fix unexpected hidden RTL sections.
SwLayoutFrame::MakeAll tried to manipulate the height instead of the
width for SwCellFrame and SwColumnFrame ( i.e. when IsNeghbourFrame()
is true. ), by selecting a wrong SwRectFn.
SwRectFn fnRect = bVert == IsNeighbourFrame() ? fnRectHori :
( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert );
It doesn't make sense to select among fnRectVertL2RBT, fnRectVertL2R,
and fnRectVert if the layout is horizontal.
The frame position got a negative top value and make the frame invisble.
Check he following commit for reference:
commit c90b6806d18c8ed25015eb2ecdff13c7bab2572d
Author: Andreas Martens <ama@openoffice.org>
Date: Wed Sep 19 07:45:10 2001 +0000
Chg: Moving vertical help functions from SwFrm to SwRect
Change-Id: I2f6da9cdbc2947de95a6fb9ce8fa94a79360c83a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138250
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/layout/data/tdf135991.odt | bin | 0 -> 12299 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout2.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/layout/calcmove.cxx | 46 |
3 files changed, 33 insertions, 21 deletions
diff --git a/sw/qa/extras/layout/data/tdf135991.odt b/sw/qa/extras/layout/data/tdf135991.odt Binary files differnew file mode 100644 index 000000000000..f490ee9fb28c --- /dev/null +++ b/sw/qa/extras/layout/data/tdf135991.odt diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index c4d1a976fe7c..09e113fc4ed0 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -2301,6 +2301,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124261) #endif } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf135991) +{ + createSwDoc(DATA_DIRECTORY, "tdf135991.odt"); + auto pDump = parseLayoutDump(); + // There used to be negative values that made the column frames invisible. + assertXPath(pDump, "//bounds[@top<0]", 0); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 1bc2506a72f4..1869794300f6 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -949,7 +949,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) const SwLayNotify aNotify( this ); bool bVert = IsVertical(); - SwRectFn fnRect = ( IsNeighbourFrame() == bVert )? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ); + SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori; std::optional<SwBorderAttrAccess> oAccess; const SwBorderAttrs*pAttrs = nullptr; @@ -975,32 +975,36 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) { // Set FixSize; VarSize is set by Format() after calculating the PrtArea setFramePrintAreaValid(false); - - SwTwips nPrtWidth = (GetUpper()->getFramePrintArea().*fnRect->fnGetWidth)(); - if( bVert && ( IsBodyFrame() || IsFootnoteContFrame() ) ) - { - SwFrame* pNxt = GetPrev(); - while( pNxt && !pNxt->IsHeaderFrame() ) - pNxt = pNxt->GetPrev(); - if( pNxt ) - nPrtWidth -= pNxt->getFrameArea().Height(); - pNxt = GetNext(); - while( pNxt && !pNxt->IsFooterFrame() ) - pNxt = pNxt->GetNext(); - if( pNxt ) - nPrtWidth -= pNxt->getFrameArea().Height(); - } - - const tools::Long nDiff = nPrtWidth - (getFrameArea().*fnRect->fnGetWidth)(); SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this); - if( IsNeighbourFrame() && IsRightToLeft() ) + if (IsNeighbourFrame()) { - (aFrm.*fnRect->fnSubLeft)( nDiff ); + SwTwips nPrtHeight = (GetUpper()->getFramePrintArea().*fnRect->fnGetHeight)(); + const tools::Long nDiff = nPrtHeight - (getFrameArea().*fnRect->fnGetHeight)(); + (aFrm.*fnRect->fnAddBottom)( nDiff ); } else { - (aFrm.*fnRect->fnAddRight)( nDiff ); + SwTwips nPrtWidth = (GetUpper()->getFramePrintArea().*fnRect->fnGetWidth)(); + if( bVert && ( IsBodyFrame() || IsFootnoteContFrame() ) ) + { + SwFrame* pNxt = GetPrev(); + while( pNxt && !pNxt->IsHeaderFrame() ) + pNxt = pNxt->GetPrev(); + if( pNxt ) + nPrtWidth -= pNxt->getFrameArea().Height(); + pNxt = GetNext(); + while( pNxt && !pNxt->IsFooterFrame() ) + pNxt = pNxt->GetNext(); + if( pNxt ) + nPrtWidth -= pNxt->getFrameArea().Height(); + } + + const tools::Long nDiff = nPrtWidth - (getFrameArea().*fnRect->fnGetWidth)(); + if(IsRightToLeft() ) + (aFrm.*fnRect->fnSubLeft)( nDiff ); + else + (aFrm.*fnRect->fnAddRight)( nDiff ); } } else |