diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-05-03 14:14:26 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-05-03 18:43:44 +0200 |
commit | 4d0987564c33bbccc9b58e041d106c6caf7686a3 (patch) | |
tree | 5aaf9570af56eb51c712a07c12f599e3c4cee098 | |
parent | 740353bc31583d9e8ad77a2b2289a204466ccf9e (diff) |
tdf#152906: use correct Y offset
GetEditCursor now returns the position relative to the line, not
to the whole text. In ImpEditEngine::CreateLines, its use wasn't
fixed, and so the Y position of all lines in the calculation was
the same, thus adjusting to the same contour's horizontal stripe.
Change-Id: I16362bab47f3064281eefb45a12834d836a8ada3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167042
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 2 | ||||
-rw-r--r-- | sd/qa/unit/data/odg/adjust-to-contour.fodg | 52 | ||||
-rw-r--r-- | sd/qa/unit/layout-tests.cxx | 48 |
3 files changed, 101 insertions, 1 deletions
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index f548e2423490..288afb5a33bd 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -923,7 +923,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) { GetTextRanger()->SetVertical( IsEffectivelyVertical() ); - tools::Long nTextY = nStartPosY + GetEditCursor(rParaPortion, *pLine, pLine->GetStart(), CursorFlags()).Top(); + tools::Long nTextY = nCurrentPosY + GetEditCursor(rParaPortion, *pLine, pLine->GetStart(), CursorFlags()).Top(); if ( !bSameLineAgain ) { SeekCursor( pNode, nTmpPos+1, aTmpFont ); diff --git a/sd/qa/unit/data/odg/adjust-to-contour.fodg b/sd/qa/unit/data/odg/adjust-to-contour.fodg new file mode 100644 index 000000000000..a5ec6fed74fc --- /dev/null +++ b/sd/qa/unit/data/odg/adjust-to-contour.fodg @@ -0,0 +1,52 @@ +<?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:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.graphics"> + <office:font-face-decls> + <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="roman" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:punctuation-wrap="simple" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + </style:default-style> + <style:style style:name="standard" style:family="graphic"> + <style:graphic-properties draw:stroke="solid" svg:stroke-width="0cm" draw:marker-start-width="0.2cm" draw:marker-start-center="false" draw:marker-end-width="0.2cm" draw:marker-end-center="false" draw:fill="solid" draw:textarea-horizontal-align="justify" fo:padding-top="0" fo:padding-bottom="0" fo:padding-left="0" fo:padding-right="0" fo:wrap-option="wrap" draw:shadow="hidden" draw:shadow-offset-x="0.2cm" draw:shadow-offset-y="0.2cm" draw:shadow-color="#808080"/> + <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" fo:line-height="100%" fo:text-indent="0cm"/> + <style:text-properties fo:font-variant="normal" fo:text-transform="none" style:use-window-font-color="true" style:text-outline="false" style:text-line-through-style="none" style:text-line-through-type="none" style:font-name="Liberation Sans" fo:font-size="18pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:letter-kerning="true" style:text-emphasize="none" style:font-relief="none" style:text-overline-style="none" style:text-overline-color="font-color"/> + </style:style> + </office:styles> + <office:automatic-styles> + <style:page-layout style:name="PM0"> + <style:page-layout-properties fo:margin-top="0" fo:margin-bottom="0" fo:margin-left="0" fo:margin-right="0" fo:page-width="21cm" fo:page-height="29.7cm" style:print-orientation="portrait"/> + </style:page-layout> + <style:style style:name="dp1" style:family="drawing-page"/> + <style:style style:name="gr1" style:family="graphic" style:parent-style-name="standard"> + <style:graphic-properties draw:textarea-vertical-align="middle" draw:fit-to-contour="true"/> + </style:style> + <style:style style:name="P1" style:family="paragraph"> + <style:paragraph-properties fo:text-align="center"/> + <style:text-properties fo:language="zxx" fo:country="none"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <draw:layer-set> + <draw:layer draw:name="layout"/> + <draw:layer draw:name="background"/> + <draw:layer draw:name="backgroundobjects"/> + <draw:layer draw:name="controls"/> + <draw:layer draw:name="measurelines"/> + </draw:layer-set> + <style:master-page style:name="Default" style:page-layout-name="PM0" draw:style-name="dp1"/> + </office:master-styles> + <office:body> + <office:drawing> + <draw:page draw:name="page1" draw:style-name="dp1" draw:master-page-name="Default"> + <draw:ellipse draw:style-name="gr1" draw:layer="layout" svg:width="13cm" svg:height="13cm" svg:x="4cm" svg:y="8cm"> + <text:p text:style-name="P1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat mi quis pretium semper. Proin luctus orci ac neque venenatis, quis commodo dolor posuere. Curabitur dignissim sapien quis cursus egestas. Donec blandit auctor arcu, nec pellentesque eros molestie eget. In consectetur aliquam hendrerit. Sed cursus mauris vitae ligula pellentesque, non pellentesque urna aliquet. Fusce placerat mauris enim, nec rutrum purus semper vel. Praesent tincidunt neque eu pellentesque pharetra. Fusce pellentesque est orci.</text:p> + </draw:ellipse> + </draw:page> + </office:drawing> + </office:body> +</office:document>
\ No newline at end of file diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx index 1735f6574be3..8143b82e5a1b 100644 --- a/sd/qa/unit/layout-tests.cxx +++ b/sd/qa/unit/layout-tests.cxx @@ -380,6 +380,54 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf112594) u"11\u202f\u1824"_ustr); } +CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf152906_AdjustToContour) +{ + // Test that the text adjusts to contour properly + + constexpr OUString sText + = u"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat mi quis " + "pretium semper. Proin luctus orci ac neque venenatis, quis commodo dolor posuere. " + "Curabitur dignissim sapien quis cursus egestas. Donec blandit auctor arcu, nec " + "pellentesque eros molestie eget. In consectetur aliquam hendrerit. Sed cursus mauris " + "vitae ligula pellentesque, non pellentesque urna aliquet. Fusce placerat mauris enim, " + "nec rutrum purus semper vel. Praesent tincidunt neque eu pellentesque pharetra. Fusce " + "pellentesque est orci."_ustr; + + // index, length, x, y + const std::tuple<int, int, int, int> strings[] = { + { 0, 6, 9599, 8647 }, // Lorem + { 6, 22, 7570, 9358 }, // ipsum dolor sit amet, + { 28, 29, 6775, 10069 }, // consectetur adipiscing elit. + { 57, 29, 6299, 10780 }, // Vestibulum consequat mi quis + { 86, 37, 5453, 11491 }, // pretium semper. Proin luctus orci ac + { 123, 36, 5134, 12202 }, // neque venenatis, quis commodo dolor + { 159, 41, 4764, 12913 }, // posuere. Curabitur dignissim sapien quis + { 200, 43, 4481, 13624 }, // cursus egestas. Donec blandit auctor arcu, + { 243, 40, 4975, 14335 }, // nec pellentesque eros molestie eget. In + { 283, 42, 4552, 15046 }, // consectetur aliquam hendrerit. Sed cursus + { 325, 38, 5363, 15757 }, // mauris vitae ligula pellentesque, non + { 363, 42, 4692, 16468 }, // pellentesque urna aliquet. Fusce placerat + { 405, 37, 5047, 17179 }, // mauris enim, nec rutrum purus semper + { 442, 33, 5963, 17890 }, // vel. Praesent tincidunt neque eu + { 475, 29, 6387, 18601 }, // pellentesque pharetra. Fusce + { 504, 22, 7499, 19312 }, // pellentesque est orci. + }; + + xmlDocUniquePtr pXmlDoc = load("odg/adjust-to-contour.fodg"); + + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray"_ostr, std::size(strings)); + for (size_t i = 0; i < std::size(strings); ++i) + { + const auto & [ index, length, x, y ] = strings[i]; + OString sXPath = "/metafile/push[1]/push[1]/textarray[" + OString::number(i + 1) + "]"; + assertXPathContent(pXmlDoc, sXPath + "/text", sText); + assertXPath(pXmlDoc, sXPath, "index"_ostr, OUString::number(index)); + assertXPath(pXmlDoc, sXPath, "length"_ostr, OUString::number(length)); + assertXPath(pXmlDoc, sXPath, "x"_ostr, OUString::number(x)); + assertXPath(pXmlDoc, sXPath, "y"_ostr, OUString::number(y)); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |