From a44a48043e54eac6126c9a2cfae9e6055ef4a15f Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 21 Sep 2017 10:45:18 -0400 Subject: Move CFGAS_PDFFontMgr to the CXFA_FFDoc This CL removes the map of CXFA_FFDoc -> CFGAS_PDFFontMgr from the CXFA_FontMgr and moves the storage of the PDFFontMgr into the CXFA_FFDoc itself. Change-Id: Ia725ddd94b1ac2c9504bfd6370040ab6ac01e272 Reviewed-on: https://pdfium-review.googlesource.com/14590 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffdoc.cpp | 6 ++++-- xfa/fxfa/cxfa_ffdoc.h | 3 +++ xfa/fxfa/cxfa_fontmgr.cpp | 16 +++------------- xfa/fxfa/cxfa_fontmgr.h | 3 --- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index b3ff3c9930..316987fcc3 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -241,7 +241,9 @@ int32_t CXFA_FFDoc::DoLoad() { } void CXFA_FFDoc::StopLoad() { - m_pApp->GetXFAFontMgr()->LoadDocFonts(this); + m_pPDFFontMgr = pdfium::MakeUnique( + GetPDFDoc(), GetApp()->GetFDEFontMgr()); + m_dwDocType = XFA_DocType::Static; CXFA_Node* pConfig = ToNode( m_pDocumentParser->GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); @@ -327,7 +329,7 @@ void CXFA_FFDoc::CloseDoc() { doc->ClearLayoutData(); m_pNotify.reset(); - m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this); + m_pPDFFontMgr.reset(); m_HashToDibDpiMap.clear(); m_pApp->ClearEventTargets(); } diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h index 7984d7425b..1d35c669da 100644 --- a/xfa/fxfa/cxfa_ffdoc.h +++ b/xfa/fxfa/cxfa_ffdoc.h @@ -15,6 +15,7 @@ #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_document_parser.h" +class CFGAS_PDFFontMgr; class CFX_ChecksumContext; class CXFA_FFApp; class CXFA_FFNotify; @@ -72,6 +73,7 @@ class CXFA_FFDoc { CFX_RetainPtr GetPDFNamedImage(const WideStringView& wsName, int32_t& iImageXDpi, int32_t& iImageYDpi); + CFGAS_PDFFontMgr* GetPDFFontMgr() const { return m_pPDFFontMgr.get(); } bool SavePackage(XFA_HashCode code, const CFX_RetainPtr& pFile, @@ -88,6 +90,7 @@ class CXFA_FFDoc { CFX_UnownedPtr m_pPDFDoc; std::map m_HashToDibDpiMap; std::unique_ptr m_DocView; + std::unique_ptr m_pPDFFontMgr; XFA_DocType m_dwDocType; }; diff --git a/xfa/fxfa/cxfa_fontmgr.cpp b/xfa/fxfa/cxfa_fontmgr.cpp index d5ba2ea807..5a11dd5dc0 100644 --- a/xfa/fxfa/cxfa_fontmgr.cpp +++ b/xfa/fxfa/cxfa_fontmgr.cpp @@ -36,9 +36,8 @@ CFX_RetainPtr CXFA_FontMgr::GetFont( return iter->second; WideString wsEnglishName = FGAS_FontNameToEnglishName(wsFontFamily); - auto it = m_PDFFontMgrMap.find(hDoc); - CFGAS_PDFFontMgr* pMgr = - it != m_PDFFontMgrMap.end() ? it->second.get() : nullptr; + + CFGAS_PDFFontMgr* pMgr = hDoc->GetPDFFontMgr(); CPDF_Font* pPDFFont = nullptr; CFX_RetainPtr pFont; if (pMgr) { @@ -62,6 +61,7 @@ CFX_RetainPtr CXFA_FontMgr::GetFont( pFont = m_pDefFontMgr->GetDefaultFont( hDoc->GetApp()->GetFDEFontMgr(), wsFontFamily, dwFontStyles, wCodePage); } + if (pFont) { if (pPDFFont) { pMgr->SetFont(pFont, pPDFFont); @@ -72,16 +72,6 @@ CFX_RetainPtr CXFA_FontMgr::GetFont( return pFont; } -void CXFA_FontMgr::LoadDocFonts(CXFA_FFDoc* hDoc) { - if (!m_PDFFontMgrMap[hDoc]) - m_PDFFontMgrMap[hDoc] = pdfium::MakeUnique( - hDoc->GetPDFDoc(), hDoc->GetApp()->GetFDEFontMgr()); -} - -void CXFA_FontMgr::ReleaseDocFonts(CXFA_FFDoc* hDoc) { - m_PDFFontMgrMap.erase(hDoc); -} - void CXFA_FontMgr::SetDefFontMgr( std::unique_ptr pFontMgr) { m_pDefFontMgr = std::move(pFontMgr); diff --git a/xfa/fxfa/cxfa_fontmgr.h b/xfa/fxfa/cxfa_fontmgr.h index 988964dab2..b7d1f51ff2 100644 --- a/xfa/fxfa/cxfa_fontmgr.h +++ b/xfa/fxfa/cxfa_fontmgr.h @@ -30,13 +30,10 @@ class CXFA_FontMgr { const WideStringView& wsFontFamily, uint32_t dwFontStyles, uint16_t wCodePage = 0xFFFF); - void LoadDocFonts(CXFA_FFDoc* hDoc); - void ReleaseDocFonts(CXFA_FFDoc* hDoc); void SetDefFontMgr(std::unique_ptr pFontMgr); private: std::unique_ptr m_pDefFontMgr; - std::map> m_PDFFontMgrMap; std::map> m_FontMap; }; -- cgit v1.2.3