sd/qa/unit/export-tests.cxx  |   12 ++++++++----
 svx/source/svdraw/svdpdf.cxx |   11 +++++++----
 2 files changed, 15 insertions(+), 8 deletions(-)

New commits:
commit d7ee2ba8f8f52621267cfb3846bb27a44e2fc7e4
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 20:31:34 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/+/193273
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index a5adfe25718d..085757fc86ed 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -1069,7 +1069,11 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, 
testExplodedPdfTextPos)
 #endif
     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)
@@ -1099,13 +1103,13 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdfFont)
 #if !defined _WIN32
     //TODO, debug this
     {
-        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);
-        int nFontHeight = getXPath(pXml, "//font[4]", "height").toInt32();
+        sal_Int32 nFontHeight = getXPath(pXml, "//font[3]", 
"height").toInt32();
         CPPUNIT_ASSERT_EQUAL(564, nFontHeight);
     }
 #endif
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 4d3cce3a707a..8941a9ca648e 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1797,10 +1797,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);
 

Reply via email to