diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-05-22 08:47:32 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-05-22 10:27:36 +0200 |
commit | 080afd6a345e5dffd924100b5a3ff9c028f5b094 (patch) | |
tree | 60142f82c48c42b9ab879496ed4693db23567fb0 /xmloff | |
parent | 76941af9837406b1526b2f2d13c89df7a2023072 (diff) |
Related: tdf#145972 sw images: fix rounding error in relative size calculation
Open the bugdoc, see that the image is roughly half of the page width,
right click, properties, UI shows that the width of the image is 5% of
the width of the entire page. This only happens if tools -> options ->
writer -> general sets the UI units to points, the default cm case is
fine.
This went wrong with commit 9e8712ed6f9fb5dbd971e352a5709bd45fadc74f (sw
image dialog: fix fallback width/height for images with relative sizes,
2022-03-17), because the layout size started to matter more after that
commit. This lead to the nWidth !=
m_xWidthED->get_value(FieldUnit::TWIP) check in SwFramePage::Init() to
be true, because 11906 * 0.48 is 5714.88, so you got 5714 in the layout,
but got 5715 with rounding in SwFramePage::Reset() (which tries to calc
the page width based on the 48% and the fly width). And once we had that
mismatch, we went down the wrong path.
Fix the problem by using rtl::math::round() in SwFlyFrame::CalcRel(), so
the relative width twips value is 5715 everywhere: once we have
consisteny, the UI value is correct, too.
Note that the original bugdoc needs more fixing, this just fixes the
bugdoc where KeepRatio is false.
Change-Id: I1e8782c95a0cf9d97375c36d41134735c01f3e46
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167916
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/qa/unit/text.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 1679af04bc1f..f95e07e42578 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -508,11 +508,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testRelativeWidth) xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this failed with: - // - Expected: 3.1492in (8cm) + // - Expected: 3.15in (8cm) // - Actual : 0.0161in (0.04 cm) // i.e. the fallback width value wasn't the expected half of the body frame width, but a smaller // value. - assertXPath(pXmlDoc, "//draw:frame"_ostr, "width"_ostr, u"3.1492in"_ustr); + assertXPath(pXmlDoc, "//draw:frame"_ostr, "width"_ostr, u"3.15in"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testScaleWidthAndHeight) |