Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: core/src/fpdfdoc/doc_form.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfdoc/doc_basic.cpp ('k') | core/src/fpdfdoc/doc_formcontrol.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "doc_utils.h" 8 #include "doc_utils.h"
9 9
10 const int nMaxRecursion = 32; 10 const int nMaxRecursion = 32;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 name_extractor.GetNext(pName, nLength); 234 name_extractor.GetNext(pName, nLength);
235 _Node *pNode = &m_Root, *pLast = NULL; 235 _Node *pNode = &m_Root, *pLast = NULL;
236 while (nLength > 0 && pNode) { 236 while (nLength > 0 && pNode) {
237 pLast = pNode; 237 pLast = pNode;
238 CFX_WideString name = CFX_WideString(pName, nLength); 238 CFX_WideString name = CFX_WideString(pName, nLength);
239 pNode = _Lookup(pLast, name); 239 pNode = _Lookup(pLast, name);
240 name_extractor.GetNext(pName, nLength); 240 name_extractor.GetNext(pName, nLength);
241 } 241 }
242 return pNode; 242 return pNode;
243 } 243 }
244 CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bGenerateAP) : CFX_PrivateData() 244 CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument, bool bGenerateAP) : CFX _PrivateData()
245 { 245 {
246 m_pDocument = pDocument; 246 m_pDocument = pDocument;
247 m_bGenerateAP = bGenerateAP; 247 m_bGenerateAP = bGenerateAP;
248 m_pFormNotify = NULL; 248 m_pFormNotify = NULL;
249 m_bUpdated = FALSE; 249 m_bUpdated = false;
250 m_pFieldTree = new CFieldTree; 250 m_pFieldTree = new CFieldTree;
251 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); 251 CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
252 m_pFormDict = pRoot->GetDict("AcroForm"); 252 m_pFormDict = pRoot->GetDict("AcroForm");
253 if (m_pFormDict == NULL) { 253 if (m_pFormDict == NULL) {
254 return; 254 return;
255 } 255 }
256 CPDF_Array* pFields = m_pFormDict->GetArray("Fields"); 256 CPDF_Array* pFields = m_pFormDict->GetArray("Fields");
257 if (pFields == NULL) { 257 if (pFields == NULL) {
258 return; 258 return;
259 } 259 }
(...skipping 13 matching lines...) Expand all
273 } 273 }
274 if (m_pFieldTree != NULL) { 274 if (m_pFieldTree != NULL) {
275 int nCount = m_pFieldTree->m_Root.CountFields(); 275 int nCount = m_pFieldTree->m_Root.CountFields();
276 for (int i = 0; i < nCount; i++) { 276 for (int i = 0; i < nCount; i++) {
277 CPDF_FormField *pField = m_pFieldTree->m_Root.GetField(i); 277 CPDF_FormField *pField = m_pFieldTree->m_Root.GetField(i);
278 delete pField; 278 delete pField;
279 } 279 }
280 delete m_pFieldTree; 280 delete m_pFieldTree;
281 } 281 }
282 } 282 }
283 FX_BOOL»CPDF_InterForm::m_bUpdateAP = TRUE; 283 bool» CPDF_InterForm::m_bUpdateAP = true;
284 FX_BOOL CPDF_InterForm::UpdatingAPEnabled() 284 bool CPDF_InterForm::UpdatingAPEnabled()
285 { 285 {
286 return m_bUpdateAP; 286 return m_bUpdateAP;
287 } 287 }
288 void CPDF_InterForm::EnableUpdateAP(FX_BOOL bUpdateAP) 288 void CPDF_InterForm::EnableUpdateAP(bool bUpdateAP)
289 { 289 {
290 m_bUpdateAP = bUpdateAP; 290 m_bUpdateAP = bUpdateAP;
291 } 291 }
292 CFX_ByteString CPDF_InterForm::GenerateNewResourceName(const CPDF_Dictionary* pR esDict, const FX_CHAR* csType, int iMinLen, const FX_CHAR* csPrefix) 292 CFX_ByteString CPDF_InterForm::GenerateNewResourceName(const CPDF_Dictionary* pR esDict, const FX_CHAR* csType, int iMinLen, const FX_CHAR* csPrefix)
293 { 293 {
294 CFX_ByteString csStr = csPrefix; 294 CFX_ByteString csStr = csPrefix;
295 CFX_ByteString csBType = csType; 295 CFX_ByteString csBType = csType;
296 if (csStr.IsEmpty()) { 296 if (csStr.IsEmpty()) {
297 if (csBType == "ExtGState") { 297 if (csBType == "ExtGState") {
298 csStr = "GS"; 298 csStr = "GS";
(...skipping 22 matching lines...) Expand all
321 } 321 }
322 if (pResDict == NULL) { 322 if (pResDict == NULL) {
323 return csTmp; 323 return csTmp;
324 } 324 }
325 CPDF_Dictionary* pDict = pResDict->GetDict(csType); 325 CPDF_Dictionary* pDict = pResDict->GetDict(csType);
326 if (pDict == NULL) { 326 if (pDict == NULL) {
327 return csTmp; 327 return csTmp;
328 } 328 }
329 int num = 0; 329 int num = 0;
330 CFX_ByteString bsNum; 330 CFX_ByteString bsNum;
331 while (TRUE) { 331 while (true) {
332 if (!pDict->KeyExist(csTmp + bsNum)) { 332 if (!pDict->KeyExist(csTmp + bsNum)) {
333 return csTmp + bsNum; 333 return csTmp + bsNum;
334 } 334 }
335 if (m < iCount) { 335 if (m < iCount) {
336 csTmp += csStr[m ++]; 336 csTmp += csStr[m ++];
337 } else { 337 } else {
338 bsNum.Format("%d", num++); 338 bsNum.Format("%d", num++);
339 } 339 }
340 m ++; 340 m ++;
341 } 341 }
342 return csTmp; 342 return csTmp;
343 } 343 }
344 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 344 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
345 typedef struct _PDF_FONTDATA { 345 typedef struct _PDF_FONTDATA {
346 FX_BOOL» » bFind; 346 bool» » bFind;
347 LOGFONTA lf; 347 LOGFONTA lf;
348 } PDF_FONTDATA, FAR* LPDF_FONTDATA; 348 } PDF_FONTDATA, FAR* LPDF_FONTDATA;
349 static int CALLBACK EnumFontFamExProc( ENUMLOGFONTEXA *lpelfe, 349 static int CALLBACK EnumFontFamExProc( ENUMLOGFONTEXA *lpelfe,
350 NEWTEXTMETRICEX *lpntme, 350 NEWTEXTMETRICEX *lpntme,
351 DWORD FontType, 351 DWORD FontType,
352 LPARAM lParam 352 LPARAM lParam
353 ) 353 )
354 { 354 {
355 if (FontType != 0x004 || strchr(lpelfe->elfLogFont.lfFaceName, '@') != NULL) { 355 if (FontType != 0x004 || strchr(lpelfe->elfLogFont.lfFaceName, '@') != NULL) {
356 return 1; 356 return 1;
357 } else { 357 } else {
358 LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; 358 LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam;
359 memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA)); 359 memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA));
360 pData->bFind = TRUE; 360 pData->bFind = true;
361 return 0; 361 return 0;
362 } 362 }
363 } 363 }
364 static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) 364 static bool RetrieveSpecificFont(LOGFONTA& lf)
365 { 365 {
366 PDF_FONTDATA fd; 366 PDF_FONTDATA fd;
367 memset(&fd, 0, sizeof(PDF_FONTDATA)); 367 memset(&fd, 0, sizeof(PDF_FONTDATA));
368 HDC hDC = ::GetDC(NULL); 368 HDC hDC = ::GetDC(NULL);
369 EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)EnumFontFamExProc, (LPARAM)&fd, 0); 369 EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)EnumFontFamExProc, (LPARAM)&fd, 0);
370 ::ReleaseDC(NULL, hDC); 370 ::ReleaseDC(NULL, hDC);
371 if (fd.bFind) { 371 if (fd.bFind) {
372 memcpy(&lf, &fd.lf, sizeof(LOGFONTA)); 372 memcpy(&lf, &fd.lf, sizeof(LOGFONTA));
373 } 373 }
374 return fd.bFind; 374 return fd.bFind;
375 } 375 }
376 static FX_BOOL RetrieveSpecificFont(uint8_t charSet, uint8_t pitchAndFamily, LPC STR pcsFontName, LOGFONTA& lf) 376 static bool RetrieveSpecificFont(uint8_t charSet, uint8_t pitchAndFamily, LPCSTR pcsFontName, LOGFONTA& lf)
377 { 377 {
378 memset(&lf, 0, sizeof(LOGFONTA)); 378 memset(&lf, 0, sizeof(LOGFONTA));
379 lf.lfCharSet = charSet; 379 lf.lfCharSet = charSet;
380 lf.lfPitchAndFamily = pitchAndFamily; 380 lf.lfPitchAndFamily = pitchAndFamily;
381 if (pcsFontName != NULL) { 381 if (pcsFontName != NULL) {
382 strcpy(lf.lfFaceName, pcsFontName); 382 strcpy(lf.lfFaceName, pcsFontName);
383 } 383 }
384 return RetrieveSpecificFont(lf); 384 return RetrieveSpecificFont(lf);
385 } 385 }
386 static FX_BOOL RetrieveStockFont(int iFontObject, uint8_t charSet, LOGFONTA& lf) 386 static bool RetrieveStockFont(int iFontObject, uint8_t charSet, LOGFONTA& lf)
387 { 387 {
388 HFONT hFont = (HFONT)::GetStockObject(iFontObject); 388 HFONT hFont = (HFONT)::GetStockObject(iFontObject);
389 if (hFont != NULL) { 389 if (hFont != NULL) {
390 memset(&lf, 0, sizeof(LOGFONTA)); 390 memset(&lf, 0, sizeof(LOGFONTA));
391 int iRet = ::GetObject(hFont, sizeof(LOGFONTA), &lf); 391 int iRet = ::GetObject(hFont, sizeof(LOGFONTA), &lf);
392 if (iRet > 0 && (lf.lfCharSet == charSet || charSet == 255)) { 392 if (iRet > 0 && (lf.lfCharSet == charSet || charSet == 255)) {
393 return RetrieveSpecificFont(lf); 393 return RetrieveSpecificFont(lf);
394 } 394 }
395 } 395 }
396 return FALSE; 396 return false;
397 } 397 }
398 #endif 398 #endif
399 CPDF_Font* CPDF_InterForm::AddSystemDefaultFont(const CPDF_Document* pDocument) 399 CPDF_Font* CPDF_InterForm::AddSystemDefaultFont(const CPDF_Document* pDocument)
400 { 400 {
401 if (pDocument == NULL) { 401 if (pDocument == NULL) {
402 return NULL; 402 return NULL;
403 } 403 }
404 CPDF_Font* pFont = NULL; 404 CPDF_Font* pFont = NULL;
405 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 405 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
406 LOGFONTA lf; 406 LOGFONTA lf;
407 FX_BOOL bRet; 407 bool bRet;
408 bRet = RetrieveStockFont(DEFAULT_GUI_FONT, 255, lf); 408 bRet = RetrieveStockFont(DEFAULT_GUI_FONT, 255, lf);
409 if (!bRet) { 409 if (!bRet) {
410 bRet = RetrieveStockFont(SYSTEM_FONT, 255, lf); 410 bRet = RetrieveStockFont(SYSTEM_FONT, 255, lf);
411 } 411 }
412 if (bRet) { 412 if (bRet) {
413 pFont = ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, FALSE, TRUE); 413 pFont = ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, false, true);
414 } 414 }
415 #endif 415 #endif
416 return pFont; 416 return pFont;
417 } 417 }
418 CPDF_Font* CPDF_InterForm::AddSystemFont(const CPDF_Document* pDocument, CFX_Byt eString csFontName, uint8_t iCharSet) 418 CPDF_Font* CPDF_InterForm::AddSystemFont(const CPDF_Document* pDocument, CFX_Byt eString csFontName, uint8_t iCharSet)
419 { 419 {
420 if (pDocument == NULL || csFontName.IsEmpty()) { 420 if (pDocument == NULL || csFontName.IsEmpty()) {
421 return NULL; 421 return NULL;
422 } 422 }
423 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 423 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
424 if (iCharSet == 1) { 424 if (iCharSet == 1) {
425 iCharSet = GetNativeCharSet(); 425 iCharSet = GetNativeCharSet();
426 } 426 }
427 HFONT hFont = ::CreateFontA(0, 0, 0, 0, 0, 0, 0, 0, iCharSet, OUT_DEFAULT_PR ECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, csFontN ame.c_str()); 427 HFONT hFont = ::CreateFontA(0, 0, 0, 0, 0, 0, 0, 0, iCharSet, OUT_DEFAULT_PR ECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, csFontN ame.c_str());
428 if (hFont != NULL) { 428 if (hFont != NULL) {
429 LOGFONTA lf; 429 LOGFONTA lf;
430 memset(&lf, 0, sizeof(LOGFONTA)); 430 memset(&lf, 0, sizeof(LOGFONTA));
431 ::GetObjectA(hFont, sizeof(LOGFONTA), &lf); 431 ::GetObjectA(hFont, sizeof(LOGFONTA), &lf);
432 ::DeleteObject(hFont); 432 ::DeleteObject(hFont);
433 if (strlen(lf.lfFaceName) > 0) { 433 if (strlen(lf.lfFaceName) > 0) {
434 return ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, FALSE, TRUE) ; 434 return ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, false, true) ;
435 } 435 }
436 } 436 }
437 #endif 437 #endif
438 return NULL; 438 return NULL;
439 } 439 }
440 CPDF_Font* CPDF_InterForm::AddSystemFont(const CPDF_Document* pDocument, CFX_Wid eString csFontName, uint8_t iCharSet) 440 CPDF_Font* CPDF_InterForm::AddSystemFont(const CPDF_Document* pDocument, CFX_Wid eString csFontName, uint8_t iCharSet)
441 { 441 {
442 if (pDocument == NULL || csFontName.IsEmpty()) { 442 if (pDocument == NULL || csFontName.IsEmpty()) {
443 return NULL; 443 return NULL;
444 } 444 }
445 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 445 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
446 if (iCharSet == 1) { 446 if (iCharSet == 1) {
447 iCharSet = GetNativeCharSet(); 447 iCharSet = GetNativeCharSet();
448 } 448 }
449 HFONT hFont = ::CreateFontW(0, 0, 0, 0, 0, 0, 0, 0, iCharSet, OUT_DEFAULT_PR ECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, csFontN ame.c_str()); 449 HFONT hFont = ::CreateFontW(0, 0, 0, 0, 0, 0, 0, 0, iCharSet, OUT_DEFAULT_PR ECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, csFontN ame.c_str());
450 if (hFont != NULL) { 450 if (hFont != NULL) {
451 LOGFONTA lf; 451 LOGFONTA lf;
452 memset(&lf, 0, sizeof(LOGFONTA)); 452 memset(&lf, 0, sizeof(LOGFONTA));
453 ::GetObject(hFont, sizeof(LOGFONTA), &lf); 453 ::GetObject(hFont, sizeof(LOGFONTA), &lf);
454 ::DeleteObject(hFont); 454 ::DeleteObject(hFont);
455 if (strlen(lf.lfFaceName) > 0) { 455 if (strlen(lf.lfFaceName) > 0) {
456 return ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, FALSE, TRUE) ; 456 return ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, false, true) ;
457 } 457 }
458 } 458 }
459 #endif 459 #endif
460 return NULL; 460 return NULL;
461 } 461 }
462 CPDF_Font* CPDF_InterForm::AddStandardFont(const CPDF_Document* pDocument, CFX_B yteString csFontName) 462 CPDF_Font* CPDF_InterForm::AddStandardFont(const CPDF_Document* pDocument, CFX_B yteString csFontName)
463 { 463 {
464 if (pDocument == NULL || csFontName.IsEmpty()) { 464 if (pDocument == NULL || csFontName.IsEmpty()) {
465 return NULL; 465 return NULL;
466 } 466 }
467 CPDF_Font* pFont = NULL; 467 CPDF_Font* pFont = NULL;
468 if (csFontName == "ZapfDingbats") { 468 if (csFontName == "ZapfDingbats") {
469 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, NULL); 469 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, NULL);
470 } else { 470 } else {
471 CPDF_FontEncoding encoding(PDFFONT_ENCODING_WINANSI); 471 CPDF_FontEncoding encoding(PDFFONT_ENCODING_WINANSI);
472 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, &encodi ng); 472 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, &encodi ng);
473 } 473 }
474 return pFont; 474 return pFont;
475 } 475 }
476 CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) 476 CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont)
477 { 477 {
478 CFX_ByteString csFontName; 478 CFX_ByteString csFontName;
479 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 479 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
480 LOGFONTA lf; 480 LOGFONTA lf;
481 FX_BOOL bRet; 481 bool bRet;
482 if (charSet == ANSI_CHARSET) { 482 if (charSet == ANSI_CHARSET) {
483 csFontName = "Helvetica"; 483 csFontName = "Helvetica";
484 return csFontName; 484 return csFontName;
485 } 485 }
486 bRet = FALSE; 486 bRet = false;
487 if (charSet == SHIFTJIS_CHARSET) { 487 if (charSet == SHIFTJIS_CHARSET) {
488 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MS Mi ncho", lf); 488 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MS Mi ncho", lf);
489 } else if (charSet == GB2312_CHARSET) { 489 } else if (charSet == GB2312_CHARSET) {
490 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "SimSu n", lf); 490 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "SimSu n", lf);
491 } else if (charSet == CHINESEBIG5_CHARSET) { 491 } else if (charSet == CHINESEBIG5_CHARSET) {
492 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MingL iU", lf); 492 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MingL iU", lf);
493 } 493 }
494 if (!bRet) { 494 if (!bRet) {
495 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "Arial Unicode MS", lf); 495 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "Arial Unicode MS", lf);
496 } 496 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 return NULL; 585 return NULL;
586 } 586 }
587 CPDF_Font* pFont = NULL; 587 CPDF_Font* pFont = NULL;
588 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 588 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
589 LOGFONTA lf; 589 LOGFONTA lf;
590 CFX_ByteString csFontName = GetNativeFont(charSet, &lf); 590 CFX_ByteString csFontName = GetNativeFont(charSet, &lf);
591 if (!csFontName.IsEmpty()) { 591 if (!csFontName.IsEmpty()) {
592 if (csFontName == "Helvetica") { 592 if (csFontName == "Helvetica") {
593 pFont = AddStandardFont(pDocument, csFontName); 593 pFont = AddStandardFont(pDocument, csFontName);
594 } else { 594 } else {
595 pFont = ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, FALSE, TRUE ); 595 pFont = ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, false, true );
596 } 596 }
597 } 597 }
598 #endif 598 #endif
599 return pFont; 599 return pFont;
600 } 600 }
601 CPDF_Font* CPDF_InterForm::AddNativeFont(const CPDF_Document* pDocument) 601 CPDF_Font* CPDF_InterForm::AddNativeFont(const CPDF_Document* pDocument)
602 { 602 {
603 if (pDocument == NULL) { 603 if (pDocument == NULL) {
604 return NULL; 604 return NULL;
605 } 605 }
606 CPDF_Font* pFont = NULL; 606 CPDF_Font* pFont = NULL;
607 uint8_t charSet = GetNativeCharSet(); 607 uint8_t charSet = GetNativeCharSet();
608 pFont = AddNativeFont(charSet, pDocument); 608 pFont = AddNativeFont(charSet, pDocument);
609 return pFont; 609 return pFont;
610 } 610 }
611 FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, int iT ype, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedCont rol) 611 bool CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, int iType , const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl )
612 { 612 {
613 if (csNewFieldName.IsEmpty()) { 613 if (csNewFieldName.IsEmpty()) {
614 return FALSE; 614 return false;
615 } 615 }
616 int iPos = 0; 616 int iPos = 0;
617 int iLength = csNewFieldName.GetLength(); 617 int iLength = csNewFieldName.GetLength();
618 CFX_WideString csSub; 618 CFX_WideString csSub;
619 while (TRUE) { 619 while (true) {
620 while (iPos < iLength && (csNewFieldName[iPos] == L'.' || csNewFieldName [iPos] == L' ')) { 620 while (iPos < iLength && (csNewFieldName[iPos] == L'.' || csNewFieldName [iPos] == L' ')) {
621 iPos ++; 621 iPos ++;
622 } 622 }
623 if (iPos < iLength && !csSub.IsEmpty()) { 623 if (iPos < iLength && !csSub.IsEmpty()) {
624 csSub += L'.'; 624 csSub += L'.';
625 } 625 }
626 while (iPos < iLength && csNewFieldName[iPos] != L'.') { 626 while (iPos < iLength && csNewFieldName[iPos] != L'.') {
627 csSub += csNewFieldName[iPos ++]; 627 csSub += csNewFieldName[iPos ++];
628 } 628 }
629 for (int i = csSub.GetLength() - 1; i > -1; i --) { 629 for (int i = csSub.GetLength() - 1; i > -1; i --) {
(...skipping 15 matching lines...) Expand all
645 continue; 645 continue;
646 } 646 }
647 } else { 647 } else {
648 continue; 648 continue;
649 } 649 }
650 } 650 }
651 CFX_WideString csFullName = pField->GetFullName(); 651 CFX_WideString csFullName = pField->GetFullName();
652 int iRet = CompareFieldName(csSub, csFullName); 652 int iRet = CompareFieldName(csSub, csFullName);
653 if (iRet == 1) { 653 if (iRet == 1) {
654 if (pField->GetFieldType() != iType) { 654 if (pField->GetFieldType() != iType) {
655 return FALSE; 655 return false;
656 } 656 }
657 } else if (iRet == 2 && csSub == csNewFieldName) { 657 } else if (iRet == 2 && csSub == csNewFieldName) {
658 if (csFullName[iPos] == L'.') { 658 if (csFullName[iPos] == L'.') {
659 return FALSE; 659 return false;
660 } 660 }
661 } else if (iRet == 3 && csSub == csNewFieldName) { 661 } else if (iRet == 3 && csSub == csNewFieldName) {
662 if (csNewFieldName[csFullName.GetLength()] == L'.') { 662 if (csNewFieldName[csFullName.GetLength()] == L'.') {
663 return FALSE; 663 return false;
664 } 664 }
665 } 665 }
666 } 666 }
667 if (iPos >= iLength) { 667 if (iPos >= iLength) {
668 break; 668 break;
669 } 669 }
670 } 670 }
671 if (csSub.IsEmpty()) { 671 if (csSub.IsEmpty()) {
672 return FALSE; 672 return false;
673 } 673 }
674 csNewFieldName = csSub; 674 csNewFieldName = csSub;
675 return TRUE; 675 return true;
676 } 676 }
677 FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, int iT ype) 677 bool CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, int iType )
678 { 678 {
679 return ValidateFieldName(csNewFieldName, iType, NULL, NULL); 679 return ValidateFieldName(csNewFieldName, iType, NULL, NULL);
680 } 680 }
681 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField, CFX_Wide String& csNewFieldName) 681 bool CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField, CFX_WideStr ing& csNewFieldName)
682 { 682 {
683 if (pField == NULL || csNewFieldName.IsEmpty()) { 683 if (pField == NULL || csNewFieldName.IsEmpty()) {
684 return FALSE; 684 return false;
685 } 685 }
686 return ValidateFieldName(csNewFieldName, ((CPDF_FormField*)pField)->GetField Type(), pField, NULL); 686 return ValidateFieldName(csNewFieldName, ((CPDF_FormField*)pField)->GetField Type(), pField, NULL);
687 } 687 }
688 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, CFX_ WideString& csNewFieldName) 688 bool CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, CFX_Wid eString& csNewFieldName)
689 { 689 {
690 if (pControl == NULL || csNewFieldName.IsEmpty()) { 690 if (pControl == NULL || csNewFieldName.IsEmpty()) {
691 return FALSE; 691 return false;
692 } 692 }
693 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField(); 693 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField();
694 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, pCo ntrol); 694 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, pCo ntrol);
695 } 695 }
696 int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte String& name2) 696 int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte String& name2)
697 { 697 {
698 const FX_CHAR* ptr1 = name1; 698 const FX_CHAR* ptr1 = name1;
699 const FX_CHAR* ptr2 = name2; 699 const FX_CHAR* ptr2 = name2;
700 if (name1.GetLength() != name2.GetLength()) { 700 if (name1.GetLength() != name2.GetLength()) {
701 int i = 0; 701 int i = 0;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 allFieldNames.RemoveAll(); 760 allFieldNames.RemoveAll();
761 int nCount = m_pFieldTree->m_Root.CountFields(); 761 int nCount = m_pFieldTree->m_Root.CountFields();
762 for (int i = 0; i < nCount; i ++) { 762 for (int i = 0; i < nCount; i ++) {
763 CPDF_FormField *pField = m_pFieldTree->m_Root.GetField(i); 763 CPDF_FormField *pField = m_pFieldTree->m_Root.GetField(i);
764 if (pField) { 764 if (pField) {
765 CFX_WideString full_name = GetFullName(pField->GetFieldDict()); 765 CFX_WideString full_name = GetFullName(pField->GetFieldDict());
766 allFieldNames.Add(full_name); 766 allFieldNames.Add(full_name);
767 } 767 }
768 } 768 }
769 } 769 }
770 FX_BOOL CPDF_InterForm::IsValidFormField(const void* pField) 770 bool CPDF_InterForm::IsValidFormField(const void* pField)
771 { 771 {
772 if (pField == NULL) { 772 if (pField == NULL) {
773 return FALSE; 773 return false;
774 } 774 }
775 int nCount = m_pFieldTree->m_Root.CountFields(); 775 int nCount = m_pFieldTree->m_Root.CountFields();
776 for (int i = 0; i < nCount; i++) { 776 for (int i = 0; i < nCount; i++) {
777 CPDF_FormField *pFormField = m_pFieldTree->m_Root.GetField(i); 777 CPDF_FormField *pFormField = m_pFieldTree->m_Root.GetField(i);
778 if (pField == pFormField) { 778 if (pField == pFormField) {
779 return TRUE; 779 return true;
780 } 780 }
781 } 781 }
782 return FALSE; 782 return false;
783 } 783 }
784 CPDF_FormField* CPDF_InterForm::GetFieldByDict(CPDF_Dictionary* pFieldDict) cons t 784 CPDF_FormField* CPDF_InterForm::GetFieldByDict(CPDF_Dictionary* pFieldDict) cons t
785 { 785 {
786 if (pFieldDict == NULL) { 786 if (pFieldDict == NULL) {
787 return NULL; 787 return NULL;
788 } 788 }
789 CFX_WideString csWName = GetFullName(pFieldDict); 789 CFX_WideString csWName = GetFullName(pFieldDict);
790 return m_pFieldTree->GetField(csWName); 790 return m_pFieldTree->GetField(csWName);
791 } 791 }
792 FX_DWORD CPDF_InterForm::CountControls(CFX_WideString csFieldName) 792 FX_DWORD CPDF_InterForm::CountControls(CFX_WideString csFieldName)
(...skipping 11 matching lines...) Expand all
804 { 804 {
805 CPDF_FormField *pField = m_pFieldTree->GetField(csFieldName); 805 CPDF_FormField *pField = m_pFieldTree->GetField(csFieldName);
806 if (pField == NULL) { 806 if (pField == NULL) {
807 return NULL; 807 return NULL;
808 } 808 }
809 if (index < (FX_DWORD)pField->m_ControlList.GetSize()) { 809 if (index < (FX_DWORD)pField->m_ControlList.GetSize()) {
810 return (CPDF_FormControl *)pField->m_ControlList.GetAt(index); 810 return (CPDF_FormControl *)pField->m_ControlList.GetAt(index);
811 } 811 }
812 return NULL; 812 return NULL;
813 } 813 }
814 FX_BOOL CPDF_InterForm::IsValidFormControl(const void* pControl) 814 bool CPDF_InterForm::IsValidFormControl(const void* pControl)
815 { 815 {
816 if (pControl == NULL) { 816 if (pControl == NULL) {
817 return FALSE; 817 return false;
818 } 818 }
819 FX_POSITION pos = m_ControlMap.GetStartPosition(); 819 FX_POSITION pos = m_ControlMap.GetStartPosition();
820 while (pos) { 820 while (pos) {
821 CPDF_Dictionary* pWidgetDict = NULL; 821 CPDF_Dictionary* pWidgetDict = NULL;
822 void* pFormControl = NULL; 822 void* pFormControl = NULL;
823 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, pFormControl); 823 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, pFormControl);
824 if (pControl == pFormControl) { 824 if (pControl == pFormControl) {
825 return TRUE; 825 return true;
826 } 826 }
827 } 827 }
828 return FALSE; 828 return false;
829 } 829 }
830 int CPDF_InterForm::CountPageControls(CPDF_Page* pPage) const 830 int CPDF_InterForm::CountPageControls(CPDF_Page* pPage) const
831 { 831 {
832 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); 832 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots");
833 if (pAnnotList == NULL) { 833 if (pAnnotList == NULL) {
834 return 0; 834 return 0;
835 } 835 }
836 int count = 0; 836 int count = 0;
837 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); i ++) { 837 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); i ++) {
838 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i); 838 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 CPDF_Dictionary* pDict = NULL; 915 CPDF_Dictionary* pDict = NULL;
916 while (pArray != NULL) { 916 while (pArray != NULL) {
917 CFX_WideString csSub; 917 CFX_WideString csSub;
918 if (iPos < iLength && csFieldName[iPos] == L'.') { 918 if (iPos < iLength && csFieldName[iPos] == L'.') {
919 iPos ++; 919 iPos ++;
920 } 920 }
921 while (iPos < iLength && csFieldName[iPos] != L'.') { 921 while (iPos < iLength && csFieldName[iPos] != L'.') {
922 csSub += csFieldName[iPos ++]; 922 csSub += csFieldName[iPos ++];
923 } 923 }
924 int iCount = pArray->GetCount(); 924 int iCount = pArray->GetCount();
925 FX_BOOL bFind = FALSE; 925 bool bFind = false;
926 for (int i = 0; i < iCount; i ++) { 926 for (int i = 0; i < iCount; i ++) {
927 pDict = pArray->GetDict(i); 927 pDict = pArray->GetDict(i);
928 if (pDict == NULL) { 928 if (pDict == NULL) {
929 continue; 929 continue;
930 } 930 }
931 CFX_WideString csT = pDict->GetUnicodeText("T"); 931 CFX_WideString csT = pDict->GetUnicodeText("T");
932 if (csT == csSub) { 932 if (csT == csSub) {
933 bFind = TRUE; 933 bFind = true;
934 break; 934 break;
935 } 935 }
936 } 936 }
937 if (!bFind) { 937 if (!bFind) {
938 return 0; 938 return 0;
939 } 939 }
940 if (iPos >= iLength) { 940 if (iPos >= iLength) {
941 break; 941 break;
942 } 942 }
943 pArray = pDict->GetArray("Kids"); 943 pArray = pDict->GetArray("Kids");
(...skipping 27 matching lines...) Expand all
971 CPDF_Dictionary* pDict = NULL; 971 CPDF_Dictionary* pDict = NULL;
972 while (pArray != NULL) { 972 while (pArray != NULL) {
973 CFX_WideString csSub; 973 CFX_WideString csSub;
974 if (iPos < iLength && csFieldName[iPos] == L'.') { 974 if (iPos < iLength && csFieldName[iPos] == L'.') {
975 iPos ++; 975 iPos ++;
976 } 976 }
977 while (iPos < iLength && csFieldName[iPos] != L'.') { 977 while (iPos < iLength && csFieldName[iPos] != L'.') {
978 csSub += csFieldName[iPos ++]; 978 csSub += csFieldName[iPos ++];
979 } 979 }
980 int iCount = pArray->GetCount(); 980 int iCount = pArray->GetCount();
981 FX_BOOL bFind = FALSE; 981 bool bFind = false;
982 for (int i = 0; i < iCount; i ++) { 982 for (int i = 0; i < iCount; i ++) {
983 pDict = pArray->GetDict(i); 983 pDict = pArray->GetDict(i);
984 if (pDict == NULL) { 984 if (pDict == NULL) {
985 continue; 985 continue;
986 } 986 }
987 CFX_WideString csT = pDict->GetUnicodeText("T"); 987 CFX_WideString csT = pDict->GetUnicodeText("T");
988 if (csT == csSub) { 988 if (csT == csSub) {
989 bFind = TRUE; 989 bFind = true;
990 break; 990 break;
991 } 991 }
992 } 992 }
993 if (!bFind) { 993 if (!bFind) {
994 return NULL; 994 return NULL;
995 } 995 }
996 if (iPos >= iLength) { 996 if (iPos >= iLength) {
997 break; 997 break;
998 } 998 }
999 pArray = pDict->GetArray("Kids"); 999 pArray = pDict->GetArray("Kids");
1000 } 1000 }
1001 if (pDict == NULL) { 1001 if (pDict == NULL) {
1002 return NULL; 1002 return NULL;
1003 } else { 1003 } else {
1004 pArray = pDict->GetArray("Kids"); 1004 pArray = pDict->GetArray("Kids");
1005 if (pArray == NULL) { 1005 if (pArray == NULL) {
1006 return pDict; 1006 return pDict;
1007 } else { 1007 } else {
1008 return pArray->GetDict(index); 1008 return pArray->GetDict(index);
1009 } 1009 }
1010 } 1010 }
1011 } 1011 }
1012 } 1012 }
1013 FX_BOOL CPDF_InterForm::NeedConstructAP() 1013 bool CPDF_InterForm::NeedConstructAP()
1014 { 1014 {
1015 if (m_pFormDict == NULL) { 1015 if (m_pFormDict == NULL) {
1016 return FALSE; 1016 return false;
1017 } 1017 }
1018 return m_pFormDict->GetBoolean("NeedAppearances"); 1018 return m_pFormDict->GetBoolean("NeedAppearances");
1019 } 1019 }
1020 void CPDF_InterForm::NeedConstructAP(FX_BOOL bNeedAP) 1020 void CPDF_InterForm::NeedConstructAP(bool bNeedAP)
1021 { 1021 {
1022 if (m_pFormDict == NULL) { 1022 if (m_pFormDict == NULL) {
1023 InitInterFormDict(m_pFormDict, m_pDocument); 1023 InitInterFormDict(m_pFormDict, m_pDocument);
1024 } 1024 }
1025 m_pFormDict->SetAtBoolean("NeedAppearances", bNeedAP); 1025 m_pFormDict->SetAtBoolean("NeedAppearances", bNeedAP);
1026 m_bGenerateAP = bNeedAP; 1026 m_bGenerateAP = bNeedAP;
1027 } 1027 }
1028 int CPDF_InterForm::CountFieldsInCalculationOrder() 1028 int CPDF_InterForm::CountFieldsInCalculationOrder()
1029 { 1029 {
1030 if (m_pFormDict == NULL) { 1030 if (m_pFormDict == NULL) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 return GetInterFormFont(m_pFormDict, m_pDocument, csFontName, csNameTag); 1085 return GetInterFormFont(m_pFormDict, m_pDocument, csFontName, csNameTag);
1086 } 1086 }
1087 CPDF_Font* CPDF_InterForm::GetNativeFormFont(uint8_t charSet, CFX_ByteString& cs NameTag) 1087 CPDF_Font* CPDF_InterForm::GetNativeFormFont(uint8_t charSet, CFX_ByteString& cs NameTag)
1088 { 1088 {
1089 return GetNativeInterFormFont(m_pFormDict, m_pDocument, charSet, csNameTag); 1089 return GetNativeInterFormFont(m_pFormDict, m_pDocument, charSet, csNameTag);
1090 } 1090 }
1091 CPDF_Font* CPDF_InterForm::GetNativeFormFont(CFX_ByteString& csNameTag) 1091 CPDF_Font* CPDF_InterForm::GetNativeFormFont(CFX_ByteString& csNameTag)
1092 { 1092 {
1093 return GetNativeInterFormFont(m_pFormDict, m_pDocument, csNameTag); 1093 return GetNativeInterFormFont(m_pFormDict, m_pDocument, csNameTag);
1094 } 1094 }
1095 FX_BOOL CPDF_InterForm::FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csN ameTag) 1095 bool CPDF_InterForm::FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csName Tag)
1096 { 1096 {
1097 return FindInterFormFont(m_pFormDict, pFont, csNameTag); 1097 return FindInterFormFont(m_pFormDict, pFont, csNameTag);
1098 } 1098 }
1099 FX_BOOL CPDF_InterForm::FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFon t, CFX_ByteString& csNameTag) 1099 bool CPDF_InterForm::FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag)
1100 { 1100 {
1101 return FindInterFormFont(m_pFormDict, m_pDocument, csFontName, pFont, csName Tag); 1101 return FindInterFormFont(m_pFormDict, m_pDocument, csFontName, pFont, csName Tag);
1102 } 1102 }
1103 void CPDF_InterForm::AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameT ag) 1103 void CPDF_InterForm::AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameT ag)
1104 { 1104 {
1105 AddInterFormFont(m_pFormDict, m_pDocument, pFont, csNameTag); 1105 AddInterFormFont(m_pFormDict, m_pDocument, pFont, csNameTag);
1106 m_bUpdated = TRUE; 1106 m_bUpdated = true;
1107 } 1107 }
1108 CPDF_Font* CPDF_InterForm::AddNativeFormFont(uint8_t charSet, CFX_ByteString& cs NameTag) 1108 CPDF_Font* CPDF_InterForm::AddNativeFormFont(uint8_t charSet, CFX_ByteString& cs NameTag)
1109 { 1109 {
1110 m_bUpdated = TRUE; 1110 m_bUpdated = true;
1111 return AddNativeInterFormFont(m_pFormDict, m_pDocument, charSet, csNameTag); 1111 return AddNativeInterFormFont(m_pFormDict, m_pDocument, charSet, csNameTag);
1112 } 1112 }
1113 CPDF_Font* CPDF_InterForm::AddNativeFormFont(CFX_ByteString& csNameTag) 1113 CPDF_Font* CPDF_InterForm::AddNativeFormFont(CFX_ByteString& csNameTag)
1114 { 1114 {
1115 m_bUpdated = TRUE; 1115 m_bUpdated = true;
1116 return AddNativeInterFormFont(m_pFormDict, m_pDocument, csNameTag); 1116 return AddNativeInterFormFont(m_pFormDict, m_pDocument, csNameTag);
1117 } 1117 }
1118 void CPDF_InterForm::RemoveFormFont(const CPDF_Font* pFont) 1118 void CPDF_InterForm::RemoveFormFont(const CPDF_Font* pFont)
1119 { 1119 {
1120 m_bUpdated = TRUE; 1120 m_bUpdated = true;
1121 RemoveInterFormFont(m_pFormDict, pFont); 1121 RemoveInterFormFont(m_pFormDict, pFont);
1122 } 1122 }
1123 void CPDF_InterForm::RemoveFormFont(CFX_ByteString csNameTag) 1123 void CPDF_InterForm::RemoveFormFont(CFX_ByteString csNameTag)
1124 { 1124 {
1125 m_bUpdated = TRUE; 1125 m_bUpdated = true;
1126 RemoveInterFormFont(m_pFormDict, csNameTag); 1126 RemoveInterFormFont(m_pFormDict, csNameTag);
1127 } 1127 }
1128 CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() 1128 CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance()
1129 { 1129 {
1130 CFX_ByteString csDA; 1130 CFX_ByteString csDA;
1131 if (m_pFormDict == NULL) { 1131 if (m_pFormDict == NULL) {
1132 return csDA; 1132 return csDA;
1133 } 1133 }
1134 csDA = m_pFormDict->GetString("DA"); 1134 csDA = m_pFormDict->GetString("DA");
1135 return csDA; 1135 return csDA;
1136 } 1136 }
1137 CPDF_Font* CPDF_InterForm::GetDefaultFormFont() 1137 CPDF_Font* CPDF_InterForm::GetDefaultFormFont()
1138 { 1138 {
1139 return GetDefaultInterFormFont(m_pFormDict, m_pDocument); 1139 return GetDefaultInterFormFont(m_pFormDict, m_pDocument);
1140 } 1140 }
1141 int CPDF_InterForm::GetFormAlignment() 1141 int CPDF_InterForm::GetFormAlignment()
1142 { 1142 {
1143 if (m_pFormDict == NULL) { 1143 if (m_pFormDict == NULL) {
1144 return 0; 1144 return 0;
1145 } 1145 }
1146 return m_pFormDict->GetInteger("Q", 0); 1146 return m_pFormDict->GetInteger("Q", 0);
1147 } 1147 }
1148 FX_BOOL CPDF_InterForm::ResetForm(const CFX_PtrArray& fields, FX_BOOL bIncludeOr Exclude, FX_BOOL bNotify) 1148 bool CPDF_InterForm::ResetForm(const CFX_PtrArray& fields, bool bIncludeOrExclud e, bool bNotify)
1149 { 1149 {
1150 if (bNotify && m_pFormNotify != NULL) { 1150 if (bNotify && m_pFormNotify != NULL) {
1151 int iRet = m_pFormNotify->BeforeFormReset(this); 1151 int iRet = m_pFormNotify->BeforeFormReset(this);
1152 if (iRet < 0) { 1152 if (iRet < 0) {
1153 return FALSE; 1153 return false;
1154 } 1154 }
1155 } 1155 }
1156 int nCount = m_pFieldTree->m_Root.CountFields(); 1156 int nCount = m_pFieldTree->m_Root.CountFields();
1157 for (int i = 0; i < nCount; i++) { 1157 for (int i = 0; i < nCount; i++) {
1158 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1158 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
1159 if (pField == NULL) { 1159 if (pField == NULL) {
1160 continue; 1160 continue;
1161 } 1161 }
1162 FX_BOOL bFind = FALSE; 1162 bool bFind = false;
1163 int iCount = fields.GetSize(); 1163 int iCount = fields.GetSize();
1164 for (int i = 0; i < iCount; i ++) { 1164 for (int i = 0; i < iCount; i ++) {
1165 if (pField == (CPDF_FormField*)fields[i]) { 1165 if (pField == (CPDF_FormField*)fields[i]) {
1166 bFind = TRUE; 1166 bFind = true;
1167 break; 1167 break;
1168 } 1168 }
1169 } 1169 }
1170 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { 1170 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) {
1171 pField->ResetField(bNotify); 1171 pField->ResetField(bNotify);
1172 } 1172 }
1173 } 1173 }
1174 if (bNotify && m_pFormNotify != NULL) { 1174 if (bNotify && m_pFormNotify != NULL) {
1175 m_pFormNotify->AfterFormReset(this); 1175 m_pFormNotify->AfterFormReset(this);
1176 } 1176 }
1177 return TRUE; 1177 return true;
1178 } 1178 }
1179 FX_BOOL CPDF_InterForm::ResetForm(FX_BOOL bNotify) 1179 bool CPDF_InterForm::ResetForm(bool bNotify)
1180 { 1180 {
1181 if (bNotify && m_pFormNotify != NULL) { 1181 if (bNotify && m_pFormNotify != NULL) {
1182 int iRet = m_pFormNotify->BeforeFormReset(this); 1182 int iRet = m_pFormNotify->BeforeFormReset(this);
1183 if (iRet < 0) { 1183 if (iRet < 0) {
1184 return FALSE; 1184 return false;
1185 } 1185 }
1186 } 1186 }
1187 int nCount = m_pFieldTree->m_Root.CountFields(); 1187 int nCount = m_pFieldTree->m_Root.CountFields();
1188 for (int i = 0; i < nCount; i++) { 1188 for (int i = 0; i < nCount; i++) {
1189 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1189 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
1190 if (pField == NULL) { 1190 if (pField == NULL) {
1191 continue; 1191 continue;
1192 } 1192 }
1193 pField->ResetField(bNotify); 1193 pField->ResetField(bNotify);
1194 } 1194 }
1195 if (bNotify && m_pFormNotify != NULL) { 1195 if (bNotify && m_pFormNotify != NULL) {
1196 m_pFormNotify->AfterFormReset(this); 1196 m_pFormNotify->AfterFormReset(this);
1197 } 1197 }
1198 return TRUE; 1198 return true;
1199 } 1199 }
1200 void CPDF_InterForm::ReloadForm() 1200 void CPDF_InterForm::ReloadForm()
1201 { 1201 {
1202 FX_POSITION pos = m_ControlMap.GetStartPosition(); 1202 FX_POSITION pos = m_ControlMap.GetStartPosition();
1203 while (pos) { 1203 while (pos) {
1204 CPDF_Dictionary* pWidgetDict; 1204 CPDF_Dictionary* pWidgetDict;
1205 CPDF_FormControl* pControl; 1205 CPDF_FormControl* pControl;
1206 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, (void*&)pControl); 1206 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, (void*&)pControl);
1207 delete pControl; 1207 delete pControl;
1208 } 1208 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 if (pChildDict) { 1249 if (pChildDict) {
1250 if (pChildDict->GetObjNum() != dwParentObjNum) { 1250 if (pChildDict->GetObjNum() != dwParentObjNum) {
1251 LoadField(pChildDict, nLevel + 1); 1251 LoadField(pChildDict, nLevel + 1);
1252 } 1252 }
1253 } 1253 }
1254 } 1254 }
1255 } else { 1255 } else {
1256 AddTerminalField(pFieldDict); 1256 AddTerminalField(pFieldDict);
1257 } 1257 }
1258 } 1258 }
1259 FX_BOOL CPDF_InterForm::HasXFAForm() const 1259 bool CPDF_InterForm::HasXFAForm() const
1260 { 1260 {
1261 return m_pFormDict && m_pFormDict->GetArray(FX_BSTRC("XFA")) != NULL; 1261 return m_pFormDict && m_pFormDict->GetArray(FX_BSTRC("XFA")) != NULL;
1262 } 1262 }
1263 void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) 1263 void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage)
1264 { 1264 {
1265 ASSERT(pPage != NULL); 1265 ASSERT(pPage != NULL);
1266 CPDF_Dictionary* pPageDict = pPage->m_pFormDict; 1266 CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
1267 if (pPageDict == NULL) { 1267 if (pPageDict == NULL) {
1268 return; 1268 return;
1269 } 1269 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 if (pFieldDict->KeyExist(FX_BSTRC("Ff"))) { 1310 if (pFieldDict->KeyExist(FX_BSTRC("Ff"))) {
1311 CPDF_Object *pFfValue = pFieldDict->GetElementValue(FX_BSTRC("Ff ")); 1311 CPDF_Object *pFfValue = pFieldDict->GetElementValue(FX_BSTRC("Ff "));
1312 if (pFfValue) { 1312 if (pFfValue) {
1313 pParent->SetAt(FX_BSTRC("Ff"), pFfValue->Clone()); 1313 pParent->SetAt(FX_BSTRC("Ff"), pFfValue->Clone());
1314 } 1314 }
1315 } 1315 }
1316 } 1316 }
1317 pField = new CPDF_FormField(this, pParent); 1317 pField = new CPDF_FormField(this, pParent);
1318 CPDF_Object* pTObj = pDict->GetElement("T"); 1318 CPDF_Object* pTObj = pDict->GetElement("T");
1319 if (pTObj && pTObj->GetType() == PDFOBJ_REFERENCE) { 1319 if (pTObj && pTObj->GetType() == PDFOBJ_REFERENCE) {
1320 CPDF_Object* pClone = pTObj->Clone(TRUE); 1320 CPDF_Object* pClone = pTObj->Clone(true);
1321 if (pClone) { 1321 if (pClone) {
1322 pDict->SetAt("T", pClone); 1322 pDict->SetAt("T", pClone);
1323 } else { 1323 } else {
1324 pDict->SetAtName("T", ""); 1324 pDict->SetAtName("T", "");
1325 } 1325 }
1326 } 1326 }
1327 m_pFieldTree->SetField(csWName, pField); 1327 m_pFieldTree->SetField(csWName, pField);
1328 } 1328 }
1329 CPDF_Array* pKids = pFieldDict->GetArray("Kids"); 1329 CPDF_Array* pKids = pFieldDict->GetArray("Kids");
1330 if (pKids == NULL) { 1330 if (pKids == NULL) {
(...skipping 18 matching lines...) Expand all
1349 { 1349 {
1350 void *rValue = NULL; 1350 void *rValue = NULL;
1351 if (m_ControlMap.Lookup((CPDF_Dictionary*)pWidgetDict, rValue)) { 1351 if (m_ControlMap.Lookup((CPDF_Dictionary*)pWidgetDict, rValue)) {
1352 return (CPDF_FormControl*)rValue; 1352 return (CPDF_FormControl*)rValue;
1353 } 1353 }
1354 CPDF_FormControl* pControl = new CPDF_FormControl((CPDF_FormField*)pField, ( CPDF_Dictionary*)pWidgetDict); 1354 CPDF_FormControl* pControl = new CPDF_FormControl((CPDF_FormField*)pField, ( CPDF_Dictionary*)pWidgetDict);
1355 m_ControlMap.SetAt((CPDF_Dictionary*)pWidgetDict, pControl); 1355 m_ControlMap.SetAt((CPDF_Dictionary*)pWidgetDict, pControl);
1356 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl); 1356 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl);
1357 return pControl; 1357 return pControl;
1358 } 1358 }
1359 CPDF_FormField* CPDF_InterForm::CheckRequiredFields(const CFX_PtrArray *fields, FX_BOOL bIncludeOrExclude) const 1359 CPDF_FormField* CPDF_InterForm::CheckRequiredFields(const CFX_PtrArray *fields, bool bIncludeOrExclude) const
1360 { 1360 {
1361 int nCount = m_pFieldTree->m_Root.CountFields(); 1361 int nCount = m_pFieldTree->m_Root.CountFields();
1362 for (int i = 0; i < nCount; i++) { 1362 for (int i = 0; i < nCount; i++) {
1363 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1363 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
1364 if (pField == NULL) { 1364 if (pField == NULL) {
1365 continue; 1365 continue;
1366 } 1366 }
1367 int32_t iType = pField->GetType(); 1367 int32_t iType = pField->GetType();
1368 if (iType == CPDF_FormField::PushButton || iType == CPDF_FormField::Chec kBox || iType == CPDF_FormField::ListBox) { 1368 if (iType == CPDF_FormField::PushButton || iType == CPDF_FormField::Chec kBox || iType == CPDF_FormField::ListBox) {
1369 continue; 1369 continue;
1370 } 1370 }
1371 FX_DWORD dwFlags = pField->GetFieldFlags(); 1371 FX_DWORD dwFlags = pField->GetFieldFlags();
1372 if (dwFlags & 0x04) { 1372 if (dwFlags & 0x04) {
1373 continue; 1373 continue;
1374 } 1374 }
1375 FX_BOOL bFind = TRUE; 1375 bool bFind = true;
1376 if (fields != NULL) { 1376 if (fields != NULL) {
1377 bFind = fields->Find(pField, 0) >= 0; 1377 bFind = fields->Find(pField, 0) >= 0;
1378 } 1378 }
1379 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { 1379 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) {
1380 CPDF_Dictionary *pFieldDict = pField->m_pDict; 1380 CPDF_Dictionary *pFieldDict = pField->m_pDict;
1381 if ((dwFlags & 0x02) != 0 && pFieldDict->GetString("V").IsEmpty()) { 1381 if ((dwFlags & 0x02) != 0 && pFieldDict->GetString("V").IsEmpty()) {
1382 return pField; 1382 return pField;
1383 } 1383 }
1384 } 1384 }
1385 } 1385 }
1386 return NULL; 1386 return NULL;
1387 } 1387 }
1388 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, FX_B OOL bSimpleFileSpec) const 1388 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, bool bSimpleFileSpec) const
1389 { 1389 {
1390 CFX_PtrArray fields; 1390 CFX_PtrArray fields;
1391 int nCount = m_pFieldTree->m_Root.CountFields(); 1391 int nCount = m_pFieldTree->m_Root.CountFields();
1392 for (int i = 0; i < nCount; i ++) { 1392 for (int i = 0; i < nCount; i ++) {
1393 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1393 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
1394 fields.Add(pField); 1394 fields.Add(pField);
1395 } 1395 }
1396 return ExportToFDF(pdf_path, fields, TRUE, bSimpleFileSpec); 1396 return ExportToFDF(pdf_path, fields, true, bSimpleFileSpec);
1397 } 1397 }
1398 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath); 1398 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath);
1399 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, CFX_ PtrArray& fields, FX_BOOL bIncludeOrExclude, FX_BOOL bSimpleFileSpec) const 1399 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, CFX_ PtrArray& fields, bool bIncludeOrExclude, bool bSimpleFileSpec) const
1400 { 1400 {
1401 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc(); 1401 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc();
1402 if (pDoc == NULL) { 1402 if (pDoc == NULL) {
1403 return NULL; 1403 return NULL;
1404 } 1404 }
1405 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF"); 1405 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF");
1406 if (!pdf_path.IsEmpty()) { 1406 if (!pdf_path.IsEmpty()) {
1407 if (bSimpleFileSpec) { 1407 if (bSimpleFileSpec) {
1408 CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path); 1408 CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path);
1409 pMainDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(ws FilePath)); 1409 pMainDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(ws FilePath));
(...skipping 12 matching lines...) Expand all
1422 int nCount = m_pFieldTree->m_Root.CountFields(); 1422 int nCount = m_pFieldTree->m_Root.CountFields();
1423 for (int i = 0; i < nCount; i ++) { 1423 for (int i = 0; i < nCount; i ++) {
1424 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1424 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
1425 if (pField == NULL || pField->GetType() == CPDF_FormField::PushButton) { 1425 if (pField == NULL || pField->GetType() == CPDF_FormField::PushButton) {
1426 continue; 1426 continue;
1427 } 1427 }
1428 FX_DWORD dwFlags = pField->GetFieldFlags(); 1428 FX_DWORD dwFlags = pField->GetFieldFlags();
1429 if (dwFlags & 0x04) { 1429 if (dwFlags & 0x04) {
1430 continue; 1430 continue;
1431 } 1431 }
1432 FX_BOOL bFind = fields.Find(pField, 0) >= 0; 1432 bool bFind = fields.Find(pField, 0) >= 0;
1433 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { 1433 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) {
1434 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty ()) { 1434 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty ()) {
1435 continue; 1435 continue;
1436 } 1436 }
1437 CFX_WideString fullname = GetFullName(pField->GetFieldDict()); 1437 CFX_WideString fullname = GetFullName(pField->GetFieldDict());
1438 CPDF_Dictionary* pFieldDict = CPDF_Dictionary::Create(); 1438 CPDF_Dictionary* pFieldDict = CPDF_Dictionary::Create();
1439 if (pFieldDict == NULL) { 1439 if (pFieldDict == NULL) {
1440 return NULL; 1440 return NULL;
1441 } 1441 }
1442 CPDF_String* pString = CPDF_String::Create(fullname); 1442 CPDF_String* pString = CPDF_String::Create(fullname);
1443 if (pString == NULL) { 1443 if (pString == NULL) {
1444 pFieldDict->Release(); 1444 pFieldDict->Release();
1445 return NULL; 1445 return NULL;
1446 } 1446 }
1447 pFieldDict->SetAt("T", pString); 1447 pFieldDict->SetAt("T", pString);
1448 if (pField->GetType() == CPDF_FormField::CheckBox || pField->GetType () == CPDF_FormField::RadioButton) { 1448 if (pField->GetType() == CPDF_FormField::CheckBox || pField->GetType () == CPDF_FormField::RadioButton) {
1449 CFX_WideString csExport = pField->GetCheckValue(FALSE); 1449 CFX_WideString csExport = pField->GetCheckValue(false);
1450 CFX_ByteString csBExport = PDF_EncodeText(csExport); 1450 CFX_ByteString csBExport = PDF_EncodeText(csExport);
1451 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt"); 1451 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt");
1452 if (pOpt == NULL) { 1452 if (pOpt == NULL) {
1453 pFieldDict->SetAtName("V", csBExport); 1453 pFieldDict->SetAtName("V", csBExport);
1454 } else { 1454 } else {
1455 pFieldDict->SetAtString("V", csBExport); 1455 pFieldDict->SetAtString("V", csBExport);
1456 } 1456 }
1457 } else { 1457 } else {
1458 CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V"); 1458 CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V");
1459 if (pV != NULL) { 1459 if (pV != NULL) {
1460 pFieldDict->SetAt("V", pV->Clone(TRUE)); 1460 pFieldDict->SetAt("V", pV->Clone(true));
1461 } 1461 }
1462 } 1462 }
1463 pFields->Add(pFieldDict); 1463 pFields->Add(pFieldDict);
1464 } 1464 }
1465 } 1465 }
1466 return pDoc; 1466 return pDoc;
1467 } 1467 }
1468 const struct _SupportFieldEncoding { 1468 const struct _SupportFieldEncoding {
1469 const FX_CHAR* m_name; 1469 const FX_CHAR* m_name;
1470 int32_t m_codePage; 1470 int32_t m_codePage;
(...skipping 19 matching lines...) Expand all
1490 csValue.ConvertFrom(csBValue, pCharMap); 1490 csValue.ConvertFrom(csBValue, pCharMap);
1491 return; 1491 return;
1492 } 1492 }
1493 CFX_ByteString csTemp = csBValue.Left(2); 1493 CFX_ByteString csTemp = csBValue.Left(2);
1494 if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF") { 1494 if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF") {
1495 csValue = PDF_DecodeText(csBValue); 1495 csValue = PDF_DecodeText(csBValue);
1496 } else { 1496 } else {
1497 csValue = CFX_WideString::FromLocal(csBValue); 1497 csValue = CFX_WideString::FromLocal(csBValue);
1498 } 1498 }
1499 } 1499 }
1500 void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, const CFX_Wide String& parent_name, FX_BOOL bNotify, int nLevel) 1500 void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, const CFX_Wide String& parent_name, bool bNotify, int nLevel)
1501 { 1501 {
1502 CFX_WideString name; 1502 CFX_WideString name;
1503 if (!parent_name.IsEmpty()) { 1503 if (!parent_name.IsEmpty()) {
1504 name = parent_name + L"."; 1504 name = parent_name + L".";
1505 } 1505 }
1506 name += pFieldDict->GetUnicodeText("T"); 1506 name += pFieldDict->GetUnicodeText("T");
1507 CPDF_Array* pKids = pFieldDict->GetArray("Kids"); 1507 CPDF_Array* pKids = pFieldDict->GetArray("Kids");
1508 if (pKids) { 1508 if (pKids) {
1509 for (FX_DWORD i = 0; i < pKids->GetCount(); i ++) { 1509 for (FX_DWORD i = 0; i < pKids->GetCount(); i ++) {
1510 CPDF_Dictionary* pKid = pKids->GetDict(i); 1510 CPDF_Dictionary* pKid = pKids->GetDict(i);
(...skipping 27 matching lines...) Expand all
1538 return; 1538 return;
1539 } 1539 }
1540 } 1540 }
1541 CFX_ByteArray statusArray; 1541 CFX_ByteArray statusArray;
1542 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { 1542 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) {
1543 SaveCheckedFieldStatus(pField, statusArray); 1543 SaveCheckedFieldStatus(pField, statusArray);
1544 } 1544 }
1545 pField->SetValue(csWValue); 1545 pField->SetValue(csWValue);
1546 CPDF_FormField::Type eType = pField->GetType(); 1546 CPDF_FormField::Type eType = pField->GetType();
1547 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && pFieldDict->KeyExist("Opt")) { 1547 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && pFieldDict->KeyExist("Opt")) {
1548 pField->m_pDict->SetAt("Opt", pFieldDict->GetElementValue("Opt")->Clone( TRUE)); 1548 pField->m_pDict->SetAt("Opt", pFieldDict->GetElementValue("Opt")->Clone( true));
1549 } 1549 }
1550 if (bNotify && m_pFormNotify != NULL) { 1550 if (bNotify && m_pFormNotify != NULL) {
1551 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { 1551 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) {
1552 m_pFormNotify->AfterCheckedStatusChange(pField, statusArray); 1552 m_pFormNotify->AfterCheckedStatusChange(pField, statusArray);
1553 } else if (iType == FIELDTYPE_LISTBOX) { 1553 } else if (iType == FIELDTYPE_LISTBOX) {
1554 m_pFormNotify->AfterSelectionChange(pField); 1554 m_pFormNotify->AfterSelectionChange(pField);
1555 } else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) { 1555 } else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) {
1556 m_pFormNotify->AfterValueChange(pField); 1556 m_pFormNotify->AfterValueChange(pField);
1557 } 1557 }
1558 } 1558 }
1559 if (CPDF_InterForm::m_bUpdateAP) { 1559 if (CPDF_InterForm::m_bUpdateAP) {
1560 pField->UpdateAP(NULL); 1560 pField->UpdateAP(NULL);
1561 } 1561 }
1562 } 1562 }
1563 FX_BOOL CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF, FX_BOOL bNotify ) 1563 bool CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF, bool bNotify)
1564 { 1564 {
1565 if (pFDF == NULL) { 1565 if (pFDF == NULL) {
1566 return FALSE; 1566 return false;
1567 } 1567 }
1568 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); 1568 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF");
1569 if (pMainDict == NULL) { 1569 if (pMainDict == NULL) {
1570 return FALSE; 1570 return false;
1571 } 1571 }
1572 CPDF_Array* pFields = pMainDict->GetArray("Fields"); 1572 CPDF_Array* pFields = pMainDict->GetArray("Fields");
1573 if (pFields == NULL) { 1573 if (pFields == NULL) {
1574 return FALSE; 1574 return false;
1575 } 1575 }
1576 m_bsEncoding = pMainDict->GetString(FX_BSTRC("Encoding")); 1576 m_bsEncoding = pMainDict->GetString(FX_BSTRC("Encoding"));
1577 if (bNotify && m_pFormNotify != NULL) { 1577 if (bNotify && m_pFormNotify != NULL) {
1578 int iRet = m_pFormNotify->BeforeFormImportData(this); 1578 int iRet = m_pFormNotify->BeforeFormImportData(this);
1579 if (iRet < 0) { 1579 if (iRet < 0) {
1580 return FALSE; 1580 return false;
1581 } 1581 }
1582 } 1582 }
1583 for (FX_DWORD i = 0; i < pFields->GetCount(); i ++) { 1583 for (FX_DWORD i = 0; i < pFields->GetCount(); i ++) {
1584 CPDF_Dictionary* pField = pFields->GetDict(i); 1584 CPDF_Dictionary* pField = pFields->GetDict(i);
1585 if (pField == NULL) { 1585 if (pField == NULL) {
1586 continue; 1586 continue;
1587 } 1587 }
1588 FDF_ImportField(pField, L"", bNotify); 1588 FDF_ImportField(pField, L"", bNotify);
1589 } 1589 }
1590 if (bNotify && m_pFormNotify != NULL) { 1590 if (bNotify && m_pFormNotify != NULL) {
1591 m_pFormNotify->AfterFormImportData(this); 1591 m_pFormNotify->AfterFormImportData(this);
1592 } 1592 }
1593 return TRUE; 1593 return true;
1594 } 1594 }
1595 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) 1595 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify)
1596 { 1596 {
1597 m_pFormNotify = (CPDF_FormNotify*)pNotify; 1597 m_pFormNotify = (CPDF_FormNotify*)pNotify;
1598 } 1598 }
1599 int CPDF_InterForm::GetPageWithWidget(int iCurPage, FX_BOOL bNext) 1599 int CPDF_InterForm::GetPageWithWidget(int iCurPage, bool bNext)
1600 { 1600 {
1601 if (iCurPage < 0) { 1601 if (iCurPage < 0) {
1602 return -1; 1602 return -1;
1603 } 1603 }
1604 int iPageCount = m_pDocument->GetPageCount(); 1604 int iPageCount = m_pDocument->GetPageCount();
1605 if (iCurPage >= iPageCount) { 1605 if (iCurPage >= iPageCount) {
1606 return -1; 1606 return -1;
1607 } 1607 }
1608 int iNewPage = iCurPage; 1608 int iNewPage = iCurPage;
1609 do { 1609 do {
(...skipping 19 matching lines...) Expand all
1629 for (FX_DWORD i = 0; i < dwCount; i ++) { 1629 for (FX_DWORD i = 0; i < dwCount; i ++) {
1630 CPDF_Object* pAnnotDict = pAnnots->GetElementValue(i); 1630 CPDF_Object* pAnnotDict = pAnnots->GetElementValue(i);
1631 if (pAnnotDict == NULL) { 1631 if (pAnnotDict == NULL) {
1632 continue; 1632 continue;
1633 } 1633 }
1634 CPDF_FormControl* pControl = NULL; 1634 CPDF_FormControl* pControl = NULL;
1635 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) { 1635 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) {
1636 return iNewPage; 1636 return iNewPage;
1637 } 1637 }
1638 } 1638 }
1639 } while (TRUE); 1639 } while (true);
1640 return -1; 1640 return -1;
1641 } 1641 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_basic.cpp ('k') | core/src/fpdfdoc/doc_formcontrol.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698