OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 |
| 7 #include "fpdfsdk/include/cpdfsdk_baannothandler.h" |
| 8 |
| 9 #include <memory> |
| 10 #include <vector> |
| 11 |
| 12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 14 #include "core/fpdfdoc/include/cpdf_interform.h" |
| 15 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
| 16 #include "fpdfsdk/include/cpdfsdk_annot.h" |
| 17 #include "fpdfsdk/include/cpdfsdk_baannot.h" |
| 18 #include "fpdfsdk/include/fsdk_mgr.h" |
| 19 |
| 20 #ifdef PDF_ENABLE_XFA |
| 21 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
| 22 #endif // PDF_ENABLE_XFA |
| 23 |
| 24 namespace { |
| 25 |
| 26 void UpdateAnnotRects(CPDFSDK_PageView* pPageView, CPDFSDK_BAAnnot* pBAAnnot) { |
| 27 std::vector<CFX_FloatRect> rects; |
| 28 rects.push_back(pBAAnnot->GetRect()); |
| 29 if (CPDF_Annot* pPopupAnnot = pBAAnnot->GetPDFPopupAnnot()) |
| 30 rects.push_back(pPopupAnnot->GetRect()); |
| 31 pPageView->UpdateRects(rects); |
| 32 } |
| 33 |
| 34 } // namespace |
| 35 |
| 36 CPDFSDK_BAAnnotHandler::CPDFSDK_BAAnnotHandler() {} |
| 37 |
| 38 CPDFSDK_BAAnnotHandler::~CPDFSDK_BAAnnotHandler() {} |
| 39 |
| 40 CFX_ByteString CPDFSDK_BAAnnotHandler::GetType() { |
| 41 return CFX_ByteString(""); |
| 42 } |
| 43 |
| 44 FX_BOOL CPDFSDK_BAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
| 45 return FALSE; |
| 46 } |
| 47 |
| 48 CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, |
| 49 CPDFSDK_PageView* pPage) { |
| 50 return new CPDFSDK_BAAnnot(pAnnot, pPage); |
| 51 } |
| 52 |
| 53 #ifdef PDF_ENABLE_XFA |
| 54 CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CXFA_FFWidget* hWidget, |
| 55 CPDFSDK_PageView* pPage) { |
| 56 return nullptr; |
| 57 } |
| 58 #endif // PDF_ENABLE_XFA |
| 59 |
| 60 void CPDFSDK_BAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
| 61 delete pAnnot; |
| 62 } |
| 63 |
| 64 void CPDFSDK_BAAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} |
| 65 |
| 66 void CPDFSDK_BAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, |
| 67 CPDFSDK_Annot* pAnnot, |
| 68 CFX_RenderDevice* pDevice, |
| 69 CFX_Matrix* pUser2Device, |
| 70 uint32_t dwFlags) { |
| 71 #ifdef PDF_ENABLE_XFA |
| 72 if (pAnnot->IsXFAField()) |
| 73 return; |
| 74 #endif // PDF_ENABLE_XFA |
| 75 static_cast<CPDFSDK_BAAnnot*>(pAnnot)->DrawAppearance( |
| 76 pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
| 77 } |
| 78 |
| 79 void CPDFSDK_BAAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, |
| 80 CPDFSDK_Annot* pAnnot, |
| 81 CFX_RenderDevice* pDevice, |
| 82 CFX_Matrix* pUser2Device, |
| 83 const CFX_FloatRect& rcWindow, |
| 84 uint32_t dwFlags) {} |
| 85 |
| 86 void CPDFSDK_BAAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} |
| 87 |
| 88 void CPDFSDK_BAAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} |
| 89 |
| 90 void CPDFSDK_BAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 91 CPDFSDK_Annot* pAnnot, |
| 92 uint32_t nFlag) { |
| 93 CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot); |
| 94 pBAAnnot->SetOpenState(true); |
| 95 UpdateAnnotRects(pPageView, pBAAnnot); |
| 96 } |
| 97 |
| 98 void CPDFSDK_BAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView, |
| 99 CPDFSDK_Annot* pAnnot, |
| 100 uint32_t nFlag) { |
| 101 CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot); |
| 102 pBAAnnot->SetOpenState(false); |
| 103 UpdateAnnotRects(pPageView, pBAAnnot); |
| 104 } |
| 105 |
| 106 FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 107 CPDFSDK_Annot* pAnnot, |
| 108 uint32_t nFlags, |
| 109 const CFX_FloatPoint& point) { |
| 110 return FALSE; |
| 111 } |
| 112 |
| 113 FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 114 CPDFSDK_Annot* pAnnot, |
| 115 uint32_t nFlags, |
| 116 const CFX_FloatPoint& point) { |
| 117 return FALSE; |
| 118 } |
| 119 |
| 120 FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
| 121 CPDFSDK_Annot* pAnnot, |
| 122 uint32_t nFlags, |
| 123 const CFX_FloatPoint& point) { |
| 124 return FALSE; |
| 125 } |
| 126 |
| 127 FX_BOOL CPDFSDK_BAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView, |
| 128 CPDFSDK_Annot* pAnnot, |
| 129 uint32_t nFlags, |
| 130 const CFX_FloatPoint& point) { |
| 131 return FALSE; |
| 132 } |
| 133 |
| 134 FX_BOOL CPDFSDK_BAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 135 CPDFSDK_Annot* pAnnot, |
| 136 uint32_t nFlags, |
| 137 short zDelta, |
| 138 const CFX_FloatPoint& point) { |
| 139 return FALSE; |
| 140 } |
| 141 |
| 142 FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 143 CPDFSDK_Annot* pAnnot, |
| 144 uint32_t nFlags, |
| 145 const CFX_FloatPoint& point) { |
| 146 return FALSE; |
| 147 } |
| 148 |
| 149 FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 150 CPDFSDK_Annot* pAnnot, |
| 151 uint32_t nFlags, |
| 152 const CFX_FloatPoint& point) { |
| 153 return FALSE; |
| 154 } |
| 155 |
| 156 FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, |
| 157 CPDFSDK_Annot* pAnnot, |
| 158 uint32_t nFlags, |
| 159 const CFX_FloatPoint& point) { |
| 160 return FALSE; |
| 161 } |
| 162 |
| 163 FX_BOOL CPDFSDK_BAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, |
| 164 uint32_t nChar, |
| 165 uint32_t nFlags) { |
| 166 return FALSE; |
| 167 } |
| 168 |
| 169 FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 170 int nKeyCode, |
| 171 int nFlag) { |
| 172 return FALSE; |
| 173 } |
| 174 |
| 175 FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, |
| 176 int nKeyCode, |
| 177 int nFlag) { |
| 178 return FALSE; |
| 179 } |
| 180 |
| 181 void CPDFSDK_BAAnnotHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {} |
| 182 |
| 183 void CPDFSDK_BAAnnotHandler::OnSelected(CPDFSDK_Annot* pAnnot) {} |
| 184 |
| 185 void CPDFSDK_BAAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) {} |
| 186 |
| 187 void CPDFSDK_BAAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} |
| 188 |
| 189 FX_BOOL CPDFSDK_BAAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, |
| 190 uint32_t nFlag) { |
| 191 return FALSE; |
| 192 } |
| 193 |
| 194 FX_BOOL CPDFSDK_BAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, |
| 195 uint32_t nFlag) { |
| 196 return FALSE; |
| 197 } |
| 198 |
| 199 #ifdef PDF_ENABLE_XFA |
| 200 FX_BOOL CPDFSDK_BAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
| 201 CPDFSDK_Annot* pNewAnnot) { |
| 202 return TRUE; |
| 203 } |
| 204 #endif // PDF_ENABLE_XFA |
| 205 |
| 206 CFX_FloatRect CPDFSDK_BAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, |
| 207 CPDFSDK_Annot* pAnnot) { |
| 208 return pAnnot->GetRect(); |
| 209 } |
| 210 |
| 211 FX_BOOL CPDFSDK_BAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, |
| 212 CPDFSDK_Annot* pAnnot, |
| 213 const CFX_FloatPoint& point) { |
| 214 ASSERT(pPageView); |
| 215 ASSERT(pAnnot); |
| 216 |
| 217 CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); |
| 218 return rect.Contains(point.x, point.y); |
| 219 } |
OLD | NEW |