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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 9 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
10 #include "fpdfsdk/include/fsdk_actionhandler.h" | 10 #include "fpdfsdk/include/fsdk_actionhandler.h" |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 if (pImageDict->GetString("Name").IsEmpty()) | 487 if (pImageDict->GetString("Name").IsEmpty()) |
488 pImageDict->SetAtString("Name", "ImgC"); | 488 pImageDict->SetAtString("Name", "ImgC"); |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 CPDF_IconFit iconFit = pControl->GetIconFit(); | 492 CPDF_IconFit iconFit = pControl->GetIconFit(); |
493 | 493 |
494 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 494 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
495 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 495 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
496 | 496 |
497 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 497 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
498 FontMap.Initial(); | 498 font_map.SetAPType("N"); |
499 | |
500 FontMap.SetAPType("N"); | |
501 | 499 |
502 CFX_ByteString csAP = | 500 CFX_ByteString csAP = |
503 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + | 501 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
504 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 502 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
505 crLeftTop, crRightBottom, nBorderStyle, | 503 crLeftTop, crRightBottom, nBorderStyle, |
506 dsBorder) + | 504 dsBorder) + |
507 CPWL_Utils::GetPushButtonAppStream( | 505 CPWL_Utils::GetPushButtonAppStream( |
508 iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, | 506 iconFit.GetFittingBounds() ? rcWindow : rcClient, &font_map, |
509 pNormalIcon, iconFit, csNormalCaption, crText, fFontSize, nLayout); | 507 pNormalIcon, iconFit, csNormalCaption, crText, fFontSize, nLayout); |
510 | 508 |
511 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP); | 509 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP); |
512 if (pNormalIcon) | 510 if (pNormalIcon) |
513 AddImageToAppearance("N", pNormalIcon); | 511 AddImageToAppearance("N", pNormalIcon); |
514 | 512 |
515 CPDF_FormControl::HighlightingMode eHLM = pControl->GetHighlightingMode(); | 513 CPDF_FormControl::HighlightingMode eHLM = pControl->GetHighlightingMode(); |
516 if (eHLM == CPDF_FormControl::Push || eHLM == CPDF_FormControl::Toggle) { | 514 if (eHLM == CPDF_FormControl::Push || eHLM == CPDF_FormControl::Toggle) { |
517 if (csRolloverCaption.IsEmpty() && !pRolloverIcon) { | 515 if (csRolloverCaption.IsEmpty() && !pRolloverIcon) { |
518 csRolloverCaption = csNormalCaption; | 516 csRolloverCaption = csNormalCaption; |
519 pRolloverIcon = pNormalIcon; | 517 pRolloverIcon = pNormalIcon; |
520 } | 518 } |
521 | 519 |
522 FontMap.SetAPType("R"); | 520 font_map.SetAPType("R"); |
523 | 521 |
524 csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + | 522 csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
525 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 523 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
526 crLeftTop, crRightBottom, | 524 crLeftTop, crRightBottom, |
527 nBorderStyle, dsBorder) + | 525 nBorderStyle, dsBorder) + |
528 CPWL_Utils::GetPushButtonAppStream( | 526 CPWL_Utils::GetPushButtonAppStream( |
529 iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, | 527 iconFit.GetFittingBounds() ? rcWindow : rcClient, &font_map, |
530 pRolloverIcon, iconFit, csRolloverCaption, crText, fFontSize, | 528 pRolloverIcon, iconFit, csRolloverCaption, crText, fFontSize, |
531 nLayout); | 529 nLayout); |
532 | 530 |
533 WriteAppearance("R", GetRotatedRect(), GetMatrix(), csAP); | 531 WriteAppearance("R", GetRotatedRect(), GetMatrix(), csAP); |
534 if (pRolloverIcon) | 532 if (pRolloverIcon) |
535 AddImageToAppearance("R", pRolloverIcon); | 533 AddImageToAppearance("R", pRolloverIcon); |
536 | 534 |
537 if (csDownCaption.IsEmpty() && !pDownIcon) { | 535 if (csDownCaption.IsEmpty() && !pDownIcon) { |
538 csDownCaption = csNormalCaption; | 536 csDownCaption = csNormalCaption; |
539 pDownIcon = pNormalIcon; | 537 pDownIcon = pNormalIcon; |
540 } | 538 } |
541 | 539 |
542 switch (nBorderStyle) { | 540 switch (nBorderStyle) { |
543 case PBS_BEVELED: { | 541 case PBS_BEVELED: { |
544 CPWL_Color crTemp = crLeftTop; | 542 CPWL_Color crTemp = crLeftTop; |
545 crLeftTop = crRightBottom; | 543 crLeftTop = crRightBottom; |
546 crRightBottom = crTemp; | 544 crRightBottom = crTemp; |
547 } break; | 545 } break; |
548 case PBS_INSET: | 546 case PBS_INSET: |
549 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); | 547 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); |
550 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); | 548 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); |
551 break; | 549 break; |
552 } | 550 } |
553 | 551 |
554 FontMap.SetAPType("D"); | 552 font_map.SetAPType("D"); |
555 | 553 |
556 csAP = CPWL_Utils::GetRectFillAppStream( | 554 csAP = CPWL_Utils::GetRectFillAppStream( |
557 rcWindow, CPWL_Utils::SubstractColor(crBackground, 0.25f)) + | 555 rcWindow, CPWL_Utils::SubstractColor(crBackground, 0.25f)) + |
558 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 556 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
559 crLeftTop, crRightBottom, | 557 crLeftTop, crRightBottom, |
560 nBorderStyle, dsBorder) + | 558 nBorderStyle, dsBorder) + |
561 CPWL_Utils::GetPushButtonAppStream( | 559 CPWL_Utils::GetPushButtonAppStream( |
562 iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, | 560 iconFit.GetFittingBounds() ? rcWindow : rcClient, &font_map, |
563 pDownIcon, iconFit, csDownCaption, crText, fFontSize, nLayout); | 561 pDownIcon, iconFit, csDownCaption, crText, fFontSize, nLayout); |
564 | 562 |
565 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP); | 563 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP); |
566 if (pDownIcon) | 564 if (pDownIcon) |
567 AddImageToAppearance("D", pDownIcon); | 565 AddImageToAppearance("D", pDownIcon); |
568 } else { | 566 } else { |
569 RemoveAppearance("D"); | 567 RemoveAppearance("D"); |
570 RemoveAppearance("R"); | 568 RemoveAppearance("R"); |
571 } | 569 } |
572 } | 570 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 CPDF_Rect rcClient = GetClientRect(); | 866 CPDF_Rect rcClient = GetClientRect(); |
869 CPDF_Rect rcButton = rcClient; | 867 CPDF_Rect rcButton = rcClient; |
870 rcButton.left = rcButton.right - 13; | 868 rcButton.left = rcButton.right - 13; |
871 rcButton.Normalize(); | 869 rcButton.Normalize(); |
872 | 870 |
873 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 871 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
874 pEdit->EnableRefresh(FALSE); | 872 pEdit->EnableRefresh(FALSE); |
875 | 873 |
876 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 874 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
877 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 875 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
878 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 876 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
879 FontMap.Initial(); | 877 pEdit->SetFontMap(&font_map); |
880 pEdit->SetFontMap(&FontMap); | |
881 | 878 |
882 CPDF_Rect rcEdit = rcClient; | 879 CPDF_Rect rcEdit = rcClient; |
883 rcEdit.right = rcButton.left; | 880 rcEdit.right = rcButton.left; |
884 rcEdit.Normalize(); | 881 rcEdit.Normalize(); |
885 | 882 |
886 pEdit->SetPlateRect(rcEdit); | 883 pEdit->SetPlateRect(rcEdit); |
887 pEdit->SetAlignmentV(1); | 884 pEdit->SetAlignmentV(1); |
888 | 885 |
889 FX_FLOAT fFontSize = GetFontSize(); | 886 FX_FLOAT fFontSize = GetFontSize(); |
890 if (IsFloatZero(fFontSize)) | 887 if (IsFloatZero(fFontSize)) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 CPDF_FormField* pField = pControl->GetField(); | 937 CPDF_FormField* pField = pControl->GetField(); |
941 CPDF_Rect rcClient = GetClientRect(); | 938 CPDF_Rect rcClient = GetClientRect(); |
942 CFX_ByteTextBuf sBody, sLines; | 939 CFX_ByteTextBuf sBody, sLines; |
943 | 940 |
944 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 941 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
945 pEdit->EnableRefresh(FALSE); | 942 pEdit->EnableRefresh(FALSE); |
946 | 943 |
947 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 944 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
948 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 945 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
949 | 946 |
950 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 947 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
951 FontMap.Initial(); | 948 pEdit->SetFontMap(&font_map); |
952 pEdit->SetFontMap(&FontMap); | |
953 | 949 |
954 pEdit->SetPlateRect(CPDF_Rect(rcClient.left, 0.0f, rcClient.right, 0.0f)); | 950 pEdit->SetPlateRect(CPDF_Rect(rcClient.left, 0.0f, rcClient.right, 0.0f)); |
955 | 951 |
956 FX_FLOAT fFontSize = GetFontSize(); | 952 FX_FLOAT fFontSize = GetFontSize(); |
957 | 953 |
958 if (IsFloatZero(fFontSize)) | 954 if (IsFloatZero(fFontSize)) |
959 pEdit->SetFontSize(12.0f); | 955 pEdit->SetFontSize(12.0f); |
960 else | 956 else |
961 pEdit->SetFontSize(fFontSize); | 957 pEdit->SetFontSize(fFontSize); |
962 | 958 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 CPDF_FormControl* pControl = GetFormControl(); | 1024 CPDF_FormControl* pControl = GetFormControl(); |
1029 CPDF_FormField* pField = pControl->GetField(); | 1025 CPDF_FormField* pField = pControl->GetField(); |
1030 CFX_ByteTextBuf sBody, sLines; | 1026 CFX_ByteTextBuf sBody, sLines; |
1031 | 1027 |
1032 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 1028 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
1033 pEdit->EnableRefresh(FALSE); | 1029 pEdit->EnableRefresh(FALSE); |
1034 | 1030 |
1035 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1031 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1036 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1032 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
1037 | 1033 |
1038 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 1034 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
1039 FontMap.Initial(); | 1035 pEdit->SetFontMap(&font_map); |
1040 pEdit->SetFontMap(&FontMap); | |
1041 | 1036 |
1042 CPDF_Rect rcClient = GetClientRect(); | 1037 CPDF_Rect rcClient = GetClientRect(); |
1043 pEdit->SetPlateRect(rcClient); | 1038 pEdit->SetPlateRect(rcClient); |
1044 pEdit->SetAlignmentH(pControl->GetControlAlignment()); | 1039 pEdit->SetAlignmentH(pControl->GetControlAlignment()); |
1045 | 1040 |
1046 FX_DWORD dwFieldFlags = pField->GetFieldFlags(); | 1041 FX_DWORD dwFieldFlags = pField->GetFieldFlags(); |
1047 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; | 1042 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; |
1048 | 1043 |
1049 if (bMultiLine) { | 1044 if (bMultiLine) { |
1050 pEdit->SetMultiLine(TRUE); | 1045 pEdit->SetMultiLine(TRUE); |
(...skipping 10 matching lines...) Expand all Loading... |
1061 | 1056 |
1062 int nMaxLen = pField->GetMaxLen(); | 1057 int nMaxLen = pField->GetMaxLen(); |
1063 FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1; | 1058 FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1; |
1064 FX_FLOAT fFontSize = GetFontSize(); | 1059 FX_FLOAT fFontSize = GetFontSize(); |
1065 | 1060 |
1066 if (nMaxLen > 0) { | 1061 if (nMaxLen > 0) { |
1067 if (bCharArray) { | 1062 if (bCharArray) { |
1068 pEdit->SetCharArray(nMaxLen); | 1063 pEdit->SetCharArray(nMaxLen); |
1069 | 1064 |
1070 if (IsFloatZero(fFontSize)) { | 1065 if (IsFloatZero(fFontSize)) { |
1071 fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(FontMap.GetPDFFont(0), | 1066 fFontSize = CPWL_Edit::GetCharArrayAutoFontSize( |
1072 rcClient, nMaxLen); | 1067 font_map.GetPDFFont(0), rcClient, nMaxLen); |
1073 } | 1068 } |
1074 } else { | 1069 } else { |
1075 if (sValue) | 1070 if (sValue) |
1076 nMaxLen = wcslen((const wchar_t*)sValue); | 1071 nMaxLen = wcslen((const wchar_t*)sValue); |
1077 pEdit->SetLimitChar(nMaxLen); | 1072 pEdit->SetLimitChar(nMaxLen); |
1078 } | 1073 } |
1079 } | 1074 } |
1080 | 1075 |
1081 if (IsFloatZero(fFontSize)) | 1076 if (IsFloatZero(fFontSize)) |
1082 pEdit->SetAutoFontSize(TRUE); | 1077 pEdit->SetAutoFontSize(TRUE); |
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 break; | 2352 break; |
2358 } | 2353 } |
2359 } | 2354 } |
2360 } | 2355 } |
2361 | 2356 |
2362 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { | 2357 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { |
2363 CPDF_Rect rcAnnot; | 2358 CPDF_Rect rcAnnot; |
2364 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2359 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
2365 return rcAnnot; | 2360 return rcAnnot; |
2366 } | 2361 } |
OLD | NEW |