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/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
8 #include "../include/fsdk_mgr.h" | 8 #include "../include/fsdk_mgr.h" |
9 #include "../include/formfiller/FFL_FormFiller.h" | 9 #include "../include/formfiller/FFL_FormFiller.h" |
10 #include "../include/fsdk_annothandler.h" | 10 #include "../include/fsdk_annothandler.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 | 281 |
282 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) | 282 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) |
283 { | 283 { |
284 ASSERT(pAnnot != NULL); | 284 ASSERT(pAnnot != NULL); |
285 | 285 |
286 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 286 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
287 { | 287 { |
288 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) | 288 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) |
289 { | 289 { |
290 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); | 290 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
291 ASSERT(pPage != NULL); | |
292 | |
293 pPage->GetSDKDocument(); | 291 pPage->GetSDKDocument(); |
294 // pDocument->SetTopmostAnnot(pAnnot); | |
295 | |
296 return TRUE; | 292 return TRUE; |
297 } | 293 } |
298 else | |
299 { | |
300 return FALSE; | |
301 } | |
302 } | 294 } |
303 | |
304 return FALSE; | 295 return FALSE; |
305 } | 296 } |
306 | 297 |
307 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot , FX_DWORD nFlag) | 298 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot , FX_DWORD nFlag) |
308 { | 299 { |
309 ASSERT(pAnnot != NULL); | 300 ASSERT(pAnnot); |
310 | |
311 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 301 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
312 { | 302 return pAnnotHandler->OnKillFocus(pAnnot, nFlag); |
313 if (pAnnotHandler->OnKillFocus(pAnnot, nFlag)) | |
314 { | |
315 return TRUE; | |
316 } | |
317 else | |
318 return FALSE; | |
319 } | |
320 | 303 |
321 return FALSE; | 304 return FALSE; |
322 } | 305 } |
323 | 306 |
324 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPage View, CPDFSDK_Annot* pAnnot) | 307 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPage View, CPDFSDK_Annot* pAnnot) |
325 { | 308 { |
326 ASSERT(pAnnot); | 309 ASSERT(pAnnot); |
327 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 310 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
328 { | |
329 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); | 311 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); |
330 } | 312 |
331 return pAnnot->GetRect(); | 313 return pAnnot->GetRect(); |
332 } | 314 } |
333 | 315 |
334 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP DFSDK_Annot* pAnnot, const CPDF_Point& point) | 316 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP DFSDK_Annot* pAnnot, const CPDF_Point& point) |
335 { | 317 { |
336 ASSERT(pAnnot); | 318 ASSERT(pAnnot); |
337 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 319 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
338 { | 320 { |
339 if(pAnnotHandler->CanAnswer(pAnnot)) | 321 if (pAnnotHandler->CanAnswer(pAnnot)) |
340 return pAnnotHandler->HitTest(pPageView, pAnnot, point); | 322 return pAnnotHandler->HitTest(pPageView, pAnnot, point); |
341 } | 323 } |
342 return FALSE; | 324 return FALSE; |
343 } | 325 } |
344 | 326 |
345 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,F X_BOOL bNext) | 327 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,F X_BOOL bNext) |
346 { | 328 { |
347 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); | 329 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); |
348 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); | 330 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
349 } | 331 } |
350 | 332 |
351 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) | 333 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) |
352 { | 334 { |
353 ASSERT(pAnnot); | 335 if (pAnnot->GetSubType() == BFFT_SIGNATURE) |
354 ASSERT(pAnnot->GetType() == "Widget"); | 336 return FALSE; |
Lei Zhang
2015/07/21 21:44:47
Should we keep this assert?
Tom Sepez
2015/07/22 20:38:24
Done.
| |
355 CFX_ByteString sSubType = pAnnot->GetSubType(); | |
356 | 337 |
357 if (sSubType == BFFT_SIGNATURE) | 338 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
358 { | 339 if (!pWidget->IsVisible()) |
359 } | 340 return FALSE; |
360 else | |
361 { | |
362 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | |
363 if (!pWidget->IsVisible()) return FALSE; | |
364 | 341 |
365 int nFieldFlags = pWidget->GetFieldFlags(); | 342 int nFieldFlags = pWidget->GetFieldFlags(); |
366 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) return FAL SE; | 343 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
367 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) | 344 return FALSE; |
368 return TRUE; | |
369 else | |
370 { | |
371 CPDF_Page* pPage = pWidget->GetPDFPage(); | |
372 ASSERT(pPage != NULL); | |
373 | 345 |
374 CPDF_Document* pDocument = pPage->m_pDocument; | 346 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
375 ASSERT(pDocument != NULL); | 347 return TRUE; |
376 | 348 |
377 FX_DWORD dwPermissions = pDocument->GetUserPermissions(); | 349 CPDF_Page* pPage = pWidget->GetPDFPage(); |
378 return (dwPermissions&FPDFPERM_FILL_FORM) || | 350 CPDF_Document* pDocument = pPage->m_pDocument; |
379 (dwPermissions&FPDFPERM_ANNOT_FORM) || | 351 FX_DWORD dwPermissions = pDocument->GetUserPermissions(); |
380 (dwPermissions&FPDFPERM_ANNOT_FORM); | 352 return (dwPermissions & FPDFPERM_FILL_FORM) || |
381 } | 353 (dwPermissions & FPDFPERM_ANNOT_FORM); |
382 } | |
383 | |
384 return FALSE; | |
385 } | 354 } |
386 | 355 |
387 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_Page View* pPage) | 356 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_Page View* pPage) |
388 { | 357 { |
389 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); | 358 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
390 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm(); | 359 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm(); |
391 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(pInterForm->GetInte rForm(), pAnnot->GetAnnotDict()); | 360 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(pInterForm->GetInte rForm(), pAnnot->GetAnnotDict()); |
392 if (!pCtrl) | 361 if (!pCtrl) |
393 return nullptr; | 362 return nullptr; |
394 | 363 |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
866 arrayList[j + 1] = arrayList[j]; | 835 arrayList[j + 1] = arrayList[j]; |
867 } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arrayList[j]) < 0); | 836 } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arrayList[j]) < 0); |
868 | 837 |
869 arrayList[j+1] = pTemp; | 838 arrayList[j+1] = pTemp; |
870 } | 839 } |
871 } | 840 } |
872 } | 841 } |
873 | 842 |
874 int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) | 843 int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) |
875 { | 844 { |
876 if(p1->GetLayoutOrder() < p2->GetLayoutOrder()) | 845 if (p1->GetLayoutOrder() < p2->GetLayoutOrder()) |
877 return -1; | 846 return -1; |
878 else if (p1->GetLayoutOrder() == p2->GetLayoutOrder()) | 847 if (p1->GetLayoutOrder() > p2->GetLayoutOrder()) |
879 return 0; | |
880 else | |
881 return 1; | 848 return 1; |
849 return 0; | |
882 } | 850 } |
883 | 851 |
884 FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView ,CFX_PtrArray * pAnnotList) | 852 FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView ,CFX_PtrArray * pAnnotList) |
885 { | 853 { |
886 ASSERT(pPageView); | 854 ASSERT(pPageView); |
887 | 855 |
888 if(pAnnotList==NULL){ | 856 if(pAnnotList==NULL){ |
889 pAnnotList=pPageView->GetAnnotList(); | 857 pAnnotList=pPageView->GetAnnotList(); |
890 } | 858 } |
891 | 859 |
(...skipping 22 matching lines...) Expand all Loading... | |
914 { | 882 { |
915 m_pIteratorAnnotList.RemoveAt(i); | 883 m_pIteratorAnnotList.RemoveAt(i); |
916 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot); | 884 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot); |
917 break; | 885 break; |
918 } | 886 } |
919 } | 887 } |
920 } | 888 } |
921 | 889 |
922 return TRUE; | 890 return TRUE; |
923 } | 891 } |
OLD | NEW |