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

Side by Side Diff: fpdfsdk/src/fsdk_mgr.cpp

Issue 1235393002: Tidy up CPDFDOC_Environment. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits. 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/src/fsdk_annothandler.cpp ('k') | fpdfsdk/src/javascript/JS_Object.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 #include "../../public/fpdf_ext.h" 7 #include "../../public/fpdf_ext.h"
8 #include "../../third_party/base/nonstd_unique_ptr.h" 8 #include "../../third_party/base/nonstd_unique_ptr.h"
9 #include "../include/fsdk_define.h" 9 #include "../include/fsdk_define.h"
10 #include "../include/fsdk_mgr.h" 10 #include "../include/fsdk_mgr.h"
11 #include "../include/formfiller/FFL_FormFiller.h" 11 #include "../include/formfiller/FFL_FormFiller.h"
12 #include "../include/javascript/IJavaScript.h" 12 #include "../include/javascript/IJavaScript.h"
13 13
14 #if _FX_OS_ == _FX_ANDROID_ 14 #if _FX_OS_ == _FX_ANDROID_
15 #include "time.h" 15 #include "time.h"
16 #else 16 #else
17 #include <ctime> 17 #include <ctime>
18 #endif 18 #endif
19 19
20 //extern CPDFDoc_Environment* g_pFormFillApp; 20 //extern CPDFDoc_Environment* g_pFormFillApp;
21 class CFX_SystemHandler:public IFX_SystemHandler 21 class CFX_SystemHandler:public IFX_SystemHandler
22 { 22 {
23 public: 23 public:
24 » CFX_SystemHandler(CPDFDoc_Environment* pEnv):m_pEnv(pEnv),m_nCharSet(-1) {} 24 CFX_SystemHandler(CPDFDoc_Environment* pEnv):m_pEnv(pEnv),m_nCharSet(-1) {}
25 public: 25 public:
26 » virtual void» » » » InvalidateRect(FX_HWND hWnd, FX_ RECT rect) ; 26 virtual void InvalidateRect(FX_HWND hWnd, FX_RECT rect) ;
27 » virtual void» » » » OutputSelectedRect(void* pFormFi ller, CPDF_Rect& rect); 27 virtual void OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect);
28 28
29 » virtual FX_BOOL»» » » IsSelectionImplemented(); 29 virtual FX_BOOL IsSelectionImplemented();
30 30
31 » virtual CFX_WideString» » GetClipboardText(FX_HWND hWnd){return L" ";} 31 virtual CFX_WideString GetClipboardText(FX_HWND hWnd){return L"";}
32 » virtual FX_BOOL»» » » SetClipboardText(FX_HWND hWnd, C FX_WideString string) {return FALSE;} 32 virtual FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString st ring) {return FALSE;}
33 33
34 » virtual void» » » » ClientToScreen(FX_HWND hWnd, int 32_t& x, int32_t& y) {} 34 virtual void ClientToScreen(FX_HWND hWnd, int32_t& x, int32_t & y) {}
35 » virtual void» » » » ScreenToClient(FX_HWND hWnd, int 32_t& x, int32_t& y) {} 35 virtual void ScreenToClient(FX_HWND hWnd, int32_t& x, int32_t & y) {}
36 36
37 » /*cursor style 37 /*cursor style
38 » FXCT_ARROW 38 FXCT_ARROW
39 » FXCT_NESW 39 FXCT_NESW
40 » FXCT_NWSE 40 FXCT_NWSE
41 » FXCT_VBEAM 41 FXCT_VBEAM
42 » FXCT_HBEAM 42 FXCT_HBEAM
43 » FXCT_HAND 43 FXCT_HAND
44 » */ 44 */
45 » virtual void» » » » SetCursor(int32_t nCursorType); 45 virtual void SetCursor(int32_t nCursorType);
46 46
47 » virtual FX_HMENU» » » CreatePopupMenu() {return NULL;} 47 virtual FX_HMENU CreatePopupMenu() {return NULL;}
48 » virtual FX_BOOL»» » » AppendMenuItem(FX_HMENU hMenu, i nt32_t nIDNewItem, CFX_WideString string) {return FALSE;} 48 virtual FX_BOOL AppendMenuItem(FX_HMENU hMenu, int32_t nIDNewIte m, CFX_WideString string) {return FALSE;}
49 » virtual FX_BOOL»» » » EnableMenuItem(FX_HMENU hMenu, i nt32_t nIDItem, FX_BOOL bEnabled) {return FALSE;} 49 virtual FX_BOOL EnableMenuItem(FX_HMENU hMenu, int32_t nIDItem, FX_BOOL bEnabled) {return FALSE;}
50 » virtual int32_t»» » TrackPopupMenu(FX_HMENU hMenu, int32_t x , int32_t y, FX_HWND hParent) {return -1;} 50 virtual int32_t TrackPopupMenu(FX_HMENU hMenu, int32_t x, int32_t y, FX_HWND hParent) {return -1;}
51 » virtual void» » » » DestroyMenu(FX_HMENU hMenu) {} 51 virtual void DestroyMenu(FX_HMENU hMenu) {}
52 52
53 » virtual CFX_ByteString» » GetNativeTrueTypeFont(int32_t nCharset); 53 virtual CFX_ByteString GetNativeTrueTypeFont(int32_t nCharset);
54 » virtual FX_BOOL»» » » FindNativeTrueTypeFont(int32_t n Charset, CFX_ByteString sFontFaceName); 54 virtual FX_BOOL FindNativeTrueTypeFont(int32_t nCharset, CFX_Byt eString sFontFaceName);
55 » virtual CPDF_Font*» » » AddNativeTrueTypeFontToPDF(CPDF_ Document* pDoc, CFX_ByteString sFontFaceName, uint8_t nCharset); 55 virtual CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CFX_ByteString sFontFaceName, uint8_t nCharset);
56 56
57 » virtual int32_t»» » SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) ; 57 virtual int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) ;
58 » virtual void» » » » KillTimer(int32_t nID) ; 58 virtual void KillTimer(int32_t nID) ;
59 59
60 60
61 » virtual FX_BOOL»» » » IsSHIFTKeyDown(FX_DWORD nFlag) { return m_pEnv->FFI_IsSHIFTKeyDown(nFlag);} 61 virtual FX_BOOL IsSHIFTKeyDown(FX_DWORD nFlag) {return m_pEnv->F FI_IsSHIFTKeyDown(nFlag);}
62 » virtual FX_BOOL»» » » IsCTRLKeyDown(FX_DWORD nFlag) {r eturn m_pEnv->FFI_IsCTRLKeyDown(nFlag);} 62 virtual FX_BOOL IsCTRLKeyDown(FX_DWORD nFlag) {return m_pEnv->FF I_IsCTRLKeyDown(nFlag);}
63 » virtual FX_BOOL»» » » IsALTKeyDown(FX_DWORD nFlag) {re turn m_pEnv->FFI_IsALTKeyDown(nFlag);} 63 virtual FX_BOOL IsALTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI _IsALTKeyDown(nFlag);}
64 » virtual FX_BOOL»» » » IsINSERTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_IsINSERTKeyDown(nFlag);} 64 virtual FX_BOOL IsINSERTKeyDown(FX_DWORD nFlag) {return m_pEnv-> FFI_IsINSERTKeyDown(nFlag);}
65 65
66 » virtual»FX_SYSTEMTIME» » GetLocalTime(); 66 virtual FX_SYSTEMTIME GetLocalTime();
67 67
68 » virtual int32_t»» » GetCharSet() {return m_nCharSet;} 68 virtual int32_t GetCharSet() {return m_nCharSet;}
69 » virtual void » » » » SetCharSet(int32_t nCharSet) {m_ nCharSet = nCharSet;} 69 virtual void SetCharSet(int32_t nCharSet) {m_nCharSet = nChar Set;}
70 private: 70 private:
71 » CPDFDoc_Environment* m_pEnv; 71 CPDFDoc_Environment* m_pEnv;
72 » int» » m_nCharSet; 72 int m_nCharSet;
73 }; 73 };
74 74
75 void CFX_SystemHandler::SetCursor(int32_t nCursorType) 75 void CFX_SystemHandler::SetCursor(int32_t nCursorType)
76 { 76 {
77 77
78 » m_pEnv->FFI_SetCursor(nCursorType); 78 m_pEnv->FFI_SetCursor(nCursorType);
79 } 79 }
80 80
81 void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect) 81 void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect)
82 { 82 {
83 » //g_pFormFillApp->FFI_Invalidate(); 83 //g_pFormFillApp->FFI_Invalidate();
84 » CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd; 84 CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd;
85 » CPDF_Page* pPage = NULL; 85 CPDF_Page* pPage = NULL;
86 » CPDFSDK_PageView* pPageView = NULL; 86 CPDFSDK_PageView* pPageView = NULL;
87 » pPageView = pSDKAnnot->GetPageView(); 87 pPageView = pSDKAnnot->GetPageView();
88 » pPage = pSDKAnnot->GetPDFPage(); 88 pPage = pSDKAnnot->GetPDFPage();
89 » if(!pPage || !pPageView) 89 if(!pPage || !pPageView)
90 » » return; 90 return;
91 » CPDF_Matrix page2device; 91 CPDF_Matrix page2device;
92 » pPageView->GetCurrentMatrix(page2device); 92 pPageView->GetCurrentMatrix(page2device);
93 » CPDF_Matrix device2page; 93 CPDF_Matrix device2page;
94 » device2page.SetReverse(page2device); 94 device2page.SetReverse(page2device);
95 » FX_FLOAT left, top, right,bottom; 95 FX_FLOAT left, top, right,bottom;
96 » device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top ); 96 device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top);
97 » device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right , bottom); 97 device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right, bo ttom);
98 // » m_pEnv->FFI_DeviceToPage(pPage, rect.left, rect.top, (double*)&left, (do uble*)&top); 98 // m_pEnv->FFI_DeviceToPage(pPage, rect.left, rect.top, (double*)&left, (double *)&top);
99 // » m_pEnv->FFI_DeviceToPage(pPage, rect.right, rect.bottom, (double*)&right , (double*)&bottom); 99 // m_pEnv->FFI_DeviceToPage(pPage, rect.right, rect.bottom, (double*)&right, (d ouble*)&bottom);
100 » CPDF_Rect rcPDF(left, bottom, right, top); 100 CPDF_Rect rcPDF(left, bottom, right, top);
101 » rcPDF.Normalize(); 101 rcPDF.Normalize();
102 102
103 » m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, rcPDF. bottom); 103 m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, rcPDF.bott om);
104 } 104 }
105 void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect) 105 void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect)
106 { 106 {
107 » CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller; 107 CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller;
108 » if(pFFL) 108 if(pFFL)
109 » { 109 {
110 » » CPDF_Point leftbottom = CPDF_Point(rect.left, rect.bottom); 110 CPDF_Point leftbottom = CPDF_Point(rect.left, rect.bottom);
111 » » CPDF_Point righttop = CPDF_Point(rect.right, rect.top); 111 CPDF_Point righttop = CPDF_Point(rect.right, rect.top);
112 » » CPDF_Point ptA = pFFL->PWLtoFFL(leftbottom); 112 CPDF_Point ptA = pFFL->PWLtoFFL(leftbottom);
113 » » CPDF_Point ptB = pFFL->PWLtoFFL(righttop); 113 CPDF_Point ptB = pFFL->PWLtoFFL(righttop);
114 114
115 115
116 » » CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot(); 116 CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot();
117 » » ASSERT(pAnnot); 117 ASSERT(pAnnot);
118 » » CPDF_Page* pPage = pAnnot->GetPDFPage(); 118 CPDF_Page* pPage = pAnnot->GetPDFPage();
119 » » ASSERT(pPage); 119 ASSERT(pPage);
120 » » m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y ); 120 m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y);
121 » } 121 }
122 122
123 } 123 }
124 124
125 FX_BOOL CFX_SystemHandler::IsSelectionImplemented() 125 FX_BOOL CFX_SystemHandler::IsSelectionImplemented()
126 { 126 {
127 » if(m_pEnv) 127 if(m_pEnv)
128 » { 128 {
129 » » FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo(); 129 FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo();
130 » » if(pInfo && pInfo->FFI_OutputSelectedRect) 130 if(pInfo && pInfo->FFI_OutputSelectedRect)
131 » » » return TRUE; 131 return TRUE;
132 » } 132 }
133 » return FALSE; 133 return FALSE;
134 } 134 }
135 135
136 CFX_ByteString CFX_SystemHandler::GetNativeTrueTypeFont(int32_t nCharset) 136 CFX_ByteString CFX_SystemHandler::GetNativeTrueTypeFont(int32_t nCharset)
137 { 137 {
138 » return ""; 138 return "";
139 } 139 }
140 140
141 FX_BOOL»CFX_SystemHandler::FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteStri ng sFontFaceName) 141 FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteStri ng sFontFaceName)
142 { 142 {
143 » CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); 143 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
144 //» FXFT_Face nFace = pFontMgr->FindSubstFont(sFontFaceName,TRUE,0,0,0,0,NUL L); 144 // FXFT_Face nFace = pFontMgr->FindSubstFont(sFontFaceName,TRUE,0,0,0,0,NULL);
145 //» FXFT_Face nFace = pFontMgr->m_pBuiltinMapper->FindSubstFont(sFontFaceNa me,TRUE,0,0,0,0,NULL); 145 // FXFT_Face nFace = pFontMgr->m_pBuiltinMapper->FindSubstFont(sFontFaceName,T RUE,0,0,0,0,NULL);
146 146
147 » if(pFontMgr) 147 if(pFontMgr)
148 » { 148 {
149 » » CFX_FontMapper*»pFontMapper = pFontMgr->m_pBuiltinMapper; 149 CFX_FontMapper* pFontMapper = pFontMgr->m_pBuiltinMapper;
150 » » if(pFontMapper) 150 if(pFontMapper)
151 » » { 151 {
152 » » » int nSize = pFontMapper->m_InstalledTTFonts.GetSize(); 152 int nSize = pFontMapper->m_InstalledTTFonts.GetSize();
153 » » » if(nSize ==0) 153 if(nSize ==0)
154 » » » { 154 {
155 » » » » pFontMapper->LoadInstalledFonts(); 155 pFontMapper->LoadInstalledFonts();
156 » » » » nSize = pFontMapper->m_InstalledTTFonts.GetSize( ); 156 nSize = pFontMapper->m_InstalledTTFonts.GetSize();
157 » » » } 157 }
158 158
159 » » » for(int i=0; i<nSize; i++) 159 for(int i=0; i<nSize; i++)
160 » » » { 160 {
161 » » » » if(pFontMapper->m_InstalledTTFonts[i].Compare(sF ontFaceName)) 161 if(pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName))
162 » » » » » return TRUE; 162 return TRUE;
163 » » » } 163 }
164 » » } 164 }
165 165
166 » } 166 }
167 167
168 » return FALSE; 168 return FALSE;
169 // » pFontMgr->m_FaceMap.Lookup(sFontFaceName,pFont); 169 // pFontMgr->m_FaceMap.Lookup(sFontFaceName,pFont);
170 // » return (pFont!=NULL); 170 // return (pFont!=NULL);
171 } 171 }
172 172
173 static int CharSet2CP(int charset) 173 static int CharSet2CP(int charset)
174 { 174 {
175 » if(charset == 128) 175 if(charset == 128)
176 » » return 932; 176 return 932;
177 » else if(charset == 134) 177 else if(charset == 134)
178 » » return 936; 178 return 936;
179 » else if(charset == 129) 179 else if(charset == 129)
180 » » return 949; 180 return 949;
181 » else if(charset == 136) 181 else if(charset == 136)
182 » » return 950; 182 return 950;
183 » return 0; 183 return 0;
184 } 184 }
185 CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CF X_ByteString sFontFaceName, 185 CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CF X_ByteString sFontFaceName,
186 » » » » » » » » » » » » » » uint8_t nCharset) 186 uint8_t nCharset)
187 { 187 {
188 » if(pDoc) 188 if(pDoc)
189 » { 189 {
190 » » CFX_Font* pFXFont = new CFX_Font(); 190 CFX_Font* pFXFont = new CFX_Font();
191 » » pFXFont->LoadSubst(sFontFaceName,TRUE,0,0,0,CharSet2CP(nCharset) ,FALSE); 191 pFXFont->LoadSubst(sFontFaceName,TRUE,0,0,0,CharSet2CP(nCharset),FALSE);
192 » » CPDF_Font* pFont = pDoc->AddFont(pFXFont,nCharset,FALSE); 192 CPDF_Font* pFont = pDoc->AddFont(pFXFont,nCharset,FALSE);
193 » » delete pFXFont; 193 delete pFXFont;
194 » » return pFont; 194 return pFont;
195 » } 195 }
196 196
197 » return NULL; 197 return NULL;
198 } 198 }
199 199
200 200
201 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) 201 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, TimerCallback lpTimerFunc)
202 { 202 {
203 » return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc); 203 return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc);
204 } 204 }
205 void CFX_SystemHandler::KillTimer(int32_t nID) 205 void CFX_SystemHandler::KillTimer(int32_t nID)
206 { 206 {
207 » m_pEnv->FFI_KillTimer(nID); 207 m_pEnv->FFI_KillTimer(nID);
208 } 208 }
209 209
210 FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() 210 FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime()
211 { 211 {
212 » return m_pEnv->FFI_GetLocalTime(); 212 return m_pEnv->FFI_GetLocalTime();
213 } 213 }
214 214
215 215
216 CJS_RuntimeFactory* GetJSRuntimeFactory() 216 CJS_RuntimeFactory* GetJSRuntimeFactory()
217 { 217 {
218 » static CJS_RuntimeFactory s_JSRuntimeFactory; 218 static CJS_RuntimeFactory s_JSRuntimeFactory;
219 » return &s_JSRuntimeFactory; 219 return &s_JSRuntimeFactory;
220 } 220 }
221 221
222 CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc) : 222 CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo) :
223 » m_pAnnotHandlerMgr(NULL), 223 m_pAnnotHandlerMgr(NULL),
224 » m_pActionHandler(NULL), 224 m_pActionHandler(NULL),
225 » m_pJSRuntime(NULL), 225 m_pJSRuntime(NULL),
226 » m_pInfo(NULL), 226 m_pInfo(pFFinfo),
227 » m_pSDKDoc(NULL), 227 m_pSDKDoc(NULL),
228 » m_pPDFDoc(pDoc), 228 m_pPDFDoc(pDoc),
229 » m_pIFormFiller(NULL) 229 m_pIFormFiller(NULL)
230 { 230 {
231 231 m_pSysHandler = new CFX_SystemHandler(this);
232 » m_pSysHandler = NULL; 232 m_pJSRuntimeFactory = GetJSRuntimeFactory();
233 » m_pSysHandler = new CFX_SystemHandler(this); 233 m_pJSRuntimeFactory->AddRef();
234
235
236 » m_pJSRuntimeFactory = NULL;
237 » m_pJSRuntimeFactory = GetJSRuntimeFactory();
238 » m_pJSRuntimeFactory->AddRef();
239 } 234 }
240 235
241 CPDFDoc_Environment::~CPDFDoc_Environment() 236 CPDFDoc_Environment::~CPDFDoc_Environment()
242 { 237 {
243 delete m_pIFormFiller; 238 delete m_pIFormFiller;
244 m_pIFormFiller = NULL; 239 m_pIFormFiller = NULL;
245 if (m_pJSRuntime && m_pJSRuntimeFactory) 240 if (m_pJSRuntime && m_pJSRuntimeFactory)
246 m_pJSRuntimeFactory->DeleteJSRuntime(m_pJSRuntime); 241 m_pJSRuntimeFactory->DeleteJSRuntime(m_pJSRuntime);
247 m_pJSRuntimeFactory->Release(); 242 m_pJSRuntimeFactory->Release();
248 243
249 delete m_pSysHandler; 244 delete m_pSysHandler;
250 m_pSysHandler = NULL; 245 m_pSysHandler = NULL;
251 246
252 delete m_pAnnotHandlerMgr; 247 delete m_pAnnotHandlerMgr;
253 m_pAnnotHandlerMgr = NULL; 248 m_pAnnotHandlerMgr = NULL;
254 delete m_pActionHandler; 249 delete m_pActionHandler;
255 m_pActionHandler = NULL; 250 m_pActionHandler = NULL;
256 } 251 }
257 252
253 int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon)
254 {
255 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert)
256 {
257 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
258 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
259 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength( ));
260 FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetL ength());
261 int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg , pTitle, Type, Icon);
262 bsMsg.ReleaseBuffer();
263 bsTitle.ReleaseBuffer();
264 return ret;
265 }
266 return -1;
267 }
268
269 int CPDFDoc_Environment::JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR * Title, const FX_WCHAR* Default,
270 const FX_WCHAR* cLabel, FPDF_BOOL bPassw ord, void* response, int length)
271 {
272 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_respons e)
273 {
274 CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode();
275 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
276 CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode();
277 CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode();
278 FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion.GetBuffer(bsQues tion.GetLength());
279 FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetL ength());
280 FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.GetBuffer(bsDefaul t.GetLength());
281 FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuffer(bsLabel.GetL ength());
282 int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo->m_pJsPlatform, p Question, pTitle,
283 pDefault, pLabel, bPasswo rd, response, length);
284 bsQuestion.ReleaseBuffer();
285 bsTitle.ReleaseBuffer();
286 bsDefault.ReleaseBuffer();
287 bsLabel.ReleaseBuffer();
288 return ret;
289 }
290 return -1;
291 }
292
258 CFX_WideString CPDFDoc_Environment::JS_fieldBrowse() 293 CFX_WideString CPDFDoc_Environment::JS_fieldBrowse()
259 { 294 {
260 if (!m_pInfo || 295 if (!m_pInfo ||
261 !m_pInfo->m_pJsPlatform || 296 !m_pInfo->m_pJsPlatform ||
262 !m_pInfo->m_pJsPlatform->Field_browse) { 297 !m_pInfo->m_pJsPlatform->Field_browse) {
263 return L""; 298 return L"";
264 } 299 }
265 300
266 const int nRequiredLen = m_pInfo->m_pJsPlatform->Field_browse( 301 const int nRequiredLen = m_pInfo->m_pJsPlatform->Field_browse(
267 m_pInfo->m_pJsPlatform, nullptr, 0); 302 m_pInfo->m_pJsPlatform, nullptr, 0);
(...skipping 30 matching lines...) Expand all
298 const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( 333 const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(
299 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); 334 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen);
300 if (nActualLen <= 0 || nActualLen > nRequiredLen) 335 if (nActualLen <= 0 || nActualLen > nRequiredLen)
301 return L""; 336 return L"";
302 337
303 CFX_ByteString bsRet = CFX_ByteString(pBuff.get(), nActualLen); 338 CFX_ByteString bsRet = CFX_ByteString(pBuff.get(), nActualLen);
304 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); 339 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet);
305 return wsRet; 340 return wsRet;
306 } 341 }
307 342
343 void CPDFDoc_Environment::JS_docSubmitForm(void* formData, int length, const FX_ WCHAR* URL)
344 {
345 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_submitF orm)
346 {
347 CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode();
348 FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestination.GetBuffer( bsDestination.GetLength());
349 m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, length, pDestination);
350 bsDestination.ReleaseBuffer();
351 }
352 }
353
354 void CPDFDoc_Environment::JS_docmailForm(void* mailData, int length, FPDF_BOOL b UI,
355 const FX_WCHAR* To, const FX_WCHAR* Sub ject,
356 const FX_WCHAR* CC, const FX_WCHAR* BCC ,
357 const FX_WCHAR* Msg)
358 {
359 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_mail)
360 {
361 CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode();
362 CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_Encode();
363 CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode();
364 CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode();
365 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
366 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength());
367 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength());
368 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength( ));
369 FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubjec t.GetLength());
370 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength( ));
371 m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, lengt h, bUI, pTo, pSubject,
372 pCC, pBcc, pMsg);
373 bsTo.ReleaseBuffer();
374 bsCC.ReleaseBuffer();
375 bsBcc.ReleaseBuffer();
376 bsSubject.ReleaseBuffer();
377 bsMsg.ReleaseBuffer();
378 }
379 }
380
308 IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime() 381 IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime()
309 { 382 {
310 » if(!IsJSInitiated()) 383 if (!IsJSInitiated())
311 » » return NULL; 384 return NULL;
312 » assert(m_pJSRuntimeFactory); 385 if (!m_pJSRuntime)
313 » if(!m_pJSRuntime) 386 m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
314 » » m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this); 387 return m_pJSRuntime;
315 » return m_pJSRuntime;
316 } 388 }
317 389
318 CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr() 390 CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr()
319 { 391 {
320 » if(!m_pAnnotHandlerMgr) 392 if (!m_pAnnotHandlerMgr)
321 » » m_pAnnotHandlerMgr = new CPDFSDK_AnnotHandlerMgr(this); 393 m_pAnnotHandlerMgr = new CPDFSDK_AnnotHandlerMgr(this);
322 » return m_pAnnotHandlerMgr; 394 return m_pAnnotHandlerMgr;
323 } 395 }
324 396
325 CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander() 397 CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander()
326 { 398 {
327 » if(!m_pActionHandler) 399 if (!m_pActionHandler)
328 » » m_pActionHandler = new CPDFSDK_ActionHandler(this); 400 m_pActionHandler = new CPDFSDK_ActionHandler(this);
329 » return m_pActionHandler; 401 return m_pActionHandler;
330 }
331
332 int CPDFDoc_Environment::RegAppHandle(FPDF_FORMFILLINFO* pFFinfo)
333 {
334 » m_pInfo = pFFinfo;
335 » return TRUE;
336 }
337
338 CPDFSDK_Document* CPDFDoc_Environment::GetCurrentDoc()
339 {
340 » return m_pSDKDoc;
341 } 402 }
342 403
343 CFFL_IFormFiller* CPDFDoc_Environment::GetIFormFiller() 404 CFFL_IFormFiller* CPDFDoc_Environment::GetIFormFiller()
344 { 405 {
345 » if(!m_pIFormFiller) 406 if (!m_pIFormFiller)
346 » » m_pIFormFiller = new CFFL_IFormFiller(this); 407 m_pIFormFiller = new CFFL_IFormFiller(this);
347 » return m_pIFormFiller; 408 return m_pIFormFiller;
348 } 409 }
349 410
350 FX_BOOL»CPDFDoc_Environment::IsJSInitiated() 411 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv ) :
412 m_pDoc(pDoc),
413 m_pInterForm(nullptr),
414 m_pFocusAnnot(nullptr),
415 m_pEnv(pEnv),
416 m_pOccontent(nullptr),
417 m_bChangeMask(FALSE)
351 { 418 {
352 if(m_pInfo)
353 {
354 if(m_pInfo->m_pJsPlatform)
355 return TRUE;
356 else
357 return FALSE;
358 }
359 return FALSE;
360 }
361
362 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv ):m_pDoc(pDoc),
363 m_pInterForm(NULL),m_pEnv(pEnv), m_pOccontent(NULL),m_bChangeMask(FALSE)
364 {
365 m_pFocusAnnot = NULL;
366 } 419 }
367 420
368 CPDFSDK_Document::~CPDFSDK_Document() 421 CPDFSDK_Document::~CPDFSDK_Document()
369 { 422 {
370 for (auto& it : m_pageMap) 423 for (auto& it : m_pageMap)
371 delete it.second; 424 delete it.second;
372 m_pageMap.clear(); 425 m_pageMap.clear();
373 426
374 delete m_pInterForm; 427 delete m_pInterForm;
375 m_pInterForm = nullptr; 428 m_pInterForm = nullptr;
(...skipping 29 matching lines...) Expand all
405 CPDF_Page* pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc, nIndex); 458 CPDF_Page* pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc, nIndex);
406 if (!pTempPage) 459 if (!pTempPage)
407 return nullptr; 460 return nullptr;
408 461
409 auto it = m_pageMap.find(pTempPage); 462 auto it = m_pageMap.find(pTempPage);
410 return it->second; 463 return it->second;
411 } 464 }
412 465
413 void CPDFSDK_Document:: ProcJavascriptFun() 466 void CPDFSDK_Document:: ProcJavascriptFun()
414 { 467 {
415 » CPDF_Document* pPDFDoc = GetDocument(); 468 CPDF_Document* pPDFDoc = GetDocument();
416 » CPDF_DocJSActions docJS(pPDFDoc); 469 CPDF_DocJSActions docJS(pPDFDoc);
417 » int iCount = docJS.CountJSActions(); 470 int iCount = docJS.CountJSActions();
418 » if (iCount < 1) return; 471 if (iCount < 1) return;
419 » for (int i = 0; i < iCount; i ++) 472 for (int i = 0; i < iCount; i ++)
420 » { 473 {
421 » » CFX_ByteString csJSName; 474 CFX_ByteString csJSName;
422 » » CPDF_Action jsAction = docJS.GetJSAction(i, csJSName); 475 CPDF_Action jsAction = docJS.GetJSAction(i, csJSName);
423 » » if(m_pEnv->GetActionHander()) 476 if(m_pEnv->GetActionHander())
424 » » » m_pEnv->GetActionHander()->DoAction_JavaScript(jsAction, CFX_WideString::FromLocal(csJSName),this); 477 m_pEnv->GetActionHander()->DoAction_JavaScript(jsAction,CFX_WideStri ng::FromLocal(csJSName),this);
425 » } 478 }
426 479
427 } 480 }
428 481
429 FX_BOOL CPDFSDK_Document::ProcOpenAction() 482 FX_BOOL CPDFSDK_Document::ProcOpenAction()
430 { 483 {
431 » if(!m_pDoc) 484 if(!m_pDoc)
432 » » return FALSE; 485 return FALSE;
433 486
434 » CPDF_Dictionary* pRoot = m_pDoc->GetRoot(); 487 CPDF_Dictionary* pRoot = m_pDoc->GetRoot();
435 » if (!pRoot) 488 if (!pRoot)
436 » » return FALSE; 489 return FALSE;
437 490
438 » CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction"); 491 CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction");
439 » if(!pOpenAction) 492 if(!pOpenAction)
440 » » pOpenAction = pRoot->GetArray("OpenAction"); 493 pOpenAction = pRoot->GetArray("OpenAction");
441 494
442 » if(!pOpenAction) 495 if(!pOpenAction)
443 » » return FALSE; 496 return FALSE;
444 497
445 » if(pOpenAction->GetType()==PDFOBJ_ARRAY) 498 if(pOpenAction->GetType()==PDFOBJ_ARRAY)
446 » » return TRUE; 499 return TRUE;
447 500
448 » if(pOpenAction->GetType()==PDFOBJ_DICTIONARY) 501 if(pOpenAction->GetType()==PDFOBJ_DICTIONARY)
449 » { 502 {
450 » » CPDF_Dictionary * pDict=(CPDF_Dictionary*)pOpenAction; 503 CPDF_Dictionary * pDict=(CPDF_Dictionary*)pOpenAction;
451 » » CPDF_Action action(pDict); 504 CPDF_Action action(pDict);
452 » » if(m_pEnv->GetActionHander()) 505 if(m_pEnv->GetActionHander())
453 » » » m_pEnv->GetActionHander()->DoAction_DocOpen(action, this ); 506 m_pEnv->GetActionHander()->DoAction_DocOpen(action, this);
454 » » return TRUE; 507 return TRUE;
455 » } 508 }
456 » return FALSE; 509 return FALSE;
457 } 510 }
458 511
459 CPDF_OCContext*»CPDFSDK_Document::GetOCContext() 512 CPDF_OCContext* CPDFSDK_Document::GetOCContext()
460 { 513 {
461 » if(!m_pOccontent) 514 if(!m_pOccontent)
462 » » m_pOccontent = new CPDF_OCContext(m_pDoc); 515 m_pOccontent = new CPDF_OCContext(m_pDoc);
463 » return m_pOccontent; 516 return m_pOccontent;
464 } 517 }
465 518
466 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage) 519 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage)
467 { 520 {
468 auto it = m_pageMap.find(pPDFPage); 521 auto it = m_pageMap.find(pPDFPage);
469 if (it == m_pageMap.end()) 522 if (it == m_pageMap.end())
470 return; 523 return;
471 524
472 CPDFSDK_PageView* pPageView = it->second; 525 CPDFSDK_PageView* pPageView = it->second;
473 if (pPageView->IsLocked()) 526 if (pPageView->IsLocked())
474 return; 527 return;
475 528
476 delete pPageView; 529 delete pPageView;
477 m_pageMap.erase(it); 530 m_pageMap.erase(it);
478 } 531 }
479 532
480 CPDF_Page * CPDFSDK_Document::GetPage(int nIndex) 533 CPDF_Page * CPDFSDK_Document::GetPage(int nIndex)
481 { 534 {
482 » CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex); 535 CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex);
483 » if(!pTempPage) 536 if(!pTempPage)
484 » » return NULL; 537 return NULL;
485 » return pTempPage; 538 return pTempPage;
486 } 539 }
487 540
488 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() 541 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm()
489 { 542 {
490 » if(!m_pInterForm) 543 if(!m_pInterForm)
491 » » m_pInterForm = new CPDFSDK_InterForm(this); 544 m_pInterForm = new CPDFSDK_InterForm(this);
492 » return m_pInterForm; 545 return m_pInterForm;
493 } 546 }
494 547
495 void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot) 548 void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot)
496 { 549 {
497 for (const auto& it : m_pageMap) { 550 for (const auto& it : m_pageMap) {
498 CPDFSDK_PageView* pPageView = it.second; 551 CPDFSDK_PageView* pPageView = it.second;
499 if (pPageView != pSender) { 552 if (pPageView != pSender) {
500 pPageView->UpdateView(pAnnot); 553 pPageView->UpdateView(pAnnot);
501 } 554 }
502 } 555 }
503 } 556 }
504 557
505 CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot() 558 CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot()
506 { 559 {
507 return m_pFocusAnnot; 560 return m_pFocusAnnot;
508 } 561 }
509 562
510 FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) 563 FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
511 { 564 {
512 565
513 » if(m_pFocusAnnot==pAnnot) return TRUE; 566 if(m_pFocusAnnot==pAnnot) return TRUE;
514 567
515 » if(m_pFocusAnnot) 568 if(m_pFocusAnnot)
516 » { 569 {
517 » » if(!KillFocusAnnot(nFlag) ) return FALSE; 570 if(!KillFocusAnnot(nFlag) ) return FALSE;
518 » } 571 }
519 » CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); 572 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
520 » if(pAnnot && pPageView->IsValid()) 573 if(pAnnot && pPageView->IsValid())
521 » { 574 {
522 » » CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMg r(); 575 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr();
523 576
524 » » if(pAnnotHandler&&!m_pFocusAnnot) 577 if(pAnnotHandler&&!m_pFocusAnnot)
525 » » { 578 {
526 » » » if (!pAnnotHandler->Annot_OnSetFocus(pAnnot,nFlag)) 579 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot,nFlag))
527 » » » » return FALSE; 580 return FALSE;
528 » » » if(!m_pFocusAnnot) 581 if(!m_pFocusAnnot)
529 » » » { 582 {
530 » » » » m_pFocusAnnot=pAnnot; 583 m_pFocusAnnot=pAnnot;
531 » » » » return TRUE; 584 return TRUE;
532 » » » } 585 }
533 » » } 586 }
534 » } 587 }
535 » return FALSE; 588 return FALSE;
536 } 589 }
537 590
538 FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) 591 FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag)
539 { 592 {
540 » if(m_pFocusAnnot) 593 if(m_pFocusAnnot)
541 » { 594 {
542 » » CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMg r(); 595 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr();
543 » » if(pAnnotHandler) 596 if(pAnnotHandler)
544 » » { 597 {
545 » » » CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; 598 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot;
546 » » » m_pFocusAnnot = NULL; 599 m_pFocusAnnot = NULL;
547 » » » if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) 600 if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag))
548 » » » { 601 {
549 602
550 » » » » if(pFocusAnnot->GetType() == FX_BSTRC("Widget")) 603 if(pFocusAnnot->GetType() == FX_BSTRC("Widget"))
551 » » » » { 604 {
552 » » » » » CPDFSDK_Widget* pWidget = (CPDFSDK_Widge t*)pFocusAnnot; 605 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot;
553 » » » » » int nFieldType = pWidget->GetFieldType() ; 606 int nFieldType = pWidget->GetFieldType();
554 » » » » » if(FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX == nFieldType) 607 if(FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX = = nFieldType)
555 » » » » » » m_pEnv->FFI_OnSetFieldInputFocus (NULL, NULL, 0, FALSE); 608 m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE);
556 » » » » } 609 }
557 610
558 » » » » if(!m_pFocusAnnot) 611 if(!m_pFocusAnnot)
559 » » » » » return TRUE; 612 return TRUE;
560 » » » } 613 }
561 » » » else 614 else
562 » » » { 615 {
563 » » » » m_pFocusAnnot = pFocusAnnot; 616 m_pFocusAnnot = pFocusAnnot;
564 » » » } 617 }
565 » » } 618 }
566 » } 619 }
567 » return FALSE; 620 return FALSE;
568 } 621 }
569 622
570 void CPDFSDK_Document::OnCloseDocument() 623 void CPDFSDK_Document::OnCloseDocument()
571 { 624 {
572 » KillFocusAnnot(); 625 KillFocusAnnot();
573 } 626 }
574 627
575 FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) 628 FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag)
576 { 629 {
577 » FX_DWORD dwPermissions = m_pDoc->GetUserPermissions(); 630 FX_DWORD dwPermissions = m_pDoc->GetUserPermissions();
578 » return dwPermissions&nFlag; 631 return dwPermissions&nFlag;
579 } 632 }
580 633
581 IFXJS_Runtime * CPDFSDK_Document::GetJsRuntime() 634 IFXJS_Runtime * CPDFSDK_Document::GetJsRuntime()
582 { 635 {
583 » ASSERT(m_pEnv!=NULL); 636 ASSERT(m_pEnv!=NULL);
584 » return m_pEnv->GetJSRuntime(); 637 return m_pEnv->GetJSRuntime();
585 } 638 }
586 639
587 CFX_WideString» CPDFSDK_Document::GetPath() 640 CFX_WideString CPDFSDK_Document::GetPath()
588 { 641 {
589 » ASSERT(m_pEnv != NULL); 642 ASSERT(m_pEnv != NULL);
590 » return m_pEnv->JS_docGetFilePath(); 643 return m_pEnv->JS_docGetFilePath();
591 } 644 }
592 645
593 646
594 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_ page(page),m_pSDKDoc(pSDKDoc) 647 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_ page(page),m_pSDKDoc(pSDKDoc)
595 { 648 {
596 » CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); 649 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm();
597 » if(pInterForm) 650 if(pInterForm)
598 » { 651 {
599 » » CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 652 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
600 » » pPDFInterForm->FixPageFields(page); 653 pPDFInterForm->FixPageFields(page);
601 » } 654 }
602 m_page->SetPrivateData((void*)m_page, (void*)this, NULL); 655 m_page->SetPrivateData((void*)m_page, (void*)this, NULL);
603 » m_fxAnnotArray.RemoveAll(); 656 m_fxAnnotArray.RemoveAll();
604 657
605 » m_bEnterWidget = FALSE; 658 m_bEnterWidget = FALSE;
606 » m_bExitWidget = FALSE; 659 m_bExitWidget = FALSE;
607 » m_bOnWidget = FALSE; 660 m_bOnWidget = FALSE;
608 » m_CaptureWidget = NULL; 661 m_CaptureWidget = NULL;
609 » m_bValid = FALSE; 662 m_bValid = FALSE;
610 m_bLocked = FALSE; 663 m_bLocked = FALSE;
611 m_bTakeOverPage = FALSE; 664 m_bTakeOverPage = FALSE;
612 } 665 }
613 666
614 CPDFSDK_PageView::~CPDFSDK_PageView() 667 CPDFSDK_PageView::~CPDFSDK_PageView()
615 { 668 {
616 » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 669 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
617 » int nAnnotCount = m_fxAnnotArray.GetSize(); 670 int nAnnotCount = m_fxAnnotArray.GetSize();
618 671
619 » for (int i=0; i<nAnnotCount; i++) 672 for (int i=0; i<nAnnotCount; i++)
620 » { 673 {
621 » » CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); 674 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
622 » » //if there is a focused annot on the page, we should kill the fo cus first. 675 //if there is a focused annot on the page, we should kill the focus firs t.
623 » » if(pAnnot == m_pSDKDoc->GetFocusAnnot()) 676 if(pAnnot == m_pSDKDoc->GetFocusAnnot())
624 » » » KillFocusAnnot(); 677 KillFocusAnnot();
625 » » CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); 678 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
626 » » ASSERT(pAnnotHandlerMgr); 679 ASSERT(pAnnotHandlerMgr);
627 » » pAnnotHandlerMgr->ReleaseAnnot(pAnnot); 680 pAnnotHandlerMgr->ReleaseAnnot(pAnnot);
628 » } 681 }
629 » m_fxAnnotArray.RemoveAll(); 682 m_fxAnnotArray.RemoveAll();
630 683
631 delete m_pAnnotList; 684 delete m_pAnnotList;
632 m_pAnnotList = NULL; 685 m_pAnnotList = NULL;
633 686
634 m_page->RemovePrivateData((void*)m_page); 687 m_page->RemovePrivateData((void*)m_page);
635 if(m_bTakeOverPage) { 688 if(m_bTakeOverPage) {
636 delete m_page; 689 delete m_page;
637 } 690 }
638 } 691 }
639 692
640 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p User2Device,CPDF_RenderOptions* pOptions) 693 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p User2Device,CPDF_RenderOptions* pOptions)
641 { 694 {
642 m_curMatrix = *pUser2Device; 695 m_curMatrix = *pUser2Device;
643 696
644 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 697 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
645 CPDFSDK_AnnotIterator annotIterator(this, TRUE); 698 CPDFSDK_AnnotIterator annotIterator(this, TRUE);
646 CPDFSDK_Annot* pSDKAnnot = nullptr; 699 CPDFSDK_Annot* pSDKAnnot = nullptr;
647 int index = -1; 700 int index = -1;
648 while ((pSDKAnnot = annotIterator.Next(index))) { 701 while ((pSDKAnnot = annotIterator.Next(index))) {
649 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 702 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
650 ASSERT(pAnnotHandlerMgr); 703 ASSERT(pAnnotHandlerMgr);
651 pAnnotHandlerMgr->Annot_OnDraw( 704 pAnnotHandlerMgr->Annot_OnDraw(
652 this, pSDKAnnot, pDevice, pUser2Device, 0); 705 this, pSDKAnnot, pDevice, pUser2Device, 0);
653 } 706 }
654 } 707 }
655 708
656 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY) 709 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY)
657 { 710 {
658 711
659 » int nCount = m_pAnnotList->Count(); 712 int nCount = m_pAnnotList->Count();
660 » for(int i = 0 ; i<nCount; i++) 713 for(int i = 0 ; i<nCount; i++)
661 » { 714 {
662 » » CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); 715 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
663 » » CFX_FloatRect annotRect; 716 CFX_FloatRect annotRect;
664 » » pAnnot->GetRect(annotRect); 717 pAnnot->GetRect(annotRect);
665 » » if(annotRect.Contains(pageX, pageY)) 718 if(annotRect.Contains(pageX, pageY))
666 » » » return pAnnot; 719 return pAnnot;
667 » } 720 }
668 » return NULL; 721 return NULL;
669 } 722 }
670 723
671 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY ) 724 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY )
672 { 725 {
673 726
674 » int nCount = m_pAnnotList->Count(); 727 int nCount = m_pAnnotList->Count();
675 » for(int i = 0 ; i<nCount; i++) 728 for(int i = 0 ; i<nCount; i++)
676 » { 729 {
677 » » CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); 730 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
678 » » if(pAnnot->GetSubType() == "Widget") 731 if(pAnnot->GetSubType() == "Widget")
679 » » { 732 {
680 » » » CFX_FloatRect annotRect; 733 CFX_FloatRect annotRect;
681 » » » pAnnot->GetRect(annotRect); 734 pAnnot->GetRect(annotRect);
682 » » » if(annotRect.Contains(pageX, pageY)) 735 if(annotRect.Contains(pageX, pageY))
683 » » » » return pAnnot; 736 return pAnnot;
684 » » } 737 }
685 » } 738 }
686 » return NULL; 739 return NULL;
687 } 740 }
688 741
689 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT page Y) 742 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT page Y)
690 { 743 {
691 744
692 » CPDFSDK_AnnotIterator annotIterator(this, FALSE); 745 CPDFSDK_AnnotIterator annotIterator(this, FALSE);
693 » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 746 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
694 » CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); 747 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
695 » CPDFSDK_Annot* pSDKAnnot = NULL; 748 CPDFSDK_Annot* pSDKAnnot = NULL;
696 » int index = -1; 749 int index = -1;
697 » while((pSDKAnnot = annotIterator.Next(index))) 750 while((pSDKAnnot = annotIterator.Next(index)))
698 » { 751 {
699 » » CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); 752 CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
700 » » if(rc.Contains(pageX, pageY)) 753 if(rc.Contains(pageX, pageY))
701 » » » return pSDKAnnot; 754 return pSDKAnnot;
702 » } 755 }
703 756
704 » return NULL; 757 return NULL;
705 } 758 }
706 759
707 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pag eY) 760 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pag eY)
708 { 761 {
709 762
710 » CPDFSDK_AnnotIterator annotIterator(this, FALSE); 763 CPDFSDK_AnnotIterator annotIterator(this, FALSE);
711 » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 764 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
712 » CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); 765 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
713 » CPDFSDK_Annot* pSDKAnnot = NULL; 766 CPDFSDK_Annot* pSDKAnnot = NULL;
714 » int index = -1; 767 int index = -1;
715 » while((pSDKAnnot = annotIterator.Next(index))) 768 while((pSDKAnnot = annotIterator.Next(index)))
716 » { 769 {
717 » » if(pSDKAnnot->GetType() == "Widget") 770 if(pSDKAnnot->GetType() == "Widget")
718 » » { 771 {
719 » » » pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); 772 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
720 » » » CPDF_Point point(pageX, pageY); 773 CPDF_Point point(pageX, pageY);
721 » » » if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) 774 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
722 » » » » return pSDKAnnot; 775 return pSDKAnnot;
723 » » } 776 }
724 » } 777 }
725 778
726 » return NULL; 779 return NULL;
727 } 780 }
728 781
729 782
730 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) 783 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot)
731 { 784 {
732 » CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); 785 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict();
733 » if(pAnnotDic) 786 if(pAnnotDic)
734 » » return» pAnnotDic->KeyExist("AS"); 787 return pAnnotDic->KeyExist("AS");
735 » return FALSE; 788 return FALSE;
736 } 789 }
737 790
738 CPDFSDK_Annot*» CPDFSDK_PageView::AddAnnot(CPDF_Annot * pPDFAnnot) 791 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot * pPDFAnnot)
739 { 792 {
740 » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 793 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
741 » ASSERT(pEnv); 794 ASSERT(pEnv);
742 » CPDFSDK_AnnotHandlerMgr * pAnnotHandler= pEnv->GetAnnotHandlerMgr(); 795 CPDFSDK_AnnotHandlerMgr * pAnnotHandler= pEnv->GetAnnotHandlerMgr();
743 796
744 » CPDFSDK_Annot* pSDKAnnot =NULL; 797 CPDFSDK_Annot* pSDKAnnot =NULL;
745 798
746 » if(pAnnotHandler) 799 if(pAnnotHandler)
747 » { 800 {
748 » » pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); 801 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this);
749 » } 802 }
750 » if(!pSDKAnnot) 803 if(!pSDKAnnot)
751 » » return NULL; 804 return NULL;
752 805
753 » m_fxAnnotArray.Add(pSDKAnnot); 806 m_fxAnnotArray.Add(pSDKAnnot);
754 807
755 » if(pAnnotHandler) 808 if(pAnnotHandler)
756 » { 809 {
757 » » pAnnotHandler->Annot_OnCreate(pSDKAnnot); 810 pAnnotHandler->Annot_OnCreate(pSDKAnnot);
758 811
759 » } 812 }
760 813
761 » return pSDKAnnot; 814 return pSDKAnnot;
762 } 815 }
763 816
764 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary * pDict) 817 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary * pDict)
765 { 818 {
766 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; 819 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr;
767 } 820 }
768 821
769 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictiona ry * pDict) 822 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictiona ry * pDict)
770 { 823 {
771 » return NULL; 824 return NULL;
772 } 825 }
773 826
774 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) 827 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot)
775 { 828 {
776 » return FALSE; 829 return FALSE;
777 } 830 }
778 831
779 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() 832 CPDF_Document* CPDFSDK_PageView::GetPDFDocument()
780 { 833 {
781 » if(m_page) 834 if(m_page)
782 » { 835 {
783 » » return m_page->m_pDocument; 836 return m_page->m_pDocument;
784 » } 837 }
785 » return NULL; 838 return NULL;
786 } 839 }
787 840
788 int» CPDFSDK_PageView::CountAnnots() 841 int CPDFSDK_PageView::CountAnnots()
789 { 842 {
790 » return m_pAnnotList->Count(); 843 return m_pAnnotList->Count();
791 } 844 }
792 845
793 CPDFSDK_Annot*» CPDFSDK_PageView::GetAnnot(int nIndex) 846 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(int nIndex)
794 { 847 {
795 » int nCount = m_fxAnnotArray.GetSize(); 848 int nCount = m_fxAnnotArray.GetSize();
796 » if ( nIndex < 0 || nIndex >= nCount ) 849 if ( nIndex < 0 || nIndex >= nCount )
797 » { 850 {
798 » » return NULL; 851 return NULL;
799 » } 852 }
800 853
801 » return (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(nIndex); 854 return (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(nIndex);
802 } 855 }
803 856
804 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary * pDict) 857 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary * pDict)
805 { 858 {
806 » int nCount = m_fxAnnotArray.GetSize(); 859 int nCount = m_fxAnnotArray.GetSize();
807 » for(int i=0; i<nCount; i++) 860 for(int i=0; i<nCount; i++)
808 » { 861 {
809 » » CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); 862 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
810 » » if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict()) 863 if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict())
811 » » » return pAnnot; 864 return pAnnot;
812 » } 865 }
813 » return NULL; 866 return NULL;
814 } 867 }
815 868
816 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag) 869 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag)
817 { 870 {
818 » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 871 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
819 » ASSERT(pEnv); 872 ASSERT(pEnv);
820 » CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); 873 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
821 » if(!pFXAnnot) 874 if(!pFXAnnot)
822 » { 875 {
823 » » KillFocusAnnot(nFlag); 876 KillFocusAnnot(nFlag);
824 » } 877 }
825 » else 878 else
826 » { 879 {
827 » » CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); 880 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
828 » » ASSERT(pAnnotHandlerMgr); 881 ASSERT(pAnnotHandlerMgr);
829 882
830 » » FX_BOOL bRet = pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAn not, nFlag,point); 883 FX_BOOL bRet = pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFl ag,point);
831 » » if(bRet) 884 if(bRet)
832 » » { 885 {
833 » » » SetFocusAnnot(pFXAnnot); 886 SetFocusAnnot(pFXAnnot);
834 » » } 887 }
835 » » return bRet; 888 return bRet;
836 » } 889 }
837 » return FALSE; 890 return FALSE;
838 } 891 }
839 892
840 893
841 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag) 894 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag)
842 { 895 {
843 » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 896 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
844 » ASSERT(pEnv); 897 ASSERT(pEnv);
845 » CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 898 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
846 » ASSERT(pAnnotHandlerMgr); 899 ASSERT(pAnnotHandlerMgr);
847 » CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); 900 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
848 » CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); 901 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot();
849 » FX_BOOL bRet = FALSE; 902 FX_BOOL bRet = FALSE;
850 » if(pFocusAnnot && pFocusAnnot != pFXAnnot) 903 if(pFocusAnnot && pFocusAnnot != pFXAnnot)
851 » { 904 {
852 » » //Last focus Annot gets a chance to handle the event. 905 //Last focus Annot gets a chance to handle the event.
853 » » bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nF lag,point); 906 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag,poin t);
854 » } 907 }
855 » if(pFXAnnot && !bRet) 908 if(pFXAnnot && !bRet)
856 » { 909 {
857 » » bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag ,point); 910 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag,point);
858 » » return bRet; 911 return bRet;
859 » } 912 }
860 » return bRet; 913 return bRet;
861 } 914 }
862 915
863 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CPDF_Point & point, int nFlag) 916 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CPDF_Point & point, int nFlag)
864 { 917 {
865 918
866 » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 919 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
867 » CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 920 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
868 » ASSERT(pAnnotHandlerMgr); 921 ASSERT(pAnnotHandlerMgr);
869 » if(CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y)) 922 if(CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y))
870 » { 923 {
871 » » if(m_CaptureWidget && m_CaptureWidget != pFXAnnot) 924 if(m_CaptureWidget && m_CaptureWidget != pFXAnnot)
872 » » { 925 {
873 » » » m_bExitWidget = TRUE; 926 m_bExitWidget = TRUE;
874 » » » m_bEnterWidget = FALSE; 927 m_bEnterWidget = FALSE;
875 » » » pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidge t, nFlag); 928 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag);
876 » » } 929 }
877 » » m_CaptureWidget = (CPDFSDK_Widget*)pFXAnnot; 930 m_CaptureWidget = (CPDFSDK_Widget*)pFXAnnot;
878 » » m_bOnWidget = TRUE; 931 m_bOnWidget = TRUE;
879 » » if(!m_bEnterWidget) 932 if(!m_bEnterWidget)
880 » » { 933 {
881 » » » m_bEnterWidget = TRUE; 934 m_bEnterWidget = TRUE;
882 » » » m_bExitWidget = FALSE; 935 m_bExitWidget = FALSE;
883 » » » pAnnotHandlerMgr->Annot_OnMouseEnter(this, pFXAnnot,nFla g); 936 pAnnotHandlerMgr->Annot_OnMouseEnter(this, pFXAnnot,nFlag);
884 » » } 937 }
885 » » pAnnotHandlerMgr->Annot_OnMouseMove(this, pFXAnnot, nFlag, point ); 938 pAnnotHandlerMgr->Annot_OnMouseMove(this, pFXAnnot, nFlag, point);
886 » » return TRUE; 939 return TRUE;
887 » } 940 }
888 » else 941 else
889 » { 942 {
890 » » if(m_bOnWidget) 943 if(m_bOnWidget)
891 » » { 944 {
892 » » » m_bOnWidget = FALSE; 945 m_bOnWidget = FALSE;
893 » » » m_bExitWidget = TRUE; 946 m_bExitWidget = TRUE;
894 » » » m_bEnterWidget = FALSE; 947 m_bEnterWidget = FALSE;
895 » » » if(m_CaptureWidget) 948 if(m_CaptureWidget)
896 » » » { 949 {
897 » » » » pAnnotHandlerMgr->Annot_OnMouseExit(this, m_Capt ureWidget, nFlag); 950 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag );
898 » » » » m_CaptureWidget = NULL; 951 m_CaptureWidget = NULL;
899 » » » } 952 }
900 » » } 953 }
901 » » return FALSE; 954 return FALSE;
902 » } 955 }
903 956
904 » return FALSE;; 957 return FALSE;;
905 } 958 }
906 959
907 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, double deltaY,const CPDF_P oint& point, int nFlag) 960 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, double deltaY,const CPDF_P oint& point, int nFlag)
908 { 961 {
909 » if(CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) 962 if(CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y))
910 » { 963 {
911 » » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 964 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
912 » » CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); 965 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
913 » » ASSERT(pAnnotHandlerMgr); 966 ASSERT(pAnnotHandlerMgr);
914 » » return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, (int)deltaY, point); 967 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, (int)de ltaY, point);
915 » } 968 }
916 » return FALSE; 969 return FALSE;
917 970
918 } 971 }
919 972
920 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag) 973 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag)
921 { 974 {
922 » if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) 975 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot())
923 » { 976 {
924 » » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 977 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
925 » » CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); 978 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
926 » » ASSERT(pAnnotHandlerMgr); 979 ASSERT(pAnnotHandlerMgr);
927 » » return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); 980 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag);
928 » } 981 }
929 982
930 » return FALSE; 983 return FALSE;
931 } 984 }
932 985
933 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) 986 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag)
934 { 987 {
935 » if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) 988 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot())
936 » { 989 {
937 » » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 990 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
938 » » CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); 991 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
939 » » ASSERT(pAnnotHandlerMgr); 992 ASSERT(pAnnotHandlerMgr);
940 » » return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag ); 993 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag);
941 » } 994 }
942 » return FALSE; 995 return FALSE;
943 } 996 }
944 997
945 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) 998 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag)
946 { 999 {
947 // » if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) 1000 // if(CPDFSDK_Annot* pAnnot = GetFocusAnnot())
948 // » { 1001 // {
949 // » » CFFL_IFormFiller* pIFormFiller = g_pFormFillApp->GetIFormFiller( ); 1002 // CFFL_IFormFiller* pIFormFiller = g_pFormFillApp->GetIFormFiller();
950 // » » return pIFormFiller->OnKeyUp(pAnnot, nKeyCode, nFlag); 1003 // return pIFormFiller->OnKeyUp(pAnnot, nKeyCode, nFlag);
951 // » } 1004 // }
952 » return FALSE; 1005 return FALSE;
953 } 1006 }
954 1007
955 extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot); 1008 extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot);
956 1009
957 void CPDFSDK_PageView::LoadFXAnnots() 1010 void CPDFSDK_PageView::LoadFXAnnots()
958 { 1011 {
959 » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 1012 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
960 1013
961 » FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); 1014 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
962 » //Disable the default AP construction. 1015 //Disable the default AP construction.
963 » CPDF_InterForm::EnableUpdateAP(FALSE); 1016 CPDF_InterForm::EnableUpdateAP(FALSE);
964 » m_pAnnotList = new CPDF_AnnotList(m_page); 1017 m_pAnnotList = new CPDF_AnnotList(m_page);
965 » CPDF_InterForm::EnableUpdateAP(enableAPUpdate); 1018 CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
966 » int nCount = m_pAnnotList->Count(); 1019 int nCount = m_pAnnotList->Count();
967 SetLock(TRUE); 1020 SetLock(TRUE);
968 » for(int i=0; i<nCount; i++) 1021 for(int i=0; i<nCount; i++)
969 » { 1022 {
970 » » CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); 1023 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
971 » » CPDF_Document * pDoc = GetPDFDocument(); 1024 CPDF_Document * pDoc = GetPDFDocument();
972 1025
973 » » CheckUnSupportAnnot(pDoc, pPDFAnnot); 1026 CheckUnSupportAnnot(pDoc, pPDFAnnot);
974 1027
975 » » CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); 1028 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
976 » » ASSERT(pAnnotHandlerMgr != NULL); 1029 ASSERT(pAnnotHandlerMgr != NULL);
977 1030
978 » » if(pAnnotHandlerMgr) 1031 if(pAnnotHandlerMgr)
979 » » { 1032 {
980 » » » CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFA nnot, this); 1033 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
981 » » » if(!pAnnot) 1034 if(!pAnnot)
982 » » » » continue; 1035 continue;
983 » » » m_fxAnnotArray.Add(pAnnot); 1036 m_fxAnnotArray.Add(pAnnot);
984 1037
985 » » » pAnnotHandlerMgr->Annot_OnLoad(pAnnot); 1038 pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
986 » » } 1039 }
987 1040
988 » } 1041 }
989 SetLock(FALSE); 1042 SetLock(FALSE);
990 } 1043 }
991 1044
992 void» CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) 1045 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects)
993 { 1046 {
994 » for(int i=0; i<rects.GetSize(); i++) 1047 for(int i=0; i<rects.GetSize(); i++)
995 » { 1048 {
996 » » CPDF_Rect rc = rects.GetAt(i); 1049 CPDF_Rect rc = rects.GetAt(i);
997 » » CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 1050 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
998 » » pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.botto m); 1051 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom);
999 » } 1052 }
1000 } 1053 }
1001 1054
1002 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) 1055 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot)
1003 { 1056 {
1004 CPDF_Rect rcWindow = pAnnot->GetRect(); 1057 CPDF_Rect rcWindow = pAnnot->GetRect();
1005 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 1058 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
1006 pEnv->FFI_Invalidate( 1059 pEnv->FFI_Invalidate(
1007 m_page, rcWindow.left, rcWindow.top, rcWindow.right, rcWindow.bottom); 1060 m_page, rcWindow.left, rcWindow.top, rcWindow.right, rcWindow.bottom);
1008 } 1061 }
1009 1062
1010 int CPDFSDK_PageView::GetPageIndex() 1063 int CPDFSDK_PageView::GetPageIndex()
1011 { 1064 {
1012 » if(m_page) 1065 if(m_page)
1013 » { 1066 {
1014 » » CPDF_Dictionary* pDic = m_page->m_pFormDict; 1067 CPDF_Dictionary* pDic = m_page->m_pFormDict;
1015 » » CPDF_Document* pDoc = m_pSDKDoc->GetDocument(); 1068 CPDF_Document* pDoc = m_pSDKDoc->GetDocument();
1016 » » if(pDoc && pDic) 1069 if(pDoc && pDic)
1017 » » { 1070 {
1018 » » » return pDoc->GetPageIndex(pDic->GetObjNum()); 1071 return pDoc->GetPageIndex(pDic->GetObjNum());
1019 » » } 1072 }
1020 » } 1073 }
1021 » return -1; 1074 return -1;
1022 } 1075 }
1023 1076
1024 FX_BOOL»CPDFSDK_PageView::IsValidAnnot(void* p) 1077 FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p)
1025 { 1078 {
1026 » if (p == NULL) return FALSE; 1079 if (p == NULL) return FALSE;
1027 » int iCount = m_pAnnotList->Count(); 1080 int iCount = m_pAnnotList->Count();
1028 » for (int i = 0; i < iCount; i++) 1081 for (int i = 0; i < iCount; i++)
1029 » { 1082 {
1030 » » if (m_pAnnotList->GetAt(i) == p) 1083 if (m_pAnnotList->GetAt(i) == p)
1031 » » » return TRUE; 1084 return TRUE;
1032 » } 1085 }
1033 » return FALSE; 1086 return FALSE;
1034 } 1087 }
1035 1088
1036 1089
1037 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() 1090 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot()
1038 { 1091 {
1039 » CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); 1092 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot();
1040 » if(!pFocusAnnot) 1093 if(!pFocusAnnot)
1041 » » return NULL; 1094 return NULL;
1042 1095
1043 » for(int i=0; i<m_fxAnnotArray.GetSize(); i++) 1096 for(int i=0; i<m_fxAnnotArray.GetSize(); i++)
1044 » { 1097 {
1045 » » CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); 1098 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
1046 » » if(pAnnot == pFocusAnnot) 1099 if(pAnnot == pFocusAnnot)
1047 » » » return pAnnot; 1100 return pAnnot;
1048 » } 1101 }
1049 » return NULL; 1102 return NULL;
1050 } 1103 }
1051
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_annothandler.cpp ('k') | fpdfsdk/src/javascript/JS_Object.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698