diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-10-18 12:28:14 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-18 16:41:35 +0000 |
commit | 854d71c1420eb80ec79755a6cdf829f3f39aead7 (patch) | |
tree | ba5f94431c46bcf8fa5b8e873304f14c8c69088c /fpdfsdk/fpdfformfill.cpp | |
parent | 7c2daec0a5f5d5e0f442db7946e9356daa7c55b2 (diff) | |
download | pdfium-854d71c1420eb80ec79755a6cdf829f3f39aead7.tar.xz |
Refactor HasXFAField into HasFormInfo
The existing API is too restrictive for collection the metrics
information that we want. Specifically it only tells us if there are
XFA forms in the document, but not AcroForms. This refactoring makes
the method more general, so that non-XFA information is provided
also. This change in semantics of the return value required some
changes at the call sites of the API.
BUG=chromium:775519
Change-Id: Id421c66c09b47196c252c64cdc2c711ca1911de0
Reviewed-on: https://pdfium-review.googlesource.com/16210
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfformfill.cpp')
-rw-r--r-- | fpdfsdk/fpdfformfill.cpp | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 9e8b69e29e..d70b678206 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -33,13 +33,15 @@ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" -static_assert(static_cast<int>(XFA_DocType::kNone) == XFADOCTYPE_NONE, - "PDF doctype must match"); -static_assert(static_cast<int>(XFA_DocType::kFull) == XFADOCTYPE_FULL, - "Dynamic XFA doctype must match"); -static_assert(static_cast<int>(XFA_DocType::kForegroundOnly) == - XFADOCTYPE_FOREGROUNDONLY, - "Static XFA doctype must match"); +static_assert(static_cast<int>(FormType::kNone) == FORMTYPE_NONE, + "None form types must match"); +static_assert(static_cast<int>(FormType::kAcroForm) == FORMTYPE_ACRO_FORM, + "AcroForm form types must match"); +static_assert(static_cast<int>(FormType::kXFAFull) == FORMTYPE_XFA_FULL, + "XFA full form types must match"); +static_assert(static_cast<int>(FormType::kXFAForeground) == + FORMTYPE_XFA_FOREGROUND, + "XFA foreground form types must match"); #endif // PDF_ENABLE_XFA namespace { @@ -457,10 +459,8 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_Widget_Undo(FPDF_DOCUMENT document, return; CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document); - if (pContext->GetDocType() != XFA_DocType::kFull && - pContext->GetDocType() != XFA_DocType::kForegroundOnly) { + if (!pContext->ContainsXFAForm()) return; - } static_cast<CXFA_FFWidget*>(hWidget)->Undo(); } @@ -471,8 +471,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_Widget_Redo(FPDF_DOCUMENT document, return; CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document); - if (pContext->GetDocType() != XFA_DocType::kFull && - pContext->GetDocType() != XFA_DocType::kForegroundOnly) + if (!pContext->ContainsXFAForm()) return; static_cast<CXFA_FFWidget*>(hWidget)->Redo(); @@ -484,8 +483,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_Widget_SelectAll(FPDF_DOCUMENT document, return; CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document); - if (pContext->GetDocType() != XFA_DocType::kFull && - pContext->GetDocType() != XFA_DocType::kForegroundOnly) + if (!pContext->ContainsXFAForm()) return; static_cast<CXFA_FFWidget*>(hWidget)->SelectAll(); @@ -499,8 +497,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_Widget_Copy(FPDF_DOCUMENT document, return; CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document); - if (pContext->GetDocType() != XFA_DocType::kFull && - pContext->GetDocType() != XFA_DocType::kForegroundOnly) + if (!pContext->ContainsXFAForm()) return; WideString wsCpText; @@ -531,8 +528,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_Widget_Cut(FPDF_DOCUMENT document, return; CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document); - if (pContext->GetDocType() != XFA_DocType::kFull && - pContext->GetDocType() != XFA_DocType::kForegroundOnly) + if (!pContext->ContainsXFAForm()) return; WideString wsCpText; @@ -563,8 +559,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_Widget_Paste(FPDF_DOCUMENT document, return; CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document); - if (pContext->GetDocType() != XFA_DocType::kFull && - pContext->GetDocType() != XFA_DocType::kForegroundOnly) + if (!pContext->ContainsXFAForm()) return; WideString wstr = WideString::FromUTF16LE(wsText, size); @@ -581,8 +576,7 @@ FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, return; CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document); - if (pContext->GetDocType() != XFA_DocType::kFull && - pContext->GetDocType() != XFA_DocType::kForegroundOnly) + if (!pContext->ContainsXFAForm()) return; CFX_PointF ptPopup; @@ -602,8 +596,7 @@ FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, return; auto* pContext = static_cast<CPDFXFA_Context*>(document); - if (pContext->GetDocType() != XFA_DocType::kFull && - pContext->GetDocType() != XFA_DocType::kForegroundOnly) + if (!pContext->ContainsXFAForm()) return; CFX_PointF ptPopup; |