diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/page/cpdf_streamparser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_crypto_handler.cpp | 8 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_crypto_handler.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 27 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_stream_acc.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.cpp | 10 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_decode.cpp | 16 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_decode.h | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_defaultappearance.cpp | 13 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_defaultappearance.h | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_docjsactions.cpp | 7 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_docjsactions.h | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_formcontrol.cpp | 5 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interform.cpp | 60 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interform.h | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_nametree.cpp | 11 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_nametree.h | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_fontmap.cpp | 28 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_fontmap.h | 7 |
20 files changed, 105 insertions, 107 deletions
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp index 3c4e534116..e0c6e25aef 100644 --- a/core/fpdfapi/page/cpdf_streamparser.cpp +++ b/core/fpdfapi/page/cpdf_streamparser.cpp @@ -62,7 +62,7 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, uint32_t limit, int width, int height, - CFX_ByteString& decoder, + const CFX_ByteString& decoder, CPDF_Dictionary* pParam, uint8_t*& dest_buf, uint32_t& dest_size) { diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp index 4fc7b3039b..ea09601b30 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp +++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp @@ -227,14 +227,14 @@ bool CPDF_CryptoHandler::CryptFinish(void* context, return true; } -void CPDF_CryptoHandler::Decrypt(uint32_t objnum, - uint32_t gennum, - CFX_ByteString& str) { +CFX_ByteString CPDF_CryptoHandler::Decrypt(uint32_t objnum, + uint32_t gennum, + const CFX_ByteString& str) { CFX_BinaryBuf dest_buf; void* context = DecryptStart(objnum, gennum); DecryptStream(context, str.raw_str(), str.GetLength(), dest_buf); DecryptFinish(context, dest_buf); - str = CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize()); + return CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize()); } void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) { diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h index 63a2590950..1e3890a55b 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.h +++ b/core/fpdfapi/parser/cpdf_crypto_handler.h @@ -23,7 +23,9 @@ class CPDF_CryptoHandler { CPDF_SecurityHandler* pSecurityHandler); uint32_t DecryptGetSize(uint32_t src_size); void* DecryptStart(uint32_t objnum, uint32_t gennum); - void Decrypt(uint32_t objnum, uint32_t gennum, CFX_ByteString& str); + CFX_ByteString Decrypt(uint32_t objnum, + uint32_t gennum, + const CFX_ByteString& str); bool DecryptStream(void* context, const uint8_t* src_buf, uint32_t src_size, diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index 5a2db8861c..aa0b4fdad6 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -837,7 +837,7 @@ void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) { m_Pos = dwOffset; } -bool CPDF_DataAvail::GetNextToken(CFX_ByteString& token) { +bool CPDF_DataAvail::GetNextToken(CFX_ByteString* token) { uint8_t ch; if (!GetNextChar(ch)) return false; @@ -870,11 +870,9 @@ bool CPDF_DataAvail::GetNextToken(CFX_ByteString& token) { if (!PDFCharIsOther(ch) && !PDFCharIsNumeric(ch)) { m_Pos--; - CFX_ByteString ret(buffer, index); - token = ret; + *token = CFX_ByteString(buffer, index); return true; } - if (index < sizeof(buffer)) buffer[index++] = ch; } @@ -895,9 +893,7 @@ bool CPDF_DataAvail::GetNextToken(CFX_ByteString& token) { else m_Pos--; } - - CFX_ByteString ret(buffer, index); - token = ret; + *token = CFX_ByteString(buffer, index); return true; } @@ -914,7 +910,7 @@ bool CPDF_DataAvail::GetNextToken(CFX_ByteString& token) { } } - token = CFX_ByteString(buffer, index); + *token = CFX_ByteString(buffer, index); return true; } @@ -948,8 +944,9 @@ bool CPDF_DataAvail::CheckCrossRefItem(DownloadHints* pHints) { int32_t iSize = 0; CFX_ByteString token; while (1) { - if (!GetNextToken(token)) { - iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); + if (!GetNextToken(&token)) { + iSize = static_cast<int32_t>( + m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); pHints->AddSegment(m_Pos, iSize); return false; } @@ -983,8 +980,9 @@ bool CPDF_DataAvail::CheckAllCrossRefStream(DownloadHints* pHints) { bool CPDF_DataAvail::CheckCrossRef(DownloadHints* pHints) { int32_t iSize = 0; CFX_ByteString token; - if (!GetNextToken(token)) { - iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); + if (!GetNextToken(&token)) { + iSize = static_cast<int32_t>(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos + : 512); pHints->AddSegment(m_Pos, iSize); return false; } @@ -995,8 +993,9 @@ bool CPDF_DataAvail::CheckCrossRef(DownloadHints* pHints) { } while (1) { - if (!GetNextToken(token)) { - iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); + if (!GetNextToken(&token)) { + iSize = static_cast<int32_t>( + m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); pHints->AddSegment(m_Pos, iSize); m_docStatus = PDF_DATAAVAIL_CROSSREF_ITEM; return false; diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index 65638cff0b..62c5d49c9d 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -156,7 +156,7 @@ class CPDF_DataAvail final { int32_t CheckCrossRefStream(DownloadHints* pHints, FX_FILESIZE& xref_offset); bool IsLinearizedFile(uint8_t* pData, uint32_t dwLen); void SetStartOffset(FX_FILESIZE dwOffset); - bool GetNextToken(CFX_ByteString& token); + bool GetNextToken(CFX_ByteString* token); bool GetNextChar(uint8_t& ch); std::unique_ptr<CPDF_Object> ParseIndirectObjectAt( FX_FILESIZE pos, diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp index 77ef2ff2bc..fe333e4d2b 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.cpp +++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp @@ -43,7 +43,7 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess, m_pData = pSrcData; m_dwSize = dwSrcSize; } else if (!PDF_DataDecode(pSrcData, dwSrcSize, m_pStream->GetDict(), m_pData, - m_dwSize, m_ImageDecoder, m_pImageParam, + m_dwSize, &m_ImageDecoder, m_pImageParam, estimated_size, bImageAcc)) { m_pData = pSrcData; m_dwSize = dwSrcSize; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index 73bf56d206..1c84b859db 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -405,13 +405,13 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObject( if (word == "(") { CFX_ByteString str = ReadString(); if (m_pCryptoHandler && bDecrypt) - m_pCryptoHandler->Decrypt(objnum, gennum, str); + str = m_pCryptoHandler->Decrypt(objnum, gennum, str); return pdfium::MakeUnique<CPDF_String>(m_pPool, str, false); } if (word == "<") { CFX_ByteString str = ReadHexString(); if (m_pCryptoHandler && bDecrypt) - m_pCryptoHandler->Decrypt(objnum, gennum, str); + str = m_pCryptoHandler->Decrypt(objnum, gennum, str); return pdfium::MakeUnique<CPDF_String>(m_pPool, str, true); } if (word == "[") { @@ -526,17 +526,17 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectForStrict( if (word == "(") { CFX_ByteString str = ReadString(); if (m_pCryptoHandler) - m_pCryptoHandler->Decrypt(objnum, gennum, str); + str = m_pCryptoHandler->Decrypt(objnum, gennum, str); return pdfium::MakeUnique<CPDF_String>(m_pPool, str, false); } if (word == "<") { CFX_ByteString str = ReadHexString(); if (m_pCryptoHandler) - m_pCryptoHandler->Decrypt(objnum, gennum, str); + str = m_pCryptoHandler->Decrypt(objnum, gennum, str); return pdfium::MakeUnique<CPDF_String>(m_pPool, str, true); } if (word == "[") { - std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); + auto pArray = pdfium::MakeUnique<CPDF_Array>(); while (std::unique_ptr<CPDF_Object> pObj = GetObject(pObjList, objnum, gennum, true)) { pArray->Add(std::move(pObj)); diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index a1698aedde..cc8b507025 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -327,7 +327,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, const CPDF_Dictionary* pDict, uint8_t*& dest_buf, uint32_t& dest_size, - CFX_ByteString& ImageEncoding, + CFX_ByteString* ImageEncoding, CPDF_Dictionary*& pImageParms, uint32_t last_estimated_size, bool bImageAcc) { @@ -362,8 +362,8 @@ bool PDF_DataDecode(const uint8_t* src_buf, int offset = -1; if (decoder == "FlateDecode" || decoder == "Fl") { if (bImageAcc && i == nSize - 1) { - ImageEncoding = "FlateDecode"; - dest_buf = (uint8_t*)last_buf; + *ImageEncoding = "FlateDecode"; + dest_buf = last_buf; dest_size = last_size; pImageParms = pParam; return true; @@ -379,8 +379,8 @@ bool PDF_DataDecode(const uint8_t* src_buf, offset = HexDecode(last_buf, last_size, new_buf, new_size); } else if (decoder == "RunLengthDecode" || decoder == "RL") { if (bImageAcc && i == nSize - 1) { - ImageEncoding = "RunLengthDecode"; - dest_buf = (uint8_t*)last_buf; + *ImageEncoding = "RunLengthDecode"; + dest_buf = last_buf; dest_size = last_size; pImageParms = pParam; return true; @@ -395,9 +395,9 @@ bool PDF_DataDecode(const uint8_t* src_buf, } else if (decoder == "CCF") { decoder = "CCITTFaxDecode"; } - ImageEncoding = decoder; + *ImageEncoding = decoder; pImageParms = pParam; - dest_buf = (uint8_t*)last_buf; + dest_buf = last_buf; dest_size = last_size; if (CPDF_Array* pDecoders = pDecoder->AsArray()) pDecoders->RemoveAt(i + 1, pDecoders->GetCount() - i - 1); @@ -413,7 +413,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, last_buf = new_buf; last_size = new_size; } - ImageEncoding = ""; + *ImageEncoding = ""; pImageParms = nullptr; dest_buf = last_buf; dest_size = last_size; diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h index 0c74e41058..955a8cfb32 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.h +++ b/core/fpdfapi/parser/fpdf_parser_decode.h @@ -87,7 +87,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, const CPDF_Dictionary* pDict, uint8_t*& dest_buf, uint32_t& dest_size, - CFX_ByteString& ImageEncoding, + CFX_ByteString* ImageEncoding, CPDF_Dictionary*& pImageParms, uint32_t estimated_size, bool bImageAcc); diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp index 1873c1ae58..28213aa33b 100644 --- a/core/fpdfdoc/cpdf_defaultappearance.cpp +++ b/core/fpdfdoc/cpdf_defaultappearance.cpp @@ -36,20 +36,19 @@ CFX_ByteString CPDF_DefaultAppearance::GetFontString() { return csFont; } -void CPDF_DefaultAppearance::GetFont(CFX_ByteString& csFontNameTag, - float& fFontSize) { - csFontNameTag = ""; - fFontSize = 0; +CFX_ByteString CPDF_DefaultAppearance::GetFont(float* fFontSize) { + *fFontSize = 0.0f; if (m_csDA.IsEmpty()) - return; + return CFX_ByteString(); + CFX_ByteString csFontNameTag; CPDF_SimpleParser syntax(m_csDA.AsStringC()); if (syntax.FindTagParamFromStart("Tf", 2)) { csFontNameTag = CFX_ByteString(syntax.GetWord()); csFontNameTag.Delete(0, 1); - fFontSize = FX_atof(syntax.GetWord()); + *fFontSize = FX_atof(syntax.GetWord()); } - csFontNameTag = PDF_NameDecode(csFontNameTag); + return PDF_NameDecode(csFontNameTag); } bool CPDF_DefaultAppearance::HasColor(PaintOperation nOperation) { diff --git a/core/fpdfdoc/cpdf_defaultappearance.h b/core/fpdfdoc/cpdf_defaultappearance.h index 0edc18c31f..3be06e294d 100644 --- a/core/fpdfdoc/cpdf_defaultappearance.h +++ b/core/fpdfdoc/cpdf_defaultappearance.h @@ -29,7 +29,7 @@ class CPDF_DefaultAppearance { bool HasFont(); CFX_ByteString GetFontString(); - void GetFont(CFX_ByteString& csFontNameTag, float& fFontSize); + CFX_ByteString GetFont(float* fFontSize); bool HasColor(PaintOperation nOperation = PaintOperation::FILL); CFX_ByteString GetColorString( diff --git a/core/fpdfdoc/cpdf_docjsactions.cpp b/core/fpdfdoc/cpdf_docjsactions.cpp index a7fcdfd071..c0e7a78fd6 100644 --- a/core/fpdfdoc/cpdf_docjsactions.cpp +++ b/core/fpdfdoc/cpdf_docjsactions.cpp @@ -16,11 +16,12 @@ int CPDF_DocJSActions::CountJSActions() const { return name_tree.GetCount(); } -CPDF_Action CPDF_DocJSActions::GetJSAction(int index, - CFX_ByteString& csName) const { +CPDF_Action CPDF_DocJSActions::GetJSActionAndName( + int index, + CFX_ByteString* csName) const { ASSERT(m_pDocument); CPDF_NameTree name_tree(m_pDocument, "JavaScript"); - CPDF_Object* pAction = name_tree.LookupValue(index, csName); + CPDF_Object* pAction = name_tree.LookupValueAndName(index, csName); return ToDictionary(pAction) ? CPDF_Action(pAction->GetDict()) : CPDF_Action(); } diff --git a/core/fpdfdoc/cpdf_docjsactions.h b/core/fpdfdoc/cpdf_docjsactions.h index 8a8d03d364..16b6be3d69 100644 --- a/core/fpdfdoc/cpdf_docjsactions.h +++ b/core/fpdfdoc/cpdf_docjsactions.h @@ -17,7 +17,7 @@ class CPDF_DocJSActions { explicit CPDF_DocJSActions(CPDF_Document* pDoc); int CountJSActions() const; - CPDF_Action GetJSAction(int index, CFX_ByteString& csName) const; + CPDF_Action GetJSActionAndName(int index, CFX_ByteString* csName) const; CPDF_Action GetJSAction(const CFX_ByteString& csName) const; int FindJSAction(const CFX_ByteString& csName) const; CPDF_Document* GetDocument() const { return m_pDocument; } diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp index b8a11cc204..d8d6854b82 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp @@ -280,10 +280,9 @@ CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() { } CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { - CPDF_DefaultAppearance cDA = GetDefaultAppearance(); - CFX_ByteString csFontNameTag; float fFontSize; - cDA.GetFont(csFontNameTag, fFontSize); + CPDF_DefaultAppearance cDA = GetDefaultAppearance(); + CFX_ByteString csFontNameTag = cDA.GetFont(&fFontSize); if (csFontNameTag.IsEmpty()) return nullptr; diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index 1192e6e556..ebe5079f3b 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -55,7 +55,7 @@ CFX_WideString GetFieldValue(const CPDF_Dictionary& pFieldDict, void AddFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, const CPDF_Font* pFont, - CFX_ByteString& csNameTag); + CFX_ByteString* csNameTag); void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { if (!pDocument) @@ -70,27 +70,24 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { CFX_ByteString csDA; if (!pFormDict->KeyExist("DR")) { CFX_ByteString csBaseName; - CFX_ByteString csDefault; uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); CPDF_Font* pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); - if (pFont) { - AddFont(pFormDict, pDocument, pFont, csBaseName); - csDefault = csBaseName; - } + if (pFont) + AddFont(pFormDict, pDocument, pFont, &csBaseName); + if (charSet != FXFONT_ANSI_CHARSET) { CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr); if (!pFont || csFontName != "Helvetica") { pFont = CPDF_InterForm::AddNativeFont(pDocument); if (pFont) { - csBaseName = ""; - AddFont(pFormDict, pDocument, pFont, csBaseName); - csDefault = csBaseName; + csBaseName.clear(); + AddFont(pFormDict, pDocument, pFont, &csBaseName); } } } if (pFont) - csDA = "/" + PDF_NameEncode(csDefault) + " 0 Tf"; + csDA = "/" + PDF_NameEncode(csBaseName) + " 0 Tf"; } if (!csDA.IsEmpty()) csDA += " "; @@ -102,7 +99,7 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { CPDF_Font* GetFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, - CFX_ByteString csNameTag) { + const CFX_ByteString& csNameTag) { CFX_ByteString csAlias = PDF_NameDecode(csNameTag); if (!pFormDict || csAlias.IsEmpty()) return nullptr; @@ -127,7 +124,7 @@ CPDF_Font* GetFont(CPDF_Dictionary* pFormDict, CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, uint8_t charSet, - CFX_ByteString& csNameTag) { + CFX_ByteString* csNameTag) { if (!pFormDict) return nullptr; @@ -157,8 +154,8 @@ CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict, if (!pSubst) continue; - if (pSubst->m_Charset == (int)charSet) { - csNameTag = csKey; + if (pSubst->m_Charset == static_cast<int>(charSet)) { + *csNameTag = csKey; return pFind; } } @@ -167,7 +164,7 @@ CPDF_Font* GetNativeFont(CPDF_Dictionary* pFormDict, bool FindFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont, - CFX_ByteString& csNameTag) { + CFX_ByteString* csNameTag) { if (!pFormDict || !pFont) return false; @@ -189,7 +186,7 @@ bool FindFont(CPDF_Dictionary* pFormDict, if (pElement->GetStringFor("Type") != "Font") continue; if (pFont->GetFontDict() == pElement) { - csNameTag = csKey; + *csNameTag = csKey; return true; } } @@ -200,7 +197,7 @@ bool FindFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString csFontName, CPDF_Font*& pFont, - CFX_ByteString& csNameTag) { + CFX_ByteString* csNameTag) { if (!pFormDict) return false; @@ -211,6 +208,7 @@ bool FindFont(CPDF_Dictionary* pFormDict, CPDF_Dictionary* pFonts = pDR->GetDictFor("Font"); if (!pFonts) return false; + if (csFontName.GetLength() > 0) csFontName.Remove(' '); @@ -232,7 +230,7 @@ bool FindFont(CPDF_Dictionary* pFormDict, csBaseFont = pFont->GetBaseFont(); csBaseFont.Remove(' '); if (csBaseFont == csFontName) { - csNameTag = csKey; + *csNameTag = csKey; return true; } } @@ -242,15 +240,15 @@ bool FindFont(CPDF_Dictionary* pFormDict, void AddFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, const CPDF_Font* pFont, - CFX_ByteString& csNameTag) { + CFX_ByteString* csNameTag) { if (!pFont) return; if (!pFormDict) InitDict(pFormDict, pDocument); CFX_ByteString csTag; - if (FindFont(pFormDict, pFont, csTag)) { - csNameTag = csTag; + if (FindFont(pFormDict, pFont, &csTag)) { + *csNameTag = csTag; return; } if (!pFormDict) @@ -264,27 +262,27 @@ void AddFont(CPDF_Dictionary*& pFormDict, if (!pFonts) pFonts = pDR->SetNewFor<CPDF_Dictionary>("Font"); - if (csNameTag.IsEmpty()) - csNameTag = pFont->GetBaseFont(); + if (csNameTag->IsEmpty()) + *csNameTag = pFont->GetBaseFont(); - csNameTag.Remove(' '); - csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, - csNameTag.c_str()); - pFonts->SetNewFor<CPDF_Reference>(csNameTag, pDocument, + csNameTag->Remove(' '); + *csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, + csNameTag->c_str()); + pFonts->SetNewFor<CPDF_Reference>(*csNameTag, pDocument, pFont->GetFontDict()->GetObjNum()); } CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, uint8_t charSet, - CFX_ByteString& csNameTag) { + CFX_ByteString* csNameTag) { if (!pFormDict) InitDict(pFormDict, pDocument); CFX_ByteString csTemp; - CPDF_Font* pFont = GetNativeFont(pFormDict, pDocument, charSet, csTemp); + CPDF_Font* pFont = GetNativeFont(pFormDict, pDocument, charSet, &csTemp); if (pFont) { - csNameTag = csTemp; + *csNameTag = csTemp; return pFont; } CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr); @@ -565,7 +563,7 @@ CFieldTree::Node* CFieldTree::FindNode(const CFX_WideString& full_name) { CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, - CFX_ByteString& csNameTag) { + CFX_ByteString* csNameTag) { uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); return AddNativeFont(pFormDict, pDocument, charSet, csNameTag); } diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h index 6c464f023d..74e5b10864 100644 --- a/core/fpdfdoc/cpdf_interform.h +++ b/core/fpdfdoc/cpdf_interform.h @@ -29,7 +29,7 @@ class IPDF_FormNotify; CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, - CFX_ByteString& csNameTag); + CFX_ByteString* csNameTag); class CPDF_InterForm { public: diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp index b8d1eb0ab1..5ecdb4863b 100644 --- a/core/fpdfdoc/cpdf_nametree.cpp +++ b/core/fpdfdoc/cpdf_nametree.cpp @@ -78,7 +78,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, size_t nIndex, size_t& nCurIndex, - CFX_ByteString& csName, + CFX_ByteString* csName, CPDF_Array** ppFind, int nLevel = 0) { if (nLevel > nMaxRecursion) @@ -93,7 +93,7 @@ CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, } if (ppFind) *ppFind = pNames; - csName = pNames->GetStringAt((nIndex - nCurIndex) * 2); + *csName = pNames->GetStringAt((nIndex - nCurIndex) * 2); return pNames->GetDirectObjectAt((nIndex - nCurIndex) * 2 + 1); } CPDF_Array* pKids = pNode->GetArrayFor("Kids"); @@ -164,10 +164,12 @@ int CPDF_NameTree::GetIndex(const CFX_ByteString& csName) const { return nIndex; } -CPDF_Object* CPDF_NameTree::LookupValue(int nIndex, - CFX_ByteString& csName) const { +CPDF_Object* CPDF_NameTree::LookupValueAndName(int nIndex, + CFX_ByteString* csName) const { + *csName = CFX_ByteString(); if (!m_pRoot) return nullptr; + size_t nCurIndex = 0; return SearchNameNode(m_pRoot, nIndex, nCurIndex, csName, nullptr); } @@ -175,6 +177,7 @@ CPDF_Object* CPDF_NameTree::LookupValue(int nIndex, CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const { if (!m_pRoot) return nullptr; + size_t nIndex = 0; return SearchNameNode(m_pRoot, csName, nIndex, nullptr); } diff --git a/core/fpdfdoc/cpdf_nametree.h b/core/fpdfdoc/cpdf_nametree.h index d6763ad987..7a792aef59 100644 --- a/core/fpdfdoc/cpdf_nametree.h +++ b/core/fpdfdoc/cpdf_nametree.h @@ -19,7 +19,7 @@ class CPDF_NameTree { explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteString& category); - CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const; + CPDF_Object* LookupValueAndName(int nIndex, CFX_ByteString* csName) const; CPDF_Object* LookupValue(const CFX_ByteString& csName) const; CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const CFX_ByteString& sName); diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp index 283f60011b..17ce673fde 100644 --- a/core/fpdfdoc/cpvt_fontmap.cpp +++ b/core/fpdfdoc/cpvt_fontmap.cpp @@ -25,25 +25,23 @@ CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc, CPVT_FontMap::~CPVT_FontMap() {} -void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc, - const CPDF_Dictionary* pResDict, - CPDF_Font*& pSysFont, - CFX_ByteString& sSysFontAlias) { +CPDF_Font* CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc, + const CPDF_Dictionary* pResDict, + CFX_ByteString* sSysFontAlias) { if (!pDoc || !pResDict) - return; + return nullptr; - CFX_ByteString sFontAlias; CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictFor("AcroForm"); CPDF_Font* pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysFontAlias); if (!pPDFFont) - return; + return nullptr; CPDF_Dictionary* pFontList = pResDict->GetDictFor("Font"); - if (pFontList && !pFontList->KeyExist(sSysFontAlias)) { - pFontList->SetNewFor<CPDF_Reference>(sSysFontAlias, pDoc, + if (pFontList && !pFontList->KeyExist(*sSysFontAlias)) { + pFontList->SetNewFor<CPDF_Reference>(*sSysFontAlias, pDoc, pPDFFont->GetFontDict()->GetObjNum()); } - pSysFont = pPDFFont; + return pPDFFont; } CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) { @@ -52,8 +50,8 @@ CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) { return m_pDefFont; case 1: if (!m_pSysFont) { - GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont, - m_sSysFontAlias); + m_pSysFont = + GetAnnotSysPDFFont(m_pDocument, m_pResDict, &m_sSysFontAlias); } return m_pSysFont; default: @@ -67,12 +65,12 @@ CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) { return m_sDefFontAlias; case 1: if (!m_pSysFont) { - GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont, - m_sSysFontAlias); + m_pSysFont = + GetAnnotSysPDFFont(m_pDocument, m_pResDict, &m_sSysFontAlias); } return m_sSysFontAlias; default: - return ""; + return CFX_ByteString(); } } diff --git a/core/fpdfdoc/cpvt_fontmap.h b/core/fpdfdoc/cpvt_fontmap.h index 98e390f409..6080010cac 100644 --- a/core/fpdfdoc/cpvt_fontmap.h +++ b/core/fpdfdoc/cpvt_fontmap.h @@ -33,10 +33,9 @@ class CPVT_FontMap : public IPVT_FontMap { int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override; int32_t CharSetFromUnicode(uint16_t word, int32_t nOldCharset) override; - static void GetAnnotSysPDFFont(CPDF_Document* pDoc, - const CPDF_Dictionary* pResDict, - CPDF_Font*& pSysFont, - CFX_ByteString& sSysFontAlias); + static CPDF_Font* GetAnnotSysPDFFont(CPDF_Document* pDoc, + const CPDF_Dictionary* pResDict, + CFX_ByteString* sSysFontAlias); private: CPDF_Document* const m_pDocument; |