diff options
author | tsepez <tsepez@chromium.org> | 2016-06-07 21:56:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-07 21:56:50 -0700 |
commit | a431e238ee42025cce44c3a76dd07c470d7f51ec (patch) | |
tree | db9761e5b59b30df8d5cf91a283dcb6db58f75f2 /core/fpdfapi | |
parent | f27aeec59186e7d11a3a2167572617fd5ed42941 (diff) | |
download | pdfium-a431e238ee42025cce44c3a76dd07c470d7f51ec.tar.xz |
Avoid const-cast in CPDF_Font
Introduce a logically const initialization (via mutable
members) so that this can happen lazily under const methods.
Review-Url: https://codereview.chromium.org/2045033002
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_font.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/include/cpdf_font.h | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp index 78bdeeffaa..c15ac6b445 100644 --- a/core/fpdfapi/fpdf_font/cpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp @@ -165,7 +165,7 @@ void CPDF_Font::AppendChar(CFX_ByteString& str, uint32_t charcode) const { CFX_WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const { if (!m_bToUnicodeLoaded) - ((CPDF_Font*)this)->LoadUnicodeMap(); + LoadUnicodeMap(); if (m_pToUnicodeMap) return m_pToUnicodeMap->Lookup(charcode); @@ -174,7 +174,7 @@ CFX_WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const { uint32_t CPDF_Font::CharCodeFromUnicode(FX_WCHAR unicode) const { if (!m_bToUnicodeLoaded) - ((CPDF_Font*)this)->LoadUnicodeMap(); + LoadUnicodeMap(); if (m_pToUnicodeMap) return m_pToUnicodeMap->ReverseLookup(unicode); @@ -294,7 +294,7 @@ void CPDF_Font::CheckFontMetrics() { } } -void CPDF_Font::LoadUnicodeMap() { +void CPDF_Font::LoadUnicodeMap() const { m_bToUnicodeLoaded = TRUE; CPDF_Stream* pStream = m_pFontDict->GetStreamBy("ToUnicode"); if (!pStream) { diff --git a/core/fpdfapi/fpdf_font/include/cpdf_font.h b/core/fpdfapi/fpdf_font/include/cpdf_font.h index 81518408e7..31badd2656 100644 --- a/core/fpdfapi/fpdf_font/include/cpdf_font.h +++ b/core/fpdfapi/fpdf_font/include/cpdf_font.h @@ -99,7 +99,7 @@ class CPDF_Font { virtual FX_BOOL Load() = 0; FX_BOOL Initialize(); - void LoadUnicodeMap(); + void LoadUnicodeMap() const; // logically const only. void LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding, CFX_ByteString*& pCharNames, @@ -115,8 +115,8 @@ class CPDF_Font { CFX_ByteString m_BaseFont; CPDF_StreamAcc* m_pFontFile; CPDF_Dictionary* m_pFontDict; - CPDF_ToUnicodeMap* m_pToUnicodeMap; - FX_BOOL m_bToUnicodeLoaded; + mutable CPDF_ToUnicodeMap* m_pToUnicodeMap; + mutable FX_BOOL m_bToUnicodeLoaded; int m_Flags; FX_RECT m_FontBBox; int m_StemV; |