Example #1
0
DLLEXPORT FPDF_FORMHANDLE STDCALL
FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
                                FPDF_FORMFILLINFO* formInfo) {
#ifdef PDF_ENABLE_XFA
  const int kRequiredVersion = 2;
#else   // PDF_ENABLE_XFA
  const int kRequiredVersion = 1;
#endif  // PDF_ENABLE_XFA
  if (!formInfo || formInfo->version != kRequiredVersion)
    return nullptr;

  UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document);
  if (!pDocument)
    return nullptr;

  CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo);
#ifdef PDF_ENABLE_XFA
  pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv));
  CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
  pApp->AddFormFillEnv(pEnv);
#else  // PDF_ENABLE_XFA
  pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv));
#endif  // PDF_ENABLE_XFA
  return pEnv;
}
Example #2
0
DLLEXPORT FPDF_FORMHANDLE STDCALL
FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
                                FPDF_FORMFILLINFO* formInfo) {
#ifdef PDF_ENABLE_XFA
    const int kRequiredVersion = 2;
#else   // PDF_ENABLE_XFA
    const int kRequiredVersion = 1;
#endif  // PDF_ENABLE_XFA
    if (!formInfo || formInfo->version != kRequiredVersion)
        return nullptr;

    UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document);
    if (!pDocument)
        return nullptr;

#ifdef PDF_ENABLE_XFA
    // If the CPDFXFA_Document has a SDKDocument already then we've done this
    // and can just return the old Env. Otherwise, we'll end up setting a new
    // SDKDocument into the XFADocument and, that could get weird.
    if (pDocument->GetSDKDoc())
        return pDocument->GetSDKDoc()->GetEnv();
#endif

    CPDFSDK_Environment* pEnv = new CPDFSDK_Environment(pDocument, formInfo);

#ifdef PDF_ENABLE_XFA
    // Ownership of the SDKDocument is passed to the CPDFXFA_Document.
    pDocument->SetSDKDoc(WrapUnique(pEnv->GetSDKDocument()));
    CPDFXFA_App::GetInstance()->AddFormFillEnv(pEnv);
#endif  // PDF_ENABLE_XFA

    return pEnv;
}
Example #3
0
DLLEXPORT FPDF_FORMHANDLE STDCALL
FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
                                FPDF_FORMFILLINFO* formInfo) {
#ifdef PDF_ENABLE_XFA
  const int kRequiredVersion = 2;
#else   // PDF_ENABLE_XFA
  const int kRequiredVersion = 1;
#endif  // PDF_ENABLE_XFA
  if (!formInfo || formInfo->version != kRequiredVersion)
    return nullptr;

  UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document);
  if (!pDocument)
    return nullptr;

#ifdef PDF_ENABLE_XFA
  // If the CPDFXFA_Context has a FormFillEnvironment already then we've done
  // this and can just return the old Env. Otherwise, we'll end up setting a new
  // environment into the XFADocument and, that could get weird.
  if (pDocument->GetFormFillEnv())
    return pDocument->GetFormFillEnv();
#endif

  CPDFSDK_FormFillEnvironment* pFormFillEnv =
      new CPDFSDK_FormFillEnvironment(pDocument, formInfo);

#ifdef PDF_ENABLE_XFA
  pDocument->SetFormFillEnv(pFormFillEnv);
#endif  // PDF_ENABLE_XFA

  return pFormFillEnv;
}
Example #4
0
DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) {
  if (UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document))
    pDoc->DeletePage(page_index);
}