summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_font
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-22 15:34:16 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-22 15:34:16 -0400
commit338805f1366dcdf9a5b48cf591541cf98d7490f1 (patch)
tree161b722bbb0628b290084b20fa8aa8f1d436c896 /core/src/fpdfapi/fpdf_font
parentc6d8683dbdd922c86375fb0520d420de13d683ed (diff)
downloadpdfium-338805f1366dcdf9a5b48cf591541cf98d7490f1.tar.xz
Add type cast definitions for CPDF_Stream.
This Cl adds ToStream, CPDF_Object::AsStream and CPDF_Object::IsStream and updates the src to use them as needed. BUG=pdfium:201 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1402413004 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_font')
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp32
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp7
2 files changed, 19 insertions, 20 deletions
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index 9954efcc5d..543816b03a 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -119,7 +119,7 @@ CPDF_Font::~CPDF_Font() {
if (m_pFontFile) {
m_pDocument->GetPageData()->ReleaseFontFileStreamAcc(
- (CPDF_Stream*)m_pFontFile->GetStream());
+ const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream()));
}
}
FX_BOOL CPDF_Font::IsVertWriting() const {
@@ -275,7 +275,7 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) {
FX_DWORD dwFontSize = m_pFontFile->GetSize();
if (!m_Font.LoadEmbedded(pFontData, dwFontSize)) {
m_pDocument->GetPageData()->ReleaseFontFileStreamAcc(
- (CPDF_Stream*)m_pFontFile->GetStream());
+ const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream()));
m_pFontFile = nullptr;
}
}
@@ -1709,10 +1709,10 @@ void CPDF_Type3Font::CheckType3FontMetrics() {
CheckFontMetrics();
}
CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) {
- if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) {
- return NULL;
- }
- CPDF_Type3Char* pChar = NULL;
+ if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_)
+ return nullptr;
+
+ CPDF_Type3Char* pChar = nullptr;
if (m_CacheMap.Lookup((void*)(uintptr_t)charcode, (void*&)pChar)) {
if (pChar->m_bPageRequired && m_pPageResources) {
delete pChar;
@@ -1723,19 +1723,19 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) {
}
const FX_CHAR* name =
GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
- return NULL;
- }
+ if (!name)
+ return nullptr;
+
CPDF_Stream* pStream =
- (CPDF_Stream*)(m_pCharProcs ? m_pCharProcs->GetElementValue(name) : NULL);
- if (pStream == NULL || pStream->GetType() != PDFOBJ_STREAM) {
- return NULL;
- }
+ ToStream(m_pCharProcs ? m_pCharProcs->GetElementValue(name) : nullptr);
+ if (!pStream)
+ return nullptr;
+
pChar = new CPDF_Type3Char;
pChar->m_pForm = new CPDF_Form(
m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources,
- pStream, NULL);
- pChar->m_pForm->ParseContent(NULL, NULL, pChar, NULL, level + 1);
+ pStream, nullptr);
+ pChar->m_pForm->ParseContent(nullptr, nullptr, pChar, nullptr, level + 1);
FX_FLOAT scale = m_FontMatrix.GetXUnit();
pChar->m_Width = (int32_t)(pChar->m_Width * scale + 0.5f);
FX_RECT& rcBBox = pChar->m_BBox;
@@ -1753,7 +1753,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) {
m_CacheMap.SetAt((void*)(uintptr_t)charcode, pChar);
if (pChar->m_pForm->CountObjects() == 0) {
delete pChar->m_pForm;
- pChar->m_pForm = NULL;
+ pChar->m_pForm = nullptr;
}
return pChar;
}
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 8972201b66..02f0933f36 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -1215,9 +1215,8 @@ FX_BOOL CPDF_CIDFont::_Load() {
->GetPageModule()
->GetFontGlobals()
->m_CMapManager.GetPredefinedCMap(cmap, m_pFontFile && m_bType1);
- } else if (pEncoding->GetType() == PDFOBJ_STREAM) {
+ } else if (CPDF_Stream* pStream = pEncoding->AsStream()) {
m_pAllocatedCMap = m_pCMap = new CPDF_CMap;
- CPDF_Stream* pStream = (CPDF_Stream*)pEncoding;
CPDF_StreamAcc acc;
acc.LoadAllData(pStream, FALSE);
m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize());
@@ -1265,9 +1264,9 @@ FX_BOOL CPDF_CIDFont::_Load() {
CPDF_Object* pmap =
pCIDFontDict->GetElementValue(FX_BSTRC("CIDToGIDMap"));
if (pmap) {
- if (pmap->GetType() == PDFOBJ_STREAM) {
+ if (CPDF_Stream* pStream = pmap->AsStream()) {
m_pCIDToGIDMap = new CPDF_StreamAcc;
- m_pCIDToGIDMap->LoadAllData((CPDF_Stream*)pmap, FALSE);
+ m_pCIDToGIDMap->LoadAllData(pStream, FALSE);
} else if (pmap->GetString() == FX_BSTRC("Identity")) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
if (m_pFontFile) {