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

Side by Side Diff: xfa/fxfa/parser/cscript_hostpseudomodel.cpp

Issue 2328573002: Split CPDFXFA_Document apart (Closed)
Patch Set: Fix merge Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/include/xfa_ffdoc.h ('k') | xfa/fxfa/parser/cxfa_scriptcontext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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/include/cfxjse_arguments.h" 9 #include "fxjs/include/cfxjse_arguments.h"
10 #include "xfa/fxfa/app/xfa_ffnotify.h" 10 #include "xfa/fxfa/app/xfa_ffnotify.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 void CScript_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue, 59 void CScript_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue,
60 FX_BOOL bSetting, 60 FX_BOOL bSetting,
61 XFA_ATTRIBUTE eAttribute) { 61 XFA_ATTRIBUTE eAttribute) {
62 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 62 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
63 if (!pNotify) { 63 if (!pNotify) {
64 return; 64 return;
65 } 65 }
66 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 66 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
67 if (bSetting) { 67 if (bSetting) {
68 pNotify->GetDocProvider()->SetCalculationsEnabled(hDoc, 68 pNotify->GetDocEnvironment()->SetCalculationsEnabled(hDoc,
69 pValue->ToBoolean()); 69 pValue->ToBoolean());
70 return; 70 return;
71 } 71 }
72 pValue->SetBoolean(pNotify->GetDocProvider()->IsCalculationsEnabled(hDoc)); 72 pValue->SetBoolean(pNotify->GetDocEnvironment()->IsCalculationsEnabled(hDoc));
73 } 73 }
74 74
75 void CScript_HostPseudoModel::CurrentPage(CFXJSE_Value* pValue, 75 void CScript_HostPseudoModel::CurrentPage(CFXJSE_Value* pValue,
76 FX_BOOL bSetting, 76 FX_BOOL bSetting,
77 XFA_ATTRIBUTE eAttribute) { 77 XFA_ATTRIBUTE eAttribute) {
78 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 78 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
79 if (!pNotify) { 79 if (!pNotify) {
80 return; 80 return;
81 } 81 }
82 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 82 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
83 if (bSetting) { 83 if (bSetting) {
84 pNotify->GetDocProvider()->SetCurrentPage(hDoc, pValue->ToInteger()); 84 pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, pValue->ToInteger());
85 return; 85 return;
86 } 86 }
87 pValue->SetInteger(pNotify->GetDocProvider()->GetCurrentPage(hDoc)); 87 pValue->SetInteger(pNotify->GetDocEnvironment()->GetCurrentPage(hDoc));
88 } 88 }
89 89
90 void CScript_HostPseudoModel::Language(CFXJSE_Value* pValue, 90 void CScript_HostPseudoModel::Language(CFXJSE_Value* pValue,
91 FX_BOOL bSetting, 91 FX_BOOL bSetting,
92 XFA_ATTRIBUTE eAttribute) { 92 XFA_ATTRIBUTE eAttribute) {
93 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 93 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
94 if (!pNotify) { 94 if (!pNotify) {
95 return; 95 return;
96 } 96 }
97 if (bSetting) { 97 if (bSetting) {
(...skipping 10 matching lines...) Expand all
108 XFA_ATTRIBUTE eAttribute) { 108 XFA_ATTRIBUTE eAttribute) {
109 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 109 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
110 if (!pNotify) { 110 if (!pNotify) {
111 return; 111 return;
112 } 112 }
113 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 113 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
114 if (bSetting) { 114 if (bSetting) {
115 ThrowException(XFA_IDS_UNABLE_SET_NUMPAGES); 115 ThrowException(XFA_IDS_UNABLE_SET_NUMPAGES);
116 return; 116 return;
117 } 117 }
118 pValue->SetInteger(pNotify->GetDocProvider()->CountPages(hDoc)); 118 pValue->SetInteger(pNotify->GetDocEnvironment()->CountPages(hDoc));
119 } 119 }
120 120
121 void CScript_HostPseudoModel::Platform(CFXJSE_Value* pValue, 121 void CScript_HostPseudoModel::Platform(CFXJSE_Value* pValue,
122 FX_BOOL bSetting, 122 FX_BOOL bSetting,
123 XFA_ATTRIBUTE eAttribute) { 123 XFA_ATTRIBUTE eAttribute) {
124 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 124 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
125 if (!pNotify) { 125 if (!pNotify) {
126 return; 126 return;
127 } 127 }
128 if (bSetting) { 128 if (bSetting) {
129 ThrowException(XFA_IDS_UNABLE_SET_PLATFORM); 129 ThrowException(XFA_IDS_UNABLE_SET_PLATFORM);
130 return; 130 return;
131 } 131 }
132 CFX_WideString wsPlatform; 132 CFX_WideString wsPlatform;
133 pNotify->GetAppProvider()->GetPlatform(wsPlatform); 133 pNotify->GetAppProvider()->GetPlatform(wsPlatform);
134 pValue->SetString(FX_UTF8Encode(wsPlatform).AsStringC()); 134 pValue->SetString(FX_UTF8Encode(wsPlatform).AsStringC());
135 } 135 }
136 void CScript_HostPseudoModel::Title(CFXJSE_Value* pValue, 136 void CScript_HostPseudoModel::Title(CFXJSE_Value* pValue,
137 FX_BOOL bSetting, 137 FX_BOOL bSetting,
138 XFA_ATTRIBUTE eAttribute) { 138 XFA_ATTRIBUTE eAttribute) {
139 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { 139 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
140 return; 140 return;
141 } 141 }
142 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 142 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
143 if (!pNotify) { 143 if (!pNotify) {
144 return; 144 return;
145 } 145 }
146 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 146 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
147 if (bSetting) { 147 if (bSetting) {
148 pNotify->GetDocProvider()->SetTitle(hDoc, pValue->ToWideString()); 148 pNotify->GetDocEnvironment()->SetTitle(hDoc, pValue->ToWideString());
149 return; 149 return;
150 } 150 }
151 CFX_WideString wsTitle; 151 CFX_WideString wsTitle;
152 pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle); 152 pNotify->GetDocEnvironment()->GetTitle(hDoc, wsTitle);
153 pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC()); 153 pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC());
154 } 154 }
155 155
156 void CScript_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue, 156 void CScript_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue,
157 FX_BOOL bSetting, 157 FX_BOOL bSetting,
158 XFA_ATTRIBUTE eAttribute) { 158 XFA_ATTRIBUTE eAttribute) {
159 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 159 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
160 if (!pNotify) { 160 if (!pNotify) {
161 return; 161 return;
162 } 162 }
163 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 163 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
164 if (bSetting) { 164 if (bSetting) {
165 pNotify->GetDocProvider()->SetValidationsEnabled(hDoc, pValue->ToBoolean()); 165 pNotify->GetDocEnvironment()->SetValidationsEnabled(hDoc,
166 pValue->ToBoolean());
166 return; 167 return;
167 } 168 }
168 FX_BOOL bEnabled = pNotify->GetDocProvider()->IsValidationsEnabled(hDoc); 169 FX_BOOL bEnabled = pNotify->GetDocEnvironment()->IsValidationsEnabled(hDoc);
169 pValue->SetBoolean(bEnabled); 170 pValue->SetBoolean(bEnabled);
170 } 171 }
171 void CScript_HostPseudoModel::Variation(CFXJSE_Value* pValue, 172 void CScript_HostPseudoModel::Variation(CFXJSE_Value* pValue,
172 FX_BOOL bSetting, 173 FX_BOOL bSetting,
173 XFA_ATTRIBUTE eAttribute) { 174 XFA_ATTRIBUTE eAttribute) {
174 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { 175 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
175 return; 176 return;
176 } 177 }
177 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 178 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
178 if (!pNotify) { 179 if (!pNotify) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 232 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
232 if (!pNotify) { 233 if (!pNotify) {
233 return; 234 return;
234 } 235 }
235 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 236 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
236 CFX_WideString wsURL; 237 CFX_WideString wsURL;
237 if (iLength >= 1) { 238 if (iLength >= 1) {
238 CFX_ByteString bsURL = pArguments->GetUTF8String(0); 239 CFX_ByteString bsURL = pArguments->GetUTF8String(0);
239 wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC()); 240 wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC());
240 } 241 }
241 pNotify->GetDocProvider()->GotoURL(hDoc, wsURL, TRUE); 242 pNotify->GetDocEnvironment()->GotoURL(hDoc, wsURL, TRUE);
242 } 243 }
243 void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) { 244 void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) {
244 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { 245 if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
245 return; 246 return;
246 } 247 }
247 int32_t iLength = pArguments->GetLength(); 248 int32_t iLength = pArguments->GetLength();
248 if (iLength != 1) { 249 if (iLength != 1) {
249 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); 250 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList");
250 return; 251 return;
251 } 252 }
(...skipping 28 matching lines...) Expand all
280 } 281 }
281 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); 282 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
282 if (!pDocLayout) { 283 if (!pDocLayout) {
283 return; 284 return;
284 } 285 }
285 CXFA_FFWidget* hWidget = 286 CXFA_FFWidget* hWidget =
286 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); 287 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode));
287 if (!hWidget) { 288 if (!hWidget) {
288 return; 289 return;
289 } 290 }
290 pNotify->GetDocProvider()->SetFocusWidget(pNotify->GetHDOC(), hWidget); 291 pNotify->GetDocEnvironment()->SetFocusWidget(pNotify->GetHDOC(), hWidget);
291 pNotify->OpenDropDownList(hWidget); 292 pNotify->OpenDropDownList(hWidget);
292 } 293 }
293 void CScript_HostPseudoModel::Response(CFXJSE_Arguments* pArguments) { 294 void CScript_HostPseudoModel::Response(CFXJSE_Arguments* pArguments) {
294 int32_t iLength = pArguments->GetLength(); 295 int32_t iLength = pArguments->GetLength();
295 if (iLength < 1 || iLength > 4) { 296 if (iLength < 1 || iLength > 4) {
296 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); 297 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response");
297 return; 298 return;
298 } 299 }
299 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 300 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
300 if (!pNotify) { 301 if (!pNotify) {
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 if (bReverseOrder) { 620 if (bReverseOrder) {
620 dwOptions |= XFA_PRINTOPT_ReverseOrder; 621 dwOptions |= XFA_PRINTOPT_ReverseOrder;
621 } 622 }
622 FX_BOOL bPrintAnnot = TRUE; 623 FX_BOOL bPrintAnnot = TRUE;
623 if (iLength >= 8) { 624 if (iLength >= 8) {
624 bPrintAnnot = pArguments->GetInt32(7) == 0 ? FALSE : TRUE; 625 bPrintAnnot = pArguments->GetInt32(7) == 0 ? FALSE : TRUE;
625 } 626 }
626 if (bPrintAnnot) { 627 if (bPrintAnnot) {
627 dwOptions |= XFA_PRINTOPT_PrintAnnot; 628 dwOptions |= XFA_PRINTOPT_PrintAnnot;
628 } 629 }
629 pNotify->GetDocProvider()->Print(hDoc, nStartPage, nEndPage, dwOptions); 630 pNotify->GetDocEnvironment()->Print(hDoc, nStartPage, nEndPage, dwOptions);
630 } 631 }
631 632
632 void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) { 633 void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) {
633 int32_t iLength = pArguments->GetLength(); 634 int32_t iLength = pArguments->GetLength();
634 if (iLength < 0 || iLength > 1) { 635 if (iLength < 0 || iLength > 1) {
635 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); 636 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData");
636 return; 637 return;
637 } 638 }
638 // Not implemented. 639 // Not implemented.
639 } 640 }
(...skipping 11 matching lines...) Expand all
651 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 652 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
652 CFX_WideString wsFilePath; 653 CFX_WideString wsFilePath;
653 FX_BOOL bXDP = TRUE; 654 FX_BOOL bXDP = TRUE;
654 if (iLength >= 1) { 655 if (iLength >= 1) {
655 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); 656 CFX_ByteString bsFilePath = pArguments->GetUTF8String(0);
656 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC()); 657 wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC());
657 } 658 }
658 if (iLength >= 2) { 659 if (iLength >= 2) {
659 bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; 660 bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE;
660 } 661 }
661 pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath, bXDP); 662 pNotify->GetDocEnvironment()->ExportData(hDoc, wsFilePath, bXDP);
662 } 663 }
663 664
664 void CScript_HostPseudoModel::PageUp(CFXJSE_Arguments* pArguments) { 665 void CScript_HostPseudoModel::PageUp(CFXJSE_Arguments* pArguments) {
665 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 666 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
666 if (!pNotify) { 667 if (!pNotify) {
667 return; 668 return;
668 } 669 }
669 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 670 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
670 int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); 671 int32_t nCurPage = pNotify->GetDocEnvironment()->GetCurrentPage(hDoc);
671 int32_t nNewPage = 0; 672 int32_t nNewPage = 0;
672 if (nCurPage <= 1) { 673 if (nCurPage <= 1) {
673 return; 674 return;
674 } 675 }
675 nNewPage = nCurPage - 1; 676 nNewPage = nCurPage - 1;
676 pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); 677 pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
677 } 678 }
678 679
679 void CScript_HostPseudoModel::PageDown(CFXJSE_Arguments* pArguments) { 680 void CScript_HostPseudoModel::PageDown(CFXJSE_Arguments* pArguments) {
680 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 681 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
681 if (!pNotify) { 682 if (!pNotify) {
682 return; 683 return;
683 } 684 }
684 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 685 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
685 int32_t nCurPage = pNotify->GetDocProvider()->GetCurrentPage(hDoc); 686 int32_t nCurPage = pNotify->GetDocEnvironment()->GetCurrentPage(hDoc);
686 int32_t nPageCount = pNotify->GetDocProvider()->CountPages(hDoc); 687 int32_t nPageCount = pNotify->GetDocEnvironment()->CountPages(hDoc);
687 if (!nPageCount || nCurPage == nPageCount) { 688 if (!nPageCount || nCurPage == nPageCount) {
688 return; 689 return;
689 } 690 }
690 int32_t nNewPage = 0; 691 int32_t nNewPage = 0;
691 if (nCurPage >= nPageCount) { 692 if (nCurPage >= nPageCount) {
692 nNewPage = nPageCount - 1; 693 nNewPage = nPageCount - 1;
693 } else { 694 } else {
694 nNewPage = nCurPage + 1; 695 nNewPage = nCurPage + 1;
695 } 696 }
696 pNotify->GetDocProvider()->SetCurrentPage(hDoc, nNewPage); 697 pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
697 } 698 }
698 699
699 void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { 700 void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) {
700 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 701 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
701 if (!pNotify) { 702 if (!pNotify) {
702 return; 703 return;
703 } 704 }
704 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); 705 CFX_WideString wsDataTime = pNotify->GetCurrentDateTime();
705 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 706 CFXJSE_Value* pValue = pArguments->GetReturnValue();
706 if (pValue) 707 if (pValue)
707 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); 708 pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC());
708 } 709 }
OLDNEW
« no previous file with comments | « xfa/fxfa/include/xfa_ffdoc.h ('k') | xfa/fxfa/parser/cxfa_scriptcontext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698