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 "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 Loading... |
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 Loading... |
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 Loading... |
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 } | 357 } |
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 static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) | 363 static bool RetrieveSpecificFont(LOGFONTA& lf) |
364 { | 364 { |
365 PDF_FONTDATA fd; | 365 PDF_FONTDATA fd; |
366 memset(&fd, 0, sizeof(PDF_FONTDATA)); | 366 memset(&fd, 0, sizeof(PDF_FONTDATA)); |
367 HDC hDC = ::GetDC(NULL); | 367 HDC hDC = ::GetDC(NULL); |
368 EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)EnumFontFamExProc, (LPARAM)&fd,
0); | 368 EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)EnumFontFamExProc, (LPARAM)&fd,
0); |
369 ::ReleaseDC(NULL, hDC); | 369 ::ReleaseDC(NULL, hDC); |
370 if (fd.bFind) { | 370 if (fd.bFind) { |
371 memcpy(&lf, &fd.lf, sizeof(LOGFONTA)); | 371 memcpy(&lf, &fd.lf, sizeof(LOGFONTA)); |
372 } | 372 } |
373 return fd.bFind; | 373 return fd.bFind; |
374 } | 374 } |
375 static FX_BOOL RetrieveSpecificFont(uint8_t charSet, uint8_t pitchAndFamily, LPC
STR pcsFontName, LOGFONTA& lf) | 375 static bool RetrieveSpecificFont(uint8_t charSet, uint8_t pitchAndFamily, LPCSTR
pcsFontName, LOGFONTA& lf) |
376 { | 376 { |
377 memset(&lf, 0, sizeof(LOGFONTA)); | 377 memset(&lf, 0, sizeof(LOGFONTA)); |
378 lf.lfCharSet = charSet; | 378 lf.lfCharSet = charSet; |
379 lf.lfPitchAndFamily = pitchAndFamily; | 379 lf.lfPitchAndFamily = pitchAndFamily; |
380 if (pcsFontName != NULL) { | 380 if (pcsFontName != NULL) { |
381 strcpy(lf.lfFaceName, pcsFontName); | 381 strcpy(lf.lfFaceName, pcsFontName); |
382 } | 382 } |
383 return RetrieveSpecificFont(lf); | 383 return RetrieveSpecificFont(lf); |
384 } | 384 } |
385 static FX_BOOL RetrieveStockFont(int iFontObject, uint8_t charSet, LOGFONTA& lf) | 385 static bool RetrieveStockFont(int iFontObject, uint8_t charSet, LOGFONTA& lf) |
386 { | 386 { |
387 HFONT hFont = (HFONT)::GetStockObject(iFontObject); | 387 HFONT hFont = (HFONT)::GetStockObject(iFontObject); |
388 if (hFont != NULL) { | 388 if (hFont != NULL) { |
389 memset(&lf, 0, sizeof(LOGFONTA)); | 389 memset(&lf, 0, sizeof(LOGFONTA)); |
390 int iRet = ::GetObject(hFont, sizeof(LOGFONTA), &lf); | 390 int iRet = ::GetObject(hFont, sizeof(LOGFONTA), &lf); |
391 if (iRet > 0 && (lf.lfCharSet == charSet || charSet == 255)) { | 391 if (iRet > 0 && (lf.lfCharSet == charSet || charSet == 255)) { |
392 return RetrieveSpecificFont(lf); | 392 return RetrieveSpecificFont(lf); |
393 } | 393 } |
394 } | 394 } |
395 return FALSE; | 395 return false; |
396 } | 396 } |
397 #endif | 397 #endif |
398 CPDF_Font* CPDF_InterForm::AddSystemDefaultFont(const CPDF_Document* pDocument) | 398 CPDF_Font* CPDF_InterForm::AddSystemDefaultFont(const CPDF_Document* pDocument) |
399 { | 399 { |
400 if (pDocument == NULL) { | 400 if (pDocument == NULL) { |
401 return NULL; | 401 return NULL; |
402 } | 402 } |
403 CPDF_Font* pFont = NULL; | 403 CPDF_Font* pFont = NULL; |
404 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 404 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
405 LOGFONTA lf; | 405 LOGFONTA lf; |
406 FX_BOOL bRet; | 406 bool bRet; |
407 bRet = RetrieveStockFont(DEFAULT_GUI_FONT, 255, lf); | 407 bRet = RetrieveStockFont(DEFAULT_GUI_FONT, 255, lf); |
408 if (!bRet) { | 408 if (!bRet) { |
409 bRet = RetrieveStockFont(SYSTEM_FONT, 255, lf); | 409 bRet = RetrieveStockFont(SYSTEM_FONT, 255, lf); |
410 } | 410 } |
411 if (bRet) { | 411 if (bRet) { |
412 pFont = ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, FALSE, TRUE); | 412 pFont = ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, false, true); |
413 } | 413 } |
414 #endif | 414 #endif |
415 return pFont; | 415 return pFont; |
416 } | 416 } |
417 CPDF_Font* CPDF_InterForm::AddSystemFont(const CPDF_Document* pDocument, CFX_Byt
eString csFontName, uint8_t iCharSet) | 417 CPDF_Font* CPDF_InterForm::AddSystemFont(const CPDF_Document* pDocument, CFX_Byt
eString csFontName, uint8_t iCharSet) |
418 { | 418 { |
419 if (pDocument == NULL || csFontName.IsEmpty()) { | 419 if (pDocument == NULL || csFontName.IsEmpty()) { |
420 return NULL; | 420 return NULL; |
421 } | 421 } |
422 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 422 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
423 if (iCharSet == 1) { | 423 if (iCharSet == 1) { |
424 iCharSet = GetNativeCharSet(); | 424 iCharSet = GetNativeCharSet(); |
425 } | 425 } |
426 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()); | 426 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 if (hFont != NULL) { | 427 if (hFont != NULL) { |
428 LOGFONTA lf; | 428 LOGFONTA lf; |
429 memset(&lf, 0, sizeof(LOGFONTA)); | 429 memset(&lf, 0, sizeof(LOGFONTA)); |
430 ::GetObjectA(hFont, sizeof(LOGFONTA), &lf); | 430 ::GetObjectA(hFont, sizeof(LOGFONTA), &lf); |
431 ::DeleteObject(hFont); | 431 ::DeleteObject(hFont); |
432 if (strlen(lf.lfFaceName) > 0) { | 432 if (strlen(lf.lfFaceName) > 0) { |
433 return ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, FALSE, TRUE)
; | 433 return ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, false, true)
; |
434 } | 434 } |
435 } | 435 } |
436 #endif | 436 #endif |
437 return NULL; | 437 return NULL; |
438 } | 438 } |
439 CPDF_Font* CPDF_InterForm::AddSystemFont(const CPDF_Document* pDocument, CFX_Wid
eString csFontName, uint8_t iCharSet) | 439 CPDF_Font* CPDF_InterForm::AddSystemFont(const CPDF_Document* pDocument, CFX_Wid
eString csFontName, uint8_t iCharSet) |
440 { | 440 { |
441 if (pDocument == NULL || csFontName.IsEmpty()) { | 441 if (pDocument == NULL || csFontName.IsEmpty()) { |
442 return NULL; | 442 return NULL; |
443 } | 443 } |
444 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 444 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
445 if (iCharSet == 1) { | 445 if (iCharSet == 1) { |
446 iCharSet = GetNativeCharSet(); | 446 iCharSet = GetNativeCharSet(); |
447 } | 447 } |
448 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()); | 448 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 if (hFont != NULL) { | 449 if (hFont != NULL) { |
450 LOGFONTA lf; | 450 LOGFONTA lf; |
451 memset(&lf, 0, sizeof(LOGFONTA)); | 451 memset(&lf, 0, sizeof(LOGFONTA)); |
452 ::GetObject(hFont, sizeof(LOGFONTA), &lf); | 452 ::GetObject(hFont, sizeof(LOGFONTA), &lf); |
453 ::DeleteObject(hFont); | 453 ::DeleteObject(hFont); |
454 if (strlen(lf.lfFaceName) > 0) { | 454 if (strlen(lf.lfFaceName) > 0) { |
455 return ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, FALSE, TRUE)
; | 455 return ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, false, true)
; |
456 } | 456 } |
457 } | 457 } |
458 #endif | 458 #endif |
459 return NULL; | 459 return NULL; |
460 } | 460 } |
461 CPDF_Font* CPDF_InterForm::AddStandardFont(const CPDF_Document* pDocument, CFX_B
yteString csFontName) | 461 CPDF_Font* CPDF_InterForm::AddStandardFont(const CPDF_Document* pDocument, CFX_B
yteString csFontName) |
462 { | 462 { |
463 if (pDocument == NULL || csFontName.IsEmpty()) { | 463 if (pDocument == NULL || csFontName.IsEmpty()) { |
464 return NULL; | 464 return NULL; |
465 } | 465 } |
466 CPDF_Font* pFont = NULL; | 466 CPDF_Font* pFont = NULL; |
467 if (csFontName == "ZapfDingbats") { | 467 if (csFontName == "ZapfDingbats") { |
468 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, NULL); | 468 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, NULL); |
469 } else { | 469 } else { |
470 CPDF_FontEncoding encoding(PDFFONT_ENCODING_WINANSI); | 470 CPDF_FontEncoding encoding(PDFFONT_ENCODING_WINANSI); |
471 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, &encodi
ng); | 471 pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, &encodi
ng); |
472 } | 472 } |
473 return pFont; | 473 return pFont; |
474 } | 474 } |
475 CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) | 475 CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) |
476 { | 476 { |
477 CFX_ByteString csFontName; | 477 CFX_ByteString csFontName; |
478 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 478 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
479 LOGFONTA lf; | 479 LOGFONTA lf; |
480 FX_BOOL bRet; | 480 bool bRet; |
481 if (charSet == ANSI_CHARSET) { | 481 if (charSet == ANSI_CHARSET) { |
482 csFontName = "Helvetica"; | 482 csFontName = "Helvetica"; |
483 return csFontName; | 483 return csFontName; |
484 } | 484 } |
485 bRet = FALSE; | 485 bRet = false; |
486 if (charSet == SHIFTJIS_CHARSET) { | 486 if (charSet == SHIFTJIS_CHARSET) { |
487 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MS Mi
ncho", lf); | 487 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MS Mi
ncho", lf); |
488 } else if (charSet == GB2312_CHARSET) { | 488 } else if (charSet == GB2312_CHARSET) { |
489 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "SimSu
n", lf); | 489 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "SimSu
n", lf); |
490 } else if (charSet == CHINESEBIG5_CHARSET) { | 490 } else if (charSet == CHINESEBIG5_CHARSET) { |
491 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MingL
iU", lf); | 491 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MingL
iU", lf); |
492 } | 492 } |
493 if (!bRet) { | 493 if (!bRet) { |
494 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "Arial
Unicode MS", lf); | 494 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "Arial
Unicode MS", lf); |
495 } | 495 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 return NULL; | 584 return NULL; |
585 } | 585 } |
586 CPDF_Font* pFont = NULL; | 586 CPDF_Font* pFont = NULL; |
587 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 587 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
588 LOGFONTA lf; | 588 LOGFONTA lf; |
589 CFX_ByteString csFontName = GetNativeFont(charSet, &lf); | 589 CFX_ByteString csFontName = GetNativeFont(charSet, &lf); |
590 if (!csFontName.IsEmpty()) { | 590 if (!csFontName.IsEmpty()) { |
591 if (csFontName == "Helvetica") { | 591 if (csFontName == "Helvetica") { |
592 pFont = AddStandardFont(pDocument, csFontName); | 592 pFont = AddStandardFont(pDocument, csFontName); |
593 } else { | 593 } else { |
594 pFont = ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, FALSE, TRUE
); | 594 pFont = ((CPDF_Document*)pDocument)->AddWindowsFont(&lf, false, true
); |
595 } | 595 } |
596 } | 596 } |
597 #endif | 597 #endif |
598 return pFont; | 598 return pFont; |
599 } | 599 } |
600 CPDF_Font* CPDF_InterForm::AddNativeFont(const CPDF_Document* pDocument) | 600 CPDF_Font* CPDF_InterForm::AddNativeFont(const CPDF_Document* pDocument) |
601 { | 601 { |
602 if (pDocument == NULL) { | 602 if (pDocument == NULL) { |
603 return NULL; | 603 return NULL; |
604 } | 604 } |
605 CPDF_Font* pFont = NULL; | 605 CPDF_Font* pFont = NULL; |
606 uint8_t charSet = GetNativeCharSet(); | 606 uint8_t charSet = GetNativeCharSet(); |
607 pFont = AddNativeFont(charSet, pDocument); | 607 pFont = AddNativeFont(charSet, pDocument); |
608 return pFont; | 608 return pFont; |
609 } | 609 } |
610 FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, int iT
ype, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedCont
rol) | 610 bool CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, int iType
, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl
) |
611 { | 611 { |
612 if (csNewFieldName.IsEmpty()) { | 612 if (csNewFieldName.IsEmpty()) { |
613 return FALSE; | 613 return false; |
614 } | 614 } |
615 int iPos = 0; | 615 int iPos = 0; |
616 int iLength = csNewFieldName.GetLength(); | 616 int iLength = csNewFieldName.GetLength(); |
617 CFX_WideString csSub; | 617 CFX_WideString csSub; |
618 while (TRUE) { | 618 while (true) { |
619 while (iPos < iLength && (csNewFieldName[iPos] == L'.' || csNewFieldName
[iPos] == L' ')) { | 619 while (iPos < iLength && (csNewFieldName[iPos] == L'.' || csNewFieldName
[iPos] == L' ')) { |
620 iPos ++; | 620 iPos ++; |
621 } | 621 } |
622 if (iPos < iLength && !csSub.IsEmpty()) { | 622 if (iPos < iLength && !csSub.IsEmpty()) { |
623 csSub += L'.'; | 623 csSub += L'.'; |
624 } | 624 } |
625 while (iPos < iLength && csNewFieldName[iPos] != L'.') { | 625 while (iPos < iLength && csNewFieldName[iPos] != L'.') { |
626 csSub += csNewFieldName[iPos ++]; | 626 csSub += csNewFieldName[iPos ++]; |
627 } | 627 } |
628 for (int i = csSub.GetLength() - 1; i > -1; i --) { | 628 for (int i = csSub.GetLength() - 1; i > -1; i --) { |
(...skipping 15 matching lines...) Expand all Loading... |
644 continue; | 644 continue; |
645 } | 645 } |
646 } else { | 646 } else { |
647 continue; | 647 continue; |
648 } | 648 } |
649 } | 649 } |
650 CFX_WideString csFullName = pField->GetFullName(); | 650 CFX_WideString csFullName = pField->GetFullName(); |
651 int iRet = CompareFieldName(csSub, csFullName); | 651 int iRet = CompareFieldName(csSub, csFullName); |
652 if (iRet == 1) { | 652 if (iRet == 1) { |
653 if (pField->GetFieldType() != iType) { | 653 if (pField->GetFieldType() != iType) { |
654 return FALSE; | 654 return false; |
655 } | 655 } |
656 } else if (iRet == 2 && csSub == csNewFieldName) { | 656 } else if (iRet == 2 && csSub == csNewFieldName) { |
657 if (csFullName[iPos] == L'.') { | 657 if (csFullName[iPos] == L'.') { |
658 return FALSE; | 658 return false; |
659 } | 659 } |
660 } else if (iRet == 3 && csSub == csNewFieldName) { | 660 } else if (iRet == 3 && csSub == csNewFieldName) { |
661 if (csNewFieldName[csFullName.GetLength()] == L'.') { | 661 if (csNewFieldName[csFullName.GetLength()] == L'.') { |
662 return FALSE; | 662 return false; |
663 } | 663 } |
664 } | 664 } |
665 } | 665 } |
666 if (iPos >= iLength) { | 666 if (iPos >= iLength) { |
667 break; | 667 break; |
668 } | 668 } |
669 } | 669 } |
670 if (csSub.IsEmpty()) { | 670 if (csSub.IsEmpty()) { |
671 return FALSE; | 671 return false; |
672 } | 672 } |
673 csNewFieldName = csSub; | 673 csNewFieldName = csSub; |
674 return TRUE; | 674 return true; |
675 } | 675 } |
676 FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, int iT
ype) | 676 bool CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, int iType
) |
677 { | 677 { |
678 return ValidateFieldName(csNewFieldName, iType, NULL, NULL); | 678 return ValidateFieldName(csNewFieldName, iType, NULL, NULL); |
679 } | 679 } |
680 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField, CFX_Wide
String& csNewFieldName) | 680 bool CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField, CFX_WideStr
ing& csNewFieldName) |
681 { | 681 { |
682 if (pField == NULL || csNewFieldName.IsEmpty()) { | 682 if (pField == NULL || csNewFieldName.IsEmpty()) { |
683 return FALSE; | 683 return false; |
684 } | 684 } |
685 return ValidateFieldName(csNewFieldName, ((CPDF_FormField*)pField)->GetField
Type(), pField, NULL); | 685 return ValidateFieldName(csNewFieldName, ((CPDF_FormField*)pField)->GetField
Type(), pField, NULL); |
686 } | 686 } |
687 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, CFX_
WideString& csNewFieldName) | 687 bool CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, CFX_Wid
eString& csNewFieldName) |
688 { | 688 { |
689 if (pControl == NULL || csNewFieldName.IsEmpty()) { | 689 if (pControl == NULL || csNewFieldName.IsEmpty()) { |
690 return FALSE; | 690 return false; |
691 } | 691 } |
692 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField(); | 692 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField(); |
693 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, pCo
ntrol); | 693 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, pCo
ntrol); |
694 } | 694 } |
695 int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte
String& name2) | 695 int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte
String& name2) |
696 { | 696 { |
697 const FX_CHAR* ptr1 = name1; | 697 const FX_CHAR* ptr1 = name1; |
698 const FX_CHAR* ptr2 = name2; | 698 const FX_CHAR* ptr2 = name2; |
699 if (name1.GetLength() == name2.GetLength()) { | 699 if (name1.GetLength() == name2.GetLength()) { |
700 return name1 == name2 ? 1 : 0; | 700 return name1 == name2 ? 1 : 0; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 allFieldNames.RemoveAll(); | 757 allFieldNames.RemoveAll(); |
758 int nCount = m_pFieldTree->m_Root.CountFields(); | 758 int nCount = m_pFieldTree->m_Root.CountFields(); |
759 for (int i = 0; i < nCount; i ++) { | 759 for (int i = 0; i < nCount; i ++) { |
760 CPDF_FormField *pField = m_pFieldTree->m_Root.GetField(i); | 760 CPDF_FormField *pField = m_pFieldTree->m_Root.GetField(i); |
761 if (pField) { | 761 if (pField) { |
762 CFX_WideString full_name = GetFullName(pField->GetFieldDict()); | 762 CFX_WideString full_name = GetFullName(pField->GetFieldDict()); |
763 allFieldNames.Add(full_name); | 763 allFieldNames.Add(full_name); |
764 } | 764 } |
765 } | 765 } |
766 } | 766 } |
767 FX_BOOL CPDF_InterForm::IsValidFormField(const void* pField) | 767 bool CPDF_InterForm::IsValidFormField(const void* pField) |
768 { | 768 { |
769 if (pField == NULL) { | 769 if (pField == NULL) { |
770 return FALSE; | 770 return false; |
771 } | 771 } |
772 int nCount = m_pFieldTree->m_Root.CountFields(); | 772 int nCount = m_pFieldTree->m_Root.CountFields(); |
773 for (int i = 0; i < nCount; i++) { | 773 for (int i = 0; i < nCount; i++) { |
774 CPDF_FormField *pFormField = m_pFieldTree->m_Root.GetField(i); | 774 CPDF_FormField *pFormField = m_pFieldTree->m_Root.GetField(i); |
775 if (pField == pFormField) { | 775 if (pField == pFormField) { |
776 return TRUE; | 776 return true; |
777 } | 777 } |
778 } | 778 } |
779 return FALSE; | 779 return false; |
780 } | 780 } |
781 CPDF_FormField* CPDF_InterForm::GetFieldByDict(CPDF_Dictionary* pFieldDict) cons
t | 781 CPDF_FormField* CPDF_InterForm::GetFieldByDict(CPDF_Dictionary* pFieldDict) cons
t |
782 { | 782 { |
783 if (pFieldDict == NULL) { | 783 if (pFieldDict == NULL) { |
784 return NULL; | 784 return NULL; |
785 } | 785 } |
786 CFX_WideString csWName = GetFullName(pFieldDict); | 786 CFX_WideString csWName = GetFullName(pFieldDict); |
787 return m_pFieldTree->GetField(csWName); | 787 return m_pFieldTree->GetField(csWName); |
788 } | 788 } |
789 FX_DWORD CPDF_InterForm::CountControls(CFX_WideString csFieldName) | 789 FX_DWORD CPDF_InterForm::CountControls(CFX_WideString csFieldName) |
(...skipping 11 matching lines...) Expand all Loading... |
801 { | 801 { |
802 CPDF_FormField *pField = m_pFieldTree->GetField(csFieldName); | 802 CPDF_FormField *pField = m_pFieldTree->GetField(csFieldName); |
803 if (pField == NULL) { | 803 if (pField == NULL) { |
804 return NULL; | 804 return NULL; |
805 } | 805 } |
806 if (index < (FX_DWORD)pField->m_ControlList.GetSize()) { | 806 if (index < (FX_DWORD)pField->m_ControlList.GetSize()) { |
807 return (CPDF_FormControl *)pField->m_ControlList.GetAt(index); | 807 return (CPDF_FormControl *)pField->m_ControlList.GetAt(index); |
808 } | 808 } |
809 return NULL; | 809 return NULL; |
810 } | 810 } |
811 FX_BOOL CPDF_InterForm::IsValidFormControl(const void* pControl) | 811 bool CPDF_InterForm::IsValidFormControl(const void* pControl) |
812 { | 812 { |
813 if (pControl == NULL) { | 813 if (pControl == NULL) { |
814 return FALSE; | 814 return false; |
815 } | 815 } |
816 FX_POSITION pos = m_ControlMap.GetStartPosition(); | 816 FX_POSITION pos = m_ControlMap.GetStartPosition(); |
817 while (pos) { | 817 while (pos) { |
818 CPDF_Dictionary* pWidgetDict = NULL; | 818 CPDF_Dictionary* pWidgetDict = NULL; |
819 void* pFormControl = NULL; | 819 void* pFormControl = NULL; |
820 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, pFormControl); | 820 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, pFormControl); |
821 if (pControl == pFormControl) { | 821 if (pControl == pFormControl) { |
822 return TRUE; | 822 return true; |
823 } | 823 } |
824 } | 824 } |
825 return FALSE; | 825 return false; |
826 } | 826 } |
827 int CPDF_InterForm::CountPageControls(CPDF_Page* pPage) const | 827 int CPDF_InterForm::CountPageControls(CPDF_Page* pPage) const |
828 { | 828 { |
829 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); | 829 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); |
830 if (pAnnotList == NULL) { | 830 if (pAnnotList == NULL) { |
831 return 0; | 831 return 0; |
832 } | 832 } |
833 int count = 0; | 833 int count = 0; |
834 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); i ++) { | 834 for (FX_DWORD i = 0; i < pAnnotList->GetCount(); i ++) { |
835 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i); | 835 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 CPDF_Dictionary* pDict = NULL; | 912 CPDF_Dictionary* pDict = NULL; |
913 while (pArray != NULL) { | 913 while (pArray != NULL) { |
914 CFX_WideString csSub; | 914 CFX_WideString csSub; |
915 if (iPos < iLength && csFieldName[iPos] == L'.') { | 915 if (iPos < iLength && csFieldName[iPos] == L'.') { |
916 iPos ++; | 916 iPos ++; |
917 } | 917 } |
918 while (iPos < iLength && csFieldName[iPos] != L'.') { | 918 while (iPos < iLength && csFieldName[iPos] != L'.') { |
919 csSub += csFieldName[iPos ++]; | 919 csSub += csFieldName[iPos ++]; |
920 } | 920 } |
921 int iCount = pArray->GetCount(); | 921 int iCount = pArray->GetCount(); |
922 FX_BOOL bFind = FALSE; | 922 bool bFind = false; |
923 for (int i = 0; i < iCount; i ++) { | 923 for (int i = 0; i < iCount; i ++) { |
924 pDict = pArray->GetDict(i); | 924 pDict = pArray->GetDict(i); |
925 if (pDict == NULL) { | 925 if (pDict == NULL) { |
926 continue; | 926 continue; |
927 } | 927 } |
928 CFX_WideString csT = pDict->GetUnicodeText("T"); | 928 CFX_WideString csT = pDict->GetUnicodeText("T"); |
929 if (csT == csSub) { | 929 if (csT == csSub) { |
930 bFind = TRUE; | 930 bFind = true; |
931 break; | 931 break; |
932 } | 932 } |
933 } | 933 } |
934 if (!bFind) { | 934 if (!bFind) { |
935 return 0; | 935 return 0; |
936 } | 936 } |
937 if (iPos >= iLength) { | 937 if (iPos >= iLength) { |
938 break; | 938 break; |
939 } | 939 } |
940 pArray = pDict->GetArray("Kids"); | 940 pArray = pDict->GetArray("Kids"); |
(...skipping 22 matching lines...) Expand all Loading... |
963 CPDF_Dictionary* pDict = NULL; | 963 CPDF_Dictionary* pDict = NULL; |
964 while (pArray != NULL) { | 964 while (pArray != NULL) { |
965 CFX_WideString csSub; | 965 CFX_WideString csSub; |
966 if (iPos < iLength && csFieldName[iPos] == L'.') { | 966 if (iPos < iLength && csFieldName[iPos] == L'.') { |
967 iPos ++; | 967 iPos ++; |
968 } | 968 } |
969 while (iPos < iLength && csFieldName[iPos] != L'.') { | 969 while (iPos < iLength && csFieldName[iPos] != L'.') { |
970 csSub += csFieldName[iPos ++]; | 970 csSub += csFieldName[iPos ++]; |
971 } | 971 } |
972 int iCount = pArray->GetCount(); | 972 int iCount = pArray->GetCount(); |
973 FX_BOOL bFind = FALSE; | 973 bool bFind = false; |
974 for (int i = 0; i < iCount; i ++) { | 974 for (int i = 0; i < iCount; i ++) { |
975 pDict = pArray->GetDict(i); | 975 pDict = pArray->GetDict(i); |
976 if (pDict == NULL) { | 976 if (pDict == NULL) { |
977 continue; | 977 continue; |
978 } | 978 } |
979 CFX_WideString csT = pDict->GetUnicodeText("T"); | 979 CFX_WideString csT = pDict->GetUnicodeText("T"); |
980 if (csT == csSub) { | 980 if (csT == csSub) { |
981 bFind = TRUE; | 981 bFind = true; |
982 break; | 982 break; |
983 } | 983 } |
984 } | 984 } |
985 if (!bFind) { | 985 if (!bFind) { |
986 return NULL; | 986 return NULL; |
987 } | 987 } |
988 if (iPos >= iLength) { | 988 if (iPos >= iLength) { |
989 break; | 989 break; |
990 } | 990 } |
991 pArray = pDict->GetArray("Kids"); | 991 pArray = pDict->GetArray("Kids"); |
992 } | 992 } |
993 if (!pDict) { | 993 if (!pDict) { |
994 return nullptr; | 994 return nullptr; |
995 } | 995 } |
996 pArray = pDict->GetArray("Kids"); | 996 pArray = pDict->GetArray("Kids"); |
997 return pArray ? pArray->GetDict(index) : pDict; | 997 return pArray ? pArray->GetDict(index) : pDict; |
998 } | 998 } |
999 FX_BOOL CPDF_InterForm::NeedConstructAP() | 999 bool CPDF_InterForm::NeedConstructAP() |
1000 { | 1000 { |
1001 if (m_pFormDict == NULL) { | 1001 if (m_pFormDict == NULL) { |
1002 return FALSE; | 1002 return false; |
1003 } | 1003 } |
1004 return m_pFormDict->GetBoolean("NeedAppearances"); | 1004 return m_pFormDict->GetBoolean("NeedAppearances"); |
1005 } | 1005 } |
1006 void CPDF_InterForm::NeedConstructAP(FX_BOOL bNeedAP) | 1006 void CPDF_InterForm::NeedConstructAP(bool bNeedAP) |
1007 { | 1007 { |
1008 if (m_pFormDict == NULL) { | 1008 if (m_pFormDict == NULL) { |
1009 InitInterFormDict(m_pFormDict, m_pDocument); | 1009 InitInterFormDict(m_pFormDict, m_pDocument); |
1010 } | 1010 } |
1011 m_pFormDict->SetAtBoolean("NeedAppearances", bNeedAP); | 1011 m_pFormDict->SetAtBoolean("NeedAppearances", bNeedAP); |
1012 m_bGenerateAP = bNeedAP; | 1012 m_bGenerateAP = bNeedAP; |
1013 } | 1013 } |
1014 int CPDF_InterForm::CountFieldsInCalculationOrder() | 1014 int CPDF_InterForm::CountFieldsInCalculationOrder() |
1015 { | 1015 { |
1016 if (m_pFormDict == NULL) { | 1016 if (m_pFormDict == NULL) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 return GetInterFormFont(m_pFormDict, m_pDocument, csFontName, csNameTag); | 1071 return GetInterFormFont(m_pFormDict, m_pDocument, csFontName, csNameTag); |
1072 } | 1072 } |
1073 CPDF_Font* CPDF_InterForm::GetNativeFormFont(uint8_t charSet, CFX_ByteString& cs
NameTag) | 1073 CPDF_Font* CPDF_InterForm::GetNativeFormFont(uint8_t charSet, CFX_ByteString& cs
NameTag) |
1074 { | 1074 { |
1075 return GetNativeInterFormFont(m_pFormDict, m_pDocument, charSet, csNameTag); | 1075 return GetNativeInterFormFont(m_pFormDict, m_pDocument, charSet, csNameTag); |
1076 } | 1076 } |
1077 CPDF_Font* CPDF_InterForm::GetNativeFormFont(CFX_ByteString& csNameTag) | 1077 CPDF_Font* CPDF_InterForm::GetNativeFormFont(CFX_ByteString& csNameTag) |
1078 { | 1078 { |
1079 return GetNativeInterFormFont(m_pFormDict, m_pDocument, csNameTag); | 1079 return GetNativeInterFormFont(m_pFormDict, m_pDocument, csNameTag); |
1080 } | 1080 } |
1081 FX_BOOL CPDF_InterForm::FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csN
ameTag) | 1081 bool CPDF_InterForm::FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csName
Tag) |
1082 { | 1082 { |
1083 return FindInterFormFont(m_pFormDict, pFont, csNameTag); | 1083 return FindInterFormFont(m_pFormDict, pFont, csNameTag); |
1084 } | 1084 } |
1085 FX_BOOL CPDF_InterForm::FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFon
t, CFX_ByteString& csNameTag) | 1085 bool CPDF_InterForm::FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFont,
CFX_ByteString& csNameTag) |
1086 { | 1086 { |
1087 return FindInterFormFont(m_pFormDict, m_pDocument, csFontName, pFont, csName
Tag); | 1087 return FindInterFormFont(m_pFormDict, m_pDocument, csFontName, pFont, csName
Tag); |
1088 } | 1088 } |
1089 void CPDF_InterForm::AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameT
ag) | 1089 void CPDF_InterForm::AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameT
ag) |
1090 { | 1090 { |
1091 AddInterFormFont(m_pFormDict, m_pDocument, pFont, csNameTag); | 1091 AddInterFormFont(m_pFormDict, m_pDocument, pFont, csNameTag); |
1092 m_bUpdated = TRUE; | 1092 m_bUpdated = true; |
1093 } | 1093 } |
1094 CPDF_Font* CPDF_InterForm::AddNativeFormFont(uint8_t charSet, CFX_ByteString& cs
NameTag) | 1094 CPDF_Font* CPDF_InterForm::AddNativeFormFont(uint8_t charSet, CFX_ByteString& cs
NameTag) |
1095 { | 1095 { |
1096 m_bUpdated = TRUE; | 1096 m_bUpdated = true; |
1097 return AddNativeInterFormFont(m_pFormDict, m_pDocument, charSet, csNameTag); | 1097 return AddNativeInterFormFont(m_pFormDict, m_pDocument, charSet, csNameTag); |
1098 } | 1098 } |
1099 CPDF_Font* CPDF_InterForm::AddNativeFormFont(CFX_ByteString& csNameTag) | 1099 CPDF_Font* CPDF_InterForm::AddNativeFormFont(CFX_ByteString& csNameTag) |
1100 { | 1100 { |
1101 m_bUpdated = TRUE; | 1101 m_bUpdated = true; |
1102 return AddNativeInterFormFont(m_pFormDict, m_pDocument, csNameTag); | 1102 return AddNativeInterFormFont(m_pFormDict, m_pDocument, csNameTag); |
1103 } | 1103 } |
1104 void CPDF_InterForm::RemoveFormFont(const CPDF_Font* pFont) | 1104 void CPDF_InterForm::RemoveFormFont(const CPDF_Font* pFont) |
1105 { | 1105 { |
1106 m_bUpdated = TRUE; | 1106 m_bUpdated = true; |
1107 RemoveInterFormFont(m_pFormDict, pFont); | 1107 RemoveInterFormFont(m_pFormDict, pFont); |
1108 } | 1108 } |
1109 void CPDF_InterForm::RemoveFormFont(CFX_ByteString csNameTag) | 1109 void CPDF_InterForm::RemoveFormFont(CFX_ByteString csNameTag) |
1110 { | 1110 { |
1111 m_bUpdated = TRUE; | 1111 m_bUpdated = true; |
1112 RemoveInterFormFont(m_pFormDict, csNameTag); | 1112 RemoveInterFormFont(m_pFormDict, csNameTag); |
1113 } | 1113 } |
1114 CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() | 1114 CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() |
1115 { | 1115 { |
1116 CFX_ByteString csDA; | 1116 CFX_ByteString csDA; |
1117 if (m_pFormDict == NULL) { | 1117 if (m_pFormDict == NULL) { |
1118 return csDA; | 1118 return csDA; |
1119 } | 1119 } |
1120 csDA = m_pFormDict->GetString("DA"); | 1120 csDA = m_pFormDict->GetString("DA"); |
1121 return csDA; | 1121 return csDA; |
1122 } | 1122 } |
1123 CPDF_Font* CPDF_InterForm::GetDefaultFormFont() | 1123 CPDF_Font* CPDF_InterForm::GetDefaultFormFont() |
1124 { | 1124 { |
1125 return GetDefaultInterFormFont(m_pFormDict, m_pDocument); | 1125 return GetDefaultInterFormFont(m_pFormDict, m_pDocument); |
1126 } | 1126 } |
1127 int CPDF_InterForm::GetFormAlignment() | 1127 int CPDF_InterForm::GetFormAlignment() |
1128 { | 1128 { |
1129 if (m_pFormDict == NULL) { | 1129 if (m_pFormDict == NULL) { |
1130 return 0; | 1130 return 0; |
1131 } | 1131 } |
1132 return m_pFormDict->GetInteger("Q", 0); | 1132 return m_pFormDict->GetInteger("Q", 0); |
1133 } | 1133 } |
1134 FX_BOOL CPDF_InterForm::ResetForm(const CFX_PtrArray& fields, FX_BOOL bIncludeOr
Exclude, FX_BOOL bNotify) | 1134 bool CPDF_InterForm::ResetForm(const CFX_PtrArray& fields, bool bIncludeOrExclud
e, bool bNotify) |
1135 { | 1135 { |
1136 if (bNotify && m_pFormNotify != NULL) { | 1136 if (bNotify && m_pFormNotify != NULL) { |
1137 int iRet = m_pFormNotify->BeforeFormReset(this); | 1137 int iRet = m_pFormNotify->BeforeFormReset(this); |
1138 if (iRet < 0) { | 1138 if (iRet < 0) { |
1139 return FALSE; | 1139 return false; |
1140 } | 1140 } |
1141 } | 1141 } |
1142 int nCount = m_pFieldTree->m_Root.CountFields(); | 1142 int nCount = m_pFieldTree->m_Root.CountFields(); |
1143 for (int i = 0; i < nCount; i++) { | 1143 for (int i = 0; i < nCount; i++) { |
1144 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 1144 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
1145 if (pField == NULL) { | 1145 if (pField == NULL) { |
1146 continue; | 1146 continue; |
1147 } | 1147 } |
1148 FX_BOOL bFind = FALSE; | 1148 bool bFind = false; |
1149 int iCount = fields.GetSize(); | 1149 int iCount = fields.GetSize(); |
1150 for (int i = 0; i < iCount; i ++) { | 1150 for (int i = 0; i < iCount; i ++) { |
1151 if (pField == (CPDF_FormField*)fields[i]) { | 1151 if (pField == (CPDF_FormField*)fields[i]) { |
1152 bFind = TRUE; | 1152 bFind = true; |
1153 break; | 1153 break; |
1154 } | 1154 } |
1155 } | 1155 } |
1156 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { | 1156 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { |
1157 pField->ResetField(bNotify); | 1157 pField->ResetField(bNotify); |
1158 } | 1158 } |
1159 } | 1159 } |
1160 if (bNotify && m_pFormNotify != NULL) { | 1160 if (bNotify && m_pFormNotify != NULL) { |
1161 m_pFormNotify->AfterFormReset(this); | 1161 m_pFormNotify->AfterFormReset(this); |
1162 } | 1162 } |
1163 return TRUE; | 1163 return true; |
1164 } | 1164 } |
1165 FX_BOOL CPDF_InterForm::ResetForm(FX_BOOL bNotify) | 1165 bool CPDF_InterForm::ResetForm(bool bNotify) |
1166 { | 1166 { |
1167 if (bNotify && m_pFormNotify != NULL) { | 1167 if (bNotify && m_pFormNotify != NULL) { |
1168 int iRet = m_pFormNotify->BeforeFormReset(this); | 1168 int iRet = m_pFormNotify->BeforeFormReset(this); |
1169 if (iRet < 0) { | 1169 if (iRet < 0) { |
1170 return FALSE; | 1170 return false; |
1171 } | 1171 } |
1172 } | 1172 } |
1173 int nCount = m_pFieldTree->m_Root.CountFields(); | 1173 int nCount = m_pFieldTree->m_Root.CountFields(); |
1174 for (int i = 0; i < nCount; i++) { | 1174 for (int i = 0; i < nCount; i++) { |
1175 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 1175 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
1176 if (pField == NULL) { | 1176 if (pField == NULL) { |
1177 continue; | 1177 continue; |
1178 } | 1178 } |
1179 pField->ResetField(bNotify); | 1179 pField->ResetField(bNotify); |
1180 } | 1180 } |
1181 if (bNotify && m_pFormNotify != NULL) { | 1181 if (bNotify && m_pFormNotify != NULL) { |
1182 m_pFormNotify->AfterFormReset(this); | 1182 m_pFormNotify->AfterFormReset(this); |
1183 } | 1183 } |
1184 return TRUE; | 1184 return true; |
1185 } | 1185 } |
1186 void CPDF_InterForm::ReloadForm() | 1186 void CPDF_InterForm::ReloadForm() |
1187 { | 1187 { |
1188 FX_POSITION pos = m_ControlMap.GetStartPosition(); | 1188 FX_POSITION pos = m_ControlMap.GetStartPosition(); |
1189 while (pos) { | 1189 while (pos) { |
1190 CPDF_Dictionary* pWidgetDict; | 1190 CPDF_Dictionary* pWidgetDict; |
1191 CPDF_FormControl* pControl; | 1191 CPDF_FormControl* pControl; |
1192 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, (void*&)pControl); | 1192 m_ControlMap.GetNextAssoc(pos, (void*&)pWidgetDict, (void*&)pControl); |
1193 delete pControl; | 1193 delete pControl; |
1194 } | 1194 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 if (pChildDict) { | 1235 if (pChildDict) { |
1236 if (pChildDict->GetObjNum() != dwParentObjNum) { | 1236 if (pChildDict->GetObjNum() != dwParentObjNum) { |
1237 LoadField(pChildDict, nLevel + 1); | 1237 LoadField(pChildDict, nLevel + 1); |
1238 } | 1238 } |
1239 } | 1239 } |
1240 } | 1240 } |
1241 } else { | 1241 } else { |
1242 AddTerminalField(pFieldDict); | 1242 AddTerminalField(pFieldDict); |
1243 } | 1243 } |
1244 } | 1244 } |
1245 FX_BOOL CPDF_InterForm::HasXFAForm() const | 1245 bool CPDF_InterForm::HasXFAForm() const |
1246 { | 1246 { |
1247 return m_pFormDict && m_pFormDict->GetArray(FX_BSTRC("XFA")) != NULL; | 1247 return m_pFormDict && m_pFormDict->GetArray(FX_BSTRC("XFA")) != NULL; |
1248 } | 1248 } |
1249 void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) | 1249 void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) |
1250 { | 1250 { |
1251 ASSERT(pPage != NULL); | 1251 ASSERT(pPage != NULL); |
1252 CPDF_Dictionary* pPageDict = pPage->m_pFormDict; | 1252 CPDF_Dictionary* pPageDict = pPage->m_pFormDict; |
1253 if (pPageDict == NULL) { | 1253 if (pPageDict == NULL) { |
1254 return; | 1254 return; |
1255 } | 1255 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 if (pFieldDict->KeyExist(FX_BSTRC("Ff"))) { | 1296 if (pFieldDict->KeyExist(FX_BSTRC("Ff"))) { |
1297 CPDF_Object *pFfValue = pFieldDict->GetElementValue(FX_BSTRC("Ff
")); | 1297 CPDF_Object *pFfValue = pFieldDict->GetElementValue(FX_BSTRC("Ff
")); |
1298 if (pFfValue) { | 1298 if (pFfValue) { |
1299 pParent->SetAt(FX_BSTRC("Ff"), pFfValue->Clone()); | 1299 pParent->SetAt(FX_BSTRC("Ff"), pFfValue->Clone()); |
1300 } | 1300 } |
1301 } | 1301 } |
1302 } | 1302 } |
1303 pField = new CPDF_FormField(this, pParent); | 1303 pField = new CPDF_FormField(this, pParent); |
1304 CPDF_Object* pTObj = pDict->GetElement("T"); | 1304 CPDF_Object* pTObj = pDict->GetElement("T"); |
1305 if (pTObj && pTObj->GetType() == PDFOBJ_REFERENCE) { | 1305 if (pTObj && pTObj->GetType() == PDFOBJ_REFERENCE) { |
1306 CPDF_Object* pClone = pTObj->Clone(TRUE); | 1306 CPDF_Object* pClone = pTObj->Clone(true); |
1307 if (pClone) { | 1307 if (pClone) { |
1308 pDict->SetAt("T", pClone); | 1308 pDict->SetAt("T", pClone); |
1309 } else { | 1309 } else { |
1310 pDict->SetAtName("T", ""); | 1310 pDict->SetAtName("T", ""); |
1311 } | 1311 } |
1312 } | 1312 } |
1313 m_pFieldTree->SetField(csWName, pField); | 1313 m_pFieldTree->SetField(csWName, pField); |
1314 } | 1314 } |
1315 CPDF_Array* pKids = pFieldDict->GetArray("Kids"); | 1315 CPDF_Array* pKids = pFieldDict->GetArray("Kids"); |
1316 if (pKids == NULL) { | 1316 if (pKids == NULL) { |
(...skipping 18 matching lines...) Expand all Loading... |
1335 { | 1335 { |
1336 void *rValue = NULL; | 1336 void *rValue = NULL; |
1337 if (m_ControlMap.Lookup((CPDF_Dictionary*)pWidgetDict, rValue)) { | 1337 if (m_ControlMap.Lookup((CPDF_Dictionary*)pWidgetDict, rValue)) { |
1338 return (CPDF_FormControl*)rValue; | 1338 return (CPDF_FormControl*)rValue; |
1339 } | 1339 } |
1340 CPDF_FormControl* pControl = new CPDF_FormControl((CPDF_FormField*)pField, (
CPDF_Dictionary*)pWidgetDict); | 1340 CPDF_FormControl* pControl = new CPDF_FormControl((CPDF_FormField*)pField, (
CPDF_Dictionary*)pWidgetDict); |
1341 m_ControlMap.SetAt((CPDF_Dictionary*)pWidgetDict, pControl); | 1341 m_ControlMap.SetAt((CPDF_Dictionary*)pWidgetDict, pControl); |
1342 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl); | 1342 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl); |
1343 return pControl; | 1343 return pControl; |
1344 } | 1344 } |
1345 CPDF_FormField* CPDF_InterForm::CheckRequiredFields(const CFX_PtrArray *fields,
FX_BOOL bIncludeOrExclude) const | 1345 CPDF_FormField* CPDF_InterForm::CheckRequiredFields(const CFX_PtrArray *fields,
bool bIncludeOrExclude) const |
1346 { | 1346 { |
1347 int nCount = m_pFieldTree->m_Root.CountFields(); | 1347 int nCount = m_pFieldTree->m_Root.CountFields(); |
1348 for (int i = 0; i < nCount; i++) { | 1348 for (int i = 0; i < nCount; i++) { |
1349 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 1349 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
1350 if (pField == NULL) { | 1350 if (pField == NULL) { |
1351 continue; | 1351 continue; |
1352 } | 1352 } |
1353 int32_t iType = pField->GetType(); | 1353 int32_t iType = pField->GetType(); |
1354 if (iType == CPDF_FormField::PushButton || iType == CPDF_FormField::Chec
kBox || iType == CPDF_FormField::ListBox) { | 1354 if (iType == CPDF_FormField::PushButton || iType == CPDF_FormField::Chec
kBox || iType == CPDF_FormField::ListBox) { |
1355 continue; | 1355 continue; |
1356 } | 1356 } |
1357 FX_DWORD dwFlags = pField->GetFieldFlags(); | 1357 FX_DWORD dwFlags = pField->GetFieldFlags(); |
1358 if (dwFlags & 0x04) { | 1358 if (dwFlags & 0x04) { |
1359 continue; | 1359 continue; |
1360 } | 1360 } |
1361 FX_BOOL bFind = TRUE; | 1361 bool bFind = true; |
1362 if (fields != NULL) { | 1362 if (fields != NULL) { |
1363 bFind = fields->Find(pField, 0) >= 0; | 1363 bFind = fields->Find(pField, 0) >= 0; |
1364 } | 1364 } |
1365 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { | 1365 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { |
1366 CPDF_Dictionary *pFieldDict = pField->m_pDict; | 1366 CPDF_Dictionary *pFieldDict = pField->m_pDict; |
1367 if ((dwFlags & 0x02) != 0 && pFieldDict->GetString("V").IsEmpty()) { | 1367 if ((dwFlags & 0x02) != 0 && pFieldDict->GetString("V").IsEmpty()) { |
1368 return pField; | 1368 return pField; |
1369 } | 1369 } |
1370 } | 1370 } |
1371 } | 1371 } |
1372 return NULL; | 1372 return NULL; |
1373 } | 1373 } |
1374 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, FX_B
OOL bSimpleFileSpec) const | 1374 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, bool
bSimpleFileSpec) const |
1375 { | 1375 { |
1376 CFX_PtrArray fields; | 1376 CFX_PtrArray fields; |
1377 int nCount = m_pFieldTree->m_Root.CountFields(); | 1377 int nCount = m_pFieldTree->m_Root.CountFields(); |
1378 for (int i = 0; i < nCount; i ++) { | 1378 for (int i = 0; i < nCount; i ++) { |
1379 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 1379 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
1380 fields.Add(pField); | 1380 fields.Add(pField); |
1381 } | 1381 } |
1382 return ExportToFDF(pdf_path, fields, TRUE, bSimpleFileSpec); | 1382 return ExportToFDF(pdf_path, fields, true, bSimpleFileSpec); |
1383 } | 1383 } |
1384 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath); | 1384 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath); |
1385 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, CFX_
PtrArray& fields, FX_BOOL bIncludeOrExclude, FX_BOOL bSimpleFileSpec) const | 1385 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, CFX_
PtrArray& fields, bool bIncludeOrExclude, bool bSimpleFileSpec) const |
1386 { | 1386 { |
1387 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc(); | 1387 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc(); |
1388 if (pDoc == NULL) { | 1388 if (pDoc == NULL) { |
1389 return NULL; | 1389 return NULL; |
1390 } | 1390 } |
1391 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF"); | 1391 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF"); |
1392 if (!pdf_path.IsEmpty()) { | 1392 if (!pdf_path.IsEmpty()) { |
1393 if (bSimpleFileSpec) { | 1393 if (bSimpleFileSpec) { |
1394 CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path); | 1394 CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path); |
1395 pMainDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(ws
FilePath)); | 1395 pMainDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(ws
FilePath)); |
(...skipping 12 matching lines...) Expand all Loading... |
1408 int nCount = m_pFieldTree->m_Root.CountFields(); | 1408 int nCount = m_pFieldTree->m_Root.CountFields(); |
1409 for (int i = 0; i < nCount; i ++) { | 1409 for (int i = 0; i < nCount; i ++) { |
1410 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 1410 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
1411 if (pField == NULL || pField->GetType() == CPDF_FormField::PushButton) { | 1411 if (pField == NULL || pField->GetType() == CPDF_FormField::PushButton) { |
1412 continue; | 1412 continue; |
1413 } | 1413 } |
1414 FX_DWORD dwFlags = pField->GetFieldFlags(); | 1414 FX_DWORD dwFlags = pField->GetFieldFlags(); |
1415 if (dwFlags & 0x04) { | 1415 if (dwFlags & 0x04) { |
1416 continue; | 1416 continue; |
1417 } | 1417 } |
1418 FX_BOOL bFind = fields.Find(pField, 0) >= 0; | 1418 bool bFind = fields.Find(pField, 0) >= 0; |
1419 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { | 1419 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { |
1420 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty
()) { | 1420 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty
()) { |
1421 continue; | 1421 continue; |
1422 } | 1422 } |
1423 CFX_WideString fullname = GetFullName(pField->GetFieldDict()); | 1423 CFX_WideString fullname = GetFullName(pField->GetFieldDict()); |
1424 CPDF_Dictionary* pFieldDict = CPDF_Dictionary::Create(); | 1424 CPDF_Dictionary* pFieldDict = CPDF_Dictionary::Create(); |
1425 if (pFieldDict == NULL) { | 1425 if (pFieldDict == NULL) { |
1426 return NULL; | 1426 return NULL; |
1427 } | 1427 } |
1428 CPDF_String* pString = CPDF_String::Create(fullname); | 1428 CPDF_String* pString = CPDF_String::Create(fullname); |
1429 if (pString == NULL) { | 1429 if (pString == NULL) { |
1430 pFieldDict->Release(); | 1430 pFieldDict->Release(); |
1431 return NULL; | 1431 return NULL; |
1432 } | 1432 } |
1433 pFieldDict->SetAt("T", pString); | 1433 pFieldDict->SetAt("T", pString); |
1434 if (pField->GetType() == CPDF_FormField::CheckBox || pField->GetType
() == CPDF_FormField::RadioButton) { | 1434 if (pField->GetType() == CPDF_FormField::CheckBox || pField->GetType
() == CPDF_FormField::RadioButton) { |
1435 CFX_WideString csExport = pField->GetCheckValue(FALSE); | 1435 CFX_WideString csExport = pField->GetCheckValue(false); |
1436 CFX_ByteString csBExport = PDF_EncodeText(csExport); | 1436 CFX_ByteString csBExport = PDF_EncodeText(csExport); |
1437 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt"); | 1437 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt"); |
1438 if (pOpt == NULL) { | 1438 if (pOpt == NULL) { |
1439 pFieldDict->SetAtName("V", csBExport); | 1439 pFieldDict->SetAtName("V", csBExport); |
1440 } else { | 1440 } else { |
1441 pFieldDict->SetAtString("V", csBExport); | 1441 pFieldDict->SetAtString("V", csBExport); |
1442 } | 1442 } |
1443 } else { | 1443 } else { |
1444 CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V"); | 1444 CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V"); |
1445 if (pV != NULL) { | 1445 if (pV != NULL) { |
1446 pFieldDict->SetAt("V", pV->Clone(TRUE)); | 1446 pFieldDict->SetAt("V", pV->Clone(true)); |
1447 } | 1447 } |
1448 } | 1448 } |
1449 pFields->Add(pFieldDict); | 1449 pFields->Add(pFieldDict); |
1450 } | 1450 } |
1451 } | 1451 } |
1452 return pDoc; | 1452 return pDoc; |
1453 } | 1453 } |
1454 const struct _SupportFieldEncoding { | 1454 const struct _SupportFieldEncoding { |
1455 const FX_CHAR* m_name; | 1455 const FX_CHAR* m_name; |
1456 int32_t m_codePage; | 1456 int32_t m_codePage; |
(...skipping 19 matching lines...) Expand all Loading... |
1476 csValue.ConvertFrom(csBValue, pCharMap); | 1476 csValue.ConvertFrom(csBValue, pCharMap); |
1477 return; | 1477 return; |
1478 } | 1478 } |
1479 CFX_ByteString csTemp = csBValue.Left(2); | 1479 CFX_ByteString csTemp = csBValue.Left(2); |
1480 if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF") { | 1480 if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF") { |
1481 csValue = PDF_DecodeText(csBValue); | 1481 csValue = PDF_DecodeText(csBValue); |
1482 } else { | 1482 } else { |
1483 csValue = CFX_WideString::FromLocal(csBValue); | 1483 csValue = CFX_WideString::FromLocal(csBValue); |
1484 } | 1484 } |
1485 } | 1485 } |
1486 void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, const CFX_Wide
String& parent_name, FX_BOOL bNotify, int nLevel) | 1486 void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, const CFX_Wide
String& parent_name, bool bNotify, int nLevel) |
1487 { | 1487 { |
1488 CFX_WideString name; | 1488 CFX_WideString name; |
1489 if (!parent_name.IsEmpty()) { | 1489 if (!parent_name.IsEmpty()) { |
1490 name = parent_name + L"."; | 1490 name = parent_name + L"."; |
1491 } | 1491 } |
1492 name += pFieldDict->GetUnicodeText("T"); | 1492 name += pFieldDict->GetUnicodeText("T"); |
1493 CPDF_Array* pKids = pFieldDict->GetArray("Kids"); | 1493 CPDF_Array* pKids = pFieldDict->GetArray("Kids"); |
1494 if (pKids) { | 1494 if (pKids) { |
1495 for (FX_DWORD i = 0; i < pKids->GetCount(); i ++) { | 1495 for (FX_DWORD i = 0; i < pKids->GetCount(); i ++) { |
1496 CPDF_Dictionary* pKid = pKids->GetDict(i); | 1496 CPDF_Dictionary* pKid = pKids->GetDict(i); |
(...skipping 27 matching lines...) Expand all Loading... |
1524 return; | 1524 return; |
1525 } | 1525 } |
1526 } | 1526 } |
1527 CFX_ByteArray statusArray; | 1527 CFX_ByteArray statusArray; |
1528 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { | 1528 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { |
1529 SaveCheckedFieldStatus(pField, statusArray); | 1529 SaveCheckedFieldStatus(pField, statusArray); |
1530 } | 1530 } |
1531 pField->SetValue(csWValue); | 1531 pField->SetValue(csWValue); |
1532 CPDF_FormField::Type eType = pField->GetType(); | 1532 CPDF_FormField::Type eType = pField->GetType(); |
1533 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox)
&& pFieldDict->KeyExist("Opt")) { | 1533 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox)
&& pFieldDict->KeyExist("Opt")) { |
1534 pField->m_pDict->SetAt("Opt", pFieldDict->GetElementValue("Opt")->Clone(
TRUE)); | 1534 pField->m_pDict->SetAt("Opt", pFieldDict->GetElementValue("Opt")->Clone(
true)); |
1535 } | 1535 } |
1536 if (bNotify && m_pFormNotify != NULL) { | 1536 if (bNotify && m_pFormNotify != NULL) { |
1537 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { | 1537 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { |
1538 m_pFormNotify->AfterCheckedStatusChange(pField, statusArray); | 1538 m_pFormNotify->AfterCheckedStatusChange(pField, statusArray); |
1539 } else if (iType == FIELDTYPE_LISTBOX) { | 1539 } else if (iType == FIELDTYPE_LISTBOX) { |
1540 m_pFormNotify->AfterSelectionChange(pField); | 1540 m_pFormNotify->AfterSelectionChange(pField); |
1541 } else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD)
{ | 1541 } else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD)
{ |
1542 m_pFormNotify->AfterValueChange(pField); | 1542 m_pFormNotify->AfterValueChange(pField); |
1543 } | 1543 } |
1544 } | 1544 } |
1545 if (CPDF_InterForm::m_bUpdateAP) { | 1545 if (CPDF_InterForm::m_bUpdateAP) { |
1546 pField->UpdateAP(NULL); | 1546 pField->UpdateAP(NULL); |
1547 } | 1547 } |
1548 } | 1548 } |
1549 FX_BOOL CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF, FX_BOOL bNotify
) | 1549 bool CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF, bool bNotify) |
1550 { | 1550 { |
1551 if (pFDF == NULL) { | 1551 if (pFDF == NULL) { |
1552 return FALSE; | 1552 return false; |
1553 } | 1553 } |
1554 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); | 1554 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); |
1555 if (pMainDict == NULL) { | 1555 if (pMainDict == NULL) { |
1556 return FALSE; | 1556 return false; |
1557 } | 1557 } |
1558 CPDF_Array* pFields = pMainDict->GetArray("Fields"); | 1558 CPDF_Array* pFields = pMainDict->GetArray("Fields"); |
1559 if (pFields == NULL) { | 1559 if (pFields == NULL) { |
1560 return FALSE; | 1560 return false; |
1561 } | 1561 } |
1562 m_bsEncoding = pMainDict->GetString(FX_BSTRC("Encoding")); | 1562 m_bsEncoding = pMainDict->GetString(FX_BSTRC("Encoding")); |
1563 if (bNotify && m_pFormNotify != NULL) { | 1563 if (bNotify && m_pFormNotify != NULL) { |
1564 int iRet = m_pFormNotify->BeforeFormImportData(this); | 1564 int iRet = m_pFormNotify->BeforeFormImportData(this); |
1565 if (iRet < 0) { | 1565 if (iRet < 0) { |
1566 return FALSE; | 1566 return false; |
1567 } | 1567 } |
1568 } | 1568 } |
1569 for (FX_DWORD i = 0; i < pFields->GetCount(); i ++) { | 1569 for (FX_DWORD i = 0; i < pFields->GetCount(); i ++) { |
1570 CPDF_Dictionary* pField = pFields->GetDict(i); | 1570 CPDF_Dictionary* pField = pFields->GetDict(i); |
1571 if (pField == NULL) { | 1571 if (pField == NULL) { |
1572 continue; | 1572 continue; |
1573 } | 1573 } |
1574 FDF_ImportField(pField, L"", bNotify); | 1574 FDF_ImportField(pField, L"", bNotify); |
1575 } | 1575 } |
1576 if (bNotify && m_pFormNotify != NULL) { | 1576 if (bNotify && m_pFormNotify != NULL) { |
1577 m_pFormNotify->AfterFormImportData(this); | 1577 m_pFormNotify->AfterFormImportData(this); |
1578 } | 1578 } |
1579 return TRUE; | 1579 return true; |
1580 } | 1580 } |
1581 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) | 1581 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) |
1582 { | 1582 { |
1583 m_pFormNotify = (CPDF_FormNotify*)pNotify; | 1583 m_pFormNotify = (CPDF_FormNotify*)pNotify; |
1584 } | 1584 } |
1585 int CPDF_InterForm::GetPageWithWidget(int iCurPage, FX_BOOL bNext) | 1585 int CPDF_InterForm::GetPageWithWidget(int iCurPage, bool bNext) |
1586 { | 1586 { |
1587 if (iCurPage < 0) { | 1587 if (iCurPage < 0) { |
1588 return -1; | 1588 return -1; |
1589 } | 1589 } |
1590 int iPageCount = m_pDocument->GetPageCount(); | 1590 int iPageCount = m_pDocument->GetPageCount(); |
1591 if (iCurPage >= iPageCount) { | 1591 if (iCurPage >= iPageCount) { |
1592 return -1; | 1592 return -1; |
1593 } | 1593 } |
1594 int iNewPage = iCurPage; | 1594 int iNewPage = iCurPage; |
1595 do { | 1595 do { |
(...skipping 19 matching lines...) Expand all Loading... |
1615 for (FX_DWORD i = 0; i < dwCount; i ++) { | 1615 for (FX_DWORD i = 0; i < dwCount; i ++) { |
1616 CPDF_Object* pAnnotDict = pAnnots->GetElementValue(i); | 1616 CPDF_Object* pAnnotDict = pAnnots->GetElementValue(i); |
1617 if (pAnnotDict == NULL) { | 1617 if (pAnnotDict == NULL) { |
1618 continue; | 1618 continue; |
1619 } | 1619 } |
1620 CPDF_FormControl* pControl = NULL; | 1620 CPDF_FormControl* pControl = NULL; |
1621 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) { | 1621 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) { |
1622 return iNewPage; | 1622 return iNewPage; |
1623 } | 1623 } |
1624 } | 1624 } |
1625 } while (TRUE); | 1625 } while (true); |
1626 return -1; | 1626 return -1; |
1627 } | 1627 } |
OLD | NEW |