diff options
author | Bo Xu <bo_xu@foxitsoftware.com> | 2014-10-28 23:03:33 -0700 |
---|---|---|
committer | Bo Xu <bo_xu@foxitsoftware.com> | 2014-11-03 11:10:11 -0800 |
commit | fdc00a7042d912aafaabddae4d9c84199921ef23 (patch) | |
tree | 32ab8ac91cc68d2cd15b9168782a71b3f3f5e7b9 /core/src/fpdfdoc | |
parent | e9b38fa38de2c95d8260be31c57d9272c4d127ed (diff) | |
download | pdfium-fdc00a7042d912aafaabddae4d9c84199921ef23.tar.xz |
Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r-- | core/src/fpdfdoc/doc_formfield.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index a2f0fbd297..64e9c287cc 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -797,6 +797,77 @@ int CPDF_FormField::FindOptionValue(FX_LPCWSTR csOptValue, int iStartIndex) } return -1; } +int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, int index, FX_BOOL bNotify)
+{
+ if (csOptLabel.IsEmpty()) return -1;
+
+ if (bNotify && m_pForm->m_pFormNotify != NULL)
+ {
+ int iRet = 0;
+ if (GetType() == ListBox) iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csOptLabel);
+ if (GetType() == ComboBox) iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csOptLabel);
+ if (iRet < 0) return -1;
+ }
+
+ CFX_ByteString csStr = PDF_EncodeText(csOptLabel, csOptLabel.GetLength());
+ CPDF_Array* pOpt = NULL;
+ CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "Opt");
+ if (pValue == NULL || pValue->GetType() != PDFOBJ_ARRAY)
+ {
+ pOpt = CPDF_Array::Create();
+ if (pOpt == NULL) return -1;
+ m_pDict->SetAt("Opt", pOpt);
+ }
+ else
+ pOpt = (CPDF_Array*)pValue;
+ int iCount = (int)pOpt->GetCount();
+ if (index < 0 || index >= iCount)
+ {
+ pOpt->AddString(csStr);
+ index = iCount;
+ }
+ else {
+ CPDF_String* pString = CPDF_String::Create(csStr);
+ if (pString == NULL) return -1;
+ pOpt->InsertAt(index, pString);
+ }
+
+ if (bNotify && m_pForm->m_pFormNotify != NULL)
+ {
+ if (GetType() == ListBox) m_pForm->m_pFormNotify->AfterSelectionChange(this);
+ if (GetType() == ComboBox) m_pForm->m_pFormNotify->AfterValueChange(this);
+ }
+ m_pForm->m_bUpdated = TRUE;
+ return index;
+} +FX_BOOL CPDF_FormField::ClearOptions(FX_BOOL bNotify)
+{
+ if (bNotify && m_pForm->m_pFormNotify != NULL)
+ {
+ int iRet = 0;
+ CFX_WideString csValue;
+ int iIndex = GetSelectedIndex(0);
+ if (iIndex >= 0) csValue = GetOptionLabel(iIndex);
+ if (GetType() == ListBox) iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue);
+ if (GetType() == ComboBox) iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue);
+ if (iRet < 0) return FALSE;
+ }
+
+ m_pDict->RemoveAt("Opt");
+ m_pDict->RemoveAt("V");
+ m_pDict->RemoveAt("DV");
+ m_pDict->RemoveAt("I");
+ m_pDict->RemoveAt("TI");
+
+ if (bNotify && m_pForm->m_pFormNotify != NULL)
+ {
+ if (GetType() == ListBox) m_pForm->m_pFormNotify->AfterSelectionChange(this);
+ if (GetType() == ComboBox) m_pForm->m_pFormNotify->AfterValueChange(this);
+ }
+
+ m_pForm->m_bUpdated = TRUE;
+ return TRUE;
+} FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, FX_BOOL bChecked, FX_BOOL bNotify) { ASSERT(GetType() == CheckBox || GetType() == RadioButton); |