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

Side by Side Diff: fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.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 | « BUILD.gn ('k') | fpdfsdk/fpdfxfa/fpdfxfa_doc.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 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" 7 #include "fpdfsdk/fpdfxfa/include/cpdfxfa_docenvironment.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" 12 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
13 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
14 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" 13 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
15 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
16 #include "fpdfsdk/include/cpdfdoc_environment.h" 14 #include "fpdfsdk/include/cpdfdoc_environment.h"
17 #include "fpdfsdk/include/cpdfsdk_document.h" 15 #include "fpdfsdk/include/cpdfsdk_document.h"
18 #include "fpdfsdk/include/cpdfsdk_interform.h" 16 #include "fpdfsdk/include/cpdfsdk_interform.h"
19 #include "fpdfsdk/include/cpdfsdk_pageview.h" 17 #include "fpdfsdk/include/cpdfsdk_pageview.h"
20 #include "fpdfsdk/include/fsdk_define.h"
21 #include "fpdfsdk/javascript/ijs_runtime.h" 18 #include "fpdfsdk/javascript/ijs_runtime.h"
22 #include "public/fpdf_formfill.h"
23 #include "xfa/fxfa/include/cxfa_eventparam.h"
24 #include "xfa/fxfa/include/xfa_ffapp.h"
25 #include "xfa/fxfa/include/xfa_ffdoc.h"
26 #include "xfa/fxfa/include/xfa_ffdocview.h" 19 #include "xfa/fxfa/include/xfa_ffdocview.h"
27 #include "xfa/fxfa/include/xfa_ffpageview.h"
28 #include "xfa/fxfa/include/xfa_ffwidget.h" 20 #include "xfa/fxfa/include/xfa_ffwidget.h"
29 #include "xfa/fxfa/include/xfa_ffwidgethandler.h" 21 #include "xfa/fxfa/include/xfa_ffwidgethandler.h"
30 22
31 #define IDS_XFA_Validate_Input \ 23 #define IDS_XFA_Validate_Input \
32 "At least one required field was empty. Please fill in the required " \ 24 "At least one required field was empty. Please fill in the required " \
33 "fields\r\n(highlighted) before continuing." 25 "fields\r\n(highlighted) before continuing."
34 26
35 // submit 27 // submit
36 #define FXFA_CONFIG 0x00000001 28 #define FXFA_CONFIG 0x00000001
37 #define FXFA_TEMPLATE 0x00000010 29 #define FXFA_TEMPLATE 0x00000010
38 #define FXFA_LOCALESET 0x00000100 30 #define FXFA_LOCALESET 0x00000100
39 #define FXFA_DATASETS 0x00001000 31 #define FXFA_DATASETS 0x00001000
40 #define FXFA_XMPMETA 0x00010000 32 #define FXFA_XMPMETA 0x00010000
41 #define FXFA_XFDF 0x00100000 33 #define FXFA_XFDF 0x00100000
42 #define FXFA_FORM 0x01000000 34 #define FXFA_FORM 0x01000000
43 #define FXFA_PDF 0x10000000 35 #define FXFA_PDF 0x10000000
44 #define FXFA_XFA_ALL 0x01111111 36 #define FXFA_XFA_ALL 0x01111111
45 37
46 #ifndef _WIN32 38 CPDFXFA_DocEnvironment::CPDFXFA_DocEnvironment(CPDFXFA_Document* doc)
47 extern void SetLastError(int err); 39 : m_pDocument(doc), m_pJSContext(nullptr) {
48 extern int GetLastError(); 40 ASSERT(m_pDocument);
49 #endif
50
51 CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc,
52 CPDFXFA_App* pProvider)
53 : m_iDocType(DOCTYPE_PDF),
54 m_pPDFDoc(std::move(pPDFDoc)),
55 m_pXFADocView(nullptr),
56 m_pApp(pProvider),
57 m_pJSContext(nullptr),
58 m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD),
59 m_nPageCount(0) {}
60
61 CPDFXFA_Document::~CPDFXFA_Document() {
62 m_nLoadStatus = FXFA_LOADSTATUS_CLOSING;
63
64 if (m_pXFADoc) {
65 CXFA_FFApp* pApp = m_pApp->GetXFAApp();
66 if (pApp) {
67 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler();
68 if (pDocHandler)
69 CloseXFADoc(pDocHandler);
70 }
71 m_pXFADoc.reset();
72 }
73 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv())
74 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext);
75
76 m_nLoadStatus = FXFA_LOADSTATUS_CLOSED;
77 } 41 }
78 42
79 FX_BOOL CPDFXFA_Document::LoadXFADoc() { 43 CPDFXFA_DocEnvironment::~CPDFXFA_DocEnvironment() {
80 m_nLoadStatus = FXFA_LOADSTATUS_LOADING; 44 if (m_pJSContext && m_pDocument->GetSDKDoc() &&
81 45 m_pDocument->GetSDKDoc()->GetEnv())
82 if (!m_pPDFDoc) 46 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->ReleaseContext(
83 return FALSE; 47 m_pJSContext);
84
85 m_XFAPageList.RemoveAll();
86
87 CXFA_FFApp* pApp = m_pApp->GetXFAApp();
88 if (!pApp)
89 return FALSE;
90
91 m_pXFADoc.reset(pApp->CreateDoc(this, m_pPDFDoc.get()));
92 if (!m_pXFADoc) {
93 SetLastError(FPDF_ERR_XFALOAD);
94 return FALSE;
95 }
96
97 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler();
98 if (!pDocHandler) {
99 SetLastError(FPDF_ERR_XFALOAD);
100 return FALSE;
101 }
102
103 m_pXFADoc->StartLoad();
104 int iStatus = m_pXFADoc->DoLoad(nullptr);
105 if (iStatus != XFA_PARSESTATUS_Done) {
106 CloseXFADoc(pDocHandler);
107 SetLastError(FPDF_ERR_XFALOAD);
108 return FALSE;
109 }
110 m_pXFADoc->StopLoad();
111 m_pXFADoc->GetXFADoc()->InitScriptContext(m_pApp->GetJSERuntime());
112
113 if (m_pXFADoc->GetDocType() == XFA_DOCTYPE_Dynamic)
114 m_iDocType = DOCTYPE_DYNAMIC_XFA;
115 else
116 m_iDocType = DOCTYPE_STATIC_XFA;
117
118 m_pXFADocView = m_pXFADoc->CreateDocView(XFA_DOCVIEW_View);
119 if (m_pXFADocView->StartLayout() < 0) {
120 CloseXFADoc(pDocHandler);
121 SetLastError(FPDF_ERR_XFALAYOUT);
122 return FALSE;
123 }
124
125 m_pXFADocView->DoLayout(nullptr);
126 m_pXFADocView->StopLayout();
127 m_nLoadStatus = FXFA_LOADSTATUS_LOADED;
128
129 return TRUE;
130 } 48 }
131 49
132 int CPDFXFA_Document::GetPageCount() { 50 void CPDFXFA_DocEnvironment::SetChangeMark(CXFA_FFDoc* hDoc) {
133 if (!m_pPDFDoc && !m_pXFADoc) 51 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetSDKDoc())
134 return 0; 52 m_pDocument->GetSDKDoc()->SetChangeMark();
135
136 switch (m_iDocType) {
137 case DOCTYPE_PDF:
138 case DOCTYPE_STATIC_XFA:
139 if (m_pPDFDoc)
140 return m_pPDFDoc->GetPageCount();
141 case DOCTYPE_DYNAMIC_XFA:
142 if (m_pXFADoc)
143 return m_pXFADocView->CountPageViews();
144 default:
145 return 0;
146 }
147 } 53 }
148 54
149 CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) { 55 void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView,
150 if (page_index < 0) 56 const CFX_RectF& rt,
151 return nullptr; 57 uint32_t dwFlags /* = 0 */) {
152 58 if (!m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
153 CPDFXFA_Page* pPage = nullptr;
154 int nCount = m_XFAPageList.GetSize();
155 if (nCount > 0 && page_index < nCount) {
156 pPage = m_XFAPageList.GetAt(page_index);
157 if (pPage)
158 pPage->Retain();
159 } else {
160 m_nPageCount = GetPageCount();
161 m_XFAPageList.SetSize(m_nPageCount);
162 }
163 if (pPage)
164 return pPage;
165
166 pPage = new CPDFXFA_Page(this, page_index);
167 if (!pPage->LoadPage()) {
168 pPage->Release();
169 return nullptr;
170 }
171 m_XFAPageList.SetAt(page_index, pPage);
172 return pPage;
173 }
174
175 CPDFXFA_Page* CPDFXFA_Document::GetPage(CXFA_FFPageView* pPage) {
176 if (!pPage)
177 return nullptr;
178
179 if (!m_pXFADoc)
180 return nullptr;
181
182 if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
183 return nullptr;
184
185 int nSize = m_XFAPageList.GetSize();
186 for (int i = 0; i < nSize; i++) {
187 CPDFXFA_Page* pTempPage = m_XFAPageList.GetAt(i);
188 if (!pTempPage)
189 continue;
190 if (pTempPage->GetXFAPageView() && pTempPage->GetXFAPageView() == pPage)
191 return pTempPage;
192 }
193
194 return nullptr;
195 }
196
197 void CPDFXFA_Document::DeletePage(int page_index) {
198 // Delete from the document first because, if GetPage was never called for
199 // this |page_index| then |m_XFAPageList| may have size < |page_index| even
200 // if it's a valid page in the document.
201 if (m_pPDFDoc)
202 m_pPDFDoc->DeletePage(page_index);
203
204 if (page_index < 0 || page_index >= m_XFAPageList.GetSize())
205 return; 59 return;
206 60
207 if (CPDFXFA_Page* pPage = m_XFAPageList.GetAt(page_index)) 61 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
208 pPage->Release();
209 }
210
211 void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page) {
212 m_XFAPageList.SetAt(page->GetPageIndex(), nullptr);
213 }
214
215 CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument(
216 CPDFDoc_Environment* pFormFillEnv) {
217 if (!m_pSDKDoc && pFormFillEnv)
218 m_pSDKDoc.reset(new CPDFSDK_Document(this, pFormFillEnv));
219 return m_pSDKDoc.get();
220 }
221
222 void CPDFXFA_Document::SetChangeMark(CXFA_FFDoc* hDoc) {
223 if (hDoc == m_pXFADoc.get() && m_pSDKDoc)
224 m_pSDKDoc->SetChangeMark();
225 }
226
227 void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView,
228 const CFX_RectF& rt,
229 uint32_t dwFlags /* = 0 */) {
230 if (!m_pXFADoc || !m_pSDKDoc)
231 return; 62 return;
232 63
233 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 64 CPDFXFA_Page* pPage = m_pDocument->GetPage(pPageView);
234 return;
235
236 CPDFXFA_Page* pPage = GetPage(pPageView);
237 if (!pPage) 65 if (!pPage)
238 return; 66 return;
239 67
240 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 68 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
241 if (!pEnv) 69 if (!pEnv)
242 return; 70 return;
243 71
244 CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt); 72 CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt);
245 pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, 73 pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom,
246 rcPage.right, rcPage.top); 74 rcPage.right, rcPage.top);
247 } 75 }
248 76
249 void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, 77 void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget,
250 FX_BOOL bVisible, 78 FX_BOOL bVisible,
251 const CFX_RectF* pRtAnchor) { 79 const CFX_RectF* pRtAnchor) {
252 if (!hWidget || !pRtAnchor || !m_pXFADoc || !m_pSDKDoc || !m_pXFADocView) 80 if (!hWidget || !pRtAnchor || !m_pDocument->GetXFADoc() ||
81 !m_pDocument->GetSDKDoc() || !m_pDocument->GetXFADocView())
253 return; 82 return;
254 83
255 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 84 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
256 return; 85 return;
257 86
258 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); 87 CXFA_FFWidgetHandler* pWidgetHandler =
88 m_pDocument->GetXFADocView()->GetWidgetHandler();
259 if (!pWidgetHandler) 89 if (!pWidgetHandler)
260 return; 90 return;
261 91
262 CXFA_FFPageView* pPageView = hWidget->GetPageView(); 92 CXFA_FFPageView* pPageView = hWidget->GetPageView();
263 if (!pPageView) 93 if (!pPageView)
264 return; 94 return;
265 95
266 CPDFXFA_Page* pPage = GetPage(pPageView); 96 CPDFXFA_Page* pPage = m_pDocument->GetPage(pPageView);
267 if (!pPage) 97 if (!pPage)
268 return; 98 return;
269 99
270 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 100 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
271 if (!pEnv) 101 if (!pEnv)
272 return; 102 return;
273 103
274 CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor); 104 CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor);
275 pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, 105 pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top,
276 rcCaret.right, rcCaret.bottom); 106 rcCaret.right, rcCaret.bottom);
277 } 107 }
278 108
279 FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, 109 FX_BOOL CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
280 FX_FLOAT fMinPopup, 110 FX_FLOAT fMinPopup,
281 FX_FLOAT fMaxPopup, 111 FX_FLOAT fMaxPopup,
282 const CFX_RectF& rtAnchor, 112 const CFX_RectF& rtAnchor,
283 CFX_RectF& rtPopup) { 113 CFX_RectF& rtPopup) {
284 if (!hWidget) 114 if (!hWidget)
285 return FALSE; 115 return FALSE;
286 116
287 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); 117 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView();
288 if (!pXFAPageView) 118 if (!pXFAPageView)
289 return FALSE; 119 return FALSE;
290 120
291 CPDFXFA_Page* pPage = GetPage(pXFAPageView); 121 CPDFXFA_Page* pPage = m_pDocument->GetPage(pXFAPageView);
292 if (!pPage) 122 if (!pPage)
293 return FALSE; 123 return FALSE;
294 124
295 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); 125 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc();
296 int nRotate = pWidgetAcc->GetRotate(); 126 int nRotate = pWidgetAcc->GetRotate();
297 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 127 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
298 if (!pEnv) 128 if (!pEnv)
299 return FALSE; 129 return FALSE;
300 130
301 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; 131 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f};
302 pEnv->FFI_GetPageViewRect(pPage, pageViewRect); 132 pEnv->FFI_GetPageViewRect(pPage, pageViewRect);
303 133
304 int t1; 134 int t1;
305 int t2; 135 int t2;
306 CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor); 136 CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor);
307 switch (nRotate) { 137 switch (nRotate) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 215 }
386 break; 216 break;
387 } 217 }
388 default: 218 default:
389 break; 219 break;
390 } 220 }
391 221
392 return TRUE; 222 return TRUE;
393 } 223 }
394 224
395 FX_BOOL CPDFXFA_Document::PopupMenu(CXFA_FFWidget* hWidget, 225 FX_BOOL CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget,
396 CFX_PointF ptPopup) { 226 CFX_PointF ptPopup) {
397 if (!hWidget) 227 if (!hWidget)
398 return FALSE; 228 return FALSE;
399 229
400 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); 230 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView();
401 if (!pXFAPageView) 231 if (!pXFAPageView)
402 return FALSE; 232 return FALSE;
403 233
404 CPDFXFA_Page* pPage = GetPage(pXFAPageView); 234 CPDFXFA_Page* pPage = m_pDocument->GetPage(pXFAPageView);
405 if (!pPage) 235 if (!pPage)
406 return FALSE; 236 return FALSE;
407 237
408 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 238 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
409 if (!pEnv) 239 if (!pEnv)
410 return FALSE; 240 return FALSE;
411 241
412 int menuFlag = 0; 242 int menuFlag = 0;
413 if (hWidget->CanUndo()) 243 if (hWidget->CanUndo())
414 menuFlag |= FXFA_MENU_UNDO; 244 menuFlag |= FXFA_MENU_UNDO;
415 if (hWidget->CanRedo()) 245 if (hWidget->CanRedo())
416 menuFlag |= FXFA_MENU_REDO; 246 menuFlag |= FXFA_MENU_REDO;
417 if (hWidget->CanPaste()) 247 if (hWidget->CanPaste())
418 menuFlag |= FXFA_MENU_PASTE; 248 menuFlag |= FXFA_MENU_PASTE;
419 if (hWidget->CanCopy()) 249 if (hWidget->CanCopy())
420 menuFlag |= FXFA_MENU_COPY; 250 menuFlag |= FXFA_MENU_COPY;
421 if (hWidget->CanCut()) 251 if (hWidget->CanCut())
422 menuFlag |= FXFA_MENU_CUT; 252 menuFlag |= FXFA_MENU_CUT;
423 if (hWidget->CanSelectAll()) 253 if (hWidget->CanSelectAll())
424 menuFlag |= FXFA_MENU_SELECTALL; 254 menuFlag |= FXFA_MENU_SELECTALL;
425 255
426 return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr); 256 return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr);
427 } 257 }
428 258
429 void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView, 259 void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView,
430 uint32_t dwFlags) { 260 uint32_t dwFlags) {
431 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 261 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
432 if (!pEnv) 262 if (!pEnv)
433 return; 263 return;
434 264
435 if (m_nLoadStatus == FXFA_LOADSTATUS_LOADING || 265 if (m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_LOADING ||
436 m_nLoadStatus == FXFA_LOADSTATUS_CLOSING || 266 m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_CLOSING ||
437 XFA_PAGEVIEWEVENT_StopLayout != dwFlags) 267 XFA_PAGEVIEWEVENT_StopLayout != dwFlags)
438 return; 268 return;
439 269
440 int nNewCount = GetPageCount(); 270 int nNewCount = m_pDocument->GetPageCount();
441 if (nNewCount == m_nPageCount) 271 if (nNewCount == m_pDocument->GetOriginalPageCount())
442 return; 272 return;
443 273
444 CXFA_FFDocView* pXFADocView = GetXFADocView(); 274 CXFA_FFDocView* pXFADocView = m_pDocument->GetXFADocView();
445 if (!pXFADocView) 275 if (!pXFADocView)
446 return; 276 return;
447 277
448 for (int iPageIter = 0; iPageIter < m_nPageCount; iPageIter++) { 278 for (int iPageIter = 0; iPageIter < m_pDocument->GetOriginalPageCount();
449 CPDFXFA_Page* pPage = m_XFAPageList.GetAt(iPageIter); 279 iPageIter++) {
280 CPDFXFA_Page* pPage = m_pDocument->GetXFAPageList()->GetAt(iPageIter);
450 if (!pPage) 281 if (!pPage)
451 continue; 282 continue;
452 283
453 m_pSDKDoc->RemovePageView(pPage); 284 m_pDocument->GetSDKDoc()->RemovePageView(pPage);
454 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); 285 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter));
455 } 286 }
456 287
457 int flag = (nNewCount < m_nPageCount) ? FXFA_PAGEVIEWEVENT_POSTREMOVED 288 int flag = (nNewCount < m_pDocument->GetOriginalPageCount())
458 : FXFA_PAGEVIEWEVENT_POSTADDED; 289 ? FXFA_PAGEVIEWEVENT_POSTREMOVED
459 int count = FXSYS_abs(nNewCount - m_nPageCount); 290 : FXFA_PAGEVIEWEVENT_POSTADDED;
460 m_nPageCount = nNewCount; 291 int count = FXSYS_abs(nNewCount - m_pDocument->GetOriginalPageCount());
461 m_XFAPageList.SetSize(nNewCount); 292 m_pDocument->SetOriginalPageCount(nNewCount);
462 pEnv->FFI_PageEvent(count, flag); 293 pEnv->FFI_PageEvent(count, flag);
463 } 294 }
464 295
465 void CPDFXFA_Document::WidgetPostAdd(CXFA_FFWidget* hWidget, 296 void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget,
466 CXFA_WidgetAcc* pWidgetData) { 297 CXFA_WidgetAcc* pWidgetData) {
467 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) 298 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget)
468 return; 299 return;
469 300
470 CXFA_FFPageView* pPageView = hWidget->GetPageView(); 301 CXFA_FFPageView* pPageView = hWidget->GetPageView();
471 if (!pPageView) 302 if (!pPageView)
472 return; 303 return;
473 304
474 CPDFXFA_Page* pXFAPage = GetPage(pPageView); 305 CPDFXFA_Page* pXFAPage = m_pDocument->GetPage(pPageView);
475 if (!pXFAPage) 306 if (!pXFAPage)
476 return; 307 return;
477 308
478 m_pSDKDoc->GetPageView(pXFAPage, true)->AddAnnot(hWidget); 309 m_pDocument->GetSDKDoc()->GetPageView(pXFAPage, true)->AddAnnot(hWidget);
479 } 310 }
480 311
481 void CPDFXFA_Document::WidgetPreRemove(CXFA_FFWidget* hWidget, 312 void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget,
482 CXFA_WidgetAcc* pWidgetData) { 313 CXFA_WidgetAcc* pWidgetData) {
483 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) 314 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget)
484 return; 315 return;
485 316
486 CXFA_FFPageView* pPageView = hWidget->GetPageView(); 317 CXFA_FFPageView* pPageView = hWidget->GetPageView();
487 if (!pPageView) 318 if (!pPageView)
488 return; 319 return;
489 320
490 CPDFXFA_Page* pXFAPage = GetPage(pPageView); 321 CPDFXFA_Page* pXFAPage = m_pDocument->GetPage(pPageView);
491 if (!pXFAPage) 322 if (!pXFAPage)
492 return; 323 return;
493 324
494 CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage, true); 325 CPDFSDK_PageView* pSdkPageView =
326 m_pDocument->GetSDKDoc()->GetPageView(pXFAPage, true);
495 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) 327 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget))
496 pSdkPageView->DeleteAnnot(pAnnot); 328 pSdkPageView->DeleteAnnot(pAnnot);
497 } 329 }
498 330
499 int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { 331 int32_t CPDFXFA_DocEnvironment::CountPages(CXFA_FFDoc* hDoc) {
500 if (hDoc == m_pXFADoc.get() && m_pSDKDoc) 332 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetSDKDoc())
501 return GetPageCount(); 333 return m_pDocument->GetPageCount();
502 return 0; 334 return 0;
503 } 335 }
504 336
505 int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { 337 int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) {
506 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) 338 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
507 return -1; 339 return -1;
508 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 340 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
509 return -1; 341 return -1;
510 342
511 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 343 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
512 if (!pEnv) 344 if (!pEnv)
513 return -1; 345 return -1;
514 346
515 return pEnv->FFI_GetCurrentPageIndex(this); 347 return pEnv->FFI_GetCurrentPageIndex(this);
516 } 348 }
517 349
518 void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) { 350 void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc,
519 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc || 351 int32_t iCurPage) {
520 m_iDocType != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || 352 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc() ||
521 iCurPage >= m_pSDKDoc->GetPageCount()) { 353 m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 ||
354 iCurPage >= m_pDocument->GetSDKDoc()->GetPageCount()) {
522 return; 355 return;
523 } 356 }
524 357
525 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 358 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
526 if (!pEnv) 359 if (!pEnv)
527 return; 360 return;
528 pEnv->FFI_SetCurrentPage(this, iCurPage); 361 pEnv->FFI_SetCurrentPage(this, iCurPage);
529 } 362 }
530 363
531 FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { 364 FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) {
532 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) 365 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
533 return FALSE; 366 return FALSE;
534 if (m_pSDKDoc->GetInterForm()) 367 if (m_pDocument->GetSDKDoc()->GetInterForm())
535 return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled(); 368 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaCalculateEnabled();
536 return FALSE; 369 return FALSE;
537 } 370 }
538 371
539 void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc, 372 void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc,
540 FX_BOOL bEnabled) { 373 FX_BOOL bEnabled) {
541 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) 374 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
542 return; 375 return;
543 if (m_pSDKDoc->GetInterForm()) 376 if (m_pDocument->GetSDKDoc()->GetInterForm())
544 m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled); 377 m_pDocument->GetSDKDoc()->GetInterForm()->XfaEnableCalculate(bEnabled);
545 } 378 }
546 379
547 void CPDFXFA_Document::GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) { 380 void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc,
548 if (hDoc != m_pXFADoc.get() || !m_pPDFDoc) 381 CFX_WideString& wsTitle) {
382 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc())
549 return; 383 return;
550 384
551 CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo(); 385 CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo();
552 if (!pInfoDict) 386 if (!pInfoDict)
553 return; 387 return;
554 388
555 CFX_ByteString csTitle = pInfoDict->GetStringBy("Title"); 389 CFX_ByteString csTitle = pInfoDict->GetStringBy("Title");
556 wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength())); 390 wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength()));
557 csTitle.ReleaseBuffer(csTitle.GetLength()); 391 csTitle.ReleaseBuffer(csTitle.GetLength());
558 } 392 }
559 393
560 void CPDFXFA_Document::SetTitle(CXFA_FFDoc* hDoc, 394 void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc,
561 const CFX_WideString& wsTitle) { 395 const CFX_WideString& wsTitle) {
562 if (hDoc != m_pXFADoc.get() || !m_pPDFDoc) 396 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc())
563 return; 397 return;
564 398
565 if (CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo()) 399 if (CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo())
566 pInfoDict->SetAt("Title", new CPDF_String(wsTitle)); 400 pInfoDict->SetAt("Title", new CPDF_String(wsTitle));
567 } 401 }
568 402
569 void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, 403 void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
570 const CFX_WideString& wsFilePath, 404 const CFX_WideString& wsFilePath,
571 FX_BOOL bXDP) { 405 FX_BOOL bXDP) {
572 if (hDoc != m_pXFADoc.get()) 406 if (hDoc != m_pDocument->GetXFADoc())
573 return; 407 return;
574 408
575 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) 409 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
410 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
576 return; 411 return;
577 412
578 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 413 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
579 if (!pEnv) 414 if (!pEnv)
580 return; 415 return;
581 416
582 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; 417 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML;
583 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); 418 CFX_ByteString bs = wsFilePath.UTF16LE_Encode();
584 if (wsFilePath.IsEmpty()) { 419 if (wsFilePath.IsEmpty()) {
585 if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) 420 if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform)
586 return; 421 return;
587 422
588 CFX_WideString filepath = pEnv->JS_fieldBrowse(); 423 CFX_WideString filepath = pEnv->JS_fieldBrowse();
589 bs = filepath.UTF16LE_Encode(); 424 bs = filepath.UTF16LE_Encode();
590 } 425 }
591 int len = bs.GetLength(); 426 int len = bs.GetLength();
592 FPDF_FILEHANDLER* pFileHandler = 427 FPDF_FILEHANDLER* pFileHandler =
593 pEnv->FFI_OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, 428 pEnv->FFI_OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML,
594 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); 429 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb");
595 bs.ReleaseBuffer(len); 430 bs.ReleaseBuffer(len);
596 if (!pFileHandler) 431 if (!pFileHandler)
597 return; 432 return;
598 433
599 CFPDF_FileStream fileWrite(pFileHandler); 434 CFPDF_FileStream fileWrite(pFileHandler);
600 CFX_ByteString content; 435 CFX_ByteString content;
601 if (fileType == FXFA_SAVEAS_XML) { 436 if (fileType == FXFA_SAVEAS_XML) {
602 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; 437 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
603 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), 438 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
604 content.GetLength()); 439 content.GetLength());
605 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Data, &fileWrite, 440 m_pDocument->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Data,
606 nullptr); 441 &fileWrite, nullptr);
607 } else if (fileType == FXFA_SAVEAS_XDP) { 442 } else if (fileType == FXFA_SAVEAS_XDP) {
608 if (!m_pPDFDoc) 443 if (!m_pDocument->GetPDFDoc())
609 return; 444 return;
610 445
611 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); 446 CPDF_Dictionary* pRoot = m_pDocument->GetPDFDoc()->GetRoot();
612 if (!pRoot) 447 if (!pRoot)
613 return; 448 return;
614 449
615 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); 450 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
616 if (!pAcroForm) 451 if (!pAcroForm)
617 return; 452 return;
618 453
619 CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA")); 454 CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA"));
620 if (!pArray) 455 if (!pArray)
621 return; 456 return;
622 457
623 int size = pArray->GetCount(); 458 int size = pArray->GetCount();
624 for (int i = 1; i < size; i += 2) { 459 for (int i = 1; i < size; i += 2) {
625 CPDF_Object* pPDFObj = pArray->GetObjectAt(i); 460 CPDF_Object* pPDFObj = pArray->GetObjectAt(i);
626 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1); 461 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1);
627 if (!pPrePDFObj->IsString()) 462 if (!pPrePDFObj->IsString())
628 continue; 463 continue;
629 if (!pPDFObj->IsReference()) 464 if (!pPDFObj->IsReference())
630 continue; 465 continue;
631 466
632 CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect()); 467 CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect());
633 if (!pStream) 468 if (!pStream)
634 continue; 469 continue;
635 if (pPrePDFObj->GetString() == "form") { 470 if (pPrePDFObj->GetString() == "form") {
636 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, &fileWrite, 471 m_pDocument->GetXFADocView()->GetDoc()->SavePackage(
637 nullptr); 472 XFA_HASHCODE_Form, &fileWrite, nullptr);
638 continue; 473 continue;
639 } 474 }
640 if (pPrePDFObj->GetString() == "datasets") { 475 if (pPrePDFObj->GetString() == "datasets") {
641 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, &fileWrite, 476 m_pDocument->GetXFADocView()->GetDoc()->SavePackage(
642 nullptr); 477 XFA_HASHCODE_Datasets, &fileWrite, nullptr);
643 continue; 478 continue;
644 } 479 }
645 if (i == size - 1) { 480 if (i == size - 1) {
646 CFX_WideString wPath = CFX_WideString::FromUTF16LE( 481 CFX_WideString wPath = CFX_WideString::FromUTF16LE(
647 reinterpret_cast<const unsigned short*>(bs.c_str()), 482 reinterpret_cast<const unsigned short*>(bs.c_str()),
648 bs.GetLength() / sizeof(unsigned short)); 483 bs.GetLength() / sizeof(unsigned short));
649 CFX_ByteString bPath = wPath.UTF8Encode(); 484 CFX_ByteString bPath = wPath.UTF8Encode();
650 const char* szFormat = 485 const char* szFormat =
651 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; 486 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
652 content.Format(szFormat, bPath.c_str()); 487 content.Format(szFormat, bPath.c_str());
653 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), 488 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
654 content.GetLength()); 489 content.GetLength());
655 } 490 }
656 std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc); 491 std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc);
657 pAcc->LoadAllData(pStream); 492 pAcc->LoadAllData(pStream);
658 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), 493 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(),
659 pAcc->GetSize()); 494 pAcc->GetSize());
660 } 495 }
661 } 496 }
662 if (!fileWrite.Flush()) { 497 if (!fileWrite.Flush()) {
663 // Ignoring flush error. 498 // Ignoring flush error.
664 } 499 }
665 } 500 }
666 501
667 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, 502 void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc,
668 const CFX_WideString& bsURL, 503 const CFX_WideString& bsURL,
669 FX_BOOL bAppend) { 504 FX_BOOL bAppend) {
670 if (hDoc != m_pXFADoc.get()) 505 if (hDoc != m_pDocument->GetXFADoc())
671 return; 506 return;
672 507
673 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 508 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
674 return; 509 return;
675 510
676 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 511 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
677 if (!pEnv) 512 if (!pEnv)
678 return; 513 return;
679 514
680 CFX_WideStringC str(bsURL.c_str()); 515 CFX_WideStringC str(bsURL.c_str());
681 516
682 pEnv->FFI_GotoURL(this, str, bAppend); 517 pEnv->FFI_GotoURL(this, str, bAppend);
683 } 518 }
684 519
685 FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { 520 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) {
686 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) 521 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
687 return FALSE; 522 return FALSE;
688 if (m_pSDKDoc->GetInterForm()) 523 if (m_pDocument->GetSDKDoc()->GetInterForm())
689 return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled(); 524 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaValidationsEnabled();
690 return TRUE; 525 return TRUE;
691 } 526 }
692 527
693 void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, 528 void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc,
694 FX_BOOL bEnabled) { 529 FX_BOOL bEnabled) {
695 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) 530 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
696 return; 531 return;
697 if (m_pSDKDoc->GetInterForm()) 532 if (m_pDocument->GetSDKDoc()->GetInterForm())
698 m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled); 533 m_pDocument->GetSDKDoc()->GetInterForm()->XfaSetValidationsEnabled(
534 bEnabled);
699 } 535 }
700 536
701 void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, 537 void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc,
702 CXFA_FFWidget* hWidget) { 538 CXFA_FFWidget* hWidget) {
703 if (hDoc != m_pXFADoc.get()) 539 if (hDoc != m_pDocument->GetXFADoc())
704 return; 540 return;
705 541
706 if (!hWidget) { 542 if (!hWidget) {
707 m_pSDKDoc->SetFocusAnnot(nullptr); 543 m_pDocument->GetSDKDoc()->SetFocusAnnot(nullptr);
708 return; 544 return;
709 } 545 }
710 546
711 int pageViewCount = m_pSDKDoc->GetPageViewCount(); 547 int pageViewCount = m_pDocument->GetSDKDoc()->GetPageViewCount();
712 for (int i = 0; i < pageViewCount; i++) { 548 for (int i = 0; i < pageViewCount; i++) {
713 CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i); 549 CPDFSDK_PageView* pPageView = m_pDocument->GetSDKDoc()->GetPageView(i);
714 if (!pPageView) 550 if (!pPageView)
715 continue; 551 continue;
716 552
717 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget); 553 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget);
718 if (pAnnot) { 554 if (pAnnot) {
719 m_pSDKDoc->SetFocusAnnot(pAnnot); 555 m_pDocument->GetSDKDoc()->SetFocusAnnot(pAnnot);
720 break; 556 break;
721 } 557 }
722 } 558 }
723 } 559 }
724 560
725 void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, 561 void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc,
726 int32_t nStartPage, 562 int32_t nStartPage,
727 int32_t nEndPage, 563 int32_t nEndPage,
728 uint32_t dwOptions) { 564 uint32_t dwOptions) {
729 if (hDoc != m_pXFADoc.get()) 565 if (hDoc != m_pDocument->GetXFADoc())
730 return; 566 return;
731 567
732 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 568 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
733 if (!pEnv || !pEnv->GetFormFillInfo() || 569 if (!pEnv || !pEnv->GetFormFillInfo() ||
734 !pEnv->GetFormFillInfo()->m_pJsPlatform || 570 !pEnv->GetFormFillInfo()->m_pJsPlatform ||
735 !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { 571 !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) {
736 return; 572 return;
737 } 573 }
738 574
739 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( 575 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print(
740 pEnv->GetFormFillInfo()->m_pJsPlatform, 576 pEnv->GetFormFillInfo()->m_pJsPlatform,
741 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, 577 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage,
742 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, 578 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage,
743 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, 579 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder,
744 dwOptions & XFA_PRINTOPT_PrintAnnot); 580 dwOptions & XFA_PRINTOPT_PrintAnnot);
745 } 581 }
746 582
747 FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { 583 FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) {
748 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) 584 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
749 return 0; 585 return 0;
750 586
751 CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm(); 587 CPDFSDK_InterForm* pInterForm = m_pDocument->GetSDKDoc()->GetInterForm();
752 if (!pInterForm) 588 if (!pInterForm)
753 return 0; 589 return 0;
754 590
755 return ArgbEncode(pInterForm->GetHighlightAlpha(), 591 return ArgbEncode(pInterForm->GetHighlightAlpha(),
756 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); 592 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA));
757 } 593 }
758 594
759 FX_BOOL CPDFXFA_Document::NotifySubmit(FX_BOOL bPrevOrPost) { 595 FX_BOOL CPDFXFA_DocEnvironment::NotifySubmit(FX_BOOL bPrevOrPost) {
760 if (bPrevOrPost) 596 if (bPrevOrPost)
761 return OnBeforeNotifySubmit(); 597 return OnBeforeNotifySubmit();
762 598
763 OnAfterNotifySubmit(); 599 OnAfterNotifySubmit();
764 return TRUE; 600 return TRUE;
765 } 601 }
766 602
767 FX_BOOL CPDFXFA_Document::OnBeforeNotifySubmit() { 603 FX_BOOL CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
768 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) 604 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
605 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
769 return TRUE; 606 return TRUE;
770 607
771 if (!m_pXFADocView) 608 if (!m_pDocument->GetXFADocView())
772 return TRUE; 609 return TRUE;
773 610
774 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); 611 CXFA_FFWidgetHandler* pWidgetHandler =
612 m_pDocument->GetXFADocView()->GetWidgetHandler();
775 if (!pWidgetHandler) 613 if (!pWidgetHandler)
776 return TRUE; 614 return TRUE;
777 615
778 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( 616 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
779 m_pXFADocView->CreateWidgetAccIterator()); 617 m_pDocument->GetXFADocView()->CreateWidgetAccIterator());
780 if (pWidgetAccIterator) { 618 if (pWidgetAccIterator) {
781 CXFA_EventParam Param; 619 CXFA_EventParam Param;
782 Param.m_eType = XFA_EVENT_PreSubmit; 620 Param.m_eType = XFA_EVENT_PreSubmit;
783 while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) 621 while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext())
784 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); 622 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
785 } 623 }
786 624
787 pWidgetAccIterator.reset(m_pXFADocView->CreateWidgetAccIterator()); 625 pWidgetAccIterator.reset(
626 m_pDocument->GetXFADocView()->CreateWidgetAccIterator());
788 if (!pWidgetAccIterator) 627 if (!pWidgetAccIterator)
789 return TRUE; 628 return TRUE;
790 629
791 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); 630 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
792 pWidgetAcc = pWidgetAccIterator->MoveToNext(); 631 pWidgetAcc = pWidgetAccIterator->MoveToNext();
793 while (pWidgetAcc) { 632 while (pWidgetAcc) {
794 int fRet = pWidgetAcc->ProcessValidate(-1); 633 int fRet = pWidgetAcc->ProcessValidate(-1);
795 if (fRet == XFA_EVENTERROR_Error) { 634 if (fRet == XFA_EVENTERROR_Error) {
796 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 635 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
797 if (!pEnv) 636 if (!pEnv)
798 return FALSE; 637 return FALSE;
799 638
800 CFX_WideString ws; 639 CFX_WideString ws;
801 ws.FromLocal(IDS_XFA_Validate_Input); 640 ws.FromLocal(IDS_XFA_Validate_Input);
802 CFX_ByteString bs = ws.UTF16LE_Encode(); 641 CFX_ByteString bs = ws.UTF16LE_Encode();
803 int len = bs.GetLength(); 642 int len = bs.GetLength();
804 pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 643 pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"",
805 0, 1); 644 0, 1);
806 bs.ReleaseBuffer(len); 645 bs.ReleaseBuffer(len);
807 return FALSE; 646 return FALSE;
808 } 647 }
809 pWidgetAcc = pWidgetAccIterator->MoveToNext(); 648 pWidgetAcc = pWidgetAccIterator->MoveToNext();
810 } 649 }
811 m_pXFADocView->UpdateDocView(); 650 m_pDocument->GetXFADocView()->UpdateDocView();
812 651
813 return TRUE; 652 return TRUE;
814 } 653 }
815 654
816 void CPDFXFA_Document::OnAfterNotifySubmit() { 655 void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() {
817 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) 656 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
657 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
818 return; 658 return;
819 659
820 if (!m_pXFADocView) 660 if (!m_pDocument->GetXFADocView())
821 return; 661 return;
822 662
823 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); 663 CXFA_FFWidgetHandler* pWidgetHandler =
664 m_pDocument->GetXFADocView()->GetWidgetHandler();
824 if (!pWidgetHandler) 665 if (!pWidgetHandler)
825 return; 666 return;
826 667
827 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( 668 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
828 m_pXFADocView->CreateWidgetAccIterator()); 669 m_pDocument->GetXFADocView()->CreateWidgetAccIterator());
829 if (!pWidgetAccIterator) 670 if (!pWidgetAccIterator)
830 return; 671 return;
831 672
832 CXFA_EventParam Param; 673 CXFA_EventParam Param;
833 Param.m_eType = XFA_EVENT_PostSubmit; 674 Param.m_eType = XFA_EVENT_PostSubmit;
834 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); 675 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
835 while (pWidgetAcc) { 676 while (pWidgetAcc) {
836 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); 677 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
837 pWidgetAcc = pWidgetAccIterator->MoveToNext(); 678 pWidgetAcc = pWidgetAccIterator->MoveToNext();
838 } 679 }
839 m_pXFADocView->UpdateDocView(); 680 m_pDocument->GetXFADocView()->UpdateDocView();
840 } 681 }
841 682
842 FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { 683 FX_BOOL CPDFXFA_DocEnvironment::SubmitData(CXFA_FFDoc* hDoc,
843 if (!NotifySubmit(TRUE) || !m_pXFADocView) 684 CXFA_Submit submit) {
685 if (!NotifySubmit(TRUE) || !m_pDocument->GetXFADocView())
844 return FALSE; 686 return FALSE;
845 687
846 m_pXFADocView->UpdateDocView(); 688 m_pDocument->GetXFADocView()->UpdateDocView();
847 FX_BOOL ret = SubmitDataInternal(hDoc, submit); 689 FX_BOOL ret = SubmitDataInternal(hDoc, submit);
848 NotifySubmit(FALSE); 690 NotifySubmit(FALSE);
849 return ret; 691 return ret;
850 } 692 }
851 693
852 IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, 694 IFX_FileRead* CPDFXFA_DocEnvironment::OpenLinkedFile(
853 const CFX_WideString& wsLink) { 695 CXFA_FFDoc* hDoc,
854 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 696 const CFX_WideString& wsLink) {
697 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
855 if (!pEnv) 698 if (!pEnv)
856 return FALSE; 699 return FALSE;
857 700
858 CFX_ByteString bs = wsLink.UTF16LE_Encode(); 701 CFX_ByteString bs = wsLink.UTF16LE_Encode();
859 int len = bs.GetLength(); 702 int len = bs.GetLength();
860 FPDF_FILEHANDLER* pFileHandler = 703 FPDF_FILEHANDLER* pFileHandler =
861 pEnv->FFI_OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); 704 pEnv->FFI_OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb");
862 bs.ReleaseBuffer(len); 705 bs.ReleaseBuffer(len);
863 706
864 if (!pFileHandler) 707 if (!pFileHandler)
865 return nullptr; 708 return nullptr;
866 return new CFPDF_FileStream(pFileHandler); 709 return new CFPDF_FileStream(pFileHandler);
867 } 710 }
868 711
869 FX_BOOL CPDFXFA_Document::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, 712 FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
870 int fileType, 713 int fileType,
871 FPDF_DWORD encodeType, 714 FPDF_DWORD encodeType,
872 FPDF_DWORD flag) { 715 FPDF_DWORD flag) {
873 if (!m_pXFADocView) 716 if (!m_pDocument->GetXFADocView())
874 return FALSE; 717 return FALSE;
875 718
876 CFX_ByteString content; 719 CFX_ByteString content;
877 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 720 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
878 if (!pEnv) 721 if (!pEnv)
879 return FALSE; 722 return FALSE;
880 723
881 CFPDF_FileStream fileStream(pFileHandler); 724 CFPDF_FileStream fileStream(pFileHandler);
882 if (fileType == FXFA_SAVEAS_XML) { 725 if (fileType == FXFA_SAVEAS_XML) {
883 const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; 726 const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
884 fileStream.WriteBlock(kContent, 0, strlen(kContent)); 727 fileStream.WriteBlock(kContent, 0, strlen(kContent));
885 m_pXFADoc->SavePackage(XFA_HASHCODE_Data, &fileStream, nullptr); 728 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Data, &fileStream,
729 nullptr);
886 return TRUE; 730 return TRUE;
887 } 731 }
888 732
889 if (fileType != FXFA_SAVEAS_XDP) 733 if (fileType != FXFA_SAVEAS_XDP)
890 return TRUE; 734 return TRUE;
891 735
892 if (!flag) { 736 if (!flag) {
893 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | 737 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
894 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; 738 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
895 } 739 }
896 if (!m_pPDFDoc) { 740 if (!m_pDocument->GetPDFDoc()) {
897 fileStream.Flush(); 741 fileStream.Flush();
898 return FALSE; 742 return FALSE;
899 } 743 }
900 744
901 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); 745 CPDF_Dictionary* pRoot = m_pDocument->GetPDFDoc()->GetRoot();
902 if (!pRoot) { 746 if (!pRoot) {
903 fileStream.Flush(); 747 fileStream.Flush();
904 return FALSE; 748 return FALSE;
905 } 749 }
906 750
907 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); 751 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
908 if (!pAcroForm) { 752 if (!pAcroForm) {
909 fileStream.Flush(); 753 fileStream.Flush();
910 return FALSE; 754 return FALSE;
911 } 755 }
(...skipping 24 matching lines...) Expand all
936 continue; 780 continue;
937 if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS)) 781 if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS))
938 continue; 782 continue;
939 if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA)) 783 if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA))
940 continue; 784 continue;
941 if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF)) 785 if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF))
942 continue; 786 continue;
943 if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM)) 787 if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM))
944 continue; 788 continue;
945 if (pPrePDFObj->GetString() == "form") { 789 if (pPrePDFObj->GetString() == "form") {
946 m_pXFADoc->SavePackage(XFA_HASHCODE_Form, &fileStream, nullptr); 790 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Form, &fileStream,
791 nullptr);
947 } else if (pPrePDFObj->GetString() == "datasets") { 792 } else if (pPrePDFObj->GetString() == "datasets") {
948 m_pXFADoc->SavePackage(XFA_HASHCODE_Datasets, &fileStream, nullptr); 793 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Datasets, &fileStream,
794 nullptr);
949 } else { 795 } else {
950 // PDF,creator. 796 // PDF,creator.
951 } 797 }
952 } 798 }
953 return TRUE; 799 return TRUE;
954 } 800 }
955 801
956 void CPDFXFA_Document::ClearChangeMark() { 802 void CPDFXFA_DocEnvironment::ToXFAContentFlags(CFX_WideString csSrcContent,
957 if (m_pSDKDoc) 803 FPDF_DWORD& flag) {
958 m_pSDKDoc->ClearChangeMark();
959 }
960
961 void CPDFXFA_Document::ToXFAContentFlags(CFX_WideString csSrcContent,
962 FPDF_DWORD& flag) {
963 if (csSrcContent.Find(L" config ", 0) != -1) 804 if (csSrcContent.Find(L" config ", 0) != -1)
964 flag |= FXFA_CONFIG; 805 flag |= FXFA_CONFIG;
965 if (csSrcContent.Find(L" template ", 0) != -1) 806 if (csSrcContent.Find(L" template ", 0) != -1)
966 flag |= FXFA_TEMPLATE; 807 flag |= FXFA_TEMPLATE;
967 if (csSrcContent.Find(L" localeSet ", 0) != -1) 808 if (csSrcContent.Find(L" localeSet ", 0) != -1)
968 flag |= FXFA_LOCALESET; 809 flag |= FXFA_LOCALESET;
969 if (csSrcContent.Find(L" datasets ", 0) != -1) 810 if (csSrcContent.Find(L" datasets ", 0) != -1)
970 flag |= FXFA_DATASETS; 811 flag |= FXFA_DATASETS;
971 if (csSrcContent.Find(L" xmpmeta ", 0) != -1) 812 if (csSrcContent.Find(L" xmpmeta ", 0) != -1)
972 flag |= FXFA_XMPMETA; 813 flag |= FXFA_XMPMETA;
973 if (csSrcContent.Find(L" xfdf ", 0) != -1) 814 if (csSrcContent.Find(L" xfdf ", 0) != -1)
974 flag |= FXFA_XFDF; 815 flag |= FXFA_XFDF;
975 if (csSrcContent.Find(L" form ", 0) != -1) 816 if (csSrcContent.Find(L" form ", 0) != -1)
976 flag |= FXFA_FORM; 817 flag |= FXFA_FORM;
977 if (flag == 0) { 818 if (flag == 0) {
978 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | 819 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
979 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; 820 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
980 } 821 }
981 } 822 }
982 823
983 FX_BOOL CPDFXFA_Document::MailToInfo(CFX_WideString& csURL, 824 FX_BOOL CPDFXFA_DocEnvironment::MailToInfo(CFX_WideString& csURL,
984 CFX_WideString& csToAddress, 825 CFX_WideString& csToAddress,
985 CFX_WideString& csCCAddress, 826 CFX_WideString& csCCAddress,
986 CFX_WideString& csBCCAddress, 827 CFX_WideString& csBCCAddress,
987 CFX_WideString& csSubject, 828 CFX_WideString& csSubject,
988 CFX_WideString& csMsg) { 829 CFX_WideString& csMsg) {
989 CFX_WideString srcURL = csURL; 830 CFX_WideString srcURL = csURL;
990 srcURL.TrimLeft(); 831 srcURL.TrimLeft();
991 if (srcURL.Left(7).CompareNoCase(L"mailto:") != 0) 832 if (srcURL.Left(7).CompareNoCase(L"mailto:") != 0)
992 return FALSE; 833 return FALSE;
993 834
994 int pos = srcURL.Find(L'?', 0); 835 int pos = srcURL.Find(L'?', 0);
995 CFX_WideString tmp; 836 CFX_WideString tmp;
996 if (pos == -1) { 837 if (pos == -1) {
997 pos = srcURL.Find(L'@', 0); 838 pos = srcURL.Find(L'@', 0);
998 if (pos == -1) 839 if (pos == -1)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 csMsg += tmp; 879 csMsg += tmp;
1039 } 880 }
1040 srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1)); 881 srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1));
1041 } 882 }
1042 csToAddress.Replace(L",", L";"); 883 csToAddress.Replace(L",", L";");
1043 csCCAddress.Replace(L",", L";"); 884 csCCAddress.Replace(L",", L";");
1044 csBCCAddress.Replace(L",", L";"); 885 csBCCAddress.Replace(L",", L";");
1045 return TRUE; 886 return TRUE;
1046 } 887 }
1047 888
1048 FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, 889 FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc,
1049 CXFA_Submit submit) { 890 CXFA_Submit submit) {
1050 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 891 CPDFDoc_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
1051 if (!pEnv) 892 if (!pEnv)
1052 return FALSE; 893 return FALSE;
1053 894
1054 CFX_WideStringC csURLC; 895 CFX_WideStringC csURLC;
1055 submit.GetSubmitTarget(csURLC); 896 submit.GetSubmitTarget(csURLC);
1056 CFX_WideString csURL(csURLC); 897 CFX_WideString csURL(csURLC);
1057 if (csURL.IsEmpty()) { 898 if (csURL.IsEmpty()) {
1058 CFX_WideString ws; 899 CFX_WideString ws;
1059 ws.FromLocal("Submit cancelled."); 900 ws.FromLocal("Submit cancelled.");
1060 CFX_ByteString bs = ws.UTF16LE_Encode(); 901 CFX_ByteString bs = ws.UTF16LE_Encode();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 CFX_WideString ws; 980 CFX_WideString ws;
1140 CFX_ByteString bs = csURL.UTF16LE_Encode(); 981 CFX_ByteString bs = csURL.UTF16LE_Encode();
1141 int len = bs.GetLength(); 982 int len = bs.GetLength();
1142 pEnv->FFI_UploadTo(pFileHandler, fileFlag, 983 pEnv->FFI_UploadTo(pFileHandler, fileFlag,
1143 (FPDF_WIDESTRING)bs.GetBuffer(len)); 984 (FPDF_WIDESTRING)bs.GetBuffer(len));
1144 bs.ReleaseBuffer(len); 985 bs.ReleaseBuffer(len);
1145 } 986 }
1146 return bRet; 987 return bRet;
1147 } 988 }
1148 989
1149 FX_BOOL CPDFXFA_Document::SetGlobalProperty(CXFA_FFDoc* hDoc, 990 FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty(
1150 const CFX_ByteStringC& szPropName, 991 CXFA_FFDoc* hDoc,
1151 CFXJSE_Value* pValue) { 992 const CFX_ByteStringC& szPropName,
1152 if (hDoc != m_pXFADoc.get()) 993 CFXJSE_Value* pValue) {
994 if (hDoc != m_pDocument->GetXFADoc())
1153 return FALSE; 995 return FALSE;
1154 996
1155 if (m_pSDKDoc && m_pSDKDoc->GetEnv()->GetJSRuntime()) 997 if (m_pDocument->GetSDKDoc() &&
1156 return m_pSDKDoc->GetEnv()->GetJSRuntime()->SetValueByName(szPropName, 998 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime())
1157 pValue); 999 return m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->SetValueByName(
1000 szPropName, pValue);
1158 return FALSE; 1001 return FALSE;
1159 } 1002 }
1160 1003
1161 FX_BOOL CPDFXFA_Document::GetGlobalProperty(CXFA_FFDoc* hDoc, 1004 FX_BOOL CPDFXFA_DocEnvironment::GetGlobalProperty(
1162 const CFX_ByteStringC& szPropName, 1005 CXFA_FFDoc* hDoc,
1163 CFXJSE_Value* pValue) { 1006 const CFX_ByteStringC& szPropName,
1164 if (hDoc != m_pXFADoc.get()) 1007 CFXJSE_Value* pValue) {
1008 if (hDoc != m_pDocument->GetXFADoc())
1165 return FALSE; 1009 return FALSE;
1166 if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime()) 1010 if (!m_pDocument->GetSDKDoc() ||
1011 !m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime())
1167 return FALSE; 1012 return FALSE;
1168 1013
1169 if (!m_pJSContext) { 1014 if (!m_pJSContext) {
1170 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc.get()); 1015 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->SetReaderDocument(
1171 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); 1016 m_pDocument->GetSDKDoc());
1017 m_pJSContext =
1018 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->NewContext();
1172 } 1019 }
1173 1020
1174 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, 1021 return m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->GetValueByName(
1175 pValue); 1022 szPropName, pValue);
1176 } 1023 }
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698