diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-06-29 07:54:17 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-06-29 10:51:11 +0200 |
commit | 761d3a128214b48645f00e2ff094e0f8928d1ee1 (patch) | |
tree | 5b86dd3344617260176d4ec0fb1e50f2981dff49 /sw/qa/core | |
parent | 6ab6f7bf61efe7f42161a2d5760763bf39f8795a (diff) |
This reverts commit 7ef9c3ef30023cc40068e1f735aa4bec4811288b (plus relevant part
of c08d71a0e0015ec7857335b68a354df04fa04a0c "Fix typos" follow-up). It started
to cause <https://ci.libreoffice.org/job/lo_ubsan/2441/> to fail with
> /sw/source/core/text/itrcrsr.cxx:1659:50: runtime error: downcast of address 0x60700059b250 which does not point to an object of type 'SwTextPortion'
> 0x60700059b250: note: object is of type 'SwHolePortion'
> 00 00 00 00 90 23 40 a7 6f 7f 00 00 e1 03 00 00 00 00 00 00 0d 01 00 00 00 00 00 00 00 00 00 00
> ^~~~~~~~~~~~~~~~~~~~~~~
> vptr for 'SwHolePortion'
> #0 0x7f6f9f1777f0 in SwTextCursor::GetModelPositionForViewPoint(SwPosition*, Point const&, bool, SwCursorMoveState*) const /sw/source/core/text/itrcrsr.cxx:1659:50
> #1 0x7f6f9efc2b39 in SwTextFrame::UnitDown_(SwPaM*, long, bool) const /sw/source/core/text/frmcrsr.cxx:1200:49
> #2 0x7f6f9efc5b50 in SwTextFrame::UnitDown(SwPaM*, long, bool) const /sw/source/core/text/frmcrsr.cxx:1298:31
> #3 0x7f6f9be4bac8 in SwCursor::UpDown(bool, unsigned short, Point const*, long, SwRootFrame&) /sw/source/core/crsr/swcrsr.cxx:2062:31
> #4 0x7f6f9bf0692b in SwShellCursor::UpDown(bool, unsigned short) /sw/source/core/crsr/viscrs.cxx:1025:22
> #5 0x7f6f9bb840c0 in SwCursorShell::UpDown(bool, unsigned short) /sw/source/core/crsr/crsrsh.cxx:511:29
> #6 0x7f6fa37f131d in SwCursorShell::Down(unsigned short) /sw/inc/crsrsh.hxx:359:50
> #7 0x7f6fa37dcfc9 in SwWrtShell::Down(bool, unsigned short, bool) /sw/source/uibase/wrtsh/move.cxx:171:27
> #8 0x7f6fb6aa1325 in testTdf43100_CursorMoveToSpacesOverMargin::TestBody() /sw/qa/core/text/text.cxx:532:20
during CppunitTest_sw_core_text
CPPUNIT_TEST_NAME=testTdf43100_CursorMoveToSpacesOverMargin::TestBody
Change-Id: I37947825ec9db826446ed28fa87a23ee60749b82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136549
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/core')
-rw-r--r-- | sw/qa/core/text/data/tdf43100_tdf120715_cursorOnSpacesOverMargin.docx | bin | 9606 -> 0 bytes | |||
-rw-r--r-- | sw/qa/core/text/text.cxx | 68 |
2 files changed, 0 insertions, 68 deletions
diff --git a/sw/qa/core/text/data/tdf43100_tdf120715_cursorOnSpacesOverMargin.docx b/sw/qa/core/text/data/tdf43100_tdf120715_cursorOnSpacesOverMargin.docx Binary files differdeleted file mode 100644 index 474d805d893e..000000000000 --- a/sw/qa/core/text/data/tdf43100_tdf120715_cursorOnSpacesOverMargin.docx +++ /dev/null diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 99d80f649fef..2db4d6dab348 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -470,74 +470,6 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testRedlineDelete) pDoc->getIDocumentRedlineAccess().GetRedlineTable().size()); } -CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf120715_CursorMoveWhenTypingSpaceAtCenteredLineEnd) -{ - SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf43100_tdf120715_cursorOnSpacesOverMargin.docx"); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - - // Make a paint to force the call of AddExtraBlankWidth, that calculate width for holePortions. - pDoc->GetDocShell()->GetPreviewBitmap(); - - // Move the cursor to the last character of the document. - pWrtShell->EndOfSection(); - - //Press space and check if the cursor move right with the additional space. - sal_Int32 nOldCursorPos = pWrtShell->GetCharRect().Left(); - pWrtShell->Insert(" "); - sal_Int32 nNewCursorPos = pWrtShell->GetCharRect().Left(); - CPPUNIT_ASSERT_GREATER(nOldCursorPos, nNewCursorPos); -} - -CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf43100_CursorMoveToSpacesOverMargin) -{ - // Test the cursor movement over the right margin in several different paragraphs. - // These differences are based on its paragraphs - // - alignment (left, center, right, justified), - // - line count (1 line, 2 lines, blank line containing only spaces) - SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf43100_tdf120715_cursorOnSpacesOverMargin.docx"); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - - // Make a paint to force the call of AddExtraBlankWidth, that calculate width for holePortions. - pDoc->GetDocShell()->GetPreviewBitmap(); - - // Move the cursor to the 2. line. - pWrtShell->Down(/*bSelect=*/false, 1, /*bBasicCall=*/false); - // Move the cursor to the right margin. - pWrtShell->RightMargin(false, false); - - sal_Int32 nMarginPos = pWrtShell->GetCharRect().Left(); - sal_Int32 nLastCursorPos = nMarginPos; - - // Move the cursor right 5 times, every step should increase the cursor x position. - // Before this fix, the cursor stopped at the margin. - for (int i = 0; i < 5; i++) - { - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); - sal_Int32 nNewCursorPos = pWrtShell->GetCharRect().Left(); - CPPUNIT_ASSERT_GREATER(nLastCursorPos, nNewCursorPos); - nLastCursorPos = nNewCursorPos; - } - - // Move down the cursor several lines, and check if it will keep nearly its horizontal position. - // Some of the lines are not reach beyond the margin, there the cursor won't be able to keep its - // original position. - bool aLineReachOverMargin[] = { false, true, true, false, false, true, true, false, true, - true, true, true, false, true, true, false, false }; - // Cursor position can be a bit inaccurate, because it can only be positioned on characters, - // that is based on the actual line layout, therefore the actual cursor position - // is checked against a more distinct position instead of the nMarginPos. - sal_Int32 nAvgLeft = (nMarginPos + nLastCursorPos) / 2; - for (int i = 2; i < 17; i++) - { - pWrtShell->Down(/*bSelect=*/false, 1, /*bBasicCall=*/false); - sal_Int32 nNewCursorPos = pWrtShell->GetCharRect().Left(); - if (aLineReachOverMargin[i]) - CPPUNIT_ASSERT_GREATER(nAvgLeft, nNewCursorPos); - else - CPPUNIT_ASSERT_LESS(nAvgLeft, nNewCursorPos); - } -} - CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |