| 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" |
| 11 #include "core/fpdfapi/parser/cpdf_string.h" | 11 #include "core/fpdfapi/parser/cpdf_string.h" |
| 12 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 12 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
| 13 #include "fpdfsdk/cpdfsdk_interform.h" | 13 #include "fpdfsdk/cpdfsdk_interform.h" |
| 14 #include "fpdfsdk/cpdfsdk_pageview.h" | 14 #include "fpdfsdk/cpdfsdk_pageview.h" |
| 15 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" | 15 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" |
| 16 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" | 16 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" |
| 17 #include "fpdfsdk/javascript/ijs_runtime.h" | 17 #include "fpdfsdk/javascript/ijs_runtime.h" |
| 18 #include "xfa/fxfa/xfa_ffdocview.h" | 18 #include "xfa/fxfa/xfa_ffdocview.h" |
| 19 #include "xfa/fxfa/xfa_ffwidget.h" | 19 #include "xfa/fxfa/xfa_ffwidget.h" |
| 20 #include "xfa/fxfa/xfa_ffwidgethandler.h" | 20 #include "xfa/fxfa/xfa_ffwidgethandler.h" |
| 21 | 21 |
| 22 #define IDS_XFA_Validate_Input \ | 22 #define IDS_XFA_Validate_Input \ |
| 23 "At least one required field was empty. Please fill in the required " \ | 23 "At least one required field was empty. Please fill in the required " \ |
| 24 "fields\r\n(highlighted) before continuing." | 24 "fields\r\n(highlighted) before continuing." |
| 25 | 25 |
| 26 // submit | 26 // submit |
| 27 #define FXFA_CONFIG 0x00000001 | 27 #define FXFA_CONFIG 0x00000001 |
| 28 #define FXFA_TEMPLATE 0x00000010 | 28 #define FXFA_TEMPLATE 0x00000010 |
| 29 #define FXFA_LOCALESET 0x00000100 | 29 #define FXFA_LOCALESET 0x00000100 |
| 30 #define FXFA_DATASETS 0x00001000 | 30 #define FXFA_DATASETS 0x00001000 |
| 31 #define FXFA_XMPMETA 0x00010000 | 31 #define FXFA_XMPMETA 0x00010000 |
| 32 #define FXFA_XFDF 0x00100000 | 32 #define FXFA_XFDF 0x00100000 |
| 33 #define FXFA_FORM 0x01000000 | 33 #define FXFA_FORM 0x01000000 |
| 34 #define FXFA_PDF 0x10000000 | 34 #define FXFA_PDF 0x10000000 |
| 35 #define FXFA_XFA_ALL 0x01111111 | 35 #define FXFA_XFA_ALL 0x01111111 |
| 36 | 36 |
| 37 CPDFXFA_DocEnvironment::CPDFXFA_DocEnvironment(CPDFXFA_Document* doc) | 37 CPDFXFA_DocEnvironment::CPDFXFA_DocEnvironment(CPDFXFA_Context* pContext) |
| 38 : m_pDocument(doc), m_pJSContext(nullptr) { | 38 : m_pContext(pContext), m_pJSContext(nullptr) { |
| 39 ASSERT(m_pDocument); | 39 ASSERT(m_pContext); |
| 40 } | 40 } |
| 41 | 41 |
| 42 CPDFXFA_DocEnvironment::~CPDFXFA_DocEnvironment() { | 42 CPDFXFA_DocEnvironment::~CPDFXFA_DocEnvironment() { |
| 43 if (m_pJSContext && m_pDocument->GetFormFillEnv()) | 43 if (m_pJSContext && m_pContext->GetFormFillEnv()) |
| 44 m_pDocument->GetFormFillEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); | 44 m_pContext->GetFormFillEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void CPDFXFA_DocEnvironment::SetChangeMark(CXFA_FFDoc* hDoc) { | 47 void CPDFXFA_DocEnvironment::SetChangeMark(CXFA_FFDoc* hDoc) { |
| 48 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv()) | 48 if (hDoc == m_pContext->GetXFADoc() && m_pContext->GetFormFillEnv()) |
| 49 m_pDocument->GetFormFillEnv()->SetChangeMark(); | 49 m_pContext->GetFormFillEnv()->SetChangeMark(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView, | 52 void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView, |
| 53 const CFX_RectF& rt, | 53 const CFX_RectF& rt, |
| 54 uint32_t dwFlags /* = 0 */) { | 54 uint32_t dwFlags /* = 0 */) { |
| 55 if (!m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 55 if (!m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) |
| 56 return; | 56 return; |
| 57 | 57 |
| 58 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 58 if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pPageView); | 61 CPDFXFA_Page* pPage = m_pContext->GetXFAPage(pPageView); |
| 62 if (!pPage) | 62 if (!pPage) |
| 63 return; | 63 return; |
| 64 | 64 |
| 65 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 65 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 66 if (!pFormFillEnv) | 66 if (!pFormFillEnv) |
| 67 return; | 67 return; |
| 68 | 68 |
| 69 CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt); | 69 CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt); |
| 70 pFormFillEnv->Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, | 70 pFormFillEnv->Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, |
| 71 rcPage.right, rcPage.top); | 71 rcPage.right, rcPage.top); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget, | 74 void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget, |
| 75 FX_BOOL bVisible, | 75 FX_BOOL bVisible, |
| 76 const CFX_RectF* pRtAnchor) { | 76 const CFX_RectF* pRtAnchor) { |
| 77 if (!hWidget || !pRtAnchor || !m_pDocument->GetXFADoc() || | 77 if (!hWidget || !pRtAnchor || !m_pContext->GetXFADoc() || |
| 78 !m_pDocument->GetFormFillEnv() || !m_pDocument->GetXFADocView()) | 78 !m_pContext->GetFormFillEnv() || !m_pContext->GetXFADocView()) |
| 79 return; | 79 return; |
| 80 | 80 |
| 81 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 81 if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 CXFA_FFWidgetHandler* pWidgetHandler = | 84 CXFA_FFWidgetHandler* pWidgetHandler = |
| 85 m_pDocument->GetXFADocView()->GetWidgetHandler(); | 85 m_pContext->GetXFADocView()->GetWidgetHandler(); |
| 86 if (!pWidgetHandler) | 86 if (!pWidgetHandler) |
| 87 return; | 87 return; |
| 88 | 88 |
| 89 CXFA_FFPageView* pPageView = hWidget->GetPageView(); | 89 CXFA_FFPageView* pPageView = hWidget->GetPageView(); |
| 90 if (!pPageView) | 90 if (!pPageView) |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pPageView); | 93 CPDFXFA_Page* pPage = m_pContext->GetXFAPage(pPageView); |
| 94 if (!pPage) | 94 if (!pPage) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 97 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 98 if (!pFormFillEnv) | 98 if (!pFormFillEnv) |
| 99 return; | 99 return; |
| 100 | 100 |
| 101 CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor); | 101 CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor); |
| 102 pFormFillEnv->DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, | 102 pFormFillEnv->DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, |
| 103 rcCaret.top, rcCaret.right, rcCaret.bottom); | 103 rcCaret.top, rcCaret.right, rcCaret.bottom); |
| 104 } | 104 } |
| 105 | 105 |
| 106 FX_BOOL CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget, | 106 FX_BOOL CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget, |
| 107 FX_FLOAT fMinPopup, | 107 FX_FLOAT fMinPopup, |
| 108 FX_FLOAT fMaxPopup, | 108 FX_FLOAT fMaxPopup, |
| 109 const CFX_RectF& rtAnchor, | 109 const CFX_RectF& rtAnchor, |
| 110 CFX_RectF& rtPopup) { | 110 CFX_RectF& rtPopup) { |
| 111 if (!hWidget) | 111 if (!hWidget) |
| 112 return FALSE; | 112 return FALSE; |
| 113 | 113 |
| 114 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); | 114 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); |
| 115 if (!pXFAPageView) | 115 if (!pXFAPageView) |
| 116 return FALSE; | 116 return FALSE; |
| 117 | 117 |
| 118 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pXFAPageView); | 118 CPDFXFA_Page* pPage = m_pContext->GetXFAPage(pXFAPageView); |
| 119 if (!pPage) | 119 if (!pPage) |
| 120 return FALSE; | 120 return FALSE; |
| 121 | 121 |
| 122 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); | 122 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); |
| 123 int nRotate = pWidgetAcc->GetRotate(); | 123 int nRotate = pWidgetAcc->GetRotate(); |
| 124 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 124 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 125 if (!pFormFillEnv) | 125 if (!pFormFillEnv) |
| 126 return FALSE; | 126 return FALSE; |
| 127 | 127 |
| 128 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; | 128 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; |
| 129 pFormFillEnv->GetPageViewRect(pPage, pageViewRect); | 129 pFormFillEnv->GetPageViewRect(pPage, pageViewRect); |
| 130 | 130 |
| 131 int t1; | 131 int t1; |
| 132 int t2; | 132 int t2; |
| 133 CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor); | 133 CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor); |
| 134 switch (nRotate) { | 134 switch (nRotate) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 FX_BOOL CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget, | 222 FX_BOOL CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget, |
| 223 CFX_PointF ptPopup) { | 223 CFX_PointF ptPopup) { |
| 224 if (!hWidget) | 224 if (!hWidget) |
| 225 return FALSE; | 225 return FALSE; |
| 226 | 226 |
| 227 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); | 227 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); |
| 228 if (!pXFAPageView) | 228 if (!pXFAPageView) |
| 229 return FALSE; | 229 return FALSE; |
| 230 | 230 |
| 231 CPDFXFA_Page* pPage = m_pDocument->GetXFAPage(pXFAPageView); | 231 CPDFXFA_Page* pPage = m_pContext->GetXFAPage(pXFAPageView); |
| 232 if (!pPage) | 232 if (!pPage) |
| 233 return FALSE; | 233 return FALSE; |
| 234 | 234 |
| 235 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 235 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 236 if (!pFormFillEnv) | 236 if (!pFormFillEnv) |
| 237 return FALSE; | 237 return FALSE; |
| 238 | 238 |
| 239 int menuFlag = 0; | 239 int menuFlag = 0; |
| 240 if (hWidget->CanUndo()) | 240 if (hWidget->CanUndo()) |
| 241 menuFlag |= FXFA_MENU_UNDO; | 241 menuFlag |= FXFA_MENU_UNDO; |
| 242 if (hWidget->CanRedo()) | 242 if (hWidget->CanRedo()) |
| 243 menuFlag |= FXFA_MENU_REDO; | 243 menuFlag |= FXFA_MENU_REDO; |
| 244 if (hWidget->CanPaste()) | 244 if (hWidget->CanPaste()) |
| 245 menuFlag |= FXFA_MENU_PASTE; | 245 menuFlag |= FXFA_MENU_PASTE; |
| 246 if (hWidget->CanCopy()) | 246 if (hWidget->CanCopy()) |
| 247 menuFlag |= FXFA_MENU_COPY; | 247 menuFlag |= FXFA_MENU_COPY; |
| 248 if (hWidget->CanCut()) | 248 if (hWidget->CanCut()) |
| 249 menuFlag |= FXFA_MENU_CUT; | 249 menuFlag |= FXFA_MENU_CUT; |
| 250 if (hWidget->CanSelectAll()) | 250 if (hWidget->CanSelectAll()) |
| 251 menuFlag |= FXFA_MENU_SELECTALL; | 251 menuFlag |= FXFA_MENU_SELECTALL; |
| 252 | 252 |
| 253 return pFormFillEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup); | 253 return pFormFillEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, | 256 void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, |
| 257 uint32_t dwFlags) { | 257 uint32_t dwFlags) { |
| 258 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 258 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 259 if (!pFormFillEnv) | 259 if (!pFormFillEnv) |
| 260 return; | 260 return; |
| 261 | 261 |
| 262 if (m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_LOADING || | 262 if (m_pContext->GetLoadStatus() == FXFA_LOADSTATUS_LOADING || |
| 263 m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_CLOSING || | 263 m_pContext->GetLoadStatus() == FXFA_LOADSTATUS_CLOSING || |
| 264 XFA_PAGEVIEWEVENT_StopLayout != dwFlags) | 264 XFA_PAGEVIEWEVENT_StopLayout != dwFlags) |
| 265 return; | 265 return; |
| 266 | 266 |
| 267 int nNewCount = m_pDocument->GetPageCount(); | 267 int nNewCount = m_pContext->GetPageCount(); |
| 268 if (nNewCount == m_pDocument->GetOriginalPageCount()) | 268 if (nNewCount == m_pContext->GetOriginalPageCount()) |
| 269 return; | 269 return; |
| 270 | 270 |
| 271 CXFA_FFDocView* pXFADocView = m_pDocument->GetXFADocView(); | 271 CXFA_FFDocView* pXFADocView = m_pContext->GetXFADocView(); |
| 272 if (!pXFADocView) | 272 if (!pXFADocView) |
| 273 return; | 273 return; |
| 274 | 274 |
| 275 for (int iPageIter = 0; iPageIter < m_pDocument->GetOriginalPageCount(); | 275 for (int iPageIter = 0; iPageIter < m_pContext->GetOriginalPageCount(); |
| 276 iPageIter++) { | 276 iPageIter++) { |
| 277 CPDFXFA_Page* pPage = m_pDocument->GetXFAPageList()->GetAt(iPageIter); | 277 CPDFXFA_Page* pPage = m_pContext->GetXFAPageList()->GetAt(iPageIter); |
| 278 if (!pPage) | 278 if (!pPage) |
| 279 continue; | 279 continue; |
| 280 | 280 |
| 281 m_pDocument->GetFormFillEnv()->RemovePageView(pPage); | 281 m_pContext->GetFormFillEnv()->RemovePageView(pPage); |
| 282 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); | 282 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); |
| 283 } | 283 } |
| 284 | 284 |
| 285 int flag = (nNewCount < m_pDocument->GetOriginalPageCount()) | 285 int flag = (nNewCount < m_pContext->GetOriginalPageCount()) |
| 286 ? FXFA_PAGEVIEWEVENT_POSTREMOVED | 286 ? FXFA_PAGEVIEWEVENT_POSTREMOVED |
| 287 : FXFA_PAGEVIEWEVENT_POSTADDED; | 287 : FXFA_PAGEVIEWEVENT_POSTADDED; |
| 288 int count = FXSYS_abs(nNewCount - m_pDocument->GetOriginalPageCount()); | 288 int count = FXSYS_abs(nNewCount - m_pContext->GetOriginalPageCount()); |
| 289 m_pDocument->SetOriginalPageCount(nNewCount); | 289 m_pContext->SetOriginalPageCount(nNewCount); |
| 290 pFormFillEnv->PageEvent(count, flag); | 290 pFormFillEnv->PageEvent(count, flag); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, | 293 void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, |
| 294 CXFA_WidgetAcc* pWidgetData) { | 294 CXFA_WidgetAcc* pWidgetData) { |
| 295 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) | 295 if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) |
| 296 return; | 296 return; |
| 297 | 297 |
| 298 CXFA_FFPageView* pPageView = hWidget->GetPageView(); | 298 CXFA_FFPageView* pPageView = hWidget->GetPageView(); |
| 299 if (!pPageView) | 299 if (!pPageView) |
| 300 return; | 300 return; |
| 301 | 301 |
| 302 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView); | 302 CPDFXFA_Page* pXFAPage = m_pContext->GetXFAPage(pPageView); |
| 303 if (!pXFAPage) | 303 if (!pXFAPage) |
| 304 return; | 304 return; |
| 305 | 305 |
| 306 m_pDocument->GetFormFillEnv() | 306 m_pContext->GetFormFillEnv()->GetPageView(pXFAPage, true)->AddAnnot(hWidget); |
| 307 ->GetPageView(pXFAPage, true) | |
| 308 ->AddAnnot(hWidget); | |
| 309 } | 307 } |
| 310 | 308 |
| 311 void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget, | 309 void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget, |
| 312 CXFA_WidgetAcc* pWidgetData) { | 310 CXFA_WidgetAcc* pWidgetData) { |
| 313 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) | 311 if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) |
| 314 return; | 312 return; |
| 315 | 313 |
| 316 CXFA_FFPageView* pPageView = hWidget->GetPageView(); | 314 CXFA_FFPageView* pPageView = hWidget->GetPageView(); |
| 317 if (!pPageView) | 315 if (!pPageView) |
| 318 return; | 316 return; |
| 319 | 317 |
| 320 CPDFXFA_Page* pXFAPage = m_pDocument->GetXFAPage(pPageView); | 318 CPDFXFA_Page* pXFAPage = m_pContext->GetXFAPage(pPageView); |
| 321 if (!pXFAPage) | 319 if (!pXFAPage) |
| 322 return; | 320 return; |
| 323 | 321 |
| 324 CPDFSDK_PageView* pSdkPageView = | 322 CPDFSDK_PageView* pSdkPageView = |
| 325 m_pDocument->GetFormFillEnv()->GetPageView(pXFAPage, true); | 323 m_pContext->GetFormFillEnv()->GetPageView(pXFAPage, true); |
| 326 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) | 324 if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) |
| 327 pSdkPageView->DeleteAnnot(pAnnot); | 325 pSdkPageView->DeleteAnnot(pAnnot); |
| 328 } | 326 } |
| 329 | 327 |
| 330 int32_t CPDFXFA_DocEnvironment::CountPages(CXFA_FFDoc* hDoc) { | 328 int32_t CPDFXFA_DocEnvironment::CountPages(CXFA_FFDoc* hDoc) { |
| 331 if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv()) | 329 if (hDoc == m_pContext->GetXFADoc() && m_pContext->GetFormFillEnv()) |
| 332 return m_pDocument->GetPageCount(); | 330 return m_pContext->GetPageCount(); |
| 333 return 0; | 331 return 0; |
| 334 } | 332 } |
| 335 | 333 |
| 336 int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) { | 334 int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) { |
| 337 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 335 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) |
| 338 return -1; | 336 return -1; |
| 339 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 337 if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
| 340 return -1; | 338 return -1; |
| 341 | 339 |
| 342 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 340 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 343 if (!pFormFillEnv) | 341 if (!pFormFillEnv) |
| 344 return -1; | 342 return -1; |
| 345 | 343 |
| 346 return pFormFillEnv->GetCurrentPageIndex(this); | 344 return pFormFillEnv->GetCurrentPageIndex(this); |
| 347 } | 345 } |
| 348 | 346 |
| 349 void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc, | 347 void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc, |
| 350 int32_t iCurPage) { | 348 int32_t iCurPage) { |
| 351 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv() || | 349 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv() || |
| 352 m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || | 350 m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || |
| 353 iCurPage >= m_pDocument->GetFormFillEnv()->GetPageCount()) { | 351 iCurPage >= m_pContext->GetFormFillEnv()->GetPageCount()) { |
| 354 return; | 352 return; |
| 355 } | 353 } |
| 356 | 354 |
| 357 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 355 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 358 if (!pFormFillEnv) | 356 if (!pFormFillEnv) |
| 359 return; | 357 return; |
| 360 pFormFillEnv->SetCurrentPage(this, iCurPage); | 358 pFormFillEnv->SetCurrentPage(this, iCurPage); |
| 361 } | 359 } |
| 362 | 360 |
| 363 FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { | 361 FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { |
| 364 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 362 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) |
| 365 return FALSE; | 363 return FALSE; |
| 366 if (m_pDocument->GetFormFillEnv()->GetInterForm()) { | 364 if (m_pContext->GetFormFillEnv()->GetInterForm()) { |
| 367 return m_pDocument->GetFormFillEnv() | 365 return m_pContext->GetFormFillEnv() |
| 368 ->GetInterForm() | 366 ->GetInterForm() |
| 369 ->IsXfaCalculateEnabled(); | 367 ->IsXfaCalculateEnabled(); |
| 370 } | 368 } |
| 371 return FALSE; | 369 return FALSE; |
| 372 } | 370 } |
| 373 | 371 |
| 374 void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc, | 372 void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc, |
| 375 FX_BOOL bEnabled) { | 373 FX_BOOL bEnabled) { |
| 376 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 374 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) |
| 377 return; | 375 return; |
| 378 if (m_pDocument->GetFormFillEnv()->GetInterForm()) { | 376 if (m_pContext->GetFormFillEnv()->GetInterForm()) { |
| 379 m_pDocument->GetFormFillEnv() | 377 m_pContext->GetFormFillEnv()->GetInterForm()->XfaEnableCalculate(bEnabled); |
| 380 ->GetInterForm() | |
| 381 ->XfaEnableCalculate(bEnabled); | |
| 382 } | 378 } |
| 383 } | 379 } |
| 384 | 380 |
| 385 void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, | 381 void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, |
| 386 CFX_WideString& wsTitle) { | 382 CFX_WideString& wsTitle) { |
| 387 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc()) | 383 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetPDFDoc()) |
| 388 return; | 384 return; |
| 389 | 385 |
| 390 CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo(); | 386 CPDF_Dictionary* pInfoDict = m_pContext->GetPDFDoc()->GetInfo(); |
| 391 if (!pInfoDict) | 387 if (!pInfoDict) |
| 392 return; | 388 return; |
| 393 | 389 |
| 394 CFX_ByteString csTitle = pInfoDict->GetStringFor("Title"); | 390 CFX_ByteString csTitle = pInfoDict->GetStringFor("Title"); |
| 395 wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength())); | 391 wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength())); |
| 396 csTitle.ReleaseBuffer(csTitle.GetLength()); | 392 csTitle.ReleaseBuffer(csTitle.GetLength()); |
| 397 } | 393 } |
| 398 | 394 |
| 399 void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc, | 395 void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc, |
| 400 const CFX_WideString& wsTitle) { | 396 const CFX_WideString& wsTitle) { |
| 401 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetPDFDoc()) | 397 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetPDFDoc()) |
| 402 return; | 398 return; |
| 403 | 399 |
| 404 if (CPDF_Dictionary* pInfoDict = m_pDocument->GetPDFDoc()->GetInfo()) | 400 if (CPDF_Dictionary* pInfoDict = m_pContext->GetPDFDoc()->GetInfo()) |
| 405 pInfoDict->SetFor("Title", new CPDF_String(wsTitle)); | 401 pInfoDict->SetFor("Title", new CPDF_String(wsTitle)); |
| 406 } | 402 } |
| 407 | 403 |
| 408 void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, | 404 void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, |
| 409 const CFX_WideString& wsFilePath, | 405 const CFX_WideString& wsFilePath, |
| 410 FX_BOOL bXDP) { | 406 FX_BOOL bXDP) { |
| 411 if (hDoc != m_pDocument->GetXFADoc()) | 407 if (hDoc != m_pContext->GetXFADoc()) |
| 412 return; | 408 return; |
| 413 | 409 |
| 414 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && | 410 if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA && |
| 415 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) { | 411 m_pContext->GetDocType() != DOCTYPE_STATIC_XFA) { |
| 416 return; | 412 return; |
| 417 } | 413 } |
| 418 | 414 |
| 419 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 415 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 420 if (!pFormFillEnv) | 416 if (!pFormFillEnv) |
| 421 return; | 417 return; |
| 422 | 418 |
| 423 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; | 419 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; |
| 424 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); | 420 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); |
| 425 if (wsFilePath.IsEmpty()) { | 421 if (wsFilePath.IsEmpty()) { |
| 426 if (!pFormFillEnv->GetFormFillInfo() || | 422 if (!pFormFillEnv->GetFormFillInfo() || |
| 427 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform) { | 423 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform) { |
| 428 return; | 424 return; |
| 429 } | 425 } |
| 430 | 426 |
| 431 CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse(); | 427 CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse(); |
| 432 bs = filepath.UTF16LE_Encode(); | 428 bs = filepath.UTF16LE_Encode(); |
| 433 } | 429 } |
| 434 int len = bs.GetLength(); | 430 int len = bs.GetLength(); |
| 435 FPDF_FILEHANDLER* pFileHandler = | 431 FPDF_FILEHANDLER* pFileHandler = |
| 436 pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, | 432 pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, |
| 437 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); | 433 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); |
| 438 bs.ReleaseBuffer(len); | 434 bs.ReleaseBuffer(len); |
| 439 if (!pFileHandler) | 435 if (!pFileHandler) |
| 440 return; | 436 return; |
| 441 | 437 |
| 442 CFPDF_FileStream fileWrite(pFileHandler); | 438 CFPDF_FileStream fileWrite(pFileHandler); |
| 443 CFX_ByteString content; | 439 CFX_ByteString content; |
| 444 if (fileType == FXFA_SAVEAS_XML) { | 440 if (fileType == FXFA_SAVEAS_XML) { |
| 445 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; | 441 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
| 446 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), | 442 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), |
| 447 content.GetLength()); | 443 content.GetLength()); |
| 448 m_pDocument->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Data, | 444 m_pContext->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Data, |
| 449 &fileWrite, nullptr); | 445 &fileWrite, nullptr); |
| 450 } else if (fileType == FXFA_SAVEAS_XDP) { | 446 } else if (fileType == FXFA_SAVEAS_XDP) { |
| 451 if (!m_pDocument->GetPDFDoc()) | 447 if (!m_pContext->GetPDFDoc()) |
| 452 return; | 448 return; |
| 453 | 449 |
| 454 CPDF_Dictionary* pRoot = m_pDocument->GetPDFDoc()->GetRoot(); | 450 CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot(); |
| 455 if (!pRoot) | 451 if (!pRoot) |
| 456 return; | 452 return; |
| 457 | 453 |
| 458 CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); | 454 CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); |
| 459 if (!pAcroForm) | 455 if (!pAcroForm) |
| 460 return; | 456 return; |
| 461 | 457 |
| 462 CPDF_Array* pArray = ToArray(pAcroForm->GetObjectFor("XFA")); | 458 CPDF_Array* pArray = ToArray(pAcroForm->GetObjectFor("XFA")); |
| 463 if (!pArray) | 459 if (!pArray) |
| 464 return; | 460 return; |
| 465 | 461 |
| 466 int size = pArray->GetCount(); | 462 int size = pArray->GetCount(); |
| 467 for (int i = 1; i < size; i += 2) { | 463 for (int i = 1; i < size; i += 2) { |
| 468 CPDF_Object* pPDFObj = pArray->GetObjectAt(i); | 464 CPDF_Object* pPDFObj = pArray->GetObjectAt(i); |
| 469 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1); | 465 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1); |
| 470 if (!pPrePDFObj->IsString()) | 466 if (!pPrePDFObj->IsString()) |
| 471 continue; | 467 continue; |
| 472 if (!pPDFObj->IsReference()) | 468 if (!pPDFObj->IsReference()) |
| 473 continue; | 469 continue; |
| 474 | 470 |
| 475 CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect()); | 471 CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect()); |
| 476 if (!pStream) | 472 if (!pStream) |
| 477 continue; | 473 continue; |
| 478 if (pPrePDFObj->GetString() == "form") { | 474 if (pPrePDFObj->GetString() == "form") { |
| 479 m_pDocument->GetXFADocView()->GetDoc()->SavePackage( | 475 m_pContext->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Form, |
| 480 XFA_HASHCODE_Form, &fileWrite, nullptr); | 476 &fileWrite, nullptr); |
| 481 continue; | 477 continue; |
| 482 } | 478 } |
| 483 if (pPrePDFObj->GetString() == "datasets") { | 479 if (pPrePDFObj->GetString() == "datasets") { |
| 484 m_pDocument->GetXFADocView()->GetDoc()->SavePackage( | 480 m_pContext->GetXFADocView()->GetDoc()->SavePackage( |
| 485 XFA_HASHCODE_Datasets, &fileWrite, nullptr); | 481 XFA_HASHCODE_Datasets, &fileWrite, nullptr); |
| 486 continue; | 482 continue; |
| 487 } | 483 } |
| 488 if (i == size - 1) { | 484 if (i == size - 1) { |
| 489 CFX_WideString wPath = CFX_WideString::FromUTF16LE( | 485 CFX_WideString wPath = CFX_WideString::FromUTF16LE( |
| 490 reinterpret_cast<const unsigned short*>(bs.c_str()), | 486 reinterpret_cast<const unsigned short*>(bs.c_str()), |
| 491 bs.GetLength() / sizeof(unsigned short)); | 487 bs.GetLength() / sizeof(unsigned short)); |
| 492 CFX_ByteString bPath = wPath.UTF8Encode(); | 488 CFX_ByteString bPath = wPath.UTF8Encode(); |
| 493 const char* szFormat = | 489 const char* szFormat = |
| 494 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; | 490 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; |
| 495 content.Format(szFormat, bPath.c_str()); | 491 content.Format(szFormat, bPath.c_str()); |
| 496 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), | 492 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), |
| 497 content.GetLength()); | 493 content.GetLength()); |
| 498 } | 494 } |
| 499 std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc); | 495 std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc); |
| 500 pAcc->LoadAllData(pStream); | 496 pAcc->LoadAllData(pStream); |
| 501 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), | 497 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), |
| 502 pAcc->GetSize()); | 498 pAcc->GetSize()); |
| 503 } | 499 } |
| 504 } | 500 } |
| 505 if (!fileWrite.Flush()) { | 501 if (!fileWrite.Flush()) { |
| 506 // Ignoring flush error. | 502 // Ignoring flush error. |
| 507 } | 503 } |
| 508 } | 504 } |
| 509 | 505 |
| 510 void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, | 506 void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, |
| 511 const CFX_WideString& bsURL) { | 507 const CFX_WideString& bsURL) { |
| 512 if (hDoc != m_pDocument->GetXFADoc()) | 508 if (hDoc != m_pContext->GetXFADoc()) |
| 513 return; | 509 return; |
| 514 | 510 |
| 515 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 511 if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
| 516 return; | 512 return; |
| 517 | 513 |
| 518 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 514 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 519 if (!pFormFillEnv) | 515 if (!pFormFillEnv) |
| 520 return; | 516 return; |
| 521 | 517 |
| 522 CFX_WideStringC str(bsURL.c_str()); | 518 CFX_WideStringC str(bsURL.c_str()); |
| 523 pFormFillEnv->GotoURL(this, str); | 519 pFormFillEnv->GotoURL(this, str); |
| 524 } | 520 } |
| 525 | 521 |
| 526 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { | 522 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { |
| 527 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 523 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) |
| 528 return FALSE; | 524 return FALSE; |
| 529 if (m_pDocument->GetFormFillEnv()->GetInterForm()) { | 525 if (m_pContext->GetFormFillEnv()->GetInterForm()) { |
| 530 return m_pDocument->GetFormFillEnv() | 526 return m_pContext->GetFormFillEnv() |
| 531 ->GetInterForm() | 527 ->GetInterForm() |
| 532 ->IsXfaValidationsEnabled(); | 528 ->IsXfaValidationsEnabled(); |
| 533 } | 529 } |
| 534 return TRUE; | 530 return TRUE; |
| 535 } | 531 } |
| 536 | 532 |
| 537 void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc, | 533 void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc, |
| 538 FX_BOOL bEnabled) { | 534 FX_BOOL bEnabled) { |
| 539 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 535 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) |
| 540 return; | 536 return; |
| 541 if (m_pDocument->GetFormFillEnv()->GetInterForm()) { | 537 if (m_pContext->GetFormFillEnv()->GetInterForm()) { |
| 542 m_pDocument->GetFormFillEnv() | 538 m_pContext->GetFormFillEnv()->GetInterForm()->XfaSetValidationsEnabled( |
| 543 ->GetInterForm() | 539 bEnabled); |
| 544 ->XfaSetValidationsEnabled(bEnabled); | |
| 545 } | 540 } |
| 546 } | 541 } |
| 547 | 542 |
| 548 void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc, | 543 void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc, |
| 549 CXFA_FFWidget* hWidget) { | 544 CXFA_FFWidget* hWidget) { |
| 550 if (hDoc != m_pDocument->GetXFADoc()) | 545 if (hDoc != m_pContext->GetXFADoc()) |
| 551 return; | 546 return; |
| 552 | 547 |
| 553 if (!hWidget) { | 548 if (!hWidget) { |
| 554 CPDFSDK_Annot::ObservedPtr pNull; | 549 CPDFSDK_Annot::ObservedPtr pNull; |
| 555 m_pDocument->GetFormFillEnv()->SetFocusAnnot(&pNull); | 550 m_pContext->GetFormFillEnv()->SetFocusAnnot(&pNull); |
| 556 return; | 551 return; |
| 557 } | 552 } |
| 558 | 553 |
| 559 int pageViewCount = m_pDocument->GetFormFillEnv()->GetPageViewCount(); | 554 int pageViewCount = m_pContext->GetFormFillEnv()->GetPageViewCount(); |
| 560 for (int i = 0; i < pageViewCount; i++) { | 555 for (int i = 0; i < pageViewCount; i++) { |
| 561 CPDFSDK_PageView* pPageView = m_pDocument->GetFormFillEnv()->GetPageView(i); | 556 CPDFSDK_PageView* pPageView = m_pContext->GetFormFillEnv()->GetPageView(i); |
| 562 if (!pPageView) | 557 if (!pPageView) |
| 563 continue; | 558 continue; |
| 564 | 559 |
| 565 CPDFSDK_Annot::ObservedPtr pAnnot(pPageView->GetAnnotByXFAWidget(hWidget)); | 560 CPDFSDK_Annot::ObservedPtr pAnnot(pPageView->GetAnnotByXFAWidget(hWidget)); |
| 566 if (pAnnot) { | 561 if (pAnnot) { |
| 567 m_pDocument->GetFormFillEnv()->SetFocusAnnot(&pAnnot); | 562 m_pContext->GetFormFillEnv()->SetFocusAnnot(&pAnnot); |
| 568 break; | 563 break; |
| 569 } | 564 } |
| 570 } | 565 } |
| 571 } | 566 } |
| 572 | 567 |
| 573 void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc, | 568 void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc, |
| 574 int32_t nStartPage, | 569 int32_t nStartPage, |
| 575 int32_t nEndPage, | 570 int32_t nEndPage, |
| 576 uint32_t dwOptions) { | 571 uint32_t dwOptions) { |
| 577 if (hDoc != m_pDocument->GetXFADoc()) | 572 if (hDoc != m_pContext->GetXFADoc()) |
| 578 return; | 573 return; |
| 579 | 574 |
| 580 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 575 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 581 if (!pFormFillEnv || !pFormFillEnv->GetFormFillInfo() || | 576 if (!pFormFillEnv || !pFormFillEnv->GetFormFillInfo() || |
| 582 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform || | 577 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform || |
| 583 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { | 578 !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { |
| 584 return; | 579 return; |
| 585 } | 580 } |
| 586 | 581 |
| 587 pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( | 582 pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( |
| 588 pFormFillEnv->GetFormFillInfo()->m_pJsPlatform, | 583 pFormFillEnv->GetFormFillInfo()->m_pJsPlatform, |
| 589 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, | 584 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, |
| 590 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, | 585 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, |
| 591 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, | 586 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, |
| 592 dwOptions & XFA_PRINTOPT_PrintAnnot); | 587 dwOptions & XFA_PRINTOPT_PrintAnnot); |
| 593 } | 588 } |
| 594 | 589 |
| 595 FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { | 590 FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { |
| 596 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv()) | 591 if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) |
| 597 return 0; | 592 return 0; |
| 598 | 593 |
| 599 CPDFSDK_InterForm* pInterForm = m_pDocument->GetFormFillEnv()->GetInterForm(); | 594 CPDFSDK_InterForm* pInterForm = m_pContext->GetFormFillEnv()->GetInterForm(); |
| 600 if (!pInterForm) | 595 if (!pInterForm) |
| 601 return 0; | 596 return 0; |
| 602 | 597 |
| 603 return ArgbEncode(pInterForm->GetHighlightAlpha(), | 598 return ArgbEncode(pInterForm->GetHighlightAlpha(), |
| 604 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); | 599 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); |
| 605 } | 600 } |
| 606 | 601 |
| 607 FX_BOOL CPDFXFA_DocEnvironment::NotifySubmit(FX_BOOL bPrevOrPost) { | 602 FX_BOOL CPDFXFA_DocEnvironment::NotifySubmit(FX_BOOL bPrevOrPost) { |
| 608 if (bPrevOrPost) | 603 if (bPrevOrPost) |
| 609 return OnBeforeNotifySubmit(); | 604 return OnBeforeNotifySubmit(); |
| 610 | 605 |
| 611 OnAfterNotifySubmit(); | 606 OnAfterNotifySubmit(); |
| 612 return TRUE; | 607 return TRUE; |
| 613 } | 608 } |
| 614 | 609 |
| 615 FX_BOOL CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() { | 610 FX_BOOL CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() { |
| 616 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && | 611 if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA && |
| 617 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) { | 612 m_pContext->GetDocType() != DOCTYPE_STATIC_XFA) { |
| 618 return TRUE; | 613 return TRUE; |
| 619 } | 614 } |
| 620 | 615 |
| 621 if (!m_pDocument->GetXFADocView()) | 616 if (!m_pContext->GetXFADocView()) |
| 622 return TRUE; | 617 return TRUE; |
| 623 | 618 |
| 624 CXFA_FFWidgetHandler* pWidgetHandler = | 619 CXFA_FFWidgetHandler* pWidgetHandler = |
| 625 m_pDocument->GetXFADocView()->GetWidgetHandler(); | 620 m_pContext->GetXFADocView()->GetWidgetHandler(); |
| 626 if (!pWidgetHandler) | 621 if (!pWidgetHandler) |
| 627 return TRUE; | 622 return TRUE; |
| 628 | 623 |
| 629 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( | 624 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( |
| 630 m_pDocument->GetXFADocView()->CreateWidgetAccIterator()); | 625 m_pContext->GetXFADocView()->CreateWidgetAccIterator()); |
| 631 if (pWidgetAccIterator) { | 626 if (pWidgetAccIterator) { |
| 632 CXFA_EventParam Param; | 627 CXFA_EventParam Param; |
| 633 Param.m_eType = XFA_EVENT_PreSubmit; | 628 Param.m_eType = XFA_EVENT_PreSubmit; |
| 634 while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) | 629 while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) |
| 635 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); | 630 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); |
| 636 } | 631 } |
| 637 | 632 |
| 638 pWidgetAccIterator.reset( | 633 pWidgetAccIterator.reset( |
| 639 m_pDocument->GetXFADocView()->CreateWidgetAccIterator()); | 634 m_pContext->GetXFADocView()->CreateWidgetAccIterator()); |
| 640 if (!pWidgetAccIterator) | 635 if (!pWidgetAccIterator) |
| 641 return TRUE; | 636 return TRUE; |
| 642 | 637 |
| 643 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 638 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 644 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 639 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 645 while (pWidgetAcc) { | 640 while (pWidgetAcc) { |
| 646 int fRet = pWidgetAcc->ProcessValidate(-1); | 641 int fRet = pWidgetAcc->ProcessValidate(-1); |
| 647 if (fRet == XFA_EVENTERROR_Error) { | 642 if (fRet == XFA_EVENTERROR_Error) { |
| 648 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 643 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 649 if (!pFormFillEnv) | 644 if (!pFormFillEnv) |
| 650 return FALSE; | 645 return FALSE; |
| 651 | 646 |
| 652 CFX_WideString ws; | 647 CFX_WideString ws; |
| 653 ws.FromLocal(IDS_XFA_Validate_Input); | 648 ws.FromLocal(IDS_XFA_Validate_Input); |
| 654 CFX_ByteString bs = ws.UTF16LE_Encode(); | 649 CFX_ByteString bs = ws.UTF16LE_Encode(); |
| 655 int len = bs.GetLength(); | 650 int len = bs.GetLength(); |
| 656 pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), | 651 pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), |
| 657 (FPDF_WIDESTRING)L"", 0, 1); | 652 (FPDF_WIDESTRING)L"", 0, 1); |
| 658 bs.ReleaseBuffer(len); | 653 bs.ReleaseBuffer(len); |
| 659 return FALSE; | 654 return FALSE; |
| 660 } | 655 } |
| 661 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 656 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 662 } | 657 } |
| 663 m_pDocument->GetXFADocView()->UpdateDocView(); | 658 m_pContext->GetXFADocView()->UpdateDocView(); |
| 664 | 659 |
| 665 return TRUE; | 660 return TRUE; |
| 666 } | 661 } |
| 667 | 662 |
| 668 void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() { | 663 void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() { |
| 669 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA && | 664 if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA && |
| 670 m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA) | 665 m_pContext->GetDocType() != DOCTYPE_STATIC_XFA) |
| 671 return; | 666 return; |
| 672 | 667 |
| 673 if (!m_pDocument->GetXFADocView()) | 668 if (!m_pContext->GetXFADocView()) |
| 674 return; | 669 return; |
| 675 | 670 |
| 676 CXFA_FFWidgetHandler* pWidgetHandler = | 671 CXFA_FFWidgetHandler* pWidgetHandler = |
| 677 m_pDocument->GetXFADocView()->GetWidgetHandler(); | 672 m_pContext->GetXFADocView()->GetWidgetHandler(); |
| 678 if (!pWidgetHandler) | 673 if (!pWidgetHandler) |
| 679 return; | 674 return; |
| 680 | 675 |
| 681 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( | 676 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( |
| 682 m_pDocument->GetXFADocView()->CreateWidgetAccIterator()); | 677 m_pContext->GetXFADocView()->CreateWidgetAccIterator()); |
| 683 if (!pWidgetAccIterator) | 678 if (!pWidgetAccIterator) |
| 684 return; | 679 return; |
| 685 | 680 |
| 686 CXFA_EventParam Param; | 681 CXFA_EventParam Param; |
| 687 Param.m_eType = XFA_EVENT_PostSubmit; | 682 Param.m_eType = XFA_EVENT_PostSubmit; |
| 688 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 683 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 689 while (pWidgetAcc) { | 684 while (pWidgetAcc) { |
| 690 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); | 685 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); |
| 691 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 686 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 692 } | 687 } |
| 693 m_pDocument->GetXFADocView()->UpdateDocView(); | 688 m_pContext->GetXFADocView()->UpdateDocView(); |
| 694 } | 689 } |
| 695 | 690 |
| 696 FX_BOOL CPDFXFA_DocEnvironment::SubmitData(CXFA_FFDoc* hDoc, | 691 FX_BOOL CPDFXFA_DocEnvironment::SubmitData(CXFA_FFDoc* hDoc, |
| 697 CXFA_Submit submit) { | 692 CXFA_Submit submit) { |
| 698 if (!NotifySubmit(TRUE) || !m_pDocument->GetXFADocView()) | 693 if (!NotifySubmit(TRUE) || !m_pContext->GetXFADocView()) |
| 699 return FALSE; | 694 return FALSE; |
| 700 | 695 |
| 701 m_pDocument->GetXFADocView()->UpdateDocView(); | 696 m_pContext->GetXFADocView()->UpdateDocView(); |
| 702 FX_BOOL ret = SubmitDataInternal(hDoc, submit); | 697 FX_BOOL ret = SubmitDataInternal(hDoc, submit); |
| 703 NotifySubmit(FALSE); | 698 NotifySubmit(FALSE); |
| 704 return ret; | 699 return ret; |
| 705 } | 700 } |
| 706 | 701 |
| 707 IFX_SeekableReadStream* CPDFXFA_DocEnvironment::OpenLinkedFile( | 702 IFX_SeekableReadStream* CPDFXFA_DocEnvironment::OpenLinkedFile( |
| 708 CXFA_FFDoc* hDoc, | 703 CXFA_FFDoc* hDoc, |
| 709 const CFX_WideString& wsLink) { | 704 const CFX_WideString& wsLink) { |
| 710 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 705 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 711 if (!pFormFillEnv) | 706 if (!pFormFillEnv) |
| 712 return nullptr; | 707 return nullptr; |
| 713 | 708 |
| 714 CFX_ByteString bs = wsLink.UTF16LE_Encode(); | 709 CFX_ByteString bs = wsLink.UTF16LE_Encode(); |
| 715 int len = bs.GetLength(); | 710 int len = bs.GetLength(); |
| 716 FPDF_FILEHANDLER* pFileHandler = | 711 FPDF_FILEHANDLER* pFileHandler = |
| 717 pFormFillEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); | 712 pFormFillEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); |
| 718 bs.ReleaseBuffer(len); | 713 bs.ReleaseBuffer(len); |
| 719 if (!pFileHandler) | 714 if (!pFileHandler) |
| 720 return nullptr; | 715 return nullptr; |
| 721 | 716 |
| 722 return new CFPDF_FileStream(pFileHandler); | 717 return new CFPDF_FileStream(pFileHandler); |
| 723 } | 718 } |
| 724 | 719 |
| 725 FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, | 720 FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, |
| 726 int fileType, | 721 int fileType, |
| 727 FPDF_DWORD encodeType, | 722 FPDF_DWORD encodeType, |
| 728 FPDF_DWORD flag) { | 723 FPDF_DWORD flag) { |
| 729 if (!m_pDocument->GetXFADocView()) | 724 if (!m_pContext->GetXFADocView()) |
| 730 return FALSE; | 725 return FALSE; |
| 731 | 726 |
| 732 CFX_ByteString content; | 727 CFX_ByteString content; |
| 733 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 728 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 734 if (!pFormFillEnv) | 729 if (!pFormFillEnv) |
| 735 return FALSE; | 730 return FALSE; |
| 736 | 731 |
| 737 CFPDF_FileStream fileStream(pFileHandler); | 732 CFPDF_FileStream fileStream(pFileHandler); |
| 738 if (fileType == FXFA_SAVEAS_XML) { | 733 if (fileType == FXFA_SAVEAS_XML) { |
| 739 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"; |
| 740 fileStream.WriteBlock(kContent, 0, strlen(kContent)); | 735 fileStream.WriteBlock(kContent, 0, strlen(kContent)); |
| 741 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Data, &fileStream, | 736 m_pContext->GetXFADoc()->SavePackage(XFA_HASHCODE_Data, &fileStream, |
| 742 nullptr); | 737 nullptr); |
| 743 return TRUE; | 738 return TRUE; |
| 744 } | 739 } |
| 745 | 740 |
| 746 if (fileType != FXFA_SAVEAS_XDP) | 741 if (fileType != FXFA_SAVEAS_XDP) |
| 747 return TRUE; | 742 return TRUE; |
| 748 | 743 |
| 749 if (!flag) { | 744 if (!flag) { |
| 750 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | | 745 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | |
| 751 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; | 746 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; |
| 752 } | 747 } |
| 753 if (!m_pDocument->GetPDFDoc()) { | 748 if (!m_pContext->GetPDFDoc()) { |
| 754 fileStream.Flush(); | 749 fileStream.Flush(); |
| 755 return FALSE; | 750 return FALSE; |
| 756 } | 751 } |
| 757 | 752 |
| 758 CPDF_Dictionary* pRoot = m_pDocument->GetPDFDoc()->GetRoot(); | 753 CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot(); |
| 759 if (!pRoot) { | 754 if (!pRoot) { |
| 760 fileStream.Flush(); | 755 fileStream.Flush(); |
| 761 return FALSE; | 756 return FALSE; |
| 762 } | 757 } |
| 763 | 758 |
| 764 CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); | 759 CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); |
| 765 if (!pAcroForm) { | 760 if (!pAcroForm) { |
| 766 fileStream.Flush(); | 761 fileStream.Flush(); |
| 767 return FALSE; | 762 return FALSE; |
| 768 } | 763 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 793 continue; | 788 continue; |
| 794 if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS)) | 789 if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS)) |
| 795 continue; | 790 continue; |
| 796 if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA)) | 791 if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA)) |
| 797 continue; | 792 continue; |
| 798 if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF)) | 793 if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF)) |
| 799 continue; | 794 continue; |
| 800 if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM)) | 795 if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM)) |
| 801 continue; | 796 continue; |
| 802 if (pPrePDFObj->GetString() == "form") { | 797 if (pPrePDFObj->GetString() == "form") { |
| 803 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Form, &fileStream, | 798 m_pContext->GetXFADoc()->SavePackage(XFA_HASHCODE_Form, &fileStream, |
| 804 nullptr); | 799 nullptr); |
| 805 } else if (pPrePDFObj->GetString() == "datasets") { | 800 } else if (pPrePDFObj->GetString() == "datasets") { |
| 806 m_pDocument->GetXFADoc()->SavePackage(XFA_HASHCODE_Datasets, &fileStream, | 801 m_pContext->GetXFADoc()->SavePackage(XFA_HASHCODE_Datasets, &fileStream, |
| 807 nullptr); | 802 nullptr); |
| 808 } else { | 803 } else { |
| 809 // PDF,creator. | 804 // PDF,creator. |
| 810 } | 805 } |
| 811 } | 806 } |
| 812 return TRUE; | 807 return TRUE; |
| 813 } | 808 } |
| 814 | 809 |
| 815 void CPDFXFA_DocEnvironment::ToXFAContentFlags(CFX_WideString csSrcContent, | 810 void CPDFXFA_DocEnvironment::ToXFAContentFlags(CFX_WideString csSrcContent, |
| 816 FPDF_DWORD& flag) { | 811 FPDF_DWORD& flag) { |
| 817 if (csSrcContent.Find(L" config ", 0) != -1) | 812 if (csSrcContent.Find(L" config ", 0) != -1) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1)); | 889 srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1)); |
| 895 } | 890 } |
| 896 csToAddress.Replace(L",", L";"); | 891 csToAddress.Replace(L",", L";"); |
| 897 csCCAddress.Replace(L",", L";"); | 892 csCCAddress.Replace(L",", L";"); |
| 898 csBCCAddress.Replace(L",", L";"); | 893 csBCCAddress.Replace(L",", L";"); |
| 899 return TRUE; | 894 return TRUE; |
| 900 } | 895 } |
| 901 | 896 |
| 902 FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, | 897 FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc, |
| 903 CXFA_Submit submit) { | 898 CXFA_Submit submit) { |
| 904 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 899 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 905 if (!pFormFillEnv) | 900 if (!pFormFillEnv) |
| 906 return FALSE; | 901 return FALSE; |
| 907 | 902 |
| 908 CFX_WideStringC csURLC; | 903 CFX_WideStringC csURLC; |
| 909 submit.GetSubmitTarget(csURLC); | 904 submit.GetSubmitTarget(csURLC); |
| 910 CFX_WideString csURL(csURLC); | 905 CFX_WideString csURL(csURLC); |
| 911 if (csURL.IsEmpty()) { | 906 if (csURL.IsEmpty()) { |
| 912 CFX_WideString ws; | 907 CFX_WideString ws; |
| 913 ws.FromLocal("Submit cancelled."); | 908 ws.FromLocal("Submit cancelled."); |
| 914 CFX_ByteString bs = ws.UTF16LE_Encode(); | 909 CFX_ByteString bs = ws.UTF16LE_Encode(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 (FPDF_WIDESTRING)bs.GetBuffer(len)); | 990 (FPDF_WIDESTRING)bs.GetBuffer(len)); |
| 996 bs.ReleaseBuffer(len); | 991 bs.ReleaseBuffer(len); |
| 997 } | 992 } |
| 998 return TRUE; | 993 return TRUE; |
| 999 } | 994 } |
| 1000 | 995 |
| 1001 FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty( | 996 FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty( |
| 1002 CXFA_FFDoc* hDoc, | 997 CXFA_FFDoc* hDoc, |
| 1003 const CFX_ByteStringC& szPropName, | 998 const CFX_ByteStringC& szPropName, |
| 1004 CFXJSE_Value* pValue) { | 999 CFXJSE_Value* pValue) { |
| 1005 if (hDoc != m_pDocument->GetXFADoc()) | 1000 if (hDoc != m_pContext->GetXFADoc()) |
| 1006 return FALSE; | 1001 return FALSE; |
| 1007 | 1002 |
| 1008 if (m_pDocument->GetFormFillEnv() && | 1003 if (m_pContext->GetFormFillEnv() && |
| 1009 m_pDocument->GetFormFillEnv()->GetJSRuntime()) { | 1004 m_pContext->GetFormFillEnv()->GetJSRuntime()) { |
| 1010 return m_pDocument->GetFormFillEnv()->GetJSRuntime()->SetValueByName( | 1005 return m_pContext->GetFormFillEnv()->GetJSRuntime()->SetValueByName( |
| 1011 szPropName, pValue); | 1006 szPropName, pValue); |
| 1012 } | 1007 } |
| 1013 return FALSE; | 1008 return FALSE; |
| 1014 } | 1009 } |
| 1015 | 1010 |
| 1016 FX_BOOL CPDFXFA_DocEnvironment::GetGlobalProperty( | 1011 FX_BOOL CPDFXFA_DocEnvironment::GetGlobalProperty( |
| 1017 CXFA_FFDoc* hDoc, | 1012 CXFA_FFDoc* hDoc, |
| 1018 const CFX_ByteStringC& szPropName, | 1013 const CFX_ByteStringC& szPropName, |
| 1019 CFXJSE_Value* pValue) { | 1014 CFXJSE_Value* pValue) { |
| 1020 if (hDoc != m_pDocument->GetXFADoc()) | 1015 if (hDoc != m_pContext->GetXFADoc()) |
| 1021 return FALSE; | 1016 return FALSE; |
| 1022 if (!m_pDocument->GetFormFillEnv() || | 1017 if (!m_pContext->GetFormFillEnv() || |
| 1023 !m_pDocument->GetFormFillEnv()->GetJSRuntime()) { | 1018 !m_pContext->GetFormFillEnv()->GetJSRuntime()) { |
| 1024 return FALSE; | 1019 return FALSE; |
| 1025 } | 1020 } |
| 1026 | 1021 |
| 1027 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv(); | 1022 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); |
| 1028 if (!m_pJSContext) | 1023 if (!m_pJSContext) |
| 1029 m_pJSContext = pFormFillEnv->GetJSRuntime()->NewContext(); | 1024 m_pJSContext = pFormFillEnv->GetJSRuntime()->NewContext(); |
| 1030 | 1025 |
| 1031 return pFormFillEnv->GetJSRuntime()->GetValueByName(szPropName, pValue); | 1026 return pFormFillEnv->GetJSRuntime()->GetValueByName(szPropName, pValue); |
| 1032 } | 1027 } |
| OLD | NEW |