diff options
author | thestig <thestig@chromium.org> | 2016-06-07 10:46:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-07 10:46:23 -0700 |
commit | 4997b22f84307521a62838f874928bf56cd3423c (patch) | |
tree | ad11d99ac0a491ee222e9d0a42ec3b6ad3354e2a /core/fpdfdoc/doc_viewerPreferences.cpp | |
parent | 0687e76dc259c678b3f29a6608331f07ffd8f1e2 (diff) | |
download | pdfium-4997b22f84307521a62838f874928bf56cd3423c.tar.xz |
Get rid of NULLs in core/
Review-Url: https://codereview.chromium.org/2032613003
Diffstat (limited to 'core/fpdfdoc/doc_viewerPreferences.cpp')
-rw-r--r-- | core/fpdfdoc/doc_viewerPreferences.cpp | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/core/fpdfdoc/doc_viewerPreferences.cpp b/core/fpdfdoc/doc_viewerPreferences.cpp index a355635bf0..1de8c92614 100644 --- a/core/fpdfdoc/doc_viewerPreferences.cpp +++ b/core/fpdfdoc/doc_viewerPreferences.cpp @@ -9,46 +9,35 @@ CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc) : m_pDoc(pDoc) {} + CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {} + FX_BOOL CPDF_ViewerPreferences::IsDirectionR2L() const { - CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return FALSE; - } - return "R2L" == pDict->GetStringBy("Direction"); + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetStringBy("Direction") == "R2L" : FALSE; } + FX_BOOL CPDF_ViewerPreferences::PrintScaling() const { - CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return TRUE; - } - return "None" != pDict->GetStringBy("PrintScaling"); + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetStringBy("PrintScaling") != "None" : TRUE; } + int32_t CPDF_ViewerPreferences::NumCopies() const { - CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return 1; - } - return pDict->GetIntegerBy("NumCopies"); + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetIntegerBy("NumCopies") : 1; } + CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const { - CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - CPDF_Array* pRange = NULL; - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return pRange; - } - pRange = pDict->GetArrayBy("PrintPageRange"); - return pRange; + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetArrayBy("PrintPageRange") : nullptr; } + CFX_ByteString CPDF_ViewerPreferences::Duplex() const { + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetStringBy("Duplex") : CFX_ByteString("None"); +} + +CPDF_Dictionary* CPDF_ViewerPreferences::GetViewerPreferences() const { CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return "None"; - } - return pDict->GetStringBy("Duplex"); + return pDict ? pDict->GetDictBy("ViewerPreferences") : nullptr; } |