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

Side by Side Diff: fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp

Issue 2396213002: Convert CPDFXFA_Document to use CPDFSDK_FormFillEnvironment (Closed)
Patch Set: Review fixes Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfformfill.cpp ('k') | fpdfsdk/fpdfxfa/cpdfxfa_document.h » ('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 2016 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/cpdfxfa_docenvironment.h" 7 #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h"
8 8
9 #include "core/fpdfapi/parser/cpdf_array.h" 9 #include "core/fpdfapi/parser/cpdf_array.h"
10 #include "core/fpdfapi/parser/cpdf_stream_acc.h" 10 #include "core/fpdfapi/parser/cpdf_stream_acc.h"
(...skipping 23 matching lines...) Expand all
34 #define FXFA_FORM 0x01000000 34 #define FXFA_FORM 0x01000000
35 #define FXFA_PDF 0x10000000 35 #define FXFA_PDF 0x10000000
36 #define FXFA_XFA_ALL 0x01111111 36 #define FXFA_XFA_ALL 0x01111111
37 37
38 CPDFXFA_DocEnvironment::CPDFXFA_DocEnvironment(CPDFXFA_Document* doc) 38 CPDFXFA_DocEnvironment::CPDFXFA_DocEnvironment(CPDFXFA_Document* doc)
39 : m_pDocument(doc), m_pJSContext(nullptr) { 39 : m_pDocument(doc), m_pJSContext(nullptr) {
40 ASSERT(m_pDocument); 40 ASSERT(m_pDocument);
41 } 41 }
42 42
43 CPDFXFA_DocEnvironment::~CPDFXFA_DocEnvironment() { 43 CPDFXFA_DocEnvironment::~CPDFXFA_DocEnvironment() {
44 if (m_pJSContext && m_pDocument->GetSDKDoc() && 44 if (m_pJSContext && m_pDocument->GetFormFillEnv())
45 m_pDocument->GetSDKDoc()->GetEnv()) 45 m_pDocument->GetFormFillEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext);
46 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->ReleaseContext(
47 m_pJSContext);
48 } 46 }
49 47
50 void CPDFXFA_DocEnvironment::SetChangeMark(CXFA_FFDoc* hDoc) { 48 void CPDFXFA_DocEnvironment::SetChangeMark(CXFA_FFDoc* hDoc) {
51 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetSDKDoc()) 49 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv())
52 m_pDocument->GetSDKDoc()->SetChangeMark(); 50 m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetChangeMark();
53 } 51 }
54 52
55 void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView, 53 void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView,
56 const CFX_RectF& rt, 54 const CFX_RectF& rt,
57 uint32_t dwFlags /* = 0 */) { 55 uint32_t dwFlags /* = 0 */) {
58 if (!m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) 56 if (!m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
59 return; 57 return;
60 58
61 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) 59 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
62 return; 60 return;
63 61
64 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pPageView); 62 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pPageView);
65 if (!pPage) 63 if (!pPage)
66 return; 64 return;
67 65
68 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 66 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
69 if (!pEnv) 67 if (!pFormFillEnv)
70 return; 68 return;
71 69
72 CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt); 70 CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt);
73 pEnv->Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, rcPage.right, 71 pFormFillEnv->Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom,
74 rcPage.top); 72 rcPage.right, rcPage.top);
75 } 73 }
76 74
77 void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget, 75 void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget,
78 FX_BOOL bVisible, 76 FX_BOOL bVisible,
79 const CFX_RectF* pRtAnchor) { 77 const CFX_RectF* pRtAnchor) {
80 if (!hWidget || !pRtAnchor || !m_pDocument->GetXFADoc() || 78 if (!hWidget || !pRtAnchor || !m_pDocument->GetXFADoc() ||
81 !m_pDocument->GetSDKDoc() || !m_pDocument->GetXFADocView()) 79 !m_pDocument->GetFormFillEnv() || !m_pDocument->GetXFADocView())
82 return; 80 return;
83 81
84 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) 82 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
85 return; 83 return;
86 84
87 CXFA_FFWidgetHandler* pWidgetHandler = 85 CXFA_FFWidgetHandler* pWidgetHandler =
88 m_pDocument->GetXFADocView()->GetWidgetHandler(); 86 m_pDocument->GetXFADocView()->GetWidgetHandler();
89 if (!pWidgetHandler) 87 if (!pWidgetHandler)
90 return; 88 return;
91 89
92 CXFA_FFPageView* pPageView = hWidget->GetPageView(); 90 CXFA_FFPageView* pPageView = hWidget->GetPageView();
93 if (!pPageView) 91 if (!pPageView)
94 return; 92 return;
95 93
96 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pPageView); 94 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pPageView);
97 if (!pPage) 95 if (!pPage)
98 return; 96 return;
99 97
100 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 98 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
101 if (!pEnv) 99 if (!pFormFillEnv)
102 return; 100 return;
103 101
104 CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor); 102 CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor);
105 pEnv->DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, 103 pFormFillEnv->DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left,
106 rcCaret.right, rcCaret.bottom); 104 rcCaret.top, rcCaret.right, rcCaret.bottom);
107 } 105 }
108 106
109 FX_BOOL CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget, 107 FX_BOOL CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
110 FX_FLOAT fMinPopup, 108 FX_FLOAT fMinPopup,
111 FX_FLOAT fMaxPopup, 109 FX_FLOAT fMaxPopup,
112 const CFX_RectF& rtAnchor, 110 const CFX_RectF& rtAnchor,
113 CFX_RectF& rtPopup) { 111 CFX_RectF& rtPopup) {
114 if (!hWidget) 112 if (!hWidget)
115 return FALSE; 113 return FALSE;
116 114
117 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); 115 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView();
118 if (!pXFAPageView) 116 if (!pXFAPageView)
119 return FALSE; 117 return FALSE;
120 118
121 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pXFAPageView); 119 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pXFAPageView);
122 if (!pPage) 120 if (!pPage)
123 return FALSE; 121 return FALSE;
124 122
125 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); 123 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc();
126 int nRotate = pWidgetAcc->GetRotate(); 124 int nRotate = pWidgetAcc->GetRotate();
127 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 125 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
128 if (!pEnv) 126 if (!pFormFillEnv)
129 return FALSE; 127 return FALSE;
130 128
131 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; 129 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f};
132 pEnv->GetPageViewRect(pPage, pageViewRect); 130 pFormFillEnv->GetPageViewRect(pPage, pageViewRect);
133 131
134 int t1; 132 int t1;
135 int t2; 133 int t2;
136 CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor); 134 CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor);
137 switch (nRotate) { 135 switch (nRotate) {
138 case 90: { 136 case 90: {
139 t1 = (int)(pageViewRect.right - rcAnchor.right); 137 t1 = (int)(pageViewRect.right - rcAnchor.right);
140 t2 = (int)(rcAnchor.left - pageViewRect.left); 138 t2 = (int)(rcAnchor.left - pageViewRect.left);
141 if (rcAnchor.bottom < pageViewRect.bottom) 139 if (rcAnchor.bottom < pageViewRect.bottom)
142 rtPopup.left += rcAnchor.bottom - pageViewRect.bottom; 140 rtPopup.left += rcAnchor.bottom - pageViewRect.bottom;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return FALSE; 226 return FALSE;
229 227
230 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); 228 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView();
231 if (!pXFAPageView) 229 if (!pXFAPageView)
232 return FALSE; 230 return FALSE;
233 231
234 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pXFAPageView); 232 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pXFAPageView);
235 if (!pPage) 233 if (!pPage)
236 return FALSE; 234 return FALSE;
237 235
238 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 236 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
239 if (!pEnv) 237 if (!pFormFillEnv)
240 return FALSE; 238 return FALSE;
241 239
242 int menuFlag = 0; 240 int menuFlag = 0;
243 if (hWidget->CanUndo()) 241 if (hWidget->CanUndo())
244 menuFlag |= FXFA_MENU_UNDO; 242 menuFlag |= FXFA_MENU_UNDO;
245 if (hWidget->CanRedo()) 243 if (hWidget->CanRedo())
246 menuFlag |= FXFA_MENU_REDO; 244 menuFlag |= FXFA_MENU_REDO;
247 if (hWidget->CanPaste()) 245 if (hWidget->CanPaste())
248 menuFlag |= FXFA_MENU_PASTE; 246 menuFlag |= FXFA_MENU_PASTE;
249 if (hWidget->CanCopy()) 247 if (hWidget->CanCopy())
250 menuFlag |= FXFA_MENU_COPY; 248 menuFlag |= FXFA_MENU_COPY;
251 if (hWidget->CanCut()) 249 if (hWidget->CanCut())
252 menuFlag |= FXFA_MENU_CUT; 250 menuFlag |= FXFA_MENU_CUT;
253 if (hWidget->CanSelectAll()) 251 if (hWidget->CanSelectAll())
254 menuFlag |= FXFA_MENU_SELECTALL; 252 menuFlag |= FXFA_MENU_SELECTALL;
255 253
256 return pEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup); 254 return pFormFillEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup);
257 } 255 }
258 256
259 void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, 257 void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView,
260 uint32_t dwFlags) { 258 uint32_t dwFlags) {
261 CPDFSDK_Document* pSDKDoc = m_pDocument->GetSDKDoc(); 259 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
262 if (!pSDKDoc) 260 if (!pFormFillEnv)
263 return;
264
265 CPDFSDK_FormFillEnvironment* pEnv = pSDKDoc->GetEnv();
266 if (!pEnv)
267 return; 261 return;
268 262
269 if (m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_LOADING || 263 if (m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_LOADING ||
270 m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_CLOSING || 264 m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_CLOSING ||
271 XFA_PAGEVIEWEVENT_StopLayout != dwFlags) 265 XFA_PAGEVIEWEVENT_StopLayout != dwFlags)
272 return; 266 return;
273 267
274 int nNewCount = m_pDocument->GetPageCount(); 268 int nNewCount = m_pDocument->GetPageCount();
275 if (nNewCount == m_pDocument->GetOriginalPageCount()) 269 if (nNewCount == m_pDocument->GetOriginalPageCount())
276 return; 270 return;
277 271
278 CXFA_FFDocView* pXFADocView = m_pDocument->GetXFADocView(); 272 CXFA_FFDocView* pXFADocView = m_pDocument->GetXFADocView();
279 if (!pXFADocView) 273 if (!pXFADocView)
280 return; 274 return;
281 275
282 for (int iPageIter = 0; iPageIter < m_pDocument->GetOriginalPageCount(); 276 for (int iPageIter = 0; iPageIter < m_pDocument->GetOriginalPageCount();
283 iPageIter++) { 277 iPageIter++) {
284 CPDFXFA_Page* pPage = m_pDocument->GetXFAPageList()->GetAt(iPageIter); 278 CPDFXFA_Page* pPage = m_pDocument->GetXFAPageList()->GetAt(iPageIter);
285 if (!pPage) 279 if (!pPage)
286 continue; 280 continue;
287 281
288 m_pDocument->GetSDKDoc()->RemovePageView(pPage); 282 m_pDocument->GetFormFillEnv()->GetSDKDocument()->RemovePageView(pPage);
289 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); 283 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter));
290 } 284 }
291 285
292 int flag = (nNewCount < m_pDocument->GetOriginalPageCount()) 286 int flag = (nNewCount < m_pDocument->GetOriginalPageCount())
293 ? FXFA_PAGEVIEWEVENT_POSTREMOVED 287 ? FXFA_PAGEVIEWEVENT_POSTREMOVED
294 : FXFA_PAGEVIEWEVENT_POSTADDED; 288 : FXFA_PAGEVIEWEVENT_POSTADDED;
295 int count = FXSYS_abs(nNewCount - m_pDocument->GetOriginalPageCount()); 289 int count = FXSYS_abs(nNewCount - m_pDocument->GetOriginalPageCount());
296 m_pDocument->SetOriginalPageCount(nNewCount); 290 m_pDocument->SetOriginalPageCount(nNewCount);
297 pEnv->PageEvent(count, flag); 291 pFormFillEnv->PageEvent(count, flag);
298 } 292 }
299 293
300 void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, 294 void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget,
301 CXFA_WidgetAcc* pWidgetData) { 295 CXFA_WidgetAcc* pWidgetData) {
302 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) 296 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget)
303 return; 297 return;
304 298
305 CXFA_FFPageView* pPageView = hWidget->GetPageView(); 299 CXFA_FFPageView* pPageView = hWidget->GetPageView();
306 if (!pPageView) 300 if (!pPageView)
307 return; 301 return;
308 302
309 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView); 303 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView);
310 if (!pXFAPage) 304 if (!pXFAPage)
311 return; 305 return;
312 306
313 m_pDocument->GetSDKDoc()->GetPageView(pXFAPage, true)->AddAnnot(hWidget); 307 m_pDocument->GetFormFillEnv()
308 ->GetSDKDocument()
309 ->GetPageView(pXFAPage, true)
310 ->AddAnnot(hWidget);
314 } 311 }
315 312
316 void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget, 313 void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget,
317 CXFA_WidgetAcc* pWidgetData) { 314 CXFA_WidgetAcc* pWidgetData) {
318 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) 315 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget)
319 return; 316 return;
320 317
321 CXFA_FFPageView* pPageView = hWidget->GetPageView(); 318 CXFA_FFPageView* pPageView = hWidget->GetPageView();
322 if (!pPageView) 319 if (!pPageView)
323 return; 320 return;
324 321
325 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView); 322 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView);
326 if (!pXFAPage) 323 if (!pXFAPage)
327 return; 324 return;
328 325
329 CPDFSDK_PageView* pSdkPageView = 326 CPDFSDK_PageView* pSdkPageView =
330 m_pDocument->GetSDKDoc()->GetPageView(pXFAPage, true); 327 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageView(pXFAPage,
328 true);
331 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) 329 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget))
332 pSdkPageView->DeleteAnnot(pAnnot); 330 pSdkPageView->DeleteAnnot(pAnnot);
333 } 331 }
334 332
335 int32_t CPDFXFA_DocEnvironment::CountPages(CXFA_FFDoc* hDoc) { 333 int32_t CPDFXFA_DocEnvironment::CountPages(CXFA_FFDoc* hDoc) {
336 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetSDKDoc()) 334 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv())
337 return m_pDocument->GetPageCount(); 335 return m_pDocument->GetPageCount();
338 return 0; 336 return 0;
339 } 337 }
340 338
341 int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) { 339 int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) {
342 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) 340 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
343 return -1; 341 return -1;
344 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) 342 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
345 return -1; 343 return -1;
346 344
347 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 345 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
348 if (!pEnv) 346 if (!pFormFillEnv)
349 return -1; 347 return -1;
350 348
351 return pEnv->GetCurrentPageIndex(this); 349 return pFormFillEnv->GetCurrentPageIndex(this);
352 } 350 }
353 351
354 void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc, 352 void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc,
355 int32_t iCurPage) { 353 int32_t iCurPage) {
356 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc() || 354 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv() ||
357 m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || 355 m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 ||
358 iCurPage >= m_pDocument->GetSDKDoc()->GetPageCount()) { 356 iCurPage >=
357 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageCount()) {
359 return; 358 return;
360 } 359 }
361 360
362 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 361 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
363 if (!pEnv) 362 if (!pFormFillEnv)
364 return; 363 return;
365 pEnv->SetCurrentPage(this, iCurPage); 364 pFormFillEnv->SetCurrentPage(this, iCurPage);
366 } 365 }
367 366
368 FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { 367 FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) {
369 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) 368 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
370 return FALSE; 369 return FALSE;
371 if (m_pDocument->GetSDKDoc()->GetInterForm()) 370 if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm())
372 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaCalculateEnabled(); 371 return m_pDocument->GetFormFillEnv()
372 ->GetSDKDocument()
373 ->GetInterForm()
374 ->IsXfaCalculateEnabled();
373 return FALSE; 375 return FALSE;
374 } 376 }
375 377
376 void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc, 378 void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc,
377 FX_BOOL bEnabled) { 379 FX_BOOL bEnabled) {
378 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) 380 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
379 return; 381 return;
380 if (m_pDocument->GetSDKDoc()->GetInterForm()) 382 if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm())
381 m_pDocument->GetSDKDoc()->GetInterForm()->XfaEnableCalculate(bEnabled); 383 m_pDocument->GetFormFillEnv()
384 ->GetSDKDocument()
385 ->GetInterForm()
386 ->XfaEnableCalculate(bEnabled);
382 } 387 }
383 388
384 void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, 389 void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc,
385 CFX_WideString& wsTitle) { 390 CFX_WideString& wsTitle) {
386 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc()) 391 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc())
387 return; 392 return;
388 393
389 CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo(); 394 CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo();
390 if (!pInfoDict) 395 if (!pInfoDict)
391 return; 396 return;
(...skipping 15 matching lines...) Expand all
407 void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, 412 void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
408 const CFX_WideString& wsFilePath, 413 const CFX_WideString& wsFilePath,
409 FX_BOOL bXDP) { 414 FX_BOOL bXDP) {
410 if (hDoc != m_pDocument->GetXFADoc()) 415 if (hDoc != m_pDocument->GetXFADoc())
411 return; 416 return;
412 417
413 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && 418 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
414 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) 419 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
415 return; 420 return;
416 421
417 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 422 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
418 if (!pEnv) 423 if (!pFormFillEnv)
419 return; 424 return;
420 425
421 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; 426 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML;
422 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); 427 CFX_ByteString bs = wsFilePath.UTF16LE_Encode();
423 if (wsFilePath.IsEmpty()) { 428 if (wsFilePath.IsEmpty()) {
424 if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) 429 if (!pFormFillEnv->GetFormFillInfo() ||
430 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform)
425 return; 431 return;
426 432
427 CFX_WideString filepath = pEnv->JS_fieldBrowse(); 433 CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse();
428 bs = filepath.UTF16LE_Encode(); 434 bs = filepath.UTF16LE_Encode();
429 } 435 }
430 int len = bs.GetLength(); 436 int len = bs.GetLength();
431 FPDF_FILEHANDLER* pFileHandler = 437 FPDF_FILEHANDLER* pFileHandler =
432 pEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, 438 pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML,
433 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); 439 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb");
434 bs.ReleaseBuffer(len); 440 bs.ReleaseBuffer(len);
435 if (!pFileHandler) 441 if (!pFileHandler)
436 return; 442 return;
437 443
438 CFPDF_FileStream fileWrite(pFileHandler); 444 CFPDF_FileStream fileWrite(pFileHandler);
439 CFX_ByteString content; 445 CFX_ByteString content;
440 if (fileType == FXFA_SAVEAS_XML) { 446 if (fileType == FXFA_SAVEAS_XML) {
441 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; 447 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
442 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), 448 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
443 content.GetLength()); 449 content.GetLength());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 510 }
505 511
506 void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, 512 void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc,
507 const CFX_WideString& bsURL) { 513 const CFX_WideString& bsURL) {
508 if (hDoc != m_pDocument->GetXFADoc()) 514 if (hDoc != m_pDocument->GetXFADoc())
509 return; 515 return;
510 516
511 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) 517 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
512 return; 518 return;
513 519
514 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 520 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
515 if (!pEnv) 521 if (!pFormFillEnv)
516 return; 522 return;
517 523
518 CFX_WideStringC str(bsURL.c_str()); 524 CFX_WideStringC str(bsURL.c_str());
519 pEnv->GotoURL(this, str); 525 pFormFillEnv->GotoURL(this, str);
520 } 526 }
521 527
522 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { 528 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) {
523 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) 529 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
524 return FALSE; 530 return FALSE;
525 if (m_pDocument->GetSDKDoc()->GetInterForm()) 531 if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm())
526 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaValidationsEnabled(); 532 return m_pDocument->GetFormFillEnv()
533 ->GetSDKDocument()
534 ->GetInterForm()
535 ->IsXfaValidationsEnabled();
527 return TRUE; 536 return TRUE;
528 } 537 }
529 538
530 void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc, 539 void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc,
531 FX_BOOL bEnabled) { 540 FX_BOOL bEnabled) {
532 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) 541 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
533 return; 542 return;
534 if (m_pDocument->GetSDKDoc()->GetInterForm()) 543 if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm())
535 m_pDocument->GetSDKDoc()->GetInterForm()->XfaSetValidationsEnabled( 544 m_pDocument->GetFormFillEnv()
536 bEnabled); 545 ->GetSDKDocument()
546 ->GetInterForm()
547 ->XfaSetValidationsEnabled(bEnabled);
537 } 548 }
538 549
539 void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc, 550 void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc,
540 CXFA_FFWidget* hWidget) { 551 CXFA_FFWidget* hWidget) {
541 if (hDoc != m_pDocument->GetXFADoc()) 552 if (hDoc != m_pDocument->GetXFADoc())
542 return; 553 return;
543 554
544 if (!hWidget) { 555 if (!hWidget) {
545 CPDFSDK_Annot::ObservedPtr pNull; 556 CPDFSDK_Annot::ObservedPtr pNull;
546 m_pDocument->GetSDKDoc()->SetFocusAnnot(&pNull); 557 m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetFocusAnnot(&pNull);
547 return; 558 return;
548 } 559 }
549 560
550 int pageViewCount = m_pDocument->GetSDKDoc()->GetPageViewCount(); 561 int pageViewCount =
562 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageViewCount();
551 for (int i = 0; i < pageViewCount; i++) { 563 for (int i = 0; i < pageViewCount; i++) {
552 CPDFSDK_PageView* pPageView = m_pDocument->GetSDKDoc()->GetPageView(i); 564 CPDFSDK_PageView* pPageView =
565 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageView(i);
553 if (!pPageView) 566 if (!pPageView)
554 continue; 567 continue;
555 568
556 CPDFSDK_Annot::ObservedPtr pAnnot(pPageView->GetAnnotByXFAWidget(hWidget)); 569 CPDFSDK_Annot::ObservedPtr pAnnot(pPageView->GetAnnotByXFAWidget(hWidget));
557 if (pAnnot) { 570 if (pAnnot) {
558 m_pDocument->GetSDKDoc()->SetFocusAnnot(&pAnnot); 571 m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetFocusAnnot(&pAnnot);
559 break; 572 break;
560 } 573 }
561 } 574 }
562 } 575 }
563 576
564 void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc, 577 void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc,
565 int32_t nStartPage, 578 int32_t nStartPage,
566 int32_t nEndPage, 579 int32_t nEndPage,
567 uint32_t dwOptions) { 580 uint32_t dwOptions) {
568 if (hDoc != m_pDocument->GetXFADoc()) 581 if (hDoc != m_pDocument->GetXFADoc())
569 return; 582 return;
570 583
571 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 584 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
572 if (!pEnv || !pEnv->GetFormFillInfo() || 585 if (!pFormFillEnv || !pFormFillEnv->GetFormFillInfo() ||
573 !pEnv->GetFormFillInfo()->m_pJsPlatform || 586 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform ||
574 !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { 587 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) {
575 return; 588 return;
576 } 589 }
577 590
578 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( 591 pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print(
579 pEnv->GetFormFillInfo()->m_pJsPlatform, 592 pFormFillEnv->GetFormFillInfo()->m_pJsPlatform,
580 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, 593 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage,
581 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, 594 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage,
582 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, 595 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder,
583 dwOptions & XFA_PRINTOPT_PrintAnnot); 596 dwOptions & XFA_PRINTOPT_PrintAnnot);
584 } 597 }
585 598
586 FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { 599 FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) {
587 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) 600 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
588 return 0; 601 return 0;
589 602
590 CPDFSDK_InterForm* pInterForm = m_pDocument->GetSDKDoc()->GetInterForm(); 603 CPDFSDK_InterForm* pInterForm =
604 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm();
591 if (!pInterForm) 605 if (!pInterForm)
592 return 0; 606 return 0;
593 607
594 return ArgbEncode(pInterForm->GetHighlightAlpha(), 608 return ArgbEncode(pInterForm->GetHighlightAlpha(),
595 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); 609 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA));
596 } 610 }
597 611
598 FX_BOOL CPDFXFA_DocEnvironment::NotifySubmit(FX_BOOL bPrevOrPost) { 612 FX_BOOL CPDFXFA_DocEnvironment::NotifySubmit(FX_BOOL bPrevOrPost) {
599 if (bPrevOrPost) 613 if (bPrevOrPost)
600 return OnBeforeNotifySubmit(); 614 return OnBeforeNotifySubmit();
(...skipping 27 matching lines...) Expand all
628 pWidgetAccIterator.reset( 642 pWidgetAccIterator.reset(
629 m_pDocument->GetXFADocView()->CreateWidgetAccIterator()); 643 m_pDocument->GetXFADocView()->CreateWidgetAccIterator());
630 if (!pWidgetAccIterator) 644 if (!pWidgetAccIterator)
631 return TRUE; 645 return TRUE;
632 646
633 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); 647 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
634 pWidgetAcc = pWidgetAccIterator->MoveToNext(); 648 pWidgetAcc = pWidgetAccIterator->MoveToNext();
635 while (pWidgetAcc) { 649 while (pWidgetAcc) {
636 int fRet = pWidgetAcc->ProcessValidate(-1); 650 int fRet = pWidgetAcc->ProcessValidate(-1);
637 if (fRet == XFA_EVENTERROR_Error) { 651 if (fRet == XFA_EVENTERROR_Error) {
638 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 652 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
639 if (!pEnv) 653 if (!pFormFillEnv)
640 return FALSE; 654 return FALSE;
641 655
642 CFX_WideString ws; 656 CFX_WideString ws;
643 ws.FromLocal(IDS_XFA_Validate_Input); 657 ws.FromLocal(IDS_XFA_Validate_Input);
644 CFX_ByteString bs = ws.UTF16LE_Encode(); 658 CFX_ByteString bs = ws.UTF16LE_Encode();
645 int len = bs.GetLength(); 659 int len = bs.GetLength();
646 pEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, 660 pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len),
647 1); 661 (FPDF_WIDESTRING)L"", 0, 1);
648 bs.ReleaseBuffer(len); 662 bs.ReleaseBuffer(len);
649 return FALSE; 663 return FALSE;
650 } 664 }
651 pWidgetAcc = pWidgetAccIterator->MoveToNext(); 665 pWidgetAcc = pWidgetAccIterator->MoveToNext();
652 } 666 }
653 m_pDocument->GetXFADocView()->UpdateDocView(); 667 m_pDocument->GetXFADocView()->UpdateDocView();
654 668
655 return TRUE; 669 return TRUE;
656 } 670 }
657 671
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 704
691 m_pDocument->GetXFADocView()->UpdateDocView(); 705 m_pDocument->GetXFADocView()->UpdateDocView();
692 FX_BOOL ret = SubmitDataInternal(hDoc, submit); 706 FX_BOOL ret = SubmitDataInternal(hDoc, submit);
693 NotifySubmit(FALSE); 707 NotifySubmit(FALSE);
694 return ret; 708 return ret;
695 } 709 }
696 710
697 IFX_FileRead* CPDFXFA_DocEnvironment::OpenLinkedFile( 711 IFX_FileRead* CPDFXFA_DocEnvironment::OpenLinkedFile(
698 CXFA_FFDoc* hDoc, 712 CXFA_FFDoc* hDoc,
699 const CFX_WideString& wsLink) { 713 const CFX_WideString& wsLink) {
700 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 714 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
701 if (!pEnv) 715 if (!pFormFillEnv)
702 return FALSE; 716 return FALSE;
703 717
704 CFX_ByteString bs = wsLink.UTF16LE_Encode(); 718 CFX_ByteString bs = wsLink.UTF16LE_Encode();
705 int len = bs.GetLength(); 719 int len = bs.GetLength();
706 FPDF_FILEHANDLER* pFileHandler = 720 FPDF_FILEHANDLER* pFileHandler =
707 pEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); 721 pFormFillEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb");
708 bs.ReleaseBuffer(len); 722 bs.ReleaseBuffer(len);
709 723
710 if (!pFileHandler) 724 if (!pFileHandler)
711 return nullptr; 725 return nullptr;
712 return new CFPDF_FileStream(pFileHandler); 726 return new CFPDF_FileStream(pFileHandler);
713 } 727 }
714 728
715 FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, 729 FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
716 int fileType, 730 int fileType,
717 FPDF_DWORD encodeType, 731 FPDF_DWORD encodeType,
718 FPDF_DWORD flag) { 732 FPDF_DWORD flag) {
719 if (!m_pDocument->GetXFADocView()) 733 if (!m_pDocument->GetXFADocView())
720 return FALSE; 734 return FALSE;
721 735
722 CFX_ByteString content; 736 CFX_ByteString content;
723 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 737 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
724 if (!pEnv) 738 if (!pFormFillEnv)
725 return FALSE; 739 return FALSE;
726 740
727 CFPDF_FileStream fileStream(pFileHandler); 741 CFPDF_FileStream fileStream(pFileHandler);
728 if (fileType == FXFA_SAVEAS_XML) { 742 if (fileType == FXFA_SAVEAS_XML) {
729 const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; 743 const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
730 fileStream.WriteBlock(kContent, 0, strlen(kContent)); 744 fileStream.WriteBlock(kContent, 0, strlen(kContent));
731 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Data, &fileStream, 745 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Data, &fileStream,
732 nullptr); 746 nullptr);
733 return TRUE; 747 return TRUE;
734 } 748 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1)); 898 srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1));
885 } 899 }
886 csToAddress.Replace(L",", L";"); 900 csToAddress.Replace(L",", L";");
887 csCCAddress.Replace(L",", L";"); 901 csCCAddress.Replace(L",", L";");
888 csBCCAddress.Replace(L",", L";"); 902 csBCCAddress.Replace(L",", L";");
889 return TRUE; 903 return TRUE;
890 } 904 }
891 905
892 FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, 906 FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc,
893 CXFA_Submit submit) { 907 CXFA_Submit submit) {
894 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); 908 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
895 if (!pEnv) 909 if (!pFormFillEnv)
896 return FALSE; 910 return FALSE;
897 911
898 CFX_WideStringC csURLC; 912 CFX_WideStringC csURLC;
899 submit.GetSubmitTarget(csURLC); 913 submit.GetSubmitTarget(csURLC);
900 CFX_WideString csURL(csURLC); 914 CFX_WideString csURL(csURLC);
901 if (csURL.IsEmpty()) { 915 if (csURL.IsEmpty()) {
902 CFX_WideString ws; 916 CFX_WideString ws;
903 ws.FromLocal("Submit cancelled."); 917 ws.FromLocal("Submit cancelled.");
904 CFX_ByteString bs = ws.UTF16LE_Encode(); 918 CFX_ByteString bs = ws.UTF16LE_Encode();
905 int len = bs.GetLength(); 919 int len = bs.GetLength();
906 pEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, 4); 920 pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len),
921 (FPDF_WIDESTRING)L"", 0, 4);
907 bs.ReleaseBuffer(len); 922 bs.ReleaseBuffer(len);
908 return FALSE; 923 return FALSE;
909 } 924 }
910 925
911 FPDF_BOOL bRet = TRUE; 926 FPDF_BOOL bRet = TRUE;
912 FPDF_FILEHANDLER* pFileHandler = nullptr; 927 FPDF_FILEHANDLER* pFileHandler = nullptr;
913 int fileFlag = -1; 928 int fileFlag = -1;
914 switch (submit.GetSubmitFormat()) { 929 switch (submit.GetSubmitFormat()) {
915 case XFA_ATTRIBUTEENUM_Xdp: { 930 case XFA_ATTRIBUTEENUM_Xdp: {
916 CFX_WideStringC csContentC; 931 CFX_WideStringC csContentC;
917 submit.GetSubmitXDPContent(csContentC); 932 submit.GetSubmitXDPContent(csContentC);
918 CFX_WideString csContent; 933 CFX_WideString csContent;
919 csContent = csContentC; 934 csContent = csContentC;
920 csContent.TrimLeft(); 935 csContent.TrimLeft();
921 csContent.TrimRight(); 936 csContent.TrimRight();
922 CFX_WideString space; 937 CFX_WideString space;
923 space.FromLocal(" "); 938 space.FromLocal(" ");
924 csContent = space + csContent + space; 939 csContent = space + csContent + space;
925 FPDF_DWORD flag = 0; 940 FPDF_DWORD flag = 0;
926 if (submit.IsSubmitEmbedPDF()) 941 if (submit.IsSubmitEmbedPDF())
927 flag |= FXFA_PDF; 942 flag |= FXFA_PDF;
928 943
929 ToXFAContentFlags(csContent, flag); 944 ToXFAContentFlags(csContent, flag);
930 pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); 945 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb");
931 fileFlag = FXFA_SAVEAS_XDP; 946 fileFlag = FXFA_SAVEAS_XDP;
932 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); 947 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag);
933 break; 948 break;
934 } 949 }
935 case XFA_ATTRIBUTEENUM_Xml: 950 case XFA_ATTRIBUTEENUM_Xml:
936 pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); 951 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb");
937 fileFlag = FXFA_SAVEAS_XML; 952 fileFlag = FXFA_SAVEAS_XML;
938 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); 953 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL);
939 break; 954 break;
940 case XFA_ATTRIBUTEENUM_Pdf: 955 case XFA_ATTRIBUTEENUM_Pdf:
941 break; 956 break;
942 case XFA_ATTRIBUTEENUM_Urlencoded: 957 case XFA_ATTRIBUTEENUM_Urlencoded:
943 pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); 958 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb");
944 fileFlag = FXFA_SAVEAS_XML; 959 fileFlag = FXFA_SAVEAS_XML;
945 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); 960 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL);
946 break; 961 break;
947 default: 962 default:
948 return false; 963 return false;
949 } 964 }
950 if (!pFileHandler) 965 if (!pFileHandler)
951 return FALSE; 966 return FALSE;
952 if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) { 967 if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) {
953 CFX_WideString csToAddress; 968 CFX_WideString csToAddress;
(...skipping 10 matching lines...) Expand all
964 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); 979 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode();
965 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); 980 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode();
966 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); 981 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode();
967 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); 982 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode();
968 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); 983 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength());
969 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); 984 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength());
970 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); 985 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength());
971 FPDF_WIDESTRING pSubject = 986 FPDF_WIDESTRING pSubject =
972 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); 987 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength());
973 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); 988 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
974 pEnv->EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); 989 pFormFillEnv->EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg);
975 bsTo.ReleaseBuffer(); 990 bsTo.ReleaseBuffer();
976 bsCC.ReleaseBuffer(); 991 bsCC.ReleaseBuffer();
977 bsBcc.ReleaseBuffer(); 992 bsBcc.ReleaseBuffer();
978 bsSubject.ReleaseBuffer(); 993 bsSubject.ReleaseBuffer();
979 bsMsg.ReleaseBuffer(); 994 bsMsg.ReleaseBuffer();
980 } else { 995 } else {
981 // HTTP or FTP 996 // HTTP or FTP
982 CFX_WideString ws; 997 CFX_WideString ws;
983 CFX_ByteString bs = csURL.UTF16LE_Encode(); 998 CFX_ByteString bs = csURL.UTF16LE_Encode();
984 int len = bs.GetLength(); 999 int len = bs.GetLength();
985 pEnv->UploadTo(pFileHandler, fileFlag, (FPDF_WIDESTRING)bs.GetBuffer(len)); 1000 pFormFillEnv->UploadTo(pFileHandler, fileFlag,
1001 (FPDF_WIDESTRING)bs.GetBuffer(len));
986 bs.ReleaseBuffer(len); 1002 bs.ReleaseBuffer(len);
987 } 1003 }
988 return bRet; 1004 return bRet;
989 } 1005 }
990 1006
991 FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty( 1007 FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty(
992 CXFA_FFDoc* hDoc, 1008 CXFA_FFDoc* hDoc,
993 const CFX_ByteStringC& szPropName, 1009 const CFX_ByteStringC& szPropName,
994 CFXJSE_Value* pValue) { 1010 CFXJSE_Value* pValue) {
995 if (hDoc != m_pDocument->GetXFADoc()) 1011 if (hDoc != m_pDocument->GetXFADoc())
996 return FALSE; 1012 return FALSE;
997 1013
998 if (m_pDocument->GetSDKDoc() && 1014 if (m_pDocument->GetFormFillEnv() &&
999 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()) 1015 m_pDocument->GetFormFillEnv()->GetJSRuntime()) {
1000 return m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->SetValueByName( 1016 return m_pDocument->GetFormFillEnv()->GetJSRuntime()->SetValueByName(
1001 szPropName, pValue); 1017 szPropName, pValue);
1018 }
1002 return FALSE; 1019 return FALSE;
1003 } 1020 }
1004 1021
1005 FX_BOOL CPDFXFA_DocEnvironment::GetGlobalProperty( 1022 FX_BOOL CPDFXFA_DocEnvironment::GetGlobalProperty(
1006 CXFA_FFDoc* hDoc, 1023 CXFA_FFDoc* hDoc,
1007 const CFX_ByteStringC& szPropName, 1024 const CFX_ByteStringC& szPropName,
1008 CFXJSE_Value* pValue) { 1025 CFXJSE_Value* pValue) {
1009 if (hDoc != m_pDocument->GetXFADoc()) 1026 if (hDoc != m_pDocument->GetXFADoc())
1010 return FALSE; 1027 return FALSE;
1011 if (!m_pDocument->GetSDKDoc() || 1028 if (!m_pDocument->GetFormFillEnv() ||
1012 !m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()) 1029 !m_pDocument->GetFormFillEnv()->GetJSRuntime()) {
1013 return FALSE; 1030 return FALSE;
1031 }
1014 1032
1015 CPDFSDK_FormFillEnvironment* pFormFillEnv = 1033 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
1016 m_pDocument->GetSDKDoc()->GetEnv();
1017 if (!m_pJSContext) 1034 if (!m_pJSContext)
1018 m_pJSContext = pFormFillEnv->GetJSRuntime()->NewContext(); 1035 m_pJSContext = pFormFillEnv->GetJSRuntime()->NewContext();
1019 1036
1020 return pFormFillEnv->GetJSRuntime()->GetValueByName(szPropName, pValue); 1037 return pFormFillEnv->GetJSRuntime()->GetValueByName(szPropName, pValue);
1021 } 1038 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfformfill.cpp ('k') | fpdfsdk/fpdfxfa/cpdfxfa_document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698