blob: 5c847fc1dfafecdfc71bdfca20979c3817907043 [file] [log] [blame]
dsinclairf34518b2016-09-13 12:03:48 -07001// Copyright 2016 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
dsinclair735606d2016-10-05 15:47:02 -07007#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
dsinclairf34518b2016-09-13 12:03:48 -07008
thestigd4c34f22016-09-28 17:04:51 -07009#include <memory>
Tom Sepezfe91c6c2017-05-16 15:33:20 -070010#include <utility>
thestigd4c34f22016-09-28 17:04:51 -070011
dsinclair7cbe68e2016-10-12 11:56:23 -070012#include "core/fpdfapi/parser/cpdf_array.h"
13#include "core/fpdfdoc/cpdf_docjsactions.h"
dsinclair114e46a2016-09-29 17:18:21 -070014#include "fpdfsdk/cpdfsdk_annothandlermgr.h"
dsinclair7cbe68e2016-10-12 11:56:23 -070015#include "fpdfsdk/cpdfsdk_interform.h"
16#include "fpdfsdk/cpdfsdk_pageview.h"
17#include "fpdfsdk/cpdfsdk_widget.h"
dsinclairb94d7c92016-09-21 12:07:00 -070018#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
dsinclair114e46a2016-09-29 17:18:21 -070019#include "fpdfsdk/fsdk_actionhandler.h"
dsinclairf34518b2016-09-13 12:03:48 -070020#include "fpdfsdk/javascript/ijs_runtime.h"
tsepez36eb4bd2016-10-03 15:24:27 -070021#include "third_party/base/ptr_util.h"
dsinclairf34518b2016-09-13 12:03:48 -070022
dsinclairf34518b2016-09-13 12:03:48 -070023namespace {
24
25// NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken
26// since modifying the result would impact |bsUTF16LE|.
27FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE) {
28 return reinterpret_cast<FPDF_WIDESTRING>(
29 bsUTF16LE->GetBuffer(bsUTF16LE->GetLength()));
30}
31
32} // namespace
33
dsinclair735606d2016-10-05 15:47:02 -070034CPDFSDK_FormFillEnvironment::CPDFSDK_FormFillEnvironment(
35 UnderlyingDocumentType* pDoc,
36 FPDF_FORMFILLINFO* pFFinfo)
dsinclaira939bfe2016-09-22 13:18:45 -070037 : m_pInfo(pFFinfo),
dsinclaira939bfe2016-09-22 13:18:45 -070038 m_pUnderlyingDoc(pDoc),
Dan Sinclair0bb13332017-03-30 16:12:02 -040039 m_pSysHandler(pdfium::MakeUnique<CFX_SystemHandler>(this)),
dsinclair6c659ab2016-10-12 13:41:38 -070040 m_bChangeMask(false),
41 m_bBeingDestroyed(false) {}
dsinclairf34518b2016-09-13 12:03:48 -070042
dsinclair735606d2016-10-05 15:47:02 -070043CPDFSDK_FormFillEnvironment::~CPDFSDK_FormFillEnvironment() {
dsinclair6c659ab2016-10-12 13:41:38 -070044 m_bBeingDestroyed = true;
dsinclair7cbe68e2016-10-12 11:56:23 -070045 ClearAllFocusedAnnots();
dsinclair7cbe68e2016-10-12 11:56:23 -070046
tsepez2599ff72016-11-08 14:38:59 -080047 // |m_PageMap| will try to access |m_pInterForm| when it cleans itself up.
48 // Make sure it is deleted before |m_pInterForm|.
49 m_PageMap.clear();
50
51 // |m_pAnnotHandlerMgr| will try to access |m_pFormFiller| when it cleans
52 // itself up. Make sure it is deleted before |m_pFormFiller|.
dsinclair709f5a92016-10-11 14:21:16 -070053 m_pAnnotHandlerMgr.reset();
54
55 // Must destroy the |m_pFormFiller| before the environment (|this|)
56 // because any created form widgets hold a pointer to the environment.
57 // Those widgets may call things like KillTimer() as they are shutdown.
58 m_pFormFiller.reset();
59
dsinclairf34518b2016-09-13 12:03:48 -070060 if (m_pInfo && m_pInfo->Release)
61 m_pInfo->Release(m_pInfo);
62}
63
Dan Sinclair812e96c2017-03-13 16:43:37 -040064int CPDFSDK_FormFillEnvironment::JS_appAlert(const wchar_t* Msg,
65 const wchar_t* Title,
dsinclair735606d2016-10-05 15:47:02 -070066 uint32_t Type,
67 uint32_t Icon) {
dsinclairf34518b2016-09-13 12:03:48 -070068 if (!m_pInfo || !m_pInfo->m_pJsPlatform ||
69 !m_pInfo->m_pJsPlatform->app_alert) {
70 return -1;
71 }
72 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
73 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
74 return m_pInfo->m_pJsPlatform->app_alert(
75 m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsMsg),
76 AsFPDFWideString(&bsTitle), Type, Icon);
77}
78
Dan Sinclair812e96c2017-03-13 16:43:37 -040079int CPDFSDK_FormFillEnvironment::JS_appResponse(const wchar_t* Question,
80 const wchar_t* Title,
81 const wchar_t* Default,
82 const wchar_t* cLabel,
dsinclair735606d2016-10-05 15:47:02 -070083 FPDF_BOOL bPassword,
84 void* response,
85 int length) {
dsinclairf34518b2016-09-13 12:03:48 -070086 if (!m_pInfo || !m_pInfo->m_pJsPlatform ||
87 !m_pInfo->m_pJsPlatform->app_response) {
88 return -1;
89 }
90 CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode();
91 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
92 CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode();
93 CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode();
94 return m_pInfo->m_pJsPlatform->app_response(
95 m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsQuestion),
96 AsFPDFWideString(&bsTitle), AsFPDFWideString(&bsDefault),
97 AsFPDFWideString(&bsLabel), bPassword, response, length);
98}
99
dsinclair735606d2016-10-05 15:47:02 -0700100void CPDFSDK_FormFillEnvironment::JS_appBeep(int nType) {
dsinclairf34518b2016-09-13 12:03:48 -0700101 if (!m_pInfo || !m_pInfo->m_pJsPlatform ||
102 !m_pInfo->m_pJsPlatform->app_beep) {
103 return;
104 }
105 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType);
106}
107
dsinclair735606d2016-10-05 15:47:02 -0700108CFX_WideString CPDFSDK_FormFillEnvironment::JS_fieldBrowse() {
dsinclairf34518b2016-09-13 12:03:48 -0700109 if (!m_pInfo || !m_pInfo->m_pJsPlatform ||
110 !m_pInfo->m_pJsPlatform->Field_browse) {
111 return CFX_WideString();
112 }
113 const int nRequiredLen =
114 m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, nullptr, 0);
115 if (nRequiredLen <= 0)
116 return CFX_WideString();
117
Tom Sepez4ad46902017-05-02 13:19:56 -0700118 std::vector<uint8_t> pBuff(nRequiredLen);
dsinclairf34518b2016-09-13 12:03:48 -0700119 const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse(
Tom Sepez4ad46902017-05-02 13:19:56 -0700120 m_pInfo->m_pJsPlatform, pBuff.data(), nRequiredLen);
dsinclairf34518b2016-09-13 12:03:48 -0700121 if (nActualLen <= 0 || nActualLen > nRequiredLen)
122 return CFX_WideString();
123
Tom Sepez4ad46902017-05-02 13:19:56 -0700124 pBuff.resize(nActualLen);
125 return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff));
dsinclairf34518b2016-09-13 12:03:48 -0700126}
127
dsinclair735606d2016-10-05 15:47:02 -0700128CFX_WideString CPDFSDK_FormFillEnvironment::JS_docGetFilePath() {
dsinclairf34518b2016-09-13 12:03:48 -0700129 if (!m_pInfo || !m_pInfo->m_pJsPlatform ||
130 !m_pInfo->m_pJsPlatform->Doc_getFilePath) {
131 return CFX_WideString();
132 }
133 const int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(
134 m_pInfo->m_pJsPlatform, nullptr, 0);
135 if (nRequiredLen <= 0)
136 return CFX_WideString();
137
Tom Sepez4ad46902017-05-02 13:19:56 -0700138 std::vector<uint8_t> pBuff(nRequiredLen);
dsinclairf34518b2016-09-13 12:03:48 -0700139 const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(
Tom Sepez4ad46902017-05-02 13:19:56 -0700140 m_pInfo->m_pJsPlatform, pBuff.data(), nRequiredLen);
dsinclairf34518b2016-09-13 12:03:48 -0700141 if (nActualLen <= 0 || nActualLen > nRequiredLen)
142 return CFX_WideString();
143
Tom Sepez4ad46902017-05-02 13:19:56 -0700144 pBuff.resize(nActualLen);
145 return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff));
dsinclairf34518b2016-09-13 12:03:48 -0700146}
147
dsinclair735606d2016-10-05 15:47:02 -0700148void CPDFSDK_FormFillEnvironment::JS_docSubmitForm(void* formData,
149 int length,
Dan Sinclair812e96c2017-03-13 16:43:37 -0400150 const wchar_t* URL) {
dsinclairf34518b2016-09-13 12:03:48 -0700151 if (!m_pInfo || !m_pInfo->m_pJsPlatform ||
152 !m_pInfo->m_pJsPlatform->Doc_submitForm) {
153 return;
154 }
155 CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode();
156 m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData,
157 length,
158 AsFPDFWideString(&bsDestination));
159}
160
dsinclair735606d2016-10-05 15:47:02 -0700161void CPDFSDK_FormFillEnvironment::JS_docmailForm(void* mailData,
162 int length,
163 FPDF_BOOL bUI,
Dan Sinclair812e96c2017-03-13 16:43:37 -0400164 const wchar_t* To,
165 const wchar_t* Subject,
166 const wchar_t* CC,
167 const wchar_t* BCC,
168 const wchar_t* Msg) {
dsinclairf34518b2016-09-13 12:03:48 -0700169 if (!m_pInfo || !m_pInfo->m_pJsPlatform ||
170 !m_pInfo->m_pJsPlatform->Doc_mail) {
171 return;
172 }
173 CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode();
174 CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode();
175 CFX_ByteString bsCC = CFX_WideString(CC).UTF16LE_Encode();
176 CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode();
177 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
178 m_pInfo->m_pJsPlatform->Doc_mail(
179 m_pInfo->m_pJsPlatform, mailData, length, bUI, AsFPDFWideString(&bsTo),
180 AsFPDFWideString(&bsSubject), AsFPDFWideString(&bsCC),
181 AsFPDFWideString(&bsBcc), AsFPDFWideString(&bsMsg));
182}
183
dsinclair735606d2016-10-05 15:47:02 -0700184void CPDFSDK_FormFillEnvironment::JS_docprint(FPDF_BOOL bUI,
185 int nStart,
186 int nEnd,
187 FPDF_BOOL bSilent,
188 FPDF_BOOL bShrinkToFit,
189 FPDF_BOOL bPrintAsImage,
190 FPDF_BOOL bReverse,
191 FPDF_BOOL bAnnotations) {
dsinclairf34518b2016-09-13 12:03:48 -0700192 if (!m_pInfo || !m_pInfo->m_pJsPlatform ||
193 !m_pInfo->m_pJsPlatform->Doc_print) {
194 return;
195 }
196 m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd,
197 bSilent, bShrinkToFit, bPrintAsImage,
198 bReverse, bAnnotations);
199}
200
dsinclair735606d2016-10-05 15:47:02 -0700201void CPDFSDK_FormFillEnvironment::JS_docgotoPage(int nPageNum) {
dsinclairf34518b2016-09-13 12:03:48 -0700202 if (!m_pInfo || !m_pInfo->m_pJsPlatform ||
203 !m_pInfo->m_pJsPlatform->Doc_gotoPage) {
204 return;
205 }
206 m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum);
207}
208
dsinclair735606d2016-10-05 15:47:02 -0700209IJS_Runtime* CPDFSDK_FormFillEnvironment::GetJSRuntime() {
dsinclairf34518b2016-09-13 12:03:48 -0700210 if (!IsJSInitiated())
211 return nullptr;
212 if (!m_pJSRuntime)
213 m_pJSRuntime.reset(IJS_Runtime::Create(this));
214 return m_pJSRuntime.get();
215}
216
dsinclair735606d2016-10-05 15:47:02 -0700217CPDFSDK_AnnotHandlerMgr* CPDFSDK_FormFillEnvironment::GetAnnotHandlerMgr() {
dsinclairf34518b2016-09-13 12:03:48 -0700218 if (!m_pAnnotHandlerMgr)
tsepez36eb4bd2016-10-03 15:24:27 -0700219 m_pAnnotHandlerMgr = pdfium::MakeUnique<CPDFSDK_AnnotHandlerMgr>(this);
dsinclairf34518b2016-09-13 12:03:48 -0700220 return m_pAnnotHandlerMgr.get();
221}
222
Lei Zhangcddc8ed2017-06-20 17:26:44 -0700223CPDFSDK_ActionHandler* CPDFSDK_FormFillEnvironment::GetActionHandler() {
dsinclairf34518b2016-09-13 12:03:48 -0700224 if (!m_pActionHandler)
tsepez36eb4bd2016-10-03 15:24:27 -0700225 m_pActionHandler = pdfium::MakeUnique<CPDFSDK_ActionHandler>();
dsinclairf34518b2016-09-13 12:03:48 -0700226 return m_pActionHandler.get();
227}
228
dsinclair735606d2016-10-05 15:47:02 -0700229CFFL_InteractiveFormFiller*
230CPDFSDK_FormFillEnvironment::GetInteractiveFormFiller() {
dsinclairb94d7c92016-09-21 12:07:00 -0700231 if (!m_pFormFiller)
tsepez36eb4bd2016-10-03 15:24:27 -0700232 m_pFormFiller = pdfium::MakeUnique<CFFL_InteractiveFormFiller>(this);
dsinclairb94d7c92016-09-21 12:07:00 -0700233 return m_pFormFiller.get();
dsinclairf34518b2016-09-13 12:03:48 -0700234}
dsinclair577ad2c2016-09-22 10:20:43 -0700235
Lei Zhang671630e2017-05-19 19:25:16 -0700236void CPDFSDK_FormFillEnvironment::Invalidate(UnderlyingPageType* page,
Dan Sinclair6eec1c42017-02-21 17:20:43 -0500237 const FX_RECT& rect) {
238 if (m_pInfo && m_pInfo->FFI_Invalidate) {
239 m_pInfo->FFI_Invalidate(m_pInfo, page, rect.left, rect.top, rect.right,
240 rect.bottom);
241 }
dsinclair735606d2016-10-05 15:47:02 -0700242}
243
Dan Sinclair60fd9fc2017-02-21 17:21:08 -0500244void CPDFSDK_FormFillEnvironment::OutputSelectedRect(
Lei Zhang671630e2017-05-19 19:25:16 -0700245 UnderlyingPageType* page,
Dan Sinclair60fd9fc2017-02-21 17:21:08 -0500246 const CFX_FloatRect& rect) {
247 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) {
248 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, rect.left, rect.top,
249 rect.right, rect.bottom);
250 }
dsinclair577ad2c2016-09-22 10:20:43 -0700251}
252
dsinclair735606d2016-10-05 15:47:02 -0700253void CPDFSDK_FormFillEnvironment::SetCursor(int nCursorType) {
dsinclair577ad2c2016-09-22 10:20:43 -0700254 if (m_pInfo && m_pInfo->FFI_SetCursor)
255 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType);
256}
257
dsinclair735606d2016-10-05 15:47:02 -0700258int CPDFSDK_FormFillEnvironment::SetTimer(int uElapse,
259 TimerCallback lpTimerFunc) {
dsinclair577ad2c2016-09-22 10:20:43 -0700260 if (m_pInfo && m_pInfo->FFI_SetTimer)
261 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc);
262 return -1;
263}
264
dsinclair735606d2016-10-05 15:47:02 -0700265void CPDFSDK_FormFillEnvironment::KillTimer(int nTimerID) {
dsinclair577ad2c2016-09-22 10:20:43 -0700266 if (m_pInfo && m_pInfo->FFI_KillTimer)
267 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID);
268}
269
dsinclair735606d2016-10-05 15:47:02 -0700270FX_SYSTEMTIME CPDFSDK_FormFillEnvironment::GetLocalTime() const {
dsinclair577ad2c2016-09-22 10:20:43 -0700271 FX_SYSTEMTIME fxtime;
272 if (!m_pInfo || !m_pInfo->FFI_GetLocalTime)
273 return fxtime;
274
275 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo);
276 fxtime.wDay = systime.wDay;
277 fxtime.wDayOfWeek = systime.wDayOfWeek;
278 fxtime.wHour = systime.wHour;
279 fxtime.wMilliseconds = systime.wMilliseconds;
280 fxtime.wMinute = systime.wMinute;
281 fxtime.wMonth = systime.wMonth;
282 fxtime.wSecond = systime.wSecond;
283 fxtime.wYear = systime.wYear;
284 return fxtime;
285}
286
dsinclair735606d2016-10-05 15:47:02 -0700287void CPDFSDK_FormFillEnvironment::OnChange() {
dsinclair577ad2c2016-09-22 10:20:43 -0700288 if (m_pInfo && m_pInfo->FFI_OnChange)
289 m_pInfo->FFI_OnChange(m_pInfo);
290}
291
Lei Zhang671630e2017-05-19 19:25:16 -0700292FPDF_PAGE CPDFSDK_FormFillEnvironment::GetCurrentPage(
293 UnderlyingDocumentType* document) {
dsinclair577ad2c2016-09-22 10:20:43 -0700294 if (m_pInfo && m_pInfo->FFI_GetCurrentPage)
295 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document);
296 return nullptr;
297}
298
Dan Sinclair812e96c2017-03-13 16:43:37 -0400299void CPDFSDK_FormFillEnvironment::ExecuteNamedAction(const char* namedAction) {
dsinclair577ad2c2016-09-22 10:20:43 -0700300 if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction)
301 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction);
302}
303
dsinclair735606d2016-10-05 15:47:02 -0700304void CPDFSDK_FormFillEnvironment::OnSetFieldInputFocus(
305 FPDF_WIDESTRING focusText,
306 FPDF_DWORD nTextLen,
tsepez4cf55152016-11-02 14:37:54 -0700307 bool bFocus) {
dsinclair577ad2c2016-09-22 10:20:43 -0700308 if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus)
309 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus);
310}
311
Dan Sinclair812e96c2017-03-13 16:43:37 -0400312void CPDFSDK_FormFillEnvironment::DoURIAction(const char* bsURI) {
dsinclair577ad2c2016-09-22 10:20:43 -0700313 if (m_pInfo && m_pInfo->FFI_DoURIAction)
314 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI);
315}
316
dsinclair735606d2016-10-05 15:47:02 -0700317void CPDFSDK_FormFillEnvironment::DoGoToAction(int nPageIndex,
318 int zoomMode,
319 float* fPosArray,
320 int sizeOfArray) {
dsinclair577ad2c2016-09-22 10:20:43 -0700321 if (m_pInfo && m_pInfo->FFI_DoGoToAction) {
322 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray,
323 sizeOfArray);
324 }
325}
326
327#ifdef PDF_ENABLE_XFA
Lei Zhang671630e2017-05-19 19:25:16 -0700328void CPDFSDK_FormFillEnvironment::DisplayCaret(CPDFXFA_Page* page,
dsinclair735606d2016-10-05 15:47:02 -0700329 FPDF_BOOL bVisible,
330 double left,
331 double top,
332 double right,
333 double bottom) {
dsinclair577ad2c2016-09-22 10:20:43 -0700334 if (m_pInfo && m_pInfo->FFI_DisplayCaret) {
335 m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right,
336 bottom);
337 }
338}
339
Lei Zhang671630e2017-05-19 19:25:16 -0700340int CPDFSDK_FormFillEnvironment::GetCurrentPageIndex(
341 CPDFXFA_Context* document) {
dsinclair577ad2c2016-09-22 10:20:43 -0700342 if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex)
343 return -1;
344 return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document);
345}
346
Lei Zhang671630e2017-05-19 19:25:16 -0700347void CPDFSDK_FormFillEnvironment::SetCurrentPage(CPDFXFA_Context* document,
dsinclair735606d2016-10-05 15:47:02 -0700348 int iCurPage) {
dsinclair577ad2c2016-09-22 10:20:43 -0700349 if (m_pInfo && m_pInfo->FFI_SetCurrentPage)
350 m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage);
351}
352
dsinclair735606d2016-10-05 15:47:02 -0700353CFX_WideString CPDFSDK_FormFillEnvironment::GetPlatform() {
dsinclair577ad2c2016-09-22 10:20:43 -0700354 if (!m_pInfo || !m_pInfo->FFI_GetPlatform)
Tom Sepez4ad46902017-05-02 13:19:56 -0700355 return CFX_WideString();
dsinclair577ad2c2016-09-22 10:20:43 -0700356
357 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, nullptr, 0);
358 if (nRequiredLen <= 0)
Tom Sepez4ad46902017-05-02 13:19:56 -0700359 return CFX_WideString();
dsinclair577ad2c2016-09-22 10:20:43 -0700360
Tom Sepez4ad46902017-05-02 13:19:56 -0700361 std::vector<uint8_t> pBuff(nRequiredLen);
362 int nActualLen =
363 m_pInfo->FFI_GetPlatform(m_pInfo, pBuff.data(), nRequiredLen);
364 if (nActualLen <= 0 || nActualLen > nRequiredLen)
365 return CFX_WideString();
366
367 return CFX_WideString::FromUTF16LE(reinterpret_cast<uint16_t*>(pBuff.data()),
368 nActualLen / sizeof(uint16_t));
dsinclair577ad2c2016-09-22 10:20:43 -0700369}
370
Lei Zhang671630e2017-05-19 19:25:16 -0700371void CPDFSDK_FormFillEnvironment::GotoURL(CPDFXFA_Context* document,
dsinclair735606d2016-10-05 15:47:02 -0700372 const CFX_WideStringC& wsURL) {
dsinclair577ad2c2016-09-22 10:20:43 -0700373 if (!m_pInfo || !m_pInfo->FFI_GotoURL)
374 return;
375
376 CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode();
377 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength());
378 m_pInfo->FFI_GotoURL(m_pInfo, document, pTo);
379 bsTo.ReleaseBuffer();
380}
381
Lei Zhang671630e2017-05-19 19:25:16 -0700382void CPDFSDK_FormFillEnvironment::GetPageViewRect(CPDFXFA_Page* page,
dsinclair735606d2016-10-05 15:47:02 -0700383 FS_RECTF& dstRect) {
dsinclair577ad2c2016-09-22 10:20:43 -0700384 if (!m_pInfo || !m_pInfo->FFI_GetPageViewRect)
385 return;
386
387 double left;
388 double top;
389 double right;
390 double bottom;
391 m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom);
Lei Zhang222e1a42017-06-20 14:47:00 -0700392 if (top < bottom)
393 std::swap(top, bottom);
dsinclair577ad2c2016-09-22 10:20:43 -0700394
395 dstRect.left = static_cast<float>(left);
Lei Zhang222e1a42017-06-20 14:47:00 -0700396 dstRect.top = static_cast<float>(top);
397 dstRect.bottom = static_cast<float>(bottom);
dsinclair577ad2c2016-09-22 10:20:43 -0700398 dstRect.right = static_cast<float>(right);
399}
400
Lei Zhang671630e2017-05-19 19:25:16 -0700401bool CPDFSDK_FormFillEnvironment::PopupMenu(CPDFXFA_Page* page,
tsepez4cf55152016-11-02 14:37:54 -0700402 FPDF_WIDGET hWidget,
403 int menuFlag,
404 CFX_PointF pt) {
tsepezdc0401a2016-10-28 13:10:35 -0700405 return m_pInfo && m_pInfo->FFI_PopupMenu &&
406 m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, pt.x, pt.y);
dsinclair577ad2c2016-09-22 10:20:43 -0700407}
408
dsinclair735606d2016-10-05 15:47:02 -0700409void CPDFSDK_FormFillEnvironment::Alert(FPDF_WIDESTRING Msg,
410 FPDF_WIDESTRING Title,
411 int Type,
412 int Icon) {
dsinclair577ad2c2016-09-22 10:20:43 -0700413 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) {
414 m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, Type,
415 Icon);
416 }
417}
418
dsinclair735606d2016-10-05 15:47:02 -0700419void CPDFSDK_FormFillEnvironment::EmailTo(FPDF_FILEHANDLER* fileHandler,
420 FPDF_WIDESTRING pTo,
421 FPDF_WIDESTRING pSubject,
422 FPDF_WIDESTRING pCC,
423 FPDF_WIDESTRING pBcc,
424 FPDF_WIDESTRING pMsg) {
dsinclair577ad2c2016-09-22 10:20:43 -0700425 if (m_pInfo && m_pInfo->FFI_EmailTo)
426 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, pMsg);
427}
428
dsinclair735606d2016-10-05 15:47:02 -0700429void CPDFSDK_FormFillEnvironment::UploadTo(FPDF_FILEHANDLER* fileHandler,
430 int fileFlag,
431 FPDF_WIDESTRING uploadTo) {
dsinclair577ad2c2016-09-22 10:20:43 -0700432 if (m_pInfo && m_pInfo->FFI_UploadTo)
433 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo);
434}
435
dsinclair735606d2016-10-05 15:47:02 -0700436FPDF_FILEHANDLER* CPDFSDK_FormFillEnvironment::OpenFile(int fileType,
437 FPDF_WIDESTRING wsURL,
438 const char* mode) {
dsinclair577ad2c2016-09-22 10:20:43 -0700439 if (m_pInfo && m_pInfo->FFI_OpenFile)
440 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode);
441 return nullptr;
442}
443
tsepez833619b2016-12-07 09:21:17 -0800444CFX_RetainPtr<IFX_SeekableReadStream>
Dan Sinclair812e96c2017-03-13 16:43:37 -0400445CPDFSDK_FormFillEnvironment::DownloadFromURL(const wchar_t* url) {
dsinclair577ad2c2016-09-22 10:20:43 -0700446 if (!m_pInfo || !m_pInfo->FFI_DownloadFromURL)
447 return nullptr;
448
449 CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode();
450 FPDF_WIDESTRING wsURL =
451 (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength());
452
453 FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL);
tsepezfa89a202016-12-02 09:48:30 -0800454 return MakeSeekableStream(fileHandler);
dsinclair577ad2c2016-09-22 10:20:43 -0700455}
456
dsinclair735606d2016-10-05 15:47:02 -0700457CFX_WideString CPDFSDK_FormFillEnvironment::PostRequestURL(
Dan Sinclair812e96c2017-03-13 16:43:37 -0400458 const wchar_t* wsURL,
459 const wchar_t* wsData,
460 const wchar_t* wsContentType,
461 const wchar_t* wsEncode,
462 const wchar_t* wsHeader) {
dsinclair577ad2c2016-09-22 10:20:43 -0700463 if (!m_pInfo || !m_pInfo->FFI_PostRequestURL)
464 return L"";
465
466 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
467 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength());
468
469 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
470 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength());
471
472 CFX_ByteString bsContentType = CFX_WideString(wsContentType).UTF16LE_Encode();
473 FPDF_WIDESTRING contentType =
474 (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength());
475
476 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
477 FPDF_WIDESTRING encode =
478 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength());
479
480 CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode();
481 FPDF_WIDESTRING header =
482 (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength());
483
484 FPDF_BSTR response;
485 FPDF_BStr_Init(&response);
486 m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header,
487 &response);
488
489 CFX_WideString wsRet = CFX_WideString::FromUTF16LE(
490 (FPDF_WIDESTRING)response.str, response.len / sizeof(FPDF_WIDESTRING));
491 FPDF_BStr_Clear(&response);
492
493 return wsRet;
494}
495
Dan Sinclair812e96c2017-03-13 16:43:37 -0400496FPDF_BOOL CPDFSDK_FormFillEnvironment::PutRequestURL(const wchar_t* wsURL,
497 const wchar_t* wsData,
498 const wchar_t* wsEncode) {
dsinclair577ad2c2016-09-22 10:20:43 -0700499 if (!m_pInfo || !m_pInfo->FFI_PutRequestURL)
tsepez4cf55152016-11-02 14:37:54 -0700500 return false;
dsinclair577ad2c2016-09-22 10:20:43 -0700501
502 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
503 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength());
504
505 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
506 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength());
507
508 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
509 FPDF_WIDESTRING encode =
510 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength());
511
512 return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode);
513}
514
dsinclair735606d2016-10-05 15:47:02 -0700515CFX_WideString CPDFSDK_FormFillEnvironment::GetLanguage() {
dsinclair577ad2c2016-09-22 10:20:43 -0700516 if (!m_pInfo || !m_pInfo->FFI_GetLanguage)
Tom Sepez4ad46902017-05-02 13:19:56 -0700517 return CFX_WideString();
dsinclair577ad2c2016-09-22 10:20:43 -0700518
519 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, nullptr, 0);
520 if (nRequiredLen <= 0)
Tom Sepez4ad46902017-05-02 13:19:56 -0700521 return CFX_WideString();
dsinclair577ad2c2016-09-22 10:20:43 -0700522
Tom Sepez4ad46902017-05-02 13:19:56 -0700523 std::vector<uint8_t> pBuff(nRequiredLen);
524 int nActualLen =
525 m_pInfo->FFI_GetLanguage(m_pInfo, pBuff.data(), nRequiredLen);
526 if (nActualLen <= 0 || nActualLen > nRequiredLen)
527 return CFX_WideString();
528
529 return CFX_WideString::FromUTF16LE(reinterpret_cast<uint16_t*>(pBuff.data()),
530 nActualLen / sizeof(uint16_t));
dsinclair577ad2c2016-09-22 10:20:43 -0700531}
532
dsinclair735606d2016-10-05 15:47:02 -0700533void CPDFSDK_FormFillEnvironment::PageEvent(int iPageCount,
534 uint32_t dwEventType) const {
dsinclair577ad2c2016-09-22 10:20:43 -0700535 if (m_pInfo && m_pInfo->FFI_PageEvent)
536 m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType);
537}
538#endif // PDF_ENABLE_XFA
dsinclair7cbe68e2016-10-12 11:56:23 -0700539
540void CPDFSDK_FormFillEnvironment::ClearAllFocusedAnnots() {
tsepez2599ff72016-11-08 14:38:59 -0800541 for (auto& it : m_PageMap) {
dsinclair7cbe68e2016-10-12 11:56:23 -0700542 if (it.second->IsValidSDKAnnot(GetFocusAnnot()))
543 KillFocusAnnot(0);
544 }
545}
546
547CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetPageView(
548 UnderlyingPageType* pUnderlyingPage,
dsinclair6c659ab2016-10-12 13:41:38 -0700549 bool renew) {
tsepez2599ff72016-11-08 14:38:59 -0800550 auto it = m_PageMap.find(pUnderlyingPage);
551 if (it != m_PageMap.end())
dsinclair6c659ab2016-10-12 13:41:38 -0700552 return it->second.get();
dsinclair7cbe68e2016-10-12 11:56:23 -0700553
dsinclair6c659ab2016-10-12 13:41:38 -0700554 if (!renew)
dsinclair7cbe68e2016-10-12 11:56:23 -0700555 return nullptr;
556
Tom Sepezfe91c6c2017-05-16 15:33:20 -0700557 auto pNew = pdfium::MakeUnique<CPDFSDK_PageView>(this, pUnderlyingPage);
558 CPDFSDK_PageView* pPageView = pNew.get();
559 m_PageMap[pUnderlyingPage] = std::move(pNew);
560
dsinclair7cbe68e2016-10-12 11:56:23 -0700561 // Delay to load all the annotations, to avoid endless loop.
562 pPageView->LoadFXAnnots();
563 return pPageView;
564}
565
566CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetCurrentView() {
567 UnderlyingPageType* pPage =
Tom Sepez940967d2017-05-18 12:32:20 -0700568 UnderlyingFromFPDFPage(GetCurrentPage(m_pUnderlyingDoc.Get()));
dsinclair7cbe68e2016-10-12 11:56:23 -0700569 return pPage ? GetPageView(pPage, true) : nullptr;
570}
571
572CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetPageView(int nIndex) {
Lei Zhang60fa2fc2017-07-21 17:42:19 -0700573 UnderlyingPageType* pTempPage = GetPage(nIndex);
dsinclair7cbe68e2016-10-12 11:56:23 -0700574 if (!pTempPage)
575 return nullptr;
576
tsepez2599ff72016-11-08 14:38:59 -0800577 auto it = m_PageMap.find(pTempPage);
578 return it != m_PageMap.end() ? it->second.get() : nullptr;
dsinclair7cbe68e2016-10-12 11:56:23 -0700579}
580
581void CPDFSDK_FormFillEnvironment::ProcJavascriptFun() {
582 CPDF_Document* pPDFDoc = GetPDFDocument();
583 CPDF_DocJSActions docJS(pPDFDoc);
584 int iCount = docJS.CountJSActions();
dsinclair7cbe68e2016-10-12 11:56:23 -0700585 for (int i = 0; i < iCount; i++) {
Jane Liu67ccef72017-07-19 13:10:50 -0400586 CFX_WideString csJSName;
Tom Sepezc4a2b752017-04-07 13:56:13 -0700587 CPDF_Action jsAction = docJS.GetJSActionAndName(i, &csJSName);
Jane Liu67ccef72017-07-19 13:10:50 -0400588 GetActionHandler()->DoAction_JavaScript(jsAction, csJSName, this);
dsinclair7cbe68e2016-10-12 11:56:23 -0700589 }
590}
591
tsepez4cf55152016-11-02 14:37:54 -0700592bool CPDFSDK_FormFillEnvironment::ProcOpenAction() {
dsinclair7cbe68e2016-10-12 11:56:23 -0700593 if (!m_pUnderlyingDoc)
tsepez4cf55152016-11-02 14:37:54 -0700594 return false;
dsinclair7cbe68e2016-10-12 11:56:23 -0700595
596 CPDF_Dictionary* pRoot = GetPDFDocument()->GetRoot();
597 if (!pRoot)
tsepez4cf55152016-11-02 14:37:54 -0700598 return false;
dsinclair7cbe68e2016-10-12 11:56:23 -0700599
600 CPDF_Object* pOpenAction = pRoot->GetDictFor("OpenAction");
601 if (!pOpenAction)
602 pOpenAction = pRoot->GetArrayFor("OpenAction");
dsinclair7cbe68e2016-10-12 11:56:23 -0700603 if (!pOpenAction)
tsepez4cf55152016-11-02 14:37:54 -0700604 return false;
dsinclair7cbe68e2016-10-12 11:56:23 -0700605
606 if (pOpenAction->IsArray())
tsepez4cf55152016-11-02 14:37:54 -0700607 return true;
dsinclair7cbe68e2016-10-12 11:56:23 -0700608
Lei Zhang222e1a42017-06-20 14:47:00 -0700609 CPDF_Dictionary* pDict = pOpenAction->AsDictionary();
610 if (!pDict)
611 return false;
612
613 CPDF_Action action(pDict);
Lei Zhangcddc8ed2017-06-20 17:26:44 -0700614 GetActionHandler()->DoAction_DocOpen(action, this);
Lei Zhang222e1a42017-06-20 14:47:00 -0700615 return true;
dsinclair7cbe68e2016-10-12 11:56:23 -0700616}
617
618void CPDFSDK_FormFillEnvironment::RemovePageView(
619 UnderlyingPageType* pUnderlyingPage) {
tsepez2599ff72016-11-08 14:38:59 -0800620 auto it = m_PageMap.find(pUnderlyingPage);
621 if (it == m_PageMap.end())
dsinclair7cbe68e2016-10-12 11:56:23 -0700622 return;
623
dsinclair6c659ab2016-10-12 13:41:38 -0700624 CPDFSDK_PageView* pPageView = it->second.get();
dsinclair7cbe68e2016-10-12 11:56:23 -0700625 if (pPageView->IsLocked() || pPageView->IsBeingDestroyed())
626 return;
627
628 // Mark the page view so we do not come into |RemovePageView| a second
629 // time while we're in the process of removing.
630 pPageView->SetBeingDestroyed();
631
632 // This must happen before we remove |pPageView| from the map because
633 // |KillFocusAnnot| can call into the |GetPage| method which will
634 // look for this page view in the map, if it doesn't find it a new one will
635 // be created. We then have two page views pointing to the same page and
636 // bad things happen.
637 if (pPageView->IsValidSDKAnnot(GetFocusAnnot()))
638 KillFocusAnnot(0);
639
640 // Remove the page from the map to make sure we don't accidentally attempt
641 // to use the |pPageView| while we're cleaning it up.
tsepez2599ff72016-11-08 14:38:59 -0800642 m_PageMap.erase(it);
dsinclair7cbe68e2016-10-12 11:56:23 -0700643}
644
645UnderlyingPageType* CPDFSDK_FormFillEnvironment::GetPage(int nIndex) {
Lei Zhang60fa2fc2017-07-21 17:42:19 -0700646 if (!m_pInfo || !m_pInfo->FFI_GetPage)
647 return nullptr;
648 return UnderlyingFromFPDFPage(
649 m_pInfo->FFI_GetPage(m_pInfo, m_pUnderlyingDoc.Get(), nIndex));
dsinclair7cbe68e2016-10-12 11:56:23 -0700650}
651
652CPDFSDK_InterForm* CPDFSDK_FormFillEnvironment::GetInterForm() {
653 if (!m_pInterForm)
654 m_pInterForm = pdfium::MakeUnique<CPDFSDK_InterForm>(this);
655 return m_pInterForm.get();
656}
657
658void CPDFSDK_FormFillEnvironment::UpdateAllViews(CPDFSDK_PageView* pSender,
659 CPDFSDK_Annot* pAnnot) {
tsepez2599ff72016-11-08 14:38:59 -0800660 for (const auto& it : m_PageMap) {
dsinclair6c659ab2016-10-12 13:41:38 -0700661 CPDFSDK_PageView* pPageView = it.second.get();
dsinclair7cbe68e2016-10-12 11:56:23 -0700662 if (pPageView != pSender)
663 pPageView->UpdateView(pAnnot);
664 }
665}
666
tsepez4cf55152016-11-02 14:37:54 -0700667bool CPDFSDK_FormFillEnvironment::SetFocusAnnot(
dsinclair7cbe68e2016-10-12 11:56:23 -0700668 CPDFSDK_Annot::ObservedPtr* pAnnot) {
669 if (m_bBeingDestroyed)
tsepez4cf55152016-11-02 14:37:54 -0700670 return false;
dsinclair7cbe68e2016-10-12 11:56:23 -0700671 if (m_pFocusAnnot == *pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700672 return true;
dsinclair7cbe68e2016-10-12 11:56:23 -0700673 if (m_pFocusAnnot && !KillFocusAnnot(0))
tsepez4cf55152016-11-02 14:37:54 -0700674 return false;
dsinclair7cbe68e2016-10-12 11:56:23 -0700675 if (!*pAnnot)
tsepez4cf55152016-11-02 14:37:54 -0700676 return false;
dsinclair7cbe68e2016-10-12 11:56:23 -0700677
Lei Zhang222e1a42017-06-20 14:47:00 -0700678 CPDFSDK_PageView* pPageView = (*pAnnot)->GetPageView();
679 if (!pPageView || !pPageView->IsValid())
680 return false;
681
682 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = GetAnnotHandlerMgr();
683 if (m_pFocusAnnot)
684 return false;
685
dsinclair7cbe68e2016-10-12 11:56:23 -0700686#ifdef PDF_ENABLE_XFA
687 CPDFSDK_Annot::ObservedPtr pLastFocusAnnot(m_pFocusAnnot.Get());
Lei Zhang222e1a42017-06-20 14:47:00 -0700688 if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, &pLastFocusAnnot))
689 return false;
dsinclair7cbe68e2016-10-12 11:56:23 -0700690#endif // PDF_ENABLE_XFA
Lei Zhang222e1a42017-06-20 14:47:00 -0700691 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, 0))
692 return false;
693 if (m_pFocusAnnot)
694 return false;
695
696 m_pFocusAnnot.Reset(pAnnot->Get());
697 return true;
dsinclair7cbe68e2016-10-12 11:56:23 -0700698}
699
tsepez4cf55152016-11-02 14:37:54 -0700700bool CPDFSDK_FormFillEnvironment::KillFocusAnnot(uint32_t nFlag) {
Lei Zhang222e1a42017-06-20 14:47:00 -0700701 if (!m_pFocusAnnot)
702 return false;
703
704 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = GetAnnotHandlerMgr();
705 CPDFSDK_Annot::ObservedPtr pFocusAnnot(m_pFocusAnnot.Get());
706 m_pFocusAnnot.Reset();
dsinclair7cbe68e2016-10-12 11:56:23 -0700707
708#ifdef PDF_ENABLE_XFA
Lei Zhang222e1a42017-06-20 14:47:00 -0700709 CPDFSDK_Annot::ObservedPtr pNull;
710 if (!pAnnotHandler->Annot_OnChangeFocus(&pNull, &pFocusAnnot))
711 return false;
dsinclair7cbe68e2016-10-12 11:56:23 -0700712#endif // PDF_ENABLE_XFA
713
Lei Zhang222e1a42017-06-20 14:47:00 -0700714 if (!pAnnotHandler->Annot_OnKillFocus(&pFocusAnnot, nFlag)) {
715 m_pFocusAnnot.Reset(pFocusAnnot.Get());
716 return false;
717 }
718
719 if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) {
720 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pFocusAnnot.Get());
721 int nFieldType = pWidget->GetFieldType();
722 if (FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX == nFieldType) {
723 OnSetFieldInputFocus(nullptr, 0, false);
dsinclair7cbe68e2016-10-12 11:56:23 -0700724 }
725 }
Lei Zhang222e1a42017-06-20 14:47:00 -0700726 return !m_pFocusAnnot;
dsinclair7cbe68e2016-10-12 11:56:23 -0700727}
728
Lei Zhangad0982a2017-06-16 19:30:38 -0700729bool CPDFSDK_FormFillEnvironment::GetPermissions(int nFlag) const {
tsepez95e58342016-10-28 11:34:42 -0700730 return !!(GetPDFDocument()->GetUserPermissions() & nFlag);
dsinclair7cbe68e2016-10-12 11:56:23 -0700731}