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