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