20#include <config_folders.h>
29#include <osl/file.hxx>
30#include <osl/thread.h>
31#include <osl/process.h>
32#include <osl/diagnose.h>
33#include <rtl/bootstrap.hxx>
34#include <rtl/ustring.hxx>
35#include <rtl/strbuf.hxx>
40#include <com/sun/star/io/XInputStream.hpp>
41#include <com/sun/star/uno/XComponentContext.hpp>
42#include <com/sun/star/rendering/PathCapType.hpp>
43#include <com/sun/star/rendering/PathJoinType.hpp>
44#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
45#include <com/sun/star/geometry/Matrix2D.hpp>
46#include <com/sun/star/geometry/AffineMatrix2D.hpp>
47#include <com/sun/star/geometry/RealRectangle2D.hpp>
48#include <com/sun/star/geometry/RealSize2D.hpp>
49#include <com/sun/star/task/XInteractionHandler.hpp>
57#include <vcl/font.hxx>
63#include <unordered_map>
126#if defined _MSC_VER && defined __clang__
127#pragma clang diagnostic push
128#pragma clang diagnostic ignored "-Wdeprecated-register"
129#pragma clang diagnostic ignored "-Wextra-tokens"
132#if defined _MSC_VER && defined __clang__
133#pragma clang diagnostic pop
138 friend class LineParser;
140 typedef std::unordered_map< sal_Int64,
152 const uno::Reference<uno::XComponentContext>& xContext ) :
159 void parseLine( std::string_view aLine );
167 void readInt32( sal_Int32& o_Value );
168 void readInt64( sal_Int64& o_Value );
169 void readDouble(
double& o_Value );
170 void readBinaryData( uno::Sequence<sal_Int8>& rBuf );
172 uno::Sequence<beans::PropertyValue> readImageImpl();
179 std::string_view readNextToken();
180 sal_Int32 readInt32();
183 uno::Reference<rendering::XPolyPolygon2D> readPath();
189 void readTransformation();
190 rendering::ARGBColor readColor();
196 void readMaskedImage();
197 void readSoftMaskedImage();
204OString lcl_unescapeLineFeeds(std::string_view i_rStr)
206 const size_t nOrigLen(i_rStr.size());
207 const char*
const pOrig(i_rStr.data());
208 std::unique_ptr<char[]> pBuffer(
new char[nOrigLen + 1]);
210 const char* pRead(pOrig);
211 char* pWrite(pBuffer.get());
212 const char* pCur(pOrig);
213 while ((pCur = strchr(pCur,
'\\')) !=
nullptr)
215 const char cNext(pCur[1]);
216 if (cNext ==
'n' || cNext ==
'r' || cNext ==
'\\')
218 const size_t nLen(pCur - pRead);
219 strncpy(pWrite, pRead, nLen);
221 *pWrite = cNext ==
'n' ?
'\n' : (cNext ==
'r' ?
'\r' :
'\\');
223 pCur = pRead = pCur + 2;
234 if (sal::static_int_cast<size_t>(pRead - pOrig) < nOrigLen)
236 const size_t nLen(nOrigLen - (pRead - pOrig));
237 strncpy(pWrite, pRead, nLen);
242 OString aResult(pBuffer.get());
246std::string_view LineParser::readNextToken()
249 SAL_WARN(
"sdext.pdfimport",
"insufficient input");
255void LineParser::readInt32( sal_Int32& o_Value )
257 std::string_view tok = readNextToken();
261sal_Int32 LineParser::readInt32()
263 std::string_view tok = readNextToken();
267void LineParser::readInt64( sal_Int64& o_Value )
269 std::string_view tok = readNextToken();
273void LineParser::readDouble(
double& o_Value )
275 std::string_view tok = readNextToken();
276 o_Value = rtl_math_stringToDouble(tok.data(), tok.data() + tok.size(),
'.', 0,
280double LineParser::readDouble()
282 std::string_view tok = readNextToken();
283 return rtl_math_stringToDouble(tok.data(), tok.data() + tok.size(),
'.', 0,
287void LineParser::readBinaryData( uno::Sequence<sal_Int8>& rBuf )
289 sal_Int32 nFileLen( rBuf.getLength() );
291 sal_uInt64 nBytesRead(0);
292 oslFileError nRes=osl_File_E_None;
295 nRes = osl_readFile(
m_parser.m_pErr, pBuf, nFileLen, &nBytesRead );
296 if (osl_File_E_None != nRes )
299 nFileLen -= sal::static_int_cast<sal_Int32>(nBytesRead);
302 OSL_PRECOND(nRes==osl_File_E_None,
"inconsistent data");
305uno::Reference<rendering::XPolyPolygon2D> LineParser::readPath()
307 static const std::string_view aSubPathMarker(
"subpath" );
309 if( readNextToken() != aSubPathMarker )
310 OSL_PRECOND(
false,
"broken path");
317 sal_Int32 nClosedFlag;
318 readInt32( nClosedFlag );
321 sal_Int32 nContiguousControlPoints(0);
330 sal_Int32 nCurveFlag;
334 readInt32( nCurveFlag );
339 ++nContiguousControlPoints;
341 else if( nContiguousControlPoints )
343 OSL_PRECOND(nContiguousControlPoints==2,
"broken bezier path");
348 const sal_uInt32 nPoints( aSubPath.
count() );
352 aSubPath.
remove(nPoints-3, 3);
355 nContiguousControlPoints=0;
359 aResult.
append( aSubPath );
364 return static_cast<rendering::XLinePolyPolygon2D*
>(
368void LineParser::readChar()
371 geometry::Matrix2D aUnoMatrix;
372 geometry::RealRectangle2D aRect;
374 readDouble(aRect.X1);
375 readDouble(aRect.Y1);
376 readDouble(aRect.X2);
377 readDouble(aRect.Y2);
378 readDouble(aUnoMatrix.m00);
379 readDouble(aUnoMatrix.m01);
380 readDouble(aUnoMatrix.m10);
381 readDouble(aUnoMatrix.m11);
382 readDouble(fontSize);
392 m_parser.m_pSink->drawGlyphs(OStringToOUString(aChars, RTL_TEXTENCODING_UTF8),
393 aRect, aUnoMatrix, fontSize);
396void LineParser::readLineCap()
398 sal_Int8 nCap(rendering::PathCapType::BUTT);
399 switch( readInt32() )
402 case 0: nCap = rendering::PathCapType::BUTT;
break;
403 case 1: nCap = rendering::PathCapType::ROUND;
break;
404 case 2: nCap = rendering::PathCapType::SQUARE;
break;
409void LineParser::readLineDash()
413 m_parser.m_pSink->setLineDash( uno::Sequence<double>(), 0.0 );
417 const double nOffset(readDouble());
418 const sal_Int32 nLen(readInt32());
420 uno::Sequence<double> aDashArray(nLen);
421 double* pArray=aDashArray.getArray();
422 for( sal_Int32 i=0;
i<nLen; ++
i )
423 *pArray++ = readDouble();
425 m_parser.m_pSink->setLineDash( aDashArray, nOffset );
428void LineParser::readLineJoin()
430 sal_Int8 nJoin(rendering::PathJoinType::MITER);
431 switch( readInt32() )
434 case 0: nJoin = rendering::PathJoinType::MITER;
break;
435 case 1: nJoin = rendering::PathJoinType::ROUND;
break;
436 case 2: nJoin = rendering::PathJoinType::BEVEL;
break;
438 m_parser.m_pSink->setLineJoin(nJoin);
441void LineParser::readTransformation()
443 geometry::AffineMatrix2D aMat;
444 readDouble(aMat.m00);
445 readDouble(aMat.m10);
446 readDouble(aMat.m01);
447 readDouble(aMat.m11);
448 readDouble(aMat.m02);
449 readDouble(aMat.m12);
450 m_parser.m_pSink->setTransformation( aMat );
453rendering::ARGBColor LineParser::readColor()
455 rendering::ARGBColor aRes;
456 readDouble(aRes.Red);
457 readDouble(aRes.Green);
458 readDouble(aRes.Blue);
459 readDouble(aRes.Alpha);
474 SAL_INFO(
"sdext.pdfimport",
"Processing " << rResult.familyName <<
" ---");
475 rResult.familyName = rResult.familyName.trim();
478 if ( rResult.familyName.endsWith(fontAttributesSuffix) )
480 rResult.familyName = rResult.familyName.replaceAll(fontAttributesSuffix,
"");
481 SAL_INFO(
"sdext.pdfimport", rResult.familyName);
482 if (fontAttributesSuffix == u
"Heavy" || fontAttributesSuffix == u
"Black")
484 rResult.fontWeight =
u"900";
486 else if (fontAttributesSuffix == u
"ExtraBold" || fontAttributesSuffix == u
"UltraBold")
488 rResult.fontWeight =
u"800";
490 else if (fontAttributesSuffix == u
"Bold")
492 rResult.fontWeight =
u"bold";
494 else if (fontAttributesSuffix == u
"Semibold")
496 rResult.fontWeight =
u"600";
498 else if (fontAttributesSuffix == u
"Medium")
500 rResult.fontWeight =
u"500";
502 else if (fontAttributesSuffix == u
"Normal" || fontAttributesSuffix == u
"Regular" || fontAttributesSuffix == u
"Book")
504 rResult.fontWeight =
u"400";
506 else if (fontAttributesSuffix == u
"Light")
508 rResult.fontWeight =
u"300";
510 else if (fontAttributesSuffix == u
"ExtraLight" || fontAttributesSuffix == u
"UltraLight")
512 rResult.fontWeight =
u"200";
514 else if (fontAttributesSuffix == u
"Thin")
516 rResult.fontWeight =
u"100";
519 if ( (fontAttributesSuffix ==
"Italic") or (fontAttributesSuffix ==
"Oblique") )
521 rResult.isItalic =
true;
527void LineParser::readFont()
537 sal_Int32 nIsEmbedded;
538 sal_Int32 nFontWeight;
540 sal_Int32 nIsUnderline;
546 readInt32(nIsEmbedded);
547 readInt32(nFontWeight);
548 readInt32(nIsItalic);
549 readInt32(nIsUnderline);
553 nSize = nSize < 0.0 ? -nSize : nSize;
562 Parser::FontMapType::const_iterator pFont(
m_parser.m_aFontMap.find(nFontID) );
563 if( pFont !=
m_parser.m_aFontMap.end() )
565 OSL_PRECOND(nFileLen==0,
"font data for known font");
574 OUString sFontWeight;
575 if (nFontWeight == 0 or nFontWeight == 4)
576 sFontWeight =
u"normal";
577 else if (nFontWeight == 1)
578 sFontWeight =
u"100";
579 else if (nFontWeight == 2)
580 sFontWeight =
u"200";
581 else if (nFontWeight == 3)
582 sFontWeight =
u"300";
583 else if (nFontWeight == 5)
584 sFontWeight =
u"500";
585 else if (nFontWeight == 6)
586 sFontWeight =
u"600";
587 else if (nFontWeight == 7)
588 sFontWeight =
u"bold";
589 else if (nFontWeight == 8)
590 sFontWeight =
u"800";
591 else if (nFontWeight == 9)
592 sFontWeight =
u"900";
593 SAL_INFO(
"sdext.pdfimport",
"Font weight passed from xpdfimport is: " << sFontWeight);
595 FontAttributes aResult( OStringToOUString( aFontName, RTL_TEXTENCODING_UTF8 ),
613 uno::Sequence<sal_Int8> aFontFile(nFileLen);
614 readBinaryData(aFontFile);
623 SAL_INFO(
"sdext.pdfimport", aResult.familyName);
628 if (aResult.familyName.getLength() > 7 and aResult.familyName.indexOf(u
"+", 6) == 6)
630 aResult.familyName = aResult.familyName.copy(7, aResult.familyName.getLength() - 7);
631 parseFontFamilyName(aResult);
633 if (aResult.familyName.endsWithIgnoreAsciiCase(
"-VKana"))
635 parseFontFamilyName(aResult);
639 if (aFontReadResult.
GetWeight() == WEIGHT_THIN)
640 aResult.fontWeight =
u"100";
641 else if (aFontReadResult.
GetWeight() == WEIGHT_ULTRALIGHT)
642 aResult.fontWeight =
u"200";
643 else if (aFontReadResult.
GetWeight() == WEIGHT_LIGHT)
644 aResult.fontWeight =
u"300";
645 else if (aFontReadResult.
GetWeight() == WEIGHT_SEMILIGHT)
646 aResult.fontWeight =
u"350";
648 else if (aFontReadResult.
GetWeight() == WEIGHT_SEMIBOLD)
649 aResult.fontWeight =
u"600";
650 else if (aFontReadResult.
GetWeight() == WEIGHT_BOLD)
651 aResult.fontWeight =
u"bold";
652 else if (aFontReadResult.
GetWeight() == WEIGHT_ULTRABOLD)
653 aResult.fontWeight =
u"800";
654 else if (aFontReadResult.
GetWeight() == WEIGHT_BLACK)
655 aResult.fontWeight =
u"900";
656 SAL_INFO(
"sdext.pdfimport", aResult.fontWeight);
664 "Font detection from fontFile returned empty result. Guessing font info from font name.");
665 parseFontFamilyName(aResult);
670 parseFontFamilyName(aResult);
674 if (aResult.familyName.isEmpty())
676 SAL_WARN(
"sdext.pdfimport",
"Failed to determine the font, using a fallback font Arial.");
677 aResult.familyName =
"Arial";
686 aResult.ascent = metric.GetAscent() / 1000.0;
688 m_parser.m_aFontMap[nFontID] = aResult;
690 aResult.size = nSize;
694uno::Sequence<beans::PropertyValue> LineParser::readImageImpl()
696 std::string_view aToken = readNextToken();
697 const sal_Int32 nImageSize( readInt32() );
700 if( aToken ==
"PNG" )
701 aFileName =
"DUMMY.PNG";
702 else if( aToken ==
"JPEG" )
703 aFileName =
"DUMMY.JPEG";
704 else if( aToken ==
"PBM" )
705 aFileName =
"DUMMY.PBM";
708 SAL_WARN_IF(aToken !=
"PPM",
"sdext.pdfimport",
"Invalid bitmap format");
709 aFileName =
"DUMMY.PPM";
712 uno::Sequence<sal_Int8> aDataSequence(nImageSize);
713 readBinaryData( aDataSequence );
715 uno::Sequence< uno::Any > aStreamCreationArgs{
uno::Any(aDataSequence) };
717 uno::Reference< uno::XComponentContext > xContext(
m_parser.m_xContext, uno::UNO_SET_THROW );
718 uno::Reference< lang::XMultiComponentFactory >
xFactory( xContext->getServiceManager(), uno::UNO_SET_THROW );
719 uno::Reference< io::XInputStream > xDataStream(
720 xFactory->createInstanceWithArgumentsAndContext(
"com.sun.star.io.SequenceInputStream", aStreamCreationArgs,
m_parser.m_xContext ),
721 uno::UNO_QUERY_THROW );
725 {
"InputStream",
uno::Any( xDataStream ) },
726 {
"InputSequence",
uno::Any(aDataSequence) }
732void LineParser::readImage()
734 sal_Int32 nWidth, nHeight,nMaskColors;
737 readInt32(nMaskColors);
739 uno::Sequence<beans::PropertyValue> aImg( readImageImpl() );
743 uno::Sequence<sal_Int8> aDataSequence(nMaskColors);
744 readBinaryData( aDataSequence );
746 uno::Sequence<double> aMinRange(nMaskColors/2);
747 auto pMinRange = aMinRange.getArray();
748 uno::Sequence<double> aMaxRange(nMaskColors/2);
749 auto pMaxRange = aMaxRange.getArray();
750 for( sal_Int32 i=0;
i<nMaskColors/2; ++
i )
752 pMinRange[
i] = aDataSequence[
i] / 255.0;
753 pMaxRange[
i] = aDataSequence[
i+nMaskColors/2] / 255.0;
756 uno::Sequence<uno::Any> aMaskRanges{
uno::Any(aMinRange),
uno::Any(aMaxRange) };
757 m_parser.m_pSink->drawColorMaskedImage( aImg, aMaskRanges );
760 m_parser.m_pSink->drawImage( aImg );
763void LineParser::readMask()
765 sal_Int32 nWidth, nHeight, nInvert;
770 m_parser.m_pSink->drawMask( readImageImpl(), nInvert != 0);
773void LineParser::readLink()
775 geometry::RealRectangle2D aBounds;
776 readDouble(aBounds.X1);
777 readDouble(aBounds.Y1);
778 readDouble(aBounds.X2);
779 readDouble(aBounds.Y2);
781 m_parser.m_pSink->hyperLink( aBounds,
782 OStringToOUString( lcl_unescapeLineFeeds(
784 RTL_TEXTENCODING_UTF8 ) );
789void LineParser::readMaskedImage()
791 sal_Int32 nWidth, nHeight, nMaskWidth, nMaskHeight, nMaskInvert;
794 readInt32(nMaskWidth);
795 readInt32(nMaskHeight);
796 readInt32(nMaskInvert);
798 const uno::Sequence<beans::PropertyValue> aImage( readImageImpl() );
799 const uno::Sequence<beans::PropertyValue> aMask ( readImageImpl() );
800 m_parser.m_pSink->drawMaskedImage( aImage, aMask, nMaskInvert != 0 );
803void LineParser::readSoftMaskedImage()
805 sal_Int32 nWidth, nHeight, nMaskWidth, nMaskHeight;
808 readInt32(nMaskWidth);
809 readInt32(nMaskHeight);
811 const uno::Sequence<beans::PropertyValue> aImage( readImageImpl() );
812 const uno::Sequence<beans::PropertyValue> aMask ( readImageImpl() );
813 m_parser.m_pSink->drawAlphaMaskedImage( aImage, aMask );
816void Parser::parseLine( std::string_view aLine )
818 OSL_PRECOND(
m_pSink,
"Invalid sink" );
819 OSL_PRECOND(
m_pErr,
"Invalid filehandle" );
820 OSL_PRECOND(
m_xContext.is(),
"Invalid service factory" );
822 LineParser lp(*
this, aLine);
823 const std::string_view rCmd = lp.readNextToken();
824 const hash_entry* pEntry = PdfKeywordHash::in_word_set( rCmd.data(),
827 switch( pEntry->eKey )
830 m_pSink->intersectClip(lp.readPath());
break;
832 lp.readChar();
break;
834 lp.readImage();
break;
836 lp.readLink();
break;
838 lp.readMask();
break;
839 case DRAWMASKEDIMAGE:
840 lp.readMaskedImage();
break;
841 case DRAWSOFTMASKEDIMAGE:
842 lp.readSoftMaskedImage();
break;
848 m_pSink->intersectEoClip(lp.readPath());
break;
850 m_pSink->eoFillPath(lp.readPath());
break;
852 m_pSink->fillPath(lp.readPath());
break;
858 m_pSink->setPageNum( lp.readInt32() );
break;
861 const double nWidth ( lp.readDouble() );
862 const double nHeight( lp.readDouble() );
863 m_pSink->startPage( geometry::RealSize2D( nWidth, nHeight ) );
867 m_pSink->strokePath(lp.readPath());
break;
869 lp.readTransformation();
break;
870 case UPDATEFILLCOLOR:
871 m_pSink->setFillColor( lp.readColor() );
break;
873 m_pSink->setFlatness( lp.readDouble( ) );
break;
875 lp.readFont();
break;
877 lp.readLineCap();
break;
879 lp.readLineDash();
break;
881 lp.readLineJoin();
break;
882 case UPDATELINEWIDTH:
883 m_pSink->setLineWidth( lp.readDouble() );
break;
884 case UPDATEMITERLIMIT:
885 m_pSink->setMiterLimit( lp.readDouble() );
break;
886 case UPDATESTROKECOLOR:
887 m_pSink->setStrokeColor( lp.readColor() );
break;
888 case UPDATESTROKEOPACITY:
890 case SETTEXTRENDERMODE:
891 m_pSink->setTextRenderMode( lp.readInt32() );
break;
895 OSL_PRECOND(
false,
"Unknown input");
901 lp.m_nCharIndex!=std::string_view::npos,
"sdext.pdfimport",
"leftover scanner input");
907 const uno::Reference< task::XInteractionHandler >& i_xIHdl,
909 bool& o_rIsEncrypted,
910 const OUString& i_rDocName
913 bool bSuccess =
false;
927 bool bAuthenticated =
false;
928 if( !io_rPwd.isEmpty() )
931 RTL_TEXTENCODING_ISO_8859_1 );
940 bool bEntered =
false;
943 bEntered =
getPassword( i_xIHdl, io_rPwd, ! bEntered, i_rDocName );
945 RTL_TEXTENCODING_ISO_8859_1 );
947 }
while( bEntered && ! bAuthenticated );
950 bSuccess = bAuthenticated;
953 else if( i_xIHdl.is() )
974 static const int SIZE = 64*1024;
983 oslFileError read(
char *pChar,
short count, sal_uInt64* pBytesRead)
985 oslFileError nRes = osl_File_E_None;
986 sal_uInt64 nBytesRead = 0;
991 nRes = osl_readFile(
pOut,
aBuffer.get(), SIZE, &left);
992 if (nRes != osl_File_E_None || left == 0)
994 *pBytesRead = nBytesRead;
1006 *pBytesRead = nBytesRead;
1007 return osl_File_E_None;
1015 const uno::Reference<task::XInteractionHandler>& xIHdl,
1016 const OUString& rPwd,
1017 const uno::Reference<uno::XComponentContext>& xContext,
1018 const OUString& rFilterOptions)
1023 if( osl_getSystemPathFromFileURL( rURL.pData, &aSysUPath.pData ) != osl_File_E_None )
1027 "getSystemPathFromFileURL(" << rURL <<
") failed");
1030 OUString aDocName( rURL.copy( rURL.lastIndexOf(
'/' )+1 ) );
1033 OUString aPwd( rPwd );
1034 bool bIsEncrypted =
false;
1035 if( !
checkEncryption( aSysUPath, xIHdl, aPwd, bIsEncrypted, aDocName ) )
1039 "checkEncryption(" << aSysUPath <<
") failed");
1044 OUString converterURL(
"$BRAND_BASE_DIR/" LIBO_BIN_FOLDER
"/xpdfimport");
1045 rtl::Bootstrap::expandMacros(converterURL);
1048 OUString errPathname(
"$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER
"/xpdfimport/xpdfimport_err.pdf");
1049 rtl::Bootstrap::expandMacros(errPathname);
1050 if (osl::FileBase::getSystemPathFromFileURL(errPathname, errPathname)
1051 != osl::FileBase::E_None)
1055 "getSystemPathFromFileURL(" << errPathname <<
") failed");
1061 OUString aOptFlag(
"-o");
1062 rtl_uString*
args[] = { aSysUPath.pData, errPathname.pData,
1063 aOptFlag.pData, rFilterOptions.pData };
1064 sal_Int32 nArgs = rFilterOptions.isEmpty() ? 2 : 4;
1066 oslProcess aProcess;
1067 oslFileHandle pIn =
nullptr;
1068 oslFileHandle
pOut =
nullptr;
1069 oslFileHandle pErr =
nullptr;
1070 oslSecurity pSecurity = osl_getCurrentSecurity ();
1071 oslProcessError eErr =
1072 osl_executeProcess_WithRedirectedIO(converterURL.pData,
1075 osl_Process_SEARCHPATH|osl_Process_HIDDEN,
1077 nullptr,
nullptr, 0,
1078 &aProcess, &pIn, &
pOut, &pErr);
1079 osl_freeSecurityHandle(pSecurity);
1084 if( eErr!=osl_Process_E_None )
1088 "executeProcess of " << converterURL <<
" failed with "
1095 OStringBuffer
aBuf(256);
1098 aBuf.append(
'\n' );
1100 sal_uInt64 nWritten = 0;
1101 osl_writeFile( pIn,
aBuf.getStr(), sal_uInt64(
aBuf.getLength()), &nWritten );
1109 Parser aParser(rSink,pErr,xContext);
1110 Buffering aBuffering(
pOut);
1115 sal_uInt64 nBytesRead;
1121 nRes = aBuffering.read(&aChar, 1, &nBytesRead);
1122 if (osl_File_E_None != nRes || nBytesRead != 1 || (aChar !=
'\n' && aChar !=
'\r') )
1125 if ( osl_File_E_None != nRes )
1128 if( aChar !=
'\n' && aChar !=
'\r' )
1129 line.append( aChar );
1133 nRes = aBuffering.read(&aChar, 1, &nBytesRead);
1134 if ( osl_File_E_None != nRes || nBytesRead != 1 || aChar ==
'\n' || aChar ==
'\r' )
1136 line.append( aChar );
1138 if ( osl_File_E_None != nRes )
1140 if (
line.isEmpty() )
1143 aParser.parseLine(
line);
1148 catch( uno::Exception& )
1157 osl_closeFile(
pOut);
1159 osl_closeFile(pErr);
1160 eErr = osl_joinProcess(aProcess);
1161 if (eErr == osl_Process_E_None)
1163 oslProcessInfo info;
1164 info.Size =
sizeof info;
1165 eErr = osl_getProcessInfo(aProcess, osl_Process_EXITCODE, &info);
1166 if (eErr == osl_Process_E_None)
1172 "getProcessInfo of " << converterURL
1173 <<
" failed with exit code " << info.Code);
1181 "getProcessInfo of " << converterURL <<
" failed with "
1190 "joinProcess of " << converterURL <<
" failed with " << +eErr);
1193 osl_freeProcessHandle(aProcess);
1200 const uno::Reference<task::XInteractionHandler >& xIHdl,
1201 const OUString& rPwd,
1202 const uno::Reference< uno::XComponentContext >& xContext,
1203 const OUString& rFilterOptions )
1205 OSL_ASSERT(xInput.is());
1209 oslFileHandle aFile =
nullptr;
1211 if( osl_createTempFile(
nullptr, &aFile, &
aURL.pData ) != osl_File_E_None )
1215 const sal_uInt32 nBufSize = 4096;
1216 uno::Sequence<sal_Int8>
aBuf( nBufSize );
1217 sal_uInt64 nBytes = 0;
1218 sal_uInt64 nWritten = 0;
1219 bool bSuccess =
true;
1224 nBytes = xInput->readBytes(
aBuf, nBufSize );
1226 catch( css::uno::Exception& )
1228 osl_closeFile( aFile );
1233 osl_writeFile( aFile,
aBuf.getConstArray(), nBytes, &nWritten );
1234 if( nWritten != nBytes )
1241 while( nBytes == nBufSize );
1243 osl_closeFile( aFile );
1247 osl_removeFile(
aURL.pData );
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void setClosed(bool bNew)
void remove(sal_uInt32 nIndex, sal_uInt32 nCount=1)
void appendBezierSegment(const basegfx::B2DPoint &rNextControlPoint, const basegfx::B2DPoint &rPrevControlPoint, const basegfx::B2DPoint &rPoint)
const OUString & GetFamilyName() const
static Font identifyFont(const void *pBuffer, sal_uInt32 nLen)
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
sal_Int64 toInt64(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
static bool checkEncryption(std::u16string_view i_rPath, const uno::Reference< task::XInteractionHandler > &i_xIHdl, OUString &io_rPwd, bool &o_rIsEncrypted, const OUString &i_rDocName)
bool xpdf_ImportFromStream(const css::uno::Reference< css::io::XInputStream > &xInput, const ContentSinkSharedPtr &rSink, const css::uno::Reference< css::task::XInteractionHandler > &xIHdl, const OUString &rPwd, const css::uno::Reference< css::uno::XComponentContext > &xContext, const OUString &rFilterOptions)
bool xpdf_ImportFromFile(const OUString &rURL, const ContentSinkSharedPtr &rSink, const css::uno::Reference< css::task::XInteractionHandler > &xIHdl, const OUString &rPwd, const css::uno::Reference< css::uno::XComponentContext > &xContext, const OUString &rFilterOptions)
const OUString fontAttributesSuffixes[]
bool getPassword(const css::uno::Reference< css::task::XInteractionHandler > &xHandler, OUString &rOutPwd, bool bFirstTry, const OUString &rDocName)
retrieve password from user
void reportUnsupportedEncryptionFormat(css::uno::Reference< css::task::XInteractionHandler > const &handler)
std::shared_ptr< ContentSink > ContentSinkSharedPtr
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
constexpr tools::Long SIZE
bool usesSupportedEncryptionFormat() const
bool setupDecryptionData(const OString &rPwd) const
static std::unique_ptr< PDFEntry > read(const char *pFileName)
const oslFileHandle m_pErr
std::unique_ptr< char[]> aBuffer
ScopedVclPtr< VirtualDevice > m_xDev
const uno::Reference< uno::XComponentContext > m_xContext
const ContentSinkSharedPtr m_pSink