sd/qa/unit/export-tests.cxx | 12 ++++++++---- svx/source/svdraw/svdpdf.cxx | 11 +++++++---- 2 files changed, 15 insertions(+), 8 deletions(-)
New commits: commit c06229c7c9c4182a1c81516fbcbd59e81f2c14b0 Author: Caolán McNamara <[email protected]> AuthorDate: Fri Oct 31 15:09:08 2025 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 31 17:31:26 2025 +0100 text in an fodg converted from pdf reimporting split over two lines when it began as one line. The original pdf breakup sets a font size which when exported and reimported through the various intermediate conversions results in a larger size used on reimport that doesn't fit in the original textbox. Best thing is to reduce to what can be represented as a twip and convert from that starting point. Change-Id: I24a6ccb4977112f2dc708ba737be07aeb86437dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193272 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index a6b0aab22971..da0afc2f6890 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -1064,7 +1064,11 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfTextPos) CPPUNIT_ASSERT_DOUBLES_EQUAL(2003, x, 0); sal_Int32 y = getXPath(pXml, "//textarray[1]", "y").toInt32(); // was 3092 originally - CPPUNIT_ASSERT_DOUBLES_EQUAL(3063, y, 0); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3057, y, 0); + + // Before fix, on reimport this was split over two lines when it + // should have remained as one line. + assertXPath(pXml, "//textarray", 1); } CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfFont) @@ -1092,13 +1096,13 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfFont) CPPUNIT_ASSERT_EQUAL(494, nFontHeight); } { - OUString sWeight = getXPath(pXml, "//font[4]", "weight"); + OUString sWeight = getXPath(pXml, "//font[3]", "weight"); // was "normal" before CPPUNIT_ASSERT_EQUAL(u"bold"_ustr, sWeight); // check that the others remain as expected - OUString sFontName = getXPath(pXml, "//font[4]", "name"); + OUString sFontName = getXPath(pXml, "//font[3]", "name"); CPPUNIT_ASSERT_EQUAL(u"Liberation Sans"_ustr, sFontName); - sal_Int32 nFontHeight = getXPath(pXml, "//font[4]", "height").toInt32(); + sal_Int32 nFontHeight = getXPath(pXml, "//font[3]", "height").toInt32(); CPPUNIT_ASSERT_EQUAL(564, nFontHeight); } } diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 8a0dc3a10429..25c8a81ef101 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -1775,10 +1775,13 @@ void ImpSdrPdfImport::ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> con double dFontSizeH = fabs(std::hypot(aMatrix.a(), aMatrix.c()) * dFontSize); double dFontSizeV = fabs(std::hypot(aMatrix.b(), aMatrix.d()) * dFontSize); - dFontSizeH = convertPointToMm100(dFontSizeH); - dFontSizeV = convertPointToMm100(dFontSizeV); - - const Size aFontSize(dFontSizeH, dFontSizeV); + // We will only really be able to squeeze a font size in whole units of + // twips through the various layers esp. export and reimport, so work in + // twips here and LogicToLogic so we don't end up using a value that cannot + // be roundtripped back. + const Size aFontSizeTwips(dFontSizeH * 20, dFontSizeV * 20); + const Size aFontSize(OutputDevice::LogicToLogic(aFontSizeTwips, MapMode(MapUnit::MapTwip), + MapMode(MapUnit::Map100thMM))); vcl::Font aFnt = mpVD->GetFont(); aFnt.SetFontSize(aFontSize);
