summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-07-16 11:09:12 -0700
committerTom Sepez <tsepez@chromium.org>2015-07-16 11:09:12 -0700
commitfb07e2843dad0774d5842c2b08e7792164efc14a (patch)
tree4583acca1bdcf5b60fad79af0b9fa405f192c5d8 /fpdfsdk
parentcc8b4d8763151f51c9fe71ce9b64b2a0d7ddcc88 (diff)
downloadpdfium-fb07e2843dad0774d5842c2b08e7792164efc14a.tar.xz
Tidy up CPDFDOC_Environment.
- untabify as encountered. - Only put single-statement method in .h file, move more complex methods to .cpp (counting an if without braces as a single statement, killing braces as needed). - Move invariant arguments to constructor and make corresponding members const. - Make all members private and add accessor methods. - Make existing accessor methods const where possible. - Kill meaningless asserts. - Add helper functions in place of duplicate code. - Rename GetCurrentDoc() to GetSDKDocument(), since the class has two document members, one of CPDF_Document and one of CPDFSDK_Document, making it clear which one you get. - Simplify some logic with early returns. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1235393002 .
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/formfiller/FFL_FormFiller.h29
-rw-r--r--fpdfsdk/include/fsdk_mgr.h769
-rw-r--r--fpdfsdk/src/formfiller/FFL_FormFiller.cpp895
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp23
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp489
-rw-r--r--fpdfsdk/src/fsdk_annothandler.cpp1179
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp1200
-rw-r--r--fpdfsdk/src/javascript/JS_Object.cpp92
-rw-r--r--fpdfsdk/src/javascript/app.cpp104
-rw-r--r--fpdfsdk/src/javascript/global.cpp14
10 files changed, 2258 insertions, 2536 deletions
diff --git a/fpdfsdk/include/formfiller/FFL_FormFiller.h b/fpdfsdk/include/formfiller/FFL_FormFiller.h
index f308c206f9..c597d1e41f 100644
--- a/fpdfsdk/include/formfiller/FFL_FormFiller.h
+++ b/fpdfsdk/include/formfiller/FFL_FormFiller.h
@@ -18,7 +18,6 @@ class CPDFSDK_PageView;
class CPDFSDK_Document;
class CPDFSDK_Widget;
-
struct FFL_KeyStrokeData
{
CFX_WideString swValue;
@@ -27,21 +26,19 @@ struct FFL_KeyStrokeData
int nSelEnd;
};
-
-
-class CFFL_FormFiller : /*public IBA_AnnotFiller,*/ public IPWL_Provider, public CPWL_TimerHandler
+class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler
{
public:
CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot);
virtual ~CFFL_FormFiller();
virtual FX_RECT GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot);
- virtual void OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
+ virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ FX_DWORD dwFlags);
+ virtual void OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow, */FX_DWORD dwFlags);
- virtual void OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow, */FX_DWORD dwFlags);
+ FX_DWORD dwFlags);
virtual void OnCreate(CPDFSDK_Annot* pAnnot);
virtual void OnLoad(CPDFSDK_Annot* pAnnot);
@@ -106,8 +103,6 @@ public:
void SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect& rcWindow);
CPDF_Rect GetWindowRect(CPDFSDK_PageView* pPageView);
- static void FFL_FreeData(void* pData);
-
FX_BOOL CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag);
virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView);
virtual void SaveData(CPDFSDK_PageView* pPageView);
@@ -155,13 +150,13 @@ public:
virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
- virtual void OnDraw(CPDFSDK_PageView *pPageView/*, HDC hDC*/, CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow,*/ FX_DWORD dwFlags);
+ virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ FX_DWORD dwFlags);
- virtual void OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow, */FX_DWORD dwFlags);
+ virtual void OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ FX_DWORD dwFlags);
protected:
FX_BOOL m_bMouseIn;
FX_BOOL m_bMouseDown;
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h
index 167d0d6fcd..d57138b350 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -21,339 +21,242 @@
#include "fsdk_actionhandler.h"
#include "javascript/IJavaScript.h"
+class CFFL_IFormFiller;
+class CJS_RuntimeFactory;
+class CPDFSDK_ActionHandler;
+class CPDFSDK_Annot;
class CPDFSDK_Document;
+class CPDFSDK_InterForm;
class CPDFSDK_PageView;
-class CPDFSDK_Annot;
-class CFFL_IFormFiller;
class CPDFSDK_Widget;
class IFX_SystemHandler;
-class CPDFSDK_ActionHandler;
-class CJS_RuntimeFactory;
class CPDFDoc_Environment final
{
public:
- CPDFDoc_Environment(CPDF_Document * pDoc);
- ~CPDFDoc_Environment();
-
- int RegAppHandle(FPDF_FORMFILLINFO* pFFinfo);
-
- void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom)
- {
- if (m_pInfo && m_pInfo->FFI_Invalidate)
- {
- m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom);
- }
- }
- void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom)
- {
- if (m_pInfo && m_pInfo->FFI_OutputSelectedRect)
- {
- m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom);
- }
- }
-
- void FFI_SetCursor(int nCursorType)
- {
- if (m_pInfo && m_pInfo->FFI_SetCursor)
- {
- m_pInfo->FFI_SetCursor(m_pInfo, nCursorType);
- }
- }
-
- int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc)
- {
- if (m_pInfo && m_pInfo->FFI_SetTimer)
- {
- return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc);
- }
- return -1;
- }
-
- void FFI_KillTimer(int nTimerID)
- {
- if (m_pInfo && m_pInfo->FFI_KillTimer)
- {
- m_pInfo->FFI_KillTimer(m_pInfo, nTimerID);
- }
- }
- FX_SYSTEMTIME FFI_GetLocalTime()
- {
- FX_SYSTEMTIME fxtime;
- if(m_pInfo && m_pInfo->FFI_GetLocalTime)
- {
- FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo);
- fxtime.wDay = systime.wDay;
- fxtime.wDayOfWeek = systime.wDayOfWeek;
- fxtime.wHour = systime.wHour;
- fxtime.wMilliseconds = systime.wMilliseconds;
- fxtime.wMinute = systime.wMinute;
- fxtime.wMonth = systime.wMonth;
- fxtime.wSecond = systime.wSecond;
- fxtime.wYear = systime.wYear;
- }
- return fxtime;
- }
-
- void FFI_OnChange()
- {
- if(m_pInfo && m_pInfo->FFI_OnChange)
- {
- m_pInfo->FFI_OnChange(m_pInfo);
- }
- }
-
- FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag)
- {
-
- return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0;
- }
- FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag)
- {
-
- return (nFlag & FWL_EVENTFLAG_ControlKey) != 0;
- }
- FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag)
- {
-
- return (nFlag & FWL_EVENTFLAG_AltKey) != 0;
- }
- FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag)
- {
- return FALSE;
- }
-
- int JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon)
- {
- if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert)
- {
- CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
- CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
- FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
- FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength());
- int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg, pTitle, Type, Icon);
- bsMsg.ReleaseBuffer();
- bsTitle.ReleaseBuffer();
- return ret;
- }
- return -1;
- }
-
- int JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, const FX_WCHAR* Default, const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* response, int length)
- {
- if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_response)
- {
- CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode();
- CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
- CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode();
- CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode();
- FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion.GetBuffer(bsQuestion.GetLength());
- FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength());
- FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.GetBuffer(bsDefault.GetLength());
- FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuffer(bsLabel.GetLength());
- int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo->m_pJsPlatform, pQuestion, pTitle,
- pDefault, pLabel, bPassword, response, length);
- bsQuestion.ReleaseBuffer();
- bsTitle.ReleaseBuffer();
- bsDefault.ReleaseBuffer();
- bsLabel.ReleaseBuffer();
- return ret;
- }
- return -1;
- }
-
- void JS_appBeep(int nType)
- {
- if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep)
- {
- m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType);
- }
- }
+ CPDFDoc_Environment(CPDF_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo);
+ ~CPDFDoc_Environment();
+
+ void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom)
+ {
+ if (m_pInfo && m_pInfo->FFI_Invalidate)
+ m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom);
+ }
+
+ void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom)
+ {
+ if (m_pInfo && m_pInfo->FFI_OutputSelectedRect)
+ m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom);
+ }
+
+ void FFI_SetCursor(int nCursorType)
+ {
+ if (m_pInfo && m_pInfo->FFI_SetCursor)
+ m_pInfo->FFI_SetCursor(m_pInfo, nCursorType);
+ }
+
+ int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc)
+ {
+ if (m_pInfo && m_pInfo->FFI_SetTimer)
+ return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc);
+ return -1;
+ }
+
+ void FFI_KillTimer(int nTimerID)
+ {
+ if (m_pInfo && m_pInfo->FFI_KillTimer)
+ m_pInfo->FFI_KillTimer(m_pInfo, nTimerID);
+ }
+
+ FX_SYSTEMTIME FFI_GetLocalTime() const
+ {
+ FX_SYSTEMTIME fxtime;
+ if (m_pInfo && m_pInfo->FFI_GetLocalTime)
+ {
+ FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo);
+ fxtime.wDay = systime.wDay;
+ fxtime.wDayOfWeek = systime.wDayOfWeek;
+ fxtime.wHour = systime.wHour;
+ fxtime.wMilliseconds = systime.wMilliseconds;
+ fxtime.wMinute = systime.wMinute;
+ fxtime.wMonth = systime.wMonth;
+ fxtime.wSecond = systime.wSecond;
+ fxtime.wYear = systime.wYear;
+ }
+ return fxtime;
+ }
+
+ void FFI_OnChange()
+ {
+ if (m_pInfo && m_pInfo->FFI_OnChange)
+ m_pInfo->FFI_OnChange(m_pInfo);
+ }
+
+ FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) const
+ {
+ return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0;
+ }
+
+ FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) const
+ {
+ return (nFlag & FWL_EVENTFLAG_ControlKey) != 0;
+ }
+
+ FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) const
+ {
+ return (nFlag & FWL_EVENTFLAG_AltKey) != 0;
+ }
+
+ FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) const
+ {
+ return FALSE;
+ }
+
+ int JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon);
+ int JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, const FX_WCHAR* Default,
+ const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* response, int length);
+
+ void JS_appBeep(int nType)
+ {
+ if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep)
+ m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType);
+ }
CFX_WideString JS_fieldBrowse();
-
CFX_WideString JS_docGetFilePath();
- void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL)
- {
- if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_submitForm)
- {
- CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode();
- FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestination.GetBuffer(bsDestination.GetLength());
- m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, length, pDestination);
- bsDestination.ReleaseBuffer();
- }
- }
-
- void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,const FX_WCHAR* To, const FX_WCHAR* Subject, const FX_WCHAR* CC, const FX_WCHAR* BCC, const FX_WCHAR* Msg)
- {
- if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_mail)
- {
- CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode();
- CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_Encode();
- CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode();
- CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode();
- CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
- FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength());
- FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength());
- FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength());
- FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength());
- FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
- m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, length, bUI, pTo, pSubject,
- pCC, pBcc, pMsg);
- bsTo.ReleaseBuffer();
- bsCC.ReleaseBuffer();
- bsBcc.ReleaseBuffer();
- bsSubject.ReleaseBuffer();
- bsMsg.ReleaseBuffer();
- }
- }
-
- void JS_docprint(FPDF_BOOL bUI , int nStart, int nEnd, FPDF_BOOL bSilent ,FPDF_BOOL bShrinkToFit,FPDF_BOOL bPrintAsImage ,FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations)
- {
- if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print)
- {
- m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations);
- }
- }
- void JS_docgotoPage(int nPageNum)
- {
- if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_gotoPage)
- {
- m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum);
- }
- }
-
- FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex)
- {
- if(m_pInfo && m_pInfo->FFI_GetPage)
- {
- return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex);
- }
- return NULL;
- }
-
- FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document)
- {
- if(m_pInfo && m_pInfo->FFI_GetCurrentPage)
- {
- return m_pInfo->FFI_GetCurrentPage(m_pInfo, document);
- }
- return NULL;
- }
-
- int FFI_GetRotation(FPDF_PAGE page)
- {
- if(m_pInfo && m_pInfo->FFI_GetRotation)
- {
- return m_pInfo->FFI_GetRotation(m_pInfo, page);
- }
- return 0;
- }
- void FFI_ExecuteNamedAction(const FX_CHAR* namedAction)
- {
- if(m_pInfo && m_pInfo->FFI_ExecuteNamedAction)
- {
- m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction);
- }
- }
- void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, FX_BOOL bFocus)
- {
- if(m_pInfo && m_pInfo->FFI_SetTextFieldFocus)
- {
- m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus);
- }
- }
-
- void FFI_DoURIAction(const FX_CHAR* bsURI)
- {
- if(m_pInfo && m_pInfo->FFI_DoURIAction)
- {
- m_pInfo->FFI_DoURIAction(m_pInfo, bsURI);
- }
- }
-
- void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int sizeOfArray)
- {
- if(m_pInfo && m_pInfo->FFI_DoGoToAction)
- {
- m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray);
- }
- }
-
- FX_BOOL IsJSInitiated();
-
- void SetCurrentDoc(CPDFSDK_Document* pFXDoc) {m_pSDKDoc = pFXDoc;}
- CPDFSDK_Document* GetCurrentDoc();
- CPDF_Document* GetPDFDocument() {return m_pPDFDoc;}
-
- CFX_ByteString GetAppName() {return "";}
-
- CFFL_IFormFiller* GetIFormFiller();
- IFX_SystemHandler* GetSysHandler() {return m_pSysHandler;}
-
- CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr();
- IFXJS_Runtime* GetJSRuntime();
- CPDFSDK_ActionHandler* GetActionHander();
- FPDF_FORMFILLINFO* GetFormFillInfo() {return m_pInfo;}
+ void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL);
+ void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,
+ const FX_WCHAR* To, const FX_WCHAR* Subject,
+ const FX_WCHAR* CC, const FX_WCHAR* BCC,
+ const FX_WCHAR* Msg);
+
+ void JS_docprint(FPDF_BOOL bUI, int nStart, int nEnd, FPDF_BOOL bSilent,
+ FPDF_BOOL bShrinkToFit, FPDF_BOOL bPrintAsImage,
+ FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations)
+ {
+ if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print)
+ m_pInfo->m_pJsPlatform->Doc_print(
+ m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, bSilent, bShrinkToFit,
+ bPrintAsImage, bReverse, bAnnotations);
+ }
+
+ void JS_docgotoPage(int nPageNum)
+ {
+ if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_gotoPage)
+ m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum);
+ }
+
+ FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document, int nPageIndex)
+ {
+ if (m_pInfo && m_pInfo->FFI_GetPage)
+ return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex);
+ return NULL;
+ }
+
+ FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document)
+ {
+ if (m_pInfo && m_pInfo->FFI_GetCurrentPage)
+ return m_pInfo->FFI_GetCurrentPage(m_pInfo, document);
+ return NULL;
+ }
+
+ int FFI_GetRotation(FPDF_PAGE page)
+ {
+ if (m_pInfo && m_pInfo->FFI_GetRotation)
+ return m_pInfo->FFI_GetRotation(m_pInfo, page);
+ return 0;
+ }
+
+ void FFI_ExecuteNamedAction(const FX_CHAR* namedAction)
+ {
+ if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction)
+ m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction);
+ }
+
+ void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, FX_BOOL bFocus)
+ {
+ if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus)
+ m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus);
+ }
+
+ void FFI_DoURIAction(const FX_CHAR* bsURI)
+ {
+ if (m_pInfo && m_pInfo->FFI_DoURIAction)
+ m_pInfo->FFI_DoURIAction(m_pInfo, bsURI);
+ }
+
+ void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int sizeOfArray)
+ {
+ if (m_pInfo && m_pInfo->FFI_DoGoToAction)
+ m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray);
+ }
+
+ FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; }
+ void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; }
+ CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; }
+ CPDF_Document* GetPDFDocument() const { return m_pPDFDoc; }
+ CFX_ByteString GetAppName() const { return ""; }
+ IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler; }
+ FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo;}
+ CJS_RuntimeFactory* GetRuntimeFactory() const { return m_pJSRuntimeFactory; }
+
+ CFFL_IFormFiller* GetIFormFiller(); // Creates if not present.
+ CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present.
+ IFXJS_Runtime* GetJSRuntime(); // Creates if not present.
+ CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present.
private:
- CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr;
- CPDFSDK_ActionHandler* m_pActionHandler;
- IFXJS_Runtime* m_pJSRuntime;
- FPDF_FORMFILLINFO* m_pInfo;
- CPDFSDK_Document* m_pSDKDoc;
- CPDF_Document* m_pPDFDoc;
-
- CFFL_IFormFiller* m_pIFormFiller;
- IFX_SystemHandler* m_pSysHandler;
-
-public:
- CJS_RuntimeFactory* m_pJSRuntimeFactory;
+ CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr;
+ CPDFSDK_ActionHandler* m_pActionHandler;
+ IFXJS_Runtime* m_pJSRuntime;
+ FPDF_FORMFILLINFO* const m_pInfo;
+ CPDFSDK_Document* m_pSDKDoc;
+ CPDF_Document* const m_pPDFDoc;
+ CFFL_IFormFiller* m_pIFormFiller;
+ IFX_SystemHandler* m_pSysHandler;
+ CJS_RuntimeFactory* m_pJSRuntimeFactory;
};
-
-
-class CPDFSDK_InterForm;
class CPDFSDK_Document
{
public:
- CPDFSDK_Document(CPDF_Document* pDoc, CPDFDoc_Environment* pEnv);
- ~CPDFSDK_Document();
-
- CPDFSDK_InterForm* GetInterForm() ;
- CPDF_Document* GetDocument() {return m_pDoc;}
-
- CPDFSDK_PageView* GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew = TRUE);
- CPDFSDK_PageView* GetPageView(int nIndex);
- CPDFSDK_PageView* GetCurrentView();
- void ReMovePageView(CPDF_Page* pPDFPage);
- void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot);
-
- CPDFSDK_Annot* GetFocusAnnot();
-
- IFXJS_Runtime * GetJsRuntime();
-
- FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0);
- FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0);
-
- FX_BOOL ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc);
- FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages);
- FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages);
-
- void OnCloseDocument();
-
- int GetPageCount() {return m_pDoc->GetPageCount();}
- FX_BOOL GetPermissions(int nFlag);
- FX_BOOL GetChangeMark() {return m_bChangeMask;}
- void SetChangeMark() {m_bChangeMask = TRUE;}
- void ClearChangeMark() {m_bChangeMask= FALSE;}
- CFX_WideString GetPath() ;
- CPDF_Page* GetPage(int nIndex);
- CPDFDoc_Environment * GetEnv() {return m_pEnv; }
- void ProcJavascriptFun();
- FX_BOOL ProcOpenAction();
- CPDF_OCContext* GetOCContext();
+ CPDFSDK_Document(CPDF_Document* pDoc, CPDFDoc_Environment* pEnv);
+ ~CPDFSDK_Document();
+
+ CPDFSDK_InterForm* GetInterForm() ;
+ CPDF_Document* GetDocument() {return m_pDoc;}
+
+ CPDFSDK_PageView* GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew = TRUE);
+ CPDFSDK_PageView* GetPageView(int nIndex);
+ CPDFSDK_PageView* GetCurrentView();
+ void ReMovePageView(CPDF_Page* pPDFPage);
+ void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot);
+
+ CPDFSDK_Annot* GetFocusAnnot();
+
+ IFXJS_Runtime * GetJsRuntime();
+
+ FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0);
+ FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0);
+
+ FX_BOOL ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc);
+ FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages);
+ FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages);
+
+ void OnCloseDocument();
+
+ int GetPageCount() {return m_pDoc->GetPageCount();}
+ FX_BOOL GetPermissions(int nFlag);
+ FX_BOOL GetChangeMark() {return m_bChangeMask;}
+ void SetChangeMark() {m_bChangeMask = TRUE;}
+ void ClearChangeMark() {m_bChangeMask= FALSE;}
+ CFX_WideString GetPath() ;
+ CPDF_Page* GetPage(int nIndex);
+ CPDFDoc_Environment * GetEnv() {return m_pEnv; }
+ void ProcJavascriptFun();
+ FX_BOOL ProcOpenAction();
+ CPDF_OCContext* GetOCContext();
private:
std::map<CPDF_Page*, CPDFSDK_PageView*> m_pageMap;
CPDF_Document* m_pDoc;
@@ -366,44 +269,44 @@ private:
class CPDFSDK_PageView final
{
public:
- CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page);
- ~CPDFSDK_PageView();
- void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) ;
- CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
- CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
- CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
- CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
- CPDFSDK_Annot* GetFocusAnnot() ;
- void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot,FX_UINT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);}
- FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {return m_pSDKDoc->KillFocusAnnot(nFlag);}
- FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot);
-
- CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict);
- CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictionary * pDict);
- CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot);
- FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot);
- int CountAnnots();
- CPDFSDK_Annot* GetAnnot(int nIndex);
- CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict);
- CPDF_Page* GetPDFPage(){return m_page;}
- CPDF_Document* GetPDFDocument();
- CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;}
- FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag);
- FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag);
- FX_BOOL OnChar(int nChar, FX_UINT nFlag);
- FX_BOOL OnKeyDown(int nKeyCode, int nFlag);
- FX_BOOL OnKeyUp(int nKeyCode, int nFlag);
-
- FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag);
- FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag);
- FX_BOOL IsValidAnnot(void* p);
- void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;}
- void UpdateRects(CFX_RectArray& rects);
- void UpdateView(CPDFSDK_Annot* pAnnot);
- CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; }
-
- int GetPageIndex();
- void LoadFXAnnots();
+ CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page);
+ ~CPDFSDK_PageView();
+ void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) ;
+ CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
+ CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
+ CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
+ CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
+ CPDFSDK_Annot* GetFocusAnnot() ;
+ void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot,FX_UINT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);}
+ FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {return m_pSDKDoc->KillFocusAnnot(nFlag);}
+ FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot);
+
+ CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict);
+ CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictionary * pDict);
+ CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot);
+ FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot);
+ int CountAnnots();
+ CPDFSDK_Annot* GetAnnot(int nIndex);
+ CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict);
+ CPDF_Page* GetPDFPage(){return m_page;}
+ CPDF_Document* GetPDFDocument();
+ CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;}
+ FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag);
+ FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag);
+ FX_BOOL OnChar(int nChar, FX_UINT nFlag);
+ FX_BOOL OnKeyDown(int nKeyCode, int nFlag);
+ FX_BOOL OnKeyUp(int nKeyCode, int nFlag);
+
+ FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag);
+ FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag);
+ FX_BOOL IsValidAnnot(void* p);
+ void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;}
+ void UpdateRects(CFX_RectArray& rects);
+ void UpdateView(CPDFSDK_Annot* pAnnot);
+ CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; }
+
+ int GetPageIndex();
+ void LoadFXAnnots();
void SetValid(FX_BOOL bValid) {m_bValid = bValid;}
FX_BOOL IsValid() {return m_bValid;}
@@ -411,18 +314,18 @@ public:
FX_BOOL IsLocked() {return m_bLocked;}
void TakeOverPage() {m_bTakeOverPage = TRUE;}
private:
- void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widget* pWidget);
+ void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widget* pWidget);
CPDF_Matrix m_curMatrix;
- CPDF_Page* m_page;
- CPDF_AnnotList* m_pAnnotList;
- //CPDFSDK_Annot* m_pFocusAnnot;
- CFX_PtrArray m_fxAnnotArray;
- CPDFSDK_Document* m_pSDKDoc;
- CPDFSDK_Widget* m_CaptureWidget;
- FX_BOOL m_bEnterWidget;
- FX_BOOL m_bExitWidget;
- FX_BOOL m_bOnWidget;
- FX_BOOL m_bValid;
+ CPDF_Page* m_page;
+ CPDF_AnnotList* m_pAnnotList;
+ //CPDFSDK_Annot* m_pFocusAnnot;
+ CFX_PtrArray m_fxAnnotArray;
+ CPDFSDK_Document* m_pSDKDoc;
+ CPDFSDK_Widget* m_CaptureWidget;
+ FX_BOOL m_bEnterWidget;
+ FX_BOOL m_bExitWidget;
+ FX_BOOL m_bOnWidget;
+ FX_BOOL m_bValid;
FX_BOOL m_bLocked;
FX_BOOL m_bTakeOverPage;
};
@@ -432,80 +335,80 @@ template<class TYPE>
class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE>
{
public:
- CGW_ArrayTemplate(){}
- virtual ~CGW_ArrayTemplate(){}
+ CGW_ArrayTemplate(){}
+ virtual ~CGW_ArrayTemplate(){}
- typedef int (*LP_COMPARE)(TYPE p1, TYPE p2);
+ typedef int (*LP_COMPARE)(TYPE p1, TYPE p2);
- void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE)
- {
- int nSize = this->GetSize();
- QuickSort(0, nSize -1, bAscent, pCompare);
- }
+ void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE)
+ {
+ int nSize = this->GetSize();
+ QuickSort(0, nSize -1, bAscent, pCompare);
+ }
private:
- void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_COMPARE pCompare)
- {
- if (nStartPos >= nStopPos) return;
-
- if ((nStopPos - nStartPos) == 1)
- {
- TYPE Value1 = this->GetAt(nStartPos);
- TYPE Value2 = this->GetAt(nStopPos);
-
- int iGreate = (*pCompare)(Value1, Value2);
- if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0))
- {
- this->SetAt(nStartPos, Value2);
- this->SetAt(nStopPos, Value1);
- }
- return;
- }
-
- FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2;
- FX_UINT i = nStartPos;
-
- TYPE Value = this->GetAt(m);
-
- while (i < m)
- {
- TYPE temp = this->GetAt(i);
-
- int iGreate = (*pCompare)(temp, Value);
- if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0))
- {
- this->InsertAt(m+1, temp);
- this->RemoveAt(i);
- m--;
- }
- else
- {
- i++;
- }
- }
-
- FX_UINT j = nStopPos;
-
- while (j > m)
- {
- TYPE temp = this->GetAt(j);
-
- int iGreate = (*pCompare)(temp, Value);
- if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0))
- {
- this->RemoveAt(j);
- this->InsertAt(m, temp);
- m++;
- }
- else
- {
- j--;
- }
- }
-
- if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare);
- if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare);
- }
+ void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_COMPARE pCompare)
+ {
+ if (nStartPos >= nStopPos) return;
+
+ if ((nStopPos - nStartPos) == 1)
+ {
+ TYPE Value1 = this->GetAt(nStartPos);
+ TYPE Value2 = this->GetAt(nStopPos);
+
+ int iGreate = (*pCompare)(Value1, Value2);
+ if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0))
+ {
+ this->SetAt(nStartPos, Value2);
+ this->SetAt(nStopPos, Value1);
+ }
+ return;
+ }
+
+ FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2;
+ FX_UINT i = nStartPos;
+
+ TYPE Value = this->GetAt(m);
+
+ while (i < m)
+ {
+ TYPE temp = this->GetAt(i);
+
+ int iGreate = (*pCompare)(temp, Value);
+ if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0))
+ {
+ this->InsertAt(m+1, temp);
+ this->RemoveAt(i);
+ m--;
+ }
+ else
+ {
+ i++;
+ }
+ }
+
+ FX_UINT j = nStopPos;
+
+ while (j > m)
+ {
+ TYPE temp = this->GetAt(j);
+
+ int iGreate = (*pCompare)(temp, Value);
+ if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0))
+ {
+ this->RemoveAt(j);
+ this->InsertAt(m, temp);
+ m++;
+ }
+ else
+ {
+ j--;
+ }
+ }
+
+ if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare);
+ if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare);
+ }
};
#endif // FPDFSDK_INCLUDE_FSDK_MGR_H_
diff --git a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
index 1b152d7b4b..c6cae08781 100644
--- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
@@ -9,21 +9,21 @@
#include "../../include/formfiller/FFL_Notify.h"
#include "../../include/formfiller/FFL_CBA_Fontmap.h"
-#define GetRed(rgb) ((uint8_t)(rgb))
-#define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8))
-#define GetBlue(rgb) ((uint8_t)((rgb)>>16))
+#define GetRed(rgb) ((uint8_t)(rgb))
+#define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8))
+#define GetBlue(rgb) ((uint8_t)((rgb)>>16))
-#define FFL_HINT_ELAPSE 800
+#define FFL_HINT_ELAPSE 800
/* ------------------------- CFFL_FormFiller ------------------------- */
CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot)
- :m_pApp(pApp),
- m_pAnnot(pAnnot),
- m_bValid(FALSE),
- m_ptOldPos(0,0)
+ : m_pApp(pApp),
+ m_pAnnot(pAnnot),
+ m_bValid(FALSE),
+ m_ptOldPos(0,0)
{
- m_pWidget = (CPDFSDK_Widget*) pAnnot;
+ m_pWidget = (CPDFSDK_Widget*) pAnnot;
}
CFFL_FormFiller::~CFFL_FormFiller()
@@ -40,75 +40,72 @@ CFFL_FormFiller::~CFFL_FormFiller()
void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect& rcWindow)
{
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
- {
- pWnd->Move(CPDF_Rect(rcWindow), TRUE, FALSE);
- }
+ if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ pWnd->Move(CPDF_Rect(rcWindow), TRUE, FALSE);
+ }
}
CPDF_Rect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView)
{
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
- {
- return pWnd->GetWindowRect();
- }
+ if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ return pWnd->GetWindowRect();
+ }
- return CPDF_Rect(0,0,0,0);
+ return CPDF_Rect(0,0,0,0);
}
FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
{
- ASSERT(pPageView != NULL);
- ASSERT(pAnnot != NULL);
+ ASSERT(pPageView != NULL);
+ ASSERT(pAnnot != NULL);
- CPDF_Rect rcAnnot = m_pWidget->GetRect();
+ CPDF_Rect rcAnnot = m_pWidget->GetRect();
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
- {
- CPDF_Rect rcWindow = pWnd->GetWindowRect();
- rcAnnot = PWLtoFFL(rcWindow);
- }
+ if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ CPDF_Rect rcWindow = pWnd->GetWindowRect();
+ rcAnnot = PWLtoFFL(rcWindow);
+ }
- CPDF_Rect rcWin = rcAnnot;
+ CPDF_Rect rcWin = rcAnnot;
- CPDF_Rect rcFocus = GetFocusBox(pPageView);
- if (!rcFocus.IsEmpty())
- rcWin.Union(rcFocus);
+ CPDF_Rect rcFocus = GetFocusBox(pPageView);
+ if (!rcFocus.IsEmpty())
+ rcWin.Union(rcFocus);
- CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin,1);
+ CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin,1);
- return rect.GetOutterRect();
+ return rect.GetOutterRect();
}
-void CFFL_FormFiller::OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow,*/ FX_DWORD dwFlags)
+void CFFL_FormFiller::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ FX_DWORD dwFlags)
{
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+ ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
- {
- CPDF_Matrix mt = GetCurMatrix();
- mt.Concat(*pUser2Device);
- pWnd->DrawAppearance(pDevice,&mt);
- }
- else
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (CFFL_IFormFiller::IsVisible(pWidget))
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- }
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ CPDF_Matrix mt = GetCurMatrix();
+ mt.Concat(*pUser2Device);
+ pWnd->DrawAppearance(pDevice,&mt);
+ }
+ else
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (CFFL_IFormFiller::IsVisible(pWidget))
+ pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ }
}
-void CFFL_FormFiller::OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow,*/ FX_DWORD dwFlags)
+void CFFL_FormFiller::OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ FX_DWORD dwFlags)
{
- ASSERT(pAnnot != NULL);
-
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
-
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
}
@@ -130,265 +127,247 @@ void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
{
- EndTimer();
- ASSERT(m_pWidget != NULL);
+ EndTimer();
+ ASSERT(m_pWidget != NULL);
}
FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE))
- {
- m_bValid = TRUE;
- FX_RECT rect = GetViewBBox(pPageView,pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE))
+ {
+ m_bValid = TRUE;
+ FX_RECT rect = GetViewBBox(pPageView,pAnnot);
+ InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
- if(!rect.Contains((int)point.x, (int)point.y))
- return FALSE;
+ if(!rect.Contains((int)point.x, (int)point.y))
+ return FALSE;
- return pWnd->OnLButtonDown(WndtoPWL(pPageView, point),nFlags);
- }
+ return pWnd->OnLButtonDown(WndtoPWL(pPageView, point),nFlags);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
- {
- FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom);
- pWnd->OnLButtonUp(WndtoPWL(pPageView, point),nFlags);
- return TRUE;
- }
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot);
+ InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom);
+ pWnd->OnLButtonUp(WndtoPWL(pPageView, point),nFlags);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
- {
- pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point),nFlags);
- return TRUE;
- }
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point),nFlags);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y))
- {
- m_ptOldPos = point;
- }
+ if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y))
+ {
+ m_ptOldPos = point;
+ }
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
- {
- pWnd->OnMouseMove(WndtoPWL(pPageView, point),nFlags);
- return TRUE;
- }
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ pWnd->OnMouseMove(WndtoPWL(pPageView, point),nFlags);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point)
{
- if (!IsValid()) return FALSE;
+ if (!IsValid()) return FALSE;
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE))
- {
- return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point),nFlags);
- }
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE))
+ {
+ return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point),nFlags);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE))
- {
- pWnd->OnRButtonDown(WndtoPWL(pPageView, point),nFlags);
- return TRUE;
- }
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE))
+ {
+ pWnd->OnRButtonDown(WndtoPWL(pPageView, point),nFlags);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
- {
- pWnd->OnRButtonUp(WndtoPWL(pPageView, point),nFlags);
- return TRUE;
- }
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ pWnd->OnRButtonUp(WndtoPWL(pPageView, point),nFlags);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags)
{
- if (IsValid())
- {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView != NULL);
+ if (IsValid())
+ {
+ CPDFSDK_PageView* pPageView = GetCurPageView();
+ ASSERT(pPageView != NULL);
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
- {
- return pWnd->OnKeyDown(nKeyCode,nFlags);
- }
- }
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ return pWnd->OnKeyDown(nKeyCode,nFlags);
+ }
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
+FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
{
- if (IsValid())
- {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView != NULL);
+ if (IsValid())
+ {
+ CPDFSDK_PageView* pPageView = GetCurPageView();
+ ASSERT(pPageView != NULL);
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
- {
- return pWnd->OnChar(nChar,nFlags);
- }
- }
+ if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ return pWnd->OnChar(nChar,nFlags);
+ }
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_FormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
+FX_BOOL CFFL_FormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
{
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
-
- CPDF_Page * pPage = pWidget->GetPDFPage();
- CPDFSDK_Document * pDoc = m_pApp->GetCurrentDoc();
- CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage);
- ASSERT(pPageView != NULL);
-
- CPWL_Wnd * pWnd = NULL;
- if ( (pWnd = GetPDFWindow(pPageView, TRUE)))
- {
- pWnd->SetFocus();
- }
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ CPDF_Page* pPage = pWidget->GetPDFPage();
+ CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument();
+ CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage);
+ if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE))
+ pWnd->SetFocus();
- m_bValid = TRUE;
- FX_RECT rcRect = GetViewBBox(pPageView,pAnnot);
- InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
-
- return TRUE;
+ m_bValid = TRUE;
+ FX_RECT rcRect = GetViewBBox(pPageView,pAnnot);
+ InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
+ return TRUE;
}
-FX_BOOL CFFL_FormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
+FX_BOOL CFFL_FormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
{
- if (IsValid())
- {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView != NULL);
-
- CommitData(pPageView, nFlag);
+ if (!IsValid())
+ return TRUE;
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
- {
- pWnd->KillFocus();
- }
+ CPDFSDK_PageView* pPageView = GetCurPageView();
+ CommitData(pPageView, nFlag);
- switch (m_pWidget->GetFieldType())
- {
- case FIELDTYPE_PUSHBUTTON:
- case FIELDTYPE_CHECKBOX:
- case FIELDTYPE_RADIOBUTTON:
- EscapeFiller(pPageView, TRUE);
- break;
- default:
- EscapeFiller(pPageView, FALSE);
- break;
- }
- }
+ if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
+ pWnd->KillFocus();
- return TRUE;
+ switch (m_pWidget->GetFieldType())
+ {
+ case FIELDTYPE_PUSHBUTTON:
+ case FIELDTYPE_CHECKBOX:
+ case FIELDTYPE_RADIOBUTTON:
+ EscapeFiller(pPageView, TRUE);
+ break;
+ default:
+ EscapeFiller(pPageView, FALSE);
+ break;
+ }
+ return TRUE;
}
-FX_BOOL CFFL_FormFiller::IsValid() const
+FX_BOOL CFFL_FormFiller::IsValid() const
{
- return m_bValid;
+ return m_bValid;
}
-PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam()
+PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam()
{
- ASSERT(m_pApp != NULL);
-
- PWL_CREATEPARAM cp;
-
- cp.pParentWnd = NULL;
- cp.pProvider = this;
- cp.rcRectWnd = GetPDFWindowRect();
-
- FX_DWORD dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE;
-
- ASSERT(m_pWidget != NULL);
-
-
- FX_DWORD dwFieldFlag = m_pWidget->GetFieldFlags();
-
- if (dwFieldFlag & FIELDFLAG_READONLY)
- {
- dwCreateFlags |= PWS_READONLY;
- }
+ ASSERT(m_pApp != NULL);
- FX_COLORREF color;
- if (m_pWidget->GetFillColor(color))
- {
- cp.sBackgroundColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color));
- }
+ PWL_CREATEPARAM cp;
+ cp.pParentWnd = NULL;
+ cp.pProvider = this;
+ cp.rcRectWnd = GetPDFWindowRect();
- if (m_pWidget->GetBorderColor(color))
- {
- cp.sBorderColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color));
- }
+ FX_DWORD dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE;
+ FX_DWORD dwFieldFlag = m_pWidget->GetFieldFlags();
+ if (dwFieldFlag & FIELDFLAG_READONLY)
+ {
+ dwCreateFlags |= PWS_READONLY;
+ }
- cp.sTextColor = CPWL_Color(COLORTYPE_GRAY,0);
+ FX_COLORREF color;
+ if (m_pWidget->GetFillColor(color))
+ {
+ cp.sBackgroundColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color));
+ }
- if (m_pWidget->GetTextColor(color))
- {
- cp.sTextColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color));
- }
+ if (m_pWidget->GetBorderColor(color))
+ {
+ cp.sBorderColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color));
+ }
- cp.fFontSize = m_pWidget->GetFontSize();
- cp.dwBorderWidth = m_pWidget->GetBorderWidth();
+ cp.sTextColor = CPWL_Color(COLORTYPE_GRAY,0);
- int nBorderStyle = m_pWidget->GetBorderStyle();
+ if (m_pWidget->GetTextColor(color))
+ {
+ cp.sTextColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color));
+ }
- switch (nBorderStyle)
- {
- case BBS_SOLID:
- cp.nBorderStyle = PBS_SOLID;
- break;
- case BBS_DASH:
- cp.nBorderStyle = PBS_DASH;
- cp.sDash = CPWL_Dash(3,3,0);
- break;
- case BBS_BEVELED:
- cp.nBorderStyle = PBS_BEVELED;
- cp.dwBorderWidth *= 2;
- break;
- case BBS_INSET:
- cp.nBorderStyle = PBS_INSET;
- cp.dwBorderWidth *= 2;
- break;
- case BBS_UNDERLINE:
- cp.nBorderStyle = PBS_UNDERLINED;
- break;
- }
+ cp.fFontSize = m_pWidget->GetFontSize();
+ cp.dwBorderWidth = m_pWidget->GetBorderWidth();
+
+ int nBorderStyle = m_pWidget->GetBorderStyle();
+
+ switch (nBorderStyle)
+ {
+ case BBS_SOLID:
+ cp.nBorderStyle = PBS_SOLID;
+ break;
+ case BBS_DASH:
+ cp.nBorderStyle = PBS_DASH;
+ cp.sDash = CPWL_Dash(3,3,0);
+ break;
+ case BBS_BEVELED:
+ cp.nBorderStyle = PBS_BEVELED;
+ cp.dwBorderWidth *= 2;
+ break;
+ case BBS_INSET:
+ cp.nBorderStyle = PBS_INSET;
+ cp.dwBorderWidth *= 2;
+ break;
+ case BBS_UNDERLINE:
+ cp.nBorderStyle = PBS_UNDERLINED;
+ break;
+ }
- if (cp.fFontSize <= 0)
- {
- dwCreateFlags |= PWS_AUTOFONTSIZE;
- }
+ if (cp.fFontSize <= 0)
+ {
+ dwCreateFlags |= PWS_AUTOFONTSIZE;
+ }
- cp.dwFlags = dwCreateFlags;
- cp.pSystemHandler = m_pApp->GetSysHandler();
- return cp;
+ cp.dwFlags = dwCreateFlags;
+ cp.pSystemHandler = m_pApp->GetSysHandler();
+ return cp;
}
CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew)
@@ -442,218 +421,184 @@ void CFFL_FormFiller::DestroyPDFWindow(CPDFSDK_PageView* pPageView)
m_Maps.erase(it);
}
-CPDF_Matrix CFFL_FormFiller::GetWindowMatrix(void* pAttachedData)
+CPDF_Matrix CFFL_FormFiller::GetWindowMatrix(void* pAttachedData)
{
- if (CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pAttachedData)
- {
- if (pPrivateData->pPageView)
- {
- CPDF_Matrix mtPageView;
- pPrivateData->pPageView->GetCurrentMatrix(mtPageView);
- CPDF_Matrix mt = GetCurMatrix();
- mt.Concat(mtPageView);
+ if (CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pAttachedData)
+ {
+ if (pPrivateData->pPageView)
+ {
+ CPDF_Matrix mtPageView;
+ pPrivateData->pPageView->GetCurrentMatrix(mtPageView);
+ CPDF_Matrix mt = GetCurMatrix();
+ mt.Concat(mtPageView);
- return mt;
- }
- }
- return CPDF_Matrix(1,0,0,1,0,0);
+ return mt;
+ }
+ }
+ return CPDF_Matrix(1,0,0,1,0,0);
}
-CPDF_Matrix CFFL_FormFiller::GetCurMatrix()
+CPDF_Matrix CFFL_FormFiller::GetCurMatrix()
{
- CPDF_Matrix mt;
+ CPDF_Matrix mt;
- ASSERT(m_pWidget != NULL);
+ ASSERT(m_pWidget != NULL);
- CPDF_Rect rcDA ;
- m_pWidget->GetPDFAnnot()->GetRect(rcDA);
+ CPDF_Rect rcDA ;
+ m_pWidget->GetPDFAnnot()->GetRect(rcDA);
- switch (m_pWidget->GetRotate())
- {
- default:
- case 0:
- mt = CPDF_Matrix(1,0,0,1,0,0);
- break;
- case 90:
- mt = CPDF_Matrix(0,1,-1,0,rcDA.right - rcDA.left,0);
- break;
- case 180:
- mt = CPDF_Matrix(-1,0,0,-1,rcDA.right - rcDA.left,rcDA.top - rcDA.bottom);
- break;
- case 270:
- mt = CPDF_Matrix(0,-1,1,0,0,rcDA.top - rcDA.bottom);
- break;
- }
- mt.e += rcDA.left;
- mt.f += rcDA.bottom;
+ switch (m_pWidget->GetRotate())
+ {
+ default:
+ case 0:
+ mt = CPDF_Matrix(1,0,0,1,0,0);
+ break;
+ case 90:
+ mt = CPDF_Matrix(0,1,-1,0,rcDA.right - rcDA.left,0);
+ break;
+ case 180:
+ mt = CPDF_Matrix(-1,0,0,-1,rcDA.right - rcDA.left,rcDA.top - rcDA.bottom);
+ break;
+ case 270:
+ mt = CPDF_Matrix(0,-1,1,0,0,rcDA.top - rcDA.bottom);
+ break;
+ }
+ mt.e += rcDA.left;
+ mt.f += rcDA.bottom;
- return mt;
+ return mt;
}
CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex)
{
- ASSERT(m_pApp != NULL);
+ ASSERT(m_pApp != NULL);
- return L"";
+ return L"";
}
CPDF_Rect CFFL_FormFiller::GetPDFWindowRect() const
{
- ASSERT(m_pWidget != NULL);
+ CPDF_Rect rectAnnot;
+ m_pWidget->GetPDFAnnot()->GetRect(rectAnnot);
- CPDF_Rect rectAnnot;
- m_pWidget->GetPDFAnnot()->GetRect(rectAnnot);
+ FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left;
+ FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom;
+ if ((m_pWidget->GetRotate() / 90) & 0x01)
+ return CPDF_Rect(0, 0, fHeight, fWidth);
- FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left;
- FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom;
-
-
- if ((m_pWidget->GetRotate() / 90) & 0x01)
- return CPDF_Rect(0,0,fHeight,fWidth);
- else
- return CPDF_Rect(0,0,fWidth,fHeight);
+ return CPDF_Rect(0, 0, fWidth, fHeight);
}
CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView()
{
-
- CPDF_Page* pPage = m_pAnnot->GetPDFPage();
- CPDFSDK_Document* pSDKDoc = m_pApp->GetCurrentDoc();
- if(pSDKDoc)
- {
- return pSDKDoc->GetPageView(pPage);
- }
- return NULL;
+ CPDF_Page* pPage = m_pAnnot->GetPDFPage();
+ CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument();
+ return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr;
}
CPDF_Rect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView)
{
- if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE))
- {
- CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect()));
- ASSERT(pPageView);
- CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox();
- if(rcPage.Contains(rcFocus))
- return rcFocus;
- else
- return CPDF_Rect(0,0,0,0);
- }
- return CPDF_Rect(0,0,0,0);
+ if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
+ {
+ CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect()));
+ CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox();
+ if (rcPage.Contains(rcFocus))
+ return rcFocus;
+ }
+ return CPDF_Rect(0,0,0,0);
}
CPDF_Rect CFFL_FormFiller::FFLtoPWL(const CPDF_Rect& rect)
{
- CPDF_Matrix mt;
- mt.SetReverse(GetCurMatrix());
+ CPDF_Matrix mt;
+ mt.SetReverse(GetCurMatrix());
- CPDF_Rect temp = rect;
- mt.TransformRect(temp);
+ CPDF_Rect temp = rect;
+ mt.TransformRect(temp);
- return temp;
+ return temp;
}
CPDF_Rect CFFL_FormFiller::PWLtoFFL(const CPDF_Rect& rect)
{
- CPDF_Matrix mt = GetCurMatrix();
+ CPDF_Matrix mt = GetCurMatrix();
- CPDF_Rect temp = rect;
- mt.TransformRect(temp);
+ CPDF_Rect temp = rect;
+ mt.TransformRect(temp);
- return temp;
+ return temp;
}
CPDF_Point CFFL_FormFiller::FFLtoPWL(const CPDF_Point& point)
{
- CPDF_Matrix mt;
- mt.SetReverse(GetCurMatrix());
+ CPDF_Matrix mt;
+ mt.SetReverse(GetCurMatrix());
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
+ CPDF_Point pt = point;
+ mt.Transform(pt.x,pt.y);
- return pt;
+ return pt;
}
CPDF_Point CFFL_FormFiller::PWLtoFFL(const CPDF_Point & point)
{
- CPDF_Matrix mt = GetCurMatrix();
+ CPDF_Matrix mt = GetCurMatrix();
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
+ CPDF_Point pt = point;
+ mt.Transform(pt.x,pt.y);
- return pt;
+ return pt;
}
CPDF_Point CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Point& pt)
{
-// ASSERT(pPageView != NULL);
-//
-// CPDF_Point point(0.0f, 0.0f);
-// pPageView->WindowToDoc(pt.x, pt.y, point.x, point.y);
-//
- return FFLtoPWL(pt);
-// return CPDF_Point(0, 0);
+ return FFLtoPWL(pt);
}
CPDF_Rect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect & rect)
{
-// FX_RECT rcRet(0,0,0,0);
-//
-// ASSERT(pPageView != NULL);
-// pPageView->DocToWindow(rect, rcRet);
-//
- return rect;
-
-}
-
-void CFFL_FormFiller::FFL_FreeData(void* pData)
-{
- ASSERT(pData != NULL);
-
- delete (CFFL_PrivateData*)pData;
+ return rect;
}
FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag)
{
- if (IsDataChanged(pPageView))
- {
- //CFFL_IFormFiller* pIFormFiller = CFFL_Module::GetFormFiller(m_pApp);
- CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();//NULL;
- ASSERT(pIFormFiller != NULL);
-
- FX_BOOL bRC = TRUE;
- FX_BOOL bExit = FALSE;
-
- pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag);
- if (bExit) return TRUE;
- if (!bRC)
- {
- ResetPDFWindow(pPageView, FALSE);
- return TRUE;
- }
-
- pIFormFiller->OnValidate(m_pWidget, pPageView, bRC, bExit, nFlag);
- if (bExit) return TRUE;
- if (!bRC)
- {
- ResetPDFWindow(pPageView, FALSE);
- return TRUE;
- }
-
- SaveData(pPageView);
-
- pIFormFiller->OnCalculate(m_pWidget, pPageView, bExit,nFlag);
- if (bExit) return TRUE;
-
- pIFormFiller->OnFormat(m_pWidget, pPageView, bExit,nFlag);
- }
-
- return TRUE;
+ if (IsDataChanged(pPageView))
+ {
+ FX_BOOL bRC = TRUE;
+ FX_BOOL bExit = FALSE;
+ CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
+ pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag);
+ if (bExit)
+ return TRUE;
+ if (!bRC)
+ {
+ ResetPDFWindow(pPageView, FALSE);
+ return TRUE;
+ }
+
+ pIFormFiller->OnValidate(m_pWidget, pPageView, bRC, bExit, nFlag);
+ if (bExit)
+ return TRUE;
+ if (!bRC)
+ {
+ ResetPDFWindow(pPageView, FALSE);
+ return TRUE;
+ }
+
+ SaveData(pPageView);
+ pIFormFiller->OnCalculate(m_pWidget, pPageView, bExit,nFlag);
+ if (bExit)
+ return TRUE;
+
+ pIFormFiller->OnFormat(m_pWidget, pPageView, bExit,nFlag);
+ }
+ return TRUE;
}
-FX_BOOL CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView)
+FX_BOOL CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView)
{
- return FALSE;
+ return FALSE;
}
void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView)
@@ -666,24 +611,24 @@ void CFFL_FormFiller::GetKeyStrokeData(CPDFSDK_PageView* pPageView, FFL_KeyStrok
void CFFL_FormFiller::SetChangeMark()
{
- m_pApp->FFI_OnChange();
+ m_pApp->FFI_OnChange();
}
void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type,
- PDFSDK_FieldAction& fa)
+ PDFSDK_FieldAction& fa)
{
- fa.sValue = m_pWidget->GetValue();
+ fa.sValue = m_pWidget->GetValue();
}
void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& fa)
+ const PDFSDK_FieldAction& fa)
{
}
-FX_BOOL CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld,
- const PDFSDK_FieldAction& faNew)
+FX_BOOL CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld,
+ const PDFSDK_FieldAction& faNew)
{
- return FALSE;
+ return FALSE;
}
void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView)
@@ -696,7 +641,7 @@ void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView)
CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue)
{
- return GetPDFWindow(pPageView, FALSE);
+ return GetPDFWindow(pPageView, FALSE);
}
void CFFL_FormFiller::TimerProc()
@@ -706,8 +651,7 @@ void CFFL_FormFiller::TimerProc()
IFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const
{
- return m_pApp->GetSysHandler();
-// return NULL;
+ return m_pApp->GetSysHandler();
}
void CFFL_FormFiller::OnKeyStroke(FX_BOOL bKeyDown)
@@ -716,28 +660,28 @@ void CFFL_FormFiller::OnKeyStroke(FX_BOOL bKeyDown)
void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroyPDFWindow)
{
- m_bValid = FALSE;
+ m_bValid = FALSE;
- FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget);
- InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
+ FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget);
+ InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
- if(bDestroyPDFWindow)
- DestroyPDFWindow(pPageView);
+ if(bDestroyPDFWindow)
+ DestroyPDFWindow(pPageView);
}
FX_BOOL CFFL_FormFiller::CanCopy(CPDFSDK_Document* pDocument)
{
- return FALSE;
+ return FALSE;
}
FX_BOOL CFFL_FormFiller::CanCut(CPDFSDK_Document* pDocument)
{
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFFL_FormFiller::CanPaste(CPDFSDK_Document* pDocument)
+FX_BOOL CFFL_FormFiller::CanPaste(CPDFSDK_Document* pDocument)
{
- return FALSE;
+ return FALSE;
}
void CFFL_FormFiller::DoCopy(CPDFSDK_Document* pDocument)
@@ -754,16 +698,16 @@ void CFFL_FormFiller::DoPaste(CPDFSDK_Document* pDocument)
void CFFL_FormFiller::InvalidateRect(double left, double top, double right, double bottom)
{
- CPDF_Page * pPage = m_pWidget->GetPDFPage();
- m_pApp->FFI_Invalidate(pPage, left, top, right, bottom);
+ CPDF_Page * pPage = m_pWidget->GetPDFPage();
+ m_pApp->FFI_Invalidate(pPage, left, top, right, bottom);
}
/* ------------------------- CFFL_Button ------------------------- */
CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) :
- CFFL_FormFiller(pApp, pWidget),
- m_bMouseIn(FALSE),
- m_bMouseDown(FALSE)
+ CFFL_FormFiller(pApp, pWidget),
+ m_bMouseIn(FALSE),
+ m_bMouseDown(FALSE)
{
}
@@ -773,99 +717,94 @@ CFFL_Button::~CFFL_Button()
void CFFL_Button::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
{
- m_bMouseIn = TRUE;
- FX_RECT rect = GetViewBBox(pPageView,pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
+ m_bMouseIn = TRUE;
+ FX_RECT rect = GetViewBBox(pPageView,pAnnot);
+ InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
}
void CFFL_Button::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
{
- m_bMouseIn = FALSE;
+ m_bMouseIn = FALSE;
- FX_RECT rect = GetViewBBox(pPageView,pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
- EndTimer();
- ASSERT(m_pWidget != NULL);
+ FX_RECT rect = GetViewBBox(pPageView,pAnnot);
+ InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
+ EndTimer();
+ ASSERT(m_pWidget != NULL);
}
FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- CPDF_Rect rcAnnot = pAnnot->GetRect();
- if(!rcAnnot.Contains(point.x, point.y))
- return FALSE;
+ CPDF_Rect rcAnnot = pAnnot->GetRect();
+ if(!rcAnnot.Contains(point.x, point.y))
+ return FALSE;
- m_bMouseDown = TRUE;
- m_bValid = TRUE;
- FX_RECT rect = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
- return TRUE;
+ m_bMouseDown = TRUE;
+ m_bValid = TRUE;
+ FX_RECT rect = GetViewBBox(pPageView, pAnnot);
+ InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
+ return TRUE;
}
-FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- CPDF_Rect rcAnnot = pAnnot->GetRect();
- if(!rcAnnot.Contains(point.x, point.y))
- return FALSE;
+ CPDF_Rect rcAnnot = pAnnot->GetRect();
+ if(!rcAnnot.Contains(point.x, point.y))
+ return FALSE;
- m_bMouseDown = FALSE;
- m_pWidget->GetPDFPage();
+ m_bMouseDown = FALSE;
+ m_pWidget->GetPDFPage();
- FX_RECT rect = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
- return TRUE;
+ FX_RECT rect = GetViewBBox(pPageView, pAnnot);
+ InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
+ return TRUE;
}
-FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(m_pApp != NULL);
+ ASSERT(m_pApp != NULL);
- return TRUE;
+ return TRUE;
}
-void CFFL_Button::OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow,*/ FX_DWORD dwFlags)
+void CFFL_Button::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ FX_DWORD dwFlags)
{
- ASSERT(pPageView != NULL);
- ASSERT(pAnnot != NULL);
-
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ ASSERT(pPageView != NULL);
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ CPDF_FormControl* pCtrl = pWidget->GetFormControl();
+ CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode();
- CPDF_FormControl* pCtrl = pWidget->GetFormControl();
- ASSERT(pCtrl != NULL);
-
- CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode();
-
- if (eHM == CPDF_FormControl::Push)
- {
- if (m_bMouseDown)
- {
- if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down))
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL);
- else
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- }
- else if (m_bMouseIn)
- {
- if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover))
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover, NULL);
- else
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- }
- else
- {
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- }
- }
- else
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ if (eHM == CPDF_FormControl::Push)
+ {
+ if (m_bMouseDown)
+ {
+ if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down))
+ pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL);
+ else
+ pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ }
+ else if (m_bMouseIn)
+ {
+ if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover))
+ pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover, NULL);
+ else
+ pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ }
+ else
+ {
+ pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ }
+ }
+ else
+ pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
}
-void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- /*const CRect& rcWindow, */FX_DWORD dwFlags)
+void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ FX_DWORD dwFlags)
{
- OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
+ OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
}
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index 078dd13c00..cd4b45b062 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -81,20 +81,15 @@ void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_
if (pFormFiller->IsValid())
{
pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
-
pAnnot->GetPDFPage();
-
- CPDFSDK_Document* pDocument = m_pApp->GetCurrentDoc();
- ASSERT(pDocument != NULL);
-
+ CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
if (pDocument->GetFocusAnnot() == pAnnot)
{
CPDF_Rect rcFocus = pFormFiller->GetFocusBox(pPageView);
if (!rcFocus.IsEmpty())
{
CFX_PathData path;
-
path.SetPointCount(5);
path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO);
path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO);
@@ -106,14 +101,10 @@ void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_
gsd.SetDashCount(1);
gsd.m_DashArray[0] = 1.0f;
gsd.m_DashPhase = 0;
-
gsd.m_LineWidth = 1.0f;
pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255,0,0,0), FXFILL_ALTERNATE);
-
- // ::DrawFocusRect(hDC, &rcFocus);
}
}
-
return;
}
}
@@ -124,10 +115,7 @@ void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_
pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget))
- {
pWidget->DrawShadow(pDevice, pPageView);
- }
-
}
}
@@ -292,14 +280,9 @@ FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Ann
FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- // CReader_Page* pPage = pAnnot->GetPage();
- // ASSERT(pPage != NULL);
- CPDFSDK_Document* pDocument = m_pApp->GetCurrentDoc();
- ASSERT(pDocument != NULL);
+ CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
switch (pWidget->GetFieldType())
{
@@ -307,9 +290,7 @@ FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot
case FIELDTYPE_CHECKBOX:
case FIELDTYPE_RADIOBUTTON:
if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y))
- {
pDocument->SetFocusAnnot(pAnnot);
- }
break;
default:
pDocument->SetFocusAnnot(pAnnot);
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index 021a78aace..d21d5d209d 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -11,6 +11,28 @@
#include "../include/fsdk_mgr.h"
#include "../include/javascript/IJavaScript.h"
+namespace {
+
+CPDFSDK_Document* FormHandleToSDKDoc(FPDF_FORMHANDLE hHandle)
+{
+ CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
+ return pEnv ? pEnv->GetSDKDocument() : nullptr;
+}
+
+CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle)
+{
+ CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
+ return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr;
+}
+
+CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page)
+{
+ CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
+ return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, TRUE) : nullptr;
+}
+
+} // namespace
+
DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(
FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y)
{
@@ -37,370 +59,259 @@ DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(
{
if (!document || !formInfo || formInfo->version != 1)
return nullptr;
- CPDF_Document * pDocument = (CPDF_Document*) document;
- CPDFDoc_Environment * pEnv = new CPDFDoc_Environment(pDocument);
- pEnv->RegAppHandle(formInfo);
- if (CPDF_Document* pEnvDocument = pEnv->GetPDFDocument())
- pEnv->SetCurrentDoc(new CPDFSDK_Document(pEnvDocument, pEnv));
+
+ CPDF_Document* pDocument = (CPDF_Document*)document;
+ CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo);
+ pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv));
return pEnv;
}
DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle)
{
- if(!hHandle)
- return;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(pSDKDoc)
- {
- ((CPDFDoc_Environment*)hHandle)->SetCurrentDoc(NULL);
- delete pSDKDoc;
- }
- delete (CPDFDoc_Environment*)hHandle;
- hHandle = NULL;
+ if (!hHandle)
+ return;
+
+ CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
+ if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument())
+ {
+ pEnv->SetSDKDocument(NULL);
+ delete pSDKDoc;
+ }
+ delete pEnv;
}
DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
{
- if (!hHandle || !page)
- return FALSE;
-// CPDF_Page * pPage = (CPDF_Page*) page;
-// CPDF_Document * pDoc = pPage->m_pDocument;
-// CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
- CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(!pFXDoc)
- return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
- if(!pPageView)
- return FALSE;
-
-// double page_x = 0;
-// double page_y = 0;
-// pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y);
- CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
- return pPageView->OnMouseMove(pt, modifier);
+ CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+ if (!pPageView)
+ return FALSE;
+
+ CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
+ return pPageView->OnMouseMove(pt, modifier);
}
DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
{
- if (!hHandle || !page)
- return FALSE;
- CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(!pFXDoc)
- return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
- if(!pPageView)
- return FALSE;
-// double page_x = 0;
-// double page_y = 0;
-// pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y);
- CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
- return pPageView->OnLButtonDown(pt, modifier);
+ CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+ if (!pPageView)
+ return FALSE;
+
+ CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
+ return pPageView->OnLButtonDown(pt, modifier);
}
DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
{
- if (!hHandle || !page)
- return FALSE;
- CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(!pFXDoc)
- return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
- if(!pPageView)
- return FALSE;
-// double page_x = 0;
-// double page_y = 0;
-// pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y);
- CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
- return pPageView->OnLButtonUp(pt, modifier);
+ CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+ if (!pPageView)
+ return FALSE;
+
+ CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
+ return pPageView->OnLButtonUp(pt, modifier);
}
DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nKeyCode, int modifier)
{
- if (!hHandle || !page)
- return FALSE;
- CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(!pFXDoc)
- return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
- if(!pPageView)
- return FALSE;
+ CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+ if (!pPageView)
+ return FALSE;
-
- return pPageView->OnKeyDown(nKeyCode, modifier);
+ return pPageView->OnKeyDown(nKeyCode, modifier);
}
DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nKeyCode, int modifier)
{
- if (!hHandle || !page)
- return FALSE;
- CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(!pFXDoc)
- return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
- if(!pPageView)
- return FALSE;
-
+ CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+ if (!pPageView)
+ return FALSE;
- return pPageView->OnKeyUp(nKeyCode, modifier);
+ return pPageView->OnKeyUp(nKeyCode, modifier);
}
-
DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nChar, int modifier)
{
- if (!hHandle || !page)
- return FALSE;
- CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(!pFXDoc)
- return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
- if(!pPageView)
- return FALSE;
- return pPageView->OnChar(nChar, modifier);
+ CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
+ if (!pPageView)
+ return FALSE;
+ return pPageView->OnChar(nChar, modifier);
}
DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle)
{
- if(!hHandle)
- return FALSE;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(!pSDKDoc)
- return FALSE;
- //Kill the current focus.
- return pSDKDoc->KillFocusAnnot(0);
+ CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
+ if (!pSDKDoc)
+ return FALSE;
+
+ return pSDKDoc->KillFocusAnnot(0);
}
-DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y,
- int size_x, int size_y, int rotate, int flags)
+DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page,
+ int start_x, int start_y, int size_x, int size_y, int rotate, int flags)
{
- if (!hHandle || !page)
- return ;
- CPDF_Page* pPage = (CPDF_Page*)page;
-
- CPDF_RenderOptions options;
- if (flags & FPDF_LCD_TEXT)
- options.m_Flags |= RENDER_CLEARTYPE;
- else
- options.m_Flags &= ~RENDER_CLEARTYPE;
-
- //Grayscale output
- if (flags & FPDF_GRAYSCALE)
- {
- options.m_ColorMode = RENDER_COLOR_GRAY;
- options.m_ForeColor = 0;
- options.m_BackColor = 0xffffff;
- }
-
- options.m_AddFlags = flags >> 8;
- options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument);
-
- CFX_AffineMatrix matrix;
- pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
-
- FX_RECT clip;
- clip.left = start_x;
- clip.right = start_x + size_x;
- clip.top = start_y;
- clip.bottom = start_y + size_y;
+ if (!hHandle || !page)
+ return;
+
+ CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_RenderOptions options;
+ if (flags & FPDF_LCD_TEXT)
+ options.m_Flags |= RENDER_CLEARTYPE;
+ else
+ options.m_Flags &= ~RENDER_CLEARTYPE;
+
+ //Grayscale output
+ if (flags & FPDF_GRAYSCALE)
+ {
+ options.m_ColorMode = RENDER_COLOR_GRAY;
+ options.m_ForeColor = 0;
+ options.m_BackColor = 0xffffff;
+ }
+
+ options.m_AddFlags = flags >> 8;
+ options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument);
+
+ CFX_AffineMatrix matrix;
+ pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
+
+ FX_RECT clip;
+ clip.left = start_x;
+ clip.right = start_x + size_x;
+ clip.top = start_y;
+ clip.bottom = start_y + size_y;
#ifdef _SKIA_SUPPORT_
- CFX_SkiaDevice* pDevice = new CFX_SkiaDevice;
+ nonstd::unique_ptr<CFX_SkiaDevice> pDevice(new CFX_SkiaDevice);
#else
- CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
+ nonstd::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
#endif
- pDevice->Attach((CFX_DIBitmap*)bitmap);
- pDevice->SaveState();
- pDevice->SetClip_Rect(&clip);
-
- CPDF_RenderContext* pContext = new CPDF_RenderContext;
- CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
- CPDFSDK_Document* pFXDoc = pEnv->GetCurrentDoc();
- if(!pFXDoc)
- {
- delete pContext;
- delete pDevice;
- pContext = NULL;
- pDevice = NULL;
- return;
- }
- if(CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
- {
- pPageView->PageView_OnDraw(pDevice, &matrix, &options);
- }
- pDevice->RestoreState();
-
- if(options.m_pOCContext)
- {
- delete options.m_pOCContext;
- options.m_pOCContext = NULL;
- }
- if(pContext)
- {
- delete pContext;
- pContext = NULL;
- }
- if(pDevice)
- {
- delete pDevice;
- pDevice = NULL;
- }
+ pDevice->Attach((CFX_DIBitmap*)bitmap);
+ pDevice->SaveState();
+ pDevice->SetClip_Rect(&clip);
+
+ if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
+ pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
+ pDevice->RestoreState();
+ delete options.m_pOCContext;
}
DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, unsigned long color)
{
- if (!hHandle)
- return;
-// CPDFDoc_Environment* pEnv = (CPDFDoc_Environment* )hHandle;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(pSDKDoc)
- {
- if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm())
- {
- pInterForm->SetHighlightColor(color, fieldType);
- }
-
- }
-
+ if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
+ pInterForm->SetHighlightColor(color, fieldType);
}
DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha)
{
- if (!hHandle)
- return;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(pSDKDoc)
- {
- if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm())
- pInterForm->SetHighlightAlpha(alpha);
- }
+ if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
+ pInterForm->SetHighlightAlpha(alpha);
}
DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle)
{
- if (!hHandle)
- return;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(pSDKDoc)
- {
- if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm())
- pInterForm->RemoveAllHighLight();
- }
+ if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
+ pInterForm->RemoveAllHighLight();
}
DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHandle)
{
- if(!hHandle || !page)
- return;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(!pSDKDoc)
- return;
- CPDF_Page* pPage = (CPDF_Page*)page;
- CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, TRUE);
- if(pPageView)
- {
- pPageView->SetValid(TRUE);
- }
+ if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page))
+ pPageView->SetValid(TRUE);
}
DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hHandle)
{
- if(!hHandle || !page)
- return;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- CPDF_Page* pPage = (CPDF_Page*)page;
- CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
- if(pPageView)
- {
- pPageView->SetValid(FALSE);
- // ReMovePageView() takes care of the delete for us.
- pSDKDoc->ReMovePageView(pPage);
- }
+ if (!hHandle || !page)
+ return;
+
+ CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
+ if (!pSDKDoc)
+ return;
+
+ CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
+ if (pPageView)
+ {
+ pPageView->SetValid(FALSE);
+ // ReMovePageView() takes care of the delete for us.
+ pSDKDoc->ReMovePageView(pPage);
+ }
}
+
DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle)
{
- if(!hHandle)
- return;
- if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc())
- {
- if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
- pSDKDoc->ProcJavascriptFun();
- }
+ CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
+ if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
+ pSDKDoc->ProcJavascriptFun();
}
DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle)
{
- if(!hHandle)
- return;
- if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc())
- {
- if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
- pSDKDoc->ProcOpenAction();
- }
+ CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
+ if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
+ pSDKDoc->ProcOpenAction();
}
+
DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaType)
{
- if(!hHandle)
- return;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(pSDKDoc)
- {
- CPDF_Document* pDoc = pSDKDoc->GetDocument();
- CPDF_Dictionary* pDic = pDoc->GetRoot();
- if (!pDic)
- return;
- CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA"));
-
- if(aa.ActionExist((CPDF_AAction::AActionType)aaType))
- {
- CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType);
- CPDFSDK_ActionHandler *pActionHandler = ((CPDFDoc_Environment*)hHandle)->GetActionHander();
- ASSERT(pActionHandler != NULL);
- pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType, pSDKDoc);
- }
- }
+ CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
+ if (!pSDKDoc)
+ return;
+
+ CPDF_Document* pDoc = pSDKDoc->GetDocument();
+ CPDF_Dictionary* pDic = pDoc->GetRoot();
+ if (!pDic)
+ return;
+
+ CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA"));
+ if (aa.ActionExist((CPDF_AAction::AActionType)aaType))
+ {
+ CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType);
+ CPDFSDK_ActionHandler *pActionHandler = ((CPDFDoc_Environment*)hHandle)->GetActionHander();
+ ASSERT(pActionHandler != NULL);
+ pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType, pSDKDoc);
+ }
}
+
DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandle, int aaType)
{
- if(!hHandle || !page)
- return;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- CPDF_Page* pPage = (CPDF_Page*)page;
- CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
- if(pPageView)
- {
- CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv();
- ASSERT(pEnv != NULL);
-
- CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander();
- ASSERT(pActionHandler != NULL);
-
- CPDF_Dictionary *pPageDict = pPage->m_pFormDict;
- ASSERT(pPageDict != NULL);
-
- CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA"));
-
- FX_BOOL bExistOAAction = FALSE;
- FX_BOOL bExistCAAction = FALSE;
- if (FPDFPAGE_AACTION_OPEN == aaType)
- {
- bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage);
- if (bExistOAAction)
- {
- CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
- pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
- }
- }
- else
- {
- bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage);
- if (bExistCAAction)
- {
- CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
- pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
- }
- }
- }
+ if(!hHandle || !page)
+ return;
+ CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
+ CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
+ if(pPageView)
+ {
+ CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv();
+ ASSERT(pEnv != NULL);
+
+ CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander();
+ ASSERT(pActionHandler != NULL);
+
+ CPDF_Dictionary *pPageDict = pPage->m_pFormDict;
+ ASSERT(pPageDict != NULL);
+
+ CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA"));
+
+ FX_BOOL bExistOAAction = FALSE;
+ FX_BOOL bExistCAAction = FALSE;
+ if (FPDFPAGE_AACTION_OPEN == aaType)
+ {
+ bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage);
+ if (bExistOAAction)
+ {
+ CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
+ pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
+ }
+ }
+ else
+ {
+ bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage);
+ if (bExistCAAction)
+ {
+ CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
+ pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
+ }
+ }
+ }
}
-
-
diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp
index 30abd0816f..de7f7d9716 100644
--- a/fpdfsdk/src/fsdk_annothandler.cpp
+++ b/fpdfsdk/src/fsdk_annothandler.cpp
@@ -12,337 +12,337 @@
CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp)
{
- m_pApp = pApp;
+ m_pApp = pApp;
- CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp);
- pHandler->SetFormFiller(m_pApp->GetIFormFiller());
- RegisterAnnotHandler(pHandler);
+ CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp);
+ pHandler->SetFormFiller(m_pApp->GetIFormFiller());
+ RegisterAnnotHandler(pHandler);
}
CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr()
{
- for(int i=0; i<m_Handlers.GetSize(); i++)
- {
- IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i);
- delete pHandler;
- }
- m_Handlers.RemoveAll();
- m_mapType2Handler.RemoveAll();
+ for(int i=0; i<m_Handlers.GetSize(); i++)
+ {
+ IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i);
+ delete pHandler;
+ }
+ m_Handlers.RemoveAll();
+ m_mapType2Handler.RemoveAll();
}
-void CPDFSDK_AnnotHandlerMgr::RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler)
+void CPDFSDK_AnnotHandlerMgr::RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler)
{
- ASSERT(pAnnotHandler != NULL);
+ ASSERT(pAnnotHandler != NULL);
- ASSERT(GetAnnotHandler(pAnnotHandler->GetType()) == NULL);
+ ASSERT(GetAnnotHandler(pAnnotHandler->GetType()) == NULL);
- m_Handlers.Add(pAnnotHandler);
- m_mapType2Handler.SetAt(pAnnotHandler->GetType(), (void*)pAnnotHandler);
+ m_Handlers.Add(pAnnotHandler);
+ m_mapType2Handler.SetAt(pAnnotHandler->GetType(), (void*)pAnnotHandler);
}
void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler)
{
- ASSERT(pAnnotHandler != NULL);
+ ASSERT(pAnnotHandler != NULL);
- m_mapType2Handler.RemoveKey(pAnnotHandler->GetType());
+ m_mapType2Handler.RemoveKey(pAnnotHandler->GetType());
- for (int i=0, sz=m_Handlers.GetSize(); i<sz; i++)
- {
- if (m_Handlers.GetAt(i) == pAnnotHandler)
- {
- m_Handlers.RemoveAt(i);
- break;
- }
- }
+ for (int i=0, sz=m_Handlers.GetSize(); i<sz; i++)
+ {
+ if (m_Handlers.GetAt(i) == pAnnotHandler)
+ {
+ m_Handlers.RemoveAt(i);
+ break;
+ }
+ }
}
CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot * pAnnot, CPDFSDK_PageView *pPageView)
{
- ASSERT(pAnnot != NULL);
- ASSERT(pPageView != NULL);
+ ASSERT(pAnnot != NULL);
+ ASSERT(pPageView != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot->GetSubType()))
- {
- return pAnnotHandler->NewAnnot(pAnnot, pPageView);
- }
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot->GetSubType()))
+ {
+ return pAnnotHandler->NewAnnot(pAnnot, pPageView);
+ }
- return new CPDFSDK_Annot(pAnnot, pPageView);
+ return new CPDFSDK_Annot(pAnnot, pPageView);
}
void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- pAnnot->GetPDFPage();
+ pAnnot->GetPDFPage();
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- pAnnotHandler->OnRelease(pAnnot);
- pAnnotHandler->ReleaseAnnot(pAnnot);
- }
- else
- {
- delete (CPDFSDK_Annot*)pAnnot;
- }
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ pAnnotHandler->OnRelease(pAnnot);
+ pAnnotHandler->ReleaseAnnot(pAnnot);
+ }
+ else
+ {
+ delete (CPDFSDK_Annot*)pAnnot;
+ }
}
void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
+ CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
- CPDFSDK_DateTime curTime;
- pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString());
- pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0);
+ CPDFSDK_DateTime curTime;
+ pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString());
+ pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- pAnnotHandler->OnCreate(pAnnot);
- }
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ pAnnotHandler->OnCreate(pAnnot);
+ }
}
void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- pAnnotHandler->OnLoad(pAnnot);
- }
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ pAnnotHandler->OnLoad(pAnnot);
+ }
}
IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(CPDFSDK_Annot* pAnnot) const
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
- ASSERT(pPDFAnnot != NULL);
+ CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
+ ASSERT(pPDFAnnot != NULL);
- return GetAnnotHandler(pPDFAnnot->GetSubType());
+ return GetAnnotHandler(pPDFAnnot->GetSubType());
}
IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(const CFX_ByteString& sType) const
{
- void* pRet = NULL;
- m_mapType2Handler.Lookup(sType, pRet);
- return (IPDFSDK_AnnotHandler*)pRet;
+ void* pRet = NULL;
+ m_mapType2Handler.Lookup(sType, pRet);
+ return (IPDFSDK_AnnotHandler*)pRet;
}
void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,FX_DWORD dwFlags)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
- }
- else
- {
- pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- }
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
+ }
+ else
+ {
+ pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ }
}
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->OnLButtonDown(pPageView, pAnnot, nFlags, point);
- }
- return FALSE;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->OnLButtonDown(pPageView, pAnnot, nFlags, point);
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->OnLButtonUp(pPageView, pAnnot, nFlags, point);
- }
- return FALSE;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->OnLButtonUp(pPageView, pAnnot, nFlags, point);
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
- }
- return FALSE;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->OnMouseMove(pPageView, pAnnot, nFlags, point);
- }
- return FALSE;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->OnMouseMove(pPageView, pAnnot, nFlags, point);
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->OnMouseWheel(pPageView, pAnnot,nFlags,zDelta, point);
- }
- return FALSE;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->OnMouseWheel(pPageView, pAnnot,nFlags,zDelta, point);
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->OnRButtonDown(pPageView, pAnnot, nFlags, point);
- }
- return FALSE;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->OnRButtonDown(pPageView, pAnnot, nFlags, point);
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->OnRButtonUp(pPageView, pAnnot, nFlags, point);
- }
- return FALSE;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->OnRButtonUp(pPageView, pAnnot, nFlags, point);
+ }
+ return FALSE;
}
void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- pAnnotHandler->OnMouseEnter(pPageView, pAnnot, nFlag);
- }
- return ;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ pAnnotHandler->OnMouseEnter(pPageView, pAnnot, nFlag);
+ }
+ return ;
}
void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- pAnnotHandler->OnMouseExit(pPageView, pAnnot, nFlag);
- }
- return;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ pAnnotHandler->OnMouseExit(pPageView, pAnnot, nFlag);
+ }
+ return;
}
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags)
{
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->OnChar(pAnnot,nChar, nFlags);
- }
- return FALSE;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->OnChar(pAnnot,nChar, nFlags);
+ }
+ return FALSE;
}
-FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag)
+FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag)
{
- if (!m_pApp->FFI_IsCTRLKeyDown(nFlag) && !m_pApp->FFI_IsALTKeyDown(nFlag))
- {
- CPDFSDK_PageView* pPage = pAnnot->GetPageView();
- CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot();
- if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab))
- {
- CPDFSDK_Annot* pNext = GetNextAnnot(pFocusAnnot, !m_pApp->FFI_IsSHIFTKeyDown(nFlag));
+ if (!m_pApp->FFI_IsCTRLKeyDown(nFlag) && !m_pApp->FFI_IsALTKeyDown(nFlag))
+ {
+ CPDFSDK_PageView* pPage = pAnnot->GetPageView();
+ CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot();
+ if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab))
+ {
+ CPDFSDK_Annot* pNext = GetNextAnnot(pFocusAnnot, !m_pApp->FFI_IsSHIFTKeyDown(nFlag));
- if(pNext && pNext != pFocusAnnot)
- {
- CPDFSDK_Document* pDocument = pPage->GetSDKDocument();
- pDocument->SetFocusAnnot(pNext);
- return TRUE;
- }
- }
- }
+ if(pNext && pNext != pFocusAnnot)
+ {
+ CPDFSDK_Document* pDocument = pPage->GetSDKDocument();
+ pDocument->SetFocusAnnot(pNext);
+ return TRUE;
+ }
+ }
+ }
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->OnKeyDown(pAnnot,nKeyCode, nFlag);
- }
- return FALSE;
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->OnKeyDown(pAnnot,nKeyCode, nFlag);
+ }
+ return FALSE;
}
-FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag)
+FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag)
{
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
+FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- if (pAnnotHandler->OnSetFocus(pAnnot, nFlag))
- {
- CPDFSDK_PageView* pPage = pAnnot->GetPageView();
- ASSERT(pPage != NULL);
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ if (pAnnotHandler->OnSetFocus(pAnnot, nFlag))
+ {
+ CPDFSDK_PageView* pPage = pAnnot->GetPageView();
+ ASSERT(pPage != NULL);
- pPage->GetSDKDocument();
- // pDocument->SetTopmostAnnot(pAnnot);
+ pPage->GetSDKDocument();
+ // pDocument->SetTopmostAnnot(pAnnot);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
+FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- if (pAnnotHandler->OnKillFocus(pAnnot, nFlag))
- {
- return TRUE;
- }
- else
- return FALSE;
- }
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ if (pAnnotHandler->OnKillFocus(pAnnot, nFlag))
+ {
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
- return FALSE;
+ return FALSE;
}
-CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
+CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- return pAnnotHandler->GetViewBBox(pPageView, pAnnot);
- }
- return pAnnot->GetRect();
+ ASSERT(pAnnot);
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ return pAnnotHandler->GetViewBBox(pPageView, pAnnot);
+ }
+ return pAnnot->GetRect();
}
-FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point)
+FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point)
{
- ASSERT(pAnnot);
- if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
- {
- if(pAnnotHandler->CanAnswer(pAnnot))
- return pAnnotHandler->HitTest(pPageView, pAnnot, point);
- }
- return FALSE;
+ ASSERT(pAnnot);
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
+ {
+ if(pAnnotHandler->CanAnswer(pAnnot))
+ return pAnnotHandler->HitTest(pPageView, pAnnot, point);
+ }
+ return FALSE;
}
-CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,FX_BOOL bNext)
+CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,FX_BOOL bNext)
{
CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", "");
return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
@@ -350,581 +350,574 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,FX
FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot);
- ASSERT(pAnnot->GetType() == "Widget");
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot);
+ ASSERT(pAnnot->GetType() == "Widget");
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (!pWidget->IsVisible()) return FALSE;
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (!pWidget->IsVisible()) return FALSE;
- int nFieldFlags = pWidget->GetFieldFlags();
- if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) return FALSE;
- if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
- return TRUE;
- else
- {
- CPDF_Page* pPage = pWidget->GetPDFPage();
- ASSERT(pPage != NULL);
+ int nFieldFlags = pWidget->GetFieldFlags();
+ if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) return FALSE;
+ if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
+ return TRUE;
+ else
+ {
+ CPDF_Page* pPage = pWidget->GetPDFPage();
+ ASSERT(pPage != NULL);
- CPDF_Document* pDocument = pPage->m_pDocument;
- ASSERT(pDocument != NULL);
+ CPDF_Document* pDocument = pPage->m_pDocument;
+ ASSERT(pDocument != NULL);
- FX_DWORD dwPermissions = pDocument->GetUserPermissions();
- return (dwPermissions&FPDFPERM_FILL_FORM) ||
- (dwPermissions&FPDFPERM_ANNOT_FORM) ||
- (dwPermissions&FPDFPERM_ANNOT_FORM);
- }
- }
+ FX_DWORD dwPermissions = pDocument->GetUserPermissions();
+ return (dwPermissions&FPDFPERM_FILL_FORM) ||
+ (dwPermissions&FPDFPERM_ANNOT_FORM) ||
+ (dwPermissions&FPDFPERM_ANNOT_FORM);
+ }
+ }
- return FALSE;
+ return FALSE;
}
-CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage)
+CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage)
{
- ASSERT(pPage != NULL);
- pPage->GetPDFDocument();
+ CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument();
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm();
+ CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(pInterForm->GetInterForm(), pAnnot->GetAnnotDict());
+ if (!pCtrl)
+ return nullptr;
- CPDFSDK_Document* pSDKDoc = m_pApp->GetCurrentDoc();
- ASSERT(pSDKDoc);
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm);
+ pInterForm->AddMap(pCtrl, pWidget);
+ CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
+ if (pPDFInterForm && pPDFInterForm->NeedConstructAP())
+ pWidget->ResetAppearance(nullptr, FALSE);
- CPDFSDK_Widget* pWidget = NULL;
- if (CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(pInterForm->GetInterForm(), pAnnot->GetAnnotDict()))
- {
- pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm);
- pInterForm->AddMap(pCtrl, pWidget);
- CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
- if(pPDFInterForm && pPDFInterForm->NeedConstructAP())
- pWidget->ResetAppearance(NULL,FALSE);
- }
-
- return pWidget;
+ return pWidget;
}
void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- if (m_pFormFiller)
- m_pFormFiller->OnDelete(pAnnot);
+ if (m_pFormFiller)
+ m_pFormFiller->OnDelete(pAnnot);
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
- ASSERT(pInterForm != NULL);
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
+ ASSERT(pInterForm != NULL);
- CPDF_FormControl* pCtrol = pWidget->GetFormControl();
- pInterForm->RemoveMap(pCtrol);
+ CPDF_FormControl* pCtrol = pWidget->GetFormControl();
+ pInterForm->RemoveMap(pCtrol);
- delete pWidget;
+ delete pWidget;
}
void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, FX_DWORD dwFlags)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- }
- else
- {
- if (m_pFormFiller)
- {
- m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
- }
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ }
+ else
+ {
+ if (m_pFormFiller)
+ {
+ m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
+ }
+ }
}
void CPDFSDK_BFAnnotHandler::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag);
+ }
}
void CPDFSDK_BFAnnotHandler::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag);
+ }
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta,point);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta,point);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnChar(pAnnot,nChar, nFlags);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnChar(pAnnot,nChar, nFlags);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnKeyDown(pAnnot,nKeyCode, nFlag);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnKeyDown(pAnnot,nKeyCode, nFlag);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag)
{
- return FALSE;
+ return FALSE;
}
-void CPDFSDK_BFAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot)
+void CPDFSDK_BFAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- m_pFormFiller->OnCreate(pAnnot);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ m_pFormFiller->OnCreate(pAnnot);
+ }
}
void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (!pWidget->IsAppearanceValid())
- pWidget->ResetAppearance(NULL, FALSE);
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ if (!pWidget->IsAppearanceValid())
+ pWidget->ResetAppearance(NULL, FALSE);
- int nFieldType = pWidget->GetFieldType();
- if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX)
- {
- FX_BOOL bFormated = FALSE;
- CFX_WideString sValue = pWidget->OnFormat(bFormated);
- if (bFormated && nFieldType == FIELDTYPE_COMBOBOX)
- {
- pWidget->ResetAppearance(sValue.c_str(), FALSE);
- }
- }
+ int nFieldType = pWidget->GetFieldType();
+ if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX)
+ {
+ FX_BOOL bFormated = FALSE;
+ CFX_WideString sValue = pWidget->OnFormat(bFormated);
+ if (bFormated && nFieldType == FIELDTYPE_COMBOBOX)
+ {
+ pWidget->ResetAppearance(sValue.c_str(), FALSE);
+ }
+ }
- if (m_pFormFiller)
- m_pFormFiller->OnLoad(pAnnot);
- }
+ if (m_pFormFiller)
+ m_pFormFiller->OnLoad(pAnnot);
+ }
}
-FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
+FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnSetFocus(pAnnot,nFlag);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnSetFocus(pAnnot,nFlag);
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPDFSDK_BFAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
+FX_BOOL CPDFSDK_BFAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->OnKillFocus(pAnnot,nFlag);
- }
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->OnKillFocus(pAnnot,nFlag);
+ }
- return TRUE;
+ return TRUE;
}
CPDF_Rect CPDFSDK_BFAnnotHandler::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
{
- ASSERT(pAnnot != NULL);
- CFX_ByteString sSubType = pAnnot->GetSubType();
+ ASSERT(pAnnot != NULL);
+ CFX_ByteString sSubType = pAnnot->GetSubType();
- if (sSubType == BFFT_SIGNATURE)
- {
- }
- else
- {
- if (m_pFormFiller)
- return m_pFormFiller->GetViewBBox(pPageView, pAnnot);
+ if (sSubType == BFFT_SIGNATURE)
+ {
+ }
+ else
+ {
+ if (m_pFormFiller)
+ return m_pFormFiller->GetViewBBox(pPageView, pAnnot);
- }
+ }
- return CPDF_Rect(0,0,0,0);
+ return CPDF_Rect(0,0,0,0);
}
-FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point)
+FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point)
{
- ASSERT(pPageView);
- ASSERT(pAnnot);
+ ASSERT(pPageView);
+ ASSERT(pAnnot);
- CPDF_Rect rect = GetViewBBox(pPageView, pAnnot);
- return rect.Contains(point.x, point.y);
+ CPDF_Rect rect = GetViewBBox(pPageView, pAnnot);
+ return rect.Contains(point.x, point.y);
}
//CReader_AnnotIteratorEx
CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView * pPageView,FX_BOOL bReverse,
- FX_BOOL bIgnoreTopmost/*=FALSE*/,
- FX_BOOL bCircle/*=FALSE*/,
- CFX_PtrArray *pList/*=NULL*/)
-{
- ASSERT(pPageView);
- m_bReverse=bReverse;
- m_bIgnoreTopmost= bIgnoreTopmost;
- m_bCircle=bCircle;
- m_pIteratorAnnotList.RemoveAll();
- InitIteratorAnnotList(pPageView,pList);
-}
-
-CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot (const CPDFSDK_Annot* pCurrent)
-{
-
- int index = -1;
- int nCount = m_pIteratorAnnotList.GetSize();
- if (pCurrent) {
- for(int i=0;i<nCount;i++){
- CPDFSDK_Annot * pReaderAnnot= (CPDFSDK_Annot *)m_pIteratorAnnotList.GetAt(i);
- if(pReaderAnnot ==pCurrent){
- index=i;
- break;
- }
- }
- }
- return NextAnnot(index);
-}
-CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot (const CPDFSDK_Annot*pCurrent)
-{
- int index = -1;
- int nCount = m_pIteratorAnnotList.GetSize();
- if(pCurrent){
- for(int i=0;i<nCount;i++){
- CPDFSDK_Annot * pReaderAnnot= (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(i);
- if(pReaderAnnot ==pCurrent){
- index=i;
- break;
- }
- }
- }
- return PrevAnnot(index);
-}
-CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot (int& index)
-{
-
- int nCount=m_pIteratorAnnotList.GetSize();
+ FX_BOOL bIgnoreTopmost/*=FALSE*/,
+ FX_BOOL bCircle/*=FALSE*/,
+ CFX_PtrArray *pList/*=NULL*/)
+{
+ ASSERT(pPageView);
+ m_bReverse=bReverse;
+ m_bIgnoreTopmost= bIgnoreTopmost;
+ m_bCircle=bCircle;
+ m_pIteratorAnnotList.RemoveAll();
+ InitIteratorAnnotList(pPageView,pList);
+}
+
+CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot (const CPDFSDK_Annot* pCurrent)
+{
+
+ int index = -1;
+ int nCount = m_pIteratorAnnotList.GetSize();
+ if (pCurrent) {
+ for(int i=0;i<nCount;i++){
+ CPDFSDK_Annot * pReaderAnnot= (CPDFSDK_Annot *)m_pIteratorAnnotList.GetAt(i);
+ if(pReaderAnnot ==pCurrent){
+ index=i;
+ break;
+ }
+ }
+ }
+ return NextAnnot(index);
+}
+CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot (const CPDFSDK_Annot*pCurrent)
+{
+ int index = -1;
+ int nCount = m_pIteratorAnnotList.GetSize();
+ if(pCurrent){
+ for(int i=0;i<nCount;i++){
+ CPDFSDK_Annot * pReaderAnnot= (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(i);
+ if(pReaderAnnot ==pCurrent){
+ index=i;
+ break;
+ }
+ }
+ }
+ return PrevAnnot(index);
+}
+CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot (int& index)
+{
+
+ int nCount=m_pIteratorAnnotList.GetSize();
if(nCount<=0) index=-1;
else{
- if(index<0){
- index=0;
- }
- else{
- if(m_bCircle){
- index=( index <nCount-1) ? (index+1) :0;
- }
- else{
- index=( index <nCount-1) ? (index+1) :-1;
- }
+ if(index<0){
+ index=0;
+ }
+ else{
+ if(m_bCircle){
+ index=( index <nCount-1) ? (index+1) :0;
+ }
+ else{
+ index=( index <nCount-1) ? (index+1) :-1;
+ }
- }
- }
- return (index <0) ? NULL : (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(index);
+ }
+ }
+ return (index <0) ? NULL : (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(index);
}
-CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot (int& index)
+CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot (int& index)
{
- int nCount=m_pIteratorAnnotList.GetSize();
+ int nCount=m_pIteratorAnnotList.GetSize();
if(nCount<=0) index=-1;
- else{
- if(index<0){
- index=nCount-1;
- }
- else{
- if(m_bCircle){
- index = ( index >0) ? (index-1) :nCount-1;
- }
- else{
- index = ( index >0) ? (index-1) :-1;
- }
- }
- }
- return (index <0) ? NULL : (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(index);
+ else{
+ if(index<0){
+ index=nCount-1;
+ }
+ else{
+ if(m_bCircle){
+ index = ( index >0) ? (index-1) :nCount-1;
+ }
+ else{
+ index = ( index >0) ? (index-1) :-1;
+ }
+ }
+ }
+ return (index <0) ? NULL : (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(index);
}
CPDFSDK_Annot*CPDFSDK_AnnotIterator::Next(const CPDFSDK_Annot* pCurrent)
{
- return (m_bReverse) ? PrevAnnot(pCurrent):NextAnnot(pCurrent);
+ return (m_bReverse) ? PrevAnnot(pCurrent):NextAnnot(pCurrent);
}
-CPDFSDK_Annot* CPDFSDK_AnnotIterator::Prev(const CPDFSDK_Annot* pCurrent)
+CPDFSDK_Annot* CPDFSDK_AnnotIterator::Prev(const CPDFSDK_Annot* pCurrent)
{
- return (m_bReverse) ? NextAnnot(pCurrent):PrevAnnot(pCurrent);
+ return (m_bReverse) ? NextAnnot(pCurrent):PrevAnnot(pCurrent);
}
CPDFSDK_Annot*CPDFSDK_AnnotIterator::Next(int& index )
{
- return (m_bReverse) ? PrevAnnot(index):NextAnnot(index);
+ return (m_bReverse) ? PrevAnnot(index):NextAnnot(index);
}
-CPDFSDK_Annot* CPDFSDK_AnnotIterator::Prev(int& index )
+CPDFSDK_Annot* CPDFSDK_AnnotIterator::Prev(int& index )
{
- return (m_bReverse) ? NextAnnot(index):PrevAnnot(index);
+ return (m_bReverse) ? NextAnnot(index):PrevAnnot(index);
}
void CPDFSDK_AnnotIterator::InsertSort(CFX_PtrArray &arrayList, AI_COMPARE pCompare)
{
- for (int i = 1; i < arrayList.GetSize(); i++)
- {
- if (pCompare((CPDFSDK_Annot*)(arrayList[i]) , (CPDFSDK_Annot*)(arrayList[i-1])) < 0)
- {
- int j = i-1;
- CPDFSDK_Annot* pTemp = (CPDFSDK_Annot*)arrayList[i];
+ for (int i = 1; i < arrayList.GetSize(); i++)
+ {
+ if (pCompare((CPDFSDK_Annot*)(arrayList[i]) , (CPDFSDK_Annot*)(arrayList[i-1])) < 0)
+ {
+ int j = i-1;
+ CPDFSDK_Annot* pTemp = (CPDFSDK_Annot*)arrayList[i];
- do
- {
- arrayList[j + 1] = arrayList[j];
- } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arrayList[j]) < 0);
+ do
+ {
+ arrayList[j + 1] = arrayList[j];
+ } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arrayList[j]) < 0);
- arrayList[j+1] = pTemp;
- }
- }
+ arrayList[j+1] = pTemp;
+ }
+ }
}
int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2)
{
- if(p1->GetLayoutOrder() < p2->GetLayoutOrder())
- return -1;
- else if (p1->GetLayoutOrder() == p2->GetLayoutOrder())
- return 0;
- else
- return 1;
+ if(p1->GetLayoutOrder() < p2->GetLayoutOrder())
+ return -1;
+ else if (p1->GetLayoutOrder() == p2->GetLayoutOrder())
+ return 0;
+ else
+ return 1;
}
FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView,CFX_PtrArray * pAnnotList)
{
- ASSERT(pPageView);
+ ASSERT(pPageView);
- if(pAnnotList==NULL){
- pAnnotList=pPageView->GetAnnotList();
- }
+ if(pAnnotList==NULL){
+ pAnnotList=pPageView->GetAnnotList();
+ }
- m_pIteratorAnnotList.RemoveAll();
- if(!pAnnotList) return FALSE;
+ m_pIteratorAnnotList.RemoveAll();
+ if(!pAnnotList) return FALSE;
- CPDFSDK_Annot * pTopMostAnnot= (m_bIgnoreTopmost) ? NULL : pPageView->GetFocusAnnot();
+ CPDFSDK_Annot * pTopMostAnnot= (m_bIgnoreTopmost) ? NULL : pPageView->GetFocusAnnot();
- int nCount =pAnnotList->GetSize();
+ int nCount =pAnnotList->GetSize();
- for(int i = nCount- 1 ;i >= 0;i--)
- {
- CPDFSDK_Annot * pReaderAnnot= (CPDFSDK_Annot*)pAnnotList->GetAt(i);
- m_pIteratorAnnotList.Add(pReaderAnnot);
- }
+ for(int i = nCount- 1 ;i >= 0;i--)
+ {
+ CPDFSDK_Annot * pReaderAnnot= (CPDFSDK_Annot*)pAnnotList->GetAt(i);
+ m_pIteratorAnnotList.Add(pReaderAnnot);
+ }
- InsertSort(m_pIteratorAnnotList,&LyOrderCompare);
+ InsertSort(m_pIteratorAnnotList,&LyOrderCompare);
- if(pTopMostAnnot)
- {
- for(int i=0 ;i<nCount;i++)
- {
- CPDFSDK_Annot * pReaderAnnot = (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(i);
- if(pReaderAnnot == pTopMostAnnot)
- {
- m_pIteratorAnnotList.RemoveAt(i);
- m_pIteratorAnnotList.InsertAt(0, pReaderAnnot);
- break;
- }
- }
- }
+ if(pTopMostAnnot)
+ {
+ for(int i=0 ;i<nCount;i++)
+ {
+ CPDFSDK_Annot * pReaderAnnot = (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(i);
+ if(pReaderAnnot == pTopMostAnnot)
+ {
+ m_pIteratorAnnotList.RemoveAt(i);
+ m_pIteratorAnnotList.InsertAt(0, pReaderAnnot);
+ break;
+ }
+ }
+ }
- return TRUE;
+ return TRUE;
}
-
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 527538cd09..e54202a3e4 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -21,221 +21,216 @@
class CFX_SystemHandler:public IFX_SystemHandler
{
public:
- CFX_SystemHandler(CPDFDoc_Environment* pEnv):m_pEnv(pEnv),m_nCharSet(-1) {}
+ CFX_SystemHandler(CPDFDoc_Environment* pEnv):m_pEnv(pEnv),m_nCharSet(-1) {}
public:
- virtual void InvalidateRect(FX_HWND hWnd, FX_RECT rect) ;
- virtual void OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect);
+ virtual void InvalidateRect(FX_HWND hWnd, FX_RECT rect) ;
+ virtual void OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect);
- virtual FX_BOOL IsSelectionImplemented();
+ virtual FX_BOOL IsSelectionImplemented();
- virtual CFX_WideString GetClipboardText(FX_HWND hWnd){return L"";}
- virtual FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString string) {return FALSE;}
+ virtual CFX_WideString GetClipboardText(FX_HWND hWnd){return L"";}
+ virtual FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString string) {return FALSE;}
- virtual void ClientToScreen(FX_HWND hWnd, int32_t& x, int32_t& y) {}
- virtual void ScreenToClient(FX_HWND hWnd, int32_t& x, int32_t& y) {}
+ virtual void ClientToScreen(FX_HWND hWnd, int32_t& x, int32_t& y) {}
+ virtual void ScreenToClient(FX_HWND hWnd, int32_t& x, int32_t& y) {}
- /*cursor style
- FXCT_ARROW
- FXCT_NESW
- FXCT_NWSE
- FXCT_VBEAM
- FXCT_HBEAM
- FXCT_HAND
- */
- virtual void SetCursor(int32_t nCursorType);
+ /*cursor style
+ FXCT_ARROW
+ FXCT_NESW
+ FXCT_NWSE
+ FXCT_VBEAM
+ FXCT_HBEAM
+ FXCT_HAND
+ */
+ virtual void SetCursor(int32_t nCursorType);
- virtual FX_HMENU CreatePopupMenu() {return NULL;}
- virtual FX_BOOL AppendMenuItem(FX_HMENU hMenu, int32_t nIDNewItem, CFX_WideString string) {return FALSE;}
- virtual FX_BOOL EnableMenuItem(FX_HMENU hMenu, int32_t nIDItem, FX_BOOL bEnabled) {return FALSE;}
- virtual int32_t TrackPopupMenu(FX_HMENU hMenu, int32_t x, int32_t y, FX_HWND hParent) {return -1;}
- virtual void DestroyMenu(FX_HMENU hMenu) {}
+ virtual FX_HMENU CreatePopupMenu() {return NULL;}
+ virtual FX_BOOL AppendMenuItem(FX_HMENU hMenu, int32_t nIDNewItem, CFX_WideString string) {return FALSE;}
+ virtual FX_BOOL EnableMenuItem(FX_HMENU hMenu, int32_t nIDItem, FX_BOOL bEnabled) {return FALSE;}
+ virtual int32_t TrackPopupMenu(FX_HMENU hMenu, int32_t x, int32_t y, FX_HWND hParent) {return -1;}
+ virtual void DestroyMenu(FX_HMENU hMenu) {}
- virtual CFX_ByteString GetNativeTrueTypeFont(int32_t nCharset);
- virtual FX_BOOL FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteString sFontFaceName);
- virtual CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CFX_ByteString sFontFaceName, uint8_t nCharset);
+ virtual CFX_ByteString GetNativeTrueTypeFont(int32_t nCharset);
+ virtual FX_BOOL FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteString sFontFaceName);
+ virtual CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CFX_ByteString sFontFaceName, uint8_t nCharset);
- virtual int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) ;
- virtual void KillTimer(int32_t nID) ;
+ virtual int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) ;
+ virtual void KillTimer(int32_t nID) ;
- virtual FX_BOOL IsSHIFTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_IsSHIFTKeyDown(nFlag);}
- virtual FX_BOOL IsCTRLKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_IsCTRLKeyDown(nFlag);}
- virtual FX_BOOL IsALTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_IsALTKeyDown(nFlag);}
- virtual FX_BOOL IsINSERTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_IsINSERTKeyDown(nFlag);}
+ virtual FX_BOOL IsSHIFTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_IsSHIFTKeyDown(nFlag);}
+ virtual FX_BOOL IsCTRLKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_IsCTRLKeyDown(nFlag);}
+ virtual FX_BOOL IsALTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_IsALTKeyDown(nFlag);}
+ virtual FX_BOOL IsINSERTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_IsINSERTKeyDown(nFlag);}
- virtual FX_SYSTEMTIME GetLocalTime();
+ virtual FX_SYSTEMTIME GetLocalTime();
- virtual int32_t GetCharSet() {return m_nCharSet;}
- virtual void SetCharSet(int32_t nCharSet) {m_nCharSet = nCharSet;}
+ virtual int32_t GetCharSet() {return m_nCharSet;}
+ virtual void SetCharSet(int32_t nCharSet) {m_nCharSet = nCharSet;}
private:
- CPDFDoc_Environment* m_pEnv;
- int m_nCharSet;
+ CPDFDoc_Environment* m_pEnv;
+ int m_nCharSet;
};
void CFX_SystemHandler::SetCursor(int32_t nCursorType)
{
- m_pEnv->FFI_SetCursor(nCursorType);
+ m_pEnv->FFI_SetCursor(nCursorType);
}
void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect)
{
- //g_pFormFillApp->FFI_Invalidate();
- CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd;
- CPDF_Page* pPage = NULL;
- CPDFSDK_PageView* pPageView = NULL;
- pPageView = pSDKAnnot->GetPageView();
- pPage = pSDKAnnot->GetPDFPage();
- if(!pPage || !pPageView)
- return;
- CPDF_Matrix page2device;
- pPageView->GetCurrentMatrix(page2device);
- CPDF_Matrix device2page;
- device2page.SetReverse(page2device);
- FX_FLOAT left, top, right,bottom;
- device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top);
- device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right, bottom);
-// m_pEnv->FFI_DeviceToPage(pPage, rect.left, rect.top, (double*)&left, (double*)&top);
-// m_pEnv->FFI_DeviceToPage(pPage, rect.right, rect.bottom, (double*)&right, (double*)&bottom);
- CPDF_Rect rcPDF(left, bottom, right, top);
- rcPDF.Normalize();
-
- m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, rcPDF.bottom);
+ //g_pFormFillApp->FFI_Invalidate();
+ CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd;
+ CPDF_Page* pPage = NULL;
+ CPDFSDK_PageView* pPageView = NULL;
+ pPageView = pSDKAnnot->GetPageView();
+ pPage = pSDKAnnot->GetPDFPage();
+ if(!pPage || !pPageView)
+ return;
+ CPDF_Matrix page2device;
+ pPageView->GetCurrentMatrix(page2device);
+ CPDF_Matrix device2page;
+ device2page.SetReverse(page2device);
+ FX_FLOAT left, top, right,bottom;
+ device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top);
+ device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right, bottom);
+// m_pEnv->FFI_DeviceToPage(pPage, rect.left, rect.top, (double*)&left, (double*)&top);
+// m_pEnv->FFI_DeviceToPage(pPage, rect.right, rect.bottom, (double*)&right, (double*)&bottom);
+ CPDF_Rect rcPDF(left, bottom, right, top);
+ rcPDF.Normalize();
+
+ m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, rcPDF.bottom);
}
void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect)
{
- CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller;
- if(pFFL)
- {
- CPDF_Point leftbottom = CPDF_Point(rect.left, rect.bottom);
- CPDF_Point righttop = CPDF_Point(rect.right, rect.top);
- CPDF_Point ptA = pFFL->PWLtoFFL(leftbottom);
- CPDF_Point ptB = pFFL->PWLtoFFL(righttop);
+ CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller;
+ if(pFFL)
+ {
+ CPDF_Point leftbottom = CPDF_Point(rect.left, rect.bottom);
+ CPDF_Point righttop = CPDF_Point(rect.right, rect.top);
+ CPDF_Point ptA = pFFL->PWLtoFFL(leftbottom);
+ CPDF_Point ptB = pFFL->PWLtoFFL(righttop);
- CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot();
- ASSERT(pAnnot);
- CPDF_Page* pPage = pAnnot->GetPDFPage();
- ASSERT(pPage);
- m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y);
- }
+ CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot();
+ ASSERT(pAnnot);
+ CPDF_Page* pPage = pAnnot->GetPDFPage();
+ ASSERT(pPage);
+ m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y);
+ }
}
FX_BOOL CFX_SystemHandler::IsSelectionImplemented()
{
- if(m_pEnv)
- {
- FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo();
- if(pInfo && pInfo->FFI_OutputSelectedRect)
- return TRUE;
- }
- return FALSE;
+ if(m_pEnv)
+ {
+ FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo();
+ if(pInfo && pInfo->FFI_OutputSelectedRect)
+ return TRUE;
+ }
+ return FALSE;
}
CFX_ByteString CFX_SystemHandler::GetNativeTrueTypeFont(int32_t nCharset)
{
- return "";
+ return "";
}
-FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteString sFontFaceName)
+FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteString sFontFaceName)
{
- CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
-// FXFT_Face nFace = pFontMgr->FindSubstFont(sFontFaceName,TRUE,0,0,0,0,NULL);
-// FXFT_Face nFace = pFontMgr->m_pBuiltinMapper->FindSubstFont(sFontFaceName,TRUE,0,0,0,0,NULL);
+ CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
+// FXFT_Face nFace = pFontMgr->FindSubstFont(sFontFaceName,TRUE,0,0,0,0,NULL);
+// FXFT_Face nFace = pFontMgr->m_pBuiltinMapper->FindSubstFont(sFontFaceName,TRUE,0,0,0,0,NULL);
- if(pFontMgr)
- {
- CFX_FontMapper* pFontMapper = pFontMgr->m_pBuiltinMapper;
- if(pFontMapper)
- {
- int nSize = pFontMapper->m_InstalledTTFonts.GetSize();
- if(nSize ==0)
- {
- pFontMapper->LoadInstalledFonts();
- nSize = pFontMapper->m_InstalledTTFonts.GetSize();
- }
+ if(pFontMgr)
+ {
+ CFX_FontMapper* pFontMapper = pFontMgr->m_pBuiltinMapper;
+ if(pFontMapper)
+ {
+ int nSize = pFontMapper->m_InstalledTTFonts.GetSize();
+ if(nSize ==0)
+ {
+ pFontMapper->LoadInstalledFonts();
+ nSize = pFontMapper->m_InstalledTTFonts.GetSize();
+ }
- for(int i=0; i<nSize; i++)
- {
- if(pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName))
- return TRUE;
- }
- }
+ for(int i=0; i<nSize; i++)
+ {
+ if(pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName))
+ return TRUE;
+ }
+ }
- }
+ }
- return FALSE;
-// pFontMgr->m_FaceMap.Lookup(sFontFaceName,pFont);
-// return (pFont!=NULL);
+ return FALSE;
+// pFontMgr->m_FaceMap.Lookup(sFontFaceName,pFont);
+// return (pFont!=NULL);
}
static int CharSet2CP(int charset)
{
- if(charset == 128)
- return 932;
- else if(charset == 134)
- return 936;
- else if(charset == 129)
- return 949;
- else if(charset == 136)
- return 950;
- return 0;
+ if(charset == 128)
+ return 932;
+ else if(charset == 134)
+ return 936;
+ else if(charset == 129)
+ return 949;
+ else if(charset == 136)
+ return 950;
+ return 0;
}
CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CFX_ByteString sFontFaceName,
- uint8_t nCharset)
-{
- if(pDoc)
- {
- CFX_Font* pFXFont = new CFX_Font();
- pFXFont->LoadSubst(sFontFaceName,TRUE,0,0,0,CharSet2CP(nCharset),FALSE);
- CPDF_Font* pFont = pDoc->AddFont(pFXFont,nCharset,FALSE);
- delete pFXFont;
- return pFont;
- }
+ uint8_t nCharset)
+{
+ if(pDoc)
+ {
+ CFX_Font* pFXFont = new CFX_Font();
+ pFXFont->LoadSubst(sFontFaceName,TRUE,0,0,0,CharSet2CP(nCharset),FALSE);
+ CPDF_Font* pFont = pDoc->AddFont(pFXFont,nCharset,FALSE);
+ delete pFXFont;
+ return pFont;
+ }
- return NULL;
+ return NULL;
}
int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, TimerCallback lpTimerFunc)
{
- return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc);
+ return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc);
}
void CFX_SystemHandler::KillTimer(int32_t nID)
{
- m_pEnv->FFI_KillTimer(nID);
+ m_pEnv->FFI_KillTimer(nID);
}
FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime()
{
- return m_pEnv->FFI_GetLocalTime();
+ return m_pEnv->FFI_GetLocalTime();
}
CJS_RuntimeFactory* GetJSRuntimeFactory()
{
- static CJS_RuntimeFactory s_JSRuntimeFactory;
- return &s_JSRuntimeFactory;
+ static CJS_RuntimeFactory s_JSRuntimeFactory;
+ return &s_JSRuntimeFactory;
}
-CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc) :
- m_pAnnotHandlerMgr(NULL),
- m_pActionHandler(NULL),
- m_pJSRuntime(NULL),
- m_pInfo(NULL),
- m_pSDKDoc(NULL),
- m_pPDFDoc(pDoc),
- m_pIFormFiller(NULL)
+CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo) :
+ m_pAnnotHandlerMgr(NULL),
+ m_pActionHandler(NULL),
+ m_pJSRuntime(NULL),
+ m_pInfo(pFFinfo),
+ m_pSDKDoc(NULL),
+ m_pPDFDoc(pDoc),
+ m_pIFormFiller(NULL)
{
-
- m_pSysHandler = NULL;
- m_pSysHandler = new CFX_SystemHandler(this);
-
-
- m_pJSRuntimeFactory = NULL;
- m_pJSRuntimeFactory = GetJSRuntimeFactory();
- m_pJSRuntimeFactory->AddRef();
+ m_pSysHandler = new CFX_SystemHandler(this);
+ m_pJSRuntimeFactory = GetJSRuntimeFactory();
+ m_pJSRuntimeFactory->AddRef();
}
CPDFDoc_Environment::~CPDFDoc_Environment()
@@ -255,6 +250,46 @@ CPDFDoc_Environment::~CPDFDoc_Environment()
m_pActionHandler = NULL;
}
+int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon)
+{
+ if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert)
+ {
+ CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
+ CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
+ FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
+ FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength());
+ int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg, pTitle, Type, Icon);
+ bsMsg.ReleaseBuffer();
+ bsTitle.ReleaseBuffer();
+ return ret;
+ }
+ return -1;
+}
+
+int CPDFDoc_Environment::JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, const FX_WCHAR* Default,
+ const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* response, int length)
+{
+ if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_response)
+ {
+ CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode();
+ CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
+ CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode();
+ CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode();
+ FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion.GetBuffer(bsQuestion.GetLength());
+ FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength());
+ FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.GetBuffer(bsDefault.GetLength());
+ FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuffer(bsLabel.GetLength());
+ int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo->m_pJsPlatform, pQuestion, pTitle,
+ pDefault, pLabel, bPassword, response, length);
+ bsQuestion.ReleaseBuffer();
+ bsTitle.ReleaseBuffer();
+ bsDefault.ReleaseBuffer();
+ bsLabel.ReleaseBuffer();
+ return ret;
+ }
+ return -1;
+}
+
CFX_WideString CPDFDoc_Environment::JS_fieldBrowse()
{
if (!m_pInfo ||
@@ -305,64 +340,82 @@ CFX_WideString CPDFDoc_Environment::JS_docGetFilePath()
return wsRet;
}
-IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime()
+void CPDFDoc_Environment::JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL)
{
- if(!IsJSInitiated())
- return NULL;
- assert(m_pJSRuntimeFactory);
- if(!m_pJSRuntime)
- m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
- return m_pJSRuntime;
+ if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_submitForm)
+ {
+ CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode();
+ FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestination.GetBuffer(bsDestination.GetLength());
+ m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, length, pDestination);
+ bsDestination.ReleaseBuffer();
+ }
}
-CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr()
-{
- if(!m_pAnnotHandlerMgr)
- m_pAnnotHandlerMgr = new CPDFSDK_AnnotHandlerMgr(this);
- return m_pAnnotHandlerMgr;
+void CPDFDoc_Environment::JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,
+ const FX_WCHAR* To, const FX_WCHAR* Subject,
+ const FX_WCHAR* CC, const FX_WCHAR* BCC,
+ const FX_WCHAR* Msg)
+{
+ if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_mail)
+ {
+ CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode();
+ CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_Encode();
+ CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode();
+ CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode();
+ CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
+ FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength());
+ FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength());
+ FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength());
+ FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength());
+ FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
+ m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, length, bUI, pTo, pSubject,
+ pCC, pBcc, pMsg);
+ bsTo.ReleaseBuffer();
+ bsCC.ReleaseBuffer();
+ bsBcc.ReleaseBuffer();
+ bsSubject.ReleaseBuffer();
+ bsMsg.ReleaseBuffer();
+ }
}
-CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander()
+IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime()
{
- if(!m_pActionHandler)
- m_pActionHandler = new CPDFSDK_ActionHandler(this);
- return m_pActionHandler;
+ if (!IsJSInitiated())
+ return NULL;
+ if (!m_pJSRuntime)
+ m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
+ return m_pJSRuntime;
}
-int CPDFDoc_Environment::RegAppHandle(FPDF_FORMFILLINFO* pFFinfo)
+CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr()
{
- m_pInfo = pFFinfo;
- return TRUE;
+ if (!m_pAnnotHandlerMgr)
+ m_pAnnotHandlerMgr = new CPDFSDK_AnnotHandlerMgr(this);
+ return m_pAnnotHandlerMgr;
}
-CPDFSDK_Document* CPDFDoc_Environment::GetCurrentDoc()
+CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander()
{
- return m_pSDKDoc;
+ if (!m_pActionHandler)
+ m_pActionHandler = new CPDFSDK_ActionHandler(this);
+ return m_pActionHandler;
}
CFFL_IFormFiller* CPDFDoc_Environment::GetIFormFiller()
{
- if(!m_pIFormFiller)
- m_pIFormFiller = new CFFL_IFormFiller(this);
- return m_pIFormFiller;
-}
-
-FX_BOOL CPDFDoc_Environment::IsJSInitiated()
-{
- if(m_pInfo)
- {
- if(m_pInfo->m_pJsPlatform)
- return TRUE;
- else
- return FALSE;
- }
- return FALSE;
+ if (!m_pIFormFiller)
+ m_pIFormFiller = new CFFL_IFormFiller(this);
+ return m_pIFormFiller;
}
-CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv):m_pDoc(pDoc),
- m_pInterForm(NULL),m_pEnv(pEnv),m_pOccontent(NULL),m_bChangeMask(FALSE)
+CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv) :
+ m_pDoc(pDoc),
+ m_pInterForm(nullptr),
+ m_pFocusAnnot(nullptr),
+ m_pEnv(pEnv),
+ m_pOccontent(nullptr),
+ m_bChangeMask(FALSE)
{
- m_pFocusAnnot = NULL;
}
CPDFSDK_Document::~CPDFSDK_Document()
@@ -412,55 +465,55 @@ CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex)
void CPDFSDK_Document:: ProcJavascriptFun()
{
- CPDF_Document* pPDFDoc = GetDocument();
- CPDF_DocJSActions docJS(pPDFDoc);
- int iCount = docJS.CountJSActions();
- if (iCount < 1) return;
- for (int i = 0; i < iCount; i ++)
- {
- CFX_ByteString csJSName;
- CPDF_Action jsAction = docJS.GetJSAction(i, csJSName);
- if(m_pEnv->GetActionHander())
- m_pEnv->GetActionHander()->DoAction_JavaScript(jsAction,CFX_WideString::FromLocal(csJSName),this);
- }
+ CPDF_Document* pPDFDoc = GetDocument();
+ CPDF_DocJSActions docJS(pPDFDoc);
+ int iCount = docJS.CountJSActions();
+ if (iCount < 1) return;
+ for (int i = 0; i < iCount; i ++)
+ {
+ CFX_ByteString csJSName;
+ CPDF_Action jsAction = docJS.GetJSAction(i, csJSName);
+ if(m_pEnv->GetActionHander())
+ m_pEnv->GetActionHander()->DoAction_JavaScript(jsAction,CFX_WideString::FromLocal(csJSName),this);
+ }
}
FX_BOOL CPDFSDK_Document::ProcOpenAction()
{
- if(!m_pDoc)
- return FALSE;
+ if(!m_pDoc)
+ return FALSE;
- CPDF_Dictionary* pRoot = m_pDoc->GetRoot();
- if (!pRoot)
- return FALSE;
+ CPDF_Dictionary* pRoot = m_pDoc->GetRoot();
+ if (!pRoot)
+ return FALSE;
- CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction");
- if(!pOpenAction)
- pOpenAction = pRoot->GetArray("OpenAction");
+ CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction");
+ if(!pOpenAction)
+ pOpenAction = pRoot->GetArray("OpenAction");
- if(!pOpenAction)
- return FALSE;
+ if(!pOpenAction)
+ return FALSE;
- if(pOpenAction->GetType()==PDFOBJ_ARRAY)
- return TRUE;
+ if(pOpenAction->GetType()==PDFOBJ_ARRAY)
+ return TRUE;
- if(pOpenAction->GetType()==PDFOBJ_DICTIONARY)
- {
- CPDF_Dictionary * pDict=(CPDF_Dictionary*)pOpenAction;
- CPDF_Action action(pDict);
- if(m_pEnv->GetActionHander())
- m_pEnv->GetActionHander()->DoAction_DocOpen(action, this);
- return TRUE;
- }
- return FALSE;
+ if(pOpenAction->GetType()==PDFOBJ_DICTIONARY)
+ {
+ CPDF_Dictionary * pDict=(CPDF_Dictionary*)pOpenAction;
+ CPDF_Action action(pDict);
+ if(m_pEnv->GetActionHander())
+ m_pEnv->GetActionHander()->DoAction_DocOpen(action, this);
+ return TRUE;
+ }
+ return FALSE;
}
-CPDF_OCContext* CPDFSDK_Document::GetOCContext()
+CPDF_OCContext* CPDFSDK_Document::GetOCContext()
{
- if(!m_pOccontent)
- m_pOccontent = new CPDF_OCContext(m_pDoc);
- return m_pOccontent;
+ if(!m_pOccontent)
+ m_pOccontent = new CPDF_OCContext(m_pDoc);
+ return m_pOccontent;
}
void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage)
@@ -479,17 +532,17 @@ void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage)
CPDF_Page * CPDFSDK_Document::GetPage(int nIndex)
{
- CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex);
- if(!pTempPage)
- return NULL;
- return pTempPage;
+ CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex);
+ if(!pTempPage)
+ return NULL;
+ return pTempPage;
}
CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm()
{
- if(!m_pInterForm)
- m_pInterForm = new CPDFSDK_InterForm(this);
- return m_pInterForm;
+ if(!m_pInterForm)
+ m_pInterForm = new CPDFSDK_InterForm(this);
+ return m_pInterForm;
}
void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot)
@@ -510,123 +563,123 @@ CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot()
FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
{
- if(m_pFocusAnnot==pAnnot) return TRUE;
+ if(m_pFocusAnnot==pAnnot) return TRUE;
- if(m_pFocusAnnot)
- {
- if(!KillFocusAnnot(nFlag) ) return FALSE;
- }
- CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
- if(pAnnot && pPageView->IsValid())
- {
- CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr();
-
- if(pAnnotHandler&&!m_pFocusAnnot)
- {
- if (!pAnnotHandler->Annot_OnSetFocus(pAnnot,nFlag))
- return FALSE;
- if(!m_pFocusAnnot)
- {
- m_pFocusAnnot=pAnnot;
- return TRUE;
- }
- }
- }
- return FALSE;
+ if(m_pFocusAnnot)
+ {
+ if(!KillFocusAnnot(nFlag) ) return FALSE;
+ }
+ CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
+ if(pAnnot && pPageView->IsValid())
+ {
+ CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr();
+
+ if(pAnnotHandler&&!m_pFocusAnnot)
+ {
+ if (!pAnnotHandler->Annot_OnSetFocus(pAnnot,nFlag))
+ return FALSE;
+ if(!m_pFocusAnnot)
+ {
+ m_pFocusAnnot=pAnnot;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag)
{
- if(m_pFocusAnnot)
- {
- CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr();
- if(pAnnotHandler)
- {
- CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot;
- m_pFocusAnnot = NULL;
- if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag))
- {
-
- if(pFocusAnnot->GetType() == FX_BSTRC("Widget"))
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot;
- int nFieldType = pWidget->GetFieldType();
- if(FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX == nFieldType)
- m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE);
- }
-
- if(!m_pFocusAnnot)
- return TRUE;
- }
- else
- {
- m_pFocusAnnot = pFocusAnnot;
- }
- }
- }
- return FALSE;
+ if(m_pFocusAnnot)
+ {
+ CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr();
+ if(pAnnotHandler)
+ {
+ CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot;
+ m_pFocusAnnot = NULL;
+ if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag))
+ {
+
+ if(pFocusAnnot->GetType() == FX_BSTRC("Widget"))
+ {
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot;
+ int nFieldType = pWidget->GetFieldType();
+ if(FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX == nFieldType)
+ m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE);
+ }
+
+ if(!m_pFocusAnnot)
+ return TRUE;
+ }
+ else
+ {
+ m_pFocusAnnot = pFocusAnnot;
+ }
+ }
+ }
+ return FALSE;
}
void CPDFSDK_Document::OnCloseDocument()
{
- KillFocusAnnot();
+ KillFocusAnnot();
}
FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag)
{
- FX_DWORD dwPermissions = m_pDoc->GetUserPermissions();
- return dwPermissions&nFlag;
+ FX_DWORD dwPermissions = m_pDoc->GetUserPermissions();
+ return dwPermissions&nFlag;
}
IFXJS_Runtime * CPDFSDK_Document::GetJsRuntime()
{
- ASSERT(m_pEnv!=NULL);
- return m_pEnv->GetJSRuntime();
+ ASSERT(m_pEnv!=NULL);
+ return m_pEnv->GetJSRuntime();
}
-CFX_WideString CPDFSDK_Document::GetPath()
+CFX_WideString CPDFSDK_Document::GetPath()
{
- ASSERT(m_pEnv != NULL);
- return m_pEnv->JS_docGetFilePath();
+ ASSERT(m_pEnv != NULL);
+ return m_pEnv->JS_docGetFilePath();
}
CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_page(page),m_pSDKDoc(pSDKDoc)
{
- CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm();
- if(pInterForm)
- {
- CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
- pPDFInterForm->FixPageFields(page);
- }
+ CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm();
+ if(pInterForm)
+ {
+ CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
+ pPDFInterForm->FixPageFields(page);
+ }
m_page->SetPrivateData((void*)m_page, (void*)this, NULL);
- m_fxAnnotArray.RemoveAll();
+ m_fxAnnotArray.RemoveAll();
- m_bEnterWidget = FALSE;
- m_bExitWidget = FALSE;
- m_bOnWidget = FALSE;
- m_CaptureWidget = NULL;
- m_bValid = FALSE;
+ m_bEnterWidget = FALSE;
+ m_bExitWidget = FALSE;
+ m_bOnWidget = FALSE;
+ m_CaptureWidget = NULL;
+ m_bValid = FALSE;
m_bLocked = FALSE;
m_bTakeOverPage = FALSE;
}
CPDFSDK_PageView::~CPDFSDK_PageView()
{
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- int nAnnotCount = m_fxAnnotArray.GetSize();
-
- for (int i=0; i<nAnnotCount; i++)
- {
- CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
- //if there is a focused annot on the page, we should kill the focus first.
- if(pAnnot == m_pSDKDoc->GetFocusAnnot())
- KillFocusAnnot();
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- ASSERT(pAnnotHandlerMgr);
- pAnnotHandlerMgr->ReleaseAnnot(pAnnot);
- }
- m_fxAnnotArray.RemoveAll();
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ int nAnnotCount = m_fxAnnotArray.GetSize();
+
+ for (int i=0; i<nAnnotCount; i++)
+ {
+ CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
+ //if there is a focused annot on the page, we should kill the focus first.
+ if(pAnnot == m_pSDKDoc->GetFocusAnnot())
+ KillFocusAnnot();
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr);
+ pAnnotHandlerMgr->ReleaseAnnot(pAnnot);
+ }
+ m_fxAnnotArray.RemoveAll();
delete m_pAnnotList;
m_pAnnotList = NULL;
@@ -656,109 +709,109 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p
CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY)
{
- int nCount = m_pAnnotList->Count();
- for(int i = 0 ; i<nCount; i++)
- {
- CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
- CFX_FloatRect annotRect;
- pAnnot->GetRect(annotRect);
- if(annotRect.Contains(pageX, pageY))
- return pAnnot;
- }
- return NULL;
+ int nCount = m_pAnnotList->Count();
+ for(int i = 0 ; i<nCount; i++)
+ {
+ CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
+ CFX_FloatRect annotRect;
+ pAnnot->GetRect(annotRect);
+ if(annotRect.Contains(pageX, pageY))
+ return pAnnot;
+ }
+ return NULL;
}
CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY)
{
- int nCount = m_pAnnotList->Count();
- for(int i = 0 ; i<nCount; i++)
- {
- CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
- if(pAnnot->GetSubType() == "Widget")
- {
- CFX_FloatRect annotRect;
- pAnnot->GetRect(annotRect);
- if(annotRect.Contains(pageX, pageY))
- return pAnnot;
- }
- }
- return NULL;
+ int nCount = m_pAnnotList->Count();
+ for(int i = 0 ; i<nCount; i++)
+ {
+ CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
+ if(pAnnot->GetSubType() == "Widget")
+ {
+ CFX_FloatRect annotRect;
+ pAnnot->GetRect(annotRect);
+ if(annotRect.Contains(pageX, pageY))
+ return pAnnot;
+ }
+ }
+ return NULL;
}
CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY)
{
- CPDFSDK_AnnotIterator annotIterator(this, FALSE);
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
- CPDFSDK_Annot* pSDKAnnot = NULL;
- int index = -1;
- while((pSDKAnnot = annotIterator.Next(index)))
- {
- CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
- if(rc.Contains(pageX, pageY))
- return pSDKAnnot;
- }
+ CPDFSDK_AnnotIterator annotIterator(this, FALSE);
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
+ CPDFSDK_Annot* pSDKAnnot = NULL;
+ int index = -1;
+ while((pSDKAnnot = annotIterator.Next(index)))
+ {
+ CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
+ if(rc.Contains(pageX, pageY))
+ return pSDKAnnot;
+ }
- return NULL;
+ return NULL;
}
CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY)
{
- CPDFSDK_AnnotIterator annotIterator(this, FALSE);
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
- CPDFSDK_Annot* pSDKAnnot = NULL;
- int index = -1;
- while((pSDKAnnot = annotIterator.Next(index)))
- {
- if(pSDKAnnot->GetType() == "Widget")
- {
- pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
- CPDF_Point point(pageX, pageY);
- if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
- return pSDKAnnot;
- }
- }
+ CPDFSDK_AnnotIterator annotIterator(this, FALSE);
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
+ CPDFSDK_Annot* pSDKAnnot = NULL;
+ int index = -1;
+ while((pSDKAnnot = annotIterator.Next(index)))
+ {
+ if(pSDKAnnot->GetType() == "Widget")
+ {
+ pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
+ CPDF_Point point(pageX, pageY);
+ if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
+ return pSDKAnnot;
+ }
+ }
- return NULL;
+ return NULL;
}
FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot)
{
- CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict();
- if(pAnnotDic)
- return pAnnotDic->KeyExist("AS");
- return FALSE;
+ CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict();
+ if(pAnnotDic)
+ return pAnnotDic->KeyExist("AS");
+ return FALSE;
}
-CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot * pPDFAnnot)
+CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot * pPDFAnnot)
{
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- ASSERT(pEnv);
- CPDFSDK_AnnotHandlerMgr * pAnnotHandler= pEnv->GetAnnotHandlerMgr();
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ ASSERT(pEnv);
+ CPDFSDK_AnnotHandlerMgr * pAnnotHandler= pEnv->GetAnnotHandlerMgr();
- CPDFSDK_Annot* pSDKAnnot =NULL;
+ CPDFSDK_Annot* pSDKAnnot =NULL;
- if(pAnnotHandler)
- {
- pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this);
- }
- if(!pSDKAnnot)
- return NULL;
+ if(pAnnotHandler)
+ {
+ pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this);
+ }
+ if(!pSDKAnnot)
+ return NULL;
- m_fxAnnotArray.Add(pSDKAnnot);
+ m_fxAnnotArray.Add(pSDKAnnot);
- if(pAnnotHandler)
- {
- pAnnotHandler->Annot_OnCreate(pSDKAnnot);
+ if(pAnnotHandler)
+ {
+ pAnnotHandler->Annot_OnCreate(pSDKAnnot);
- }
+ }
- return pSDKAnnot;
+ return pSDKAnnot;
}
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary * pDict)
@@ -768,235 +821,235 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary * pDict)
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictionary * pDict)
{
- return NULL;
+ return NULL;
}
FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot)
{
- return FALSE;
+ return FALSE;
}
CPDF_Document* CPDFSDK_PageView::GetPDFDocument()
{
- if(m_page)
- {
- return m_page->m_pDocument;
- }
- return NULL;
+ if(m_page)
+ {
+ return m_page->m_pDocument;
+ }
+ return NULL;
}
-int CPDFSDK_PageView::CountAnnots()
+int CPDFSDK_PageView::CountAnnots()
{
- return m_pAnnotList->Count();
+ return m_pAnnotList->Count();
}
-CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(int nIndex)
+CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(int nIndex)
{
- int nCount = m_fxAnnotArray.GetSize();
- if ( nIndex < 0 || nIndex >= nCount )
- {
- return NULL;
- }
+ int nCount = m_fxAnnotArray.GetSize();
+ if ( nIndex < 0 || nIndex >= nCount )
+ {
+ return NULL;
+ }
- return (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(nIndex);
+ return (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(nIndex);
}
CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary * pDict)
{
- int nCount = m_fxAnnotArray.GetSize();
- for(int i=0; i<nCount; i++)
- {
- CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
- if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict())
- return pAnnot;
- }
- return NULL;
+ int nCount = m_fxAnnotArray.GetSize();
+ for(int i=0; i<nCount; i++)
+ {
+ CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
+ if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict())
+ return pAnnot;
+ }
+ return NULL;
}
FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag)
{
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- ASSERT(pEnv);
- CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
- if(!pFXAnnot)
- {
- KillFocusAnnot(nFlag);
- }
- else
- {
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- ASSERT(pAnnotHandlerMgr);
-
- FX_BOOL bRet = pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag,point);
- if(bRet)
- {
- SetFocusAnnot(pFXAnnot);
- }
- return bRet;
- }
- return FALSE;
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ ASSERT(pEnv);
+ CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
+ if(!pFXAnnot)
+ {
+ KillFocusAnnot(nFlag);
+ }
+ else
+ {
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr);
+
+ FX_BOOL bRet = pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag,point);
+ if(bRet)
+ {
+ SetFocusAnnot(pFXAnnot);
+ }
+ return bRet;
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag)
{
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- ASSERT(pEnv);
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- ASSERT(pAnnotHandlerMgr);
- CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
- CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot();
- FX_BOOL bRet = FALSE;
- if(pFocusAnnot && pFocusAnnot != pFXAnnot)
- {
- //Last focus Annot gets a chance to handle the event.
- bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag,point);
- }
- if(pFXAnnot && !bRet)
- {
- bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag,point);
- return bRet;
- }
- return bRet;
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ ASSERT(pEnv);
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr);
+ CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
+ CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot();
+ FX_BOOL bRet = FALSE;
+ if(pFocusAnnot && pFocusAnnot != pFXAnnot)
+ {
+ //Last focus Annot gets a chance to handle the event.
+ bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag,point);
+ }
+ if(pFXAnnot && !bRet)
+ {
+ bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag,point);
+ return bRet;
+ }
+ return bRet;
}
FX_BOOL CPDFSDK_PageView::OnMouseMove(const CPDF_Point & point, int nFlag)
{
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- ASSERT(pAnnotHandlerMgr);
- if(CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y))
- {
- if(m_CaptureWidget && m_CaptureWidget != pFXAnnot)
- {
- m_bExitWidget = TRUE;
- m_bEnterWidget = FALSE;
- pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag);
- }
- m_CaptureWidget = (CPDFSDK_Widget*)pFXAnnot;
- m_bOnWidget = TRUE;
- if(!m_bEnterWidget)
- {
- m_bEnterWidget = TRUE;
- m_bExitWidget = FALSE;
- pAnnotHandlerMgr->Annot_OnMouseEnter(this, pFXAnnot,nFlag);
- }
- pAnnotHandlerMgr->Annot_OnMouseMove(this, pFXAnnot, nFlag, point);
- return TRUE;
- }
- else
- {
- if(m_bOnWidget)
- {
- m_bOnWidget = FALSE;
- m_bExitWidget = TRUE;
- m_bEnterWidget = FALSE;
- if(m_CaptureWidget)
- {
- pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag);
- m_CaptureWidget = NULL;
- }
- }
- return FALSE;
- }
-
- return FALSE;;
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr);
+ if(CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y))
+ {
+ if(m_CaptureWidget && m_CaptureWidget != pFXAnnot)
+ {
+ m_bExitWidget = TRUE;
+ m_bEnterWidget = FALSE;
+ pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag);
+ }
+ m_CaptureWidget = (CPDFSDK_Widget*)pFXAnnot;
+ m_bOnWidget = TRUE;
+ if(!m_bEnterWidget)
+ {
+ m_bEnterWidget = TRUE;
+ m_bExitWidget = FALSE;
+ pAnnotHandlerMgr->Annot_OnMouseEnter(this, pFXAnnot,nFlag);
+ }
+ pAnnotHandlerMgr->Annot_OnMouseMove(this, pFXAnnot, nFlag, point);
+ return TRUE;
+ }
+ else
+ {
+ if(m_bOnWidget)
+ {
+ m_bOnWidget = FALSE;
+ m_bExitWidget = TRUE;
+ m_bEnterWidget = FALSE;
+ if(m_CaptureWidget)
+ {
+ pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag);
+ m_CaptureWidget = NULL;
+ }
+ }
+ return FALSE;
+ }
+
+ return FALSE;;
}
FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag)
{
- if(CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y))
- {
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- ASSERT(pAnnotHandlerMgr);
- return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, (int)deltaY, point);
- }
- return FALSE;
+ if(CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y))
+ {
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr);
+ return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, (int)deltaY, point);
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag)
{
- if(CPDFSDK_Annot* pAnnot = GetFocusAnnot())
- {
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- ASSERT(pAnnotHandlerMgr);
- return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag);
- }
+ if(CPDFSDK_Annot* pAnnot = GetFocusAnnot())
+ {
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr);
+ return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag);
+ }
- return FALSE;
+ return FALSE;
}
FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag)
{
- if(CPDFSDK_Annot* pAnnot = GetFocusAnnot())
- {
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- ASSERT(pAnnotHandlerMgr);
- return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag);
- }
- return FALSE;
+ if(CPDFSDK_Annot* pAnnot = GetFocusAnnot())
+ {
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr);
+ return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag);
+ }
+ return FALSE;
}
FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag)
{
-// if(CPDFSDK_Annot* pAnnot = GetFocusAnnot())
-// {
-// CFFL_IFormFiller* pIFormFiller = g_pFormFillApp->GetIFormFiller();
-// return pIFormFiller->OnKeyUp(pAnnot, nKeyCode, nFlag);
-// }
- return FALSE;
+// if(CPDFSDK_Annot* pAnnot = GetFocusAnnot())
+// {
+// CFFL_IFormFiller* pIFormFiller = g_pFormFillApp->GetIFormFiller();
+// return pIFormFiller->OnKeyUp(pAnnot, nKeyCode, nFlag);
+// }
+ return FALSE;
}
extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot);
void CPDFSDK_PageView::LoadFXAnnots()
{
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
- //Disable the default AP construction.
- CPDF_InterForm::EnableUpdateAP(FALSE);
- m_pAnnotList = new CPDF_AnnotList(m_page);
- CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
- int nCount = m_pAnnotList->Count();
+ FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
+ //Disable the default AP construction.
+ CPDF_InterForm::EnableUpdateAP(FALSE);
+ m_pAnnotList = new CPDF_AnnotList(m_page);
+ CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
+ int nCount = m_pAnnotList->Count();
SetLock(TRUE);
- for(int i=0; i<nCount; i++)
- {
- CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
- CPDF_Document * pDoc = GetPDFDocument();
+ for(int i=0; i<nCount; i++)
+ {
+ CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
+ CPDF_Document * pDoc = GetPDFDocument();
- CheckUnSupportAnnot(pDoc, pPDFAnnot);
+ CheckUnSupportAnnot(pDoc, pPDFAnnot);
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- ASSERT(pAnnotHandlerMgr != NULL);
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr != NULL);
- if(pAnnotHandlerMgr)
- {
- CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
- if(!pAnnot)
- continue;
- m_fxAnnotArray.Add(pAnnot);
+ if(pAnnotHandlerMgr)
+ {
+ CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
+ if(!pAnnot)
+ continue;
+ m_fxAnnotArray.Add(pAnnot);
- pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
- }
+ pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
+ }
- }
+ }
SetLock(FALSE);
}
-void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects)
+void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects)
{
- for(int i=0; i<rects.GetSize(); i++)
- {
- CPDF_Rect rc = rects.GetAt(i);
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom);
- }
+ for(int i=0; i<rects.GetSize(); i++)
+ {
+ CPDF_Rect rc = rects.GetAt(i);
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom);
+ }
}
void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot)
@@ -1009,43 +1062,42 @@ void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot)
int CPDFSDK_PageView::GetPageIndex()
{
- if(m_page)
- {
- CPDF_Dictionary* pDic = m_page->m_pFormDict;
- CPDF_Document* pDoc = m_pSDKDoc->GetDocument();
- if(pDoc && pDic)
- {
- return pDoc->GetPageIndex(pDic->GetObjNum());
- }
- }
- return -1;
+ if(m_page)
+ {
+ CPDF_Dictionary* pDic = m_page->m_pFormDict;
+ CPDF_Document* pDoc = m_pSDKDoc->GetDocument();
+ if(pDoc && pDic)
+ {
+ return pDoc->GetPageIndex(pDic->GetObjNum());
+ }
+ }
+ return -1;
}
-FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p)
+FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p)
{
- if (p == NULL) return FALSE;
- int iCount = m_pAnnotList->Count();
- for (int i = 0; i < iCount; i++)
- {
- if (m_pAnnotList->GetAt(i) == p)
- return TRUE;
- }
- return FALSE;
+ if (p == NULL) return FALSE;
+ int iCount = m_pAnnotList->Count();
+ for (int i = 0; i < iCount; i++)
+ {
+ if (m_pAnnotList->GetAt(i) == p)
+ return TRUE;
+ }
+ return FALSE;
}
CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot()
{
- CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot();
- if(!pFocusAnnot)
- return NULL;
+ CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot();
+ if(!pFocusAnnot)
+ return NULL;
- for(int i=0; i<m_fxAnnotArray.GetSize(); i++)
- {
- CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
- if(pAnnot == pFocusAnnot)
- return pAnnot;
- }
- return NULL;
+ for(int i=0; i<m_fxAnnotArray.GetSize(); i++)
+ {
+ CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
+ if(pAnnot == pFocusAnnot)
+ return pAnnot;
+ }
+ return NULL;
}
-
diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp
index bd40fc05c0..7a1b150ad8 100644
--- a/fpdfsdk/src/javascript/JS_Object.cpp
+++ b/fpdfsdk/src/javascript/JS_Object.cpp
@@ -8,8 +8,6 @@
#include "../../include/javascript/IJavaScript.h"
#include "../../include/javascript/JS_Define.h"
#include "../../include/javascript/JS_Object.h"
-// #include "../../include/javascript/JS_MsgBox.h"
-// #include "../../include/javascript/JS_ResMgr.h"
#include "../../include/javascript/JS_Context.h"
JS_TIMER_MAPARRAY& GetTimeMap()
@@ -21,106 +19,102 @@ JS_TIMER_MAPARRAY& GetTimeMap()
int FXJS_MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, const FX_WCHAR* swMsg, const FX_WCHAR* swTitle, FX_UINT nType, FX_UINT nIcon)
{
- int nRet = 0;
+ if (!pApp)
+ return 0;
- if(pApp)
- {
- CPDFSDK_Document* pDoc = pApp->GetCurrentDoc();
- if(pDoc)
- pDoc->KillFocusAnnot();
- nRet = pApp->JS_appAlert(swMsg, swTitle, nType, nIcon);
- }
+ if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument())
+ pDoc->KillFocusAnnot();
- return nRet;
+ return pApp->JS_appAlert(swMsg, swTitle, nType, nIcon);
}
CPDFSDK_PageView* FXJS_GetPageView(IFXJS_Context* cc)
{
- if (CJS_Context* pContext = (CJS_Context *)cc)
- {
- if (pContext->GetReaderDocument())
- return NULL;
- }
- return NULL;
+ if (CJS_Context* pContext = (CJS_Context *)cc)
+ {
+ if (pContext->GetReaderDocument())
+ return NULL;
+ }
+ return NULL;
}
/* --------------------------------- CJS_EmbedObj --------------------------------- */
CJS_EmbedObj::CJS_EmbedObj(CJS_Object* pJSObject) :
- m_pJSObject(pJSObject)
+ m_pJSObject(pJSObject)
{
}
CJS_EmbedObj::~CJS_EmbedObj()
{
- m_pJSObject = NULL;
+ m_pJSObject = NULL;
}
CPDFSDK_PageView* CJS_EmbedObj::JSGetPageView(IFXJS_Context* cc)
{
- return FXJS_GetPageView(cc);
+ return FXJS_GetPageView(cc);
}
int CJS_EmbedObj::MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView,const FX_WCHAR* swMsg,const FX_WCHAR* swTitle,FX_UINT nType,FX_UINT nIcon)
{
- return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
+ return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
}
void CJS_EmbedObj::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg)
{
- CJS_Object::Alert(pContext, swMsg);
+ CJS_Object::Alert(pContext, swMsg);
}
CJS_Timer* CJS_EmbedObj::BeginTimer(CPDFDoc_Environment * pApp,FX_UINT nElapse)
{
- CJS_Timer* pTimer = new CJS_Timer(this,pApp);
- pTimer->SetJSTimer(nElapse);
+ CJS_Timer* pTimer = new CJS_Timer(this,pApp);
+ pTimer->SetJSTimer(nElapse);
- return pTimer;
+ return pTimer;
}
void CJS_EmbedObj::EndTimer(CJS_Timer* pTimer)
{
- ASSERT(pTimer != NULL);
- pTimer->KillJSTimer();
- delete pTimer;
+ ASSERT(pTimer != NULL);
+ pTimer->KillJSTimer();
+ delete pTimer;
}
/* --------------------------------- CJS_Object --------------------------------- */
void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data)
{
- CJS_Object* pJSObj = data.GetParameter();
+ CJS_Object* pJSObj = data.GetParameter();
pJSObj->ExitInstance();
delete pJSObj;
- JS_FreePrivate(data.GetInternalField(0));
+ JS_FreePrivate(data.GetInternalField(0));
}
void DisposeObject(const v8::WeakCallbackInfo<CJS_Object>& data)
{
- CJS_Object* pJSObj = data.GetParameter();
+ CJS_Object* pJSObj = data.GetParameter();
pJSObj->Dispose();
data.SetSecondPassCallback(FreeObject);
}
CJS_Object::CJS_Object(JSFXObject pObject) :m_pEmbedObj(NULL)
{
- v8::Local<v8::Context> context = pObject->CreationContext();
- m_pIsolate = context->GetIsolate();
- m_pObject.Reset(m_pIsolate, pObject);
+ v8::Local<v8::Context> context = pObject->CreationContext();
+ m_pIsolate = context->GetIsolate();
+ m_pObject.Reset(m_pIsolate, pObject);
};
CJS_Object::~CJS_Object(void)
{
- delete m_pEmbedObj;
- m_pEmbedObj = NULL;
+ delete m_pEmbedObj;
+ m_pEmbedObj = NULL;
- m_pObject.Reset();
+ m_pObject.Reset();
};
-void CJS_Object::MakeWeak()
+void CJS_Object::MakeWeak()
{
- m_pObject.SetWeak(
+ m_pObject.SetWeak(
this, DisposeObject, v8::WeakCallbackType::kInternalFields);
}
@@ -131,24 +125,22 @@ void CJS_Object::Dispose()
CPDFSDK_PageView* CJS_Object::JSGetPageView(IFXJS_Context* cc)
{
- return FXJS_GetPageView(cc);
+ return FXJS_GetPageView(cc);
}
int CJS_Object::MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, const FX_WCHAR* swMsg, const FX_WCHAR* swTitle, FX_UINT nType, FX_UINT nIcon)
{
- return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
+ return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon);
}
void CJS_Object::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg)
{
- ASSERT(pContext != NULL);
+ ASSERT(pContext != NULL);
- if (pContext->IsMsgBoxEnabled())
- {
- CPDFDoc_Environment* pApp = pContext->GetReaderApp();
- if(pApp)
- pApp->JS_appAlert(swMsg, NULL, 0, 3);
- }
+ if (pContext->IsMsgBoxEnabled())
+ {
+ CPDFDoc_Environment* pApp = pContext->GetReaderApp();
+ if(pApp)
+ pApp->JS_appAlert(swMsg, NULL, 0, 3);
+ }
}
-
-
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 31e313179e..af329655fd 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -119,10 +119,10 @@ END_JS_STATIC_METHOD()
IMPLEMENT_JS_CLASS(CJS_App,app)
-app::app(CJS_Object * pJSObject) : CJS_EmbedObj(pJSObject) ,
- m_bCalculate(true),
- m_bRuntimeHighLight(false)
-// m_pMenuHead(NULL)
+app::app(CJS_Object * pJSObject)
+ : CJS_EmbedObj(pJSObject),
+ m_bCalculate(true),
+ m_bRuntimeHighLight(false)
{
}
@@ -136,60 +136,37 @@ app::~app(void)
FX_BOOL app::activeDocs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
- if (vp.IsGetting())
- {
-
- CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
-
- CPDFDoc_Environment* pApp = pContext->GetReaderApp();
- ASSERT(pApp != NULL);
-
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
- CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument();
-
- CJS_Array aDocs(pRuntime->GetIsolate());
-// int iNumDocs = pApp->CountDocuments();
-
-// for(int iIndex = 0; iIndex<iNumDocs; iIndex++)
-// {
- CPDFSDK_Document* pDoc = pApp->GetCurrentDoc();
- if (pDoc)
- {
- CJS_Document * pJSDocument = NULL;
-
- if (pDoc == pCurDoc)
- {
- JSFXObject pObj = JS_GetThisObj(*pRuntime);
-
- if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"Document"))
- {
- pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(),pObj);
- }
- }
- else
- {
- JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime,L"Document"));
- pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(),pObj);
- ASSERT(pJSDocument != NULL);
-
-
- // pDocument->AttachDoc(pDoc);
- }
+ if (!vp.IsGetting())
+ return FALSE;
- aDocs.SetElement(0,CJS_Value(pRuntime->GetIsolate(),pJSDocument));
- }
- // }
+ CJS_Context* pContext = (CJS_Context *)cc;
+ CPDFDoc_Environment* pApp = pContext->GetReaderApp();
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+ CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument();
+ CJS_Array aDocs(pRuntime->GetIsolate());
+ if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument())
+ {
+ CJS_Document* pJSDocument = NULL;
+ if (pDoc == pCurDoc)
+ {
+ JSFXObject pObj = JS_GetThisObj(*pRuntime);
+ if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"Document"))
+ pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(),pObj);
+ }
+ else
+ {
+ JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime,L"Document"));
+ pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(),pObj);
+ ASSERT(pJSDocument != NULL);
+ }
+ aDocs.SetElement(0,CJS_Value(pRuntime->GetIsolate(),pJSDocument));
+ }
+ if (aDocs.GetLength() > 0)
+ vp << aDocs;
+ else
+ vp.SetNull();
- if (aDocs.GetLength() > 0)
- vp << aDocs;
- else
- vp.SetNull();
- return TRUE;
- }
- return FALSE;
+ return TRUE;
}
FX_BOOL app::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
@@ -201,27 +178,16 @@ FX_BOOL app::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
m_bCalculate = (FX_BOOL)bVP;
CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
-
CPDFDoc_Environment* pApp = pContext->GetReaderApp();
- ASSERT(pApp != NULL);
-
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
CJS_Array aDocs(pRuntime->GetIsolate());
- if (CPDFSDK_Document* pDoc = pApp->GetCurrentDoc())
- {
- CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDoc->GetInterForm();
- ASSERT(pInterForm != NULL);
- pInterForm->EnableCalculate((FX_BOOL)m_bCalculate);
- }
+ if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument())
+ pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate);
}
else
{
vp << (bool)m_bCalculate;
}
-
return TRUE;
}
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index cddc919f75..6eea290f68 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -117,24 +117,14 @@ global_alternate::global_alternate(CJS_Object* pJSObject)
global_alternate::~global_alternate(void)
{
- ASSERT(m_pApp != NULL);
-
-// CommitGlobalPersisitentVariables();
DestroyGlobalPersisitentVariables();
-
- CJS_RuntimeFactory* pFactory = m_pApp->m_pJSRuntimeFactory;
- ASSERT(pFactory);
-
- pFactory->ReleaseGlobalData();
+ m_pApp->GetRuntimeFactory()->ReleaseGlobalData();
}
void global_alternate::Initial(CPDFDoc_Environment* pApp)
{
m_pApp = pApp;
-
- CJS_RuntimeFactory* pFactory = pApp->m_pJSRuntimeFactory;
- ASSERT(pFactory);
- m_pGlobalData = pFactory->NewGlobalData(pApp);
+ m_pGlobalData = pApp->GetRuntimeFactory()->NewGlobalData(pApp);
UpdateGlobalPersistentVariables();
}