summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfdoc/fpdf_doc.h39
-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.cpp18
-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.cpp14
8 files changed, 37 insertions, 71 deletions
diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h
index 61fbb753ba..f0088a6cb3 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);
@@ -887,16 +885,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,
@@ -906,19 +903,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) {
@@ -974,8 +965,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);
@@ -1002,6 +992,7 @@ class CPDF_FormControl {
friend class CPDF_InterForm;
friend class CPDF_FormField;
};
+
class CPDF_FormNotify {
public:
virtual ~CPDF_FormNotify() {}
@@ -1010,29 +1001,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 9911b1cb45..9eb03b9818 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -371,7 +371,7 @@ 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;
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index a061c852b5..2f9cb51385 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -1160,10 +1160,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) &&
@@ -1173,7 +1169,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 b309e82575..3c161cf1e2 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: {
@@ -740,10 +736,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();
@@ -789,7 +781,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;
@@ -817,10 +809,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);
@@ -839,7 +827,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..90b932cd4c 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -748,16 +748,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;