Merge to XFA: Make (and verify) public/ files compile under C.
authorTom Sepez <tsepez@chromium.org>
Wed, 13 May 2015 00:28:08 +0000 (17:28 -0700)
committerTom Sepez <tsepez@chromium.org>
Wed, 13 May 2015 00:28:08 +0000 (17:28 -0700)
The following files needed adjustment beyond a mechanical merge:
   fpdfsdk/src/fpdfview.cpp
   public/fpdf_formfill.h
   samples/pdfium_test.cc
   testing/embedder_test.cpp

Original Review URL: https://codereview.chromium.org/1130843003

BUG=pdfium:158
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1137233002

15 files changed:
BUILD.gn
fpdfsdk/src/fpdfview.cpp
fpdfsdk/src/fpdfview_c_api_test.c [new file with mode: 0644]
fpdfsdk/src/fpdfview_c_api_test.h [new file with mode: 0644]
fpdfsdk/src/fpdfview_embeddertest.cpp
pdfium.gyp
public/fpdf_dataavail.h
public/fpdf_ext.h
public/fpdf_formfill.h
public/fpdf_fwlevent.h
public/fpdf_save.h
public/fpdf_transformpage.h
public/fpdfview.h
samples/pdfium_test.cc
testing/embedder_test.cpp

index 43a8644..9e05bab 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1579,6 +1579,8 @@ test("pdfium_embeddertests") {
     "fpdfsdk/src/fpdfdoc_embeddertest.cpp",
     "fpdfsdk/src/fpdfformfill_embeddertest.cpp",
     "fpdfsdk/src/fpdftext_embeddertest.cpp",
+    "fpdfsdk/src/fpdfview_c_api_test.c",
+    "fpdfsdk/src/fpdfview_c_api_test.h",
     "fpdfsdk/src/fpdfview_embeddertest.cpp",
     "testing/embedder_test.cpp",
     "testing/embedder_test.h",
index 7852670..c5d8f32 100644 (file)
@@ -266,7 +266,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY
        return pDocument;
 }
 
-DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType)
+DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int* docType)
 {
        if (!document)
                return FALSE;
@@ -290,9 +290,9 @@ DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType)
        FX_BOOL bDynamicXFA = pRoot->GetBoolean("NeedsRendering", FALSE);
 
        if (bDynamicXFA)
-               docType = DOCTYPE_DYNIMIC_XFA;
+               *docType = DOCTYPE_DYNIMIC_XFA;
        else
-               docType = DOCTYPE_STATIC_XFA;
+               *docType = DOCTYPE_STATIC_XFA;
 
        return TRUE;
 }
@@ -1011,10 +1011,10 @@ FPDF_RESULT     FPDF_BStr_Clear(FPDF_BSTR* str)
        return 0;
 }
 
-DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, long& buflen)
+DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, long* buflen)
 {
     if (!buffer)
-        buflen = 0;
+        *buflen = 0;
     if (!document || index < 0) return NULL;
        CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
 
@@ -1051,12 +1051,12 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index,
     CFX_ByteString utf16Name = wsName.UTF16LE_Encode();
     unsigned int len = utf16Name.GetLength();
     if (!buffer) {
-        buflen = len;
-    } else if (buflen >= len) {
+        *buflen = len;
+    } else if (*buflen >= len) {
         memcpy(buffer, utf16Name.c_str(), len);
-        buflen = len;
+        *buflen = len;
     } else {
-        buflen = -1;
+        *buflen = -1;
     }
     return (FPDF_DEST)pDestObj;
 }
diff --git a/fpdfsdk/src/fpdfview_c_api_test.c b/fpdfsdk/src/fpdfview_c_api_test.c
new file mode 100644 (file)
index 0000000..f96aec4
--- /dev/null
@@ -0,0 +1,232 @@
+// Copyright 2015 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This "C" (not "C++") file ensures that the public headers compile
+// and link for "C" (and not just "C++").
+
+#include <stdio.h>
+
+#include "fpdfview_c_api_test.h"
+
+#include "../../public/fpdf_dataavail.h"
+#include "../../public/fpdf_doc.h"
+#include "../../public/fpdf_edit.h"
+#include "../../public/fpdf_ext.h"
+#include "../../public/fpdf_flatten.h"
+#include "../../public/fpdf_formfill.h"
+#include "../../public/fpdf_fwlevent.h"
+#include "../../public/fpdf_ppo.h"
+#include "../../public/fpdf_progressive.h"
+#include "../../public/fpdf_save.h"
+#include "../../public/fpdf_searchex.h"
+#include "../../public/fpdf_sysfontinfo.h"
+#include "../../public/fpdf_text.h"
+#include "../../public/fpdf_transformpage.h"
+#include "../../public/fpdfview.h"
+
+// Scheme for avoiding LTO out of existence, warnings, etc.
+typedef void (*fnptr)(void);  // Legal generic function type for casts.
+fnptr g_c_api_test_fnptr = NULL;  // Extern, so can't know it doesn't change.
+#define CHK(x) if ((fnptr)(x) == g_c_api_test_fnptr) return 0
+
+// Function to call from gtest harness to ensure linker resolution.
+int CheckPDFiumCApi() {
+    // fpdf_dataavail.h
+    CHK(FPDFAvail_Create);
+    CHK(FPDFAvail_Destroy);
+    CHK(FPDFAvail_IsDocAvail);
+    CHK(FPDFAvail_GetDocument);
+    CHK(FPDFAvail_GetFirstPageNum);
+    CHK(FPDFAvail_IsPageAvail);
+    CHK(FPDFAvail_IsFormAvail);
+    CHK(FPDFAvail_IsLinearized);
+
+    // fpdf_doc.h
+    CHK(FPDFBookmark_GetFirstChild);
+    CHK(FPDFBookmark_GetNextSibling);
+    CHK(FPDFBookmark_GetTitle);
+    CHK(FPDFBookmark_Find);
+    CHK(FPDFBookmark_GetDest);
+    CHK(FPDFBookmark_GetAction);
+    CHK(FPDFAction_GetType);
+    CHK(FPDFAction_GetDest);
+    CHK(FPDFAction_GetURIPath);
+    CHK(FPDFDest_GetPageIndex);
+    CHK(FPDFLink_GetLinkAtPoint);
+    CHK(FPDFLink_GetDest);
+    CHK(FPDFLink_GetAction);
+    CHK(FPDFLink_Enumerate);
+    CHK(FPDFLink_GetAnnotRect);
+    CHK(FPDFLink_CountQuadPoints);
+    CHK(FPDFLink_GetQuadPoints);
+    CHK(FPDF_GetMetaText);
+
+    // fpdf_edit.h
+    CHK(FPDF_CreateNewDocument);
+    CHK(FPDFPage_New);
+    CHK(FPDFPage_Delete);
+    CHK(FPDFPage_GetRotation);
+    CHK(FPDFPage_SetRotation);
+    CHK(FPDFPage_InsertObject);
+    CHK(FPDFPage_CountObject);
+    CHK(FPDFPage_GetObject);
+    CHK(FPDFPage_HasTransparency);
+    CHK(FPDFPage_GenerateContent);
+    CHK(FPDFPageObj_HasTransparency);
+    CHK(FPDFPageObj_Transform);
+    CHK(FPDFPage_TransformAnnots);
+    CHK(FPDFPageObj_NewImgeObj);
+    CHK(FPDFImageObj_LoadJpegFile);
+    CHK(FPDFImageObj_SetMatrix);
+    CHK(FPDFImageObj_SetBitmap);
+
+    // fpdf_ext.h
+    CHK(FSDK_SetUnSpObjProcessHandler);
+    CHK(FPDFDoc_GetPageMode);
+
+    // fpdf_flatten.h
+    CHK(FPDFPage_Flatten);
+
+    // fpdf_fwlevent.h - no exports.
+
+    // fpdf_formfill.h
+    CHK(FPDFDOC_InitFormFillEnvironment);
+    CHK(FPDFDOC_ExitFormFillEnvironment);
+    CHK(FORM_OnAfterLoadPage);
+    CHK(FORM_OnBeforeClosePage);
+    CHK(FORM_DoDocumentJSAction);
+    CHK(FORM_DoDocumentOpenAction);
+    CHK(FORM_DoDocumentAAction);
+    CHK(FORM_DoPageAAction);
+    CHK(FORM_OnMouseMove);
+    CHK(FORM_OnLButtonDown);
+    CHK(FORM_OnLButtonUp);
+    CHK(FORM_OnRButtonDown);
+    CHK(FORM_OnRButtonUp);
+    CHK(FORM_OnKeyDown);
+    CHK(FORM_OnKeyUp);
+    CHK(FORM_OnChar);
+    CHK(FORM_ForceToKillFocus);
+    CHK(FPDPage_HasFormFieldAtPoint);
+    CHK(FPDF_SetFormFieldHighlightColor);
+    CHK(FPDF_SetFormFieldHighlightAlpha);
+    CHK(FPDF_RemoveFormFieldHighlight);
+    CHK(FPDF_FFLDraw);
+    CHK(FPDF_HasXFAField);
+    CHK(FPDF_LoadXFA);
+    CHK(FPDF_Widget_Undo);
+    CHK(FPDF_Widget_Redo);
+    CHK(FPDF_Widget_SelectAll);
+    CHK(FPDF_Widget_Copy);
+    CHK(FPDF_Widget_Cut);
+    CHK(FPDF_Widget_Paste);
+    CHK(FPDF_Widget_ReplaceSpellCheckWord);
+    CHK(FPDF_Widget_GetSpellCheckWords);
+    CHK(FPDF_StringHandleCounts);
+    CHK(FPDF_StringHandleGetStringByIndex);
+    CHK(FPDF_StringHandleRelease);
+    CHK(FPDF_StringHandleAddString);
+
+    // fpdf_ppo.h
+    CHK(FPDF_ImportPages);
+    CHK(FPDF_CopyViewerPreferences);
+
+    // fpdf_progressive.h
+    CHK(FPDF_RenderPageBitmap_Start);
+    CHK(FPDF_RenderPage_Continue);
+    CHK(FPDF_RenderPage_Close);
+
+    // fpdf_save.h
+    CHK(FPDF_SaveAsCopy);
+    CHK(FPDF_SaveWithVersion);
+
+    // fpdf_searchex.h
+    CHK(FPDFText_GetCharIndexFromTextIndex);
+
+    // fpdf_sysfontinfo.h
+    CHK(FPDF_GetDefaultTTFMap);
+    CHK(FPDF_AddInstalledFont);
+    CHK(FPDF_SetSystemFontInfo);
+    CHK(FPDF_GetDefaultSystemFontInfo);
+
+    // fpdf_text.h
+    CHK(FPDFText_LoadPage);
+    CHK(FPDFText_ClosePage);
+    CHK(FPDFText_CountChars);
+    CHK(FPDFText_GetUnicode);
+    CHK(FPDFText_GetFontSize);
+    CHK(FPDFText_GetCharBox);
+    CHK(FPDFText_GetCharIndexAtPos);
+    CHK(FPDFText_GetText);
+    CHK(FPDFText_CountRects);
+    CHK(FPDFText_GetRect);
+    CHK(FPDFText_GetBoundedText);
+    CHK(FPDFText_FindStart);
+    CHK(FPDFText_FindNext);
+    CHK(FPDFText_FindPrev);
+    CHK(FPDFText_GetSchResultIndex);
+    CHK(FPDFText_GetSchCount);
+    CHK(FPDFText_FindClose);
+    CHK(FPDFLink_LoadWebLinks);
+    CHK(FPDFLink_CountWebLinks);
+    CHK(FPDFLink_GetURL);
+    CHK(FPDFLink_CountRects);
+    CHK(FPDFLink_GetRect);
+    CHK(FPDFLink_CloseWebLinks);
+
+    // fpdf_transformpage.h
+    CHK(FPDFPage_SetMediaBox);
+    CHK(FPDFPage_SetCropBox);
+    CHK(FPDFPage_GetMediaBox);
+    CHK(FPDFPage_GetCropBox);
+    CHK(FPDFPage_TransFormWithClip);
+    CHK(FPDFPageObj_TransformClipPath);
+    CHK(FPDF_CreateClipPath);
+    CHK(FPDF_DestroyClipPath);
+    CHK(FPDFPage_InsertClipPath);
+
+    // fpdfview.h
+    CHK(FPDF_InitLibrary);
+    CHK(FPDF_DestroyLibrary);
+    CHK(FPDF_SetSandBoxPolicy);
+    CHK(FPDF_LoadDocument);
+    CHK(FPDF_LoadMemDocument);
+    CHK(FPDF_LoadCustomDocument);
+    CHK(FPDF_GetFileVersion);
+    CHK(FPDF_GetLastError);
+    CHK(FPDF_GetDocPermissions);
+    CHK(FPDF_GetSecurityHandlerRevision);
+    CHK(FPDF_GetPageCount);
+    CHK(FPDF_LoadPage);
+    CHK(FPDF_GetPageWidth);
+    CHK(FPDF_GetPageHeight);
+    CHK(FPDF_GetPageSizeByIndex);
+    CHK(FPDF_RenderPageBitmap);
+    CHK(FPDF_ClosePage);
+    CHK(FPDF_CloseDocument);
+    CHK(FPDF_DeviceToPage);
+    CHK(FPDF_PageToDevice);
+    CHK(FPDFBitmap_Create);
+    CHK(FPDFBitmap_CreateEx);
+    CHK(FPDFBitmap_FillRect);
+    CHK(FPDFBitmap_GetBuffer);
+    CHK(FPDFBitmap_GetWidth);
+    CHK(FPDFBitmap_GetHeight);
+    CHK(FPDFBitmap_GetStride);
+    CHK(FPDFBitmap_Destroy);
+    CHK(FPDF_VIEWERREF_GetPrintScaling);
+    CHK(FPDF_VIEWERREF_GetNumCopies);
+    CHK(FPDF_VIEWERREF_GetPrintPageRange);
+    CHK(FPDF_VIEWERREF_GetDuplex);
+    CHK(FPDF_CountNamedDests);
+    CHK(FPDF_GetNamedDestByName);
+    CHK(FPDF_GetNamedDest);
+    CHK(FPDF_BStr_Init);
+    CHK(FPDF_BStr_Set);
+    CHK(FPDF_BStr_Clear);
+
+    return 1;
+}
+
+#undef CHK
diff --git a/fpdfsdk/src/fpdfview_c_api_test.h b/fpdfsdk/src/fpdfview_c_api_test.h
new file mode 100644 (file)
index 0000000..755d821
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2015 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef FPDFSDK_SRC_FPDFVIEW_C_API_TEST_H_
+#define FPDFSDK_SRC_FPDFVIEW_C_API_TEST_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Function to call from gtest harness to ensure linker resolution. Returns
+// 1 on success or 0 on error.
+int CheckPDFiumCApi();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  // FPDFSDK_SRC_FPDFVIEW_C_API_TEST_H_
index d722324..9dcfa08 100644 (file)
@@ -7,8 +7,13 @@
 
 #include "../../public/fpdfview.h"
 #include "../../testing/embedder_test.h"
+#include "fpdfview_c_api_test.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
+TEST(fpdf, CApiTest) {
+  EXPECT_TRUE(CheckPDFiumCApi());
+}
+
 class FPDFViewEmbeddertest : public EmbedderTest {
 };
 
@@ -50,20 +55,20 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
 
   // Query the size of the first item.
   buffer_size = 2000000; // Absurdly large, check not used for this case.
-  dest = FPDF_GetNamedDest(document(), 0, nullptr, buffer_size);
+  dest = FPDF_GetNamedDest(document(), 0, nullptr, &buffer_size);
   EXPECT_NE(nullptr, dest);
   EXPECT_EQ(12u, buffer_size);
 
   // Try to retrieve the first item with too small a buffer.
   buffer_size = 10;
-  dest = FPDF_GetNamedDest(document(), 0, fixed_buffer, buffer_size);
+  dest = FPDF_GetNamedDest(document(), 0, fixed_buffer, &buffer_size);
   EXPECT_NE(nullptr, dest);
   EXPECT_EQ(-1, buffer_size);
 
   // Try to retrieve the first item with correctly sized buffer. Item is
   // taken from Dests NameTree in named_dests.pdf.
   buffer_size = 12;
-  dest = FPDF_GetNamedDest(document(), 0, fixed_buffer, buffer_size);
+  dest = FPDF_GetNamedDest(document(), 0, fixed_buffer, &buffer_size);
   EXPECT_NE(nullptr, dest);
   EXPECT_EQ(12u, buffer_size);
   EXPECT_EQ(std::string("F\0i\0r\0s\0t\0\0\0", 12),
@@ -72,7 +77,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
   // Try to retrieve the second item with ample buffer. Item is taken
   // from Dests NameTree but has a sub-dictionary in named_dests.pdf.
   buffer_size = sizeof(fixed_buffer);
-  dest = FPDF_GetNamedDest(document(), 1, fixed_buffer, buffer_size);
+  dest = FPDF_GetNamedDest(document(), 1, fixed_buffer, &buffer_size);
   EXPECT_NE(nullptr, dest);
   EXPECT_EQ(10u, buffer_size);
   EXPECT_EQ(std::string("N\0e\0x\0t\0\0\0", 10),
@@ -82,21 +87,21 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
   // from Dests NameTree but has a bad sub-dictionary in named_dests.pdf.
   // in named_dests.pdf).
   buffer_size = sizeof(fixed_buffer);
-  dest = FPDF_GetNamedDest(document(), 2, fixed_buffer, buffer_size);
+  dest = FPDF_GetNamedDest(document(), 2, fixed_buffer, &buffer_size);
   EXPECT_EQ(nullptr, dest);
   EXPECT_EQ(sizeof(fixed_buffer), buffer_size);  // unmodified.
 
   // Try to retrieve the forth item with ample buffer. Item is taken
   // from Dests NameTree but has a vale of the wrong type in named_dests.pdf.
   buffer_size = sizeof(fixed_buffer);
-  dest = FPDF_GetNamedDest(document(), 3, fixed_buffer, buffer_size);
+  dest = FPDF_GetNamedDest(document(), 3, fixed_buffer, &buffer_size);
   EXPECT_EQ(nullptr, dest);
   EXPECT_EQ(sizeof(fixed_buffer), buffer_size);  // unmodified.
 
   // Try to retrieve fifth item with ample buffer. Item taken from the
   // old-style Dests dictionary object in named_dests.pdf.
   buffer_size = sizeof(fixed_buffer);
-  dest = FPDF_GetNamedDest(document(), 4, fixed_buffer, buffer_size);
+  dest = FPDF_GetNamedDest(document(), 4, fixed_buffer, &buffer_size);
   EXPECT_NE(nullptr, dest);
   EXPECT_EQ(30u, buffer_size);
   EXPECT_EQ(
@@ -107,7 +112,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
   // old-style Dests dictionary object but has a sub-dictionary in
   // named_dests.pdf.
   buffer_size = sizeof(fixed_buffer);
-  dest = FPDF_GetNamedDest(document(), 5, fixed_buffer, buffer_size);
+  dest = FPDF_GetNamedDest(document(), 5, fixed_buffer, &buffer_size);
   EXPECT_NE(nullptr, dest);
   EXPECT_EQ(28u, buffer_size);
   EXPECT_EQ(
@@ -116,25 +121,25 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
 
   // Try to retrieve non-existent item with ample buffer.
   buffer_size = sizeof(fixed_buffer);
-  dest = FPDF_GetNamedDest(document(), 6, fixed_buffer, buffer_size);
+  dest = FPDF_GetNamedDest(document(), 6, fixed_buffer, &buffer_size);
   EXPECT_EQ(nullptr, dest);
   EXPECT_EQ(sizeof(fixed_buffer), buffer_size);  // unmodified.
 
   // Try to underflow/overflow the integer index.
   buffer_size = sizeof(fixed_buffer);
   dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::max(),
-                           fixed_buffer, buffer_size);
+                           fixed_buffer, &buffer_size);
   EXPECT_EQ(nullptr, dest);
   EXPECT_EQ(sizeof(fixed_buffer), buffer_size);  // unmodified.
 
   buffer_size = sizeof(fixed_buffer);
   dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::min(),
-                           fixed_buffer, buffer_size);
+                           fixed_buffer, &buffer_size);
   EXPECT_EQ(nullptr, dest);
   EXPECT_EQ(sizeof(fixed_buffer), buffer_size);  // unmodified.
 
   buffer_size = sizeof(fixed_buffer);
-  dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, buffer_size);
+  dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, &buffer_size);
   EXPECT_EQ(nullptr, dest);
   EXPECT_EQ(sizeof(fixed_buffer), buffer_size);  // unmodified.
 }
@@ -156,7 +161,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDestsByName) {
 
   long ignore_len = 0;
   FPDF_DEST dest_by_index =
-      FPDF_GetNamedDest(document(), 0, nullptr, ignore_len);
+      FPDF_GetNamedDest(document(), 0, nullptr, &ignore_len);
   EXPECT_EQ(dest_by_index, dest);
 
   // Item from Dests dictionary.
@@ -164,7 +169,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDestsByName) {
   EXPECT_NE(nullptr, dest);
 
   ignore_len = 0;
-  dest_by_index = FPDF_GetNamedDest(document(), 4, nullptr, ignore_len);
+  dest_by_index = FPDF_GetNamedDest(document(), 4, nullptr, &ignore_len);
   EXPECT_EQ(dest_by_index, dest);
 
   // Bad value type for item from Dests NameTree array.
index 164d8e8..8a18909 100644 (file)
         'fpdfsdk/src/fpdfdoc_embeddertest.cpp',
         'fpdfsdk/src/fpdfformfill_embeddertest.cpp',
         'fpdfsdk/src/fpdftext_embeddertest.cpp',
+        'fpdfsdk/src/fpdfview_c_api_test.c',
+        'fpdfsdk/src/fpdfview_c_api_test.h',
         'fpdfsdk/src/fpdfview_embeddertest.cpp',
         'testing/embedder_test.cpp',
         'testing/embedder_test.h',
index de6cb23..bb929f4 100644 (file)
@@ -47,7 +47,7 @@ typedef struct _FX_FILEAVAIL {
         * Comments:
         *              Called by Foxit SDK to check whether the data section is ready.
         */
-       bool (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t size);
+       FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t size);
 } FX_FILEAVAIL;
 
 typedef void* FPDF_AVAIL;
index 96e3c85..a67ac2e 100644 (file)
@@ -53,8 +53,8 @@ typedef       struct _UNSUPPORT_INFO
        *               None.
        * */
 
-       void(*FSDK_UnSupport_Handler)(_UNSUPPORT_INFO* pThis,int nType);
-}UNSUPPORT_INFO;
+       void(*FSDK_UnSupport_Handler)(struct _UNSUPPORT_INFO* pThis, int nType);
+} UNSUPPORT_INFO;
 
 
 /**
index 5191fd7..cc81716 100644 (file)
@@ -1107,7 +1107,7 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,FPDF_BITMAP bitmap,
  * Return Value:
  *                      TRUE indicates that the input document has XFA fields, otherwise FALSE.
  **/
-DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType);
+DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int* docType);
 
 /**
  * Function: FPDF_LoadXFA
index f77e7e3..f27499a 100644 (file)
@@ -9,6 +9,10 @@
 
 #include "fpdfview.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef int                    FPDF_INT32;
 typedef unsigned int FPDF_UINT32;
 typedef float          FPDF_FLOAT;
@@ -281,6 +285,10 @@ struct FWL_EVENT
        }s;
 };  
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif //_FWL_EVENT_H
 
 
index 0909d5a..28b169b 100644 (file)
@@ -15,7 +15,7 @@ extern "C" {
 
 
 // Structure for custom file write
-struct FPDF_FILEWRITE{
+typedef struct FPDF_FILEWRITE_ {
 
        //
        //Version number of the interface. Currently must be 1.
@@ -38,9 +38,9 @@ struct FPDF_FILEWRITE{
        // Return value:
        //                      Should be non-zero if successful, zero for error.
        //
-       int             (*WriteBlock)( FPDF_FILEWRITE* pThis, const void* pData, unsigned long size);
+       int             (*WriteBlock)(struct FPDF_FILEWRITE_* pThis, const void* pData, unsigned long size);
 
-};
+} FPDF_FILEWRITE;
 
 
 /** @brief Incremental. */
index 32b0ea0..49de089 100644 (file)
 #include "fpdfview.h"
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef void* FPDF_PAGEARCSAVER;
 typedef void* FPDF_PAGEARCLOADER;
 /**
@@ -114,5 +118,9 @@ DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath);
 */
 DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,FPDF_CLIPPATH clipPath);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
index d0b745c..18acc6e 100644 (file)
@@ -738,7 +738,7 @@ DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
 // Return value:
 //                     The handle of the dest.
 //
-DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_BYTESTRING name);
+DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name);
 
 // Function: FPDF_GetNamedDest
 //                     Get the specified named destinations of the PDF document by index.
@@ -755,7 +755,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_
 //                     2) Second time pass in allocated |buffer| and buflen to retrieve |buffer|, which should be used as wchar_t*.
 //                        If buflen is not sufficiently large, it will be set to -1 upon return.
 //
-DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, long& buflen);
+DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, long* buflen);
 
 // Function: FPDF_BStr_Init    
 //                     Helper function to initialize a byte string.
index 8ab9497..7c6b8b9 100644 (file)
@@ -414,7 +414,7 @@ int Get_Block(void* param, unsigned long pos, unsigned char* pBuf,
   return 1;
 }
 
-bool Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) {
+FPDF_BOOL Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) {
   return true;
 }
 
@@ -478,7 +478,7 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
 
   FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks);
   int docType = DOCTYPE_PDF;
-  if (FPDF_HasXFAField(doc, docType))
+  if (FPDF_HasXFAField(doc, &docType))
   {
       if (docType != DOCTYPE_PDF && !FPDF_LoadXFA(doc))
           fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n");
index e161867..1c3c2fe 100644 (file)
@@ -167,7 +167,7 @@ int Get_Block(void* param, unsigned long pos, unsigned char* pBuf,
   return 1;
 }
 
-bool Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) {
+FPDF_BOOL Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) {
   return true;
 }
 
@@ -262,7 +262,7 @@ bool EmbedderTest::OpenDocument(const std::string& filename) {
     return false;
   }
   int docType = DOCTYPE_PDF;
-  if (FPDF_HasXFAField(document_, docType))
+  if (FPDF_HasXFAField(document_, &docType))
   {
     if (docType != DOCTYPE_PDF)
       (void) FPDF_LoadXFA(document_);