summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-02 16:02:03 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-02 16:02:03 -0800
commited5d7aa789ec5ef7b440d7e56b71804b41a928e3 (patch)
tree028bced4e1203313752240a1a3de7fbf998611c3
parent23bf560507a8e03968e66480281597be9161abf4 (diff)
downloadpdfium-ed5d7aa789ec5ef7b440d7e56b71804b41a928e3.tar.xz
Merge to XFA: Kill CFX_ByteArray in master.
One trivial edit in fx_basic.h Includes both fixes for build breakage. Review URL: https://codereview.chromium.org/1653253002 . (cherry picked from commit 9b0a59d659d8083802385649ba74370d65c41e36) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1655423002 .
-rw-r--r--core/include/fpdfdoc/fpdf_doc.h43
-rw-r--r--core/include/fxcrt/fx_basic.h2
-rw-r--r--core/src/fpdfdoc/doc_form.cpp6
-rw-r--r--core/src/fpdfdoc/doc_formcontrol.cpp9
-rw-r--r--core/src/fpdfdoc/doc_formfield.cpp22
-rw-r--r--core/src/fpdfdoc/doc_utils.cpp16
-rw-r--r--core/src/fpdfdoc/doc_utils.h4
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp15
-rw-r--r--fpdfsdk/include/fsdk_baseform.h3
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp12
10 files changed, 47 insertions, 85 deletions
diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h
index 97d7391cd0..a99d10ed58 100644
--- a/core/include/fpdfdoc/fpdf_doc.h
+++ b/core/include/fpdfdoc/fpdf_doc.h
@@ -734,12 +734,10 @@ class CPDF_FormField {
CFX_WideString GetFullName();
- Type GetType() { return m_Type; }
-
- FX_DWORD GetFlags() { return m_Flags; }
+ Type GetType() const { return m_Type; }
+ FX_DWORD GetFlags() const { return m_Flags; }
CPDF_Dictionary* GetFieldDict() const { return m_pDict; }
-
void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; }
FX_BOOL ResetField(FX_BOOL bNotify = FALSE);
@@ -799,8 +797,8 @@ class CPDF_FormField {
int FindOptionValue(const CFX_WideString& csOptValue, int iStartIndex = 0);
FX_BOOL CheckControl(int iControlIndex,
- FX_BOOL bChecked,
- FX_BOOL bNotify = FALSE);
+ bool bChecked,
+ bool bNotify = false);
int GetTopVisibleIndex();
@@ -895,16 +893,15 @@ class CPDF_IconFit {
#define TEXTPOS_RIGHT 4
#define TEXTPOS_LEFT 5
#define TEXTPOS_OVERLAID 6
+
class CPDF_FormControl {
public:
- CPDF_FormField::Type GetType() { return m_pField->GetType(); }
+ enum HighlightingMode { None = 0, Invert, Outline, Push, Toggle };
+ CPDF_FormField::Type GetType() const { return m_pField->GetType(); }
CPDF_InterForm* GetInterForm() const { return m_pForm; }
-
CPDF_FormField* GetField() const { return m_pField; }
-
CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; }
-
CFX_FloatRect GetRect() const;
void DrawControl(CFX_RenderDevice* pDevice,
@@ -914,19 +911,13 @@ class CPDF_FormControl {
const CPDF_RenderOptions* pOptions = NULL);
CFX_ByteString GetCheckedAPState();
-
CFX_WideString GetExportValue();
- FX_BOOL IsChecked();
-
- FX_BOOL IsDefaultChecked();
-
- enum HighlightingMode { None = 0, Invert, Outline, Push, Toggle };
+ bool IsChecked() const;
+ bool IsDefaultChecked() const;
HighlightingMode GetHighlightingMode();
-
bool HasMKEntry(CFX_ByteString csEntry) const;
-
int GetRotation();
inline FX_ARGB GetBorderColor(int& iColorType) {
@@ -982,8 +973,7 @@ class CPDF_FormControl {
protected:
CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict);
- CFX_ByteString GetOnStateName();
-
+ CFX_ByteString GetOnStateName() const;
void SetOnStateName(const CFX_ByteString& csOn);
void CheckControl(FX_BOOL bChecked);
@@ -1010,6 +1000,7 @@ class CPDF_FormControl {
friend class CPDF_InterForm;
friend class CPDF_FormField;
};
+
class CPDF_FormNotify {
public:
virtual ~CPDF_FormNotify() {}
@@ -1018,29 +1009,21 @@ class CPDF_FormNotify {
CFX_WideString& csValue) {
return 0;
}
-
virtual int AfterValueChange(const CPDF_FormField* pField) { return 0; }
virtual int BeforeSelectionChange(const CPDF_FormField* pField,
CFX_WideString& csValue) {
return 0;
}
-
virtual int AfterSelectionChange(const CPDF_FormField* pField) { return 0; }
- virtual int AfterCheckedStatusChange(const CPDF_FormField* pField,
- const CFX_ByteArray& statusArray) {
- return 0;
- }
-
+ virtual void AfterCheckedStatusChange(CPDF_FormField* pField) {}
virtual int BeforeFormReset(const CPDF_InterForm* pForm) { return 0; }
-
virtual int AfterFormReset(const CPDF_InterForm* pForm) { return 0; }
-
virtual int BeforeFormImportData(const CPDF_InterForm* pForm) { return 0; }
-
virtual int AfterFormImportData(const CPDF_InterForm* pForm) { return 0; }
};
+
FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
class CPDF_PageLabel {
public:
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index 34c79ee510..291aaaf9f8 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -435,13 +435,13 @@ class CFX_ArrayTemplate : public CFX_BasicArray {
return -1;
}
};
-typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray;
typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray;
typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray;
typedef CFX_ArrayTemplate<void*> CFX_PtrArray;
typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray;
#ifdef PDF_ENABLE_XFA
typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
+typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray;
typedef CFX_ArrayTemplate<int32_t> CFX_Int32Array;
#endif // PDF_ENABLE_XFA
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index b07fe45ed5..5cfad3f068 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -1175,10 +1175,6 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict,
return;
}
}
- CFX_ByteArray statusArray;
- if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) {
- SaveCheckedFieldStatus(pField, statusArray);
- }
pField->SetValue(csWValue);
CPDF_FormField::Type eType = pField->GetType();
if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) &&
@@ -1188,7 +1184,7 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict,
}
if (bNotify && m_pFormNotify) {
if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) {
- m_pFormNotify->AfterCheckedStatusChange(pField, statusArray);
+ m_pFormNotify->AfterCheckedStatusChange(pField);
} else if (iType == FIELDTYPE_LISTBOX) {
m_pFormNotify->AfterSelectionChange(pField);
} else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) {
diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp
index feaff38f16..169e9d73b7 100644
--- a/core/src/fpdfdoc/doc_formcontrol.cpp
+++ b/core/src/fpdfdoc/doc_formcontrol.cpp
@@ -17,7 +17,7 @@ CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField,
CFX_FloatRect CPDF_FormControl::GetRect() const {
return m_pWidgetDict->GetRectBy("Rect");
}
-CFX_ByteString CPDF_FormControl::GetOnStateName() {
+CFX_ByteString CPDF_FormControl::GetOnStateName() const {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
CFX_ByteString csOn;
@@ -112,14 +112,16 @@ CFX_WideString CPDF_FormControl::GetExportValue() {
CFX_WideString csWOn = PDF_DecodeText(csOn);
return csWOn;
}
-FX_BOOL CPDF_FormControl::IsChecked() {
+
+bool CPDF_FormControl::IsChecked() const {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
CFX_ByteString csOn = GetOnStateName();
CFX_ByteString csAS = m_pWidgetDict->GetStringBy("AS");
return csAS == csOn;
}
-FX_BOOL CPDF_FormControl::IsDefaultChecked() {
+
+bool CPDF_FormControl::IsDefaultChecked() const {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
CPDF_Object* pDV = FPDF_GetFieldAttr(m_pField->m_pDict, "DV");
@@ -130,6 +132,7 @@ FX_BOOL CPDF_FormControl::IsDefaultChecked() {
CFX_ByteString csOn = GetOnStateName();
return (csDV == csOn);
}
+
void CPDF_FormControl::CheckControl(FX_BOOL bChecked) {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp
index 39af0c94c7..31557b490d 100644
--- a/core/src/fpdfdoc/doc_formfield.cpp
+++ b/core/src/fpdfdoc/doc_formfield.cpp
@@ -102,10 +102,6 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
switch (m_Type) {
case CPDF_FormField::CheckBox:
case CPDF_FormField::RadioButton: {
- CFX_ByteArray statusArray;
- if (bNotify && m_pForm->m_pFormNotify) {
- SaveCheckedFieldStatus(this, statusArray);
- }
int iCount = CountControls();
if (iCount) {
if (PDF_FormField_IsUnison(this)) {
@@ -121,7 +117,7 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
}
}
if (bNotify && m_pForm->m_pFormNotify) {
- m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray);
+ m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
} break;
case CPDF_FormField::ComboBox: {
@@ -805,8 +801,8 @@ FX_BOOL CPDF_FormField::ClearOptions(FX_BOOL bNotify) {
}
#endif // PDF_ENABLE_XFA
FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
- FX_BOOL bChecked,
- FX_BOOL bNotify) {
+ bool bChecked,
+ bool bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
CPDF_FormControl* pControl = GetControl(iControlIndex);
if (!pControl) {
@@ -815,10 +811,6 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
if (!bChecked && pControl->IsChecked() == bChecked) {
return FALSE;
}
- CFX_ByteArray statusArray;
- if (bNotify && m_pForm->m_pFormNotify) {
- SaveCheckedFieldStatus(this, statusArray);
- }
CFX_WideString csWExport = pControl->GetExportValue();
CFX_ByteString csBExport = PDF_EncodeText(csWExport);
int iCount = CountControls();
@@ -864,7 +856,7 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
m_pDict->SetAtName("V", csIndex);
}
if (bNotify && m_pForm->m_pFormNotify) {
- m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray);
+ m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
m_pForm->m_bUpdated = TRUE;
return TRUE;
@@ -892,10 +884,6 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value,
FX_BOOL bDefault,
FX_BOOL bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
- CFX_ByteArray statusArray;
- if (bNotify && m_pForm->m_pFormNotify) {
- SaveCheckedFieldStatus(this, statusArray);
- }
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
@@ -914,7 +902,7 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value,
}
}
if (bNotify && m_pForm->m_pFormNotify) {
- m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray);
+ m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
m_pForm->m_bUpdated = TRUE;
return TRUE;
diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp
index 7db2887834..a2c0454bc9 100644
--- a/core/src/fpdfdoc/doc_utils.cpp
+++ b/core/src/fpdfdoc/doc_utils.cpp
@@ -678,17 +678,17 @@ FX_BOOL CPDF_IconFit::GetFittingBounds() {
}
return m_pDict->GetBooleanBy("FB");
}
-void SaveCheckedFieldStatus(CPDF_FormField* pField,
- CFX_ByteArray& statusArray) {
+
+std::vector<bool> SaveCheckedFieldStatus(CPDF_FormField* pField) {
+ std::vector<bool> result;
int iCount = pField->CountControls();
- for (int i = 0; i < iCount; i++) {
- CPDF_FormControl* pControl = pField->GetControl(i);
- if (!pControl) {
- continue;
- }
- statusArray.Add(pControl->IsChecked() ? 1 : 0);
+ for (int i = 0; i < iCount; ++i) {
+ if (CPDF_FormControl* pControl = pField->GetControl(i))
+ result.push_back(pControl->IsChecked());
}
+ return result;
}
+
CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict,
const FX_CHAR* name,
int nLevel) {
diff --git a/core/src/fpdfdoc/doc_utils.h b/core/src/fpdfdoc/doc_utils.h
index 4a6652f9c6..58eee84380 100644
--- a/core/src/fpdfdoc/doc_utils.h
+++ b/core/src/fpdfdoc/doc_utils.h
@@ -7,6 +7,8 @@
#ifndef CORE_SRC_FPDFDOC_DOC_UTILS_H_
#define CORE_SRC_FPDFDOC_DOC_UTILS_H_
+#include <vector>
+
CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict);
void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument);
FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict);
@@ -54,7 +56,7 @@ CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict,
void SetDefaultInterFormFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
const CPDF_Font* pFont);
-void SaveCheckedFieldStatus(CPDF_FormField* pField, CFX_ByteArray& statusArray);
+std::vector<bool> SaveCheckedFieldStatus(CPDF_FormField* pField);
FX_BOOL NeedPDFEncodeForFieldFullName(const CFX_WideString& csFieldName);
FX_BOOL NeedPDFEncodeForFieldTree(CPDF_Dictionary* pFieldDict, int nLevel = 0);
void EncodeFieldName(const CFX_WideString& csName, CFX_ByteString& csT);
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 55f736ee9c..66d20aff08 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -10,6 +10,7 @@
#include <cctype>
#include <cwctype>
#include <memory>
+#include <vector>
#include "core/include/fpdfapi/fpdf_module.h"
#include "core/include/fpdfapi/fpdf_page.h"
@@ -748,16 +749,10 @@ int32_t CPDF_TextPage::FindTextlineFlowDirection() {
}
const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth();
const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight();
- CFX_ByteArray nHorizontalMask;
- if (!nHorizontalMask.SetSize(nPageWidth)) {
- return -1;
- }
- uint8_t* pDataH = nHorizontalMask.GetData();
- CFX_ByteArray nVerticalMask;
- if (!nVerticalMask.SetSize(nPageHeight)) {
- return -1;
- }
- uint8_t* pDataV = nVerticalMask.GetData();
+ std::vector<uint8_t> nHorizontalMask(nPageWidth);
+ std::vector<uint8_t> nVerticalMask(nPageHeight);
+ uint8_t* pDataH = nHorizontalMask.data();
+ uint8_t* pDataV = nVerticalMask.data();
int32_t index = 0;
FX_FLOAT fLineHeight = 0.0f;
CPDF_PageObject* pPageObj = NULL;
diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h
index 0d72639b9b..6722382a25 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -327,8 +327,7 @@ class CPDFSDK_InterForm : public CPDF_FormNotify {
int BeforeSelectionChange(const CPDF_FormField* pField,
CFX_WideString& csValue) override;
int AfterSelectionChange(const CPDF_FormField* pField) override;
- int AfterCheckedStatusChange(const CPDF_FormField* pField,
- const CFX_ByteArray& statusArray) override;
+ void AfterCheckedStatusChange(CPDF_FormField* pField) override;
int BeforeFormReset(const CPDF_InterForm* pForm) override;
int AfterFormReset(const CPDF_InterForm* pForm) override;
int BeforeFormImportData(const CPDF_InterForm* pForm) override;
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 72c192a7e9..78bb20e353 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -2671,16 +2671,12 @@ int CPDFSDK_InterForm::AfterSelectionChange(const CPDF_FormField* pField) {
return 0;
}
-int CPDFSDK_InterForm::AfterCheckedStatusChange(
- const CPDF_FormField* pField,
- const CFX_ByteArray& statusArray) {
- CPDF_FormField* pFormField = (CPDF_FormField*)pField;
- int nType = pFormField->GetFieldType();
+void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) {
+ int nType = pField->GetFieldType();
if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON) {
- OnCalculate(pFormField);
- UpdateField(pFormField);
+ OnCalculate(pField);
+ UpdateField(pField);
}
- return 0;
}
int CPDFSDK_InterForm::BeforeFormReset(const CPDF_InterForm* pForm) {