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 "xfa/fxfa/parser/cscript_hostpseudomodel.h" | 7 #include "xfa/fxfa/parser/cscript_hostpseudomodel.h" |
8 | 8 |
9 #include "fxjs/cfxjse_arguments.h" | 9 #include "fxjs/cfxjse_arguments.h" |
10 #include "xfa/fxfa/app/xfa_ffnotify.h" | 10 #include "xfa/fxfa/app/xfa_ffnotify.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 void CScript_HostPseudoModel::LoadString(CFXJSE_Value* pValue, | 35 void CScript_HostPseudoModel::LoadString(CFXJSE_Value* pValue, |
36 CXFA_FFNotify* pNotify, | 36 CXFA_FFNotify* pNotify, |
37 uint32_t dwFlag) { | 37 uint32_t dwFlag) { |
38 CFX_WideString wsValue; | 38 CFX_WideString wsValue; |
39 pNotify->GetAppProvider()->LoadString(dwFlag, wsValue); | 39 pNotify->GetAppProvider()->LoadString(dwFlag, wsValue); |
40 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); | 40 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
41 } | 41 } |
42 | 42 |
43 void CScript_HostPseudoModel::AppType(CFXJSE_Value* pValue, | 43 void CScript_HostPseudoModel::AppType(CFXJSE_Value* pValue, |
44 FX_BOOL bSetting, | 44 bool bSetting, |
45 XFA_ATTRIBUTE eAttribute) { | 45 XFA_ATTRIBUTE eAttribute) { |
46 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 46 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
47 if (!pNotify) | 47 if (!pNotify) |
48 return; | 48 return; |
49 if (bSetting) { | 49 if (bSetting) { |
50 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 50 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
51 return; | 51 return; |
52 } | 52 } |
53 pValue->SetString("Exchange"); | 53 pValue->SetString("Exchange"); |
54 } | 54 } |
55 | 55 |
56 void CScript_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue, | 56 void CScript_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue, |
57 FX_BOOL bSetting, | 57 bool bSetting, |
58 XFA_ATTRIBUTE eAttribute) { | 58 XFA_ATTRIBUTE eAttribute) { |
59 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 59 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
60 if (!pNotify) { | 60 if (!pNotify) { |
61 return; | 61 return; |
62 } | 62 } |
63 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 63 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
64 if (bSetting) { | 64 if (bSetting) { |
65 pNotify->GetDocEnvironment()->SetCalculationsEnabled(hDoc, | 65 pNotify->GetDocEnvironment()->SetCalculationsEnabled(hDoc, |
66 pValue->ToBoolean()); | 66 pValue->ToBoolean()); |
67 return; | 67 return; |
68 } | 68 } |
69 pValue->SetBoolean(pNotify->GetDocEnvironment()->IsCalculationsEnabled(hDoc)); | 69 pValue->SetBoolean(pNotify->GetDocEnvironment()->IsCalculationsEnabled(hDoc)); |
70 } | 70 } |
71 | 71 |
72 void CScript_HostPseudoModel::CurrentPage(CFXJSE_Value* pValue, | 72 void CScript_HostPseudoModel::CurrentPage(CFXJSE_Value* pValue, |
73 FX_BOOL bSetting, | 73 bool bSetting, |
74 XFA_ATTRIBUTE eAttribute) { | 74 XFA_ATTRIBUTE eAttribute) { |
75 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 75 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
76 if (!pNotify) { | 76 if (!pNotify) { |
77 return; | 77 return; |
78 } | 78 } |
79 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 79 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
80 if (bSetting) { | 80 if (bSetting) { |
81 pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, pValue->ToInteger()); | 81 pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, pValue->ToInteger()); |
82 return; | 82 return; |
83 } | 83 } |
84 pValue->SetInteger(pNotify->GetDocEnvironment()->GetCurrentPage(hDoc)); | 84 pValue->SetInteger(pNotify->GetDocEnvironment()->GetCurrentPage(hDoc)); |
85 } | 85 } |
86 | 86 |
87 void CScript_HostPseudoModel::Language(CFXJSE_Value* pValue, | 87 void CScript_HostPseudoModel::Language(CFXJSE_Value* pValue, |
88 FX_BOOL bSetting, | 88 bool bSetting, |
89 XFA_ATTRIBUTE eAttribute) { | 89 XFA_ATTRIBUTE eAttribute) { |
90 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 90 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
91 if (!pNotify) { | 91 if (!pNotify) { |
92 return; | 92 return; |
93 } | 93 } |
94 if (bSetting) { | 94 if (bSetting) { |
95 ThrowException(XFA_IDS_UNABLE_SET_LANGUAGE); | 95 ThrowException(XFA_IDS_UNABLE_SET_LANGUAGE); |
96 return; | 96 return; |
97 } | 97 } |
98 CFX_WideString wsLanguage; | 98 CFX_WideString wsLanguage; |
99 pNotify->GetAppProvider()->GetLanguage(wsLanguage); | 99 pNotify->GetAppProvider()->GetLanguage(wsLanguage); |
100 pValue->SetString(FX_UTF8Encode(wsLanguage).AsStringC()); | 100 pValue->SetString(FX_UTF8Encode(wsLanguage).AsStringC()); |
101 } | 101 } |
102 | 102 |
103 void CScript_HostPseudoModel::NumPages(CFXJSE_Value* pValue, | 103 void CScript_HostPseudoModel::NumPages(CFXJSE_Value* pValue, |
104 FX_BOOL bSetting, | 104 bool bSetting, |
105 XFA_ATTRIBUTE eAttribute) { | 105 XFA_ATTRIBUTE eAttribute) { |
106 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 106 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
107 if (!pNotify) { | 107 if (!pNotify) { |
108 return; | 108 return; |
109 } | 109 } |
110 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 110 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
111 if (bSetting) { | 111 if (bSetting) { |
112 ThrowException(XFA_IDS_UNABLE_SET_NUMPAGES); | 112 ThrowException(XFA_IDS_UNABLE_SET_NUMPAGES); |
113 return; | 113 return; |
114 } | 114 } |
115 pValue->SetInteger(pNotify->GetDocEnvironment()->CountPages(hDoc)); | 115 pValue->SetInteger(pNotify->GetDocEnvironment()->CountPages(hDoc)); |
116 } | 116 } |
117 | 117 |
118 void CScript_HostPseudoModel::Platform(CFXJSE_Value* pValue, | 118 void CScript_HostPseudoModel::Platform(CFXJSE_Value* pValue, |
119 FX_BOOL bSetting, | 119 bool bSetting, |
120 XFA_ATTRIBUTE eAttribute) { | 120 XFA_ATTRIBUTE eAttribute) { |
121 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 121 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
122 if (!pNotify) { | 122 if (!pNotify) { |
123 return; | 123 return; |
124 } | 124 } |
125 if (bSetting) { | 125 if (bSetting) { |
126 ThrowException(XFA_IDS_UNABLE_SET_PLATFORM); | 126 ThrowException(XFA_IDS_UNABLE_SET_PLATFORM); |
127 return; | 127 return; |
128 } | 128 } |
129 CFX_WideString wsPlatform; | 129 CFX_WideString wsPlatform; |
130 pNotify->GetAppProvider()->GetPlatform(wsPlatform); | 130 pNotify->GetAppProvider()->GetPlatform(wsPlatform); |
131 pValue->SetString(FX_UTF8Encode(wsPlatform).AsStringC()); | 131 pValue->SetString(FX_UTF8Encode(wsPlatform).AsStringC()); |
132 } | 132 } |
133 void CScript_HostPseudoModel::Title(CFXJSE_Value* pValue, | 133 void CScript_HostPseudoModel::Title(CFXJSE_Value* pValue, |
134 FX_BOOL bSetting, | 134 bool bSetting, |
135 XFA_ATTRIBUTE eAttribute) { | 135 XFA_ATTRIBUTE eAttribute) { |
136 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 136 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
137 return; | 137 return; |
138 } | 138 } |
139 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 139 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
140 if (!pNotify) { | 140 if (!pNotify) { |
141 return; | 141 return; |
142 } | 142 } |
143 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 143 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
144 if (bSetting) { | 144 if (bSetting) { |
145 pNotify->GetDocEnvironment()->SetTitle(hDoc, pValue->ToWideString()); | 145 pNotify->GetDocEnvironment()->SetTitle(hDoc, pValue->ToWideString()); |
146 return; | 146 return; |
147 } | 147 } |
148 CFX_WideString wsTitle; | 148 CFX_WideString wsTitle; |
149 pNotify->GetDocEnvironment()->GetTitle(hDoc, wsTitle); | 149 pNotify->GetDocEnvironment()->GetTitle(hDoc, wsTitle); |
150 pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC()); | 150 pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC()); |
151 } | 151 } |
152 | 152 |
153 void CScript_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue, | 153 void CScript_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue, |
154 FX_BOOL bSetting, | 154 bool bSetting, |
155 XFA_ATTRIBUTE eAttribute) { | 155 XFA_ATTRIBUTE eAttribute) { |
156 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 156 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
157 if (!pNotify) { | 157 if (!pNotify) { |
158 return; | 158 return; |
159 } | 159 } |
160 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 160 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
161 if (bSetting) { | 161 if (bSetting) { |
162 pNotify->GetDocEnvironment()->SetValidationsEnabled(hDoc, | 162 pNotify->GetDocEnvironment()->SetValidationsEnabled(hDoc, |
163 pValue->ToBoolean()); | 163 pValue->ToBoolean()); |
164 return; | 164 return; |
165 } | 165 } |
166 FX_BOOL bEnabled = pNotify->GetDocEnvironment()->IsValidationsEnabled(hDoc); | 166 bool bEnabled = pNotify->GetDocEnvironment()->IsValidationsEnabled(hDoc); |
167 pValue->SetBoolean(bEnabled); | 167 pValue->SetBoolean(bEnabled); |
168 } | 168 } |
169 | 169 |
170 void CScript_HostPseudoModel::Variation(CFXJSE_Value* pValue, | 170 void CScript_HostPseudoModel::Variation(CFXJSE_Value* pValue, |
171 FX_BOOL bSetting, | 171 bool bSetting, |
172 XFA_ATTRIBUTE eAttribute) { | 172 XFA_ATTRIBUTE eAttribute) { |
173 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) | 173 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) |
174 return; | 174 return; |
175 | 175 |
176 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 176 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
177 if (!pNotify) | 177 if (!pNotify) |
178 return; | 178 return; |
179 if (bSetting) { | 179 if (bSetting) { |
180 ThrowException(XFA_IDS_UNABLE_SET_VARIATION); | 180 ThrowException(XFA_IDS_UNABLE_SET_VARIATION); |
181 return; | 181 return; |
182 } | 182 } |
183 pValue->SetString("Full"); | 183 pValue->SetString("Full"); |
184 } | 184 } |
185 | 185 |
186 void CScript_HostPseudoModel::Version(CFXJSE_Value* pValue, | 186 void CScript_HostPseudoModel::Version(CFXJSE_Value* pValue, |
187 FX_BOOL bSetting, | 187 bool bSetting, |
188 XFA_ATTRIBUTE eAttribute) { | 188 XFA_ATTRIBUTE eAttribute) { |
189 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 189 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
190 if (!pNotify) { | 190 if (!pNotify) { |
191 return; | 191 return; |
192 } | 192 } |
193 if (bSetting) { | 193 if (bSetting) { |
194 ThrowException(XFA_IDS_UNABLE_SET_VERSION); | 194 ThrowException(XFA_IDS_UNABLE_SET_VERSION); |
195 return; | 195 return; |
196 } | 196 } |
197 pValue->SetString("11"); | 197 pValue->SetString("11"); |
198 } | 198 } |
199 | 199 |
200 void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, | 200 void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, |
201 FX_BOOL bSetting, | 201 bool bSetting, |
202 XFA_ATTRIBUTE eAttribute) { | 202 XFA_ATTRIBUTE eAttribute) { |
203 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 203 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
204 if (!pNotify) { | 204 if (!pNotify) { |
205 return; | 205 return; |
206 } | 206 } |
207 if (bSetting) { | 207 if (bSetting) { |
208 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 208 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
209 return; | 209 return; |
210 } | 210 } |
211 CFX_WideString wsAppName; | 211 CFX_WideString wsAppName; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); | 290 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); |
291 return; | 291 return; |
292 } | 292 } |
293 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 293 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
294 if (!pNotify) { | 294 if (!pNotify) { |
295 return; | 295 return; |
296 } | 296 } |
297 CFX_WideString wsQuestion; | 297 CFX_WideString wsQuestion; |
298 CFX_WideString wsTitle; | 298 CFX_WideString wsTitle; |
299 CFX_WideString wsDefaultAnswer; | 299 CFX_WideString wsDefaultAnswer; |
300 FX_BOOL bMark = FALSE; | 300 bool bMark = false; |
301 if (iLength >= 1) { | 301 if (iLength >= 1) { |
302 CFX_ByteString bsQuestion = pArguments->GetUTF8String(0); | 302 CFX_ByteString bsQuestion = pArguments->GetUTF8String(0); |
303 wsQuestion = CFX_WideString::FromUTF8(bsQuestion.AsStringC()); | 303 wsQuestion = CFX_WideString::FromUTF8(bsQuestion.AsStringC()); |
304 } | 304 } |
305 if (iLength >= 2) { | 305 if (iLength >= 2) { |
306 CFX_ByteString bsTitle = pArguments->GetUTF8String(1); | 306 CFX_ByteString bsTitle = pArguments->GetUTF8String(1); |
307 wsTitle = CFX_WideString::FromUTF8(bsTitle.AsStringC()); | 307 wsTitle = CFX_WideString::FromUTF8(bsTitle.AsStringC()); |
308 } | 308 } |
309 if (iLength >= 3) { | 309 if (iLength >= 3) { |
310 CFX_ByteString bsDefaultAnswer = pArguments->GetUTF8String(2); | 310 CFX_ByteString bsDefaultAnswer = pArguments->GetUTF8String(2); |
311 wsDefaultAnswer = CFX_WideString::FromUTF8(bsDefaultAnswer.AsStringC()); | 311 wsDefaultAnswer = CFX_WideString::FromUTF8(bsDefaultAnswer.AsStringC()); |
312 } | 312 } |
313 if (iLength >= 4) { | 313 if (iLength >= 4) { |
314 bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; | 314 bMark = pArguments->GetInt32(3) == 0 ? false : true; |
315 } | 315 } |
316 CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response( | 316 CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response( |
317 wsQuestion, wsTitle, wsDefaultAnswer, bMark); | 317 wsQuestion, wsTitle, wsDefaultAnswer, bMark); |
318 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 318 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
319 if (pValue) | 319 if (pValue) |
320 pValue->SetString(FX_UTF8Encode(wsAnswer).AsStringC()); | 320 pValue->SetString(FX_UTF8Encode(wsAnswer).AsStringC()); |
321 } | 321 } |
322 | 322 |
323 void CScript_HostPseudoModel::DocumentInBatch(CFXJSE_Arguments* pArguments) { | 323 void CScript_HostPseudoModel::DocumentInBatch(CFXJSE_Arguments* pArguments) { |
324 if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) | 324 if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 if (dwButtonType > XFA_MB_YesNoCancel) { | 506 if (dwButtonType > XFA_MB_YesNoCancel) { |
507 dwButtonType = XFA_MB_OK; | 507 dwButtonType = XFA_MB_OK; |
508 } | 508 } |
509 } | 509 } |
510 int32_t iValue = pNotify->GetAppProvider()->MsgBox( | 510 int32_t iValue = pNotify->GetAppProvider()->MsgBox( |
511 wsMessage, bsTitle, dwMessageType, dwButtonType); | 511 wsMessage, bsTitle, dwMessageType, dwButtonType); |
512 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 512 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
513 if (pValue) | 513 if (pValue) |
514 pValue->SetInteger(iValue); | 514 pValue->SetInteger(iValue); |
515 } | 515 } |
516 FX_BOOL CScript_HostPseudoModel::ValidateArgsForMsg( | 516 bool CScript_HostPseudoModel::ValidateArgsForMsg(CFXJSE_Arguments* pArguments, |
517 CFXJSE_Arguments* pArguments, | 517 int32_t iArgIndex, |
518 int32_t iArgIndex, | 518 CFX_WideString& wsValue) { |
519 CFX_WideString& wsValue) { | |
520 if (!pArguments || iArgIndex < 0) { | 519 if (!pArguments || iArgIndex < 0) { |
521 return FALSE; | 520 return false; |
522 } | 521 } |
523 FX_BOOL bIsJsType = FALSE; | 522 bool bIsJsType = false; |
524 if (m_pDocument->GetScriptContext()->GetType() == | 523 if (m_pDocument->GetScriptContext()->GetType() == |
525 XFA_SCRIPTLANGTYPE_Javascript) { | 524 XFA_SCRIPTLANGTYPE_Javascript) { |
526 bIsJsType = TRUE; | 525 bIsJsType = true; |
527 } | 526 } |
528 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); | 527 std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); |
529 if (!pValueArg->IsString() && bIsJsType) { | 528 if (!pValueArg->IsString() && bIsJsType) { |
530 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 529 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
531 return FALSE; | 530 return false; |
532 } | 531 } |
533 if (pValueArg->IsNull()) { | 532 if (pValueArg->IsNull()) { |
534 wsValue = FX_WSTRC(L""); | 533 wsValue = FX_WSTRC(L""); |
535 } else { | 534 } else { |
536 wsValue = pValueArg->ToWideString(); | 535 wsValue = pValueArg->ToWideString(); |
537 } | 536 } |
538 return TRUE; | 537 return true; |
539 } | 538 } |
540 void CScript_HostPseudoModel::DocumentCountInBatch( | 539 void CScript_HostPseudoModel::DocumentCountInBatch( |
541 CFXJSE_Arguments* pArguments) { | 540 CFXJSE_Arguments* pArguments) { |
542 if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) | 541 if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) |
543 pValue->SetInteger(0); | 542 pValue->SetInteger(0); |
544 } | 543 } |
545 void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { | 544 void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { |
546 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { | 545 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |
547 return; | 546 return; |
548 } | 547 } |
549 int32_t iLength = pArguments->GetLength(); | 548 int32_t iLength = pArguments->GetLength(); |
550 if (iLength != 8) { | 549 if (iLength != 8) { |
551 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); | 550 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); |
552 return; | 551 return; |
553 } | 552 } |
554 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 553 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
555 if (!pNotify) { | 554 if (!pNotify) { |
556 return; | 555 return; |
557 } | 556 } |
558 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 557 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
559 uint32_t dwOptions = 0; | 558 uint32_t dwOptions = 0; |
560 FX_BOOL bShowDialog = TRUE; | 559 bool bShowDialog = true; |
561 if (iLength >= 1) { | 560 if (iLength >= 1) { |
562 bShowDialog = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; | 561 bShowDialog = pArguments->GetInt32(0) == 0 ? false : true; |
563 } | 562 } |
564 if (bShowDialog) { | 563 if (bShowDialog) { |
565 dwOptions |= XFA_PRINTOPT_ShowDialog; | 564 dwOptions |= XFA_PRINTOPT_ShowDialog; |
566 } | 565 } |
567 int32_t nStartPage = 0; | 566 int32_t nStartPage = 0; |
568 if (iLength >= 2) { | 567 if (iLength >= 2) { |
569 nStartPage = pArguments->GetInt32(1); | 568 nStartPage = pArguments->GetInt32(1); |
570 } | 569 } |
571 int32_t nEndPage = 0; | 570 int32_t nEndPage = 0; |
572 if (iLength >= 3) { | 571 if (iLength >= 3) { |
573 nEndPage = pArguments->GetInt32(2); | 572 nEndPage = pArguments->GetInt32(2); |
574 } | 573 } |
575 FX_BOOL bCanCancel = TRUE; | 574 bool bCanCancel = true; |
576 if (iLength >= 4) { | 575 if (iLength >= 4) { |
577 bCanCancel = pArguments->GetInt32(3) == 0 ? FALSE : TRUE; | 576 bCanCancel = pArguments->GetInt32(3) == 0 ? false : true; |
578 } | 577 } |
579 if (bCanCancel) { | 578 if (bCanCancel) { |
580 dwOptions |= XFA_PRINTOPT_CanCancel; | 579 dwOptions |= XFA_PRINTOPT_CanCancel; |
581 } | 580 } |
582 FX_BOOL bShrinkPage = TRUE; | 581 bool bShrinkPage = true; |
583 if (iLength >= 5) { | 582 if (iLength >= 5) { |
584 bShrinkPage = pArguments->GetInt32(4) == 0 ? FALSE : TRUE; | 583 bShrinkPage = pArguments->GetInt32(4) == 0 ? false : true; |
585 } | 584 } |
586 if (bShrinkPage) { | 585 if (bShrinkPage) { |
587 dwOptions |= XFA_PRINTOPT_ShrinkPage; | 586 dwOptions |= XFA_PRINTOPT_ShrinkPage; |
588 } | 587 } |
589 FX_BOOL bAsImage = TRUE; | 588 bool bAsImage = true; |
590 if (iLength >= 6) { | 589 if (iLength >= 6) { |
591 bAsImage = pArguments->GetInt32(5) == 0 ? FALSE : TRUE; | 590 bAsImage = pArguments->GetInt32(5) == 0 ? false : true; |
592 } | 591 } |
593 if (bAsImage) { | 592 if (bAsImage) { |
594 dwOptions |= XFA_PRINTOPT_AsImage; | 593 dwOptions |= XFA_PRINTOPT_AsImage; |
595 } | 594 } |
596 FX_BOOL bReverseOrder = TRUE; | 595 bool bReverseOrder = true; |
597 if (iLength >= 7) { | 596 if (iLength >= 7) { |
598 bAsImage = pArguments->GetInt32(5) == 0 ? FALSE : TRUE; | 597 bAsImage = pArguments->GetInt32(5) == 0 ? false : true; |
599 } | 598 } |
600 bReverseOrder = pArguments->GetInt32(6) == 0 ? FALSE : TRUE; | 599 bReverseOrder = pArguments->GetInt32(6) == 0 ? false : true; |
601 if (bReverseOrder) { | 600 if (bReverseOrder) { |
602 dwOptions |= XFA_PRINTOPT_ReverseOrder; | 601 dwOptions |= XFA_PRINTOPT_ReverseOrder; |
603 } | 602 } |
604 FX_BOOL bPrintAnnot = TRUE; | 603 bool bPrintAnnot = true; |
605 if (iLength >= 8) { | 604 if (iLength >= 8) { |
606 bPrintAnnot = pArguments->GetInt32(7) == 0 ? FALSE : TRUE; | 605 bPrintAnnot = pArguments->GetInt32(7) == 0 ? false : true; |
607 } | 606 } |
608 if (bPrintAnnot) { | 607 if (bPrintAnnot) { |
609 dwOptions |= XFA_PRINTOPT_PrintAnnot; | 608 dwOptions |= XFA_PRINTOPT_PrintAnnot; |
610 } | 609 } |
611 pNotify->GetDocEnvironment()->Print(hDoc, nStartPage, nEndPage, dwOptions); | 610 pNotify->GetDocEnvironment()->Print(hDoc, nStartPage, nEndPage, dwOptions); |
612 } | 611 } |
613 | 612 |
614 void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) { | 613 void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) { |
615 int32_t iLength = pArguments->GetLength(); | 614 int32_t iLength = pArguments->GetLength(); |
616 if (iLength < 0 || iLength > 1) { | 615 if (iLength < 0 || iLength > 1) { |
617 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); | 616 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); |
618 return; | 617 return; |
619 } | 618 } |
620 // Not implemented. | 619 // Not implemented. |
621 } | 620 } |
622 | 621 |
623 void CScript_HostPseudoModel::ExportData(CFXJSE_Arguments* pArguments) { | 622 void CScript_HostPseudoModel::ExportData(CFXJSE_Arguments* pArguments) { |
624 int32_t iLength = pArguments->GetLength(); | 623 int32_t iLength = pArguments->GetLength(); |
625 if (iLength < 0 || iLength > 2) { | 624 if (iLength < 0 || iLength > 2) { |
626 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); | 625 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); |
627 return; | 626 return; |
628 } | 627 } |
629 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 628 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
630 if (!pNotify) { | 629 if (!pNotify) { |
631 return; | 630 return; |
632 } | 631 } |
633 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 632 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
634 CFX_WideString wsFilePath; | 633 CFX_WideString wsFilePath; |
635 FX_BOOL bXDP = TRUE; | 634 bool bXDP = true; |
636 if (iLength >= 1) { | 635 if (iLength >= 1) { |
637 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); | 636 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); |
638 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); | 637 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); |
639 } | 638 } |
640 if (iLength >= 2) { | 639 if (iLength >= 2) { |
641 bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; | 640 bXDP = pArguments->GetInt32(1) == 0 ? false : true; |
642 } | 641 } |
643 pNotify->GetDocEnvironment()->ExportData(hDoc, wsFilePath, bXDP); | 642 pNotify->GetDocEnvironment()->ExportData(hDoc, wsFilePath, bXDP); |
644 } | 643 } |
645 | 644 |
646 void CScript_HostPseudoModel::PageUp(CFXJSE_Arguments* pArguments) { | 645 void CScript_HostPseudoModel::PageUp(CFXJSE_Arguments* pArguments) { |
647 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 646 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
648 if (!pNotify) { | 647 if (!pNotify) { |
649 return; | 648 return; |
650 } | 649 } |
651 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 650 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
(...skipping 29 matching lines...) Expand all Loading... |
681 void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { | 680 void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { |
682 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); | 681 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
683 if (!pNotify) { | 682 if (!pNotify) { |
684 return; | 683 return; |
685 } | 684 } |
686 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); | 685 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); |
687 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 686 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
688 if (pValue) | 687 if (pValue) |
689 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); | 688 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); |
690 } | 689 } |
OLD | NEW |