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

Side by Side Diff: fpdfsdk/src/javascript/Field.cpp

Issue 1394103002: Wean CJS_Value off of v8::Isolate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "Field.h" 7 #include "Field.h"
8 8
9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment.
10 #include "../../include/javascript/IJavaScript.h" 10 #include "../../include/javascript/IJavaScript.h"
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 void Field::SetCommitOnSelChange(CPDFSDK_Document* pDocument, 1024 void Field::SetCommitOnSelChange(CPDFSDK_Document* pDocument,
1025 const CFX_WideString& swFieldName, 1025 const CFX_WideString& swFieldName,
1026 int nControlIndex, 1026 int nControlIndex,
1027 bool b) { 1027 bool b) {
1028 // Not supported. 1028 // Not supported.
1029 } 1029 }
1030 1030
1031 FX_BOOL Field::currentValueIndices(IJS_Context* cc, 1031 FX_BOOL Field::currentValueIndices(IJS_Context* cc,
1032 CJS_PropValue& vp, 1032 CJS_PropValue& vp,
1033 CFX_WideString& sError) { 1033 CFX_WideString& sError) {
1034 ASSERT(m_pDocument != NULL); 1034 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1035 1035
1036 if (vp.IsSetting()) { 1036 if (vp.IsSetting()) {
1037 if (!m_bCanSet) 1037 if (!m_bCanSet)
1038 return FALSE; 1038 return FALSE;
1039 1039
1040 CFX_DWordArray array; 1040 CFX_DWordArray array;
1041 1041
1042 if (vp.GetType() == CJS_Value::VT_number) { 1042 if (vp.GetType() == CJS_Value::VT_number) {
1043 int iSelecting = 0; 1043 int iSelecting = 0;
1044 vp >> iSelecting; 1044 vp >> iSelecting;
1045 array.Add(iSelecting); 1045 array.Add(iSelecting);
1046 } else if (vp.IsArrayObject()) { 1046 } else if (vp.IsArrayObject()) {
1047 CJS_Array SelArray(m_isolate); 1047 CJS_Array SelArray(pRuntime);
1048 CJS_Value SelValue(m_isolate); 1048 CJS_Value SelValue(pRuntime);
1049 int iSelecting; 1049 int iSelecting;
1050 vp >> SelArray; 1050 vp >> SelArray;
1051 for (int i = 0, sz = SelArray.GetLength(); i < sz; i++) { 1051 for (int i = 0, sz = SelArray.GetLength(); i < sz; i++) {
1052 SelArray.GetElement(i, SelValue); 1052 SelArray.GetElement(i, SelValue);
1053 iSelecting = SelValue.ToInt(); 1053 iSelecting = SelValue.ToInt();
1054 array.Add(iSelecting); 1054 array.Add(iSelecting);
1055 } 1055 }
1056 } 1056 }
1057 1057
1058 if (m_bDelay) { 1058 if (m_bDelay) {
(...skipping 11 matching lines...) Expand all
1070 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 1070 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
1071 ASSERT(pFormField != NULL); 1071 ASSERT(pFormField != NULL);
1072 1072
1073 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 1073 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
1074 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) 1074 pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
1075 return FALSE; 1075 return FALSE;
1076 1076
1077 if (pFormField->CountSelectedItems() == 1) 1077 if (pFormField->CountSelectedItems() == 1)
1078 vp << pFormField->GetSelectedIndex(0); 1078 vp << pFormField->GetSelectedIndex(0);
1079 else if (pFormField->CountSelectedItems() > 1) { 1079 else if (pFormField->CountSelectedItems() > 1) {
1080 CJS_Array SelArray(m_isolate); 1080 CJS_Array SelArray(pRuntime);
1081 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { 1081 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
1082 SelArray.SetElement( 1082 SelArray.SetElement(
1083 i, CJS_Value(m_isolate, pFormField->GetSelectedIndex(i))); 1083 i, CJS_Value(pRuntime, pFormField->GetSelectedIndex(i)));
1084 } 1084 }
1085 vp << SelArray; 1085 vp << SelArray;
1086 } else 1086 } else
1087 vp << -1; 1087 vp << -1;
1088 } 1088 }
1089 1089
1090 return TRUE; 1090 return TRUE;
1091 } 1091 }
1092 1092
1093 void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument, 1093 void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument,
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 else 1482 else
1483 vp << false; 1483 vp << false;
1484 } 1484 }
1485 1485
1486 return TRUE; 1486 return TRUE;
1487 } 1487 }
1488 1488
1489 FX_BOOL Field::exportValues(IJS_Context* cc, 1489 FX_BOOL Field::exportValues(IJS_Context* cc,
1490 CJS_PropValue& vp, 1490 CJS_PropValue& vp,
1491 CFX_WideString& sError) { 1491 CFX_WideString& sError) {
1492 ASSERT(m_pDocument != NULL);
1493
1494 CFX_PtrArray FieldArray; 1492 CFX_PtrArray FieldArray;
1495 GetFormFields(m_FieldName, FieldArray); 1493 GetFormFields(m_FieldName, FieldArray);
1496 if (FieldArray.GetSize() <= 0) 1494 if (FieldArray.GetSize() <= 0)
1497 return FALSE; 1495 return FALSE;
1498 1496
1499 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 1497 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
1500 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && 1498 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX &&
1501 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) 1499 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
1502 return FALSE; 1500 return FALSE;
1503 1501
1504 if (vp.IsSetting()) { 1502 if (vp.IsSetting()) {
1505 if (!m_bCanSet) 1503 if (!m_bCanSet)
1506 return FALSE; 1504 return FALSE;
1507 1505
1508 if (!vp.IsArrayObject()) 1506 if (!vp.IsArrayObject())
1509 return FALSE; 1507 return FALSE;
1510 } else { 1508 } else {
1511 CJS_Array ExportValusArray(m_isolate); 1509 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1510 CJS_Array ExportValusArray(pRuntime);
1512 if (m_nFormControlIndex < 0) { 1511 if (m_nFormControlIndex < 0) {
1513 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { 1512 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
1514 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1513 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1515 ExportValusArray.SetElement( 1514 ExportValusArray.SetElement(
1516 i, CJS_Value(m_isolate, pFormControl->GetExportValue().c_str())); 1515 i, CJS_Value(pRuntime, pFormControl->GetExportValue().c_str()));
1517 } 1516 }
1518 } else { 1517 } else {
1519 if (m_nFormControlIndex >= pFormField->CountControls()) 1518 if (m_nFormControlIndex >= pFormField->CountControls())
1520 return FALSE; 1519 return FALSE;
1521 1520
1522 CPDF_FormControl* pFormControl = 1521 CPDF_FormControl* pFormControl =
1523 pFormField->GetControl(m_nFormControlIndex); 1522 pFormField->GetControl(m_nFormControlIndex);
1524 if (!pFormControl) 1523 if (!pFormControl)
1525 return FALSE; 1524 return FALSE;
1526 1525
1527 ExportValusArray.SetElement( 1526 ExportValusArray.SetElement(
1528 0, CJS_Value(m_isolate, pFormControl->GetExportValue().c_str())); 1527 0, CJS_Value(pRuntime, pFormControl->GetExportValue().c_str()));
1529 } 1528 }
1530 vp << ExportValusArray; 1529 vp << ExportValusArray;
1531 } 1530 }
1532 return TRUE; 1531 return TRUE;
1533 } 1532 }
1534 1533
1535 FX_BOOL Field::fileSelect(IJS_Context* cc, 1534 FX_BOOL Field::fileSelect(IJS_Context* cc,
1536 CJS_PropValue& vp, 1535 CJS_PropValue& vp,
1537 CFX_WideString& sError) { 1536 CFX_WideString& sError) {
1538 ASSERT(m_pDocument != NULL); 1537 ASSERT(m_pDocument != NULL);
(...skipping 18 matching lines...) Expand all
1557 vp << true; 1556 vp << true;
1558 else 1557 else
1559 vp << false; 1558 vp << false;
1560 } 1559 }
1561 return TRUE; 1560 return TRUE;
1562 } 1561 }
1563 1562
1564 FX_BOOL Field::fillColor(IJS_Context* cc, 1563 FX_BOOL Field::fillColor(IJS_Context* cc,
1565 CJS_PropValue& vp, 1564 CJS_PropValue& vp,
1566 CFX_WideString& sError) { 1565 CFX_WideString& sError) {
1567 ASSERT(m_pDocument != NULL); 1566 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1568 1567 CJS_Array crArray(pRuntime);
1569 CJS_Array crArray(m_isolate);
1570
1571 CFX_PtrArray FieldArray; 1568 CFX_PtrArray FieldArray;
1572 GetFormFields(m_FieldName, FieldArray); 1569 GetFormFields(m_FieldName, FieldArray);
1573 if (FieldArray.GetSize() <= 0) 1570 if (FieldArray.GetSize() <= 0)
1574 return FALSE; 1571 return FALSE;
1575 1572
1576 if (vp.IsSetting()) { 1573 if (vp.IsSetting()) {
1577 if (!m_bCanSet) 1574 if (!m_bCanSet)
1578 return FALSE; 1575 return FALSE;
1579 1576
1580 if (!vp.IsArrayObject()) 1577 if (!vp.IsArrayObject())
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 return FALSE; 2011 return FALSE;
2015 2012
2016 vp << m_FieldName; 2013 vp << m_FieldName;
2017 2014
2018 return TRUE; 2015 return TRUE;
2019 } 2016 }
2020 2017
2021 FX_BOOL Field::numItems(IJS_Context* cc, 2018 FX_BOOL Field::numItems(IJS_Context* cc,
2022 CJS_PropValue& vp, 2019 CJS_PropValue& vp,
2023 CFX_WideString& sError) { 2020 CFX_WideString& sError) {
2021 if (!vp.IsGetting())
2022 return FALSE;
2023
2024 CFX_PtrArray FieldArray; 2024 CFX_PtrArray FieldArray;
2025 GetFormFields(m_FieldName, FieldArray); 2025 GetFormFields(m_FieldName, FieldArray);
2026 if (FieldArray.GetSize() <= 0) 2026 if (FieldArray.GetSize() <= 0)
2027 return FALSE; 2027 return FALSE;
2028 2028
2029 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 2029 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
2030 ASSERT(pFormField != NULL);
2031
2032 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 2030 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
2033 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) 2031 pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
2034 return FALSE; 2032 return FALSE;
2035 2033
2036 if (!vp.IsGetting())
2037 return FALSE;
2038
2039 vp << (int32_t)pFormField->CountOptions(); 2034 vp << (int32_t)pFormField->CountOptions();
2040
2041 return TRUE; 2035 return TRUE;
2042 } 2036 }
2043 2037
2044 FX_BOOL Field::page(IJS_Context* cc, 2038 FX_BOOL Field::page(IJS_Context* cc,
2045 CJS_PropValue& vp, 2039 CJS_PropValue& vp,
2046 CFX_WideString& sError) { 2040 CFX_WideString& sError) {
2047 if (!vp.IsGetting()) 2041 if (!vp.IsGetting())
2048 return FALSE; 2042 return FALSE;
2049 2043
2050 CFX_PtrArray FieldArray; 2044 CFX_PtrArray FieldArray;
2051 GetFormFields(m_FieldName, FieldArray); 2045 GetFormFields(m_FieldName, FieldArray);
2052 if (FieldArray.GetSize() <= 0) 2046 if (FieldArray.GetSize() <= 0)
2053 return FALSE; 2047 return FALSE;
2054 2048
2055 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 2049 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
2056 if (!pFormField) 2050 if (!pFormField)
2057 return FALSE; 2051 return FALSE;
2058 2052
2059 ASSERT(m_pDocument != NULL); 2053 CFX_PtrArray widgetArray;
2060
2061 CPDFSDK_InterForm* pInterForm = 2054 CPDFSDK_InterForm* pInterForm =
2062 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 2055 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
2063 ASSERT(pInterForm != NULL);
2064
2065 CFX_PtrArray widgetArray;
2066 pInterForm->GetWidgets(pFormField, widgetArray); 2056 pInterForm->GetWidgets(pFormField, widgetArray);
2067 2057
2068 if (widgetArray.GetSize() > 0) { 2058 if (widgetArray.GetSize() > 0) {
2069 CJS_Array PageArray(m_isolate); 2059 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2070 2060 CJS_Array PageArray(pRuntime);
2071 for (int i = 0, sz = widgetArray.GetSize(); i < sz; i++) { 2061 for (int i = 0, sz = widgetArray.GetSize(); i < sz; i++) {
2072 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgetArray.GetAt(i); 2062 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgetArray.GetAt(i);
2073 ASSERT(pWidget != NULL);
2074
2075 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); 2063 CPDFSDK_PageView* pPageView = pWidget->GetPageView();
2076 if (!pPageView) 2064 if (!pPageView)
2077 return FALSE; 2065 return FALSE;
2078 2066
2079 PageArray.SetElement( 2067 PageArray.SetElement(
2080 i, CJS_Value(m_isolate, (int32_t)pPageView->GetPageIndex())); 2068 i, CJS_Value(pRuntime, (int32_t)pPageView->GetPageIndex()));
2081 } 2069 }
2082 2070
2083 vp << PageArray; 2071 vp << PageArray;
2084 } else { 2072 } else {
2085 vp << (int32_t)-1; 2073 vp << (int32_t)-1;
2086 } 2074 }
2087 2075
2088 return TRUE; 2076 return TRUE;
2089 } 2077 }
2090 2078
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 else 2265 else
2278 vp << false; 2266 vp << false;
2279 } 2267 }
2280 2268
2281 return TRUE; 2269 return TRUE;
2282 } 2270 }
2283 2271
2284 FX_BOOL Field::rect(IJS_Context* cc, 2272 FX_BOOL Field::rect(IJS_Context* cc,
2285 CJS_PropValue& vp, 2273 CJS_PropValue& vp,
2286 CFX_WideString& sError) { 2274 CFX_WideString& sError) {
2287 ASSERT(m_pDocument != NULL); 2275 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2276 CJS_Value Upper_Leftx(pRuntime);
2277 CJS_Value Upper_Lefty(pRuntime);
2278 CJS_Value Lower_Rightx(pRuntime);
2279 CJS_Value Lower_Righty(pRuntime);
2288 2280
2289 if (vp.IsSetting()) { 2281 if (vp.IsSetting()) {
2290 if (!m_bCanSet) 2282 if (!m_bCanSet)
2291 return FALSE; 2283 return FALSE;
2292 if (!vp.IsArrayObject()) 2284 if (!vp.IsArrayObject())
2293 return FALSE; 2285 return FALSE;
2294 2286
2295 CJS_Array rcArray(m_isolate); 2287 CJS_Array rcArray(pRuntime);
2296 vp >> rcArray; 2288 vp >> rcArray;
2297 CJS_Value Upper_Leftx(m_isolate), Upper_Lefty(m_isolate),
2298 Lower_Rightx(m_isolate), Lower_Righty(m_isolate);
2299 rcArray.GetElement(0, Upper_Leftx); 2289 rcArray.GetElement(0, Upper_Leftx);
2300 rcArray.GetElement(1, Upper_Lefty); 2290 rcArray.GetElement(1, Upper_Lefty);
2301 rcArray.GetElement(2, Lower_Rightx); 2291 rcArray.GetElement(2, Lower_Rightx);
2302 rcArray.GetElement(3, Lower_Righty); 2292 rcArray.GetElement(3, Lower_Righty);
2303 2293
2304 FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f}; 2294 FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f};
2305 pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt(); 2295 pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt();
2306 pArray[1] = (FX_FLOAT)Lower_Righty.ToInt(); 2296 pArray[1] = (FX_FLOAT)Lower_Righty.ToInt();
2307 pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(); 2297 pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt();
2308 pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(); 2298 pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt();
2309 2299
2310 CPDF_Rect crRect(pArray); 2300 CPDF_Rect crRect(pArray);
2311
2312 if (m_bDelay) { 2301 if (m_bDelay) {
2313 AddDelay_Rect(FP_RECT, crRect); 2302 AddDelay_Rect(FP_RECT, crRect);
2314 } else { 2303 } else {
2315 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); 2304 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect);
2316 } 2305 }
2317 } else { 2306 } else {
2318 CFX_PtrArray FieldArray; 2307 CFX_PtrArray FieldArray;
2319 GetFormFields(m_FieldName, FieldArray); 2308 GetFormFields(m_FieldName, FieldArray);
2320 if (FieldArray.GetSize() <= 0) 2309 if (FieldArray.GetSize() <= 0)
2321 return FALSE; 2310 return FALSE;
2322 2311
2323 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 2312 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
2324 ASSERT(pFormField != NULL);
2325
2326 CPDFSDK_InterForm* pInterForm = 2313 CPDFSDK_InterForm* pInterForm =
2327 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 2314 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
2328 ASSERT(pInterForm != NULL);
2329
2330 CPDFSDK_Widget* pWidget = 2315 CPDFSDK_Widget* pWidget =
2331 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); 2316 pInterForm->GetWidget(GetSmartFieldControl(pFormField));
2332 if (!pWidget) 2317 if (!pWidget)
2333 return FALSE; 2318 return FALSE;
2334 2319
2335 CFX_FloatRect crRect = pWidget->GetRect(); 2320 CFX_FloatRect crRect = pWidget->GetRect();
2336 CJS_Value Upper_Leftx(m_isolate), Upper_Lefty(m_isolate),
2337 Lower_Rightx(m_isolate), Lower_Righty(m_isolate);
2338 Upper_Leftx = (int32_t)crRect.left; 2321 Upper_Leftx = (int32_t)crRect.left;
2339 Upper_Lefty = (int32_t)crRect.top; 2322 Upper_Lefty = (int32_t)crRect.top;
2340 Lower_Rightx = (int32_t)crRect.right; 2323 Lower_Rightx = (int32_t)crRect.right;
2341 Lower_Righty = (int32_t)crRect.bottom; 2324 Lower_Righty = (int32_t)crRect.bottom;
2342 2325
2343 CJS_Array rcArray(m_isolate); 2326 CJS_Array rcArray(pRuntime);
2344 rcArray.SetElement(0, Upper_Leftx); 2327 rcArray.SetElement(0, Upper_Leftx);
2345 rcArray.SetElement(1, Upper_Lefty); 2328 rcArray.SetElement(1, Upper_Lefty);
2346 rcArray.SetElement(2, Lower_Rightx); 2329 rcArray.SetElement(2, Lower_Rightx);
2347 rcArray.SetElement(3, Lower_Righty); 2330 rcArray.SetElement(3, Lower_Righty);
2348
2349 vp << rcArray; 2331 vp << rcArray;
2350 } 2332 }
2351
2352 return TRUE; 2333 return TRUE;
2353 } 2334 }
2354 2335
2355 void Field::SetRect(CPDFSDK_Document* pDocument, 2336 void Field::SetRect(CPDFSDK_Document* pDocument,
2356 const CFX_WideString& swFieldName, 2337 const CFX_WideString& swFieldName,
2357 int nControlIndex, 2338 int nControlIndex,
2358 const CPDF_Rect& rect) { 2339 const CPDF_Rect& rect) {
2359 ASSERT(pDocument != NULL); 2340 ASSERT(pDocument != NULL);
2360 2341
2361 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); 2342 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 void Field::SetRotation(CPDFSDK_Document* pDocument, 2546 void Field::SetRotation(CPDFSDK_Document* pDocument,
2566 const CFX_WideString& swFieldName, 2547 const CFX_WideString& swFieldName,
2567 int nControlIndex, 2548 int nControlIndex,
2568 int number) { 2549 int number) {
2569 // Not supported. 2550 // Not supported.
2570 } 2551 }
2571 2552
2572 FX_BOOL Field::strokeColor(IJS_Context* cc, 2553 FX_BOOL Field::strokeColor(IJS_Context* cc,
2573 CJS_PropValue& vp, 2554 CJS_PropValue& vp,
2574 CFX_WideString& sError) { 2555 CFX_WideString& sError) {
2575 ASSERT(m_pDocument != NULL); 2556 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2557 CJS_Array crArray(pRuntime);
2576 2558
2577 if (vp.IsSetting()) { 2559 if (vp.IsSetting()) {
2578 if (!m_bCanSet) 2560 if (!m_bCanSet)
2579 return FALSE; 2561 return FALSE;
2580 2562
2581 if (!vp.IsArrayObject()) 2563 if (!vp.IsArrayObject())
2582 return FALSE; 2564 return FALSE;
2583 2565
2584 CJS_Array crArray(m_isolate);
2585 vp >> crArray; 2566 vp >> crArray;
2586 2567
2587 CPWL_Color color; 2568 CPWL_Color color;
2588 color::ConvertArrayToPWLColor(crArray, color); 2569 color::ConvertArrayToPWLColor(crArray, color);
2589 2570
2590 if (m_bDelay) { 2571 if (m_bDelay) {
2591 AddDelay_Color(FP_STROKECOLOR, color); 2572 AddDelay_Color(FP_STROKECOLOR, color);
2592 } else { 2573 } else {
2593 Field::SetStrokeColor(m_pDocument, m_FieldName, m_nFormControlIndex, 2574 Field::SetStrokeColor(m_pDocument, m_FieldName, m_nFormControlIndex,
2594 color); 2575 color);
2595 } 2576 }
2596 } else { 2577 } else {
2597 CFX_PtrArray FieldArray; 2578 CFX_PtrArray FieldArray;
2598 GetFormFields(m_FieldName, FieldArray); 2579 GetFormFields(m_FieldName, FieldArray);
2599 if (FieldArray.GetSize() <= 0) 2580 if (FieldArray.GetSize() <= 0)
2600 return FALSE; 2581 return FALSE;
2601 2582
2602 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 2583 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
2603 ASSERT(pFormField != NULL);
2604
2605 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2584 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2606 if (!pFormControl) 2585 if (!pFormControl)
2607 return FALSE; 2586 return FALSE;
2608 2587
2609 int iColorType; 2588 int iColorType;
2610 pFormControl->GetBorderColor(iColorType); 2589 pFormControl->GetBorderColor(iColorType);
2611 2590
2612 CPWL_Color color; 2591 CPWL_Color color;
2613
2614 if (iColorType == COLORTYPE_TRANSPARENT) { 2592 if (iColorType == COLORTYPE_TRANSPARENT) {
2615 color = CPWL_Color(COLORTYPE_TRANSPARENT); 2593 color = CPWL_Color(COLORTYPE_TRANSPARENT);
2616 } else if (iColorType == COLORTYPE_GRAY) { 2594 } else if (iColorType == COLORTYPE_GRAY) {
2617 color = 2595 color =
2618 CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0)); 2596 CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0));
2619 } else if (iColorType == COLORTYPE_RGB) { 2597 } else if (iColorType == COLORTYPE_RGB) {
2620 color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0), 2598 color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0),
2621 pFormControl->GetOriginalBorderColor(1), 2599 pFormControl->GetOriginalBorderColor(1),
2622 pFormControl->GetOriginalBorderColor(2)); 2600 pFormControl->GetOriginalBorderColor(2));
2623 } else if (iColorType == COLORTYPE_CMYK) { 2601 } else if (iColorType == COLORTYPE_CMYK) {
2624 color = 2602 color =
2625 CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0), 2603 CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0),
2626 pFormControl->GetOriginalBorderColor(1), 2604 pFormControl->GetOriginalBorderColor(1),
2627 pFormControl->GetOriginalBorderColor(2), 2605 pFormControl->GetOriginalBorderColor(2),
2628 pFormControl->GetOriginalBorderColor(3)); 2606 pFormControl->GetOriginalBorderColor(3));
2629 } else 2607 } else
2630 return FALSE; 2608 return FALSE;
2631 2609
2632 CJS_Array crArray(m_isolate);
2633 color::ConvertPWLColorToArray(color, crArray); 2610 color::ConvertPWLColorToArray(color, crArray);
2634 vp << crArray; 2611 vp << crArray;
2635 } 2612 }
2636
2637 return TRUE; 2613 return TRUE;
2638 } 2614 }
2639 2615
2640 void Field::SetStrokeColor(CPDFSDK_Document* pDocument, 2616 void Field::SetStrokeColor(CPDFSDK_Document* pDocument,
2641 const CFX_WideString& swFieldName, 2617 const CFX_WideString& swFieldName,
2642 int nControlIndex, 2618 int nControlIndex,
2643 const CPWL_Color& color) { 2619 const CPWL_Color& color) {
2644 // Not supported. 2620 // Not supported.
2645 } 2621 }
2646 2622
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2717 2693
2718 FX_BOOL Field::submitName(IJS_Context* cc, 2694 FX_BOOL Field::submitName(IJS_Context* cc,
2719 CJS_PropValue& vp, 2695 CJS_PropValue& vp,
2720 CFX_WideString& sError) { 2696 CFX_WideString& sError) {
2721 return TRUE; 2697 return TRUE;
2722 } 2698 }
2723 2699
2724 FX_BOOL Field::textColor(IJS_Context* cc, 2700 FX_BOOL Field::textColor(IJS_Context* cc,
2725 CJS_PropValue& vp, 2701 CJS_PropValue& vp,
2726 CFX_WideString& sError) { 2702 CFX_WideString& sError) {
2727 ASSERT(m_pDocument != NULL); 2703 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2704 CJS_Array crArray(pRuntime);
2728 2705
2729 if (vp.IsSetting()) { 2706 if (vp.IsSetting()) {
2730 if (!m_bCanSet) 2707 if (!m_bCanSet)
2731 return FALSE; 2708 return FALSE;
2732 2709
2733 CJS_Array crArray(m_isolate);
2734 if (!vp.IsArrayObject()) 2710 if (!vp.IsArrayObject())
2735 return FALSE; 2711 return FALSE;
2712
2736 vp >> crArray; 2713 vp >> crArray;
2737 2714
2738 CPWL_Color color; 2715 CPWL_Color color;
2739 color::ConvertArrayToPWLColor(crArray, color); 2716 color::ConvertArrayToPWLColor(crArray, color);
2740 2717
2741 if (m_bDelay) { 2718 if (m_bDelay) {
2742 AddDelay_Color(FP_TEXTCOLOR, color); 2719 AddDelay_Color(FP_TEXTCOLOR, color);
2743 } else { 2720 } else {
2744 Field::SetTextColor(m_pDocument, m_FieldName, m_nFormControlIndex, color); 2721 Field::SetTextColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);
2745 } 2722 }
2746 } else { 2723 } else {
2747 CFX_PtrArray FieldArray; 2724 CFX_PtrArray FieldArray;
2748 GetFormFields(m_FieldName, FieldArray); 2725 GetFormFields(m_FieldName, FieldArray);
2749 if (FieldArray.GetSize() <= 0) 2726 if (FieldArray.GetSize() <= 0)
2750 return FALSE; 2727 return FALSE;
2751 2728
2752 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 2729 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
2753 ASSERT(pFormField != NULL);
2754
2755 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 2730 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
2756 if (!pFormControl) 2731 if (!pFormControl)
2757 return FALSE; 2732 return FALSE;
2758 2733
2759 int iColorType; 2734 int iColorType;
2760 FX_ARGB color; 2735 FX_ARGB color;
2761 CPDF_DefaultAppearance FieldAppearance = 2736 CPDF_DefaultAppearance FieldAppearance =
2762 pFormControl->GetDefaultAppearance(); 2737 pFormControl->GetDefaultAppearance();
2763 FieldAppearance.GetColor(color, iColorType); 2738 FieldAppearance.GetColor(color, iColorType);
2764 int32_t a, r, g, b; 2739 int32_t a, r, g, b;
2765 ArgbDecode(color, a, r, g, b); 2740 ArgbDecode(color, a, r, g, b);
2766 2741
2767 CPWL_Color crRet = 2742 CPWL_Color crRet =
2768 CPWL_Color(COLORTYPE_RGB, r / 255.0f, g / 255.0f, b / 255.0f); 2743 CPWL_Color(COLORTYPE_RGB, r / 255.0f, g / 255.0f, b / 255.0f);
2769 2744
2770 if (iColorType == COLORTYPE_TRANSPARENT) 2745 if (iColorType == COLORTYPE_TRANSPARENT)
2771 crRet = CPWL_Color(COLORTYPE_TRANSPARENT); 2746 crRet = CPWL_Color(COLORTYPE_TRANSPARENT);
2772 2747
2773 CJS_Array crArray(m_isolate);
2774 color::ConvertPWLColorToArray(crRet, crArray); 2748 color::ConvertPWLColorToArray(crRet, crArray);
2775 vp << crArray; 2749 vp << crArray;
2776 } 2750 }
2777
2778 return TRUE; 2751 return TRUE;
2779 } 2752 }
2780 2753
2781 void Field::SetTextColor(CPDFSDK_Document* pDocument, 2754 void Field::SetTextColor(CPDFSDK_Document* pDocument,
2782 const CFX_WideString& swFieldName, 2755 const CFX_WideString& swFieldName,
2783 int nControlIndex, 2756 int nControlIndex,
2784 const CPWL_Color& color) { 2757 const CPWL_Color& color) {
2785 // Not supported. 2758 // Not supported.
2786 } 2759 }
2787 2760
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2976 void Field::SetUserName(CPDFSDK_Document* pDocument, 2949 void Field::SetUserName(CPDFSDK_Document* pDocument,
2977 const CFX_WideString& swFieldName, 2950 const CFX_WideString& swFieldName,
2978 int nControlIndex, 2951 int nControlIndex,
2979 const CFX_WideString& string) { 2952 const CFX_WideString& string) {
2980 // Not supported. 2953 // Not supported.
2981 } 2954 }
2982 2955
2983 FX_BOOL Field::value(IJS_Context* cc, 2956 FX_BOOL Field::value(IJS_Context* cc,
2984 CJS_PropValue& vp, 2957 CJS_PropValue& vp,
2985 CFX_WideString& sError) { 2958 CFX_WideString& sError) {
2986 ASSERT(m_pDocument != NULL); 2959 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2987 2960
2988 if (vp.IsSetting()) { 2961 if (vp.IsSetting()) {
2989 if (!m_bCanSet) 2962 if (!m_bCanSet)
2990 return FALSE; 2963 return FALSE;
2991 2964
2992 CJS_WideStringArray strArray; 2965 CJS_WideStringArray strArray;
2993 2966
2994 if (vp.IsArrayObject()) { 2967 if (vp.IsArrayObject()) {
2995 CJS_Array ValueArray(m_isolate); 2968 CJS_Array ValueArray(pRuntime);
2996 vp.ConvertToArray(ValueArray); 2969 vp.ConvertToArray(ValueArray);
2997 for (int i = 0, sz = ValueArray.GetLength(); i < sz; i++) { 2970 for (int i = 0, sz = ValueArray.GetLength(); i < sz; i++) {
2998 CJS_Value ElementValue(m_isolate); 2971 CJS_Value ElementValue(pRuntime);
2999 ValueArray.GetElement(i, ElementValue); 2972 ValueArray.GetElement(i, ElementValue);
3000 strArray.Add(ElementValue.ToCFXWideString()); 2973 strArray.Add(ElementValue.ToCFXWideString());
3001 } 2974 }
3002 } else { 2975 } else {
3003 CFX_WideString swValue; 2976 CFX_WideString swValue;
3004 vp >> swValue; 2977 vp >> swValue;
3005
3006 strArray.Add(swValue); 2978 strArray.Add(swValue);
3007 } 2979 }
3008 2980
3009 if (m_bDelay) { 2981 if (m_bDelay) {
3010 AddDelay_WideStringArray(FP_VALUE, strArray); 2982 AddDelay_WideStringArray(FP_VALUE, strArray);
3011 } else { 2983 } else {
3012 Field::SetValue(m_pDocument, m_FieldName, m_nFormControlIndex, strArray); 2984 Field::SetValue(m_pDocument, m_FieldName, m_nFormControlIndex, strArray);
3013 } 2985 }
3014 } else { 2986 } else {
3015 CFX_PtrArray FieldArray; 2987 CFX_PtrArray FieldArray;
3016 GetFormFields(m_FieldName, FieldArray); 2988 GetFormFields(m_FieldName, FieldArray);
3017 if (FieldArray.GetSize() <= 0) 2989 if (FieldArray.GetSize() <= 0)
3018 return FALSE; 2990 return FALSE;
3019 2991
3020 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 2992 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
3021 ASSERT(pFormField != NULL);
3022
3023 switch (pFormField->GetFieldType()) { 2993 switch (pFormField->GetFieldType()) {
3024 case FIELDTYPE_PUSHBUTTON: 2994 case FIELDTYPE_PUSHBUTTON:
3025 return FALSE; 2995 return FALSE;
3026 case FIELDTYPE_COMBOBOX: 2996 case FIELDTYPE_COMBOBOX:
3027 case FIELDTYPE_TEXTFIELD: { 2997 case FIELDTYPE_TEXTFIELD: {
3028 CFX_WideString swValue = pFormField->GetValue(); 2998 CFX_WideString swValue = pFormField->GetValue();
3029 2999
3030 double dRet; 3000 double dRet;
3031 FX_BOOL bDot; 3001 FX_BOOL bDot;
3032 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, 3002 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet,
3033 bDot)) { 3003 bDot)) {
3034 if (bDot) 3004 if (bDot)
3035 vp << dRet; 3005 vp << dRet;
3036 else 3006 else
3037 vp << dRet; 3007 vp << dRet;
3038 } else 3008 } else
3039 vp << swValue; 3009 vp << swValue;
3040 } break; 3010 } break;
3041 case FIELDTYPE_LISTBOX: { 3011 case FIELDTYPE_LISTBOX: {
3042 if (pFormField->CountSelectedItems() > 1) { 3012 if (pFormField->CountSelectedItems() > 1) {
3043 CJS_Array ValueArray(m_isolate); 3013 CJS_Array ValueArray(pRuntime);
3044 CJS_Value ElementValue(m_isolate); 3014 CJS_Value ElementValue(pRuntime);
3045 int iIndex; 3015 int iIndex;
3046 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { 3016 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
3047 iIndex = pFormField->GetSelectedIndex(i); 3017 iIndex = pFormField->GetSelectedIndex(i);
3048 ElementValue = pFormField->GetOptionValue(iIndex).c_str(); 3018 ElementValue = pFormField->GetOptionValue(iIndex).c_str();
3049 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) 3019 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0)
3050 ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); 3020 ElementValue = pFormField->GetOptionLabel(iIndex).c_str();
3051 ValueArray.SetElement(i, ElementValue); 3021 ValueArray.SetElement(i, ElementValue);
3052 } 3022 }
3053 vp << ValueArray; 3023 vp << ValueArray;
3054 } else { 3024 } else {
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 3477
3508 swSort.Add(new CFX_WideString(pFormField->GetFullName())); 3478 swSort.Add(new CFX_WideString(pFormField->GetFullName()));
3509 } 3479 }
3510 swSort.Sort(JS_COMPARESTRING); 3480 swSort.Sort(JS_COMPARESTRING);
3511 3481
3512 CJS_Context* pContext = (CJS_Context*)cc; 3482 CJS_Context* pContext = (CJS_Context*)cc;
3513 ASSERT(pContext != NULL); 3483 ASSERT(pContext != NULL);
3514 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 3484 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
3515 ASSERT(pRuntime != NULL); 3485 ASSERT(pRuntime != NULL);
3516 3486
3517 CJS_Array FormFieldArray(m_isolate); 3487 CJS_Array FormFieldArray(pRuntime);
3518 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { 3488 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) {
3519 nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j)); 3489 nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j));
3520 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( 3490 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
3521 pRuntime->GetIsolate(), pContext, CJS_Field::g_nObjDefnID); 3491 pRuntime->GetIsolate(), pContext, CJS_Field::g_nObjDefnID);
3522 ASSERT(!pObj.IsEmpty()); 3492 ASSERT(!pObj.IsEmpty());
3523 3493
3524 CJS_Field* pJSField = 3494 CJS_Field* pJSField =
3525 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); 3495 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
3526 Field* pField = (Field*)pJSField->GetEmbedObject(); 3496 Field* pField = (Field*)pJSField->GetEmbedObject();
3527 pField->AttachField(m_pJSDoc, *pStr); 3497 pField->AttachField(m_pJSDoc, *pStr);
3528 3498
3529 CJS_Value FormFieldValue(m_isolate); 3499 CJS_Value FormFieldValue(pRuntime);
3530 FormFieldValue = pJSField; 3500 FormFieldValue = pJSField;
3531 FormFieldArray.SetElement(j, FormFieldValue); 3501 FormFieldArray.SetElement(j, FormFieldValue);
3532 } 3502 }
3533 3503
3534 vRet = FormFieldArray; 3504 vRet = FormFieldArray;
3535 swSort.RemoveAll(); 3505 swSort.RemoveAll();
3536 return TRUE; 3506 return TRUE;
3537 } 3507 }
3538 3508
3539 FX_BOOL Field::getItemAt(IJS_Context* cc, 3509 FX_BOOL Field::getItemAt(IJS_Context* cc,
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
4037 #define JS_FIELD_MINWIDTH 1 4007 #define JS_FIELD_MINWIDTH 1
4038 #define JS_FIELD_MINHEIGHT 1 4008 #define JS_FIELD_MINHEIGHT 1
4039 4009
4040 void Field::AddField(CPDFSDK_Document* pDocument, 4010 void Field::AddField(CPDFSDK_Document* pDocument,
4041 int nPageIndex, 4011 int nPageIndex,
4042 int nFieldType, 4012 int nFieldType,
4043 const CFX_WideString& sName, 4013 const CFX_WideString& sName,
4044 const CPDF_Rect& rcCoords) { 4014 const CPDF_Rect& rcCoords) {
4045 // Not supported. 4015 // Not supported.
4046 } 4016 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698