summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/doc_basic.cpp19
-rw-r--r--core/fpdfdoc/include/fpdf_doc.h5
2 files changed, 15 insertions, 9 deletions
diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp
index a3e94cb033..a0c6b2babc 100644
--- a/core/fpdfdoc/doc_basic.cpp
+++ b/core/fpdfdoc/doc_basic.cpp
@@ -71,12 +71,19 @@ FX_FLOAT CPDF_Dest::GetParam(int index) {
CFX_ByteString CPDF_Dest::GetRemoteName() {
return m_pObj ? m_pObj->GetString() : CFX_ByteString();
}
+
CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc,
- const CFX_ByteStringC& category) {
- if (pDoc->GetRoot() && pDoc->GetRoot()->GetDictBy("Names"))
- m_pRoot = pDoc->GetRoot()->GetDictBy("Names")->GetDictBy(category);
- else
- m_pRoot = NULL;
+ const CFX_ByteString& category)
+ : m_pRoot(nullptr) {
+ CPDF_Dictionary* pRoot = pDoc->GetRoot();
+ if (!pRoot)
+ return;
+
+ CPDF_Dictionary* pNames = pRoot->GetDictBy("Names");
+ if (!pNames)
+ return;
+
+ m_pRoot = pNames->GetDictBy(category);
}
static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
@@ -233,7 +240,7 @@ CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const {
return SearchNameNode(m_pRoot, csName, nIndex, NULL);
}
CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc,
- const CFX_ByteStringC& sName) {
+ const CFX_ByteString& sName) {
CPDF_Object* pValue = LookupValue(sName);
if (!pValue) {
CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictBy("Dests");
diff --git a/core/fpdfdoc/include/fpdf_doc.h b/core/fpdfdoc/include/fpdf_doc.h
index b8bc56b0cc..c11bf43c4e 100644
--- a/core/fpdfdoc/include/fpdf_doc.h
+++ b/core/fpdfdoc/include/fpdf_doc.h
@@ -51,12 +51,11 @@ class CFX_RenderDevice;
class CPDF_NameTree {
public:
explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {}
- CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteStringC& category);
+ CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteString& category);
CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const;
CPDF_Object* LookupValue(const CFX_ByteString& csName) const;
- CPDF_Array* LookupNamedDest(CPDF_Document* pDoc,
- const CFX_ByteStringC& sName);
+ CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const CFX_ByteString& sName);
int GetIndex(const CFX_ByteString& csName) const;
size_t GetCount() const;
CPDF_Dictionary* GetRoot() const { return m_pRoot; }