| 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 "fpdfsdk/include/fsdk_baseform.h" | 7 #include "fpdfsdk/include/fsdk_baseform.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 CPDF_Annot::AppearanceMode mode, | 809 CPDF_Annot::AppearanceMode mode, |
| 810 const CPDF_RenderOptions* pOptions) { | 810 const CPDF_RenderOptions* pOptions) { |
| 811 int nFieldType = GetFieldType(); | 811 int nFieldType = GetFieldType(); |
| 812 | 812 |
| 813 if ((nFieldType == FIELDTYPE_CHECKBOX || | 813 if ((nFieldType == FIELDTYPE_CHECKBOX || |
| 814 nFieldType == FIELDTYPE_RADIOBUTTON) && | 814 nFieldType == FIELDTYPE_RADIOBUTTON) && |
| 815 mode == CPDF_Annot::Normal && | 815 mode == CPDF_Annot::Normal && |
| 816 !IsWidgetAppearanceValid(CPDF_Annot::Normal)) { | 816 !IsWidgetAppearanceValid(CPDF_Annot::Normal)) { |
| 817 CFX_PathData pathData; | 817 CFX_PathData pathData; |
| 818 | 818 |
| 819 CFX_FloatRect rcAnnot = GetRect(); | 819 CPDF_Rect rcAnnot = GetRect(); |
| 820 | 820 |
| 821 pathData.AppendRect(rcAnnot.left, rcAnnot.bottom, rcAnnot.right, | 821 pathData.AppendRect(rcAnnot.left, rcAnnot.bottom, rcAnnot.right, |
| 822 rcAnnot.top); | 822 rcAnnot.top); |
| 823 | 823 |
| 824 CFX_GraphStateData gsd; | 824 CFX_GraphStateData gsd; |
| 825 gsd.m_LineWidth = 0.0f; | 825 gsd.m_LineWidth = 0.0f; |
| 826 | 826 |
| 827 pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, | 827 pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, |
| 828 FXFILL_ALTERNATE); | 828 FXFILL_ALTERNATE); |
| 829 } else { | 829 } else { |
| 830 CPDFSDK_BAAnnot::DrawAppearance(pDevice, pUser2Device, mode, pOptions); | 830 CPDFSDK_BAAnnot::DrawAppearance(pDevice, pUser2Device, mode, pOptions); |
| 831 } | 831 } |
| 832 } | 832 } |
| 833 | 833 |
| 834 void CPDFSDK_Widget::UpdateField() { | 834 void CPDFSDK_Widget::UpdateField() { |
| 835 CPDF_FormField* pFormField = GetFormField(); | 835 CPDF_FormField* pFormField = GetFormField(); |
| 836 ASSERT(pFormField); | 836 ASSERT(pFormField); |
| 837 m_pInterForm->UpdateField(pFormField); | 837 m_pInterForm->UpdateField(pFormField); |
| 838 } | 838 } |
| 839 | 839 |
| 840 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, | 840 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, |
| 841 CPDFSDK_PageView* pPageView) { | 841 CPDFSDK_PageView* pPageView) { |
| 842 int nFieldType = GetFieldType(); | 842 int nFieldType = GetFieldType(); |
| 843 if (m_pInterForm->IsNeedHighLight(nFieldType)) { | 843 if (m_pInterForm->IsNeedHighLight(nFieldType)) { |
| 844 CFX_FloatRect rc = GetRect(); | 844 CPDF_Rect rc = GetRect(); |
| 845 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); | 845 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); |
| 846 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); | 846 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); |
| 847 | 847 |
| 848 CFX_FloatRect rcDevice; | 848 CFX_FloatRect rcDevice; |
| 849 ASSERT(m_pInterForm->GetDocument()); | 849 ASSERT(m_pInterForm->GetDocument()); |
| 850 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); | 850 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); |
| 851 if (!pEnv) | 851 if (!pEnv) |
| 852 return; | 852 return; |
| 853 CFX_Matrix page2device; | 853 CFX_Matrix page2device; |
| 854 pPageView->GetCurrentMatrix(page2device); | 854 pPageView->GetCurrentMatrix(page2device); |
| 855 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), | 855 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), |
| 856 rcDevice.left, rcDevice.bottom); | 856 rcDevice.left, rcDevice.bottom); |
| 857 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), | 857 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), |
| 858 rcDevice.right, rcDevice.top); | 858 rcDevice.right, rcDevice.top); |
| 859 | 859 |
| 860 rcDevice.Normalize(); | 860 rcDevice.Normalize(); |
| 861 | 861 |
| 862 FX_ARGB argb = ArgbEncode((int)alpha, color); | 862 FX_ARGB argb = ArgbEncode((int)alpha, color); |
| 863 FX_RECT rcDev((int)rcDevice.left, (int)rcDevice.top, (int)rcDevice.right, | 863 FX_RECT rcDev((int)rcDevice.left, (int)rcDevice.top, (int)rcDevice.right, |
| 864 (int)rcDevice.bottom); | 864 (int)rcDevice.bottom); |
| 865 pDevice->FillRect(&rcDev, argb); | 865 pDevice->FillRect(&rcDev, argb); |
| 866 } | 866 } |
| 867 } | 867 } |
| 868 | 868 |
| 869 void CPDFSDK_Widget::ResetAppearance_PushButton() { | 869 void CPDFSDK_Widget::ResetAppearance_PushButton() { |
| 870 CPDF_FormControl* pControl = GetFormControl(); | 870 CPDF_FormControl* pControl = GetFormControl(); |
| 871 CFX_FloatRect rcWindow = GetRotatedRect(); | 871 CPDF_Rect rcWindow = GetRotatedRect(); |
| 872 int32_t nLayout = 0; | 872 int32_t nLayout = 0; |
| 873 switch (pControl->GetTextPosition()) { | 873 switch (pControl->GetTextPosition()) { |
| 874 case TEXTPOS_ICON: | 874 case TEXTPOS_ICON: |
| 875 nLayout = PPBL_ICON; | 875 nLayout = PPBL_ICON; |
| 876 break; | 876 break; |
| 877 case TEXTPOS_BELOW: | 877 case TEXTPOS_BELOW: |
| 878 nLayout = PPBL_ICONTOPLABELBOTTOM; | 878 nLayout = PPBL_ICONTOPLABELBOTTOM; |
| 879 break; | 879 break; |
| 880 case TEXTPOS_ABOVE: | 880 case TEXTPOS_ABOVE: |
| 881 nLayout = PPBL_LABELTOPICONBOTTOM; | 881 nLayout = PPBL_LABELTOPICONBOTTOM; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); | 930 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); |
| 931 break; | 931 break; |
| 932 case BBS_UNDERLINE: | 932 case BBS_UNDERLINE: |
| 933 nBorderStyle = PBS_UNDERLINED; | 933 nBorderStyle = PBS_UNDERLINED; |
| 934 break; | 934 break; |
| 935 default: | 935 default: |
| 936 nBorderStyle = PBS_SOLID; | 936 nBorderStyle = PBS_SOLID; |
| 937 break; | 937 break; |
| 938 } | 938 } |
| 939 | 939 |
| 940 CFX_FloatRect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); | 940 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); |
| 941 | 941 |
| 942 CPWL_Color crText(COLORTYPE_GRAY, 0); | 942 CPWL_Color crText(COLORTYPE_GRAY, 0); |
| 943 | 943 |
| 944 FX_FLOAT fFontSize = 12.0f; | 944 FX_FLOAT fFontSize = 12.0f; |
| 945 CFX_ByteString csNameTag; | 945 CFX_ByteString csNameTag; |
| 946 | 946 |
| 947 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); | 947 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); |
| 948 if (da.HasColor()) { | 948 if (da.HasColor()) { |
| 949 da.GetColor(iColorType, fc); | 949 da.GetColor(iColorType, fc); |
| 950 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 950 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); | 1118 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); |
| 1119 break; | 1119 break; |
| 1120 case BBS_UNDERLINE: | 1120 case BBS_UNDERLINE: |
| 1121 nBorderStyle = PBS_UNDERLINED; | 1121 nBorderStyle = PBS_UNDERLINED; |
| 1122 break; | 1122 break; |
| 1123 default: | 1123 default: |
| 1124 nBorderStyle = PBS_SOLID; | 1124 nBorderStyle = PBS_SOLID; |
| 1125 break; | 1125 break; |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 CFX_FloatRect rcWindow = GetRotatedRect(); | 1128 CPDF_Rect rcWindow = GetRotatedRect(); |
| 1129 CFX_FloatRect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); | 1129 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); |
| 1130 | 1130 |
| 1131 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); | 1131 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); |
| 1132 if (da.HasColor()) { | 1132 if (da.HasColor()) { |
| 1133 da.GetColor(iColorType, fc); | 1133 da.GetColor(iColorType, fc); |
| 1134 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1134 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1135 } | 1135 } |
| 1136 | 1136 |
| 1137 int32_t nStyle = 0; | 1137 int32_t nStyle = 0; |
| 1138 | 1138 |
| 1139 CFX_WideString csWCaption = pControl->GetNormalCaption(); | 1139 CFX_WideString csWCaption = pControl->GetNormalCaption(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); | 1244 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); |
| 1245 break; | 1245 break; |
| 1246 case BBS_UNDERLINE: | 1246 case BBS_UNDERLINE: |
| 1247 nBorderStyle = PBS_UNDERLINED; | 1247 nBorderStyle = PBS_UNDERLINED; |
| 1248 break; | 1248 break; |
| 1249 default: | 1249 default: |
| 1250 nBorderStyle = PBS_SOLID; | 1250 nBorderStyle = PBS_SOLID; |
| 1251 break; | 1251 break; |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 CFX_FloatRect rcWindow = GetRotatedRect(); | 1254 CPDF_Rect rcWindow = GetRotatedRect(); |
| 1255 CFX_FloatRect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); | 1255 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); |
| 1256 | 1256 |
| 1257 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); | 1257 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); |
| 1258 if (da.HasColor()) { | 1258 if (da.HasColor()) { |
| 1259 da.GetColor(iColorType, fc); | 1259 da.GetColor(iColorType, fc); |
| 1260 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1260 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1261 } | 1261 } |
| 1262 | 1262 |
| 1263 int32_t nStyle = 0; | 1263 int32_t nStyle = 0; |
| 1264 | 1264 |
| 1265 CFX_WideString csWCaption = pControl->GetNormalCaption(); | 1265 CFX_WideString csWCaption = pControl->GetNormalCaption(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1283 case L'4': | 1283 case L'4': |
| 1284 nStyle = PCS_CHECK; | 1284 nStyle = PCS_CHECK; |
| 1285 break; | 1285 break; |
| 1286 } | 1286 } |
| 1287 } else { | 1287 } else { |
| 1288 nStyle = PCS_CIRCLE; | 1288 nStyle = PCS_CIRCLE; |
| 1289 } | 1289 } |
| 1290 | 1290 |
| 1291 CFX_ByteString csAP_N_ON; | 1291 CFX_ByteString csAP_N_ON; |
| 1292 | 1292 |
| 1293 CFX_FloatRect rcCenter = | 1293 CPDF_Rect rcCenter = |
| 1294 CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare(rcWindow), 1.0f); | 1294 CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare(rcWindow), 1.0f); |
| 1295 | 1295 |
| 1296 if (nStyle == PCS_CIRCLE) { | 1296 if (nStyle == PCS_CIRCLE) { |
| 1297 if (nBorderStyle == PBS_BEVELED) { | 1297 if (nBorderStyle == PBS_BEVELED) { |
| 1298 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); | 1298 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); |
| 1299 crRightBottom = CPWL_Utils::SubstractColor(crBackground, 0.25f); | 1299 crRightBottom = CPWL_Utils::SubstractColor(crBackground, 0.25f); |
| 1300 } else if (nBorderStyle == PBS_INSET) { | 1300 } else if (nBorderStyle == PBS_INSET) { |
| 1301 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5f); | 1301 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5f); |
| 1302 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75f); | 1302 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75f); |
| 1303 } | 1303 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 CFX_ByteString csAS = GetAppState(); | 1368 CFX_ByteString csAS = GetAppState(); |
| 1369 if (csAS.IsEmpty()) | 1369 if (csAS.IsEmpty()) |
| 1370 SetAppState("Off"); | 1370 SetAppState("Off"); |
| 1371 } | 1371 } |
| 1372 | 1372 |
| 1373 void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) { | 1373 void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) { |
| 1374 CPDF_FormControl* pControl = GetFormControl(); | 1374 CPDF_FormControl* pControl = GetFormControl(); |
| 1375 CPDF_FormField* pField = pControl->GetField(); | 1375 CPDF_FormField* pField = pControl->GetField(); |
| 1376 CFX_ByteTextBuf sBody, sLines; | 1376 CFX_ByteTextBuf sBody, sLines; |
| 1377 | 1377 |
| 1378 CFX_FloatRect rcClient = GetClientRect(); | 1378 CPDF_Rect rcClient = GetClientRect(); |
| 1379 CFX_FloatRect rcButton = rcClient; | 1379 CPDF_Rect rcButton = rcClient; |
| 1380 rcButton.left = rcButton.right - 13; | 1380 rcButton.left = rcButton.right - 13; |
| 1381 rcButton.Normalize(); | 1381 rcButton.Normalize(); |
| 1382 | 1382 |
| 1383 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 1383 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
| 1384 pEdit->EnableRefresh(FALSE); | 1384 pEdit->EnableRefresh(FALSE); |
| 1385 | 1385 |
| 1386 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1386 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1387 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1387 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
| 1388 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1388 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
| 1389 pEdit->SetFontMap(&font_map); | 1389 pEdit->SetFontMap(&font_map); |
| 1390 | 1390 |
| 1391 CFX_FloatRect rcEdit = rcClient; | 1391 CPDF_Rect rcEdit = rcClient; |
| 1392 rcEdit.right = rcButton.left; | 1392 rcEdit.right = rcButton.left; |
| 1393 rcEdit.Normalize(); | 1393 rcEdit.Normalize(); |
| 1394 | 1394 |
| 1395 pEdit->SetPlateRect(rcEdit); | 1395 pEdit->SetPlateRect(rcEdit); |
| 1396 pEdit->SetAlignmentV(1); | 1396 pEdit->SetAlignmentV(1); |
| 1397 | 1397 |
| 1398 FX_FLOAT fFontSize = GetFontSize(); | 1398 FX_FLOAT fFontSize = GetFontSize(); |
| 1399 if (IsFloatZero(fFontSize)) | 1399 if (IsFloatZero(fFontSize)) |
| 1400 pEdit->SetAutoFontSize(TRUE); | 1400 pEdit->SetAutoFontSize(TRUE); |
| 1401 else | 1401 else |
| 1402 pEdit->SetFontSize(fFontSize); | 1402 pEdit->SetFontSize(fFontSize); |
| 1403 | 1403 |
| 1404 pEdit->Initialize(); | 1404 pEdit->Initialize(); |
| 1405 | 1405 |
| 1406 if (sValue) { | 1406 if (sValue) { |
| 1407 pEdit->SetText(sValue); | 1407 pEdit->SetText(sValue); |
| 1408 } else { | 1408 } else { |
| 1409 int32_t nCurSel = pField->GetSelectedIndex(0); | 1409 int32_t nCurSel = pField->GetSelectedIndex(0); |
| 1410 | 1410 |
| 1411 if (nCurSel < 0) | 1411 if (nCurSel < 0) |
| 1412 pEdit->SetText(pField->GetValue().c_str()); | 1412 pEdit->SetText(pField->GetValue().c_str()); |
| 1413 else | 1413 else |
| 1414 pEdit->SetText(pField->GetOptionLabel(nCurSel).c_str()); | 1414 pEdit->SetText(pField->GetOptionLabel(nCurSel).c_str()); |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 CFX_FloatRect rcContent = pEdit->GetContentRect(); | 1417 CPDF_Rect rcContent = pEdit->GetContentRect(); |
| 1418 | 1418 |
| 1419 CFX_ByteString sEdit = | 1419 CFX_ByteString sEdit = |
| 1420 CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f)); | 1420 CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f, 0.0f)); |
| 1421 if (sEdit.GetLength() > 0) { | 1421 if (sEdit.GetLength() > 0) { |
| 1422 sBody << "/Tx BMC\n" | 1422 sBody << "/Tx BMC\n" |
| 1423 << "q\n"; | 1423 << "q\n"; |
| 1424 if (rcContent.Width() > rcEdit.Width() || | 1424 if (rcContent.Width() > rcEdit.Width() || |
| 1425 rcContent.Height() > rcEdit.Height()) { | 1425 rcContent.Height() > rcEdit.Height()) { |
| 1426 sBody << rcEdit.left << " " << rcEdit.bottom << " " << rcEdit.Width() | 1426 sBody << rcEdit.left << " " << rcEdit.bottom << " " << rcEdit.Width() |
| 1427 << " " << rcEdit.Height() << " re\nW\nn\n"; | 1427 << " " << rcEdit.Height() << " re\nW\nn\n"; |
| 1428 } | 1428 } |
| 1429 | 1429 |
| 1430 CPWL_Color crText = GetTextPWLColor(); | 1430 CPWL_Color crText = GetTextPWLColor(); |
| 1431 sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit | 1431 sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit |
| 1432 << "ET\n" | 1432 << "ET\n" |
| 1433 << "Q\nEMC\n"; | 1433 << "Q\nEMC\n"; |
| 1434 } | 1434 } |
| 1435 | 1435 |
| 1436 IFX_Edit::DelEdit(pEdit); | 1436 IFX_Edit::DelEdit(pEdit); |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 sBody << CPWL_Utils::GetDropButtonAppStream(rcButton); | 1439 sBody << CPWL_Utils::GetDropButtonAppStream(rcButton); |
| 1440 | 1440 |
| 1441 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + | 1441 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + |
| 1442 sLines.GetByteString() + sBody.GetByteString(); | 1442 sLines.GetByteString() + sBody.GetByteString(); |
| 1443 | 1443 |
| 1444 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 1444 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
| 1445 } | 1445 } |
| 1446 | 1446 |
| 1447 void CPDFSDK_Widget::ResetAppearance_ListBox() { | 1447 void CPDFSDK_Widget::ResetAppearance_ListBox() { |
| 1448 CPDF_FormControl* pControl = GetFormControl(); | 1448 CPDF_FormControl* pControl = GetFormControl(); |
| 1449 CPDF_FormField* pField = pControl->GetField(); | 1449 CPDF_FormField* pField = pControl->GetField(); |
| 1450 CFX_FloatRect rcClient = GetClientRect(); | 1450 CPDF_Rect rcClient = GetClientRect(); |
| 1451 CFX_ByteTextBuf sBody, sLines; | 1451 CFX_ByteTextBuf sBody, sLines; |
| 1452 | 1452 |
| 1453 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 1453 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
| 1454 pEdit->EnableRefresh(FALSE); | 1454 pEdit->EnableRefresh(FALSE); |
| 1455 | 1455 |
| 1456 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1456 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1457 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1457 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
| 1458 | 1458 |
| 1459 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1459 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
| 1460 pEdit->SetFontMap(&font_map); | 1460 pEdit->SetFontMap(&font_map); |
| 1461 | 1461 |
| 1462 pEdit->SetPlateRect( | 1462 pEdit->SetPlateRect(CPDF_Rect(rcClient.left, 0.0f, rcClient.right, 0.0f)); |
| 1463 CFX_FloatRect(rcClient.left, 0.0f, rcClient.right, 0.0f)); | |
| 1464 | 1463 |
| 1465 FX_FLOAT fFontSize = GetFontSize(); | 1464 FX_FLOAT fFontSize = GetFontSize(); |
| 1466 | 1465 |
| 1467 if (IsFloatZero(fFontSize)) | 1466 if (IsFloatZero(fFontSize)) |
| 1468 pEdit->SetFontSize(12.0f); | 1467 pEdit->SetFontSize(12.0f); |
| 1469 else | 1468 else |
| 1470 pEdit->SetFontSize(fFontSize); | 1469 pEdit->SetFontSize(fFontSize); |
| 1471 | 1470 |
| 1472 pEdit->Initialize(); | 1471 pEdit->Initialize(); |
| 1473 | 1472 |
| 1474 CFX_ByteTextBuf sList; | 1473 CFX_ByteTextBuf sList; |
| 1475 FX_FLOAT fy = rcClient.top; | 1474 FX_FLOAT fy = rcClient.top; |
| 1476 | 1475 |
| 1477 int32_t nTop = pField->GetTopVisibleIndex(); | 1476 int32_t nTop = pField->GetTopVisibleIndex(); |
| 1478 int32_t nCount = pField->CountOptions(); | 1477 int32_t nCount = pField->CountOptions(); |
| 1479 int32_t nSelCount = pField->CountSelectedItems(); | 1478 int32_t nSelCount = pField->CountSelectedItems(); |
| 1480 | 1479 |
| 1481 for (int32_t i = nTop; i < nCount; i++) { | 1480 for (int32_t i = nTop; i < nCount; i++) { |
| 1482 FX_BOOL bSelected = FALSE; | 1481 FX_BOOL bSelected = FALSE; |
| 1483 for (int32_t j = 0; j < nSelCount; j++) { | 1482 for (int32_t j = 0; j < nSelCount; j++) { |
| 1484 if (pField->GetSelectedIndex(j) == i) { | 1483 if (pField->GetSelectedIndex(j) == i) { |
| 1485 bSelected = TRUE; | 1484 bSelected = TRUE; |
| 1486 break; | 1485 break; |
| 1487 } | 1486 } |
| 1488 } | 1487 } |
| 1489 | 1488 |
| 1490 pEdit->SetText(pField->GetOptionLabel(i).c_str()); | 1489 pEdit->SetText(pField->GetOptionLabel(i).c_str()); |
| 1491 | 1490 |
| 1492 CFX_FloatRect rcContent = pEdit->GetContentRect(); | 1491 CPDF_Rect rcContent = pEdit->GetContentRect(); |
| 1493 FX_FLOAT fItemHeight = rcContent.Height(); | 1492 FX_FLOAT fItemHeight = rcContent.Height(); |
| 1494 | 1493 |
| 1495 if (bSelected) { | 1494 if (bSelected) { |
| 1496 CFX_FloatRect rcItem = | 1495 CPDF_Rect rcItem = |
| 1497 CFX_FloatRect(rcClient.left, fy - fItemHeight, rcClient.right, fy); | 1496 CPDF_Rect(rcClient.left, fy - fItemHeight, rcClient.right, fy); |
| 1498 sList << "q\n" << CPWL_Utils::GetColorAppStream( | 1497 sList << "q\n" << CPWL_Utils::GetColorAppStream( |
| 1499 CPWL_Color(COLORTYPE_RGB, 0, 51.0f / 255.0f, | 1498 CPWL_Color(COLORTYPE_RGB, 0, 51.0f / 255.0f, |
| 1500 113.0f / 255.0f), | 1499 113.0f / 255.0f), |
| 1501 TRUE) | 1500 TRUE) |
| 1502 << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width() | 1501 << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width() |
| 1503 << " " << rcItem.Height() << " re f\n" | 1502 << " " << rcItem.Height() << " re f\n" |
| 1504 << "Q\n"; | 1503 << "Q\n"; |
| 1505 | 1504 |
| 1506 sList << "BT\n" << CPWL_Utils::GetColorAppStream( | 1505 sList << "BT\n" << CPWL_Utils::GetColorAppStream( |
| 1507 CPWL_Color(COLORTYPE_GRAY, 1), TRUE) | 1506 CPWL_Color(COLORTYPE_GRAY, 1), TRUE) |
| 1508 << CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, fy)) | 1507 << CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f, fy)) |
| 1509 << "ET\n"; | 1508 << "ET\n"; |
| 1510 } else { | 1509 } else { |
| 1511 CPWL_Color crText = GetTextPWLColor(); | 1510 CPWL_Color crText = GetTextPWLColor(); |
| 1512 sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) | 1511 sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) |
| 1513 << CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, fy)) | 1512 << CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f, fy)) |
| 1514 << "ET\n"; | 1513 << "ET\n"; |
| 1515 } | 1514 } |
| 1516 | 1515 |
| 1517 fy -= fItemHeight; | 1516 fy -= fItemHeight; |
| 1518 } | 1517 } |
| 1519 | 1518 |
| 1520 if (sList.GetSize() > 0) { | 1519 if (sList.GetSize() > 0) { |
| 1521 sBody << "/Tx BMC\n" | 1520 sBody << "/Tx BMC\n" |
| 1522 << "q\n" << rcClient.left << " " << rcClient.bottom << " " | 1521 << "q\n" << rcClient.left << " " << rcClient.bottom << " " |
| 1523 << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; | 1522 << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1540 | 1539 |
| 1541 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 1540 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
| 1542 pEdit->EnableRefresh(FALSE); | 1541 pEdit->EnableRefresh(FALSE); |
| 1543 | 1542 |
| 1544 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1543 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1545 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1544 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
| 1546 | 1545 |
| 1547 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1546 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
| 1548 pEdit->SetFontMap(&font_map); | 1547 pEdit->SetFontMap(&font_map); |
| 1549 | 1548 |
| 1550 CFX_FloatRect rcClient = GetClientRect(); | 1549 CPDF_Rect rcClient = GetClientRect(); |
| 1551 pEdit->SetPlateRect(rcClient); | 1550 pEdit->SetPlateRect(rcClient); |
| 1552 pEdit->SetAlignmentH(pControl->GetControlAlignment()); | 1551 pEdit->SetAlignmentH(pControl->GetControlAlignment()); |
| 1553 | 1552 |
| 1554 FX_DWORD dwFieldFlags = pField->GetFieldFlags(); | 1553 FX_DWORD dwFieldFlags = pField->GetFieldFlags(); |
| 1555 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; | 1554 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; |
| 1556 | 1555 |
| 1557 if (bMultiLine) { | 1556 if (bMultiLine) { |
| 1558 pEdit->SetMultiLine(TRUE); | 1557 pEdit->SetMultiLine(TRUE); |
| 1559 pEdit->SetAutoReturn(TRUE); | 1558 pEdit->SetAutoReturn(TRUE); |
| 1560 } else { | 1559 } else { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 else | 1598 else |
| 1600 pEdit->SetFontSize(fFontSize); | 1599 pEdit->SetFontSize(fFontSize); |
| 1601 | 1600 |
| 1602 pEdit->Initialize(); | 1601 pEdit->Initialize(); |
| 1603 | 1602 |
| 1604 if (sValue) | 1603 if (sValue) |
| 1605 pEdit->SetText(sValue); | 1604 pEdit->SetText(sValue); |
| 1606 else | 1605 else |
| 1607 pEdit->SetText(pField->GetValue().c_str()); | 1606 pEdit->SetText(pField->GetValue().c_str()); |
| 1608 | 1607 |
| 1609 CFX_FloatRect rcContent = pEdit->GetContentRect(); | 1608 CPDF_Rect rcContent = pEdit->GetContentRect(); |
| 1610 | 1609 |
| 1611 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream( | 1610 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream( |
| 1612 pEdit, CFX_FloatPoint(0.0f, 0.0f), NULL, !bCharArray, subWord); | 1611 pEdit, CPDF_Point(0.0f, 0.0f), NULL, !bCharArray, subWord); |
| 1613 | 1612 |
| 1614 if (sEdit.GetLength() > 0) { | 1613 if (sEdit.GetLength() > 0) { |
| 1615 sBody << "/Tx BMC\n" | 1614 sBody << "/Tx BMC\n" |
| 1616 << "q\n"; | 1615 << "q\n"; |
| 1617 if (rcContent.Width() > rcClient.Width() || | 1616 if (rcContent.Width() > rcClient.Width() || |
| 1618 rcContent.Height() > rcClient.Height()) { | 1617 rcContent.Height() > rcClient.Height()) { |
| 1619 sBody << rcClient.left << " " << rcClient.bottom << " " | 1618 sBody << rcClient.left << " " << rcClient.bottom << " " |
| 1620 << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; | 1619 << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; |
| 1621 } | 1620 } |
| 1622 CPWL_Color crText = GetTextPWLColor(); | 1621 CPWL_Color crText = GetTextPWLColor(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 } | 1673 } |
| 1675 | 1674 |
| 1676 IFX_Edit::DelEdit(pEdit); | 1675 IFX_Edit::DelEdit(pEdit); |
| 1677 } | 1676 } |
| 1678 | 1677 |
| 1679 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + | 1678 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + |
| 1680 sLines.GetByteString() + sBody.GetByteString(); | 1679 sLines.GetByteString() + sBody.GetByteString(); |
| 1681 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 1680 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
| 1682 } | 1681 } |
| 1683 | 1682 |
| 1684 CFX_FloatRect CPDFSDK_Widget::GetClientRect() const { | 1683 CPDF_Rect CPDFSDK_Widget::GetClientRect() const { |
| 1685 CFX_FloatRect rcWindow = GetRotatedRect(); | 1684 CPDF_Rect rcWindow = GetRotatedRect(); |
| 1686 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); | 1685 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); |
| 1687 switch (GetBorderStyle()) { | 1686 switch (GetBorderStyle()) { |
| 1688 case BBS_BEVELED: | 1687 case BBS_BEVELED: |
| 1689 case BBS_INSET: | 1688 case BBS_INSET: |
| 1690 fBorderWidth *= 2.0f; | 1689 fBorderWidth *= 2.0f; |
| 1691 break; | 1690 break; |
| 1692 } | 1691 } |
| 1693 | 1692 |
| 1694 return CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); | 1693 return CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); |
| 1695 } | 1694 } |
| 1696 | 1695 |
| 1697 CFX_FloatRect CPDFSDK_Widget::GetRotatedRect() const { | 1696 CPDF_Rect CPDFSDK_Widget::GetRotatedRect() const { |
| 1698 CFX_FloatRect rectAnnot = GetRect(); | 1697 CPDF_Rect rectAnnot = GetRect(); |
| 1699 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; | 1698 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; |
| 1700 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; | 1699 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; |
| 1701 | 1700 |
| 1702 CPDF_FormControl* pControl = GetFormControl(); | 1701 CPDF_FormControl* pControl = GetFormControl(); |
| 1703 CFX_FloatRect rcPDFWindow; | 1702 CPDF_Rect rcPDFWindow; |
| 1704 switch (abs(pControl->GetRotation() % 360)) { | 1703 switch (abs(pControl->GetRotation() % 360)) { |
| 1705 case 0: | 1704 case 0: |
| 1706 case 180: | 1705 case 180: |
| 1707 default: | 1706 default: |
| 1708 rcPDFWindow = CFX_FloatRect(0, 0, fWidth, fHeight); | 1707 rcPDFWindow = CPDF_Rect(0, 0, fWidth, fHeight); |
| 1709 break; | 1708 break; |
| 1710 case 90: | 1709 case 90: |
| 1711 case 270: | 1710 case 270: |
| 1712 rcPDFWindow = CFX_FloatRect(0, 0, fHeight, fWidth); | 1711 rcPDFWindow = CPDF_Rect(0, 0, fHeight, fWidth); |
| 1713 break; | 1712 break; |
| 1714 } | 1713 } |
| 1715 | 1714 |
| 1716 return rcPDFWindow; | 1715 return rcPDFWindow; |
| 1717 } | 1716 } |
| 1718 | 1717 |
| 1719 CFX_ByteString CPDFSDK_Widget::GetBackgroundAppStream() const { | 1718 CFX_ByteString CPDFSDK_Widget::GetBackgroundAppStream() const { |
| 1720 CPWL_Color crBackground = GetFillPWLColor(); | 1719 CPWL_Color crBackground = GetFillPWLColor(); |
| 1721 if (crBackground.nColorType != COLORTYPE_TRANSPARENT) { | 1720 if (crBackground.nColorType != COLORTYPE_TRANSPARENT) { |
| 1722 return CPWL_Utils::GetRectFillAppStream(GetRotatedRect(), crBackground); | 1721 return CPWL_Utils::GetRectFillAppStream(GetRotatedRect(), crBackground); |
| 1723 } | 1722 } |
| 1724 return ""; | 1723 return ""; |
| 1725 } | 1724 } |
| 1726 | 1725 |
| 1727 CFX_ByteString CPDFSDK_Widget::GetBorderAppStream() const { | 1726 CFX_ByteString CPDFSDK_Widget::GetBorderAppStream() const { |
| 1728 CFX_FloatRect rcWindow = GetRotatedRect(); | 1727 CPDF_Rect rcWindow = GetRotatedRect(); |
| 1729 CPWL_Color crBorder = GetBorderPWLColor(); | 1728 CPWL_Color crBorder = GetBorderPWLColor(); |
| 1730 CPWL_Color crBackground = GetFillPWLColor(); | 1729 CPWL_Color crBackground = GetFillPWLColor(); |
| 1731 CPWL_Color crLeftTop, crRightBottom; | 1730 CPWL_Color crLeftTop, crRightBottom; |
| 1732 | 1731 |
| 1733 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); | 1732 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); |
| 1734 int32_t nBorderStyle = 0; | 1733 int32_t nBorderStyle = 0; |
| 1735 CPWL_Dash dsBorder(3, 0, 0); | 1734 CPWL_Dash dsBorder(3, 0, 0); |
| 1736 | 1735 |
| 1737 switch (GetBorderStyle()) { | 1736 switch (GetBorderStyle()) { |
| 1738 case BBS_DASH: | 1737 case BBS_DASH: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1760 } | 1759 } |
| 1761 | 1760 |
| 1762 return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 1761 return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
| 1763 crLeftTop, crRightBottom, nBorderStyle, | 1762 crLeftTop, crRightBottom, nBorderStyle, |
| 1764 dsBorder); | 1763 dsBorder); |
| 1765 } | 1764 } |
| 1766 | 1765 |
| 1767 CFX_Matrix CPDFSDK_Widget::GetMatrix() const { | 1766 CFX_Matrix CPDFSDK_Widget::GetMatrix() const { |
| 1768 CFX_Matrix mt; | 1767 CFX_Matrix mt; |
| 1769 CPDF_FormControl* pControl = GetFormControl(); | 1768 CPDF_FormControl* pControl = GetFormControl(); |
| 1770 CFX_FloatRect rcAnnot = GetRect(); | 1769 CPDF_Rect rcAnnot = GetRect(); |
| 1771 FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left; | 1770 FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left; |
| 1772 FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom; | 1771 FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom; |
| 1773 | 1772 |
| 1774 switch (abs(pControl->GetRotation() % 360)) { | 1773 switch (abs(pControl->GetRotation() % 360)) { |
| 1775 case 0: | 1774 case 0: |
| 1776 default: | 1775 default: |
| 1777 mt = CFX_Matrix(1, 0, 0, 1, 0, 0); | 1776 mt = CFX_Matrix(1, 0, 0, 1, 0, 0); |
| 1778 break; | 1777 break; |
| 1779 case 90: | 1778 case 90: |
| 1780 mt = CFX_Matrix(0, 1, -1, 0, fWidth, 0); | 1779 mt = CFX_Matrix(0, 1, -1, 0, fWidth, 0); |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2779 CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); | 2778 CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); |
| 2780 if (pAnnot->GetType() == m_sType && pAnnot->GetSubType() == m_sSubType) | 2779 if (pAnnot->GetType() == m_sType && pAnnot->GetSubType() == m_sSubType) |
| 2781 sa.push_back(pAnnot); | 2780 sa.push_back(pAnnot); |
| 2782 } | 2781 } |
| 2783 | 2782 |
| 2784 std::sort(sa.begin(), sa.end(), CompareByLeftAscending); | 2783 std::sort(sa.begin(), sa.end(), CompareByLeftAscending); |
| 2785 while (!sa.empty()) { | 2784 while (!sa.empty()) { |
| 2786 int nLeftTopIndex = -1; | 2785 int nLeftTopIndex = -1; |
| 2787 FX_FLOAT fTop = 0.0f; | 2786 FX_FLOAT fTop = 0.0f; |
| 2788 for (int i = sa.size() - 1; i >= 0; i--) { | 2787 for (int i = sa.size() - 1; i >= 0; i--) { |
| 2789 CFX_FloatRect rcAnnot = GetAnnotRect(sa[i]); | 2788 CPDF_Rect rcAnnot = GetAnnotRect(sa[i]); |
| 2790 if (rcAnnot.top > fTop) { | 2789 if (rcAnnot.top > fTop) { |
| 2791 nLeftTopIndex = i; | 2790 nLeftTopIndex = i; |
| 2792 fTop = rcAnnot.top; | 2791 fTop = rcAnnot.top; |
| 2793 } | 2792 } |
| 2794 } | 2793 } |
| 2795 if (nLeftTopIndex >= 0) { | 2794 if (nLeftTopIndex >= 0) { |
| 2796 CPDFSDK_Annot* pLeftTopAnnot = sa[nLeftTopIndex]; | 2795 CPDFSDK_Annot* pLeftTopAnnot = sa[nLeftTopIndex]; |
| 2797 CFX_FloatRect rcLeftTop = GetAnnotRect(pLeftTopAnnot); | 2796 CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot); |
| 2798 m_Annots.push_back(pLeftTopAnnot); | 2797 m_Annots.push_back(pLeftTopAnnot); |
| 2799 sa.erase(sa.begin() + nLeftTopIndex); | 2798 sa.erase(sa.begin() + nLeftTopIndex); |
| 2800 | 2799 |
| 2801 std::vector<int> aSelect; | 2800 std::vector<int> aSelect; |
| 2802 for (int i = 0; i < sa.size(); ++i) { | 2801 for (int i = 0; i < sa.size(); ++i) { |
| 2803 CFX_FloatRect rcAnnot = GetAnnotRect(sa[i]); | 2802 CPDF_Rect rcAnnot = GetAnnotRect(sa[i]); |
| 2804 FX_FLOAT fCenterY = (rcAnnot.top + rcAnnot.bottom) / 2.0f; | 2803 FX_FLOAT fCenterY = (rcAnnot.top + rcAnnot.bottom) / 2.0f; |
| 2805 if (fCenterY > rcLeftTop.bottom && fCenterY < rcLeftTop.top) | 2804 if (fCenterY > rcLeftTop.bottom && fCenterY < rcLeftTop.top) |
| 2806 aSelect.push_back(i); | 2805 aSelect.push_back(i); |
| 2807 } | 2806 } |
| 2808 for (int i = 0; i < aSelect.size(); ++i) | 2807 for (int i = 0; i < aSelect.size(); ++i) |
| 2809 m_Annots.push_back(sa[aSelect[i]]); | 2808 m_Annots.push_back(sa[aSelect[i]]); |
| 2810 | 2809 |
| 2811 for (int i = aSelect.size() - 1; i >= 0; --i) | 2810 for (int i = aSelect.size() - 1; i >= 0; --i) |
| 2812 sa.erase(sa.begin() + aSelect[i]); | 2811 sa.erase(sa.begin() + aSelect[i]); |
| 2813 } | 2812 } |
| 2814 } | 2813 } |
| 2815 } break; | 2814 } break; |
| 2816 case COLUMN: { | 2815 case COLUMN: { |
| 2817 std::vector<CPDFSDK_Annot*> sa; | 2816 std::vector<CPDFSDK_Annot*> sa; |
| 2818 for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) { | 2817 for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) { |
| 2819 CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); | 2818 CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); |
| 2820 if (pAnnot->GetType() == m_sType && pAnnot->GetSubType() == m_sSubType) | 2819 if (pAnnot->GetType() == m_sType && pAnnot->GetSubType() == m_sSubType) |
| 2821 sa.push_back(pAnnot); | 2820 sa.push_back(pAnnot); |
| 2822 } | 2821 } |
| 2823 | 2822 |
| 2824 std::sort(sa.begin(), sa.end(), CompareByTopDescending); | 2823 std::sort(sa.begin(), sa.end(), CompareByTopDescending); |
| 2825 while (!sa.empty()) { | 2824 while (!sa.empty()) { |
| 2826 int nLeftTopIndex = -1; | 2825 int nLeftTopIndex = -1; |
| 2827 FX_FLOAT fLeft = -1.0f; | 2826 FX_FLOAT fLeft = -1.0f; |
| 2828 for (int i = sa.size() - 1; i >= 0; --i) { | 2827 for (int i = sa.size() - 1; i >= 0; --i) { |
| 2829 CFX_FloatRect rcAnnot = GetAnnotRect(sa[i]); | 2828 CPDF_Rect rcAnnot = GetAnnotRect(sa[i]); |
| 2830 if (fLeft < 0) { | 2829 if (fLeft < 0) { |
| 2831 nLeftTopIndex = 0; | 2830 nLeftTopIndex = 0; |
| 2832 fLeft = rcAnnot.left; | 2831 fLeft = rcAnnot.left; |
| 2833 } else if (rcAnnot.left < fLeft) { | 2832 } else if (rcAnnot.left < fLeft) { |
| 2834 nLeftTopIndex = i; | 2833 nLeftTopIndex = i; |
| 2835 fLeft = rcAnnot.left; | 2834 fLeft = rcAnnot.left; |
| 2836 } | 2835 } |
| 2837 } | 2836 } |
| 2838 | 2837 |
| 2839 if (nLeftTopIndex >= 0) { | 2838 if (nLeftTopIndex >= 0) { |
| 2840 CPDFSDK_Annot* pLeftTopAnnot = sa[nLeftTopIndex]; | 2839 CPDFSDK_Annot* pLeftTopAnnot = sa[nLeftTopIndex]; |
| 2841 CFX_FloatRect rcLeftTop = GetAnnotRect(pLeftTopAnnot); | 2840 CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot); |
| 2842 m_Annots.push_back(pLeftTopAnnot); | 2841 m_Annots.push_back(pLeftTopAnnot); |
| 2843 sa.erase(sa.begin() + nLeftTopIndex); | 2842 sa.erase(sa.begin() + nLeftTopIndex); |
| 2844 | 2843 |
| 2845 std::vector<int> aSelect; | 2844 std::vector<int> aSelect; |
| 2846 for (int i = 0; i < sa.size(); ++i) { | 2845 for (int i = 0; i < sa.size(); ++i) { |
| 2847 CFX_FloatRect rcAnnot = GetAnnotRect(sa[i]); | 2846 CPDF_Rect rcAnnot = GetAnnotRect(sa[i]); |
| 2848 FX_FLOAT fCenterX = (rcAnnot.left + rcAnnot.right) / 2.0f; | 2847 FX_FLOAT fCenterX = (rcAnnot.left + rcAnnot.right) / 2.0f; |
| 2849 if (fCenterX > rcLeftTop.left && fCenterX < rcLeftTop.right) | 2848 if (fCenterX > rcLeftTop.left && fCenterX < rcLeftTop.right) |
| 2850 aSelect.push_back(i); | 2849 aSelect.push_back(i); |
| 2851 } | 2850 } |
| 2852 for (int i = 0; i < aSelect.size(); ++i) | 2851 for (int i = 0; i < aSelect.size(); ++i) |
| 2853 m_Annots.push_back(sa[aSelect[i]]); | 2852 m_Annots.push_back(sa[aSelect[i]]); |
| 2854 | 2853 |
| 2855 for (int i = aSelect.size() - 1; i >= 0; --i) | 2854 for (int i = aSelect.size() - 1; i >= 0; --i) |
| 2856 sa.erase(sa.begin() + aSelect[i]); | 2855 sa.erase(sa.begin() + aSelect[i]); |
| 2857 } | 2856 } |
| 2858 } | 2857 } |
| 2859 break; | 2858 break; |
| 2860 } | 2859 } |
| 2861 } | 2860 } |
| 2862 } | 2861 } |
| 2863 | 2862 |
| 2864 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2863 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { |
| 2865 CFX_FloatRect rcAnnot; | 2864 CPDF_Rect rcAnnot; |
| 2866 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2865 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
| 2867 return rcAnnot; | 2866 return rcAnnot; |
| 2868 } | 2867 } |
| OLD | NEW |