• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
ResetPDFWindow(CPDFSDK_PageView * pPageView,bool bRestoreValue)9 CPWL_Wnd* CFFL_TextObject::ResetPDFWindow(CPDFSDK_PageView* pPageView,
10                                           bool bRestoreValue) {
11   if (bRestoreValue)
12     SaveState(pPageView);
13 
14   DestroyPDFWindow(pPageView);
15   if (bRestoreValue)
16     RestoreState(pPageView);
17 
18   CPWL_Wnd::ObservedPtr pRet(GetPDFWindow(pPageView, !bRestoreValue));
19   m_pWidget->UpdateField();  // May invoke JS, invalidating |pRet|.
20   return pRet.Get();
21 }
22 
CFFL_TextObject(CPDFSDK_FormFillEnvironment * pApp,CPDFSDK_Widget * pWidget)23 CFFL_TextObject::CFFL_TextObject(CPDFSDK_FormFillEnvironment* pApp,
24                                  CPDFSDK_Widget* pWidget)
25     : CFFL_FormFiller(pApp, pWidget) {}
26 
~CFFL_TextObject()27 CFFL_TextObject::~CFFL_TextObject() {
28   // Destroy view classes before this object's members are destroyed since
29   // the view classes have pointers to m_pFontMap that would be left dangling.
30   DestroyWindows();
31 }
32 
MaybeCreateFontMap()33 CBA_FontMap* CFFL_TextObject::MaybeCreateFontMap() {
34   if (!m_pFontMap) {
35     m_pFontMap =
36         pdfium::MakeUnique<CBA_FontMap>(m_pWidget.Get(), GetSystemHandler());
37   }
38   return m_pFontMap.get();
39 }
40