1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_PDFI_FILTERDET_HXX 25 #define INCLUDED_PDFI_FILTERDET_HXX 26 27 #include <com/sun/star/document/XExtendedFilterDetection.hpp> 28 #include <com/sun/star/lang/XServiceInfo.hpp> 29 #include <com/sun/star/uno/XComponentContext.hpp> 30 #include <com/sun/star/io/XStream.hpp> 31 #include <com/sun/star/task/XInteractionHandler.hpp> 32 33 #include <cppuhelper/compbase1.hxx> 34 #include <cppuhelper/basemutex.hxx> 35 36 37 namespace pdfi 38 { 39 40 typedef ::cppu::WeakComponentImplHelper1< 41 com::sun::star::document::XExtendedFilterDetection > PDFDetectorBase; 42 43 class PDFDetector : private cppu::BaseMutex, 44 public PDFDetectorBase 45 { 46 private: 47 com::sun::star::uno::Reference< 48 com::sun::star::uno::XComponentContext > m_xContext; 49 50 public: 51 explicit PDFDetector( const ::com::sun::star::uno::Reference< 52 ::com::sun::star::uno::XComponentContext >& xContext ); 53 54 // XExtendedFilterDetection 55 virtual rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< 56 com::sun::star::beans::PropertyValue >& io_rDescriptor ) 57 throw (com::sun::star::uno::RuntimeException); 58 }; 59 60 61 /** Retrieve embedded substream from PDF file 62 63 Useful e.g. for hybrid PDF 64 65 @param rPDFFile 66 URI of the pdf file 67 68 @param o_rOutMimetype 69 Output parameter. Receives the mime type of the 70 substream. Used to distinguish between 71 draw/impress/writer/calc during import 72 73 @param o_rOutPwd 74 In/Out parameter. If given password is wrong, user is queried 75 for another (if bMayUseUI is true) 76 77 @param xContext 78 Component context 79 80 @param rFilterData 81 Basically used to pass on XFilter::filter properties (function 82 uses it to retrieve interaction handler) 83 84 @param bMayUseUI 85 When false, no dialog is opened to query user for alternate 86 password 87 */ 88 com::sun::star::uno::Reference< com::sun::star::io::XStream > 89 getAdditionalStream( const rtl::OUString& rPDFFile, 90 rtl::OUString& o_rOutMimetype, 91 rtl::OUString& io_rOutPwd, 92 const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext, 93 const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rFilterData, 94 bool bMayUseUI ); 95 96 97 bool checkDocChecksum( const rtl::OUString& rInPDFFileURL, 98 sal_uInt32 nBytes, 99 const rtl::OUString& rChkSum ); 100 101 bool getPassword( const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler, 102 rtl::OUString& o_rPwd, 103 bool bFirstTry, 104 const rtl::OUString& i_rDocName 105 ); 106 107 } 108 109 #endif 110 111