1 // Copyright 2017 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/formfiller/cffl_textobject.h" 8 9 #include "core/fpdfapi/page/cpdf_page.h" 10 #include "core/fpdfdoc/cba_fontmap.h" 11 #include "third_party/base/ptr_util.h" 12 ResetPWLWindow(CPDFSDK_PageView * pPageView,bool bRestoreValue)13CPWL_Wnd* CFFL_TextObject::ResetPWLWindow(CPDFSDK_PageView* pPageView, 14 bool bRestoreValue) { 15 if (bRestoreValue) 16 SaveState(pPageView); 17 18 DestroyPWLWindow(pPageView); 19 if (bRestoreValue) 20 RestoreState(pPageView); 21 22 ObservedPtr<CPWL_Wnd> pRet(GetPWLWindow(pPageView, !bRestoreValue)); 23 m_pWidget->UpdateField(); // May invoke JS, invalidating |pRet|. 24 return pRet.Get(); 25 } 26 CFFL_TextObject(CPDFSDK_FormFillEnvironment * pApp,CPDFSDK_Widget * pWidget)27CFFL_TextObject::CFFL_TextObject(CPDFSDK_FormFillEnvironment* pApp, 28 CPDFSDK_Widget* pWidget) 29 : CFFL_FormFiller(pApp, pWidget) {} 30 ~CFFL_TextObject()31CFFL_TextObject::~CFFL_TextObject() { 32 // Destroy view classes before this object's members are destroyed since 33 // the view classes have pointers to m_pFontMap that would be left dangling. 34 DestroyWindows(); 35 } 36 MaybeCreateFontMap()37CBA_FontMap* CFFL_TextObject::MaybeCreateFontMap() { 38 if (!m_pFontMap) { 39 m_pFontMap = pdfium::MakeUnique<CBA_FontMap>( 40 m_pWidget->GetPDFPage()->GetDocument(), 41 m_pWidget->GetPDFAnnot()->GetAnnotDict()); 42 } 43 return m_pFontMap.get(); 44 } 45