OLD | NEW |
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 Loading... |
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 Loading... |
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 (CPDFSDK_InterForm* pForm = m_pDocument->GetFormFillEnv()->GetInterForm()) |
372 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaCalculateEnabled(); | 371 return pForm->IsXfaCalculateEnabled(); |
373 return FALSE; | 372 return FALSE; |
374 } | 373 } |
375 | 374 |
376 void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc, | 375 void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc, |
377 FX_BOOL bEnabled) { | 376 FX_BOOL bEnabled) { |
378 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) | 377 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
379 return; | 378 return; |
380 if (m_pDocument->GetSDKDoc()->GetInterForm()) | 379 if (CPDFSDK_InterForm* pForm = m_pDocument->GetFormFillEnv()->GetInterForm()) |
381 m_pDocument->GetSDKDoc()->GetInterForm()->XfaEnableCalculate(bEnabled); | 380 pForm->XfaEnableCalculate(bEnabled); |
382 } | 381 } |
383 | 382 |
384 void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, | 383 void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, |
385 CFX_WideString& wsTitle) { | 384 CFX_WideString& wsTitle) { |
386 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc()) | 385 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc()) |
387 return; | 386 return; |
388 | 387 |
389 CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo(); | 388 CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo(); |
390 if (!pInfoDict) | 389 if (!pInfoDict) |
391 return; | 390 return; |
(...skipping 15 matching lines...) Expand all Loading... |
407 void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, | 406 void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, |
408 const CFX_WideString& wsFilePath, | 407 const CFX_WideString& wsFilePath, |
409 FX_BOOL bXDP) { | 408 FX_BOOL bXDP) { |
410 if (hDoc != m_pDocument->GetXFADoc()) | 409 if (hDoc != m_pDocument->GetXFADoc()) |
411 return; | 410 return; |
412 | 411 |
413 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && | 412 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && |
414 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) | 413 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) |
415 return; | 414 return; |
416 | 415 |
417 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 416 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
418 if (!pEnv) | 417 if (!pFormFillEnv) |
419 return; | 418 return; |
420 | 419 |
421 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; | 420 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; |
422 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); | 421 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); |
423 if (wsFilePath.IsEmpty()) { | 422 if (wsFilePath.IsEmpty()) { |
424 if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) | 423 if (!pFormFillEnv->GetFormFillInfo() || |
| 424 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform) |
425 return; | 425 return; |
426 | 426 |
427 CFX_WideString filepath = pEnv->JS_fieldBrowse(); | 427 CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse(); |
428 bs = filepath.UTF16LE_Encode(); | 428 bs = filepath.UTF16LE_Encode(); |
429 } | 429 } |
430 int len = bs.GetLength(); | 430 int len = bs.GetLength(); |
431 FPDF_FILEHANDLER* pFileHandler = | 431 FPDF_FILEHANDLER* pFileHandler = |
432 pEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, | 432 pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, |
433 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); | 433 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); |
434 bs.ReleaseBuffer(len); | 434 bs.ReleaseBuffer(len); |
435 if (!pFileHandler) | 435 if (!pFileHandler) |
436 return; | 436 return; |
437 | 437 |
438 CFPDF_FileStream fileWrite(pFileHandler); | 438 CFPDF_FileStream fileWrite(pFileHandler); |
439 CFX_ByteString content; | 439 CFX_ByteString content; |
440 if (fileType == FXFA_SAVEAS_XML) { | 440 if (fileType == FXFA_SAVEAS_XML) { |
441 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; | 441 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
442 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), | 442 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), |
443 content.GetLength()); | 443 content.GetLength()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 } | 504 } |
505 | 505 |
506 void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, | 506 void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, |
507 const CFX_WideString& bsURL) { | 507 const CFX_WideString& bsURL) { |
508 if (hDoc != m_pDocument->GetXFADoc()) | 508 if (hDoc != m_pDocument->GetXFADoc()) |
509 return; | 509 return; |
510 | 510 |
511 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 511 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
512 return; | 512 return; |
513 | 513 |
514 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 514 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
515 if (!pEnv) | 515 if (!pFormFillEnv) |
516 return; | 516 return; |
517 | 517 |
518 CFX_WideStringC str(bsURL.c_str()); | 518 CFX_WideStringC str(bsURL.c_str()); |
519 pEnv->GotoURL(this, str); | 519 pFormFillEnv->GotoURL(this, str); |
520 } | 520 } |
521 | 521 |
522 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { | 522 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { |
523 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) | 523 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
524 return FALSE; | 524 return FALSE; |
525 if (m_pDocument->GetSDKDoc()->GetInterForm()) | 525 if (m_pDocument->GetFormFillEnv()->GetInterForm()) |
526 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaValidationsEnabled(); | 526 return m_pDocument->GetFormFillEnv() |
| 527 ->GetInterForm() |
| 528 ->IsXfaValidationsEnabled(); |
527 return TRUE; | 529 return TRUE; |
528 } | 530 } |
529 | 531 |
530 void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc, | 532 void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc, |
531 FX_BOOL bEnabled) { | 533 FX_BOOL bEnabled) { |
532 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) | 534 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
533 return; | 535 return; |
534 if (m_pDocument->GetSDKDoc()->GetInterForm()) | 536 if (m_pDocument->GetFormFillEnv()->GetInterForm()) |
535 m_pDocument->GetSDKDoc()->GetInterForm()->XfaSetValidationsEnabled( | 537 m_pDocument->GetFormFillEnv()->GetInterForm()->XfaSetValidationsEnabled( |
536 bEnabled); | 538 bEnabled); |
537 } | 539 } |
538 | 540 |
539 void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc, | 541 void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc, |
540 CXFA_FFWidget* hWidget) { | 542 CXFA_FFWidget* hWidget) { |
541 if (hDoc != m_pDocument->GetXFADoc()) | 543 if (hDoc != m_pDocument->GetXFADoc()) |
542 return; | 544 return; |
543 | 545 |
544 if (!hWidget) { | 546 if (!hWidget) { |
545 CPDFSDK_Annot::ObservedPtr pNull; | 547 CPDFSDK_Annot::ObservedPtr pNull; |
546 m_pDocument->GetSDKDoc()->SetFocusAnnot(&pNull); | 548 m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetFocusAnnot(&pNull); |
547 return; | 549 return; |
548 } | 550 } |
549 | 551 |
550 int pageViewCount = m_pDocument->GetSDKDoc()->GetPageViewCount(); | 552 int pageViewCount = |
| 553 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageViewCount(); |
551 for (int i = 0; i < pageViewCount; i++) { | 554 for (int i = 0; i < pageViewCount; i++) { |
552 CPDFSDK_PageView* pPageView = m_pDocument->GetSDKDoc()->GetPageView(i); | 555 CPDFSDK_PageView* pPageView = |
| 556 m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageView(i); |
553 if (!pPageView) | 557 if (!pPageView) |
554 continue; | 558 continue; |
555 | 559 |
556 CPDFSDK_Annot::ObservedPtr pAnnot(pPageView->GetAnnotByXFAWidget(hWidget)); | 560 CPDFSDK_Annot::ObservedPtr pAnnot(pPageView->GetAnnotByXFAWidget(hWidget)); |
557 if (pAnnot) { | 561 if (pAnnot) { |
558 m_pDocument->GetSDKDoc()->SetFocusAnnot(&pAnnot); | 562 m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetFocusAnnot(&pAnnot); |
559 break; | 563 break; |
560 } | 564 } |
561 } | 565 } |
562 } | 566 } |
563 | 567 |
564 void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc, | 568 void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc, |
565 int32_t nStartPage, | 569 int32_t nStartPage, |
566 int32_t nEndPage, | 570 int32_t nEndPage, |
567 uint32_t dwOptions) { | 571 uint32_t dwOptions) { |
568 if (hDoc != m_pDocument->GetXFADoc()) | 572 if (hDoc != m_pDocument->GetXFADoc()) |
569 return; | 573 return; |
570 | 574 |
571 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 575 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
572 if (!pEnv || !pEnv->GetFormFillInfo() || | 576 if (!pFormFillEnv || !pFormFillEnv->GetFormFillInfo() || |
573 !pEnv->GetFormFillInfo()->m_pJsPlatform || | 577 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform || |
574 !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { | 578 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { |
575 return; | 579 return; |
576 } | 580 } |
577 | 581 |
578 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( | 582 pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( |
579 pEnv->GetFormFillInfo()->m_pJsPlatform, | 583 pFormFillEnv->GetFormFillInfo()->m_pJsPlatform, |
580 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, | 584 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, |
581 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, | 585 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, |
582 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, | 586 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, |
583 dwOptions & XFA_PRINTOPT_PrintAnnot); | 587 dwOptions & XFA_PRINTOPT_PrintAnnot); |
584 } | 588 } |
585 | 589 |
586 FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { | 590 FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { |
587 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) | 591 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) |
588 return 0; | 592 return 0; |
589 | 593 |
590 CPDFSDK_InterForm* pInterForm = m_pDocument->GetSDKDoc()->GetInterForm(); | 594 CPDFSDK_InterForm* pInterForm = m_pDocument->GetFormFillEnv()->GetInterForm(); |
591 if (!pInterForm) | 595 if (!pInterForm) |
592 return 0; | 596 return 0; |
593 | 597 |
594 return ArgbEncode(pInterForm->GetHighlightAlpha(), | 598 return ArgbEncode(pInterForm->GetHighlightAlpha(), |
595 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); | 599 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); |
596 } | 600 } |
597 | 601 |
598 FX_BOOL CPDFXFA_DocEnvironment::NotifySubmit(FX_BOOL bPrevOrPost) { | 602 FX_BOOL CPDFXFA_DocEnvironment::NotifySubmit(FX_BOOL bPrevOrPost) { |
599 if (bPrevOrPost) | 603 if (bPrevOrPost) |
600 return OnBeforeNotifySubmit(); | 604 return OnBeforeNotifySubmit(); |
(...skipping 27 matching lines...) Expand all Loading... |
628 pWidgetAccIterator.reset( | 632 pWidgetAccIterator.reset( |
629 m_pDocument->GetXFADocView()->CreateWidgetAccIterator()); | 633 m_pDocument->GetXFADocView()->CreateWidgetAccIterator()); |
630 if (!pWidgetAccIterator) | 634 if (!pWidgetAccIterator) |
631 return TRUE; | 635 return TRUE; |
632 | 636 |
633 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 637 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
634 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 638 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
635 while (pWidgetAcc) { | 639 while (pWidgetAcc) { |
636 int fRet = pWidgetAcc->ProcessValidate(-1); | 640 int fRet = pWidgetAcc->ProcessValidate(-1); |
637 if (fRet == XFA_EVENTERROR_Error) { | 641 if (fRet == XFA_EVENTERROR_Error) { |
638 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 642 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
639 if (!pEnv) | 643 if (!pFormFillEnv) |
640 return FALSE; | 644 return FALSE; |
641 | 645 |
642 CFX_WideString ws; | 646 CFX_WideString ws; |
643 ws.FromLocal(IDS_XFA_Validate_Input); | 647 ws.FromLocal(IDS_XFA_Validate_Input); |
644 CFX_ByteString bs = ws.UTF16LE_Encode(); | 648 CFX_ByteString bs = ws.UTF16LE_Encode(); |
645 int len = bs.GetLength(); | 649 int len = bs.GetLength(); |
646 pEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, | 650 pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), |
647 1); | 651 (FPDF_WIDESTRING)L"", 0, 1); |
648 bs.ReleaseBuffer(len); | 652 bs.ReleaseBuffer(len); |
649 return FALSE; | 653 return FALSE; |
650 } | 654 } |
651 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 655 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
652 } | 656 } |
653 m_pDocument->GetXFADocView()->UpdateDocView(); | 657 m_pDocument->GetXFADocView()->UpdateDocView(); |
654 | 658 |
655 return TRUE; | 659 return TRUE; |
656 } | 660 } |
657 | 661 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 | 694 |
691 m_pDocument->GetXFADocView()->UpdateDocView(); | 695 m_pDocument->GetXFADocView()->UpdateDocView(); |
692 FX_BOOL ret = SubmitDataInternal(hDoc, submit); | 696 FX_BOOL ret = SubmitDataInternal(hDoc, submit); |
693 NotifySubmit(FALSE); | 697 NotifySubmit(FALSE); |
694 return ret; | 698 return ret; |
695 } | 699 } |
696 | 700 |
697 IFX_FileRead* CPDFXFA_DocEnvironment::OpenLinkedFile( | 701 IFX_FileRead* CPDFXFA_DocEnvironment::OpenLinkedFile( |
698 CXFA_FFDoc* hDoc, | 702 CXFA_FFDoc* hDoc, |
699 const CFX_WideString& wsLink) { | 703 const CFX_WideString& wsLink) { |
700 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 704 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
701 if (!pEnv) | 705 if (!pFormFillEnv) |
702 return FALSE; | 706 return FALSE; |
703 | 707 |
704 CFX_ByteString bs = wsLink.UTF16LE_Encode(); | 708 CFX_ByteString bs = wsLink.UTF16LE_Encode(); |
705 int len = bs.GetLength(); | 709 int len = bs.GetLength(); |
706 FPDF_FILEHANDLER* pFileHandler = | 710 FPDF_FILEHANDLER* pFileHandler = |
707 pEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); | 711 pFormFillEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); |
708 bs.ReleaseBuffer(len); | 712 bs.ReleaseBuffer(len); |
709 | 713 |
710 if (!pFileHandler) | 714 if (!pFileHandler) |
711 return nullptr; | 715 return nullptr; |
712 return new CFPDF_FileStream(pFileHandler); | 716 return new CFPDF_FileStream(pFileHandler); |
713 } | 717 } |
714 | 718 |
715 FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, | 719 FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, |
716 int fileType, | 720 int fileType, |
717 FPDF_DWORD encodeType, | 721 FPDF_DWORD encodeType, |
718 FPDF_DWORD flag) { | 722 FPDF_DWORD flag) { |
719 if (!m_pDocument->GetXFADocView()) | 723 if (!m_pDocument->GetXFADocView()) |
720 return FALSE; | 724 return FALSE; |
721 | 725 |
722 CFX_ByteString content; | 726 CFX_ByteString content; |
723 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 727 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
724 if (!pEnv) | 728 if (!pFormFillEnv) |
725 return FALSE; | 729 return FALSE; |
726 | 730 |
727 CFPDF_FileStream fileStream(pFileHandler); | 731 CFPDF_FileStream fileStream(pFileHandler); |
728 if (fileType == FXFA_SAVEAS_XML) { | 732 if (fileType == FXFA_SAVEAS_XML) { |
729 const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; | 733 const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
730 fileStream.WriteBlock(kContent, 0, strlen(kContent)); | 734 fileStream.WriteBlock(kContent, 0, strlen(kContent)); |
731 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Data, &fileStream, | 735 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Data, &fileStream, |
732 nullptr); | 736 nullptr); |
733 return TRUE; | 737 return TRUE; |
734 } | 738 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1)); | 888 srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1)); |
885 } | 889 } |
886 csToAddress.Replace(L",", L";"); | 890 csToAddress.Replace(L",", L";"); |
887 csCCAddress.Replace(L",", L";"); | 891 csCCAddress.Replace(L",", L";"); |
888 csBCCAddress.Replace(L",", L";"); | 892 csBCCAddress.Replace(L",", L";"); |
889 return TRUE; | 893 return TRUE; |
890 } | 894 } |
891 | 895 |
892 FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, | 896 FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, |
893 CXFA_Submit submit) { | 897 CXFA_Submit submit) { |
894 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 898 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); |
895 if (!pEnv) | 899 if (!pFormFillEnv) |
896 return FALSE; | 900 return FALSE; |
897 | 901 |
898 CFX_WideStringC csURLC; | 902 CFX_WideStringC csURLC; |
899 submit.GetSubmitTarget(csURLC); | 903 submit.GetSubmitTarget(csURLC); |
900 CFX_WideString csURL(csURLC); | 904 CFX_WideString csURL(csURLC); |
901 if (csURL.IsEmpty()) { | 905 if (csURL.IsEmpty()) { |
902 CFX_WideString ws; | 906 CFX_WideString ws; |
903 ws.FromLocal("Submit cancelled."); | 907 ws.FromLocal("Submit cancelled."); |
904 CFX_ByteString bs = ws.UTF16LE_Encode(); | 908 CFX_ByteString bs = ws.UTF16LE_Encode(); |
905 int len = bs.GetLength(); | 909 int len = bs.GetLength(); |
906 pEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, 4); | 910 pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), |
| 911 (FPDF_WIDESTRING)L"", 0, 4); |
907 bs.ReleaseBuffer(len); | 912 bs.ReleaseBuffer(len); |
908 return FALSE; | 913 return FALSE; |
909 } | 914 } |
910 | 915 |
911 FPDF_BOOL bRet = TRUE; | 916 FPDF_BOOL bRet = TRUE; |
912 FPDF_FILEHANDLER* pFileHandler = nullptr; | 917 FPDF_FILEHANDLER* pFileHandler = nullptr; |
913 int fileFlag = -1; | 918 int fileFlag = -1; |
914 switch (submit.GetSubmitFormat()) { | 919 switch (submit.GetSubmitFormat()) { |
915 case XFA_ATTRIBUTEENUM_Xdp: { | 920 case XFA_ATTRIBUTEENUM_Xdp: { |
916 CFX_WideStringC csContentC; | 921 CFX_WideStringC csContentC; |
917 submit.GetSubmitXDPContent(csContentC); | 922 submit.GetSubmitXDPContent(csContentC); |
918 CFX_WideString csContent; | 923 CFX_WideString csContent; |
919 csContent = csContentC; | 924 csContent = csContentC; |
920 csContent.TrimLeft(); | 925 csContent.TrimLeft(); |
921 csContent.TrimRight(); | 926 csContent.TrimRight(); |
922 CFX_WideString space; | 927 CFX_WideString space; |
923 space.FromLocal(" "); | 928 space.FromLocal(" "); |
924 csContent = space + csContent + space; | 929 csContent = space + csContent + space; |
925 FPDF_DWORD flag = 0; | 930 FPDF_DWORD flag = 0; |
926 if (submit.IsSubmitEmbedPDF()) | 931 if (submit.IsSubmitEmbedPDF()) |
927 flag |= FXFA_PDF; | 932 flag |= FXFA_PDF; |
928 | 933 |
929 ToXFAContentFlags(csContent, flag); | 934 ToXFAContentFlags(csContent, flag); |
930 pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); | 935 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); |
931 fileFlag = FXFA_SAVEAS_XDP; | 936 fileFlag = FXFA_SAVEAS_XDP; |
932 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); | 937 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); |
933 break; | 938 break; |
934 } | 939 } |
935 case XFA_ATTRIBUTEENUM_Xml: | 940 case XFA_ATTRIBUTEENUM_Xml: |
936 pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); | 941 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
937 fileFlag = FXFA_SAVEAS_XML; | 942 fileFlag = FXFA_SAVEAS_XML; |
938 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); | 943 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); |
939 break; | 944 break; |
940 case XFA_ATTRIBUTEENUM_Pdf: | 945 case XFA_ATTRIBUTEENUM_Pdf: |
941 break; | 946 break; |
942 case XFA_ATTRIBUTEENUM_Urlencoded: | 947 case XFA_ATTRIBUTEENUM_Urlencoded: |
943 pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); | 948 pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
944 fileFlag = FXFA_SAVEAS_XML; | 949 fileFlag = FXFA_SAVEAS_XML; |
945 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); | 950 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); |
946 break; | 951 break; |
947 default: | 952 default: |
948 return false; | 953 return false; |
949 } | 954 } |
950 if (!pFileHandler) | 955 if (!pFileHandler) |
951 return FALSE; | 956 return FALSE; |
952 if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) { | 957 if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) { |
953 CFX_WideString csToAddress; | 958 CFX_WideString csToAddress; |
(...skipping 10 matching lines...) Expand all Loading... |
964 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); | 969 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); |
965 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); | 970 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); |
966 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); | 971 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); |
967 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); | 972 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); |
968 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); | 973 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); |
969 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); | 974 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); |
970 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); | 975 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); |
971 FPDF_WIDESTRING pSubject = | 976 FPDF_WIDESTRING pSubject = |
972 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); | 977 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); |
973 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); | 978 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
974 pEnv->EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); | 979 pFormFillEnv->EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); |
975 bsTo.ReleaseBuffer(); | 980 bsTo.ReleaseBuffer(); |
976 bsCC.ReleaseBuffer(); | 981 bsCC.ReleaseBuffer(); |
977 bsBcc.ReleaseBuffer(); | 982 bsBcc.ReleaseBuffer(); |
978 bsSubject.ReleaseBuffer(); | 983 bsSubject.ReleaseBuffer(); |
979 bsMsg.ReleaseBuffer(); | 984 bsMsg.ReleaseBuffer(); |
980 } else { | 985 } else { |
981 // HTTP or FTP | 986 // HTTP or FTP |
982 CFX_WideString ws; | 987 CFX_WideString ws; |
983 CFX_ByteString bs = csURL.UTF16LE_Encode(); | 988 CFX_ByteString bs = csURL.UTF16LE_Encode(); |
984 int len = bs.GetLength(); | 989 int len = bs.GetLength(); |
985 pEnv->UploadTo(pFileHandler, fileFlag, (FPDF_WIDESTRING)bs.GetBuffer(len)); | 990 pFormFillEnv->UploadTo(pFileHandler, fileFlag, |
| 991 (FPDF_WIDESTRING)bs.GetBuffer(len)); |
986 bs.ReleaseBuffer(len); | 992 bs.ReleaseBuffer(len); |
987 } | 993 } |
988 return bRet; | 994 return bRet; |
989 } | 995 } |
990 | 996 |
991 FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty( | 997 FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty( |
992 CXFA_FFDoc* hDoc, | 998 CXFA_FFDoc* hDoc, |
993 const CFX_ByteStringC& szPropName, | 999 const CFX_ByteStringC& szPropName, |
994 CFXJSE_Value* pValue) { | 1000 CFXJSE_Value* pValue) { |
995 if (hDoc != m_pDocument->GetXFADoc()) | 1001 if (hDoc != m_pDocument->GetXFADoc()) |
996 return FALSE; | 1002 return FALSE; |
997 | 1003 |
998 if (m_pDocument->GetSDKDoc() && | 1004 if (m_pDocument->GetFormFillEnv() && |
999 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()) | 1005 m_pDocument->GetFormFillEnv()->GetJSRuntime()) |
1000 return m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->SetValueByName( | 1006 return m_pDocument->GetFormFillEnv()->GetJSRuntime()->SetValueByName( |
1001 szPropName, pValue); | 1007 szPropName, pValue); |
1002 return FALSE; | 1008 return FALSE; |
1003 } | 1009 } |
1004 | 1010 |
1005 FX_BOOL CPDFXFA_DocEnvironment::GetGlobalProperty( | 1011 FX_BOOL CPDFXFA_DocEnvironment::GetGlobalProperty( |
1006 CXFA_FFDoc* hDoc, | 1012 CXFA_FFDoc* hDoc, |
1007 const CFX_ByteStringC& szPropName, | 1013 const CFX_ByteStringC& szPropName, |
1008 CFXJSE_Value* pValue) { | 1014 CFXJSE_Value* pValue) { |
1009 if (hDoc != m_pDocument->GetXFADoc()) | 1015 if (hDoc != m_pDocument->GetXFADoc()) |
1010 return FALSE; | 1016 return FALSE; |
1011 if (!m_pDocument->GetSDKDoc() || | 1017 if (!m_pDocument->GetFormFillEnv() || |
1012 !m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()) | 1018 !m_pDocument->GetFormFillEnv()->GetJSRuntime()) |
1013 return FALSE; | 1019 return FALSE; |
1014 | 1020 |
1015 if (!m_pJSContext) { | 1021 if (!m_pJSContext) { |
1016 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->SetReaderDocument( | 1022 m_pDocument->GetFormFillEnv()->GetJSRuntime()->SetReaderDocument( |
1017 m_pDocument->GetSDKDoc()); | 1023 m_pDocument->GetFormFillEnv()->GetSDKDocument()); |
1018 m_pJSContext = | 1024 m_pJSContext = m_pDocument->GetFormFillEnv()->GetJSRuntime()->NewContext(); |
1019 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->NewContext(); | |
1020 } | 1025 } |
1021 | 1026 |
1022 return m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->GetValueByName( | 1027 return m_pDocument->GetFormFillEnv()->GetJSRuntime()->GetValueByName( |
1023 szPropName, pValue); | 1028 szPropName, pValue); |
1024 } | 1029 } |
OLD | NEW |