[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sdext/source

2022-09-15 Thread Kevin Suo (via logerrit)
 sdext/source/pdfimport/wrapper/wrapper.cxx|   52 --
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |   18 +++---
 2 files changed, 10 insertions(+), 60 deletions(-)

New commits:
commit 020931b82a0226f6167969bd5ea28262092ce23d
Author: Kevin Suo 
AuthorDate: Sat Jul 10 11:47:39 2021 +0800
Commit: Thorsten Behrens 
CommitDate: Thu Sep 15 22:12:39 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 
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=getNameWithoutSubsetTag=chrome..69i57.784j0j7=chrome=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 
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 07087041610ca8351d764c838ae07fa58f3bdf9e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140010
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx 
b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 3d36e77110be..ad25b2edd85b 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -486,12 +486,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. BA+Thorndale)
-if( nLen > 8 && pCopy[6] == '+' )
-{
-pCopy += 7;
-nLen -= 7;
-}
 
 // TODO: Looks like this block needs to be refactored
 while( nLen )
@@ -613,52 +607,6 @@ void Parser::readFont()
 
 // extract textual attributes (bold, italic in the name, etc.)
 parseFontFamilyName(aResult);
-// need to read font file?
-if( nFileLen )
-{
-uno::Sequence 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
-

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sdext/source

2022-09-15 Thread Sam James (via logerrit)
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 7352d8968988ae42948354de9a63d214c03ac6ce
Author: Sam James 
AuthorDate: Fri Sep 2 04:31:18 2022 +0100
Commit: Michael Stahl 
CommitDate: Thu Sep 15 18:13:06 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(, , );
~~ ^~~
/usr/include/poppler/GfxState.h:1506:32: note: 'getLineDash' declared here
const std::vector (double *start)
   ^
1 error generated.
```

Poppler changed the getLineDash interface:
```
-void getLineDash(double **dash, int *length, double *start)
+const std::vector (double *start)
```

Signed-off-by: Sam James 
Change-Id: I29e18f20d7650a7fcac1bc8ab4aaa04aaa2ab8fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139249
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit b7d63694985bbb1cf86eb71769feadb28ce68c17)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139835
(cherry picked from commit 89d2ecd6bc71fc6e581cff595b18ae67a13d8b11)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140009
Tested-by: Michael Stahl 

diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx 
b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 85cd88d50162..d621aabc8204 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  = state->getLineDash();
+const double* dashArray = dash.data();
+arrayLen = dash.size();
+#else
+double* dashArray;
 state->getLineDash(, , );
+#endif
 
 printf( "updateLineDash" );
 if( arrayLen && dashArray )


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sdext/source

2022-09-15 Thread Nathan Pratta Teodosio (via logerrit)
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |   30 ++
 sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx|   10 ++
 2 files changed, 40 insertions(+)

New commits:
commit 016d689ced3275c9f5206e4edb2e9cb28e619f7c
Author: Nathan Pratta Teodosio 
AuthorDate: Tue Jun 21 08:47:14 2022 -0300
Commit: Michael Stahl 
CommitDate: Thu Sep 15 17:40:36 2022 +0200

Update for Poppler 22.06

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136261
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 0d0469b4302dfe95b016a6f04b145834b79d5ed3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136319
Reviewed-by: Adolfo Jayme Barrientos 
(cherry picked from commit 56c7e666ebf47d6cdf29adf85fc5de56246be86d)

Follow-up for Poppler 22.06 update

Change-Id: I8ee9f1a53cc4389e6a4d44e9765b478b5edfffd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136342
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit ad1ffc62e40c2409b610dfff25a8483b1f2556ad)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136382
Reviewed-by: Adolfo Jayme Barrientos 
(cherry picked from commit 71fb0151f985924af60c383331b214a5a27790a5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140008
Tested-by: Michael Stahl 

diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx 
b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 16ad04bf660a..85cd88d50162 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -456,12 +456,21 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* 
gfxFont, GfxState* state )
 {
 // TODO(P3): Unfortunately, need to read stream twice, since
 // we must write byte count to stdout before
+#if POPPLER_CHECK_VERSION(22, 6, 0)
+std::optional> pBuf = 
gfxFont->readEmbFontFile( m_pDoc->getXRef() );
+if ( pBuf )
+{
+aNewFont.isEmbedded = true;
+nSize = pBuf->size();
+}
+#else
 char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(),  );
 if( pBuf )
 {
 aNewFont.isEmbedded = true;
 gfree(pBuf);
 }
+#endif
 }
 
 m_aFontMap[ nNewId ] = aNewFont;
@@ -474,13 +483,29 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const
 return;
 
 int nSize = 0;
+#if POPPLER_CHECK_VERSION(22, 6, 0)
+std::optional> pBuf = gfxFont->readEmbFontFile( 
m_pDoc->getXRef() );
+if ( pBuf )
+nSize = pBuf->size();
+if ( nSize == 0 )
+return;
+#else
 char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(),  );
 if( !pBuf )
 return;
+#endif
 
 // ---sync point--- see SYNC STREAMS above
 fflush(stdout);
 
+#if POPPLER_CHECK_VERSION(22, 6, 0)
+if( fwrite(pBuf->data(), sizeof(*pBuf->data()), nSize, g_binary_out) != 
static_cast(nSize) )
+{
+exit(1); // error
+}
+// ---sync point--- see SYNC STREAMS above
+fflush(g_binary_out);
+#else
 if( fwrite(pBuf, sizeof(char), nSize, g_binary_out) != 
static_cast(nSize) )
 {
 gfree(pBuf);
@@ -489,6 +514,7 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const
 // ---sync point--- see SYNC STREAMS above
 fflush(g_binary_out);
 gfree(pBuf);
+#endif
 }
 
 #if POPPLER_CHECK_VERSION(0, 83, 0)
@@ -742,7 +768,11 @@ void PDFOutDev::updateFont(GfxState *state)
 {
 assert(state);
 
+#if POPPLER_CHECK_VERSION(22, 6, 0)
+GfxFont *gfxFont = state->getFont().get();
+#else
 GfxFont *gfxFont = state->getFont();
+#endif
 if( !gfxFont )
 return;
 
diff --git a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx 
b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
index b1a54bd09c5f..3ab3381652cd 100644
--- a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
@@ -119,6 +119,15 @@ int main(int argc, char **argv)
 _setmode( _fileno( g_binary_out ), _O_BINARY );
 #endif
 
+#if POPPLER_CHECK_VERSION(22, 6, 0)
+PDFDoc aDoc( std::make_unique(pFileName),
+ std::optional(pOwnerPasswordStr),
+ std::optional(pUserPasswordStr) );
+
+PDFDoc aErrDoc( std::make_unique(pErrFileName),
+ std::optional(pOwnerPasswordStr),
+ std::optional(pUserPasswordStr) );
+#else
 PDFDoc aDoc( pFileName,
  pOwnerPasswordStr,
  pUserPasswordStr );
@@ -126,6 +135,7 @@ int main(int argc, char **argv)
 PDFDoc aErrDoc( pErrFileName,
  pOwnerPasswordStr,
  pUserPasswordStr );
+#endif
 
 // Check various permissions for aDoc.
 PDFDoc  = aDoc.isOk()? aDoc: aErrDoc;