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