diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-12-16 13:27:34 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-12-16 21:22:08 +0100 |
commit | c6a7cc15e971218c2488fc2bba8016937264e2e0 (patch) | |
tree | 9a9ab1c18791bf162d8f642b1de6624939ac0d3c /sw | |
parent | 0101975f8eac650bb87c4af81157cb33a6309e0e (diff) |
tdf#138592: also consider following zero-width text portions
... after this text portion, to handle possible combining characters
inside separate text span, and hence separate portions.
The fix is modelled after 63d8041c60c5d7c63dd34f94a694871b7ea9e2ca.
Thanks Justin!
Change-Id: Idf3b79ce1c384f093bce201ccb5ecefd350e1478
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107826
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/layout/data/tdf138592-a-acute.fodt | 31 | ||||
-rw-r--r-- | sw/qa/extras/layout/layout2.cxx | 30 | ||||
-rw-r--r-- | sw/source/core/text/itrcrsr.cxx | 6 |
3 files changed, 67 insertions, 0 deletions
diff --git a/sw/qa/extras/layout/data/tdf138592-a-acute.fodt b/sw/qa/extras/layout/data/tdf138592-a-acute.fodt new file mode 100644 index 000000000000..07bcabef1013 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf138592-a-acute.fodt @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:font-face-decls> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Serif1" svg:font-family="'Liberation Serif'" style:font-family-generic="roman"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="paragraph"> + <style:text-properties style:font-name="Liberation Serif" fo:font-size="12pt"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + </office:styles> + <office:automatic-styles> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="210.01mm" fo:page-height="297mm" style:print-orientation="portrait" fo:margin-top="20mm" fo:margin-bottom="20mm" fo:margin-left="20mm" fo:margin-right="20mm" style:writing-mode="lr-tb"/> + </style:page-layout> + <style:style style:name="T1" style:family="text"> + <style:text-properties style:font-name="Liberation Serif1"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <!-- A problem had been with a combining character in a separate span --> + <text:p text:style-name="Standard">a<text:span text:style-name="T1">́</text:span></text:p> + </office:text> + </office:body> +</office:document>
\ No newline at end of file diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index a62921e5c870..b87b4c992c60 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -1994,6 +1994,36 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testCommentCursorPosition) // bb<comment>| - the cursor should move behind the |, not before it. } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testCombiningCharacterCursorPosition) +{ + // Load a document that has "a" in it, followed by a combining acute in a separate rext span + SwDoc* pDoc = createDoc("tdf138592-a-acute.fodt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + SwRootFrame* pRoot = pWrtShell->GetLayout(); + CPPUNIT_ASSERT(pRoot->GetLower()->IsPageFrame()); + SwPageFrame* pPage = static_cast<SwPageFrame*>(pRoot->GetLower()); + CPPUNIT_ASSERT(pPage->GetLower()->IsBodyFrame()); + SwBodyFrame* pBody = static_cast<SwBodyFrame*>(pPage->GetLower()); + CPPUNIT_ASSERT(pBody->GetLower()->IsTextFrame()); + SwTextFrame* pTextFrame = static_cast<SwTextFrame*>(pBody->GetLower()); + + // Set a point in the whitespace past the end of the first line. + Point aPoint = pWrtShell->getShellCursor(false)->GetSttPos(); + aPoint.AdjustX(10000); + + // Ask for the doc model pos of this layout point. + SwPosition aPosition(*pTextFrame->GetTextNodeForFirstText()); + pTextFrame->GetModelPositionForViewPoint(&aPosition, aPoint); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 1 + // i.e. the cursor got positioned before the acute, so typing shifted the acute (applying it + // to newly typed characters) instead of adding content after it. + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aPosition.nContent.GetIndex()); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf64222) { createDoc("tdf64222.docx"); diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 6835ff41fa12..a4e3dca7c1ec 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -1271,6 +1271,12 @@ static bool ConsiderNextPortionForCursorOffset(const SwLinePortion* pPor, sal_uI return false; } + // tdf#138592: consider all following zero-width text portions of current text portion, + // like combining characters. + if (nWidth30 == nX && pPor->IsTextPortion() && pPor->GetNextPortion()->IsTextPortion() + && pPor->GetNextPortion()->Width() == 0) + return true; + // If we're past the target position, stop the iteration in general. // Exception: don't stop the iteration between as-char fly portions and their comments. if (nWidth30 >= nX && (!pPor->IsFlyCntPortion() || !pPor->GetNextPortion()->IsPostItsPortion())) |