summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-12-14 21:05:02 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2020-12-16 13:13:26 +0100
commitb4e9f8093daecec90e8294287029070262a634ac (patch)
treed5c9b519dbd9f959a368580592855535d65eed51
parentbb3d6a788001436ef29d0f5e53431c8c0a75040e (diff)
tdf#138600 sw: fix too small print area for btlr text in nested table
Regression from commit 435ab51ec8920033b7865f27f4afee8a852a0b31 (tdf#128399 sw btlr: fix clicking to lower rotated cell, 2019-10-29), the bugdoc has a btlr table cell and the row frame of the outer table has a bottom value which is very small at the point when SwFrame::GetPaintArea() is invoked for the inner btlr cell. This means the "cell should not leave its parent" mechanism kicks in and reduces the bottom of the paint area to a small value, so the text is not visible at all. Fix the problem by teaching SwFrame::GetPaintArea() that btlr cell frames are OK to leave their parent towards the bottom of the page; that parent will grow at a later phase of the layout process anyway. Change-Id: I99334bbf0116df8d8ed27f192c81c0441b6c797d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107730 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107787 Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107818
-rw-r--r--sw/qa/core/layout/data/btlr-nested-cell.odtbin0 -> 9936 bytes
-rw-r--r--sw/qa/core/layout/layout.cxx26
-rw-r--r--sw/source/core/layout/ssfrm.cxx3
3 files changed, 28 insertions, 1 deletions
diff --git a/sw/qa/core/layout/data/btlr-nested-cell.odt b/sw/qa/core/layout/data/btlr-nested-cell.odt
new file mode 100644
index 000000000000..ca7a4798db97
--- /dev/null
+++ b/sw/qa/core/layout/data/btlr-nested-cell.odt
Binary files differ
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index 947152de49c6..6a6840f425a4 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -15,6 +15,8 @@
#include <wrtsh.hxx>
#include <IDocumentDrawModelAccess.hxx>
#include <drawdoc.hxx>
+#include <IDocumentLayoutAccess.hxx>
+#include <rootfrm.hxx>
static char const DATA_DIRECTORY[] = "/sw/qa/core/layout/data/";
@@ -171,6 +173,30 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxAutoGrowVertical)
CPPUNIT_ASSERT(aShapeRect.IsInside(aFlyRect));
}
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBtlrNestedCell)
+{
+ // Load a document with a nested table, the inner A1 cell has a btlr text direction.
+ load(DATA_DIRECTORY, "btlr-nested-cell.odt");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ SwFrame* pPage = pLayout->GetLower();
+ SwFrame* pBody = pPage->GetLower();
+ SwFrame* pOuterTable = pBody->GetLower()->GetNext();
+ SwFrame* pInnerTable = pOuterTable->GetLower()->GetLower()->GetLower();
+
+ // Check the paint area of the only text frame in the cell.
+ SwFrame* pTextFrame = pInnerTable->GetLower()->GetLower()->GetLower();
+ long nFrameBottom = pTextFrame->getFrameArea().Bottom();
+ SwRect aPaintArea = pTextFrame->GetPaintArea();
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected greater or equal than: 2829
+ // - Actual : 2080
+ // i.e. part of the text frame area was not painted, hiding the actual text.
+ CPPUNIT_ASSERT_GREATEREQUAL(nFrameBottom, aPaintArea.Bottom());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index 1a92144a5583..59d7d64afdd8 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -626,7 +626,8 @@ SwRect SwFrame::GetPaintArea() const
pTmp->IsCellFrame() || pTmp->IsRowFrame() || //nobody leaves a table!
pTmp->IsRootFrame() )
{
- if( bLeft || aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 )
+ // BTLR is OK to expand towards the physical down direction. Physical down is left.
+ if( bLeft || (aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 && !IsVertLRBT()) )
nLeft = nTmpLeft;
if( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 )
nRight = nTmpRight;