| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../include/formfiller/FFL_FormFiller.h" | 7 #include "../../include/formfiller/FFL_FormFiller.h" |
| 8 #include "../../include/formfiller/FFL_IFormFiller.h" | 8 #include "../../include/formfiller/FFL_IFormFiller.h" |
| 9 #include "../../include/formfiller/FFL_CheckBox.h" | 9 #include "../../include/formfiller/FFL_CheckBox.h" |
| 10 #include "../../include/formfiller/FFL_ComboBox.h" | 10 #include "../../include/formfiller/FFL_ComboBox.h" |
| 11 #include "../../include/formfiller/FFL_ListBox.h" | 11 #include "../../include/formfiller/FFL_ListBox.h" |
| 12 #include "../../include/formfiller/FFL_PushButton.h" | 12 #include "../../include/formfiller/FFL_PushButton.h" |
| 13 #include "../../include/formfiller/FFL_RadioButton.h" | 13 #include "../../include/formfiller/FFL_RadioButton.h" |
| 14 #include "../../include/formfiller/FFL_TextField.h" | 14 #include "../../include/formfiller/FFL_TextField.h" |
| 15 | 15 |
| 16 #define FFL_MAXLISTBOXHEIGHT 140.0f | 16 #define FFL_MAXLISTBOXHEIGHT 140.0f |
| 17 | 17 |
| 18 // HHOOK CFFL_IFormFiller::m_hookSheet = NULL; | 18 // HHOOK CFFL_IFormFiller::m_hookSheet = NULL; |
| 19 // MSG CFFL_IFormFiller::g_Msg; | 19 // MSG CFFL_IFormFiller::g_Msg; |
| 20 | 20 |
| 21 /* ----------------------------- CFFL_IFormFiller -----------------------------
*/ | 21 /* ----------------------------- CFFL_IFormFiller ----------------------------- |
| 22 | 22 */ |
| 23 CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) : | 23 |
| 24 m_pApp(pApp), | 24 CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) |
| 25 m_bNotifying(FALSE) | 25 : m_pApp(pApp), m_bNotifying(FALSE) {} |
| 26 { | 26 |
| 27 } | 27 CFFL_IFormFiller::~CFFL_IFormFiller() { |
| 28 | 28 for (auto& it : m_Maps) |
| 29 CFFL_IFormFiller::~CFFL_IFormFiller() | 29 delete it.second; |
| 30 { | 30 m_Maps.clear(); |
| 31 for (auto& it : m_Maps) | 31 } |
| 32 delete it.second; | 32 |
| 33 m_Maps.clear(); | 33 FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, |
| 34 } | 34 CPDFSDK_Annot* pAnnot, |
| 35 | 35 CPDF_Point point) { |
| 36 FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Anno
t* pAnnot, CPDF_Point point) | 36 CPDF_Rect rc = pAnnot->GetRect(); |
| 37 { | 37 if (rc.Contains(point.x, point.y)) |
| 38 CPDF_Rect rc = pAnnot->GetRect(); | 38 return TRUE; |
| 39 if(rc.Contains(point.x, point.y)) | 39 return FALSE; |
| 40 } |
| 41 |
| 42 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, |
| 43 CPDFSDK_Annot* pAnnot) { |
| 44 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
| 45 return pFormFiller->GetViewBBox(pPageView, pAnnot); |
| 46 |
| 47 ASSERT(pPageView != NULL); |
| 48 |
| 49 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
| 50 CPDF_Rect rcAnnot; |
| 51 pPDFAnnot->GetRect(rcAnnot); |
| 52 |
| 53 CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1); |
| 54 return rcWin.GetOutterRect(); |
| 55 } |
| 56 |
| 57 void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, |
| 58 /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, |
| 59 CFX_RenderDevice* pDevice, |
| 60 CPDF_Matrix* pUser2Device, |
| 61 /*const CRect& rcWindow,*/ FX_DWORD dwFlags) { |
| 62 ASSERT(pPageView != NULL); |
| 63 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 64 |
| 65 if (IsVisible(pWidget)) { |
| 66 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 67 if (pFormFiller->IsValid()) { |
| 68 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
| 69 pAnnot->GetPDFPage(); |
| 70 |
| 71 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); |
| 72 if (pDocument->GetFocusAnnot() == pAnnot) { |
| 73 CPDF_Rect rcFocus = pFormFiller->GetFocusBox(pPageView); |
| 74 if (!rcFocus.IsEmpty()) { |
| 75 CFX_PathData path; |
| 76 path.SetPointCount(5); |
| 77 path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO); |
| 78 path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO); |
| 79 path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO); |
| 80 path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO); |
| 81 path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO); |
| 82 |
| 83 CFX_GraphStateData gsd; |
| 84 gsd.SetDashCount(1); |
| 85 gsd.m_DashArray[0] = 1.0f; |
| 86 gsd.m_DashPhase = 0; |
| 87 gsd.m_LineWidth = 1.0f; |
| 88 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, |
| 89 ArgbEncode(255, 0, 0, 0), FXFILL_ALTERNATE); |
| 90 } |
| 91 } |
| 92 return; |
| 93 } |
| 94 } |
| 95 |
| 96 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
| 97 pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device, |
| 98 dwFlags); |
| 99 else |
| 100 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 101 |
| 102 if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget)) |
| 103 pWidget->DrawShadow(pDevice, pPageView); |
| 104 } |
| 105 } |
| 106 |
| 107 void CFFL_IFormFiller::OnCreate(CPDFSDK_Annot* pAnnot) { |
| 108 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 109 pFormFiller->OnCreate(pAnnot); |
| 110 } |
| 111 } |
| 112 |
| 113 void CFFL_IFormFiller::OnLoad(CPDFSDK_Annot* pAnnot) { |
| 114 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 115 pFormFiller->OnLoad(pAnnot); |
| 116 } |
| 117 } |
| 118 |
| 119 void CFFL_IFormFiller::OnDelete(CPDFSDK_Annot* pAnnot) { |
| 120 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 121 pFormFiller->OnDelete(pAnnot); |
| 122 } |
| 123 |
| 124 UnRegisterFormFiller(pAnnot); |
| 125 } |
| 126 |
| 127 void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 128 CPDFSDK_Annot* pAnnot, |
| 129 FX_UINT nFlag) { |
| 130 ASSERT(pAnnot != NULL); |
| 131 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 132 |
| 133 if (!m_bNotifying) { |
| 134 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 135 if (pWidget->GetAAction(CPDF_AAction::CursorEnter)) { |
| 136 m_bNotifying = TRUE; |
| 137 |
| 138 int nValueAge = pWidget->GetValueAge(); |
| 139 |
| 140 pWidget->ClearAppModified(); |
| 141 |
| 142 ASSERT(pPageView != NULL); |
| 143 |
| 144 PDFSDK_FieldAction fa; |
| 145 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
| 146 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
| 147 pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView); |
| 148 m_bNotifying = FALSE; |
| 149 |
| 150 // if ( !IsValidAnnot(pPageView, pAnnot) ) return; |
| 151 |
| 152 if (pWidget->IsAppModified()) { |
| 153 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { |
| 154 pFormFiller->ResetPDFWindow(pPageView, |
| 155 pWidget->GetValueAge() == nValueAge); |
| 156 } |
| 157 } |
| 158 } |
| 159 } |
| 160 |
| 161 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) { |
| 162 pFormFiller->OnMouseEnter(pPageView, pAnnot); |
| 163 } |
| 164 } |
| 165 |
| 166 void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, |
| 167 CPDFSDK_Annot* pAnnot, |
| 168 FX_UINT nFlag) { |
| 169 ASSERT(pAnnot != NULL); |
| 170 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 171 |
| 172 if (!m_bNotifying) { |
| 173 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 174 if (pWidget->GetAAction(CPDF_AAction::CursorExit)) { |
| 175 m_bNotifying = TRUE; |
| 176 pWidget->GetAppearanceAge(); |
| 177 int nValueAge = pWidget->GetValueAge(); |
| 178 pWidget->ClearAppModified(); |
| 179 |
| 180 ASSERT(pPageView != NULL); |
| 181 |
| 182 PDFSDK_FieldAction fa; |
| 183 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
| 184 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
| 185 |
| 186 pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView); |
| 187 m_bNotifying = FALSE; |
| 188 |
| 189 // if (!IsValidAnnot(pPageView, pAnnot)) return; |
| 190 |
| 191 if (pWidget->IsAppModified()) { |
| 192 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { |
| 193 pFormFiller->ResetPDFWindow(pPageView, |
| 194 nValueAge == pWidget->GetValueAge()); |
| 195 } |
| 196 } |
| 197 } |
| 198 } |
| 199 |
| 200 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 201 pFormFiller->OnMouseExit(pPageView, pAnnot); |
| 202 } |
| 203 } |
| 204 |
| 205 FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 206 CPDFSDK_Annot* pAnnot, |
| 207 FX_UINT nFlags, |
| 208 const CPDF_Point& point) { |
| 209 ASSERT(pAnnot != NULL); |
| 210 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 211 |
| 212 if (!m_bNotifying) { |
| 213 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 214 if (Annot_HitTest(pPageView, pAnnot, point) && |
| 215 pWidget->GetAAction(CPDF_AAction::ButtonDown)) { |
| 216 m_bNotifying = TRUE; |
| 217 pWidget->GetAppearanceAge(); |
| 218 int nValueAge = pWidget->GetValueAge(); |
| 219 pWidget->ClearAppModified(); |
| 220 |
| 221 ASSERT(pPageView != NULL); |
| 222 |
| 223 PDFSDK_FieldAction fa; |
| 224 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlags); |
| 225 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlags); |
| 226 pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView); |
| 227 m_bNotifying = FALSE; |
| 228 |
| 229 if (!IsValidAnnot(pPageView, pAnnot)) |
| 40 return TRUE; | 230 return TRUE; |
| 41 return FALSE; | 231 |
| 42 } | 232 if (pWidget->IsAppModified()) { |
| 43 | 233 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { |
| 44 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot
* pAnnot) | 234 pFormFiller->ResetPDFWindow(pPageView, |
| 45 { | 235 nValueAge == pWidget->GetValueAge()); |
| 46 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 236 } |
| 47 return pFormFiller->GetViewBBox(pPageView, pAnnot); | 237 } |
| 48 | 238 } |
| 49 ASSERT(pPageView != NULL); | 239 } |
| 50 | 240 |
| 51 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 241 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 52 CPDF_Rect rcAnnot; | 242 return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); |
| 53 pPDFAnnot->GetRect(rcAnnot); | 243 } |
| 54 | 244 |
| 55 CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1); | 245 return FALSE; |
| 56 return rcWin.GetOutterRect(); | 246 } |
| 57 } | 247 |
| 58 | 248 FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 59 void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_
Annot* pAnnot, | 249 CPDFSDK_Annot* pAnnot, |
| 60 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, | 250 FX_UINT nFlags, |
| 61 /*const CRect& rcWindow,*/ FX_DWORD dwFlags) | 251 const CPDF_Point& point) { |
| 62 { | 252 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 63 ASSERT(pPageView != NULL); | 253 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 64 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 254 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); |
| 65 | 255 |
| 66 if (IsVisible(pWidget)) | 256 switch (pWidget->GetFieldType()) { |
| 67 { | |
| 68 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 69 { | |
| 70 if (pFormFiller->IsValid()) | |
| 71 { | |
| 72 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dw
Flags); | |
| 73 pAnnot->GetPDFPage(); | |
| 74 | |
| 75 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); | |
| 76 if (pDocument->GetFocusAnnot() == pAnnot) | |
| 77 { | |
| 78 CPDF_Rect rcFocus = pFormFiller->GetFocusBox(pPageView); | |
| 79 if (!rcFocus.IsEmpty()) | |
| 80 { | |
| 81 CFX_PathData path; | |
| 82 path.SetPointCount(5); | |
| 83 path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO
); | |
| 84 path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LIN
ETO); | |
| 85 path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LI
NETO); | |
| 86 path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINET
O); | |
| 87 path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO
); | |
| 88 | |
| 89 CFX_GraphStateData gsd; | |
| 90 gsd.SetDashCount(1); | |
| 91 gsd.m_DashArray[0] = 1.0f; | |
| 92 gsd.m_DashPhase = 0; | |
| 93 gsd.m_LineWidth = 1.0f; | |
| 94 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEnco
de(255,0,0,0), FXFILL_ALTERNATE); | |
| 95 } | |
| 96 } | |
| 97 return; | |
| 98 } | |
| 99 } | |
| 100 | |
| 101 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 102 pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device
, dwFlags); | |
| 103 else | |
| 104 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, N
ULL); | |
| 105 | |
| 106 if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget)) | |
| 107 pWidget->DrawShadow(pDevice, pPageView); | |
| 108 } | |
| 109 } | |
| 110 | |
| 111 void CFFL_IFormFiller::OnCreate(CPDFSDK_Annot* pAnnot) | |
| 112 { | |
| 113 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 114 { | |
| 115 pFormFiller->OnCreate(pAnnot); | |
| 116 } | |
| 117 } | |
| 118 | |
| 119 void CFFL_IFormFiller::OnLoad(CPDFSDK_Annot* pAnnot) | |
| 120 { | |
| 121 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 122 { | |
| 123 pFormFiller->OnLoad(pAnnot); | |
| 124 } | |
| 125 } | |
| 126 | |
| 127 void CFFL_IFormFiller::OnDelete(CPDFSDK_Annot* pAnnot) | |
| 128 { | |
| 129 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 130 { | |
| 131 pFormFiller->OnDelete(pAnnot); | |
| 132 } | |
| 133 | |
| 134 UnRegisterFormFiller(pAnnot); | |
| 135 } | |
| 136 | |
| 137 void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlag) | |
| 138 { | |
| 139 ASSERT(pAnnot != NULL); | |
| 140 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 141 | |
| 142 if (!m_bNotifying) | |
| 143 { | |
| 144 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | |
| 145 if (pWidget->GetAAction(CPDF_AAction::CursorEnter)) | |
| 146 { | |
| 147 m_bNotifying = TRUE; | |
| 148 | |
| 149 int nValueAge = pWidget->GetValueAge(); | |
| 150 | |
| 151 pWidget->ClearAppModified(); | |
| 152 | |
| 153 ASSERT(pPageView != NULL); | |
| 154 | |
| 155 | |
| 156 | |
| 157 PDFSDK_FieldAction fa; | |
| 158 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | |
| 159 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | |
| 160 pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView ); | |
| 161 m_bNotifying = FALSE; | |
| 162 | |
| 163 //if ( !IsValidAnnot(pPageView, pAnnot) ) return; | |
| 164 | |
| 165 if (pWidget->IsAppModified()) | |
| 166 { | |
| 167 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)
) | |
| 168 { | |
| 169 pFormFiller->ResetPDFWindow(pPageView, pWidget->GetValueAge(
) == nValueAge); | |
| 170 } | |
| 171 } | |
| 172 } | |
| 173 } | |
| 174 | |
| 175 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) | |
| 176 { | |
| 177 pFormFiller->OnMouseEnter(pPageView, pAnnot); | |
| 178 } | |
| 179 } | |
| 180 | |
| 181 void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* p
Annot, FX_UINT nFlag) | |
| 182 { | |
| 183 ASSERT(pAnnot != NULL); | |
| 184 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 185 | |
| 186 if (!m_bNotifying) | |
| 187 { | |
| 188 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | |
| 189 if (pWidget->GetAAction(CPDF_AAction::CursorExit)) | |
| 190 { | |
| 191 m_bNotifying = TRUE; | |
| 192 pWidget->GetAppearanceAge(); | |
| 193 int nValueAge = pWidget->GetValueAge(); | |
| 194 pWidget->ClearAppModified(); | |
| 195 | |
| 196 ASSERT(pPageView != NULL); | |
| 197 | |
| 198 | |
| 199 | |
| 200 PDFSDK_FieldAction fa; | |
| 201 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | |
| 202 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | |
| 203 | |
| 204 pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView); | |
| 205 m_bNotifying = FALSE; | |
| 206 | |
| 207 //if (!IsValidAnnot(pPageView, pAnnot)) return; | |
| 208 | |
| 209 if (pWidget->IsAppModified()) | |
| 210 { | |
| 211 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)
) | |
| 212 { | |
| 213 pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget-
>GetValueAge()); | |
| 214 } | |
| 215 } | |
| 216 } | |
| 217 } | |
| 218 | |
| 219 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 220 { | |
| 221 pFormFiller->OnMouseExit(pPageView, pAnnot); | |
| 222 } | |
| 223 } | |
| 224 | |
| 225 FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Ann
ot* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | |
| 226 { | |
| 227 ASSERT(pAnnot != NULL); | |
| 228 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 229 | |
| 230 if (!m_bNotifying) | |
| 231 { | |
| 232 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | |
| 233 if (Annot_HitTest(pPageView, pAnnot, point) && pWidget->GetAAction(CPDF_
AAction::ButtonDown)) | |
| 234 { | |
| 235 m_bNotifying = TRUE; | |
| 236 pWidget->GetAppearanceAge(); | |
| 237 int nValueAge = pWidget->GetValueAge(); | |
| 238 pWidget->ClearAppModified(); | |
| 239 | |
| 240 ASSERT(pPageView != NULL); | |
| 241 | |
| 242 | |
| 243 | |
| 244 PDFSDK_FieldAction fa; | |
| 245 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlags); | |
| 246 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlags); | |
| 247 pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView); | |
| 248 m_bNotifying = FALSE; | |
| 249 | |
| 250 if (!IsValidAnnot(pPageView, pAnnot)) return TRUE; | |
| 251 | |
| 252 if (pWidget->IsAppModified()) | |
| 253 { | |
| 254 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)
) | |
| 255 { | |
| 256 pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget-
>GetValueAge()); | |
| 257 } | |
| 258 } | |
| 259 } | |
| 260 } | |
| 261 | |
| 262 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 263 { | |
| 264 return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); | |
| 265 } | |
| 266 | |
| 267 return FALSE; | |
| 268 } | |
| 269 | |
| 270 FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot
* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | |
| 271 { | |
| 272 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 273 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | |
| 274 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); | |
| 275 | |
| 276 switch (pWidget->GetFieldType()) | |
| 277 { | |
| 278 case FIELDTYPE_PUSHBUTTON: | 257 case FIELDTYPE_PUSHBUTTON: |
| 279 case FIELDTYPE_CHECKBOX: | 258 case FIELDTYPE_CHECKBOX: |
| 280 case FIELDTYPE_RADIOBUTTON: | 259 case FIELDTYPE_RADIOBUTTON: |
| 281 if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y)) | 260 if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y)) |
| 282 pDocument->SetFocusAnnot(pAnnot); | 261 pDocument->SetFocusAnnot(pAnnot); |
| 283 break; | 262 break; |
| 284 default: | 263 default: |
| 285 pDocument->SetFocusAnnot(pAnnot); | 264 pDocument->SetFocusAnnot(pAnnot); |
| 286 break; | 265 break; |
| 287 } | 266 } |
| 288 | 267 |
| 289 FX_BOOL bRet = FALSE; | 268 FX_BOOL bRet = FALSE; |
| 290 | 269 |
| 291 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 270 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 292 { | 271 bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
| 293 bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); | 272 } |
| 294 } | 273 |
| 295 | 274 if (pDocument->GetFocusAnnot() == pAnnot) { |
| 296 if (pDocument->GetFocusAnnot() == pAnnot) | 275 FX_BOOL bExit = FALSE; |
| 297 { | 276 FX_BOOL bReset = FALSE; |
| 298 FX_BOOL bExit = FALSE; | 277 OnButtonUp(pWidget, pPageView, bReset, bExit, nFlags); |
| 299 FX_BOOL bReset = FALSE; | 278 if (bExit) |
| 300 OnButtonUp(pWidget, pPageView, bReset, bExit,nFlags); | 279 return TRUE; |
| 301 if (bExit) return TRUE; | 280 } |
| 302 } | 281 return bRet; |
| 303 return bRet; | 282 } |
| 304 } | 283 |
| 305 | 284 void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget, |
| 306 void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPa
geView, FX_BOOL& bReset, FX_BOOL& bExit,FX_UINT nFlag) | 285 CPDFSDK_PageView* pPageView, |
| 307 { | 286 FX_BOOL& bReset, |
| 308 ASSERT(pWidget != NULL); | 287 FX_BOOL& bExit, |
| 309 | 288 FX_UINT nFlag) { |
| 310 if (!m_bNotifying) | 289 ASSERT(pWidget != NULL); |
| 311 { | 290 |
| 312 if (pWidget->GetAAction(CPDF_AAction::ButtonUp)) | 291 if (!m_bNotifying) { |
| 313 { | 292 if (pWidget->GetAAction(CPDF_AAction::ButtonUp)) { |
| 314 m_bNotifying = TRUE; | 293 m_bNotifying = TRUE; |
| 315 int nAge = pWidget->GetAppearanceAge(); | 294 int nAge = pWidget->GetAppearanceAge(); |
| 316 int nValueAge = pWidget->GetValueAge(); | 295 int nValueAge = pWidget->GetValueAge(); |
| 317 | 296 |
| 318 ASSERT(pPageView != NULL); | 297 ASSERT(pPageView != NULL); |
| 319 // CReader_DocView* pDocView = pPageView->GetDocView(); | 298 // CReader_DocView* pDocView = pPageView->GetDocView(); |
| 320 // ASSERT(pDocView != NULL); | 299 // ASSERT(pDocView != NULL); |
| 321 | 300 |
| 322 | 301 PDFSDK_FieldAction fa; |
| 323 | 302 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
| 324 PDFSDK_FieldAction fa; | 303 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
| 325 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | 304 |
| 326 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | 305 pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView); |
| 327 | 306 m_bNotifying = FALSE; |
| 328 pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView); | 307 |
| 329 m_bNotifying = FALSE; | 308 if (!IsValidAnnot(pPageView, pWidget)) { |
| 330 | 309 bExit = TRUE; |
| 331 if (!IsValidAnnot(pPageView, pWidget)) | 310 return; |
| 332 { | 311 } |
| 333 bExit = TRUE; | 312 |
| 334 return; | 313 if (nAge != pWidget->GetAppearanceAge()) { |
| 335 } | 314 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { |
| 336 | 315 pFormFiller->ResetPDFWindow(pPageView, |
| 337 if (nAge != pWidget->GetAppearanceAge()) | 316 nValueAge == pWidget->GetValueAge()); |
| 338 { | 317 } |
| 339 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)
) | 318 |
| 340 { | 319 bReset = TRUE; |
| 341 pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget-
>GetValueAge()); | 320 } |
| 342 } | 321 } |
| 343 | 322 } |
| 344 bReset = TRUE; | 323 } |
| 345 } | 324 |
| 346 } | 325 FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
| 347 } | 326 CPDFSDK_Annot* pAnnot, |
| 348 } | 327 FX_UINT nFlags, |
| 349 | 328 const CPDF_Point& point) { |
| 350 FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_A
nnot* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 329 ASSERT(pAnnot != NULL); |
| 351 { | 330 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 352 ASSERT(pAnnot != NULL); | 331 |
| 353 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 332 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 354 | 333 return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); |
| 355 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 334 } |
| 356 { | 335 |
| 357 return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); | 336 return FALSE; |
| 358 } | 337 } |
| 359 | 338 |
| 339 FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, |
| 340 CPDFSDK_Annot* pAnnot, |
| 341 FX_UINT nFlags, |
| 342 const CPDF_Point& point) { |
| 343 ASSERT(pAnnot != NULL); |
| 344 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 345 |
| 346 // change cursor |
| 347 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) { |
| 348 return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); |
| 349 } |
| 350 |
| 351 return FALSE; |
| 352 } |
| 353 |
| 354 FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 355 CPDFSDK_Annot* pAnnot, |
| 356 FX_UINT nFlags, |
| 357 short zDelta, |
| 358 const CPDF_Point& point) { |
| 359 ASSERT(pAnnot != NULL); |
| 360 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 361 |
| 362 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 363 return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point); |
| 364 } |
| 365 |
| 366 return FALSE; |
| 367 } |
| 368 |
| 369 FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 370 CPDFSDK_Annot* pAnnot, |
| 371 FX_UINT nFlags, |
| 372 const CPDF_Point& point) { |
| 373 ASSERT(pAnnot != NULL); |
| 374 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 375 |
| 376 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 377 return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); |
| 378 } |
| 379 |
| 380 return FALSE; |
| 381 } |
| 382 |
| 383 FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 384 CPDFSDK_Annot* pAnnot, |
| 385 FX_UINT nFlags, |
| 386 const CPDF_Point& point) { |
| 387 ASSERT(pAnnot != NULL); |
| 388 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 389 |
| 390 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 391 return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
| 392 } |
| 393 |
| 394 return FALSE; |
| 395 } |
| 396 |
| 397 FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 398 FX_UINT nKeyCode, |
| 399 FX_UINT nFlags) { |
| 400 ASSERT(pAnnot != NULL); |
| 401 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 402 |
| 403 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 404 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); |
| 405 } |
| 406 |
| 407 return FALSE; |
| 408 } |
| 409 |
| 410 FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, |
| 411 FX_UINT nChar, |
| 412 FX_UINT nFlags) { |
| 413 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 414 if (nChar == FWL_VKEY_Tab) |
| 415 return TRUE; |
| 416 |
| 417 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
| 418 return pFormFiller->OnChar(pAnnot, nChar, nFlags); |
| 419 |
| 420 return FALSE; |
| 421 } |
| 422 |
| 423 FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { |
| 424 if (!pAnnot) |
| 360 return FALSE; | 425 return FALSE; |
| 361 } | 426 |
| 362 | 427 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 363 FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, CPDFSDK_Annot
* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 428 |
| 364 { | 429 if (!m_bNotifying) { |
| 365 ASSERT(pAnnot != NULL); | 430 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 366 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 431 if (pWidget->GetAAction(CPDF_AAction::GetFocus)) { |
| 367 | 432 m_bNotifying = TRUE; |
| 368 //change cursor | 433 pWidget->GetAppearanceAge(); |
| 369 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) | 434 |
| 370 { | 435 int nValueAge = pWidget->GetValueAge(); |
| 371 return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); | 436 pWidget->ClearAppModified(); |
| 372 } | 437 |
| 373 | 438 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
| 439 ASSERT(pPageView != NULL); |
| 440 |
| 441 PDFSDK_FieldAction fa; |
| 442 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
| 443 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
| 444 |
| 445 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE); |
| 446 if (!pFormFiller) |
| 447 return FALSE; |
| 448 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa); |
| 449 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView); |
| 450 m_bNotifying = FALSE; |
| 451 |
| 452 if (pWidget->IsAppModified()) { |
| 453 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { |
| 454 pFormFiller->ResetPDFWindow(pPageView, |
| 455 nValueAge == pWidget->GetValueAge()); |
| 456 } |
| 457 } |
| 458 } |
| 459 } |
| 460 |
| 461 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) |
| 462 return pFormFiller->OnSetFocus(pAnnot, nFlag); |
| 463 |
| 464 return TRUE; |
| 465 } |
| 466 |
| 467 FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { |
| 468 if (!pAnnot) |
| 374 return FALSE; | 469 return FALSE; |
| 375 } | 470 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
| 376 | 471 |
| 377 FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, CPDFSDK_Anno
t* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point) | 472 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 378 { | 473 if (pFormFiller->OnKillFocus(pAnnot, nFlag)) { |
| 379 ASSERT(pAnnot != NULL); | 474 if (!m_bNotifying) { |
| 380 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 381 | |
| 382 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 383 { | |
| 384 return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, poin
t); | |
| 385 } | |
| 386 | |
| 387 return FALSE; | |
| 388 } | |
| 389 | |
| 390 FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Ann
ot* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | |
| 391 { | |
| 392 ASSERT(pAnnot != NULL); | |
| 393 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 394 | |
| 395 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 396 { | |
| 397 return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); | |
| 398 } | |
| 399 | |
| 400 return FALSE; | |
| 401 } | |
| 402 | |
| 403 FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot
* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | |
| 404 { | |
| 405 ASSERT(pAnnot != NULL); | |
| 406 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 407 | |
| 408 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 409 { | |
| 410 return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); | |
| 411 } | |
| 412 | |
| 413 return FALSE; | |
| 414 } | |
| 415 | |
| 416 FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_
UINT nFlags) | |
| 417 { | |
| 418 ASSERT(pAnnot != NULL); | |
| 419 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 420 | |
| 421 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 422 { | |
| 423 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); | |
| 424 } | |
| 425 | |
| 426 return FALSE; | |
| 427 } | |
| 428 | |
| 429 FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT n
Flags) | |
| 430 { | |
| 431 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 432 if (nChar == FWL_VKEY_Tab) | |
| 433 return TRUE; | |
| 434 | |
| 435 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | |
| 436 return pFormFiller->OnChar(pAnnot, nChar, nFlags); | |
| 437 | |
| 438 return FALSE; | |
| 439 } | |
| 440 | |
| 441 FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) | |
| 442 { | |
| 443 if (!pAnnot) | |
| 444 return FALSE; | |
| 445 | |
| 446 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | |
| 447 | |
| 448 if (!m_bNotifying) | |
| 449 { | |
| 450 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 475 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 451 if (pWidget->GetAAction(CPDF_AAction::GetFocus)) | 476 if (pWidget->GetAAction(CPDF_AAction::LoseFocus)) { |
| 452 { | 477 m_bNotifying = TRUE; |
| 453 m_bNotifying = TRUE; | 478 pWidget->ClearAppModified(); |
| 454 pWidget->GetAppearanceAge(); | 479 |
| 455 | 480 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); |
| 456 int nValueAge = pWidget->GetValueAge(); | 481 ASSERT(pPageView != NULL); |
| 457 pWidget->ClearAppModified(); | 482 |
| 458 | 483 PDFSDK_FieldAction fa; |
| 459 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 484 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
| 460 ASSERT(pPageView != NULL); | 485 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
| 461 | 486 |
| 462 PDFSDK_FieldAction fa; | 487 pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa); |
| 463 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | 488 |
| 464 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | 489 pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView); |
| 465 | 490 m_bNotifying = FALSE; |
| 466 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE); | 491 } |
| 467 if(!pFormFiller) return FALSE; | 492 } |
| 468 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa); | 493 } else |
| 469 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView); | 494 return FALSE; |
| 470 m_bNotifying = FALSE; | 495 } |
| 471 | 496 |
| 472 if (pWidget->IsAppModified()) | 497 return TRUE; |
| 473 { | 498 } |
| 474 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)
) | 499 |
| 475 { | 500 FX_BOOL CFFL_IFormFiller::IsVisible(CPDFSDK_Widget* pWidget) { |
| 476 pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget-
>GetValueAge()); | 501 return pWidget->IsVisible(); |
| 477 } | 502 } |
| 478 } | 503 |
| 479 } | 504 FX_BOOL CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) { |
| 480 } | 505 ASSERT(pWidget != NULL); |
| 481 | 506 |
| 482 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) | 507 int nFieldFlags = pWidget->GetFieldFlags(); |
| 483 return pFormFiller->OnSetFocus(pAnnot, nFlag); | 508 |
| 484 | 509 return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY; |
| 510 } |
| 511 |
| 512 FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) { |
| 513 ASSERT(pWidget != NULL); |
| 514 |
| 515 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
| 485 return TRUE; | 516 return TRUE; |
| 486 } | 517 else { |
| 487 | 518 CPDF_Page* pPage = pWidget->GetPDFPage(); |
| 488 FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) | 519 ASSERT(pPage != NULL); |
| 489 { | 520 |
| 490 if(!pAnnot) return FALSE; | 521 CPDF_Document* pDocument = pPage->m_pDocument; |
| 491 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 522 ASSERT(pDocument != NULL); |
| 492 | 523 |
| 493 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 524 FX_DWORD dwPermissions = pDocument->GetUserPermissions(); |
| 494 { | 525 return (dwPermissions & FPDFPERM_FILL_FORM) || |
| 495 if (pFormFiller->OnKillFocus(pAnnot, nFlag)) | 526 (dwPermissions & FPDFPERM_ANNOT_FORM) || |
| 496 { | 527 (dwPermissions & FPDFPERM_MODIFY); |
| 497 if (!m_bNotifying) | 528 } |
| 498 { | 529 return TRUE; |
| 499 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 530 } |
| 500 if (pWidget->GetAAction(CPDF_AAction::LoseFocus)) | 531 |
| 501 { | 532 CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, |
| 502 m_bNotifying = TRUE; | 533 FX_BOOL bRegister) { |
| 503 pWidget->ClearAppModified(); | 534 auto it = m_Maps.find(pAnnot); |
| 504 | 535 if (it != m_Maps.end()) |
| 505 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); | 536 return it->second; |
| 506 ASSERT(pPageView != NULL); | 537 |
| 507 | 538 if (!bRegister) |
| 508 PDFSDK_FieldAction fa; | 539 return nullptr; |
| 509 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | 540 |
| 510 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | 541 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 511 | 542 int nFieldType = pWidget->GetFieldType(); |
| 512 pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocu
s, fa); | 543 CFFL_FormFiller* pFormFiller; |
| 513 | 544 switch (nFieldType) { |
| 514 pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView); | 545 case FIELDTYPE_PUSHBUTTON: |
| 515 m_bNotifying = FALSE; | 546 pFormFiller = new CFFL_PushButton(m_pApp, pWidget); |
| 516 | 547 break; |
| 517 } | 548 case FIELDTYPE_CHECKBOX: |
| 518 } | 549 pFormFiller = new CFFL_CheckBox(m_pApp, pWidget); |
| 519 } | 550 break; |
| 520 else | 551 case FIELDTYPE_RADIOBUTTON: |
| 521 return FALSE; | 552 pFormFiller = new CFFL_RadioButton(m_pApp, pWidget); |
| 522 } | 553 break; |
| 523 | 554 case FIELDTYPE_TEXTFIELD: |
| 524 return TRUE; | 555 pFormFiller = new CFFL_TextField(m_pApp, pWidget); |
| 525 } | 556 break; |
| 526 | 557 case FIELDTYPE_LISTBOX: |
| 527 FX_BOOL CFFL_IFormFiller::IsVisible(CPDFSDK_Widget* pWidget) | 558 pFormFiller = new CFFL_ListBox(m_pApp, pWidget); |
| 528 { | 559 break; |
| 529 return pWidget->IsVisible(); | 560 case FIELDTYPE_COMBOBOX: |
| 530 } | 561 pFormFiller = new CFFL_ComboBox(m_pApp, pWidget); |
| 531 | 562 break; |
| 532 FX_BOOL CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) | 563 case FIELDTYPE_UNKNOWN: |
| 533 { | 564 default: |
| 534 ASSERT(pWidget != NULL); | 565 pFormFiller = nullptr; |
| 535 | 566 break; |
| 536 int nFieldFlags = pWidget->GetFieldFlags(); | 567 } |
| 537 | 568 |
| 538 return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY; | 569 if (!pFormFiller) |
| 539 } | 570 return nullptr; |
| 540 | 571 |
| 541 FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) | 572 m_Maps[pAnnot] = pFormFiller; |
| 542 { | 573 return pFormFiller; |
| 543 ASSERT(pWidget != NULL); | 574 } |
| 544 | 575 |
| 545 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) | 576 void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot) { |
| 546 return TRUE; | 577 if (pAnnot != NULL) { |
| 547 else | 578 UnRegisterFormFiller(pAnnot); |
| 548 { | 579 } |
| 549 CPDF_Page* pPage = pWidget->GetPDFPage(); | 580 } |
| 550 ASSERT(pPage != NULL); | 581 |
| 551 | 582 void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) { |
| 552 CPDF_Document* pDocument = pPage->m_pDocument; | 583 auto it = m_Maps.find(pAnnot); |
| 553 ASSERT(pDocument != NULL); | 584 if (it == m_Maps.end()) |
| 554 | 585 return; |
| 555 FX_DWORD dwPermissions = pDocument->GetUserPermissions(); | 586 |
| 556 return (dwPermissions&FPDFPERM_FILL_FORM) || | 587 delete it->second; |
| 557 (dwPermissions&FPDFPERM_ANNOT_FORM) || | 588 m_Maps.erase(it); |
| 558 (dwPermissions&FPDFPERM_MODIFY); | 589 } |
| 559 } | 590 |
| 560 return TRUE; | 591 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, |
| 561 } | 592 FX_FLOAT fPopupMin, |
| 562 | 593 FX_FLOAT fPopupMax, |
| 563 CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL
bRegister) | 594 int32_t& nRet, |
| 564 { | 595 FX_FLOAT& fPopupRet) { |
| 565 auto it = m_Maps.find(pAnnot); | 596 ASSERT(pPrivateData != NULL); |
| 566 if (it != m_Maps.end()) | 597 |
| 567 return it->second; | 598 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
| 568 | 599 |
| 569 if (!bRegister) | 600 CPDF_Rect rcPageView(0, 0, 0, 0); |
| 570 return nullptr; | 601 rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth(); |
| 571 | 602 rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight(); |
| 572 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 603 rcPageView.Normalize(); |
| 573 int nFieldType = pWidget->GetFieldType(); | 604 |
| 574 CFFL_FormFiller* pFormFiller; | 605 ASSERT(pData->pWidget != NULL); |
| 575 switch (nFieldType) { | 606 CPDF_Rect rcAnnot = pData->pWidget->GetRect(); |
| 576 case FIELDTYPE_PUSHBUTTON: | 607 |
| 577 pFormFiller = new CFFL_PushButton(m_pApp, pWidget); | 608 FX_FLOAT fTop = 0.0f; |
| 578 break; | 609 FX_FLOAT fBottom = 0.0f; |
| 579 case FIELDTYPE_CHECKBOX: | 610 |
| 580 pFormFiller = new CFFL_CheckBox(m_pApp, pWidget); | 611 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pData->pWidget; |
| 581 break; | 612 switch (pWidget->GetRotate() / 90) { |
| 582 case FIELDTYPE_RADIOBUTTON: | |
| 583 pFormFiller = new CFFL_RadioButton(m_pApp, pWidget); | |
| 584 break; | |
| 585 case FIELDTYPE_TEXTFIELD: | |
| 586 pFormFiller = new CFFL_TextField(m_pApp, pWidget); | |
| 587 break; | |
| 588 case FIELDTYPE_LISTBOX: | |
| 589 pFormFiller = new CFFL_ListBox(m_pApp, pWidget); | |
| 590 break; | |
| 591 case FIELDTYPE_COMBOBOX: | |
| 592 pFormFiller = new CFFL_ComboBox(m_pApp, pWidget); | |
| 593 break; | |
| 594 case FIELDTYPE_UNKNOWN: | |
| 595 default: | |
| 596 pFormFiller = nullptr; | |
| 597 break; | |
| 598 } | |
| 599 | |
| 600 if (!pFormFiller) | |
| 601 return nullptr; | |
| 602 | |
| 603 m_Maps[pAnnot] = pFormFiller; | |
| 604 return pFormFiller; | |
| 605 } | |
| 606 | |
| 607 void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot) | |
| 608 { | |
| 609 if ( pAnnot != NULL ) | |
| 610 { | |
| 611 UnRegisterFormFiller( pAnnot ); | |
| 612 } | |
| 613 } | |
| 614 | |
| 615 void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) | |
| 616 { | |
| 617 auto it = m_Maps.find(pAnnot); | |
| 618 if (it == m_Maps.end()) | |
| 619 return; | |
| 620 | |
| 621 delete it->second; | |
| 622 m_Maps.erase(it); | |
| 623 } | |
| 624 | |
| 625 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX
_FLOAT fPopupMax, int32_t & nRet, FX_FLOAT & fPopupRet) | |
| 626 { | |
| 627 ASSERT(pPrivateData != NULL); | |
| 628 | |
| 629 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 CPDF_Rect rcPageView(0,0,0,0); | |
| 635 rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth(); | |
| 636 rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight(); | |
| 637 rcPageView.Normalize(); | |
| 638 | |
| 639 | |
| 640 ASSERT(pData->pWidget != NULL); | |
| 641 CPDF_Rect rcAnnot = pData->pWidget->GetRect(); | |
| 642 | |
| 643 FX_FLOAT fTop = 0.0f; | |
| 644 FX_FLOAT fBottom = 0.0f; | |
| 645 | |
| 646 CPDFSDK_Widget * pWidget = (CPDFSDK_Widget*)pData->pWidget; | |
| 647 switch (pWidget->GetRotate() / 90) | |
| 648 { | |
| 649 default: | 613 default: |
| 650 case 0: | 614 case 0: |
| 651 fTop = rcPageView.top - rcAnnot.top; | 615 fTop = rcPageView.top - rcAnnot.top; |
| 652 fBottom = rcAnnot.bottom - rcPageView.bottom; | 616 fBottom = rcAnnot.bottom - rcPageView.bottom; |
| 653 break; | 617 break; |
| 654 case 1: | 618 case 1: |
| 655 fTop = rcAnnot.left - rcPageView.left; | 619 fTop = rcAnnot.left - rcPageView.left; |
| 656 fBottom = rcPageView.right - rcAnnot.right; | 620 fBottom = rcPageView.right - rcAnnot.right; |
| 657 break; | 621 break; |
| 658 case 2: | 622 case 2: |
| 659 fTop = rcAnnot.bottom - rcPageView.bottom; | 623 fTop = rcAnnot.bottom - rcPageView.bottom; |
| 660 fBottom = rcPageView.top - rcAnnot.top; | 624 fBottom = rcPageView.top - rcAnnot.top; |
| 661 break; | 625 break; |
| 662 case 3: | 626 case 3: |
| 663 fTop = rcPageView.right - rcAnnot.right; | 627 fTop = rcPageView.right - rcAnnot.right; |
| 664 fBottom = rcAnnot.left - rcPageView.left; | 628 fBottom = rcAnnot.left - rcPageView.left; |
| 665 break; | 629 break; |
| 666 } | 630 } |
| 667 | 631 |
| 668 FX_FLOAT fFactHeight = 0; | 632 FX_FLOAT fFactHeight = 0; |
| 669 FX_BOOL bBottom = TRUE; | 633 FX_BOOL bBottom = TRUE; |
| 670 FX_FLOAT fMaxListBoxHeight = 0; | 634 FX_FLOAT fMaxListBoxHeight = 0; |
| 671 if (fPopupMax > FFL_MAXLISTBOXHEIGHT) | 635 if (fPopupMax > FFL_MAXLISTBOXHEIGHT) { |
| 672 { | 636 if (fPopupMin > FFL_MAXLISTBOXHEIGHT) { |
| 673 if (fPopupMin > FFL_MAXLISTBOXHEIGHT) | 637 fMaxListBoxHeight = fPopupMin; |
| 674 { | 638 } else { |
| 675 fMaxListBoxHeight = fPopupMin; | 639 fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT; |
| 676 } | 640 } |
| 677 else | 641 } else |
| 678 { | 642 fMaxListBoxHeight = fPopupMax; |
| 679 fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT; | 643 |
| 680 } | 644 if (fBottom > fMaxListBoxHeight) { |
| 681 } | 645 fFactHeight = fMaxListBoxHeight; |
| 682 else | 646 bBottom = TRUE; |
| 683 fMaxListBoxHeight = fPopupMax; | 647 } else { |
| 684 | 648 if (fTop > fMaxListBoxHeight) { |
| 685 if (fBottom > fMaxListBoxHeight) | 649 fFactHeight = fMaxListBoxHeight; |
| 686 { | 650 bBottom = FALSE; |
| 687 fFactHeight = fMaxListBoxHeight; | 651 } else { |
| 652 if (fTop > fBottom) { |
| 653 fFactHeight = fTop; |
| 654 bBottom = FALSE; |
| 655 } else { |
| 656 fFactHeight = fBottom; |
| 688 bBottom = TRUE; | 657 bBottom = TRUE; |
| 689 } | 658 } |
| 690 else | 659 } |
| 691 { | 660 } |
| 692 if (fTop > fMaxListBoxHeight) | 661 |
| 693 { | 662 nRet = bBottom ? 0 : 1; |
| 694 fFactHeight = fMaxListBoxHeight; | 663 fPopupRet = fFactHeight; |
| 695 bBottom = FALSE; | 664 } |
| 696 } | 665 |
| 697 else | 666 void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, |
| 698 { | 667 CPDFSDK_PageView* pPageView, |
| 699 if (fTop > fBottom) | 668 FX_BOOL& bRC, |
| 700 { | 669 FX_BOOL& bExit, |
| 701 fFactHeight = fTop; | 670 FX_DWORD nFlag) { |
| 702 bBottom = FALSE; | 671 if (!m_bNotifying) { |
| 703 } | 672 ASSERT(pWidget != NULL); |
| 704 else | 673 if (pWidget->GetAAction(CPDF_AAction::KeyStroke)) { |
| 705 { | 674 m_bNotifying = TRUE; |
| 706 fFactHeight = fBottom; | 675 pWidget->ClearAppModified(); |
| 707 bBottom = TRUE; | 676 |
| 708 } | 677 ASSERT(pPageView != NULL); |
| 709 } | 678 |
| 710 } | 679 PDFSDK_FieldAction fa; |
| 711 | 680 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
| 712 nRet = bBottom ? 0 : 1; | 681 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
| 713 fPopupRet = fFactHeight; | 682 fa.bWillCommit = TRUE; |
| 714 } | 683 fa.bKeyDown = TRUE; |
| 715 | 684 fa.bRC = TRUE; |
| 716 void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageVi
ew* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag) | 685 |
| 717 { | 686 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); |
| 718 if (!m_bNotifying) | 687 ASSERT(pFormFiller != NULL); |
| 719 { | 688 |
| 720 ASSERT(pWidget != NULL); | 689 pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa); |
| 721 if (pWidget->GetAAction(CPDF_AAction::KeyStroke)) | 690 pFormFiller->SaveState(pPageView); |
| 722 { | 691 |
| 723 m_bNotifying = TRUE; | 692 PDFSDK_FieldAction faOld = fa; |
| 724 pWidget->ClearAppModified(); | 693 pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView); |
| 725 | 694 |
| 726 ASSERT(pPageView != NULL); | 695 bRC = fa.bRC; |
| 727 | 696 // bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, |
| 728 PDFSDK_FieldAction fa; | 697 // pWidget); |
| 729 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | 698 |
| 730 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | 699 m_bNotifying = FALSE; |
| 731 fa.bWillCommit = TRUE; | 700 } |
| 732 fa.bKeyDown = TRUE; | 701 } |
| 733 fa.bRC = TRUE; | 702 } |
| 734 | 703 |
| 735 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); | 704 void CFFL_IFormFiller::OnValidate(CPDFSDK_Widget* pWidget, |
| 736 ASSERT(pFormFiller != NULL); | 705 CPDFSDK_PageView* pPageView, |
| 737 | 706 FX_BOOL& bRC, |
| 738 pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa); | 707 FX_BOOL& bExit, |
| 739 pFormFiller->SaveState(pPageView); | 708 FX_DWORD nFlag) { |
| 740 | 709 if (!m_bNotifying) { |
| 741 PDFSDK_FieldAction faOld = fa; | 710 ASSERT(pWidget != NULL); |
| 742 pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView); | 711 if (pWidget->GetAAction(CPDF_AAction::Validate)) { |
| 743 | 712 m_bNotifying = TRUE; |
| 744 bRC = fa.bRC; | 713 pWidget->ClearAppModified(); |
| 745 // bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidge
t); | 714 |
| 746 | 715 ASSERT(pPageView != NULL); |
| 747 m_bNotifying = FALSE; | 716 // CReader_DocView* pDocView = pPageView->GetDocView(); |
| 748 } | 717 // ASSERT(pDocView != NULL); |
| 749 } | 718 |
| 750 } | 719 PDFSDK_FieldAction fa; |
| 751 | 720 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
| 752 void CFFL_IFormFiller::OnValidate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPa
geView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag) | 721 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
| 753 { | 722 fa.bKeyDown = TRUE; |
| 754 if (!m_bNotifying) | 723 fa.bRC = TRUE; |
| 755 { | 724 |
| 756 ASSERT(pWidget != NULL); | 725 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); |
| 757 if (pWidget->GetAAction(CPDF_AAction::Validate)) | 726 ASSERT(pFormFiller != NULL); |
| 758 { | 727 |
| 759 m_bNotifying = TRUE; | 728 pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa); |
| 760 pWidget->ClearAppModified(); | 729 pFormFiller->SaveState(pPageView); |
| 761 | 730 |
| 762 ASSERT(pPageView != NULL); | 731 PDFSDK_FieldAction faOld = fa; |
| 763 // CReader_DocView* pDocView = pPageView->GetDocView(); | 732 pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView); |
| 764 // ASSERT(pDocView != NULL); | 733 |
| 765 | 734 bRC = fa.bRC; |
| 766 | 735 // bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, |
| 767 | 736 // pWidget); |
| 768 PDFSDK_FieldAction fa; | 737 |
| 769 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | 738 m_bNotifying = FALSE; |
| 770 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | 739 } |
| 771 fa.bKeyDown = TRUE; | 740 } |
| 772 fa.bRC = TRUE; | 741 } |
| 773 | 742 |
| 774 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); | 743 void CFFL_IFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, |
| 775 ASSERT(pFormFiller != NULL); | 744 CPDFSDK_PageView* pPageView, |
| 776 | 745 FX_BOOL& bExit, |
| 777 pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa); | 746 FX_DWORD nFlag) { |
| 778 pFormFiller->SaveState(pPageView); | 747 if (!m_bNotifying) { |
| 779 | 748 ASSERT(pWidget != NULL); |
| 780 PDFSDK_FieldAction faOld = fa; | |
| 781 pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView); | |
| 782 | |
| 783 bRC = fa.bRC; | |
| 784 // bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidge
t); | |
| 785 | |
| 786 m_bNotifying = FALSE; | |
| 787 } | |
| 788 } | |
| 789 } | |
| 790 | |
| 791 void CFFL_IFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pP
ageView, FX_BOOL& bExit, FX_DWORD nFlag) | |
| 792 { | |
| 793 if (!m_bNotifying) | |
| 794 { | |
| 795 ASSERT(pWidget != NULL); | |
| 796 ASSERT(pPageView != NULL); | |
| 797 // CReader_DocView* pDocView = pPageView->GetDocView(); | |
| 798 // ASSERT(pDocView != NULL); | |
| 799 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | |
| 800 ASSERT(pDocument != NULL); | |
| 801 | |
| 802 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF
orm(); | |
| 803 ASSERT(pInterForm != NULL); | |
| 804 | |
| 805 pInterForm->OnCalculate(pWidget->GetFormField()); | |
| 806 | |
| 807 // bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget); | |
| 808 | |
| 809 m_bNotifying = FALSE; | |
| 810 } | |
| 811 } | |
| 812 | |
| 813 void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPage
View, FX_BOOL& bExit, FX_DWORD nFlag) | |
| 814 { | |
| 815 if (!m_bNotifying) | |
| 816 { | |
| 817 ASSERT(pWidget != NULL); | |
| 818 ASSERT(pPageView != NULL); | |
| 819 // CReader_DocView* pDocView = pPageView->GetDocView(); | |
| 820 // ASSERT(pDocView != NULL); | |
| 821 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | |
| 822 ASSERT(pDocument != NULL); | |
| 823 | |
| 824 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF
orm(); | |
| 825 ASSERT(pInterForm != NULL); | |
| 826 | |
| 827 FX_BOOL bFormated = FALSE; | |
| 828 CFX_WideString sValue = pInterForm->OnFormat(pWidget->GetFormField(), bF
ormated); | |
| 829 | |
| 830 // bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget); | |
| 831 | |
| 832 if (bExit) return; | |
| 833 | |
| 834 if (bFormated) | |
| 835 { | |
| 836 pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue.c_s
tr(), TRUE); | |
| 837 pInterForm->UpdateField(pWidget->GetFormField()); | |
| 838 } | |
| 839 | |
| 840 m_bNotifying = FALSE; | |
| 841 } | |
| 842 } | |
| 843 | |
| 844 FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Anno
t* pAnnot) | |
| 845 { | |
| 846 | |
| 847 ASSERT(pPageView != NULL); | 749 ASSERT(pPageView != NULL); |
| 848 ASSERT(pAnnot != NULL); | 750 // CReader_DocView* pDocView = pPageView->GetDocView(); |
| 849 | 751 // ASSERT(pDocView != NULL); |
| 850 if(pPageView) | 752 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
| 851 return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot()); | 753 ASSERT(pDocument != NULL); |
| 852 else | 754 |
| 853 return FALSE; | 755 CPDFSDK_InterForm* pInterForm = |
| 854 } | 756 (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 855 | 757 ASSERT(pInterForm != NULL); |
| 856 void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData
, int32_t nKeyCode, | 758 |
| 857 CFX_WideString & strChange, const
CFX_WideString& strChangeEx, | 759 pInterForm->OnCalculate(pWidget->GetFormField()); |
| 858 int nSelStart, int nSelEnd, | 760 |
| 859 FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL
& bExit, FX_DWORD nFlag) | 761 // bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, |
| 860 { | 762 // pWidget); |
| 861 ASSERT(pPrivateData != NULL); | 763 |
| 862 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 764 m_bNotifying = FALSE; |
| 863 ASSERT(pData->pWidget != NULL); | 765 } |
| 864 | 766 } |
| 865 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); | 767 |
| 866 ASSERT(pFormFiller != NULL); | 768 void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget, |
| 867 | 769 CPDFSDK_PageView* pPageView, |
| 868 if (!m_bNotifying) | 770 FX_BOOL& bExit, |
| 869 { | 771 FX_DWORD nFlag) { |
| 870 if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke)) | 772 if (!m_bNotifying) { |
| 871 { | 773 ASSERT(pWidget != NULL); |
| 872 m_bNotifying = TRUE; | 774 ASSERT(pPageView != NULL); |
| 873 int nAge = pData->pWidget->GetAppearanceAge(); | 775 // CReader_DocView* pDocView = pPageView->GetDocView(); |
| 874 int nValueAge = pData->pWidget->GetValueAge(); | 776 // ASSERT(pDocView != NULL); |
| 875 | 777 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
| 876 ASSERT(pData->pPageView != NULL); | 778 ASSERT(pDocument != NULL); |
| 877 CPDFSDK_Document* pDocument = pData->pPageView->GetSDKDocument(); | 779 |
| 878 | 780 CPDFSDK_InterForm* pInterForm = |
| 879 PDFSDK_FieldAction fa; | 781 (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 880 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); | 782 ASSERT(pInterForm != NULL); |
| 881 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); | 783 |
| 882 fa.sChange = strChange; | 784 FX_BOOL bFormated = FALSE; |
| 883 fa.sChangeEx = strChangeEx; | 785 CFX_WideString sValue = |
| 884 fa.bKeyDown = bKeyDown; | 786 pInterForm->OnFormat(pWidget->GetFormField(), bFormated); |
| 885 fa.bWillCommit = FALSE; | 787 |
| 886 fa.bRC = TRUE; | 788 // bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, |
| 887 fa.nSelStart = nSelStart; | 789 // pWidget); |
| 888 fa.nSelEnd = nSelEnd; | 790 |
| 889 | 791 if (bExit) |
| 890 | 792 return; |
| 891 pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke
, fa); | 793 |
| 892 pFormFiller->SaveState(pData->pPageView); | 794 if (bFormated) { |
| 893 | 795 pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue.c_str(), |
| 894 if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pData->pP
ageView)) | 796 TRUE); |
| 895 { | 797 pInterForm->UpdateField(pWidget->GetFormField()); |
| 896 if (!IsValidAnnot(pData->pPageView, pData->pWidget)) | 798 } |
| 897 { | 799 |
| 898 bExit = TRUE; | 800 m_bNotifying = FALSE; |
| 899 m_bNotifying = FALSE; | 801 } |
| 900 return; | 802 } |
| 901 } | 803 |
| 902 | 804 FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, |
| 903 if (nAge != pData->pWidget->GetAppearanceAge()) | 805 CPDFSDK_Annot* pAnnot) { |
| 904 { | 806 ASSERT(pPageView != NULL); |
| 905 CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow(pData->pPageVie
w, nValueAge == pData->pWidget->GetValueAge()); | 807 ASSERT(pAnnot != NULL); |
| 906 pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); | 808 |
| 907 bExit = TRUE; | 809 if (pPageView) |
| 908 } | 810 return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot()); |
| 909 | 811 else |
| 910 if (fa.bRC) | 812 return FALSE; |
| 911 { | 813 } |
| 912 pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::K
eyStroke, fa); | 814 |
| 913 bRC = FALSE; | 815 void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, |
| 914 } | 816 void* pPrivateData, |
| 915 else | 817 int32_t nKeyCode, |
| 916 { | 818 CFX_WideString& strChange, |
| 917 pFormFiller->RestoreState(pData->pPageView); | 819 const CFX_WideString& strChangeEx, |
| 918 bRC = FALSE; | 820 int nSelStart, |
| 919 } | 821 int nSelEnd, |
| 920 | 822 FX_BOOL bKeyDown, |
| 921 if (pDocument->GetFocusAnnot() != pData->pWidget) | 823 FX_BOOL& bRC, |
| 922 { | 824 FX_BOOL& bExit, |
| 923 pFormFiller->CommitData(pData->pPageView,nFlag); | 825 FX_DWORD nFlag) { |
| 924 bExit = TRUE; | 826 ASSERT(pPrivateData != NULL); |
| 925 } | 827 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
| 926 } | 828 ASSERT(pData->pWidget != NULL); |
| 927 else | 829 |
| 928 { | 830 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); |
| 929 if (!IsValidAnnot(pData->pPageView, pData->pWidget)) | 831 ASSERT(pFormFiller != NULL); |
| 930 { | 832 |
| 931 bExit = TRUE; | 833 if (!m_bNotifying) { |
| 932 m_bNotifying = FALSE; | 834 if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke)) { |
| 933 return; | 835 m_bNotifying = TRUE; |
| 934 } | 836 int nAge = pData->pWidget->GetAppearanceAge(); |
| 935 } | 837 int nValueAge = pData->pWidget->GetValueAge(); |
| 936 | 838 |
| 937 m_bNotifying = FALSE; | 839 ASSERT(pData->pPageView != NULL); |
| 938 } | 840 CPDFSDK_Document* pDocument = pData->pPageView->GetSDKDocument(); |
| 939 } | 841 |
| 940 } | 842 PDFSDK_FieldAction fa; |
| 941 | 843 fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); |
| 942 void CFFL_IFormFiller::OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateDa
ta, FX_BOOL & bExit,FX_DWORD nFlag) | 844 fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag); |
| 943 { | 845 fa.sChange = strChange; |
| 944 ASSERT(pPrivateData != NULL); | 846 fa.sChangeEx = strChangeEx; |
| 945 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 847 fa.bKeyDown = bKeyDown; |
| 946 ASSERT(pData->pWidget != NULL); | 848 fa.bWillCommit = FALSE; |
| 947 | 849 fa.bRC = TRUE; |
| 948 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); | 850 fa.nSelStart = nSelStart; |
| 949 ASSERT(pFormFiller != NULL); | 851 fa.nSelEnd = nSelEnd; |
| 950 | 852 |
| 951 if (!bEditOrList) | 853 pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); |
| 952 pFormFiller->OnKeyStroke(bExit); | 854 pFormFiller->SaveState(pData->pPageView); |
| 953 } | 855 |
| 856 if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, |
| 857 pData->pPageView)) { |
| 858 if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { |
| 859 bExit = TRUE; |
| 860 m_bNotifying = FALSE; |
| 861 return; |
| 862 } |
| 863 |
| 864 if (nAge != pData->pWidget->GetAppearanceAge()) { |
| 865 CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow( |
| 866 pData->pPageView, nValueAge == pData->pWidget->GetValueAge()); |
| 867 pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); |
| 868 bExit = TRUE; |
| 869 } |
| 870 |
| 871 if (fa.bRC) { |
| 872 pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, |
| 873 fa); |
| 874 bRC = FALSE; |
| 875 } else { |
| 876 pFormFiller->RestoreState(pData->pPageView); |
| 877 bRC = FALSE; |
| 878 } |
| 879 |
| 880 if (pDocument->GetFocusAnnot() != pData->pWidget) { |
| 881 pFormFiller->CommitData(pData->pPageView, nFlag); |
| 882 bExit = TRUE; |
| 883 } |
| 884 } else { |
| 885 if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { |
| 886 bExit = TRUE; |
| 887 m_bNotifying = FALSE; |
| 888 return; |
| 889 } |
| 890 } |
| 891 |
| 892 m_bNotifying = FALSE; |
| 893 } |
| 894 } |
| 895 } |
| 896 |
| 897 void CFFL_IFormFiller::OnAfterKeyStroke(FX_BOOL bEditOrList, |
| 898 void* pPrivateData, |
| 899 FX_BOOL& bExit, |
| 900 FX_DWORD nFlag) { |
| 901 ASSERT(pPrivateData != NULL); |
| 902 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
| 903 ASSERT(pData->pWidget != NULL); |
| 904 |
| 905 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); |
| 906 ASSERT(pFormFiller != NULL); |
| 907 |
| 908 if (!bEditOrList) |
| 909 pFormFiller->OnKeyStroke(bExit); |
| 910 } |
| OLD | NEW |