svx/source/svdraw/svdpdf.cxx |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 88c70ae002120f46e1f9a2a5cac2f73f835a4984
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Apr 30 19:07:44 2020 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Jun 8 13:43:54 2020 +0200

    SdrPdfImport: fix garbled text at breaking the PDF graphic
    
    The text size of OUString expects no. of characters, but we give
    the number of bytes as that is what we get from PDFium. Best to
    just not give the text size at all and let OUString determine
    that as the text shouldbe terminated correctly.
    
    Change-Id: Icc5cd6e851a9d2920faa9ca2eb6d827465483e72
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93330
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit d4190effb9068dff5ebd3c01c7e3073b1af78b2d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95782
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 106718a34aa9..78bb7131ae13 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -810,16 +810,19 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
     const tools::Rectangle aRect = PointsToLogic(aTextRect.getMinX(), 
aTextRect.getMaxX(),
                                                  aTextRect.getMinY(), 
aTextRect.getMaxY());
 
-    const int nChars = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0);
-    std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars]);
+    const int nBytes = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0);
+    std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nBytes]);
 
-    const int nActualChars = FPDFTextObj_GetText(pPageObject, pTextPage, 
pText.get(), nChars);
-    if (nActualChars <= 0)
+    const int nActualBytes = FPDFTextObj_GetText(pPageObject, pTextPage, 
pText.get(), nBytes);
+    if (nActualBytes <= 0)
     {
         return;
     }
 
-    OUString sText(pText.get(), nActualChars);
+    // Let's rely on null-terminaton for the length of the string. We
+    // just know the number of bytes the string takes, but in OUString
+    // needs the number of charaters.
+    OUString sText(pText.get());
 
     const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
     double dFontSizeH = fabs(sqrt2(a, c) * dFontSize);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to