| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../include/fpdfdoc/fpdf_doc.h" | 7 #include "../../include/fpdfdoc/fpdf_doc.h" |
| 8 #include "../../include/fxcrt/fx_xml.h" | 8 #include "../../include/fxcrt/fx_xml.h" |
| 9 #include "doc_utils.h" | 9 #include "doc_utils.h" |
| 10 | 10 |
| 11 const int nMaxRecursion = 32; | 11 const int nMaxRecursion = 32; |
| 12 | 12 |
| 13 class _CFieldNameExtractor | 13 class _CFieldNameExtractor |
| 14 { | 14 { |
| 15 public: | 15 public: |
| 16 _CFieldNameExtractor(const CFX_WideString& full_name) | 16 _CFieldNameExtractor(const CFX_WideString& full_name) |
| 17 { | 17 { |
| 18 m_pStart = full_name.c_str(); | 18 m_pStart = full_name.c_str(); |
| 19 m_pEnd = m_pStart + full_name.GetLength(); | 19 m_pEnd = m_pStart + full_name.GetLength(); |
| 20 m_pCur = m_pStart; | 20 m_pCur = m_pStart; |
| 21 } | 21 } |
| 22 void GetNext(FX_LPCWSTR &pSubName, FX_STRSIZE& size) | 22 void GetNext(const FX_WCHAR* &pSubName, FX_STRSIZE& size) |
| 23 { | 23 { |
| 24 pSubName = m_pCur; | 24 pSubName = m_pCur; |
| 25 while (m_pCur < m_pEnd && m_pCur[0] != L'.') { | 25 while (m_pCur < m_pEnd && m_pCur[0] != L'.') { |
| 26 m_pCur++; | 26 m_pCur++; |
| 27 } | 27 } |
| 28 size = (FX_STRSIZE)(m_pCur - pSubName); | 28 size = (FX_STRSIZE)(m_pCur - pSubName); |
| 29 if (m_pCur < m_pEnd && m_pCur[0] == L'.') { | 29 if (m_pCur < m_pEnd && m_pCur[0] == L'.') { |
| 30 m_pCur++; | 30 m_pCur++; |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 protected: | 33 protected: |
| 34 FX_LPCWSTR m_pStart; | 34 const FX_WCHAR* m_pStart; |
| 35 FX_LPCWSTR m_pEnd; | 35 const FX_WCHAR* m_pEnd; |
| 36 FX_LPCWSTR m_pCur; | 36 const FX_WCHAR* m_pCur; |
| 37 }; | 37 }; |
| 38 class CFieldTree | 38 class CFieldTree |
| 39 { | 39 { |
| 40 public: | 40 public: |
| 41 struct _Node { | 41 struct _Node { |
| 42 _Node *parent; | 42 _Node *parent; |
| 43 CFX_PtrArray children; | 43 CFX_PtrArray children; |
| 44 CFX_WideString short_name; | 44 CFX_WideString short_name; |
| 45 CPDF_FormField *field_ptr; | 45 CPDF_FormField *field_ptr; |
| 46 int CountFields(int nLevel = 0) | 46 int CountFields(int nLevel = 0) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 _Node *pNode = (_Node *)ptr_array[i]; | 152 _Node *pNode = (_Node *)ptr_array[i]; |
| 153 RemoveNode(pNode); | 153 RemoveNode(pNode); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 void CFieldTree::SetField(const CFX_WideString &full_name, CPDF_FormField *field
_ptr) | 156 void CFieldTree::SetField(const CFX_WideString &full_name, CPDF_FormField *field
_ptr) |
| 157 { | 157 { |
| 158 if (full_name == L"") { | 158 if (full_name == L"") { |
| 159 return; | 159 return; |
| 160 } | 160 } |
| 161 _CFieldNameExtractor name_extractor(full_name); | 161 _CFieldNameExtractor name_extractor(full_name); |
| 162 FX_LPCWSTR pName; | 162 const FX_WCHAR* pName; |
| 163 FX_STRSIZE nLength; | 163 FX_STRSIZE nLength; |
| 164 name_extractor.GetNext(pName, nLength); | 164 name_extractor.GetNext(pName, nLength); |
| 165 _Node *pNode = &m_Root, *pLast = NULL; | 165 _Node *pNode = &m_Root, *pLast = NULL; |
| 166 while (nLength > 0) { | 166 while (nLength > 0) { |
| 167 pLast = pNode; | 167 pLast = pNode; |
| 168 CFX_WideString name = CFX_WideString(pName, nLength); | 168 CFX_WideString name = CFX_WideString(pName, nLength); |
| 169 pNode = _Lookup(pLast, name); | 169 pNode = _Lookup(pLast, name); |
| 170 if (pNode == NULL) { | 170 if (pNode == NULL) { |
| 171 pNode = AddChild(pLast, name, NULL); | 171 pNode = AddChild(pLast, name, NULL); |
| 172 } | 172 } |
| 173 name_extractor.GetNext(pName, nLength); | 173 name_extractor.GetNext(pName, nLength); |
| 174 } | 174 } |
| 175 if (pNode != &m_Root) { | 175 if (pNode != &m_Root) { |
| 176 pNode->field_ptr = field_ptr; | 176 pNode->field_ptr = field_ptr; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 CPDF_FormField *CFieldTree::GetField(const CFX_WideString &full_name) | 179 CPDF_FormField *CFieldTree::GetField(const CFX_WideString &full_name) |
| 180 { | 180 { |
| 181 if (full_name == L"") { | 181 if (full_name == L"") { |
| 182 return NULL; | 182 return NULL; |
| 183 } | 183 } |
| 184 _CFieldNameExtractor name_extractor(full_name); | 184 _CFieldNameExtractor name_extractor(full_name); |
| 185 FX_LPCWSTR pName; | 185 const FX_WCHAR* pName; |
| 186 FX_STRSIZE nLength; | 186 FX_STRSIZE nLength; |
| 187 name_extractor.GetNext(pName, nLength); | 187 name_extractor.GetNext(pName, nLength); |
| 188 _Node *pNode = &m_Root, *pLast = NULL; | 188 _Node *pNode = &m_Root, *pLast = NULL; |
| 189 while (nLength > 0 && pNode) { | 189 while (nLength > 0 && pNode) { |
| 190 pLast = pNode; | 190 pLast = pNode; |
| 191 CFX_WideString name = CFX_WideString(pName, nLength); | 191 CFX_WideString name = CFX_WideString(pName, nLength); |
| 192 pNode = _Lookup(pLast, name); | 192 pNode = _Lookup(pLast, name); |
| 193 name_extractor.GetNext(pName, nLength); | 193 name_extractor.GetNext(pName, nLength); |
| 194 } | 194 } |
| 195 return pNode ? pNode->field_ptr : NULL; | 195 return pNode ? pNode->field_ptr : NULL; |
| 196 } | 196 } |
| 197 CPDF_FormField *CFieldTree::RemoveField(const CFX_WideString & full_name) | 197 CPDF_FormField *CFieldTree::RemoveField(const CFX_WideString & full_name) |
| 198 { | 198 { |
| 199 if (full_name == L"") { | 199 if (full_name == L"") { |
| 200 return NULL; | 200 return NULL; |
| 201 } | 201 } |
| 202 _CFieldNameExtractor name_extractor(full_name); | 202 _CFieldNameExtractor name_extractor(full_name); |
| 203 FX_LPCWSTR pName; | 203 const FX_WCHAR* pName; |
| 204 FX_STRSIZE nLength; | 204 FX_STRSIZE nLength; |
| 205 name_extractor.GetNext(pName, nLength); | 205 name_extractor.GetNext(pName, nLength); |
| 206 _Node *pNode = &m_Root, *pLast = NULL; | 206 _Node *pNode = &m_Root, *pLast = NULL; |
| 207 while (nLength > 0 && pNode) { | 207 while (nLength > 0 && pNode) { |
| 208 pLast = pNode; | 208 pLast = pNode; |
| 209 CFX_WideString name = CFX_WideString(pName, nLength); | 209 CFX_WideString name = CFX_WideString(pName, nLength); |
| 210 pNode = _Lookup(pLast, name); | 210 pNode = _Lookup(pLast, name); |
| 211 name_extractor.GetNext(pName, nLength); | 211 name_extractor.GetNext(pName, nLength); |
| 212 } | 212 } |
| 213 if (pNode && pNode != &m_Root) { | 213 if (pNode && pNode != &m_Root) { |
| 214 CFX_PtrArray& ptr_array = pLast->children; | 214 CFX_PtrArray& ptr_array = pLast->children; |
| 215 for (int i = 0; i < ptr_array.GetSize(); i ++) { | 215 for (int i = 0; i < ptr_array.GetSize(); i ++) { |
| 216 if (pNode == (_Node *)ptr_array[i]) { | 216 if (pNode == (_Node *)ptr_array[i]) { |
| 217 ptr_array.RemoveAt(i); | 217 ptr_array.RemoveAt(i); |
| 218 break; | 218 break; |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 CPDF_FormField *pField = pNode->field_ptr; | 221 CPDF_FormField *pField = pNode->field_ptr; |
| 222 RemoveNode(pNode); | 222 RemoveNode(pNode); |
| 223 return pField; | 223 return pField; |
| 224 } | 224 } |
| 225 return NULL; | 225 return NULL; |
| 226 } | 226 } |
| 227 CFieldTree::_Node *CFieldTree::FindNode(const CFX_WideString& full_name) | 227 CFieldTree::_Node *CFieldTree::FindNode(const CFX_WideString& full_name) |
| 228 { | 228 { |
| 229 if (full_name == L"") { | 229 if (full_name == L"") { |
| 230 return NULL; | 230 return NULL; |
| 231 } | 231 } |
| 232 _CFieldNameExtractor name_extractor(full_name); | 232 _CFieldNameExtractor name_extractor(full_name); |
| 233 FX_LPCWSTR pName; | 233 const FX_WCHAR* pName; |
| 234 FX_STRSIZE nLength; | 234 FX_STRSIZE nLength; |
| 235 name_extractor.GetNext(pName, nLength); | 235 name_extractor.GetNext(pName, nLength); |
| 236 _Node *pNode = &m_Root, *pLast = NULL; | 236 _Node *pNode = &m_Root, *pLast = NULL; |
| 237 while (nLength > 0 && pNode) { | 237 while (nLength > 0 && pNode) { |
| 238 pLast = pNode; | 238 pLast = pNode; |
| 239 CFX_WideString name = CFX_WideString(pName, nLength); | 239 CFX_WideString name = CFX_WideString(pName, nLength); |
| 240 pNode = _Lookup(pLast, name); | 240 pNode = _Lookup(pLast, name); |
| 241 name_extractor.GetNext(pName, nLength); | 241 name_extractor.GetNext(pName, nLength); |
| 242 } | 242 } |
| 243 return pNode; | 243 return pNode; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 260 } | 260 } |
| 261 int count = pFields->GetCount(); | 261 int count = pFields->GetCount(); |
| 262 for (int i = 0; i < count; i ++) { | 262 for (int i = 0; i < count; i ++) { |
| 263 LoadField(pFields->GetDict(i)); | 263 LoadField(pFields->GetDict(i)); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 CPDF_InterForm::~CPDF_InterForm() | 266 CPDF_InterForm::~CPDF_InterForm() |
| 267 { | 267 { |
| 268 FX_POSITION pos = m_ControlMap.GetStartPosition(); | 268 FX_POSITION pos = m_ControlMap.GetStartPosition(); |
| 269 while (pos) { | 269 while (pos) { |
| 270 FX_LPVOID key, value; | 270 void* key; |
| 271 void* value; |
| 271 m_ControlMap.GetNextAssoc(pos, key, value); | 272 m_ControlMap.GetNextAssoc(pos, key, value); |
| 272 delete (CPDF_FormControl*)value; | 273 delete (CPDF_FormControl*)value; |
| 273 } | 274 } |
| 274 if (m_pFieldTree != NULL) { | 275 if (m_pFieldTree != NULL) { |
| 275 int nCount = m_pFieldTree->m_Root.CountFields(); | 276 int nCount = m_pFieldTree->m_Root.CountFields(); |
| 276 for (int i = 0; i < nCount; i++) { | 277 for (int i = 0; i < nCount; i++) { |
| 277 CPDF_FormField *pField = m_pFieldTree->m_Root.GetField(i); | 278 CPDF_FormField *pField = m_pFieldTree->m_Root.GetField(i); |
| 278 delete pField; | 279 delete pField; |
| 279 } | 280 } |
| 280 delete m_pFieldTree; | 281 delete m_pFieldTree; |
| 281 } | 282 } |
| 282 } | 283 } |
| 283 FX_BOOL CPDF_InterForm::m_bUpdateAP = TRUE; | 284 FX_BOOL CPDF_InterForm::m_bUpdateAP = TRUE; |
| 284 FX_BOOL CPDF_InterForm::UpdatingAPEnabled() | 285 FX_BOOL CPDF_InterForm::UpdatingAPEnabled() |
| 285 { | 286 { |
| 286 return m_bUpdateAP; | 287 return m_bUpdateAP; |
| 287 } | 288 } |
| 288 void CPDF_InterForm::EnableUpdateAP(FX_BOOL bUpdateAP) | 289 void CPDF_InterForm::EnableUpdateAP(FX_BOOL bUpdateAP) |
| 289 { | 290 { |
| 290 m_bUpdateAP = bUpdateAP; | 291 m_bUpdateAP = bUpdateAP; |
| 291 } | 292 } |
| 292 CFX_ByteString CPDF_InterForm::GenerateNewResourceName(const CPDF_Dictionary* pR
esDict, FX_LPCSTR csType, int iMinLen, FX_LPCSTR csPrefix) | 293 CFX_ByteString CPDF_InterForm::GenerateNewResourceName(const CPDF_Dictionary* pR
esDict, const FX_CHAR* csType, int iMinLen, const FX_CHAR* csPrefix) |
| 293 { | 294 { |
| 294 CFX_ByteString csStr = csPrefix; | 295 CFX_ByteString csStr = csPrefix; |
| 295 CFX_ByteString csBType = csType; | 296 CFX_ByteString csBType = csType; |
| 296 if (csStr.IsEmpty()) { | 297 if (csStr.IsEmpty()) { |
| 297 if (csBType == "ExtGState") { | 298 if (csBType == "ExtGState") { |
| 298 csStr = "GS"; | 299 csStr = "GS"; |
| 299 } else if (csBType == "ColorSpace") { | 300 } else if (csBType == "ColorSpace") { |
| 300 csStr = "CS"; | 301 csStr = "CS"; |
| 301 } else if (csBType == "Font") { | 302 } else if (csBType == "Font") { |
| 302 csStr = "ZiTi"; | 303 csStr = "ZiTi"; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 467 } |
| 467 CPDF_Font* pFont = NULL; | 468 CPDF_Font* pFont = NULL; |
| 468 if (csFontName == "ZapfDingbats") { | 469 if (csFontName == "ZapfDingbats") { |
| 469 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, NULL); | 470 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, NULL); |
| 470 } else { | 471 } else { |
| 471 CPDF_FontEncoding encoding(PDFFONT_ENCODING_WINANSI); | 472 CPDF_FontEncoding encoding(PDFFONT_ENCODING_WINANSI); |
| 472 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, &encodi
ng); | 473 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, &encodi
ng); |
| 473 } | 474 } |
| 474 return pFont; | 475 return pFont; |
| 475 } | 476 } |
| 476 CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, FX_LPVOID pLogFont
) | 477 CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) |
| 477 { | 478 { |
| 478 CFX_ByteString csFontName; | 479 CFX_ByteString csFontName; |
| 479 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 480 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 480 LOGFONTA lf; | 481 LOGFONTA lf; |
| 481 FX_BOOL bRet; | 482 FX_BOOL bRet; |
| 482 if (charSet == ANSI_CHARSET) { | 483 if (charSet == ANSI_CHARSET) { |
| 483 csFontName = "Helvetica"; | 484 csFontName = "Helvetica"; |
| 484 return csFontName; | 485 return csFontName; |
| 485 } | 486 } |
| 486 bRet = FALSE; | 487 bRet = FALSE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 503 if (bRet) { | 504 if (bRet) { |
| 504 if (pLogFont != NULL) { | 505 if (pLogFont != NULL) { |
| 505 memcpy(pLogFont, &lf, sizeof(LOGFONTA)); | 506 memcpy(pLogFont, &lf, sizeof(LOGFONTA)); |
| 506 } | 507 } |
| 507 csFontName = lf.lfFaceName; | 508 csFontName = lf.lfFaceName; |
| 508 return csFontName; | 509 return csFontName; |
| 509 } | 510 } |
| 510 #endif | 511 #endif |
| 511 return csFontName; | 512 return csFontName; |
| 512 } | 513 } |
| 513 CFX_ByteString CPDF_InterForm::GetNativeFont(FX_LPVOID pLogFont) | 514 CFX_ByteString CPDF_InterForm::GetNativeFont(void* pLogFont) |
| 514 { | 515 { |
| 515 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 516 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 516 uint8_t charSet = GetNativeCharSet(); | 517 uint8_t charSet = GetNativeCharSet(); |
| 517 return GetNativeFont(charSet, pLogFont); | 518 return GetNativeFont(charSet, pLogFont); |
| 518 #else | 519 #else |
| 519 return CFX_ByteString(); | 520 return CFX_ByteString(); |
| 520 #endif | 521 #endif |
| 521 } | 522 } |
| 522 uint8_t CPDF_InterForm::GetNativeCharSet() | 523 uint8_t CPDF_InterForm::GetNativeCharSet() |
| 523 { | 524 { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, CFX_
WideString& csNewFieldName) | 689 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, CFX_
WideString& csNewFieldName) |
| 689 { | 690 { |
| 690 if (pControl == NULL || csNewFieldName.IsEmpty()) { | 691 if (pControl == NULL || csNewFieldName.IsEmpty()) { |
| 691 return FALSE; | 692 return FALSE; |
| 692 } | 693 } |
| 693 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField(); | 694 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField(); |
| 694 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, pCo
ntrol); | 695 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, pCo
ntrol); |
| 695 } | 696 } |
| 696 int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte
String& name2) | 697 int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte
String& name2) |
| 697 { | 698 { |
| 698 FX_LPCSTR ptr1 = name1, ptr2 = name2; | 699 const FX_CHAR* ptr1 = name1; |
| 700 const FX_CHAR* ptr2 = name2; |
| 699 if (name1.GetLength() != name2.GetLength()) { | 701 if (name1.GetLength() != name2.GetLength()) { |
| 700 int i = 0; | 702 int i = 0; |
| 701 while (ptr1[i] == ptr2[i]) { | 703 while (ptr1[i] == ptr2[i]) { |
| 702 i ++; | 704 i ++; |
| 703 } | 705 } |
| 704 if (i == name1.GetLength()) { | 706 if (i == name1.GetLength()) { |
| 705 return 2; | 707 return 2; |
| 706 } | 708 } |
| 707 if (i == name2.GetLength()) { | 709 if (i == name2.GetLength()) { |
| 708 return 3; | 710 return 3; |
| 709 } | 711 } |
| 710 return 0; | 712 return 0; |
| 711 } else { | 713 } else { |
| 712 return name1 == name2 ? 1 : 0; | 714 return name1 == name2 ? 1 : 0; |
| 713 } | 715 } |
| 714 } | 716 } |
| 715 int CPDF_InterForm::CompareFieldName(const CFX_WideString& name1, const CFX_Wide
String& name2) | 717 int CPDF_InterForm::CompareFieldName(const CFX_WideString& name1, const CFX_Wide
String& name2) |
| 716 { | 718 { |
| 717 FX_LPCWSTR ptr1 = name1.c_str(); | 719 const FX_WCHAR* ptr1 = name1.c_str(); |
| 718 FX_LPCWSTR ptr2 = name2.c_str(); | 720 const FX_WCHAR* ptr2 = name2.c_str(); |
| 719 if (name1.GetLength() != name2.GetLength()) { | 721 if (name1.GetLength() != name2.GetLength()) { |
| 720 int i = 0; | 722 int i = 0; |
| 721 while (ptr1[i] == ptr2[i]) { | 723 while (ptr1[i] == ptr2[i]) { |
| 722 i ++; | 724 i ++; |
| 723 } | 725 } |
| 724 if (i == name1.GetLength()) { | 726 if (i == name1.GetLength()) { |
| 725 return 2; | 727 return 2; |
| 726 } | 728 } |
| 727 if (i == name2.GetLength()) { | 729 if (i == name2.GetLength()) { |
| 728 return 3; | 730 return 3; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 } | 814 } |
| 813 FX_BOOL CPDF_InterForm::IsValidFormControl(const void* pControl) | 815 FX_BOOL CPDF_InterForm::IsValidFormControl(const void* pControl) |
| 814 { | 816 { |
| 815 if (pControl == NULL) { | 817 if (pControl == NULL) { |
| 816 return FALSE; | 818 return FALSE; |
| 817 } | 819 } |
| 818 FX_POSITION pos = m_ControlMap.GetStartPosition(); | 820 FX_POSITION pos = m_ControlMap.GetStartPosition(); |
| 819 while (pos) { | 821 while (pos) { |
| 820 CPDF_Dictionary* pWidgetDict = NULL; | 822 CPDF_Dictionary* pWidgetDict = NULL; |
| 821 void* pFormControl = NULL; | 823 void* pFormControl = NULL; |
| 822 m_ControlMap.GetNextAssoc(pos, (FX_LPVOID&)pWidgetDict, pFormControl); | 824 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, pFormControl); |
| 823 if (pControl == pFormControl) { | 825 if (pControl == pFormControl) { |
| 824 return TRUE; | 826 return TRUE; |
| 825 } | 827 } |
| 826 } | 828 } |
| 827 return FALSE; | 829 return FALSE; |
| 828 } | 830 } |
| 829 int CPDF_InterForm::CountPageControls(CPDF_Page* pPage) const | 831 int CPDF_InterForm::CountPageControls(CPDF_Page* pPage) const |
| 830 { | 832 { |
| 831 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); | 833 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); |
| 832 if (pAnnotList == NULL) { | 834 if (pAnnotList == NULL) { |
| 833 return 0; | 835 return 0; |
| 834 } | 836 } |
| 835 int count = 0; | 837 int count = 0; |
| 836 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); i ++) { | 838 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); i ++) { |
| 837 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i); | 839 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i); |
| 838 if (pAnnot == NULL) { | 840 if (pAnnot == NULL) { |
| 839 continue; | 841 continue; |
| 840 } | 842 } |
| 841 CPDF_FormControl* pControl; | 843 CPDF_FormControl* pControl; |
| 842 if (!m_ControlMap.Lookup(pAnnot, (FX_LPVOID&)pControl)) { | 844 if (!m_ControlMap.Lookup(pAnnot, (void*&)pControl)) { |
| 843 continue; | 845 continue; |
| 844 } | 846 } |
| 845 count ++; | 847 count ++; |
| 846 } | 848 } |
| 847 return count; | 849 return count; |
| 848 } | 850 } |
| 849 CPDF_FormControl* CPDF_InterForm::GetPageControl(CPDF_Page* pPage, int index) co
nst | 851 CPDF_FormControl* CPDF_InterForm::GetPageControl(CPDF_Page* pPage, int index) co
nst |
| 850 { | 852 { |
| 851 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); | 853 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); |
| 852 if (pAnnotList == NULL) { | 854 if (pAnnotList == NULL) { |
| 853 return NULL; | 855 return NULL; |
| 854 } | 856 } |
| 855 int count = 0; | 857 int count = 0; |
| 856 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); i ++) { | 858 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); i ++) { |
| 857 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i); | 859 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i); |
| 858 if (pAnnot == NULL) { | 860 if (pAnnot == NULL) { |
| 859 continue; | 861 continue; |
| 860 } | 862 } |
| 861 CPDF_FormControl* pControl; | 863 CPDF_FormControl* pControl; |
| 862 if (!m_ControlMap.Lookup(pAnnot, (FX_LPVOID&)pControl)) { | 864 if (!m_ControlMap.Lookup(pAnnot, (void*&)pControl)) { |
| 863 continue; | 865 continue; |
| 864 } | 866 } |
| 865 if (index == count) { | 867 if (index == count) { |
| 866 return pControl; | 868 return pControl; |
| 867 } | 869 } |
| 868 count ++; | 870 count ++; |
| 869 } | 871 } |
| 870 return NULL; | 872 return NULL; |
| 871 } | 873 } |
| 872 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, FX_FLOAT p
df_x, FX_FLOAT pdf_y) const | 874 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, FX_FLOAT p
df_x, FX_FLOAT pdf_y) const |
| 873 { | 875 { |
| 874 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); | 876 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); |
| 875 if (pAnnotList == NULL) { | 877 if (pAnnotList == NULL) { |
| 876 return NULL; | 878 return NULL; |
| 877 } | 879 } |
| 878 for (FX_DWORD i = pAnnotList->GetCount(); i > 0; i --) { | 880 for (FX_DWORD i = pAnnotList->GetCount(); i > 0; i --) { |
| 879 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i - 1); | 881 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i - 1); |
| 880 if (pAnnot == NULL) { | 882 if (pAnnot == NULL) { |
| 881 continue; | 883 continue; |
| 882 } | 884 } |
| 883 CPDF_FormControl* pControl; | 885 CPDF_FormControl* pControl; |
| 884 if (!m_ControlMap.Lookup(pAnnot, (FX_LPVOID&)pControl)) { | 886 if (!m_ControlMap.Lookup(pAnnot, (void*&)pControl)) { |
| 885 continue; | 887 continue; |
| 886 } | 888 } |
| 887 CFX_FloatRect rect = pControl->GetRect(); | 889 CFX_FloatRect rect = pControl->GetRect(); |
| 888 if (rect.Contains(pdf_x, pdf_y)) { | 890 if (rect.Contains(pdf_x, pdf_y)) { |
| 889 return pControl; | 891 return pControl; |
| 890 } | 892 } |
| 891 } | 893 } |
| 892 return NULL; | 894 return NULL; |
| 893 } | 895 } |
| 894 CPDF_FormControl* CPDF_InterForm::GetControlByDict(CPDF_Dictionary* pWidgetDict)
const | 896 CPDF_FormControl* CPDF_InterForm::GetControlByDict(CPDF_Dictionary* pWidgetDict)
const |
| 895 { | 897 { |
| 896 CPDF_FormControl* pControl = NULL; | 898 CPDF_FormControl* pControl = NULL; |
| 897 m_ControlMap.Lookup(pWidgetDict, (FX_LPVOID&)pControl); | 899 m_ControlMap.Lookup(pWidgetDict, (void*&)pControl); |
| 898 return pControl; | 900 return pControl; |
| 899 } | 901 } |
| 900 FX_DWORD CPDF_InterForm::CountInternalFields(const CFX_WideString& csFieldName)
const | 902 FX_DWORD CPDF_InterForm::CountInternalFields(const CFX_WideString& csFieldName)
const |
| 901 { | 903 { |
| 902 if (m_pFormDict == NULL) { | 904 if (m_pFormDict == NULL) { |
| 903 return 0; | 905 return 0; |
| 904 } | 906 } |
| 905 CPDF_Array* pArray = m_pFormDict->GetArray("Fields"); | 907 CPDF_Array* pArray = m_pFormDict->GetArray("Fields"); |
| 906 if (pArray == NULL) { | 908 if (pArray == NULL) { |
| 907 return 0; | 909 return 0; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 m_pFormNotify->AfterFormReset(this); | 1197 m_pFormNotify->AfterFormReset(this); |
| 1196 } | 1198 } |
| 1197 return TRUE; | 1199 return TRUE; |
| 1198 } | 1200 } |
| 1199 void CPDF_InterForm::ReloadForm() | 1201 void CPDF_InterForm::ReloadForm() |
| 1200 { | 1202 { |
| 1201 FX_POSITION pos = m_ControlMap.GetStartPosition(); | 1203 FX_POSITION pos = m_ControlMap.GetStartPosition(); |
| 1202 while (pos) { | 1204 while (pos) { |
| 1203 CPDF_Dictionary* pWidgetDict; | 1205 CPDF_Dictionary* pWidgetDict; |
| 1204 CPDF_FormControl* pControl; | 1206 CPDF_FormControl* pControl; |
| 1205 m_ControlMap.GetNextAssoc(pos, (FX_LPVOID&)pWidgetDict, (FX_LPVOID&)pCon
trol); | 1207 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, (void*&)pControl); |
| 1206 delete pControl; | 1208 delete pControl; |
| 1207 } | 1209 } |
| 1208 m_ControlMap.RemoveAll(); | 1210 m_ControlMap.RemoveAll(); |
| 1209 int nCount = m_pFieldTree->m_Root.CountFields(); | 1211 int nCount = m_pFieldTree->m_Root.CountFields(); |
| 1210 for (int k = 0; k < nCount; k ++) { | 1212 for (int k = 0; k < nCount; k ++) { |
| 1211 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(k); | 1213 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(k); |
| 1212 delete pField; | 1214 delete pField; |
| 1213 } | 1215 } |
| 1214 m_pFieldTree->RemoveAll(); | 1216 m_pFieldTree->RemoveAll(); |
| 1215 if (m_pFormDict == NULL) { | 1217 if (m_pFormDict == NULL) { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 if (pV != NULL) { | 1460 if (pV != NULL) { |
| 1459 pFieldDict->SetAt("V", pV->Clone(TRUE)); | 1461 pFieldDict->SetAt("V", pV->Clone(TRUE)); |
| 1460 } | 1462 } |
| 1461 } | 1463 } |
| 1462 pFields->Add(pFieldDict); | 1464 pFields->Add(pFieldDict); |
| 1463 } | 1465 } |
| 1464 } | 1466 } |
| 1465 return pDoc; | 1467 return pDoc; |
| 1466 } | 1468 } |
| 1467 const struct _SupportFieldEncoding { | 1469 const struct _SupportFieldEncoding { |
| 1468 FX_LPCSTR m_name; | 1470 const FX_CHAR* m_name; |
| 1469 int32_t m_codePage; | 1471 int32_t m_codePage; |
| 1470 } g_fieldEncoding[] = { | 1472 } g_fieldEncoding[] = { |
| 1471 { "BigFive", 950 }, | 1473 { "BigFive", 950 }, |
| 1472 { "GBK", 936 }, | 1474 { "GBK", 936 }, |
| 1473 { "Shift-JIS", 932 }, | 1475 { "Shift-JIS", 932 }, |
| 1474 { "UHC", 949 }, | 1476 { "UHC", 949 }, |
| 1475 }; | 1477 }; |
| 1476 static void FPDFDOC_FDF_GetFieldValue(CPDF_Dictionary *pFieldDict, CFX_WideStrin
g &csValue, CFX_ByteString &bsEncoding) | 1478 static void FPDFDOC_FDF_GetFieldValue(CPDF_Dictionary *pFieldDict, CFX_WideStrin
g &csValue, CFX_ByteString &bsEncoding) |
| 1477 { | 1479 { |
| 1478 ASSERT(pFieldDict != NULL); | 1480 ASSERT(pFieldDict != NULL); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 continue; | 1633 continue; |
| 1632 } | 1634 } |
| 1633 CPDF_FormControl* pControl = NULL; | 1635 CPDF_FormControl* pControl = NULL; |
| 1634 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) { | 1636 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) { |
| 1635 return iNewPage; | 1637 return iNewPage; |
| 1636 } | 1638 } |
| 1637 } | 1639 } |
| 1638 } while (TRUE); | 1640 } while (TRUE); |
| 1639 return -1; | 1641 return -1; |
| 1640 } | 1642 } |
| OLD | NEW |