summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-02-27 21:31:06 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-02-28 09:17:49 +0100
commit8ae5a98852c2f3d87d6efff598f0c7d54df835d3 (patch)
treebf5105ab44f1a3f2df7cdfb21c5cda24b43cd890
parent8701bed5e8cf344dfc2c10051bbf42291b6cb8d9 (diff)
sw btlr writing mode shell: left/right cursor travelling, fix dest para
Fix aVerticalLeftToRightBottomToTop: - fnXDiff takes "logically larger, logically smaller" arguments, so it's first - second for top to bottom text (existing directions) but it's second - first for btlr - fnXInc was effectively unused before, but it probably meant to provide logical left + width, so set that to physical left - width for btlr And then port 3 places in lcl_UpDown() to use aRectFnSet, so we get correct behavior for both ttb and btt directions. With this, pressing the left/right arrow jumps to the previous / next paragraph correctly. Change-Id: I1323e95e2ce0ab2d66a3ea6e02bd50df2cebf232 Reviewed-on: https://gerrit.libreoffice.org/68462 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/layout/layout.cxx9
-rw-r--r--sw/source/core/layout/newfrm.cxx4
-rw-r--r--sw/source/core/layout/trvlfrm.cxx12
3 files changed, 17 insertions, 8 deletions
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index a1f805d42bd9..6b54065d9e88 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2841,6 +2841,7 @@ void SwLayoutWriter::testBtlrCell()
CPPUNIT_ASSERT_LESS(nFirstParaBottom, rCharRect.Top());
// Test that pressing "up" at the start of the cell goes to the next character position.
+ sal_uLong nNodeIndex = pWrtShell->GetCursor()->Start()->nNode.GetIndex();
sal_Int32 nIndex = pWrtShell->GetCursor()->Start()->nContent.GetIndex();
KeyEvent aKeyEvent(0, KEY_UP);
SwEditWin& rEditWin = pShell->GetView()->GetEditWin();
@@ -2849,6 +2850,14 @@ void SwLayoutWriter::testBtlrCell()
// Without the accompanying fix in place, this test would have failed: "up" was interpreted as
// logical "left", which does nothing if you're at the start of the text anyway.
CPPUNIT_ASSERT_EQUAL(nIndex + 1, pWrtShell->GetCursor()->Start()->nContent.GetIndex());
+
+ // Test that pressing "right" goes to the next paragraph (logical "down").
+ aKeyEvent = KeyEvent(0, KEY_RIGHT);
+ rEditWin.KeyInput(aKeyEvent);
+ Scheduler::ProcessEventsToIdle();
+ // Without the accompanying fix in place, this test would have failed: the cursor went to the
+ // paragraph after the table.
+ CPPUNIT_ASSERT_EQUAL(nNodeIndex + 1, pWrtShell->GetCursor()->Start()->nNode.GetIndex());
#endif
}
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index 94e016434e47..bfaf62657091 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -275,9 +275,9 @@ static SwRectFnCollection aVerticalLeftToRightBottomToTop = {
/*.fnSetPos =*/&SwRect::SetLowerLeftCorner,
/*.fnMakePos =*/&SwFrame::MakeRightPos,
- /*.fnXDiff =*/&FirstMinusSecond,
+ /*.fnXDiff =*/&SecondMinusFirst,
/*.fnYDiff =*/&FirstMinusSecond,
- /*.fnXInc =*/&SwIncrement,
+ /*.fnXInc =*/&SwDecrement,
/*.fnYInc =*/&SwIncrement,
/*.fnSetLeftAndWidth =*/&SwRect::SetBottomAndHeight,
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index a434a20567c2..912cbafbb43e 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -757,8 +757,8 @@ static bool lcl_UpDown( SwPaM *pPam, const SwContentFrame *pStart,
while ( pCell && !pCell->IsCellFrame() )
pCell = pCell->GetUpper();
OSL_ENSURE( pCell, "could not find the cell" );
- nX = aRectFnSet.GetLeft(pCell->getFrameArea()) +
- aRectFnSet.GetWidth(pCell->getFrameArea()) / 2;
+ nX = aRectFnSet.XInc(aRectFnSet.GetLeft(pCell->getFrameArea()),
+ aRectFnSet.GetWidth(pCell->getFrameArea()) / 2);
//The flow leads from one table to the next. The X-value needs to be
//corrected based on the middle of the starting cell by the amount
@@ -778,14 +778,14 @@ static bool lcl_UpDown( SwPaM *pPam, const SwContentFrame *pStart,
const long nPrtLeft = bRTL ?
aRectFnSet.GetPrtRight(*pTable) :
aRectFnSet.GetPrtLeft(*pTable);
- if ( bRTL != (nX < nPrtLeft) )
+ if (bRTL != (aRectFnSet.XDiff(nPrtLeft, nX) > 0))
nX = nPrtLeft;
else
{
const long nPrtRight = bRTL ?
aRectFnSet.GetPrtLeft(*pTable) :
aRectFnSet.GetPrtRight(*pTable);
- if ( bRTL != (nX > nPrtRight) )
+ if (bRTL != (aRectFnSet.XDiff(nX, nPrtRight) > 0))
nX = nPrtRight;
}
}
@@ -884,7 +884,7 @@ static bool lcl_UpDown( SwPaM *pPam, const SwContentFrame *pStart,
if ( aRectFnSet.IsVert() )
{
if ( nTmpTop )
- --nTmpTop;
+ nTmpTop = aRectFnSet.XInc(nTmpTop, -1);
aInsideCell = Point( nTmpTop, nX );
}
@@ -896,7 +896,7 @@ static bool lcl_UpDown( SwPaM *pPam, const SwContentFrame *pStart,
if ( aRectFnSet.IsVert() )
{
if ( nTmpTop )
- --nTmpTop;
+ nTmpTop = aRectFnSet.XInc(nTmpTop, -1);
aInsideCnt = Point( nTmpTop, nX );
}