home *** CD-ROM | disk | FTP | other *** search
- // PdfDataRecognizer.cpp
- //
- // Copyright (c) 1997-1999 Symbian Ltd. All rights reserved.
- //
- // Copyright (c) 1999 Sander van der Wal
- //
- // $Id: Pdfdatarecognizer.cpp 1.2 2000-09-21 14:06:37+02 svdwal Exp svdwal $
- //
- // $Log: Pdfdatarecognizer.cpp $
- // Revision 1.2 2000-09-21 14:06:37+02 svdwal
- // Some edits
- //
- // Revision 1.1 2000-09-17 15:08:15+02 svdwal
- // Initial checkin
- //
-
-
- /////////////////////////////////////////////////////////////////////////
- //
- // According to the Adobe Portable Document Format Reference Manual
- // version 1.3, March 1999, Chapter 5.12, page 55-56
- // A pdf file will contain in it's first line the string
- //
- // %PDF-
- //
- // and a version number afterwards.
- // The line should be 255 chars or less long.
- // Here we use 1000 chars, the Adobe PDF readers do that too.
- //
- //
- ////////////////////////////////////////////////////////////////////////
-
-
- #include "PdfDataRecognizer.h"
-
- // AppArc
- #ifndef __APMSTD_H__
- #include <apmstd.h>
- #endif
-
- // Global const
-
- #ifdef _UNICODE
- const TInt KUidRecPdfValue = 0x10005DE8;
- const TUid KUidRecPdf = { 0x10005DE8 };
- #else
- const TInt KUidRecPdfValue = 0x10005DE7;
- const TUid KUidRecPdf = { 0x10005DE7 };
- #endif
-
- const TInt KMinBufferLength = 5; // minimum amount of file needed to determine a pdf file IF it's not called .pdf
- const TInt KMaxBufferLength = 1000; // maximum amount of buffer space we will ever use
-
- _LIT8(KDataTypeApplicationPdf, "application/pdf");
-
- CPdfDataRecognizer::CPdfDataRecognizer()
- :CApaDataRecognizerType(KUidRecPdf, CApaDataRecognizerType::ELow)
- {
- iCountDataTypes=1;
- }
-
-
- TUint CPdfDataRecognizer::PreferredBufSize()
- {
- return KMaxBufferLength;
- }
-
-
- TDataType CPdfDataRecognizer::SupportedDataTypeL(TInt aIndex) const
- {
- __ASSERT_DEBUG(aIndex==0,User::Invariant());
- return TDataType(KDataTypeApplicationPdf);
- }
-
-
- void CPdfDataRecognizer::DoRecognizeL(const TDesC& /* aName */, const TDesC8& aBuffer)
- {
- if (aBuffer.Length()<KMinBufferLength)
- // not recognized, no room for '%PDF-'
- return;
-
- // look for the '%PDF-'-string
- if (aBuffer.FindF(_L("%PDF-")) >= 0) {
- // found it.
- iConfidence=ECertain;
- iDataType=TDataType(KDataTypeApplicationPdf);
- }
- return;
-
- }
-
-
- //
- // The gate function - ordinal 1
- //
- EXPORT_C CApaDataRecognizerType* CreateRecognizer()
- {
- return new CPdfDataRecognizer(); // 0 if new failed
- }
-
-
- //
- // DLL entry point
- //
- GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
- {
- return KErrNone;
- }
-
-
- #ifdef __WINS__
- //
- // VC++ 6.0 Introductionary version wants this to be able to link
- //
- extern "C" void __pfnBkCheck() {}
-
- #endif
-