sdext/source/pdfimport/wrapper/wrapper.cxx            |   52 ------------------
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |   26 ++++++---
 2 files changed, 18 insertions(+), 60 deletions(-)
New commits:
commit 0a03bf027eed9a952ac242a79a79711948228584
Author:     Kevin Suo <suokunl...@126.com>
AuthorDate: Sat Jul 10 11:47:39 2021 +0800
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Sun Oct 30 00:22:25 2022 +0200

    tdf#78427 sdext.pdfimport: No need to read a font file for the purpose of...
    
    ...determining the bold/italic/underline etc.
    
    The purpose for reading a font file is that in case the font attributes 
determined by the xpdfimport process is not enough, then we use the lo core 
font classes which read in the font file and then determine whether it is bold, 
italic etc.
    However, while this works in some cases, it does not work in many cases 
when the font file was actually a subset and a toUnicode map is followed in the 
PDF, see tdf#78427.
    In addition, in case the information collected from the xpdfimport process 
is enough, there is no need to read the font file.
    
    This commit removes the read of font file part. Also, this commit uses 
gfxFont->getNameWithoutSubsetTag() to get the font name with the subset tags 
removed, thus simplified the code in wrapper.cxx while also improves performace 
as the remove of subset tags is only run when the font is a subset (the 
previous code did this for all the font names).
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118733
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins
    (cherry picked from commit da59686672fd2bc98f8cb28d5f04dc978b50ac13)
    
    restore compatibility with older popplers
    
    with poppler 20.09:
    
    
/home/rene/LibreOffice/git/libreoffice-7-2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx:
 In member function 'int
                     pdfi::PDFOutDev::parseFont(long long int, GfxFont*, 
GfxState*) const':
    
/home/rene/LibreOffice/git/libreoffice-7-2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx:438:39:
 error: 'class
                     GfxFont' has no member named 'getNameWithoutSubsetTag'
    
    
https://www.google.com/search?q=getNameWithoutSubsetTag&oq=getNameWithoutSubsetTag&aqs=chrome..69i57.784j0j7&sourceid=chrome&ie=UTF-8
 suggests it was added in 20.12
    
    Change-Id: I4eacd2d740cb689ff9b3c6cab59376e01b1ba162
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118977
    Tested-by: René Engelhard <r...@debian.org>
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    (cherry picked from commit 07087041610ca8351d764c838ae07fa58f3bdf9e)

diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx 
b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 7d3d68901e37..2d4ad4cd5763 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -494,12 +494,6 @@ void Parser::parseFontFamilyName( FontAttributes& rResult )
 
     const sal_Unicode* pCopy = rResult.familyName.getStr();
     sal_Int32 nLen = rResult.familyName.getLength();
-    // parse out truetype subsets (e.g. BAAAAA+Thorndale)
-    if( nLen > 8 && pCopy[6] == '+' )
-    {
-        pCopy += 7;
-        nLen -= 7;
-    }
 
     // TODO: Looks like this block needs to be refactored
     while( nLen )
@@ -621,52 +615,6 @@ void Parser::readFont()
 
     // extract textual attributes (bold, italic in the name, etc.)
     parseFontFamilyName(aResult);
-    // need to read font file?
-    if( nFileLen )
-    {
-        uno::Sequence<sal_Int8> aFontFile(nFileLen);
-        readBinaryData( aFontFile );
-
-        awt::FontDescriptor aFD;
-        uno::Sequence< uno::Any > aArgs(1);
-        aArgs[0] <<= aFontFile;
-
-        try
-        {
-            uno::Reference< beans::XMaterialHolder > xMat(
-                
m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
-                    "com.sun.star.awt.FontIdentificator", aArgs, m_xContext ),
-                uno::UNO_QUERY );
-            if( xMat.is() )
-            {
-                uno::Any aRes( xMat->getMaterial() );
-                if( aRes >>= aFD )
-                {
-                    if (!aFD.Name.isEmpty())
-                    {
-                        aResult.familyName = aFD.Name;
-                        parseFontFamilyName(aResult);
-                    }
-                    aResult.isBold      = (aFD.Weight > 100.0);
-                    aResult.isItalic    = (aFD.Slant == awt::FontSlant_OBLIQUE 
||
-                                           aFD.Slant == awt::FontSlant_ITALIC 
);
-                    aResult.isUnderline = false;
-                    aResult.size        = 0;
-                }
-            }
-        }
-        catch( uno::Exception& )
-        {
-        }
-
-        if( aResult.familyName.isEmpty() )
-        {
-            // last fallback
-            aResult.familyName  = "Arial";
-            aResult.isUnderline = false;
-        }
-
-    }
 
     if (!m_xDev)
         m_xDev.disposeAndReset(VclPtr<VirtualDevice>::Create());
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx 
b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 4e9af359a6b1..446f507daa80 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -432,14 +432,19 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* 
gfxFont, GfxState* state )
     FontAttributes aNewFont;
     int nSize = 0;
 
-#if POPPLER_CHECK_VERSION(0, 64, 0)
-    const
+#if POPPLER_CHECK_VERSION(20, 12, 0)
+    std::string familyName = gfxFont->getNameWithoutSubsetTag();
+#else
+    std::string familyName = gfxFont->getName()->toStr();
+    if (familyName.length() > 7 && familyName.at(6) == '+')
+    {
+        familyName = familyName.substr(7);
+    }
 #endif
-    GooString* pFamily = gfxFont->getName();
-    if( pFamily )
+    if( familyName != "" )
     {
         aNewFont.familyName.clear();
-        aNewFont.familyName.append( gfxFont->getName() );
+        aNewFont.familyName.append( familyName );
     }
     else
     {
@@ -823,8 +828,6 @@ void PDFOutDev::updateFont(GfxState *state)
         }
         printf( "\n" );
 
-        if( nEmbedSize )
-            writeFontFile(gfxFont);
     }
 }
 
commit d76fa5c6ccec9ba07137cc9fe01d94bb7bf46368
Author:     Sam James <s...@gentoo.org>
AuthorDate: Fri Sep 2 04:31:18 2022 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Sun Oct 30 00:22:25 2022 +0200

    Fix build with Poppler 22.09.0
    
    With Poppler 22.09.0, LO fails to build with:
    ```
    
/var/tmp/portage/app-office/libreoffice-7.3.5.2/work/libreoffice-7.3.5.2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx:682:36:
 error: too many arguments to function call, expected single argument 'start', 
have 3 arguments
        state->getLineDash(&dashArray, &arrayLen, &startOffset);
        ~~~~~~~~~~~~~~~~~~             ^~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/poppler/GfxState.h:1506:32: note: 'getLineDash' declared here
        const std::vector<double> &getLineDash(double *start)
                                   ^
    1 error generated.
    ```
    
    Poppler changed the getLineDash interface:
    ```
    -    void getLineDash(double **dash, int *length, double *start)
    +    const std::vector<double> &getLineDash(double *start)
    ```
    
    Signed-off-by: Sam James <s...@gentoo.org>
    Change-Id: I29e18f20d7650a7fcac1bc8ab4aaa04aaa2ab8fb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139249
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit b7d63694985bbb1cf86eb71769feadb28ce68c17)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139835
    (cherry picked from commit 89d2ecd6bc71fc6e581cff595b18ae67a13d8b11)

diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx 
b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 0e89336c93db..4e9af359a6b1 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -661,8 +661,15 @@ void PDFOutDev::updateLineDash(GfxState *state)
         return;
     assert(state);
 
-    double* dashArray; int arrayLen; double startOffset;
+    int arrayLen; double startOffset;
+#if POPPLER_CHECK_VERSION(22, 9, 0)
+    const std::vector<double> &dash = state->getLineDash(&startOffset);
+    const double* dashArray = dash.data();
+    arrayLen = dash.size();
+#else
+    double* dashArray;
     state->getLineDash(&dashArray, &arrayLen, &startOffset);
+#endif
 
     printf( "updateLineDash" );
     if( arrayLen && dashArray )

Reply via email to