summaryrefslogtreecommitdiff
path: root/core/src
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 /core/src
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 .
Diffstat (limited to 'core/src')
-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
6 files changed, 28 insertions, 44 deletions
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;