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

Side by Side Diff: fpdfsdk/include/fsdk_mgr.h

Issue 1244503002: Merge to XFA: Tidy up CPDFDOC_Environment. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Address comments, also remove two noisy unused var. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/include/formfiller/FFL_FormFiller.h ('k') | fpdfsdk/src/formfiller/FFL_FormFiller.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_ 7 #ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_
8 #define FPDFSDK_INCLUDE_FSDK_MGR_H_ 8 #define FPDFSDK_INCLUDE_FSDK_MGR_H_
9 9
10 #include <map> 10 #include <map>
11 11
12 #include "../../core/include/fpdftext/fpdf_text.h" 12 #include "../../core/include/fpdftext/fpdf_text.h"
13 #include "../../public/fpdf_formfill.h" 13 #include "../../public/fpdf_formfill.h"
14 #include "../../public/fpdf_fwlevent.h" // cross platform keycode and events def ine. 14 #include "../../public/fpdf_fwlevent.h" // cross platform keycode and events def ine.
15 #include "fsdk_common.h" 15 #include "fsdk_common.h"
16 #include "fsdk_define.h" 16 #include "fsdk_define.h"
17 #include "fx_systemhandler.h" 17 #include "fx_systemhandler.h"
18 #include "fpdfxfa/fpdfxfa_doc.h" 18 #include "fpdfxfa/fpdfxfa_doc.h"
19 #include "fpdfxfa/fpdfxfa_page.h" 19 #include "fpdfxfa/fpdfxfa_page.h"
20 #include "fsdk_baseannot.h" 20 #include "fsdk_baseannot.h"
21 #include "fsdk_baseform.h" 21 #include "fsdk_baseform.h"
22 #include "fsdk_annothandler.h" 22 #include "fsdk_annothandler.h"
23 #include "fsdk_actionhandler.h" 23 #include "fsdk_actionhandler.h"
24 #include "javascript/IJavaScript.h" 24 #include "javascript/IJavaScript.h"
25 25
26 class CFFL_IFormFiller;
27 class CJS_RuntimeFactory;
28 class CPDFSDK_ActionHandler;
29 class CPDFSDK_Annot;
26 class CPDFSDK_Document; 30 class CPDFSDK_Document;
31 class CPDFSDK_InterForm;
27 class CPDFSDK_PageView; 32 class CPDFSDK_PageView;
28 class CPDFSDK_Annot;
29 class CFFL_IFormFiller;
30 class CPDFSDK_Widget; 33 class CPDFSDK_Widget;
31 class IFX_SystemHandler; 34 class IFX_SystemHandler;
32 class CPDFSDK_ActionHandler;
33 class CJS_RuntimeFactory;
34 35
35 class CPDFDoc_Environment final 36 class CPDFDoc_Environment final
36 { 37 {
37 public: 38 public:
38 CPDFDoc_Environment(CPDFXFA_Document * pDoc); 39 CPDFDoc_Environment(CPDFXFA_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo);
39 virtual ~CPDFDoc_Environment(); 40 virtual ~CPDFDoc_Environment();
40 41
41 int RegAppHandle(FPDF_FORMFILLINFO* pFFinfo); 42 virtual void Release()
42 43 {
43 virtual void Release() 44 if (m_pInfo && m_pInfo->Release)
44 { 45 m_pInfo->Release(m_pInfo);
45 if (m_pInfo && m_pInfo->Release) 46 delete this;
46 m_pInfo->Release(m_pInfo); 47 }
47 delete this; 48
48 } 49 void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, d ouble bottom)
49 void FFI_Invalidate(FPDF_PAGE page, double left, double top, double righ t, double bottom) 50 {
50 { 51 if (m_pInfo && m_pInfo->FFI_Invalidate)
51 if (m_pInfo && m_pInfo->FFI_Invalidate) 52 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom);
52 { 53 }
53 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); 54
54 } 55 void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom)
55 } 56 {
56 void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, dou ble right, double bottom) 57 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect)
57 { 58 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bot tom);
58 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) 59 }
59 { 60
60 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top , right, bottom); 61 void FFI_SetCursor(int nCursorType)
61 } 62 {
62 } 63 if (m_pInfo && m_pInfo->FFI_SetCursor)
63 64 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType);
64 void FFI_SetCursor(int nCursorType) 65 }
65 { 66
66 if (m_pInfo && m_pInfo->FFI_SetCursor) 67 int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc)
67 { 68 {
68 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); 69 if (m_pInfo && m_pInfo->FFI_SetTimer)
69 } 70 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc);
70 } 71 return -1;
71 72 }
72 int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) 73
73 { 74 void FFI_KillTimer(int nTimerID)
74 if (m_pInfo && m_pInfo->FFI_SetTimer) 75 {
75 { 76 if (m_pInfo && m_pInfo->FFI_KillTimer)
76 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFu nc); 77 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID);
77 } 78 }
78 return -1; 79
79 } 80 FX_SYSTEMTIME FFI_GetLocalTime()
80 81 {
81 void FFI_KillTimer(int nTimerID) 82 FX_SYSTEMTIME fxtime;
82 { 83 if(m_pInfo && m_pInfo->FFI_GetLocalTime)
83 if (m_pInfo && m_pInfo->FFI_KillTimer) 84 {
84 { 85 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo);
85 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); 86 fxtime.wDay = systime.wDay;
86 } 87 fxtime.wDayOfWeek = systime.wDayOfWeek;
87 } 88 fxtime.wHour = systime.wHour;
88 FX_SYSTEMTIME FFI_GetLocalTime() 89 fxtime.wMilliseconds = systime.wMilliseconds;
89 { 90 fxtime.wMinute = systime.wMinute;
90 FX_SYSTEMTIME fxtime; 91 fxtime.wMonth = systime.wMonth;
91 if(m_pInfo && m_pInfo->FFI_GetLocalTime) 92 fxtime.wSecond = systime.wSecond;
92 { 93 fxtime.wYear = systime.wYear;
93 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pI nfo); 94 }
94 fxtime.wDay = systime.wDay; 95 return fxtime;
95 fxtime.wDayOfWeek = systime.wDayOfWeek; 96 }
96 fxtime.wHour = systime.wHour; 97
97 fxtime.wMilliseconds = systime.wMilliseconds; 98 void FFI_OnChange()
98 fxtime.wMinute = systime.wMinute; 99 {
99 fxtime.wMonth = systime.wMonth; 100 if (m_pInfo && m_pInfo->FFI_OnChange)
100 fxtime.wSecond = systime.wSecond; 101 m_pInfo->FFI_OnChange(m_pInfo);
101 fxtime.wYear = systime.wYear; 102 }
102 } 103
103 return fxtime; 104 FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag)
104 } 105 {
105 106 return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0;
106 void FFI_OnChange() 107 }
107 { 108
108 if(m_pInfo && m_pInfo->FFI_OnChange) 109 FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag)
109 { 110 {
110 m_pInfo->FFI_OnChange(m_pInfo); 111 return (nFlag & FWL_EVENTFLAG_ControlKey) != 0;
111 } 112 }
112 } 113
113 114 FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag)
114 FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) 115 {
115 { 116 return (nFlag & FWL_EVENTFLAG_AltKey) != 0;
116 117 }
117 return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; 118
118 } 119 FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag)
119 FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) 120 {
120 { 121 return FALSE;
121 122 }
122 return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; 123
123 } 124 int JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX _UINT Icon);
124 FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) 125 int JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, const FX _WCHAR* Default,
125 { 126 const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* respon se, int length);
126 127
127 return (nFlag & FWL_EVENTFLAG_AltKey) != 0; 128 void JS_appBeep(int nType)
128 } 129 {
129 FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) 130 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_bee p)
130 { 131 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType);
131 return FALSE; 132 }
132 } 133
133 134 CFX_WideString JS_fieldBrowse();
134 int JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type , FX_UINT Icon) 135 CFX_WideString JS_docGetFilePath();
135 { 136
136 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> app_alert) 137 void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL);
137 { 138 void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,
138 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encod e(); 139 const FX_WCHAR* To, const FX_WCHAR* Subject,
139 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_E ncode(); 140 const FX_WCHAR* CC, const FX_WCHAR* BCC,
140 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer( bsMsg.GetLength()); 141 const FX_WCHAR* Msg);
141 FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuf fer(bsTitle.GetLength()); 142
142 int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_p JsPlatform, pMsg, pTitle, Type, Icon); 143 void JS_docprint(FPDF_BOOL bUI, int nStart, int nEnd, FPDF_BOOL bSilent,
143 bsMsg.ReleaseBuffer(); 144 FPDF_BOOL bShrinkToFit, FPDF_BOOL bPrintAsImage,
144 bsTitle.ReleaseBuffer(); 145 FPDF_BOOL bReverse, FPDF_BOOL bAnnotations)
145 return ret; 146 {
146 } 147 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_pri nt)
147 return -1; 148 m_pInfo->m_pJsPlatform->Doc_print(
148 } 149 m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, bSilent, bShrinkToFit ,
149 150 bPrintAsImage, bReverse, bAnnotations);
150 int JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, cons t FX_WCHAR* Default, const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* response , int length) 151 }
151 { 152
152 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform- >app_response) 153 void JS_docgotoPage(int nPageNum)
153 { 154 {
154 CFX_ByteString bsQuestion = CFX_WideString(Question).UTF 16LE_Encode(); 155 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_goto Page)
155 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_E ncode(); 156 m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNu m);
156 CFX_ByteString bsDefault = CFX_WideString(Default).UTF16 LE_Encode(); 157 }
157 CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_ Encode(); 158
158 FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion. GetBuffer(bsQuestion.GetLength()); 159 FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex)
159 FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuf fer(bsTitle.GetLength()); 160 {
160 FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.Ge tBuffer(bsDefault.GetLength()); 161 if (m_pInfo && m_pInfo->FFI_GetPage)
161 FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuf fer(bsLabel.GetLength()); 162 return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex);
162 int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo-> m_pJsPlatform, pQuestion, pTitle, 163 return NULL;
163 pDefault, pLabel, bPassword, response, length); 164 }
164 bsQuestion.ReleaseBuffer(); 165
165 bsTitle.ReleaseBuffer(); 166 FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document)
166 bsDefault.ReleaseBuffer(); 167 {
167 bsLabel.ReleaseBuffer(); 168 if (m_pInfo && m_pInfo->FFI_GetCurrentPage)
168 return ret; 169 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document);
169 } 170 return NULL;
170 return -1; 171 }
171 } 172
172 173 int FFI_GetRotation(FPDF_PAGE page)
173 void JS_appBeep(int nType) 174 {
174 { 175 if (m_pInfo && m_pInfo->FFI_GetRotation)
175 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> app_beep) 176 return m_pInfo->FFI_GetRotation(m_pInfo, page);
176 { 177 return 0;
177 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); 178 }
178 } 179
179 } 180 void FFI_ExecuteNamedAction(const FX_CHAR* namedAction)
180 181 {
181 CFX_WideString JS_fieldBrowse() 182 if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction)
182 { 183 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction);
183 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform- >Field_browse) 184 }
184 { 185
185 int nRequiredLen = m_pInfo->m_pJsPlatform->Field_browse( m_pInfo->m_pJsPlatform, NULL, 0); 186 void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DW ORD nTextLen, FX_BOOL bFocus)
186 if (nRequiredLen <= 0) 187 {
187 return L""; 188 if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus)
188 189 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus) ;
189 char* pbuff = new char[nRequiredLen]; 190 }
190 if (!pbuff) 191
191 return L""; 192 void FFI_DoURIAction(const FX_CHAR* bsURI)
192 193 {
193 memset(pbuff, 0, nRequiredLen); 194 if (m_pInfo && m_pInfo->FFI_DoURIAction)
194 int nActualLen = m_pInfo->m_pJsPlatform->Field_browse(m_ pInfo->m_pJsPlatform, pbuff, nRequiredLen); 195 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI);
195 if (nActualLen <= 0 || nActualLen > nRequiredLen) 196 }
196 { 197
197 delete[] pbuff; 198 void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int si zeOfArray)
198 return L""; 199 {
199 } 200 if (m_pInfo && m_pInfo->FFI_DoGoToAction)
200 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen) ; 201 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray);
201 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); 202 }
202 delete[] pbuff; 203
203 return wsRet; 204 void FFI_DisplayCaret(FPDF_PAGE page, FPDF_BOOL bVisible, double left, doubl e top, double right, double bottom)
204 } 205 {
205 return L""; 206 if (m_pInfo && m_pInfo->FFI_DisplayCaret)
206 } 207 m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, bottom);
207 208 }
208 CFX_WideString JS_docGetFilePath() 209
209 { 210 int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document)
210 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform- >Doc_getFilePath) 211 {
211 { 212 if (m_pInfo && m_pInfo->FFI_GetCurrentPageIndex)
212 int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePa th(m_pInfo->m_pJsPlatform, NULL, 0); 213 m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document);
213 if (nRequiredLen <= 0) 214 return -1;
214 return L""; 215 }
215 216
216 char* pbuff = new char[nRequiredLen]; 217 int FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage)
217 if (!pbuff) 218 {
218 return L""; 219 if (m_pInfo && m_pInfo->FFI_SetCurrentPage)
219 220 m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage);
220 memset(pbuff, 0, nRequiredLen); 221 return -1;
221 int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath (m_pInfo->m_pJsPlatform, pbuff, nRequiredLen); 222 }
222 if (nActualLen <= 0 || nActualLen > nRequiredLen) 223
223 { 224 CFX_WideString FFI_GetAppName() const { return CFX_WideString(L"Acrobat"); }
224 delete[] pbuff; 225
225 return L""; 226 CFX_WideString FFI_GetPlatform()
226 } 227 {
227 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen) ; 228 if (m_pInfo && m_pInfo->FFI_GetPlatform)
228 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); 229 {
229 delete[] pbuff; 230 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, NULL, 0);
230 return wsRet; 231 if (nRequiredLen <= 0)
231 } 232 return L"";
232 return L""; 233
233 } 234 char* pbuff = new char[nRequiredLen];
234 235 if (!pbuff)
235 void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL) 236 return L"";
236 { 237
237 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> Doc_submitForm) 238 memset(pbuff, 0, nRequiredLen);
238 { 239 int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredL en);
239 CFX_ByteString bsDestination = CFX_WideString(URL).UTF16 LE_Encode(); 240 if (nActualLen <= 0 || nActualLen > nRequiredLen)
240 FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestin ation.GetBuffer(bsDestination.GetLength()); 241 {
241 m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPla tform, formData, length, pDestination); 242 delete[] pbuff;
242 bsDestination.ReleaseBuffer(); 243 return L"";
243 } 244 }
244 } 245 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
245 246 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*) bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short));
246 void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,const FX_W CHAR* To, const FX_WCHAR* Subject, const FX_WCHAR* CC, const FX_WCHAR* BCC, cons t FX_WCHAR* Msg) 247 delete[] pbuff;
247 { 248 return wsRet;
248 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> Doc_mail) 249 }
249 { 250 return L"";
250 CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode( ); 251 }
251 CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_En code(); 252
252 CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encod e(); 253 void FFI_GotoURL(FPDF_DOCUMENT document, const CFX_WideStringC& wsURL, FX_BO OL bAppend)
253 CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16 LE_Encode(); 254 {
254 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encod e(); 255 if (m_pInfo && m_pInfo->FFI_GotoURL)
255 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bs To.GetLength()); 256 {
256 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bs CC.GetLength()); 257 CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode();
257 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer( bsBcc.GetLength()); 258 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLengt h());
258 FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.Ge tBuffer(bsSubject.GetLength()); 259 m_pInfo->FFI_GotoURL(m_pInfo, document, pTo);
259 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer( bsMsg.GetLength()); 260 bsTo.ReleaseBuffer();
260 m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, length, bUI, pTo, pSubject, 261 }
261 pCC, pBcc, pMsg); 262 }
262 bsTo.ReleaseBuffer(); 263
263 bsCC.ReleaseBuffer(); 264 void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL)
264 bsBcc.ReleaseBuffer(); 265 {
265 bsSubject.ReleaseBuffer(); 266 wsURL = CFX_WideString();
266 bsMsg.ReleaseBuffer(); 267 }
267 } 268
268 } 269 void FFI_AddDoRecord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) {}
269 270 void FFI_PageEvent(FPDF_PAGE page, FPDF_DWORD flag) {}
270 void JS_docprint(FPDF_BOOL bUI , int nStart, int nEnd, FPDF_BOOL bSilent ,FPDF_BOOL bShrinkToFit,FPDF_BOOL bPrintAsImage ,FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations) 271
271 { 272 void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect)
272 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> Doc_print) 273 {
273 { 274 if (m_pInfo && m_pInfo->FFI_GetPageViewRect)
274 m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform , bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotation s); 275 {
275 } 276 double left;
276 } 277 double top;
277 void JS_docgotoPage(int nPageNum) 278 double right;
278 { 279 double bottom;
279 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> Doc_gotoPage) 280 m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bo ttom);
280 { 281
281 m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatf orm, nPageNum); 282 dstRect.left = static_cast<float>(left);
282 } 283 dstRect.top = static_cast<float>(top < bottom ? bottom : top);
283 } 284 dstRect.bottom = static_cast<float>(top < bottom ? top : bottom);
284 285 dstRect.right = static_cast<float>(right);
285 FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex) 286 }
286 { 287 }
287 if(m_pInfo && m_pInfo->FFI_GetPage) 288
288 { 289 FX_BOOL FFI_PopupMenu(FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, CFX _PointF ptPopup, const CFX_PointF* pRectExclude)
289 return m_pInfo->FFI_GetPage(m_pInfo, document, nPageInde x); 290 {
290 } 291 if (m_pInfo && m_pInfo->FFI_PopupMenu)
291 return NULL; 292 return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPo pup.x, ptPopup.y);
292 } 293 return FALSE;
293 294 }
294 FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) 295
295 { 296 void FFI_Alert(FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Ico n)
296 if(m_pInfo && m_pInfo->FFI_GetCurrentPage) 297 {
297 { 298 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_ale rt)
298 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); 299 m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title , Type, Icon);
299 } 300 }
300 return NULL; 301
301 } 302 void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler, FPDF_WIDESTRING pTo,
302 303 FPDF_WIDESTRING pSubject, FPDF_WIDESTRING pCC,
303 int FFI_GetRotation(FPDF_PAGE page) 304 FPDF_WIDESTRING pBcc, FPDF_WIDESTRING pMsg)
304 { 305 {
305 if(m_pInfo && m_pInfo->FFI_GetRotation) 306 if (m_pInfo && m_pInfo->FFI_EmailTo)
306 { 307 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, pMsg);
307 return m_pInfo->FFI_GetRotation(m_pInfo, page); 308 }
308 } 309
309 return 0; 310 void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler, int fileFlag, FPDF_WIDESTRI NG uploadTo)
310 } 311 {
311 void FFI_ExecuteNamedAction(const FX_CHAR* namedAction) 312 if (m_pInfo && m_pInfo->FFI_UploadTo)
312 { 313 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo);
313 if(m_pInfo && m_pInfo->FFI_ExecuteNamedAction) 314 }
314 { 315
315 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); 316 FPDF_FILEHANDLER* FFI_OpenFile(int fileType, FPDF_WIDESTRING wsURL, const ch ar* mode)
316 } 317 {
317 } 318 if (m_pInfo && m_pInfo->FFI_OpenFile)
318 void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, FX_BOOL bFocus) 319 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode);
319 { 320 return NULL;
320 if(m_pInfo && m_pInfo->FFI_SetTextFieldFocus) 321 }
321 { 322
322 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nText Len, bFocus); 323 CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler) const
323 } 324 {
324 } 325 return L"";
325 326 }
326 void FFI_DoURIAction(const FX_CHAR* bsURI) 327
327 { 328 int FFI_GetDocumentCount() const { return 0; }
328 if(m_pInfo && m_pInfo->FFI_DoURIAction) 329 int FFI_GetCurDocument() const { return 0; }
329 { 330
330 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); 331 IFX_FileRead* FFI_DownloadFromURL(const FX_WCHAR* url)
331 } 332 {
332 } 333 if (m_pInfo && m_pInfo->FFI_DownloadFromURL)
333 334 {
334 void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int sizeOfArray) 335 CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode();
335 { 336 FPDF_WIDESTRING wsURL = (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.G etLength());
336 if(m_pInfo && m_pInfo->FFI_DoGoToAction) 337
337 { 338 FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFromURL(m_pInf o, wsURL);
338 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray); 339
339 } 340 CFPDF_FileStream* fileStream = FX_NEW CFPDF_FileStream(fileHandler);
340 } 341 return fileStream;
341 342 }
342 void FFI_DisplayCaret(FPDF_PAGE page, FPDF_BOOL bVisible, double left , double top, double right, double bottom) 343 return NULL;
343 { 344 }
344 if (m_pInfo && m_pInfo->FFI_DisplayCaret) 345
345 { 346 CFX_WideString FFI_PostRequestURL(const FX_WCHAR* wsURL,
346 m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, bottom); 347 const FX_WCHAR* wsData,
347 } 348 const FX_WCHAR* wsContentType,
348 } 349 const FX_WCHAR* wsEncode,
349 int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document) 350 const FX_WCHAR* wsHeader)
350 { 351 {
351 if (m_pInfo && m_pInfo->FFI_GetCurrentPageIndex) 352 if (m_pInfo && m_pInfo->FFI_PostRequestURL)
352 { 353 {
353 m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); 354 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
354 } 355 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLeng th());
355 return -1; 356
356 } 357 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
357 int FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) 358 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetL ength());
358 { 359
359 if (m_pInfo && m_pInfo->FFI_SetCurrentPage) 360 CFX_ByteString bsContentType = CFX_WideString(wsContentType).UTF16LE _Encode();
360 { 361 FPDF_WIDESTRING contentType = (FPDF_WIDESTRING)bsContentType.GetBuff er(bsContentType.GetLength());
361 m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage) ; 362
362 } 363 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
363 return -1; 364 FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncod e.GetLength());
364 } 365
365 366 CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode();
366 CFX_WideString FFI_GetAppName() 367 FPDF_WIDESTRING header = (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeade r.GetLength());
367 { 368
368 return CFX_WideString(L"Acrobat"); 369 FPDF_BSTR respone;
369 370 FPDF_BStr_Init(&respone);
370 //if (m_pInfo && m_pInfo->FFI_GetAppName) 371 m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, &respone);
371 //{ 372
372 // int nLen = m_pInfo->FFI_GetAppName(m_pInfo, NULL, 0); 373 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*) respone.str, respone.len/sizeof(unsigned short));
373 // if(nLen <= 0) 374 FPDF_BStr_Clear(&respone);
374 // return L""; 375
375 // char* pbuff = new char[nLen]; 376 return wsRet;
376 // if(pbuff) 377 }
377 // memset(pbuff, 0, nLen); 378 return L"";
378 // else 379 }
379 // return L""; 380
380 // nLen = m_pInfo->FFI_GetAppName(m_pInfo, pbuff, nLen); 381 FPDF_BOOL FFI_PutRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, c onst FX_WCHAR* wsEncode)
381 // CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen); 382 {
382 // CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); 383 if (m_pInfo && m_pInfo->FFI_PutRequestURL)
383 // delete[] pbuff; 384 {
384 // return wsRet; 385 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
385 //} 386 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLeng th());
386 387
387 //return L""; 388 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
388 } 389 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetL ength());
389 390
390 CFX_WideString FFI_GetPlatform() 391 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
391 { 392 FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncod e.GetLength());
392 if (m_pInfo && m_pInfo->FFI_GetPlatform) 393
393 { 394 return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode);
394 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, NUL L, 0); 395 }
395 if (nRequiredLen <= 0) 396 return FALSE;
396 return L""; 397 }
397 398
398 char* pbuff = new char[nRequiredLen]; 399 FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle, const FX_WCHAR* wsFilt er, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen)
399 if (!pbuff) 400 {
400 return L""; 401 return FALSE;
401 402 }
402 memset(pbuff, 0, nRequiredLen); 403
403 int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff , nRequiredLen); 404 CFX_WideString FFI_GetLanguage()
404 if (nActualLen <= 0 || nActualLen > nRequiredLen) 405 {
405 { 406 if (m_pInfo && m_pInfo->FFI_GetLanguage)
406 delete[] pbuff; 407 {
407 return L""; 408 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NULL, 0);
408 } 409 if (nRequiredLen <= 0)
409 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen) ; 410 return L"";
410 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsi gned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigne d short)); 411
411 delete[] pbuff; 412 char* pbuff = new char[nRequiredLen];
412 return wsRet; 413 if (!pbuff)
413 } 414 return L"";
414 return L""; 415
415 } 416 memset(pbuff, 0, nRequiredLen);
416 417 int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredL en);
417 void FFI_GotoURL(FPDF_DOCUMENT document, const CFX_WideStringC& wsURL, F X_BOOL bAppend) 418 if (nActualLen <= 0 || nActualLen > nRequiredLen)
418 { 419 {
419 if (m_pInfo && m_pInfo->FFI_GotoURL) 420 delete[] pbuff;
420 { 421 return L"";
421 CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Enco de(); 422 }
422 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(ws URL.GetLength()); 423 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
423 m_pInfo->FFI_GotoURL(m_pInfo, document, pTo); 424 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*) bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short));
424 bsTo.ReleaseBuffer(); 425 delete[] pbuff;
425 } 426 return wsRet;
426 } 427 }
427 void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL) 428 return L"";
428 { 429 }
429 wsURL = CFX_WideString(); 430
430 return; 431 FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; }
431 //if (m_pInfo && m_pInfo->FFI_GetURL) 432 void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; }
432 //{ 433 CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; }
433 // FPDF_WIDESTRING url = m_pInfo->FFI_GetURL(m_pInfo, docum ent); 434 CPDFXFA_Document* GetPDFXFADocument() const { return m_pXFADoc; }
434 // CFX_WideString tmp; 435 CFX_ByteString GetAppName() const { return ""; }
435 // tmp.FromUTF16LE(url); 436 IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler; }
436 // wsURL = tmp; 437 FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; }
437 //} 438
438 } 439 CFFL_IFormFiller* GetIFormFiller(); // Creates if not present.
439 440 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present.
440 void FFI_AddDoRecord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) 441 IFXJS_Runtime* GetJSRuntime(); // Creates if not present.
441 { 442 CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present.
442 //if (m_pInfo && m_pInfo->FFI_AddDoRecord)
443 //{
444 // m_pInfo->FFI_AddDoRecord(m_pInfo, document, hWidget);
445 //}
446 }
447 void FFI_PageEvent(FPDF_PAGE page, FPDF_DWORD flag)
448 {
449 //if (m_pInfo && m_pInfo->FFI_PageEvent)
450 //{
451 // m_pInfo->FFI_PageEvent(m_pInfo, page, flag);
452 //}
453 }
454
455 void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect)
456 {
457 if (m_pInfo && m_pInfo->FFI_GetPageViewRect)
458 {
459 double left;
460 double top;
461 double right;
462 double bottom;
463 m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom);
464
465 dstRect.left = static_cast<float>(left);
466 dstRect.top = static_cast<float>(top < bottom ? bottom : top);
467 dstRect.bottom = static_cast<float>(top < bottom ? top : bottom);
468 dstRect.right = static_cast<float>(right);
469 }
470 }
471
472
473 FX_BOOL FFI_PopupMenu(FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag , CFX_PointF ptPopup, const CFX_PointF* pRectExclude)
474 {
475 if (m_pInfo && m_pInfo->FFI_PopupMenu)
476 {
477 return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, me nuFlag, ptPopup.x, ptPopup.y);
478 }
479 return FALSE;
480 }
481
482 void FFI_Alert(FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon)
483 {
484 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> app_alert)
485 {
486 m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform , Msg, Title, Type, Icon);
487 }
488 }
489 void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler, FPDF_WIDESTRING pTo, FPDF_WIDESTRING pSubject, FPDF_WIDESTRING pCC, FPDF_WIDESTRING pBcc, FPDF_WIDEST RING pMsg)
490 {
491 if(m_pInfo && m_pInfo->FFI_EmailTo)
492 {
493 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject , pCC, pBcc, pMsg);
494 }
495 }
496 void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler, int fileFlag, FPDF_W IDESTRING uploadTo)
497 {
498 if(m_pInfo && m_pInfo->FFI_UploadTo)
499 {
500 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, up loadTo);
501 }
502 }
503 FPDF_FILEHANDLER* FFI_OpenFile(int fileType, FPDF_WIDESTRING wsURL, cons t char* mode)
504 {
505 if(m_pInfo && m_pInfo->FFI_OpenFile)
506 {
507 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, m ode);
508 }
509 return NULL;
510 }
511 CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler)
512 {
513 #if 0
514 if (m_pInfo && m_pInfo->FFI_GetFilePath)
515 {
516 int nRequiredLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFi leHandler, NULL, 0);
517 if (nRequiredLen <= 0)
518 return L"";
519
520 char* pbuff = new char[nRequiredLen];
521 if (!pbuff)
522 return L"";
523
524 memset(pbuff, 0, nRequiredLen);
525 int nActualLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFile Handler, pbuff, nRequiredLen);
526 if (nActualLen <= 0 || nActualLen > nRequiredLen)
527 {
528 delete[] pbuff;
529 return L"";
530 }
531 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen) ;
532 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsi gned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigne d short));
533 delete[] pbuff;
534 return wsRet;
535 }
536 return L"";
537 #else
538 return L"";
539 #endif
540 }
541 int FFI_GetDocumentCount()
542 {
543 //if (m_pInfo && m_pInfo->FFI_GetDocumentCount)
544 //{
545 //return m_pInfo->FFI_GetDocumentCount(m_pInfo);
546 //}
547 return 0;
548 }
549
550 int FFI_GetCurDocument()
551 {
552 //if (m_pInfo && m_pInfo->FFI_GetCurDocumentIndex)
553 //{
554 // return m_pInfo->FFI_GetCurDocumentIndex(m_pInfo);
555 //}
556 return 0;
557 }
558
559 IFX_FileRead* FFI_DownloadFromURL(const FX_WCHAR* url)
560 {
561 if (m_pInfo && m_pInfo->FFI_DownloadFromURL)
562 {
563 CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Enc ode();
564 FPDF_WIDESTRING wsURL = (FPDF_WIDESTRING)bstrURL.GetBuff er(bstrURL.GetLength());
565
566 FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFr omURL(m_pInfo, wsURL);
567
568 CFPDF_FileStream* fileStream = FX_NEW CFPDF_FileStream(f ileHandler);
569 return fileStream;
570 }
571 return NULL;
572 }
573
574 CFX_WideString FFI_PostRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR * wsData, const FX_WCHAR* wsContentType, const FX_WCHAR* wsEncode, const FX_WCHA R* wsHeader)
575 {
576 if (m_pInfo && m_pInfo->FFI_PostRequestURL)
577 {
578 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Enc ode();
579 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(b sURL.GetLength());
580
581 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_E ncode();
582 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer (bsData.GetLength());
583
584 CFX_ByteString bsContentType = CFX_WideString(wsContentT ype).UTF16LE_Encode();
585 FPDF_WIDESTRING contentType = (FPDF_WIDESTRING)bsContent Type.GetBuffer(bsContentType.GetLength());
586
587 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16 LE_Encode();
588 FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBu ffer(bsEncode.GetLength());
589
590 CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16 LE_Encode();
591 FPDF_WIDESTRING header = (FPDF_WIDESTRING)bsHeader.GetBu ffer(bsHeader.GetLength());
592
593 FPDF_BSTR respone;
594 FPDF_BStr_Init(&respone);
595 FPDF_BOOL bRet = m_pInfo->FFI_PostRequestURL(m_pInfo, UR L, data, contentType, encode, header, &respone);
596
597 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsi gned short*)respone.str, respone.len/sizeof(unsigned short));
598 FPDF_BStr_Clear(&respone);
599
600 return wsRet;
601 }
602 return L"";
603 }
604
605 FPDF_BOOL FFI_PutRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, const FX_WCHAR* wsEncode)
606 {
607 if (m_pInfo && m_pInfo->FFI_PutRequestURL)
608 {
609 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Enc ode();
610 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(b sURL.GetLength());
611
612 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_E ncode();
613 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer (bsData.GetLength());
614
615 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16 LE_Encode();
616 FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBu ffer(bsEncode.GetLength());
617
618 return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, en code);
619 }
620 return FALSE;
621 }
622
623 FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle, const FX_WCH AR* wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen)
624 {
625 /*CFX_ByteString bsTitle = CFX_WideString(wsTitle).UTF16LE_Encod e();
626 FPDF_WIDESTRING title = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTit le.GetLength());
627
628 CFX_ByteString bsFilter = CFX_WideString(wsFilter).UTF16LE_Encod e();
629 FPDF_WIDESTRING filter = (FPDF_WIDESTRING)bsFilter.GetBuffer(bsF ilter.GetLength());
630
631 CFX_ByteStringArray* strPathArr = FX_NEW CFX_ByteStringArray();
632 if (m_pInfo && m_pInfo->FFI_ShowFileDialog)
633 {
634 FPDF_BOOL bRet = m_pInfo->FFI_ShowFileDialog(m_pInfo, ti tle, filter, bOpen, (FPDF_STRINGHANDLE)strPathArr);
635 if (bRet)
636 {
637 int count = strPathArr->GetSize();
638 for (int i=0; i<count; i++)
639 {
640 CFX_ByteString bsPath = *strPathArr->Get DataPtr(i);
641 CFX_WideString wsPath = CFX_WideString:: FromUTF16LE((unsigned short*)bsPath.GetBuffer(bsPath.GetLength()), bsPath.GetLen gth()/sizeof(unsigned short));
642 if (!wsPath.IsEmpty())
643 wsPathArr.Add(wsPath);
644 wsPath = L"";
645 }
646 return TRUE;
647 }
648
649 return FALSE;
650 }
651 */
652
653 return FALSE;
654 }
655 CFX_WideString FFI_GetLanguage()
656 {
657 if (m_pInfo && m_pInfo->FFI_GetLanguage)
658 {
659 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NUL L, 0);
660 if (nRequiredLen <= 0)
661 return L"";
662
663 char* pbuff = new char[nRequiredLen];
664 if (!pbuff)
665 return L"";
666
667 memset(pbuff, 0, nRequiredLen);
668 int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff , nRequiredLen);
669 if (nActualLen <= 0 || nActualLen > nRequiredLen)
670 {
671 delete[] pbuff;
672 return L"";
673 }
674 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen) ;
675 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsi gned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigne d short));
676 delete[] pbuff;
677 return wsRet;
678 }
679 return L"";
680 }
681
682 FX_BOOL IsJSInitiated();
683
684 void SetCurrentDoc(CPDFSDK_Document* pFXDoc) {m_pSDKDoc = pFXDoc;}
685 CPDFSDK_Document* GetCurrentDoc();
686 CPDFXFA_Document* GetPDFXFADocument() {return m_pDoc;}
687
688 CFX_ByteString GetAppName() {return "";}
689
690 CFFL_IFormFiller* GetIFormFiller();
691 IFX_SystemHandler* GetSysHandler() {return m_pSysHandler;}
692
693 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr();
694 IFXJS_Runtime* GetJSRuntime();
695 CPDFSDK_ActionHandler* GetActionHander();
696 FPDF_FORMFILLINFO* GetFormFillInfo() {return m_pInfo;}
697 443
698 private: 444 private:
699 » CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr; 445 CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr;
700 » CPDFSDK_ActionHandler*» m_pActionHandler; 446 CPDFSDK_ActionHandler* m_pActionHandler;
701 » IFXJS_Runtime*» m_pJSRuntime; 447 IFXJS_Runtime* m_pJSRuntime;
702 » FPDF_FORMFILLINFO*» m_pInfo; 448 FPDF_FORMFILLINFO* const m_pInfo;
703 » CPDFSDK_Document* m_pSDKDoc; 449 CPDFSDK_Document* m_pSDKDoc;
704 » CPDFXFA_Document* m_pDoc; 450 CPDFXFA_Document* const m_pXFADoc;
705 451 CFFL_IFormFiller* m_pIFormFiller;
706 » CFFL_IFormFiller* m_pIFormFiller; 452 IFX_SystemHandler* m_pSysHandler;
707 » IFX_SystemHandler* m_pSysHandler;
708
709 public:
710 » //CJS_RuntimeFactory* m_pJSRuntimeFactory;
711 }; 453 };
712 454
713
714
715 class CPDFSDK_InterForm;
716 class CPDFSDK_Document 455 class CPDFSDK_Document
717 { 456 {
718 public: 457 public:
719 » CPDFSDK_Document(CPDFXFA_Document* pDoc, CPDFDoc_Environment* pEnv); 458 CPDFSDK_Document(CPDFXFA_Document* pDoc, CPDFDoc_Environment* pEnv);
720 » ~CPDFSDK_Document(); 459 ~CPDFSDK_Document();
721 460
722 » CPDFSDK_InterForm*» » GetInterForm() ; 461 CPDFSDK_InterForm* GetInterForm() ;
723 » CPDFXFA_Document*» » GetDocument() {return m_pDoc;} 462 CPDFXFA_Document* GetDocument() {return m_pDoc;}
724 463
725 int GetPageViewCount() const { return m_pageMap.size(); } 464 int GetPageViewCount() const { return m_pageMap.size(); }
726 » CPDFSDK_PageView*» » GetPageView(CPDFXFA_Page* pPDFXFAPage, F X_BOOL ReNew = TRUE); 465 CPDFSDK_PageView* GetPageView(CPDFXFA_Page* pPDFXFAPage, FX_BOOL ReNew = TRUE);
727 » CPDFSDK_PageView*» » GetPageView(int nIndex); 466 CPDFSDK_PageView* GetPageView(int nIndex);
728 » CPDFSDK_PageView*» » GetCurrentView(); 467 CPDFSDK_PageView* GetCurrentView();
729 » void» » » » » ReMovePageView(CPDFXFA_Page* pPD FPage); 468 void ReMovePageView(CPDFXFA_Page* pPDFPage);
730 » void» » » » » UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); 469 void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_An not* pAnnot);
731 470
732 » CPDFSDK_Annot*» » » GetFocusAnnot(); 471 CPDFSDK_Annot* GetFocusAnnot();
733 472
734 » IFXJS_Runtime *»» » GetJsRuntime(); 473 IFXJS_Runtime * GetJsRuntime();
735 474
736 » FX_BOOL»» » » » SetFocusAnnot(CPDFSDK_Annot* pAn not, FX_UINT nFlag = 0); 475 FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0);
737 » FX_BOOL»» » » » KillFocusAnnot(FX_UINT nFlag = 0 ); 476 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0);
738 477
739 » FX_BOOL»» » » » ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc); 478 FX_BOOL ExtractPages(const CFX_WordArray &arrExtraPages, CPD F_Document* pDstDoc);
740 » FX_BOOL»» » » » InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); 479 FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrc Doc, const CFX_WordArray &arrSrcPages);
741 » FX_BOOL»» » » » DeletePages(int nStart, int nCou nt); 480 FX_BOOL DeletePages(int nStart, int nCount);
742 » FX_BOOL»» » » » ReplacePages(int nPage, const CP DF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); 481 FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc , const CFX_WordArray &arrSrcPages);
743 482
744 » void» » » » » OnCloseDocument(); 483 void OnCloseDocument();
745 484
746 » int» » » » » » GetPageCount() {return m _pDoc->GetPageCount();} 485 int GetPageCount() {return m_pDoc->GetPageCount();}
747 » FX_BOOL»» » » » GetPermissions(int nFlag); 486 FX_BOOL GetPermissions(int nFlag);
748 » FX_BOOL»» » » » GetChangeMark() {return m_bChang eMask;} 487 FX_BOOL GetChangeMark() {return m_bChangeMask;}
749 » void» » » » » SetChangeMark() {m_bChangeMask = TRUE;} 488 void SetChangeMark() {m_bChangeMask = TRUE;}
750 » void» » » » » ClearChangeMark() {m_bChangeMask = FALSE;} 489 void ClearChangeMark() {m_bChangeMask= FALSE;}
751 » CFX_WideString» » » GetPath() ; 490 CFX_WideString GetPath() ;
752 » CPDFXFA_Page*» » » GetPage(int nIndex); 491 CPDFXFA_Page* GetPage(int nIndex);
753 » CPDFDoc_Environment *» GetEnv() {return m_pEnv; } 492 CPDFDoc_Environment * GetEnv() {return m_pEnv; }
754 » void» » » » ProcJavascriptFun(); 493 void ProcJavascriptFun();
755 » FX_BOOL»» » » » ProcOpenAction(); 494 FX_BOOL ProcOpenAction();
756 » CPDF_OCContext*»» » GetOCContext(); 495 CPDF_OCContext* GetOCContext();
757 private: 496 private:
758 std::map<CPDFXFA_Page*, CPDFSDK_PageView*> m_pageMap; 497 std::map<CPDFXFA_Page*, CPDFSDK_PageView*> m_pageMap;
759 CPDFXFA_Document* m_pDoc; 498 CPDFXFA_Document* m_pDoc;
760 CPDFSDK_InterForm* m_pInterForm; 499 CPDFSDK_InterForm* m_pInterForm;
761 CPDFSDK_Annot* m_pFocusAnnot; 500 CPDFSDK_Annot* m_pFocusAnnot;
762 CPDFDoc_Environment* m_pEnv; 501 CPDFDoc_Environment* m_pEnv;
763 CPDF_OCContext* m_pOccontent; 502 CPDF_OCContext* m_pOccontent;
764 FX_BOOL m_bChangeMask; 503 FX_BOOL m_bChangeMask;
765 }; 504 };
766 class CPDFSDK_PageView final 505 class CPDFSDK_PageView final
767 { 506 {
768 public: 507 public:
769 » CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDFXFA_Page* page); 508 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDFXFA_Page* page);
770 » ~CPDFSDK_PageView(); 509 ~CPDFSDK_PageView();
771 » void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devic e,CPDF_RenderOptions* pOptions, FX_RECT* pClip = NULL) ; 510 void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CP DF_RenderOptions* pOptions, FX_RECT* pClip = NULL) ;
772 » CPDF_Annot*» » » » » » GetPDFAnnotAtPoi nt(FX_FLOAT pageX, FX_FLOAT pageY); 511 CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
773 » CPDFSDK_Annot*» » » » » GetFXAnnotAtPoint(FX_FLO AT pageX, FX_FLOAT pageY); 512 CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT p ageY);
774 » CPDF_Annot*» » » » » » GetPDFWidgetAtPo int(FX_FLOAT pageX, FX_FLOAT pageY); 513 CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
775 » CPDFSDK_Annot*» » » » » GetFXWidgetAtPoint(FX_FL OAT pageX, FX_FLOAT pageY); 514 CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
776 » CPDFSDK_Annot*» » » » » GetFocusAnnot() ; 515 CPDFSDK_Annot* GetFocusAnnot() ;
777 » void» » » » » » » SetFocusAnnot(CP DFSDK_Annot* pSDKAnnot,FX_UINT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, n Flag);} 516 void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot,FX_UI NT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);}
778 » FX_BOOL»» » » » » » KillFocusAnnot(F X_UINT nFlag = 0) {return m_pSDKDoc->KillFocusAnnot(nFlag);} 517 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {return m_ pSDKDoc->KillFocusAnnot(nFlag);}
779 » FX_BOOL»» » » » » » Annot_HasAppeara nce(CPDF_Annot* pAnnot); 518 FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot);
780 519
781 » CPDFSDK_Annot*» » » » » AddAnnot(CPDF_Dictionary * pDict); 520 CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict);
782 » CPDFSDK_Annot*» » » » » AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictionary * pDict); 521 CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType,CPDF_Dicti onary * pDict);
783 » CPDFSDK_Annot*» » » » » AddAnnot(CPDF_Annot * pP DFAnnot); 522 CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot);
784 » CPDFSDK_Annot*» » » » » AddAnnot(IXFA_Widget* pP DFAnnot); 523 CPDFSDK_Annot* AddAnnot(IXFA_Widget* pPDFAnnot);
785 » FX_BOOL»» » » » » » DeleteAnnot(CPDF SDK_Annot* pAnnot); 524 FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot);
786 525
787 » int» » » » » » » » CountAnn ots(); 526 int CountAnnots();
788 » CPDFSDK_Annot*» » » » » GetAnnot(int nIndex); 527 CPDFSDK_Annot* GetAnnot(int nIndex);
789 » CPDFSDK_Annot*» » » » GetAnnotByDict(CPDF_Dictiona ry * pDict); 528 CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict);
790 » CPDFSDK_Annot*» » » » » GetAnnotByXFAWidget(IXFA _Widget* hWidget); 529 CPDFSDK_Annot* GetAnnotByXFAWidget(IXFA_Widget* hWidget);
791 » CPDFXFA_Page*» » » » » GetPDFXFAPage(){return m _page;} 530 CPDFXFA_Page* GetPDFXFAPage(){return m_page;}
792 » CPDF_Page*» » » » » » GetPDFPage(); 531 CPDF_Page* GetPDFPage();
793 » CPDF_Document*» » » » » GetPDFDocument(); 532 CPDF_Document* GetPDFDocument();
794 » CPDFSDK_Document*» » » » GetSDKDocument() {return m_pSDKDoc;} 533 CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;}
795 » FX_BOOL»» » » » OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag); 534 FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFla g);
796 » FX_BOOL»» » » » OnLButtonUp(const CPDF_Point & p oint, FX_UINT nFlag); 535 FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag) ;
797 » FX_BOOL»» » » » OnRButtonDown(const CPDF_Point & point, FX_UINT nFlag); 536 FX_BOOL OnRButtonDown(const CPDF_Point & point, FX_UINT nFla g);
798 » FX_BOOL»» » » » OnRButtonUp(const CPDF_Point & p oint, FX_UINT nFlag); 537 FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_UINT nFlag) ;
799 » FX_BOOL»» » » » OnChar(int nChar, FX_UINT nFlag) ; 538 FX_BOOL OnChar(int nChar, FX_UINT nFlag);
800 » FX_BOOL»» » » » OnKeyDown(int nKeyCode, int nFla g); 539 FX_BOOL OnKeyDown(int nKeyCode, int nFlag);
801 » FX_BOOL»» » » » OnKeyUp(int nKeyCode, int nFlag) ; 540 FX_BOOL OnKeyUp(int nKeyCode, int nFlag);
802 541
803 » FX_BOOL»» » » » OnMouseMove(const CPDF_Point & p oint, int nFlag); 542 FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag);
804 » FX_BOOL»» » » » OnMouseWheel(double deltaX, doub le deltaY,const CPDF_Point& point, int nFlag); 543 FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF _Point& point, int nFlag);
805 » FX_BOOL»» » » » IsValidAnnot(void* p); 544 FX_BOOL IsValidAnnot(void* p);
806 » void» » » » » GetCurrentMatrix(CPDF_Matrix& ma trix) {matrix = m_curMatrix;} 545 void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_cu rMatrix;}
807 » void» » » » » UpdateRects(CFX_RectArray& rects ); 546 void UpdateRects(CFX_RectArray& rects);
808 » void» » » » » » » UpdateView(CPDFS DK_Annot* pAnnot); 547 void UpdateView(CPDFSDK_Annot* pAnnot);
809 » CFX_PtrArray*» » » » » GetAnnotList(){ return & m_fxAnnotArray; } 548 CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; }
810 549
811 » int» » » » » » GetPageIndex(); 550 int GetPageIndex();
812 » void» » » » » » » LoadFXAnnots(); 551 void LoadFXAnnots();
813 » void SetValid(FX_BOOL bValid) {m_bValid = bValid;} 552 void SetValid(FX_BOOL bValid) {m_bValid = bValid;}
814 FX_BOOL IsValid() {return m_bValid;} 553 FX_BOOL IsValid() {return m_bValid;}
815 void SetLock(FX_BOOL bLocked) {m_bLocked= bLocked;} 554 void SetLock(FX_BOOL bLocked) {m_bLocked= bLocked;}
816 FX_BOOL IsLocked() {return m_bLocked;} 555 FX_BOOL IsLocked() {return m_bLocked;}
817 private: 556 private:
818 » void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_W idget* pWidget); 557 void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widge t* pWidget);
819 » CPDF_Matrix m_curMatrix; 558 CPDF_Matrix m_curMatrix;
820 » CPDFXFA_Page* m_page; 559 CPDFXFA_Page* m_page;
821 » CPDF_AnnotList* m_pAnnotList; 560 CPDF_AnnotList* m_pAnnotList;
822 » //CPDFSDK_Annot* m_pFocusAnnot; 561 //CPDFSDK_Annot* m_pFocusAnnot;
823 » CFX_PtrArray m_fxAnnotArray; 562 CFX_PtrArray m_fxAnnotArray;
824 » CPDFSDK_Document* m_pSDKDoc; 563 CPDFSDK_Document* m_pSDKDoc;
825 » CPDFSDK_Annot* m_CaptureWidget; 564 CPDFSDK_Annot* m_CaptureWidget;
826 » FX_BOOL m_bEnterWidget; 565 FX_BOOL m_bEnterWidget;
827 » FX_BOOL m_bExitWidget; 566 FX_BOOL m_bExitWidget;
828 » FX_BOOL m_bOnWidget; 567 FX_BOOL m_bOnWidget;
829 » FX_BOOL m_bValid; 568 FX_BOOL m_bValid;
830 FX_BOOL m_bLocked; 569 FX_BOOL m_bLocked;
831 }; 570 };
832 571
833 572
834 template<class TYPE> 573 template<class TYPE>
835 class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE> 574 class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE>
836 { 575 {
837 public: 576 public:
838 » CGW_ArrayTemplate(){} 577 CGW_ArrayTemplate(){}
839 » virtual ~CGW_ArrayTemplate(){} 578 virtual ~CGW_ArrayTemplate(){}
840 579
841 » typedef int (*LP_COMPARE)(TYPE p1, TYPE p2); 580 typedef int (*LP_COMPARE)(TYPE p1, TYPE p2);
842 581
843 » void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) 582 void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE)
844 » { 583 {
845 » » int nSize = this->GetSize(); 584 int nSize = this->GetSize();
846 » » QuickSort(0, nSize -1, bAscent, pCompare); 585 QuickSort(0, nSize -1, bAscent, pCompare);
847 » } 586 }
848 587
849 private: 588 private:
850 » void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_ COMPARE pCompare) 589 void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_COMP ARE pCompare)
851 » { 590 {
852 » » if (nStartPos >= nStopPos) return; 591 if (nStartPos >= nStopPos) return;
853 592
854 » » if ((nStopPos - nStartPos) == 1) 593 if ((nStopPos - nStartPos) == 1)
855 » » { 594 {
856 » » » TYPE Value1 = this->GetAt(nStartPos); 595 TYPE Value1 = this->GetAt(nStartPos);
857 » » » TYPE Value2 = this->GetAt(nStopPos); 596 TYPE Value2 = this->GetAt(nStopPos);
858 597
859 » » » int iGreate = (*pCompare)(Value1, Value2); 598 int iGreate = (*pCompare)(Value1, Value2);
860 » » » if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0 )) 599 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0))
861 » » » { 600 {
862 » » » » this->SetAt(nStartPos, Value2); 601 this->SetAt(nStartPos, Value2);
863 » » » » this->SetAt(nStopPos, Value1); 602 this->SetAt(nStopPos, Value1);
864 » » » } 603 }
865 » » » return; 604 return;
866 » » } 605 }
867 606
868 » » FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2; 607 FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2;
869 » » FX_UINT i = nStartPos; 608 FX_UINT i = nStartPos;
870 609
871 » » TYPE Value = this->GetAt(m); 610 TYPE Value = this->GetAt(m);
872 611
873 » » while (i < m) 612 while (i < m)
874 » » { 613 {
875 » » » TYPE temp = this->GetAt(i); 614 TYPE temp = this->GetAt(i);
876 615
877 » » » int iGreate = (*pCompare)(temp, Value); 616 int iGreate = (*pCompare)(temp, Value);
878 » » » if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0 )) 617 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0))
879 » » » { 618 {
880 » » » » this->InsertAt(m+1, temp); 619 this->InsertAt(m+1, temp);
881 » » » » this->RemoveAt(i); 620 this->RemoveAt(i);
882 » » » » m--; 621 m--;
883 » » » } 622 }
884 » » » else 623 else
885 » » » { 624 {
886 » » » » i++; 625 i++;
887 » » » } 626 }
888 » » } 627 }
889 628
890 » » FX_UINT j = nStopPos; 629 FX_UINT j = nStopPos;
891 630
892 » » while (j > m) 631 while (j > m)
893 » » { 632 {
894 » » » TYPE temp = this->GetAt(j); 633 TYPE temp = this->GetAt(j);
895 634
896 » » » int iGreate = (*pCompare)(temp, Value); 635 int iGreate = (*pCompare)(temp, Value);
897 » » » if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0 )) 636 if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0))
898 » » » { 637 {
899 » » » » this->RemoveAt(j); 638 this->RemoveAt(j);
900 » » » » this->InsertAt(m, temp); 639 this->InsertAt(m, temp);
901 » » » » m++; 640 m++;
902 » » » } 641 }
903 » » » else 642 else
904 » » » { 643 {
905 » » » » j--; 644 j--;
906 » » » } 645 }
907 » » } 646 }
908 647
909 » » if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare); 648 if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare);
910 » » if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare); 649 if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare);
911 » } 650 }
912 }; 651 };
913 652
914 #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ 653 #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/formfiller/FFL_FormFiller.h ('k') | fpdfsdk/src/formfiller/FFL_FormFiller.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698