diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/formfiller/cba_fontmap.cpp | 21 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cba_fontmap.h | 6 | ||||
-rw-r--r-- | fpdfsdk/fpdf_ext.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/fpdf_sysfontinfo.cpp | 12 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_FontMap.cpp | 7 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_FontMap.h | 2 |
6 files changed, 25 insertions, 28 deletions
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp index 750b41627e..1c380e59c1 100644 --- a/fpdfsdk/formfiller/cba_fontmap.cpp +++ b/fpdfsdk/formfiller/cba_fontmap.cpp @@ -45,7 +45,7 @@ void CBA_FontMap::Initialize() { int32_t nCharset = FXFONT_DEFAULT_CHARSET; if (!m_pDefaultFont) { - m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); + m_pDefaultFont = GetAnnotDefaultFont(&m_sDefaultFontName); if (m_pDefaultFont) { if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) { nCharset = pSubstFont->m_Charset; @@ -83,7 +83,7 @@ void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont, AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); } -CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, +CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString* sFontAlias, int32_t nCharset) { if (m_pAnnotDict->GetStringFor("Subtype") != "Widget") return nullptr; @@ -109,7 +109,7 @@ CPDF_Document* CBA_FontMap::GetDocument() { } CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, - CFX_ByteString& sFontAlias, + CFX_ByteString* sFontAlias, int32_t nCharset) { if (!pResDict) return nullptr; @@ -138,7 +138,7 @@ CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, if (!pSubst) continue; if (pSubst->m_Charset == nCharset) { - sFontAlias = csKey; + *sFontAlias = csKey; pFind = pFont; } } @@ -194,7 +194,7 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, } } -CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) { +CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString* sAlias) { CPDF_Dictionary* pAcroFormDict = nullptr; const bool bWidget = (m_pAnnotDict->GetStringFor("Subtype") == "Widget"); if (bWidget) { @@ -218,27 +218,26 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) { CPDF_SimpleParser syntax(sDA.AsStringC()); syntax.FindTagParamFromStart("Tf", 2); + CFX_ByteString sFontName(syntax.GetWord()); - sAlias = PDF_NameDecode(sFontName).Mid(1); - CPDF_Dictionary* pFontDict = nullptr; + *sAlias = PDF_NameDecode(sFontName).Mid(1); + CPDF_Dictionary* pFontDict = nullptr; if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictFor("AP")) { if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictFor("N")) { if (CPDF_Dictionary* pNormalResDict = pNormalDict->GetDictFor("Resources")) { if (CPDF_Dictionary* pResFontDict = pNormalResDict->GetDictFor("Font")) - pFontDict = pResFontDict->GetDictFor(sAlias); + pFontDict = pResFontDict->GetDictFor(*sAlias); } } } - if (bWidget && !pFontDict && pAcroFormDict) { if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictFor("DR")) { if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictFor("Font")) - pFontDict = pDRFontDict->GetDictFor(sAlias); + pFontDict = pDRFontDict->GetDictFor(*sAlias); } } - return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; } diff --git a/fpdfsdk/formfiller/cba_fontmap.h b/fpdfsdk/formfiller/cba_fontmap.h index c0e569a0d3..09a5a38116 100644 --- a/fpdfsdk/formfiller/cba_fontmap.h +++ b/fpdfsdk/formfiller/cba_fontmap.h @@ -26,14 +26,14 @@ class CBA_FontMap : public CPWL_FontMap { // CPWL_FontMap: void Initialize() override; CPDF_Document* GetDocument() override; - CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, + CPDF_Font* FindFontSameCharset(CFX_ByteString* sFontAlias, int32_t nCharset) override; void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias) override; CPDF_Font* FindResFontSameCharset(CPDF_Dictionary* pResDict, - CFX_ByteString& sFontAlias, + CFX_ByteString* sFontAlias, int32_t nCharset); - CPDF_Font* GetAnnotDefaultFont(CFX_ByteString& csNameTag); + CPDF_Font* GetAnnotDefaultFont(CFX_ByteString* csNameTag); void AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAlias); CPDF_Document* m_pDocument; diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp index 2db4aaf787..8773d680ea 100644 --- a/fpdfsdk/fpdf_ext.cpp +++ b/fpdfsdk/fpdf_ext.cpp @@ -79,9 +79,10 @@ bool CheckSharedForm(const CXML_Element* pElement, CFX_ByteString cbName) { int count = pElement->CountAttrs(); int i = 0; for (i = 0; i < count; i++) { - CFX_ByteString space, name; + CFX_ByteString space; + CFX_ByteString name; CFX_WideString value; - pElement->GetAttrByIndex(i, space, name, value); + pElement->GetAttrByIndex(i, &space, &name, &value); if (space == "xmlns" && name == "adhocwf" && value == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") { CXML_Element* pVersion = diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp index 3d15ca3a41..6939eba14d 100644 --- a/fpdfsdk/fpdf_sysfontinfo.cpp +++ b/fpdfsdk/fpdf_sysfontinfo.cpp @@ -58,7 +58,7 @@ class CFX_ExternalFontInfo final : public IFX_SystemFontInfo { return m_pInfo->GetFontData(m_pInfo, hFont, table, buffer, size); } - bool GetFaceName(void* hFont, CFX_ByteString& name) override { + bool GetFaceName(void* hFont, CFX_ByteString* name) override { if (!m_pInfo->GetFaceName) return false; uint32_t size = m_pInfo->GetFaceName(m_pInfo, hFont, nullptr, 0); @@ -66,16 +66,16 @@ class CFX_ExternalFontInfo final : public IFX_SystemFontInfo { return false; char* buffer = FX_Alloc(char, size); size = m_pInfo->GetFaceName(m_pInfo, hFont, buffer, size); - name = CFX_ByteString(buffer, size); + *name = CFX_ByteString(buffer, size); FX_Free(buffer); return true; } - bool GetFontCharset(void* hFont, int& charset) override { + bool GetFontCharset(void* hFont, int* charset) override { if (!m_pInfo->GetFontCharset) return false; - charset = m_pInfo->GetFontCharset(m_pInfo, hFont); + *charset = m_pInfo->GetFontCharset(m_pInfo, hFont); return true; } @@ -155,7 +155,7 @@ static unsigned long DefaultGetFaceName(struct _FPDF_SYSFONTINFO* pThis, unsigned long buf_size) { CFX_ByteString name; auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); - if (!pDefault->m_pFontInfo->GetFaceName(hFont, name)) + if (!pDefault->m_pFontInfo->GetFaceName(hFont, &name)) return 0; if (name.GetLength() >= (long)buf_size) return name.GetLength() + 1; @@ -168,7 +168,7 @@ static unsigned long DefaultGetFaceName(struct _FPDF_SYSFONTINFO* pThis, static int DefaultGetFontCharset(struct _FPDF_SYSFONTINFO* pThis, void* hFont) { int charset; auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); - if (!pDefault->m_pFontInfo->GetFontCharset(hFont, charset)) + if (!pDefault->m_pFontInfo->GetFontCharset(hFont, &charset)) return 0; return charset; } diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/pdfwindow/PWL_FontMap.cpp index a7c42698cd..ddf496fbb0 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.cpp +++ b/fpdfsdk/pdfwindow/PWL_FontMap.cpp @@ -180,10 +180,7 @@ int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, return nFontIndex; CFX_ByteString sAlias; - CPDF_Font* pFont = nullptr; - if (bFind) - pFont = FindFontSameCharset(sAlias, nCharset); - + CPDF_Font* pFont = bFind ? FindFontSameCharset(&sAlias, nCharset) : nullptr; if (!pFont) { CFX_ByteString sTemp = sFontName; pFont = AddFontToDocument(GetDocument(), sTemp, nCharset); @@ -193,7 +190,7 @@ int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, return AddFontData(pFont, sAlias, nCharset); } -CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, +CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString* sFontAlias, int32_t nCharset) { return nullptr; } diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.h b/fpdfsdk/pdfwindow/PWL_FontMap.h index c14fcd7cd3..21535305ae 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.h +++ b/fpdfsdk/pdfwindow/PWL_FontMap.h @@ -53,7 +53,7 @@ class CPWL_FontMap : public IPVT_FontMap { protected: virtual void Initialize(); virtual CPDF_Document* GetDocument(); - virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, + virtual CPDF_Font* FindFontSameCharset(CFX_ByteString* sFontAlias, int32_t nCharset); virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); |