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

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

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

Powered by Google App Engine
This is Rietveld 408576698