Chromium Code Reviews| 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/fpdf_ext.h" | 9 #include "../include/fpdf_ext.h" |
| 10 #include "../include/formfiller/FFL_FormFiller.h" | 10 #include "../include/formfiller/FFL_FormFiller.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 } | 325 } |
| 326 | 326 |
| 327 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv ):m_pDoc(pDoc), | 327 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv ):m_pDoc(pDoc), |
| 328 m_pInterForm(NULL),m_pEnv(pEnv), m_pOccontent(NULL),m_bChangeMask(FALSE) | 328 m_pInterForm(NULL),m_pEnv(pEnv), m_pOccontent(NULL),m_bChangeMask(FALSE) |
| 329 { | 329 { |
| 330 m_pFocusAnnot = NULL; | 330 m_pFocusAnnot = NULL; |
| 331 } | 331 } |
| 332 | 332 |
| 333 CPDFSDK_Document::~CPDFSDK_Document() | 333 CPDFSDK_Document::~CPDFSDK_Document() |
| 334 { | 334 { |
| 335 » m_pageMap.RemoveAll(); | 335 » FX_POSITION pos = m_pageMap.GetStartPosition(); |
| 336 » while (pos) { | |
| 337 CPDF_Page* pPage = NULL; | |
| 338 CPDFSDK_PageView* pPageView = NULL; | |
| 339 m_pageMap.GetNextAssoc(pos, pPage, pPageView); | |
| 340 delete pPageView; | |
|
Tom Sepez
2014/09/23 23:38:54
don't we need to remove the item from the page map
Bo Xu
2014/09/24 00:04:30
delete pPageView is removing the value of the hash
| |
| 341 } | |
| 342 m_pageMap.RemoveAll(); | |
| 336 if(m_pInterForm) | 343 if(m_pInterForm) |
| 337 { | 344 { |
| 338 m_pInterForm->Destroy(); | 345 m_pInterForm->Destroy(); |
| 339 m_pInterForm = NULL; | 346 m_pInterForm = NULL; |
| 340 } | 347 } |
| 341 if(m_pOccontent) | 348 if(m_pOccontent) |
| 342 { | 349 { |
| 343 delete m_pOccontent; | 350 delete m_pOccontent; |
| 344 m_pOccontent = NULL; | 351 m_pOccontent = NULL; |
| 345 } | 352 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 CPDF_OCContext* CPDFSDK_Document::GetOCContext() | 453 CPDF_OCContext* CPDFSDK_Document::GetOCContext() |
| 447 { | 454 { |
| 448 if(!m_pOccontent) | 455 if(!m_pOccontent) |
| 449 m_pOccontent = new CPDF_OCContext(m_pDoc); | 456 m_pOccontent = new CPDF_OCContext(m_pDoc); |
| 450 return m_pOccontent; | 457 return m_pOccontent; |
| 451 } | 458 } |
| 452 | 459 |
| 453 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage) | 460 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage) |
| 454 { | 461 { |
| 455 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pP DFPage); | 462 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pP DFPage); |
| 456 » if(pPageView) | 463 » if(pPageView && !pPageView->IsLocked()) |
| 457 { | 464 { |
| 458 delete pPageView; | 465 delete pPageView; |
| 459 m_pageMap.RemoveKey(pPDFPage); | 466 m_pageMap.RemoveKey(pPDFPage); |
| 460 } | 467 } |
| 461 } | 468 } |
| 462 | 469 |
| 463 CPDF_Page * CPDFSDK_Document::GetPage(int nIndex) | 470 CPDF_Page * CPDFSDK_Document::GetPage(int nIndex) |
| 464 { | 471 { |
| 465 CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex); | 472 CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex); |
| 466 if(!pTempPage) | 473 if(!pTempPage) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 | 608 |
| 602 | 609 |
| 603 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_ page(page),m_pSDKDoc(pSDKDoc) | 610 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_ page(page),m_pSDKDoc(pSDKDoc) |
| 604 { | 611 { |
| 605 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 612 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
| 606 if(pInterForm) | 613 if(pInterForm) |
| 607 { | 614 { |
| 608 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 615 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 609 pPDFInterForm->FixPageFields(page); | 616 pPDFInterForm->FixPageFields(page); |
| 610 } | 617 } |
| 611 | 618 m_page->SetPrivateData((FX_LPVOID)m_page, (FX_LPVOID)this, NULL); |
| 612 m_fxAnnotArray.RemoveAll(); | 619 m_fxAnnotArray.RemoveAll(); |
| 613 | 620 |
| 614 m_bEnterWidget = FALSE; | 621 m_bEnterWidget = FALSE; |
| 615 m_bExitWidget = FALSE; | 622 m_bExitWidget = FALSE; |
| 616 m_bOnWidget = FALSE; | 623 m_bOnWidget = FALSE; |
| 617 m_CaptureWidget = NULL; | 624 m_CaptureWidget = NULL; |
| 618 » m_bValid = FALSE; | 625 » m_Flag = 0; |
| 619 } | 626 } |
| 620 | 627 |
| 621 CPDFSDK_PageView::~CPDFSDK_PageView() | 628 CPDFSDK_PageView::~CPDFSDK_PageView() |
| 622 { | 629 { |
| 623 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 630 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 624 int nAnnotCount = m_fxAnnotArray.GetSize(); | 631 int nAnnotCount = m_fxAnnotArray.GetSize(); |
| 632 | |
| 625 for (int i=0; i<nAnnotCount; i++) | 633 for (int i=0; i<nAnnotCount; i++) |
| 626 { | 634 { |
| 627 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 635 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
| 628 //if there is a focused annot on the page, we should kill the fo cus first. | 636 //if there is a focused annot on the page, we should kill the fo cus first. |
| 629 if(pAnnot == m_pSDKDoc->GetFocusAnnot()) | 637 if(pAnnot == m_pSDKDoc->GetFocusAnnot()) |
| 630 KillFocusAnnot(); | 638 KillFocusAnnot(); |
| 631 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); | 639 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); |
| 632 ASSERT(pAnnotHandlerMgr); | 640 ASSERT(pAnnotHandlerMgr); |
| 633 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); | 641 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
| 634 } | 642 } |
| 635 m_fxAnnotArray.RemoveAll(); | 643 m_fxAnnotArray.RemoveAll(); |
| 636 if(m_pAnnotList) | 644 if(m_pAnnotList) |
| 637 { | 645 { |
| 638 delete m_pAnnotList; | 646 delete m_pAnnotList; |
| 639 m_pAnnotList = NULL; | 647 m_pAnnotList = NULL; |
| 640 } | 648 } |
| 649 m_page->RemovePrivateData((FX_LPVOID)m_page); | |
| 650 if(m_Flag & PAGEVIEW_FLAG_TAKEOVERPAGE) { | |
| 651 delete m_page; | |
| 652 } | |
| 641 } | 653 } |
| 642 | 654 |
| 643 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p User2Device,CPDF_RenderOptions* pOptions) | 655 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p User2Device,CPDF_RenderOptions* pOptions) |
| 644 { | 656 { |
| 645 m_curMatrix = *pUser2Device; | 657 m_curMatrix = *pUser2Device; |
| 646 | 658 |
| 647 // m_pAnnotList->DisplayAnnots(m_page, pDevice, pUser2Device, FALSE , pOptions); | 659 // m_pAnnotList->DisplayAnnots(m_page, pDevice, pUser2Device, FALSE , pOptions); |
| 648 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 660 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 649 CPDFSDK_AnnotIterator annotIterator(this, TRUE); | 661 CPDFSDK_AnnotIterator annotIterator(this, TRUE); |
| 650 CPDFSDK_Annot * pSDKAnnot=NULL; | 662 CPDFSDK_Annot * pSDKAnnot=NULL; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 965 void CPDFSDK_PageView::LoadFXAnnots() | 977 void CPDFSDK_PageView::LoadFXAnnots() |
| 966 { | 978 { |
| 967 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 979 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 968 | 980 |
| 969 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | 981 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
| 970 //Disable the default AP construction. | 982 //Disable the default AP construction. |
| 971 CPDF_InterForm::EnableUpdateAP(FALSE); | 983 CPDF_InterForm::EnableUpdateAP(FALSE); |
| 972 m_pAnnotList = new CPDF_AnnotList(m_page); | 984 m_pAnnotList = new CPDF_AnnotList(m_page); |
| 973 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | 985 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
| 974 int nCount = m_pAnnotList->Count(); | 986 int nCount = m_pAnnotList->Count(); |
| 987 SetLock(); | |
| 975 for(int i=0; i<nCount; i++) | 988 for(int i=0; i<nCount; i++) |
| 976 { | 989 { |
| 977 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 990 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
| 978 CPDF_Document * pDoc = this->GetPDFDocument(); | 991 CPDF_Document * pDoc = this->GetPDFDocument(); |
| 979 | 992 |
| 980 CheckUnSupportAnnot(pDoc, pPDFAnnot); | 993 CheckUnSupportAnnot(pDoc, pPDFAnnot); |
| 981 | 994 |
| 982 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); | 995 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); |
| 983 ASSERT(pAnnotHandlerMgr != NULL); | 996 ASSERT(pAnnotHandlerMgr != NULL); |
| 997 | |
| 984 if(pAnnotHandlerMgr) | 998 if(pAnnotHandlerMgr) |
| 985 { | 999 { |
| 986 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFA nnot, this); | 1000 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFA nnot, this); |
| 987 if(!pAnnot) | 1001 if(!pAnnot) |
| 988 continue; | 1002 continue; |
| 989 m_fxAnnotArray.Add(pAnnot); | 1003 m_fxAnnotArray.Add(pAnnot); |
| 990 | 1004 |
| 991 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 1005 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 992 } | 1006 } |
| 993 | 1007 |
| 994 } | 1008 } |
| 1009 ClearLock(); | |
| 995 } | 1010 } |
| 996 | 1011 |
| 997 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) | 1012 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) |
| 998 { | 1013 { |
| 999 for(int i=0; i<rects.GetSize(); i++) | 1014 for(int i=0; i<rects.GetSize(); i++) |
| 1000 { | 1015 { |
| 1001 CPDF_Rect rc = rects.GetAt(i); | 1016 CPDF_Rect rc = rects.GetAt(i); |
| 1002 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1017 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 1003 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.botto m); | 1018 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.botto m); |
| 1004 } | 1019 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 | 1066 |
| 1052 for(int i=0; i<m_fxAnnotArray.GetSize(); i++) | 1067 for(int i=0; i<m_fxAnnotArray.GetSize(); i++) |
| 1053 { | 1068 { |
| 1054 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 1069 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
| 1055 if(pAnnot == pFocusAnnot) | 1070 if(pAnnot == pFocusAnnot) |
| 1056 return pAnnot; | 1071 return pAnnot; |
| 1057 } | 1072 } |
| 1058 return NULL; | 1073 return NULL; |
| 1059 } | 1074 } |
| 1060 | 1075 |
| OLD | NEW |