File r1600-Get-PoDoFo-build-under-Visual-Studio-2008.patch of Package podofo.23799

------------------------------------------------------------------------
r1600 | aja_ | 2014-05-25 00:05:23 +0200 (dom, 25 may 2014) | 21 lines

ADDED: Patch by Ulrich Arnold: Get PoDoFo build under Visual Studio 2008 (Windows build, OpenSSL optional)

- PdfEncrypt.cpp: Introduced a new define PODOFO_HAVE_OPENSSL. If this is not set,
  all of the encyption functionality is removed and openssl-lib is not needed.
  The CreatePdfEncrypt-members throws an exception in this case, the same as GetMD5String

- PdfExtension.h: Return type of getLevel changed to pdf_int64, as the member variable is also pdf_int64

- PdfFiltersPrivate.cpp: VS2008 spits on #pragma GCC, therefore removed with #ifndef _MSC_VER

- PdfIdentityEncoding.h/cpp: Argument of GetUnicodeValue und return of GetCIDValue changed from long to pdf_utf16be

- PdfImage.cpp: Included PdfFiltersPrivate.h, this eliminates the manual declaration of jpeg_memory_src.
  In LoadFromJpegData jpeg_memory_src is used instead of jpeg_mem_src, to be independend of new API-function
  introduced in Jpeg9-library

- PdfSigIncMemDocument.cpp: Removed collision between windows and jpeg-headers

- PdfSigIncSignatureField.cpp: Was implicitly dependend on Jpeg-library. Now
  if PODOF_HAVE_JPEG is not defined, NULL will be returned as image


Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt.orig
+++ CMakeLists.txt
@@ -309,8 +309,14 @@ ENDIF(CMAKE_COMPILER_IS_GNUCXX)
 FIND_PACKAGE(ZLIB REQUIRED)
 MESSAGE("Found zlib headers in ${ZLIB_INCLUDE_DIR}, library at ${ZLIB_LIBRARIES}")
 
-FIND_PACKAGE(LIBCRYPTO REQUIRED)
-MESSAGE("Found OpenSSL's libCrypto headers in ${LIBCRYPTO_INCLUDE_DIR}, library at ${LIBCRYPTO_LIBRARIES}")
+FIND_PACKAGE(LIBCRYPTO)
+
+IF(LIBCRYPTO_FOUND)
+	SET(PODOFO_HAVE_OPENSSL TRUE)
+	MESSAGE("Found OpenSSL's libCrypto headers in ${LIBCRYPTO_INCLUDE_DIR}, library at ${LIBCRYPTO_LIBRARIES}")
+ELSE(LIBCRYPTO_FOUND)
+	MESSAGE("OpenSSL's libCrypto not found. Encryption support will be disabled")
+ENDIF(LIBCRYPTO_FOUND)
 
 FIND_PACKAGE(LIBIDN)
 
Index: podofo_config.h.in
===================================================================
--- podofo_config.h.in.orig
+++ podofo_config.h.in
@@ -47,6 +47,7 @@
 #cmakedefine PODOFO_HAVE_LUA
 #cmakedefine PODOFO_HAVE_BOOST
 #cmakedefine PODOFO_HAVE_CPPUNIT
+#cmakedefine PODOFO_HAVE_OPENSSL
 #cmakedefine PODOFO_HAVE_LIBIDN
 
 /* Platform quirks */
Index: src/base/PdfEncrypt.cpp
===================================================================
--- src/base/PdfEncrypt.cpp.orig
+++ src/base/PdfEncrypt.cpp
@@ -33,6 +33,7 @@
 #include <string.h>
 #include <sstream>
 
+#ifdef PODOFO_HAVE_OPENSSL
 // SHA-256
 #ifdef PODOFO_HAVE_LIBIDN
 // AES-256 dependencies :
@@ -43,6 +44,7 @@
 
 #include <openssl/md5.h>
 #include <openssl/evp.h>
+#endif //PODOFO_HAVE_OPENSSL
 
 namespace
 {
@@ -65,6 +67,7 @@ ePdfEncryptAlgorithm_RC4V2 |
 ePdfEncryptAlgorithm_AESV2;
 #endif // PODOFO_HAVE_LIBIDN
 
+#ifdef PODOFO_HAVE_OPENSSL
 // Default value for P (permissions) = no permission
 #define PERMS_DEFAULT 0xFFFFF0C0
 
@@ -1657,4 +1660,40 @@ PdfOutputStream* PdfEncryptAESV3::Create
 }
     
 #endif // PODOFO_HAVE_LIBIDN
+#else  // PODOFO_HAVE_OPENSSL
+PdfEncrypt *
+PdfEncrypt::CreatePdfEncrypt( const std::string & userPassword, 
+                              const std::string & ownerPassword, 
+                              int protection,
+                              EPdfEncryptAlgorithm eAlgorithm, 
+                              EPdfKeyLength eKeyLength )
+{
+    PODOFO_RAISE_ERROR_INFO( ePdfError_NotCompiled, "PdfEncrypt::CreatePdfEncrypt: Encryption support was disabled during compile time" );
+    return NULL;
+}
+
+PdfEncrypt* PdfEncrypt::CreatePdfEncrypt( const PdfObject* pObject )
+{
+    PODOFO_RAISE_ERROR_INFO( ePdfError_NotCompiled, "PdfEncrypt::CreatePdfEncrypt: Encryption support was disabled during compile time" );
+    return NULL;
+}
+
+PdfEncrypt *
+PdfEncrypt::CreatePdfEncrypt(const PdfEncrypt & rhs )  
+{
+    PODOFO_RAISE_ERROR_INFO( ePdfError_NotCompiled, "PdfEncrypt::CreatePdfEncrypt: Encryption support was disabled during compile time" );
+    return NULL;
+}
+
+PdfEncrypt::~PdfEncrypt()
+{
+}
+
+PdfString PdfEncryptMD5Base::GetMD5String( const unsigned char* pBuffer, int nLength )
+{
+    PODOFO_RAISE_ERROR_INFO( ePdfError_NotCompiled, "PdfEncryptMD5Base::GetMD5String: Encryption support was disabled during compile time" );
+    return PdfString();
+}
+
+#endif // PODOFO_HAVE_OPENSSL
 }
Index: src/base/PdfError.cpp
===================================================================
--- src/base/PdfError.cpp.orig
+++ src/base/PdfError.cpp
@@ -321,6 +321,9 @@ const char* PdfError::ErrorName( EPdfErr
         case ePdfError_NotImplemented:
             pszMsg = "ePdfError_NotImplemented";
             break;
+        case ePdfError_NotCompiled:
+            pszMsg = "ePdfError_NotCompiled";
+            break;
         case ePdfError_DestinationAlreadyPresent:
             pszMsg = "ePdfError_DestinationAlreadyPresent"; 
             break;
@@ -460,6 +463,9 @@ const char* PdfError::ErrorMessage( EPdf
         case ePdfError_NotImplemented:
             pszMsg = "This feature is currently not implemented.";
             break;
+        case ePdfError_NotCompiled:
+            pszMsg = "This feature was disabled during compile time.";
+            break;
         case ePdfError_Unknown:
             pszMsg = "Error code unknown.";
             break;
Index: src/base/PdfError.h
===================================================================
--- src/base/PdfError.h.orig
+++ src/base/PdfError.h
@@ -108,6 +108,8 @@ enum EPdfError {
     ePdfError_DestinationAlreadyPresent,/**< An destination was already present when trying to add a Action */
     ePdfError_ChangeOnImmutable,        /**< Changing values on immutable objects is not allowed. */
 
+    ePdfError_NotCompiled,              /**< This feature was disabled during compile time. */
+
     ePdfError_Unknown = 0xffff          /**< Unknown error */
 };
 
Index: src/base/PdfFiltersPrivate.cpp
===================================================================
--- src/base/PdfFiltersPrivate.cpp.orig
+++ src/base/PdfFiltersPrivate.cpp
@@ -1152,8 +1152,10 @@ void PdfCCITTFilter::EndEncodeImpl()
     PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
 }
 
+#ifndef _MSC_VER
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
 void PdfCCITTFilter::BeginDecodeImpl( const PdfDictionary* pDict )
 { 
 #ifdef DS_CCITT_DEVELOPMENT_CODE
@@ -1210,7 +1212,9 @@ void PdfCCITTFilter::BeginDecodeImpl( co
 
 
 }
+#ifndef _MSC_VER
 #pragma GCC diagnostic pop
+#endif
 
 void PdfCCITTFilter::DecodeBlockImpl( const char*, pdf_long )
 {
Index: src/doc/PdfImage.cpp
===================================================================
--- src/doc/PdfImage.cpp.orig
+++ src/doc/PdfImage.cpp
@@ -24,6 +24,7 @@
 
 #include "base/PdfColor.h"
 #include "base/PdfStream.h"
+#include "base/PdfFiltersPrivate.h"
 
 #include <stdio.h>
 #include <wchar.h>
@@ -229,10 +230,6 @@ void PdfImage::LoadFromFile( const char*
 }
 
 #ifdef PODOFO_HAVE_JPEG_LIB
-#if !defined(PODOFO_JPEG_RUNTIME_COMPATIBLE)
-void jpeg_memory_src (j_decompress_ptr cinfo, const JOCTET * buffer, size_t bufsize);
-#endif // PODOFO_JPEG_RUNTIME_COMPATIBLE
-
 extern "C" {
 static void JPegErrorExit(j_common_ptr cinfo)
 {
openSUSE Build Service is sponsored by