summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-04-15 21:01:11 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-04-16 14:04:33 +0200
commit8072a926da2a02dfaf3fa848a2976634641a594f (patch)
tree611fab8ce92f4522dc9b3449b28e204652ddb694
parent8c75e66234b01b0a336f2eff107cc378286583e4 (diff)
tdf#124521 sw btlr writing mode render: fix paint rectangle on scroll
By implementing btlr support in SwTextFrame::SwitchVerticalToHorizontal(SwRect), so not only invalidation but paint rectangle is also correct, which means actual text painting happens. Change-Id: I4215799ff63c93b300e4e8f97c6824f75d7c5401 Reviewed-on: https://gerrit.libreoffice.org/70797 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/layout/layout.cxx31
-rw-r--r--sw/source/core/text/txtfrm.cxx13
2 files changed, 43 insertions, 1 deletions
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index ff06af442bff..e44acc8ba1c0 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -22,6 +22,7 @@
#include <wrtsh.hxx>
#include <edtwin.hxx>
#include <view.hxx>
+#include <txtfrm.hxx>
static char const DATA_DIRECTORY[] = "/sw/qa/extras/layout/data/";
@@ -2839,6 +2840,36 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testBtlrCell)
ss << "selection rectangle " << rRect << " is not inside cell rectangle " << aCellRect;
CPPUNIT_ASSERT_MESSAGE(ss.str(), aCellRect.IsInside(rRect));
}
+
+ // Make sure that the correct rectangle gets repainted on scroll.
+ SwFrame* pPageFrame = pLayout->GetLower();
+ CPPUNIT_ASSERT(pPageFrame->IsPageFrame());
+
+ SwFrame* pBodyFrame = pPageFrame->GetLower();
+ CPPUNIT_ASSERT(pBodyFrame->IsBodyFrame());
+
+ SwFrame* pTabFrame = pBodyFrame->GetLower();
+ CPPUNIT_ASSERT(pTabFrame->IsTabFrame());
+
+ SwFrame* pRowFrame = pTabFrame->GetLower();
+ CPPUNIT_ASSERT(pRowFrame->IsRowFrame());
+
+ SwFrame* pCellFrame = pRowFrame->GetLower();
+ CPPUNIT_ASSERT(pCellFrame->IsCellFrame());
+
+ SwFrame* pFrame = pCellFrame->GetLower();
+ CPPUNIT_ASSERT(pFrame->IsTextFrame());
+
+ SwTextFrame* pTextFrame = static_cast<SwTextFrame*>(pFrame);
+ pTextFrame->SwapWidthAndHeight();
+ // Mimic what normally SwTextFrame::PaintSwFrame() does:
+ SwRect aRect(4207, 2273, 269, 572);
+ pTextFrame->SwitchVerticalToHorizontal(aRect);
+ // Without the accompanying fix in place, this test would have failed with:
+ // Expected: 572x269@(1691,4217)
+ // Actual : 572x269@(2263,4217)
+ // i.e. the paint rectangle position was incorrect, text was not painted on scrolling up.
+ CPPUNIT_ASSERT_EQUAL(SwRect(1691, 4217, 572, 269), aRect);
#endif
}
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index f71fee6ec9d5..66beb06d3928 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -595,7 +595,18 @@ void SwTextFrame::SwitchVerticalToHorizontal( SwRect& rRect ) const
nOfstX = getFrameArea().Left() + getFrameArea().Width() - ( rRect.Left() + rRect.Width() );
}
- const long nOfstY = rRect.Top() - getFrameArea().Top();
+ long nOfstY;
+ if (IsVertLRBT())
+ {
+ // Note that mbIsSwapped only affects the frame area, not rRect, so rRect.Height() is used
+ // here unconditionally.
+ if (mbIsSwapped)
+ nOfstY = getFrameArea().Top() + getFrameArea().Width() - (rRect.Top() + rRect.Height());
+ else
+ nOfstY = getFrameArea().Top() + getFrameArea().Height() - (rRect.Top() + rRect.Height());
+ }
+ else
+ nOfstY = rRect.Top() - getFrameArea().Top();
const long nWidth = rRect.Height();
const long nHeight = rRect.Width();