LibreOffice Module sdext (master) 1
filterdet.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#include "filterdet.hxx"
22#include "inc/pdfihelper.hxx"
23#include "inc/pdfparse.hxx"
24
25#include <osl/file.h>
26#include <osl/thread.h>
27#include <rtl/digest.h>
28#include <sal/log.hxx>
29#include <com/sun/star/io/IOException.hpp>
30#include <com/sun/star/io/XInputStream.hpp>
31#include <com/sun/star/io/XStream.hpp>
32#include <com/sun/star/io/XSeekable.hpp>
33#include <com/sun/star/io/TempFile.hpp>
34#include <com/sun/star/task/XInteractionHandler.hpp>
36#include <comphelper/hash.hxx>
39#include <memory>
40#include <utility>
41#include <string.h>
42
43using namespace com::sun::star;
44
45namespace pdfi
46{
47
48// TODO(T3): locking/thread safety
49
50namespace {
51
52class FileEmitContext : public pdfparse::EmitContext
53{
54private:
55 oslFileHandle m_aReadHandle;
56 unsigned int m_nReadLen;
57 uno::Reference< io::XStream > m_xContextStream;
58 uno::Reference< io::XSeekable > m_xSeek;
59 uno::Reference< io::XOutputStream > m_xOut;
60
61public:
62 FileEmitContext( const OUString& rOrigFile,
63 const uno::Reference< uno::XComponentContext >& xContext,
64 const pdfparse::PDFContainer* pTop );
65 virtual ~FileEmitContext() override;
66
67 virtual bool write( const void* pBuf, unsigned int nLen ) override;
68 virtual unsigned int getCurPos() override;
69 virtual bool copyOrigBytes( unsigned int nOrigOffset, unsigned int nLen ) override;
70 virtual unsigned int readOrigBytes( unsigned int nOrigOffset, unsigned int nLen, void* pBuf ) override;
71
72 const uno::Reference< io::XStream >& getContextStream() const { return m_xContextStream; }
73};
74
75}
76
77FileEmitContext::FileEmitContext( const OUString& rOrigFile,
78 const uno::Reference< uno::XComponentContext >& xContext,
79 const pdfparse::PDFContainer* pTop ) :
80 pdfparse::EmitContext( pTop ),
81 m_aReadHandle(nullptr),
82 m_nReadLen(0)
83{
84 m_xContextStream.set( io::TempFile::create(xContext), uno::UNO_QUERY_THROW );
85 m_xOut = m_xContextStream->getOutputStream();
86 m_xSeek.set(m_xOut, uno::UNO_QUERY_THROW );
87
88 if( osl_openFile( rOrigFile.pData,
90 osl_File_OpenFlag_Read ) == osl_File_E_None )
91 {
92 oslFileError aErr = osl_setFilePos( m_aReadHandle, osl_Pos_End, 0 );
93 if( aErr == osl_File_E_None )
94 {
95 sal_uInt64 nFileSize = 0;
96 if( (aErr=osl_getFilePos( m_aReadHandle,
97 &nFileSize )) == osl_File_E_None )
98 {
99 m_nReadLen = static_cast<unsigned int>(nFileSize);
100 }
101 }
102 if( aErr != osl_File_E_None )
103 {
104 osl_closeFile( m_aReadHandle );
105 m_aReadHandle = nullptr;
106 }
107 }
108 m_bDeflate = true;
109}
110
111FileEmitContext::~FileEmitContext()
112{
113 if( m_aReadHandle )
114 osl_closeFile( m_aReadHandle );
115}
116
117bool FileEmitContext::write( const void* pBuf, unsigned int nLen )
118{
119 if( ! m_xOut.is() )
120 return false;
121
122 uno::Sequence< sal_Int8 > aSeq( nLen );
123 memcpy( aSeq.getArray(), pBuf, nLen );
124 m_xOut->writeBytes( aSeq );
125 return true;
126}
127
128unsigned int FileEmitContext::getCurPos()
129{
130 unsigned int nPos = 0;
131 if( m_xSeek.is() )
132 {
133 nPos = static_cast<unsigned int>( m_xSeek->getPosition() );
134 }
135 return nPos;
136}
137
138bool FileEmitContext::copyOrigBytes( unsigned int nOrigOffset, unsigned int nLen )
139{
140 if( nOrigOffset + nLen > m_nReadLen )
141 return false;
142
143 if( osl_setFilePos( m_aReadHandle, osl_Pos_Absolut, nOrigOffset ) != osl_File_E_None )
144 return false;
145
146 uno::Sequence< sal_Int8 > aSeq( nLen );
147
148 sal_uInt64 nBytesRead = 0;
149 if( osl_readFile( m_aReadHandle,
150 aSeq.getArray(),
151 nLen,
152 &nBytesRead ) != osl_File_E_None
153 || nBytesRead != static_cast<sal_uInt64>(nLen) )
154 {
155 return false;
156 }
157
158 m_xOut->writeBytes( aSeq );
159 return true;
160}
161
162unsigned int FileEmitContext::readOrigBytes( unsigned int nOrigOffset, unsigned int nLen, void* pBuf )
163{
164 if( nOrigOffset + nLen > m_nReadLen )
165 return 0;
166
167 if( osl_setFilePos( m_aReadHandle,
168 osl_Pos_Absolut,
169 nOrigOffset ) != osl_File_E_None )
170 {
171 return 0;
172 }
173
174 sal_uInt64 nBytesRead = 0;
175 if( osl_readFile( m_aReadHandle,
176 pBuf,
177 nLen,
178 &nBytesRead ) != osl_File_E_None )
179 {
180 return 0;
181 }
182 return static_cast<unsigned int>(nBytesRead);
183}
184
185
186PDFDetector::PDFDetector( uno::Reference< uno::XComponentContext > xContext) :
187 m_xContext(std::move( xContext ))
188{}
189
190namespace
191{
192
193sal_Int32 fillAttributes(uno::Sequence<beans::PropertyValue> const& rFilterData, uno::Reference<io::XInputStream>& xInput, OUString& aURL, sal_Int32& nFilterNamePos, sal_Int32& nPasswordPos, OUString& aPassword)
194{
195 const beans::PropertyValue* pAttribs = rFilterData.getConstArray();
196 sal_Int32 nAttribs = rFilterData.getLength();
197 for (sal_Int32 i = 0; i < nAttribs; i++)
198 {
199 OUString aVal( "<no string>" );
200 pAttribs[i].Value >>= aVal;
201 SAL_INFO("sdext.pdfimport", "doDetection: Attrib: " + pAttribs[i].Name + " = " + aVal);
202
203 if (pAttribs[i].Name == "InputStream")
204 pAttribs[i].Value >>= xInput;
205 else if (pAttribs[i].Name == "URL")
206 pAttribs[i].Value >>= aURL;
207 else if (pAttribs[i].Name == "FilterName")
208 nFilterNamePos = i;
209 else if (pAttribs[i].Name == "Password")
210 {
211 nPasswordPos = i;
212 pAttribs[i].Value >>= aPassword;
213 }
214 }
215 return nAttribs;
216}
217
218// read the first 1024 byte (see PDF reference implementation note 12)
219constexpr const sal_Int32 constHeaderSize = 1024;
220
221bool detectPDF(uno::Reference<io::XInputStream> const& xInput, uno::Sequence<sal_Int8>& aHeader, sal_uInt64& nHeaderReadSize)
222{
223 try
224 {
225 uno::Reference<io::XSeekable> xSeek(xInput, uno::UNO_QUERY);
226 if (xSeek.is())
227 xSeek->seek(0);
228
229 nHeaderReadSize = xInput->readBytes(aHeader, constHeaderSize);
230 if (nHeaderReadSize <= 5)
231 return false;
232
233 const sal_Int8* pBytes = aHeader.getConstArray();
234 for (sal_uInt64 i = 0; i < nHeaderReadSize - 5; i++)
235 {
236 if (pBytes[i+0] == '%' &&
237 pBytes[i+1] == 'P' &&
238 pBytes[i+2] == 'D' &&
239 pBytes[i+3] == 'F' &&
240 pBytes[i+4] == '-')
241 {
242 return true;
243 }
244 }
245 }
246 catch (const css::io::IOException &)
247 {
248 TOOLS_WARN_EXCEPTION("sdext.pdfimport", "caught");
249 }
250 return false;
251}
252
253bool copyToTemp(uno::Reference<io::XInputStream> const& xInput, oslFileHandle& rFileHandle, uno::Sequence<sal_Int8> const& aHeader, sal_uInt64 nHeaderReadSize)
254{
255 try
256 {
257 sal_uInt64 nWritten = 0;
258 osl_writeFile(rFileHandle, aHeader.getConstArray(), nHeaderReadSize, &nWritten);
259
260 const sal_uInt64 nBufferSize = 4096;
261 uno::Sequence<sal_Int8> aBuffer(nBufferSize);
262
263 // copy the bytes
264 sal_uInt64 nRead = 0;
265 do
266 {
267 nRead = xInput->readBytes(aBuffer, nBufferSize);
268 if (nRead > 0)
269 {
270 osl_writeFile(rFileHandle, aBuffer.getConstArray(), nRead, &nWritten);
271 if (nWritten != nRead)
272 return false;
273 }
274 }
275 while (nRead == nBufferSize);
276 }
277 catch (const css::io::IOException &)
278 {
279 TOOLS_WARN_EXCEPTION("sdext.pdfimport", "caught");
280 }
281 return false;
282}
283
284} // end anonymous namespace
285
286// XExtendedFilterDetection
287OUString SAL_CALL PDFDetector::detect( uno::Sequence< beans::PropertyValue >& rFilterData )
288{
289 std::unique_lock guard( m_aMutex );
290 bool bSuccess = false;
291
292 // get the InputStream carrying the PDF content
293 uno::Reference<io::XInputStream> xInput;
294 uno::Reference<io::XStream> xEmbedStream;
295 OUString aOutFilterName;
296 OUString aOutTypeName;
297 OUString aURL;
298 OUString aPassword;
299
300 sal_Int32 nFilterNamePos = -1;
301 sal_Int32 nPasswordPos = -1;
302 sal_Int32 nAttribs = fillAttributes(rFilterData, xInput, aURL, nFilterNamePos, nPasswordPos, aPassword);
303
304 if (!xInput.is())
305 return OUString();
306
307
308 uno::Sequence<sal_Int8> aHeader(constHeaderSize);
309 sal_uInt64 nHeaderReadSize = 0;
310 bSuccess = detectPDF(xInput, aHeader, nHeaderReadSize);
311
312 if (!bSuccess)
313 return OUString();
314
315 oslFileHandle aFileHandle = nullptr;
316
317 // check for hybrid PDF
318 if (bSuccess && (aURL.isEmpty() || !comphelper::isFileUrl(aURL)))
319 {
320 if (osl_createTempFile(nullptr, &aFileHandle, &aURL.pData) != osl_File_E_None)
321 {
322 bSuccess = false;
323 }
324 else
325 {
326 SAL_INFO( "sdext.pdfimport", "created temp file " + aURL);
327 bSuccess = copyToTemp(xInput, aFileHandle, aHeader, nHeaderReadSize);
328 }
329 osl_closeFile(aFileHandle);
330 }
331
332 if (!bSuccess)
333 {
334 if (aFileHandle)
335 osl_removeFile(aURL.pData);
336 return OUString();
337 }
338
339 OUString aEmbedMimetype;
340 xEmbedStream = getAdditionalStream(aURL, aEmbedMimetype, aPassword, m_xContext, rFilterData, false);
341
342 if (aFileHandle)
343 osl_removeFile(aURL.pData);
344
345 if (!aEmbedMimetype.isEmpty())
346 {
347 if( aEmbedMimetype == "application/vnd.oasis.opendocument.text"
348 || aEmbedMimetype == "application/vnd.oasis.opendocument.text-master" )
349 aOutFilterName = "writer_pdf_addstream_import";
350 else if ( aEmbedMimetype == "application/vnd.oasis.opendocument.presentation" )
351 aOutFilterName = "impress_pdf_addstream_import";
352 else if( aEmbedMimetype == "application/vnd.oasis.opendocument.graphics"
353 || aEmbedMimetype == "application/vnd.oasis.opendocument.drawing" )
354 aOutFilterName = "draw_pdf_addstream_import";
355 else if ( aEmbedMimetype == "application/vnd.oasis.opendocument.spreadsheet" )
356 aOutFilterName = "calc_pdf_addstream_import";
357 }
358
359 if (!aOutFilterName.isEmpty())
360 {
361 if( nFilterNamePos == -1 )
362 {
363 nFilterNamePos = nAttribs;
364 rFilterData.realloc( ++nAttribs );
365 rFilterData.getArray()[ nFilterNamePos ].Name = "FilterName";
366 }
367 auto pFilterData = rFilterData.getArray();
368 aOutTypeName = "pdf_Portable_Document_Format";
369
370 pFilterData[nFilterNamePos].Value <<= aOutFilterName;
371 if( xEmbedStream.is() )
372 {
373 rFilterData.realloc( ++nAttribs );
374 pFilterData = rFilterData.getArray();
375 pFilterData[nAttribs-1].Name = "EmbeddedSubstream";
376 pFilterData[nAttribs-1].Value <<= xEmbedStream;
377 }
378 if (!aPassword.isEmpty())
379 {
380 if (nPasswordPos == -1)
381 {
382 nPasswordPos = nAttribs;
383 rFilterData.realloc(++nAttribs);
384 pFilterData = rFilterData.getArray();
385 pFilterData[nPasswordPos].Name = "Password";
386 }
387 pFilterData[nPasswordPos].Value <<= aPassword;
388 }
389 }
390 else
391 {
392 css::beans::PropertyValue* pFilterData;
393 if( nFilterNamePos == -1 )
394 {
395 nFilterNamePos = nAttribs;
396 rFilterData.realloc( ++nAttribs );
397 pFilterData = rFilterData.getArray();
398 pFilterData[ nFilterNamePos ].Name = "FilterName";
399 }
400 else
401 pFilterData = rFilterData.getArray();
402
403 const sal_Int32 nDocumentType = 0; //const sal_Int32 nDocumentType = queryDocumentTypeDialog(m_xContext,aURL);
404 if( nDocumentType < 0 )
405 {
406 return OUString();
407 }
408 else
409 {
410 switch (nDocumentType)
411 {
412 case 0:
413 pFilterData[nFilterNamePos].Value <<= OUString( "draw_pdf_import" );
414 break;
415
416 case 1:
417 pFilterData[nFilterNamePos].Value <<= OUString( "impress_pdf_import" );
418 break;
419
420 case 2:
421 pFilterData[nFilterNamePos].Value <<= OUString( "writer_pdf_import" );
422 break;
423
424 default:
425 assert(!"Unexpected case");
426 }
427 }
428
429 aOutTypeName = "pdf_Portable_Document_Format";
430 }
431
432 return aOutTypeName;
433}
434
436{
437 return "org.libreoffice.comp.documents.PDFDetector";
438}
439
440sal_Bool PDFDetector::supportsService(OUString const & ServiceName)
441{
443}
444
445css::uno::Sequence<OUString> PDFDetector::getSupportedServiceNames()
446{
447 return {"com.sun.star.document.ImportFilter"};
448}
449
450bool checkDocChecksum( const OUString& rInPDFFileURL,
451 sal_uInt32 nBytes,
452 const OUString& rChkSum )
453{
454 if( rChkSum.getLength() != 2* RTL_DIGEST_LENGTH_MD5 )
455 {
456 SAL_INFO(
457 "sdext.pdfimport",
458 "checksum of length " << rChkSum.getLength() << ", expected "
459 << 2*RTL_DIGEST_LENGTH_MD5);
460 return false;
461 }
462
463 // prepare checksum to test
464 sal_uInt8 nTestChecksum[ RTL_DIGEST_LENGTH_MD5 ];
465 const sal_Unicode* pChar = rChkSum.getStr();
466 for(sal_uInt8 & rn : nTestChecksum)
467 {
468 sal_uInt8 nByte = sal_uInt8( ( (*pChar >= '0' && *pChar <= '9') ? *pChar - '0' :
469 ( (*pChar >= 'A' && *pChar <= 'F') ? *pChar - 'A' + 10 :
470 ( (*pChar >= 'a' && *pChar <= 'f') ? *pChar - 'a' + 10 :
471 0 ) ) ) );
472 nByte <<= 4;
473 pChar++;
474 nByte |= ( (*pChar >= '0' && *pChar <= '9') ? *pChar - '0' :
475 ( (*pChar >= 'A' && *pChar <= 'F') ? *pChar - 'A' + 10 :
476 ( (*pChar >= 'a' && *pChar <= 'f') ? *pChar - 'a' + 10 :
477 0 ) ) );
478 pChar++;
479 rn = nByte;
480 }
481
482 // open file and calculate actual checksum up to index nBytes
483 ::std::vector<unsigned char> nChecksum;
484 ::comphelper::Hash aDigest(::comphelper::HashType::MD5);
485 oslFileHandle aRead = nullptr;
486 if( osl_openFile(rInPDFFileURL.pData,
487 &aRead,
488 osl_File_OpenFlag_Read ) == osl_File_E_None )
489 {
490 sal_uInt8 aBuf[4096];
491 sal_uInt32 nCur = 0;
492 sal_uInt64 nBytesRead = 0;
493 while( nCur < nBytes )
494 {
495 sal_uInt32 nPass = std::min<sal_uInt32>(nBytes - nCur, sizeof( aBuf ));
496 if( osl_readFile( aRead, aBuf, nPass, &nBytesRead) != osl_File_E_None
497 || nBytesRead == 0 )
498 {
499 break;
500 }
501 nPass = static_cast<sal_uInt32>(nBytesRead);
502 nCur += nPass;
503 aDigest.update(aBuf, nPass);
504 }
505
506 nChecksum = aDigest.finalize();
507 osl_closeFile( aRead );
508 }
509
510 // compare the contents
511 return nChecksum.size() == RTL_DIGEST_LENGTH_MD5
512 && (0 == memcmp(nChecksum.data(), nTestChecksum, nChecksum.size()));
513}
514
515uno::Reference< io::XStream > getAdditionalStream( const OUString& rInPDFFileURL,
516 OUString& rOutMimetype,
517 OUString& io_rPwd,
518 const uno::Reference<uno::XComponentContext>& xContext,
519 const uno::Sequence<beans::PropertyValue>& rFilterData,
520 bool bMayUseUI )
521{
522 uno::Reference< io::XStream > xEmbed;
523 OString aPDFFile;
524 OUString aSysUPath;
525 if( osl_getSystemPathFromFileURL( rInPDFFileURL.pData, &aSysUPath.pData ) != osl_File_E_None )
526 return xEmbed;
527 aPDFFile = OUStringToOString( aSysUPath, osl_getThreadTextEncoding() );
528
529 std::unique_ptr<pdfparse::PDFEntry> pEntry( pdfparse::PDFReader::read( aPDFFile.getStr() ));
530 if( pEntry )
531 {
532 pdfparse::PDFFile* pPDFFile = dynamic_cast<pdfparse::PDFFile*>(pEntry.get());
533 if( pPDFFile )
534 {
535 unsigned int nElements = pPDFFile->m_aSubElements.size();
536 while( nElements-- > 0 )
537 {
538 pdfparse::PDFTrailer* pTrailer = dynamic_cast<pdfparse::PDFTrailer*>(pPDFFile->m_aSubElements[nElements].get());
539 if( pTrailer && pTrailer->m_pDict )
540 {
541 // search document checksum entry
542 auto chk = pTrailer->m_pDict->m_aMap.find( "DocChecksum" );
543 if( chk == pTrailer->m_pDict->m_aMap.end() )
544 {
545 SAL_INFO( "sdext.pdfimport", "no DocChecksum entry" );
546 continue;
547 }
548 pdfparse::PDFName* pChkSumName = dynamic_cast<pdfparse::PDFName*>(chk->second);
549 if( pChkSumName == nullptr )
550 {
551 SAL_INFO( "sdext.pdfimport", "no name for DocChecksum entry" );
552 continue;
553 }
554
555 // search for AdditionalStreams entry
556 auto add_stream = pTrailer->m_pDict->m_aMap.find( "AdditionalStreams" );
557 if( add_stream == pTrailer->m_pDict->m_aMap.end() )
558 {
559 SAL_INFO( "sdext.pdfimport", "no AdditionalStreams entry" );
560 continue;
561 }
562 pdfparse::PDFArray* pStreams = dynamic_cast<pdfparse::PDFArray*>(add_stream->second);
563 if( ! pStreams || pStreams->m_aSubElements.size() < 2 )
564 {
565 SAL_INFO( "sdext.pdfimport", "AdditionalStreams array too small" );
566 continue;
567 }
568
569 // check checksum
570 OUString aChkSum = pChkSumName->getFilteredName();
571 if( ! checkDocChecksum( rInPDFFileURL, pTrailer->m_nOffset, aChkSum ) )
572 continue;
573
574 // extract addstream and mimetype
575 pdfparse::PDFName* pMimeType = dynamic_cast<pdfparse::PDFName*>(pStreams->m_aSubElements[0].get());
576 pdfparse::PDFObjectRef* pStreamRef = dynamic_cast<pdfparse::PDFObjectRef*>(pStreams->m_aSubElements[1].get());
577
578 SAL_WARN_IF( !pMimeType, "sdext.pdfimport", "error: no mimetype element" );
579 SAL_WARN_IF( !pStreamRef, "sdext.pdfimport", "error: no stream ref element" );
580
581 if( pMimeType && pStreamRef )
582 {
583 pdfparse::PDFObject* pObject = pPDFFile->findObject( pStreamRef->m_nNumber, pStreamRef->m_nGeneration );
584 SAL_WARN_IF( !pObject, "sdext.pdfimport", "object not found" );
585 if( pObject )
586 {
587 if( pPDFFile->isEncrypted() )
588 {
589 bool bAuthenticated = false;
590 if( !io_rPwd.isEmpty() )
591 {
592 OString aIsoPwd = OUStringToOString( io_rPwd,
593 RTL_TEXTENCODING_ISO_8859_1 );
594 bAuthenticated = pPDFFile->setupDecryptionData( aIsoPwd );
595 }
596 if( ! bAuthenticated )
597 {
598 uno::Reference< task::XInteractionHandler > xIntHdl;
599 for( const beans::PropertyValue& rAttrib : rFilterData )
600 {
601 if ( rAttrib.Name == "InteractionHandler" )
602 rAttrib.Value >>= xIntHdl;
603 }
604 if( ! bMayUseUI || ! xIntHdl.is() )
605 {
606 rOutMimetype = pMimeType->getFilteredName();
607 xEmbed.clear();
608 break;
609 }
610
611 OUString aDocName( rInPDFFileURL.copy( rInPDFFileURL.lastIndexOf( '/' )+1 ) );
612
613 bool bEntered = false;
614 do
615 {
616 bEntered = getPassword( xIntHdl, io_rPwd, ! bEntered, aDocName );
617 OString aIsoPwd = OUStringToOString( io_rPwd,
618 RTL_TEXTENCODING_ISO_8859_1 );
619 bAuthenticated = pPDFFile->setupDecryptionData( aIsoPwd );
620 } while( bEntered && ! bAuthenticated );
621 }
622
623 if( ! bAuthenticated )
624 continue;
625 }
626 rOutMimetype = pMimeType->getFilteredName();
627 FileEmitContext aContext( rInPDFFileURL,
628 xContext,
629 pPDFFile );
630 aContext.m_bDecrypt = pPDFFile->isEncrypted();
631 pObject->writeStream( aContext, pPDFFile );
632 xEmbed = aContext.getContextStream();
633 break; // success
634 }
635 }
636 }
637 }
638 }
639 }
640
641 return xEmbed;
642}
643
644
645extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
647 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
648{
649 return cppu::acquire(new PDFDetector(context));
650}
651
652}
653
654/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< unsigned char > finalize()
void update(const unsigned char *pInput, size_t length)
OUString SAL_CALL getImplementationName() override
Definition: filterdet.cxx:435
virtual OUString SAL_CALL detect(css::uno::Sequence< css::beans::PropertyValue > &io_rDescriptor) override
Definition: filterdet.cxx:287
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: filterdet.cxx:445
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
Definition: filterdet.cxx:440
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: filterdet.hxx:41
sal_Int32 nElements
#define TOOLS_WARN_EXCEPTION(area, stream)
URL aURL
EmbeddedObjectRef * pObject
unsigned int m_nReadLen
Definition: filterdet.cxx:56
uno::Reference< io::XStream > m_xContextStream
Definition: filterdet.cxx:57
uno::Reference< io::XOutputStream > m_xOut
Definition: filterdet.cxx:59
oslFileHandle m_aReadHandle
Definition: filterdet.cxx:55
uno::Reference< io::XSeekable > m_xSeek
Definition: filterdet.cxx:58
sal_uInt16 nPos
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
aBuf
COMPHELPER_DLLPUBLIC bool isFileUrl(std::u16string_view url)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * sdext_PDFDetector_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: filterdet.cxx:646
bool checkDocChecksum(const OUString &rInPDFFileURL, sal_uInt32 nBytes, const OUString &rChkSum)
Definition: filterdet.cxx:450
uno::Reference< io::XStream > getAdditionalStream(const OUString &rInPDFFileURL, OUString &rOutMimetype, OUString &io_rPwd, const uno::Reference< uno::XComponentContext > &xContext, const uno::Sequence< beans::PropertyValue > &rFilterData, bool bMayUseUI)
Definition: filterdet.cxx:515
bool getPassword(const css::uno::Reference< css::task::XInteractionHandler > &xHandler, OUString &rOutPwd, bool bFirstTry, const OUString &rDocName)
retrieve password from user
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
PDFObject * findObject(unsigned int nNumber, unsigned int nGeneration) const
Definition: pdfentries.cxx:475
std::vector< std::unique_ptr< PDFEntry > > m_aSubElements
Definition: pdfparse.hxx:162
bool setupDecryptionData(const OString &rPwd) const
bool isEncrypted() const
OUString getFilteredName() const
Definition: pdfentries.cxx:157
unsigned int m_nNumber
Definition: pdfparse.hxx:140
unsigned int m_nGeneration
Definition: pdfparse.hxx:141
static std::unique_ptr< PDFEntry > read(const char *pFileName)
Definition: pdfparse.cxx:609
unsigned char sal_uInt8
unsigned char sal_Bool
sal_uInt16 sal_Unicode
signed char sal_Int8
std::unique_ptr< char[]> aBuffer
Definition: wrapper.cxx:975
const uno::Reference< uno::XComponentContext > m_xContext
Definition: wrapper.cxx:144
const char * pChar