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

Side by Side Diff: fpdfsdk/cpdfsdk_widget.cpp

Issue 2397723005: Convert CPDFSDK_InterForm to take a CPDFSDK_FormFillEnvironment (Closed)
Patch Set: Rebase to master Created 4 years, 2 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 | « fpdfsdk/cpdfsdk_interform.cpp ('k') | fpdfsdk/javascript/Field.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "fpdfsdk/cpdfsdk_widget.h" 7 #include "fpdfsdk/cpdfsdk_widget.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 CPDFSDK_PageView* pPageView) { 845 CPDFSDK_PageView* pPageView) {
846 int nFieldType = GetFieldType(); 846 int nFieldType = GetFieldType();
847 if (!m_pInterForm->IsNeedHighLight(nFieldType)) 847 if (!m_pInterForm->IsNeedHighLight(nFieldType))
848 return; 848 return;
849 849
850 CFX_FloatRect rc = GetRect(); 850 CFX_FloatRect rc = GetRect();
851 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); 851 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType);
852 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); 852 uint8_t alpha = m_pInterForm->GetHighlightAlpha();
853 853
854 CFX_FloatRect rcDevice; 854 CFX_FloatRect rcDevice;
855 ASSERT(m_pInterForm->GetDocument()); 855 CPDFSDK_FormFillEnvironment* pEnv = m_pInterForm->GetFormFillEnv();
856 CPDFSDK_FormFillEnvironment* pEnv = m_pInterForm->GetDocument()->GetEnv();
857 if (!pEnv) 856 if (!pEnv)
858 return; 857 return;
858
859 CFX_Matrix page2device; 859 CFX_Matrix page2device;
860 pPageView->GetCurrentMatrix(page2device); 860 pPageView->GetCurrentMatrix(page2device);
861 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), 861 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom),
862 rcDevice.left, rcDevice.bottom); 862 rcDevice.left, rcDevice.bottom);
863 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), 863 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top),
864 rcDevice.right, rcDevice.top); 864 rcDevice.right, rcDevice.top);
865 865
866 rcDevice.Normalize(); 866 rcDevice.Normalize();
867 867
868 FX_ARGB argb = ArgbEncode((int)alpha, color); 868 FX_ARGB argb = ArgbEncode((int)alpha, color);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 992
993 if (pDownIcon) { 993 if (pDownIcon) {
994 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { 994 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) {
995 if (pImageDict->GetStringFor("Name").IsEmpty()) 995 if (pImageDict->GetStringFor("Name").IsEmpty())
996 pImageDict->SetStringFor("Name", "ImgC"); 996 pImageDict->SetStringFor("Name", "ImgC");
997 } 997 }
998 } 998 }
999 999
1000 CPDF_IconFit iconFit = pControl->GetIconFit(); 1000 CPDF_IconFit iconFit = pControl->GetIconFit();
1001 1001
1002 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); 1002 CBA_FontMap font_map(this, m_pInterForm->GetFormFillEnv()->GetSysHandler());
1003 CPDFSDK_FormFillEnvironment* pEnv = pDoc->GetEnv();
1004
1005 CBA_FontMap font_map(this, pEnv->GetSysHandler());
1006 font_map.SetAPType("N"); 1003 font_map.SetAPType("N");
1007 1004
1008 CFX_ByteString csAP = 1005 CFX_ByteString csAP =
1009 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + 1006 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
1010 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, 1007 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
1011 crLeftTop, crRightBottom, nBorderStyle, 1008 crLeftTop, crRightBottom, nBorderStyle,
1012 dsBorder) + 1009 dsBorder) +
1013 CPWL_Utils::GetPushButtonAppStream( 1010 CPWL_Utils::GetPushButtonAppStream(
1014 iconFit.GetFittingBounds() ? rcWindow : rcClient, &font_map, 1011 iconFit.GetFittingBounds() ? rcWindow : rcClient, &font_map,
1015 pNormalIcon, iconFit, csNormalCaption, crText, fFontSize, nLayout); 1012 pNormalIcon, iconFit, csNormalCaption, crText, fFontSize, nLayout);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 CFX_ByteTextBuf sBody, sLines; 1367 CFX_ByteTextBuf sBody, sLines;
1371 1368
1372 CFX_FloatRect rcClient = GetClientRect(); 1369 CFX_FloatRect rcClient = GetClientRect();
1373 CFX_FloatRect rcButton = rcClient; 1370 CFX_FloatRect rcButton = rcClient;
1374 rcButton.left = rcButton.right - 13; 1371 rcButton.left = rcButton.right - 13;
1375 rcButton.Normalize(); 1372 rcButton.Normalize();
1376 1373
1377 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); 1374 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit);
1378 pEdit->EnableRefresh(FALSE); 1375 pEdit->EnableRefresh(FALSE);
1379 1376
1380 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); 1377 CBA_FontMap font_map(this, m_pInterForm->GetFormFillEnv()->GetSysHandler());
1381 CPDFSDK_FormFillEnvironment* pEnv = pDoc->GetEnv();
1382 CBA_FontMap font_map(this, pEnv->GetSysHandler());
1383 pEdit->SetFontMap(&font_map); 1378 pEdit->SetFontMap(&font_map);
1384 1379
1385 CFX_FloatRect rcEdit = rcClient; 1380 CFX_FloatRect rcEdit = rcClient;
1386 rcEdit.right = rcButton.left; 1381 rcEdit.right = rcButton.left;
1387 rcEdit.Normalize(); 1382 rcEdit.Normalize();
1388 1383
1389 pEdit->SetPlateRect(rcEdit); 1384 pEdit->SetPlateRect(rcEdit);
1390 pEdit->SetAlignmentV(1, TRUE); 1385 pEdit->SetAlignmentV(1, TRUE);
1391 1386
1392 FX_FLOAT fFontSize = GetFontSize(); 1387 FX_FLOAT fFontSize = GetFontSize();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 1431
1437 void CPDFSDK_Widget::ResetAppearance_ListBox() { 1432 void CPDFSDK_Widget::ResetAppearance_ListBox() {
1438 CPDF_FormControl* pControl = GetFormControl(); 1433 CPDF_FormControl* pControl = GetFormControl();
1439 CPDF_FormField* pField = pControl->GetField(); 1434 CPDF_FormField* pField = pControl->GetField();
1440 CFX_FloatRect rcClient = GetClientRect(); 1435 CFX_FloatRect rcClient = GetClientRect();
1441 CFX_ByteTextBuf sBody, sLines; 1436 CFX_ByteTextBuf sBody, sLines;
1442 1437
1443 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); 1438 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit);
1444 pEdit->EnableRefresh(FALSE); 1439 pEdit->EnableRefresh(FALSE);
1445 1440
1446 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); 1441 CBA_FontMap font_map(this, m_pInterForm->GetFormFillEnv()->GetSysHandler());
1447 CPDFSDK_FormFillEnvironment* pEnv = pDoc->GetEnv();
1448
1449 CBA_FontMap font_map(this, pEnv->GetSysHandler());
1450 pEdit->SetFontMap(&font_map); 1442 pEdit->SetFontMap(&font_map);
1451 1443
1452 pEdit->SetPlateRect(CFX_FloatRect(rcClient.left, 0.0f, rcClient.right, 0.0f)); 1444 pEdit->SetPlateRect(CFX_FloatRect(rcClient.left, 0.0f, rcClient.right, 0.0f));
1453 1445
1454 FX_FLOAT fFontSize = GetFontSize(); 1446 FX_FLOAT fFontSize = GetFontSize();
1455 1447
1456 pEdit->SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); 1448 pEdit->SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize);
1457 1449
1458 pEdit->Initialize(); 1450 pEdit->Initialize();
1459 1451
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 } 1515 }
1524 1516
1525 void CPDFSDK_Widget::ResetAppearance_TextField(const CFX_WideString* sValue) { 1517 void CPDFSDK_Widget::ResetAppearance_TextField(const CFX_WideString* sValue) {
1526 CPDF_FormControl* pControl = GetFormControl(); 1518 CPDF_FormControl* pControl = GetFormControl();
1527 CPDF_FormField* pField = pControl->GetField(); 1519 CPDF_FormField* pField = pControl->GetField();
1528 CFX_ByteTextBuf sBody, sLines; 1520 CFX_ByteTextBuf sBody, sLines;
1529 1521
1530 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); 1522 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit);
1531 pEdit->EnableRefresh(FALSE); 1523 pEdit->EnableRefresh(FALSE);
1532 1524
1533 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); 1525 CBA_FontMap font_map(this, m_pInterForm->GetFormFillEnv()->GetSysHandler());
1534 CPDFSDK_FormFillEnvironment* pEnv = pDoc->GetEnv();
1535
1536 CBA_FontMap font_map(this, pEnv->GetSysHandler());
1537 pEdit->SetFontMap(&font_map); 1526 pEdit->SetFontMap(&font_map);
1538 1527
1539 CFX_FloatRect rcClient = GetClientRect(); 1528 CFX_FloatRect rcClient = GetClientRect();
1540 pEdit->SetPlateRect(rcClient); 1529 pEdit->SetPlateRect(rcClient);
1541 pEdit->SetAlignmentH(pControl->GetControlAlignment(), TRUE); 1530 pEdit->SetAlignmentH(pControl->GetControlAlignment(), TRUE);
1542 1531
1543 uint32_t dwFieldFlags = pField->GetFieldFlags(); 1532 uint32_t dwFieldFlags = pField->GetFieldFlags();
1544 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; 1533 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1;
1545 1534
1546 if (bMultiLine) { 1535 if (bMultiLine) {
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 return FALSE; 1936 return FALSE;
1948 1937
1949 if (!IsVisible()) 1938 if (!IsVisible())
1950 return FALSE; 1939 return FALSE;
1951 1940
1952 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) 1941 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
1953 return FALSE; 1942 return FALSE;
1954 1943
1955 return TRUE; 1944 return TRUE;
1956 } 1945 }
OLDNEW
« no previous file with comments | « fpdfsdk/cpdfsdk_interform.cpp ('k') | fpdfsdk/javascript/Field.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698