Replace CFX_MapPtrTemplate with std::map.
[pdfium.git] / fpdfsdk / src / fpdfformfill.cpp
index 2de7603..9358c9e 100644 (file)
@@ -1,11 +1,11 @@
 // Copyright 2014 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.
+
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "../include/fpdfview.h"
-#include "../include/fpdfformfill.h"
+#include "../../public/fpdf_formfill.h"
+#include "../../public/fpdfview.h"
 #include "../include/fsdk_define.h"
 #include "../include/fsdk_mgr.h"
 
@@ -35,13 +35,13 @@ DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_
                delete pInterForm;
                return -1;
        }
-       
+
        int nType = pFormField->GetFieldType();
        delete pInterForm;
        return nType;
 }
 
-DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnviroument(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo)
+DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo)
 {
        if(!document || !formInfo || formInfo->version!=1)
                return NULL;
@@ -61,10 +61,10 @@ DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnviroument(FPDF_DOCUMENT
        return pEnv;
 }
 
-DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnviroument(FPDF_FORMHANDLE hHandle)
+DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle)
 {
        if(!hHandle)
-               return; 
+               return;
        CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
        if(pSDKDoc)
        {
@@ -76,7 +76,7 @@ DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnviroument(FPDF_FORMHANDLE hHandle)
 }
 
 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
-{      
+{
        if (!hHandle || !page)
                return FALSE;
 //     CPDF_Page * pPage = (CPDF_Page*) page;
@@ -88,7 +88,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE
        CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
        if(!pPageView)
                return FALSE;
-       
+
 //     double page_x = 0;
 //     double page_y = 0;
 //     pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y);
@@ -140,8 +140,8 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa
        CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
        if(!pPageView)
                return FALSE;
-       
-       
+
+
        return pPageView->OnKeyDown(nKeyCode, modifier);
 }
 
@@ -155,8 +155,8 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page
        CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
        if(!pPageView)
                return FALSE;
-       
-       
+
+
        return pPageView->OnKeyUp(nKeyCode, modifier);
 }
 
@@ -182,23 +182,23 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle)
        CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
        if(!pSDKDoc)
                return FALSE;
-       //Kill the current focus. 
+       //Kill the current focus.
        return pSDKDoc->KillFocusAnnot(0);
 }
 
-DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, 
+DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y,
                                                                                                  int size_x, int size_y, int rotate, int flags)
 {
        if (!hHandle || !page)
                return ;
        CPDF_Page* pPage = (CPDF_Page*)page;
-       
+
        CPDF_RenderOptions options;
        if (flags & FPDF_LCD_TEXT)
                options.m_Flags |= RENDER_CLEARTYPE;
        else
                options.m_Flags &= ~RENDER_CLEARTYPE;
-       
+
        //Grayscale output
        if (flags & FPDF_GRAYSCALE)
        {
@@ -206,16 +206,13 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
                options.m_ForeColor = 0;
                options.m_BackColor = 0xffffff;
        }
-       
-       options.m_AddFlags = flags >> 8;
 
-       options.m_pOCContext = FX_NEW CPDF_OCContext(pPage->m_pDocument);
+       options.m_AddFlags = flags >> 8;
+       options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument);
 
-       //FXMT_CSLOCK_OBJ(&pPage->m_PageLock);
-       
        CFX_AffineMatrix matrix;
-       pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); 
-       
+       pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
+
        FX_RECT clip;
        clip.left = start_x;
        clip.right = start_x + size_x;
@@ -223,30 +220,15 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
        clip.bottom = start_y + size_y;
 
 #ifdef _SKIA_SUPPORT_
-       CFX_SkiaDevice* pDevice = FX_NEW CFX_SkiaDevice;
+       CFX_SkiaDevice* pDevice = new CFX_SkiaDevice;
 #else
-       CFX_FxgeDevice* pDevice = NULL;
-       pDevice = FX_NEW CFX_FxgeDevice;
+       CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
 #endif
-
-       if (!pDevice)
-               return;
        pDevice->Attach((CFX_DIBitmap*)bitmap);
        pDevice->SaveState();
        pDevice->SetClip_Rect(&clip);
-       
-
-       CPDF_RenderContext* pContext = NULL;
-       pContext = FX_NEW CPDF_RenderContext;
-       if (!pContext)
-       {
-               delete pDevice;
-               pDevice = NULL;
-               return;
-       }
-
 
-//     CPDF_Document* pDoc = pPage->m_pDocument;
+       CPDF_RenderContext* pContext = new CPDF_RenderContext;
        CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
        CPDFSDK_Document* pFXDoc = pEnv->GetCurrentDoc();
        if(!pFXDoc)
@@ -293,7 +275,7 @@ DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
                {
                        pInterForm->SetHighlightColor(color, fieldType);
                }
-       
+
        }
 
 }
@@ -334,7 +316,7 @@ DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan
        if(pPageView)
        {
                pPageView->SetValid(TRUE);
-       }       
+       }
 }
 
 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hHandle)
@@ -357,10 +339,9 @@ DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle)
                return;
        if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc())
        {
-               pSDKDoc->InitPageView();
                if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
                        pSDKDoc->ProcJavascriptFun();
-       }       
+       }
 }
 
 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle)
@@ -385,7 +366,7 @@ DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaTyp
                if (!pDic)
                        return;
                CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA"));
-               
+
                if(aa.ActionExist((CPDF_AAction::AActionType)aaType))
                {
                        CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType);
@@ -406,13 +387,13 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl
        {
                CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv();
                ASSERT(pEnv != NULL);
-                       
+
                CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander();
                ASSERT(pActionHandler != NULL);
-               
+
                CPDF_Dictionary *pPageDict = pPage->m_pFormDict;
                ASSERT(pPageDict != NULL);
-                
+
                CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA"));
 
                FX_BOOL bExistOAAction = FALSE;