From 5fd907b8266766152377a9836abfcac0161832fc Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 19 Nov 2015 22:20:59 -0800 Subject: Merge to XFA: Add more overrides. Using Chromium's clang + build options, there's more override warnings. TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1453643002 . (cherry picked from commit 126ba519bdd489ec6c285d1410dcae773e8ef673) Review URL: https://codereview.chromium.org/1458373002 . --- core/include/fpdfapi/fpdf_resource.h | 38 +++++----- core/include/fxcrt/fx_stream.h | 83 ++++++++++----------- core/src/fpdfapi/fpdf_font/ttgsubtable.h | 5 +- core/src/fxcodec/codec/codec_int.h | 123 ++++++++++++++++--------------- core/src/fxcodec/codec/fx_codec_jbig.cpp | 2 +- core/src/fxcrt/extension.h | 40 +++++----- 6 files changed, 144 insertions(+), 147 deletions(-) (limited to 'core') diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h index ccecce83eb..6c39e381f5 100644 --- a/core/include/fpdfapi/fpdf_resource.h +++ b/core/include/fpdfapi/fpdf_resource.h @@ -346,21 +346,23 @@ class CPDF_Type1Font : public CPDF_SimpleFont { CPDF_Type1Font(); int GetBase14Font() { return m_Base14Font; } - virtual int GlyphFromCharCodeExt(FX_DWORD charcode); protected: - virtual FX_BOOL _Load(); + // CPDF_SimpleFont: + int GlyphFromCharCodeExt(FX_DWORD charcode) override; + FX_BOOL _Load() override; + void LoadGlyphMap() override; int m_Base14Font; - virtual void LoadGlyphMap(); }; class CPDF_TrueTypeFont : public CPDF_SimpleFont { public: CPDF_TrueTypeFont(); protected: - virtual FX_BOOL _Load(); - virtual void LoadGlyphMap(); + // CPDF_SimpleFont: + FX_BOOL _Load() override; + void LoadGlyphMap() override; }; class CPDF_Type3Char { @@ -428,33 +430,33 @@ class CPDF_CIDFont : public CPDF_Font { static FX_FLOAT CIDTransformToFloat(uint8_t ch); - FX_BOOL LoadGB2312(); + // CPDF_Font: int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph = NULL) override; int GetCharWidthF(FX_DWORD charcode, int level = 0) override; void GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level = 0) override; - FX_WORD CIDFromCharCode(FX_DWORD charcode) const; - - FX_BOOL IsTrueType() const { return !m_bType1; } - - virtual FX_DWORD GetNextChar(const FX_CHAR* pString, - int nStrLen, - int& offset) const override; + FX_DWORD GetNextChar(const FX_CHAR* pString, + int nStrLen, + int& offset) const override; int CountChar(const FX_CHAR* pString, int size) const override; int AppendChar(FX_CHAR* str, FX_DWORD charcode) const override; int GetCharSize(FX_DWORD charcode) const override; - const uint8_t* GetCIDTransform(FX_WORD CID) const; FX_BOOL IsVertWriting() const override; + FX_BOOL IsUnicodeCompatible() const override; + FX_BOOL _Load() override; + FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const override; + FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const override; + + FX_BOOL LoadGB2312(); + FX_WORD CIDFromCharCode(FX_DWORD charcode) const; + FX_BOOL IsTrueType() const { return !m_bType1; } + const uint8_t* GetCIDTransform(FX_WORD CID) const; short GetVertWidth(FX_WORD CID) const; void GetVertOrigin(FX_WORD CID, short& vx, short& vy) const; - FX_BOOL IsUnicodeCompatible() const override; virtual FX_BOOL IsFontStyleFromCharCode(FX_DWORD charcode) const; protected: friend class CPDF_Font; - FX_BOOL _Load() override; - FX_WCHAR _UnicodeFromCharCode(FX_DWORD charcode) const override; - FX_DWORD _CharCodeFromUnicode(FX_WCHAR Unicode) const override; int GetGlyphIndex(FX_DWORD unicodeb, FX_BOOL* pVertGlyph); void LoadMetricsArray(CPDF_Array* pArray, CFX_DWordArray& result, diff --git a/core/include/fxcrt/fx_stream.h b/core/include/fxcrt/fx_stream.h index c369830382..544eacdb5b 100644 --- a/core/include/fxcrt/fx_stream.h +++ b/core/include/fxcrt/fx_stream.h @@ -62,76 +62,71 @@ class IFX_StreamWrite { virtual void Release() = 0; virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0; }; + class IFX_FileWrite : public IFX_StreamWrite { public: - virtual void Release() = 0; + // IFX_StreamWrite: + FX_BOOL WriteBlock(const void* pData, size_t size) override { + return WriteBlock(pData, GetSize(), size); + } virtual FX_FILESIZE GetSize() = 0; - virtual FX_BOOL Flush() = 0; - virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) = 0; - virtual FX_BOOL WriteBlock(const void* pData, size_t size) { - return WriteBlock(pData, GetSize(), size); - } }; + class IFX_StreamRead { public: virtual ~IFX_StreamRead() {} virtual void Release() = 0; - virtual FX_BOOL IsEOF() = 0; - virtual FX_FILESIZE GetPosition() = 0; - virtual size_t ReadBlock(void* buffer, size_t size) = 0; }; + class IFX_FileRead : IFX_StreamRead { public: - virtual void Release() = 0; - - virtual FX_FILESIZE GetSize() = 0; - - virtual FX_BOOL IsEOF() { return FALSE; } - - virtual FX_FILESIZE GetPosition() { return 0; } + // IFX_StreamRead: + void Release() override = 0; + FX_BOOL IsEOF() override { return FALSE; } + FX_FILESIZE GetPosition() override { return 0; } + size_t ReadBlock(void* buffer, size_t size) override { return 0; } virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; - - virtual size_t ReadBlock(void* buffer, size_t size) { return 0; } + virtual FX_FILESIZE GetSize() = 0; }; + IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); + class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { public: virtual IFX_FileStream* Retain() = 0; - virtual void Release() = 0; - - virtual FX_FILESIZE GetSize() = 0; - - virtual FX_BOOL IsEOF() = 0; - - virtual FX_FILESIZE GetPosition() = 0; - - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; - - virtual size_t ReadBlock(void* buffer, size_t size) = 0; - - virtual FX_BOOL WriteBlock(const void* buffer, - FX_FILESIZE offset, - size_t size) = 0; - virtual FX_BOOL WriteBlock(const void* buffer, size_t size) { + // IFX_FileRead: + void Release() override = 0; + FX_BOOL IsEOF() override = 0; + FX_FILESIZE GetPosition() override = 0; + size_t ReadBlock(void* buffer, size_t size) override = 0; + FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override = 0; + FX_FILESIZE GetSize() override = 0; + + // IFX_FileWrite: + FX_BOOL WriteBlock(const void* buffer, + FX_FILESIZE offset, + size_t size) override = 0; + FX_BOOL WriteBlock(const void* buffer, size_t size) override { return WriteBlock(buffer, GetSize(), size); } - - virtual FX_BOOL Flush() = 0; + FX_BOOL Flush() override = 0; }; + IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes); IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD dwModes); + class IFX_FileAccess { public: virtual ~IFX_FileAccess() {} @@ -141,6 +136,7 @@ class IFX_FileAccess { virtual IFX_FileStream* CreateFileStream(FX_DWORD dwModes) = 0; }; IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath); + class IFX_MemoryStream : public IFX_FileStream { public: virtual FX_BOOL IsConsecutive() const = 0; @@ -161,20 +157,15 @@ IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); class IFX_BufferRead : public IFX_StreamRead { public: - virtual void Release() = 0; - - virtual FX_BOOL IsEOF() = 0; - - virtual FX_FILESIZE GetPosition() = 0; - - virtual size_t ReadBlock(void* buffer, size_t size) = 0; + // IFX_StreamRead: + void Release() override = 0; + FX_BOOL IsEOF() override = 0; + FX_FILESIZE GetPosition() override = 0; + size_t ReadBlock(void* buffer, size_t size) override = 0; virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0; - virtual const uint8_t* GetBlockBuffer() = 0; - virtual size_t GetBlockSize() = 0; - virtual FX_FILESIZE GetBlockOffset() = 0; }; diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.h b/core/src/fpdfapi/fpdf_font/ttgsubtable.h index 7dd8cce36c..e3c9965654 100644 --- a/core/src/fpdfapi/fpdf_font/ttgsubtable.h +++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.h @@ -260,7 +260,7 @@ class CFX_CTTGSUBTable { TSingleSubstFormat2() : Coverage(NULL), GlyphCount(0), Substitute(NULL) { SubstFormat = 2; } - ~TSingleSubstFormat2() { + ~TSingleSubstFormat2() override { delete Coverage; delete[] Substitute; } @@ -356,8 +356,7 @@ class CFX_CTTGSUBTable { class CFX_GSUBTable final : public IFX_GSUBTable { public: ~CFX_GSUBTable() override {} - virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, - FX_DWORD* vglyphnum) override; + FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) override; CFX_CTTGSUBTable m_GsubImp; }; diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h index eeaac886dd..199df82512 100644 --- a/core/src/fxcodec/codec/codec_int.h +++ b/core/src/fxcodec/codec/codec_int.h @@ -21,20 +21,21 @@ class CFX_IccTransformCache; class CCodec_BasicModule : public ICodec_BasicModule { public: - virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf, - FX_DWORD src_size, - uint8_t*& dest_buf, - FX_DWORD& dest_size); - virtual FX_BOOL A85Encode(const uint8_t* src_buf, - FX_DWORD src_size, - uint8_t*& dest_buf, - FX_DWORD& dest_size); - virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, - FX_DWORD src_size, - int width, - int height, - int nComps, - int bpc); + // ICodec_BasicModule: + FX_BOOL RunLengthEncode(const uint8_t* src_buf, + FX_DWORD src_size, + uint8_t*& dest_buf, + FX_DWORD& dest_size) override; + FX_BOOL A85Encode(const uint8_t* src_buf, + FX_DWORD src_size, + uint8_t*& dest_buf, + FX_DWORD& dest_size) override; + ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, + FX_DWORD src_size, + int width, + int height, + int nComps, + int bpc) override; }; class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { @@ -101,22 +102,23 @@ class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { class CCodec_FaxModule : public ICodec_FaxModule { public: - virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, - FX_DWORD src_size, - int width, - int height, - int K, - FX_BOOL EndOfLine, - FX_BOOL EncodedByteAlign, - FX_BOOL BlackIs1, - int Columns, - int Rows); + // ICodec_FaxModule: + ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, + FX_DWORD src_size, + int width, + int height, + int K, + FX_BOOL EndOfLine, + FX_BOOL EncodedByteAlign, + FX_BOOL BlackIs1, + int Columns, + int Rows) override; FX_BOOL Encode(const uint8_t* src_buf, int width, int height, int pitch, uint8_t*& dest_buf, - FX_DWORD& dest_size); + FX_DWORD& dest_size) override; }; class CCodec_FlateModule : public ICodec_FlateModule { @@ -258,42 +260,45 @@ class CCodec_BmpModule : public ICodec_BmpModule { }; class CCodec_IccModule : public ICodec_IccModule { public: - virtual IccCS GetProfileCS(const uint8_t* pProfileData, - unsigned int dwProfileSize); - virtual IccCS GetProfileCS(IFX_FileRead* pFile); - virtual void* CreateTransform( - ICodec_IccModule::IccParam* pInputParam, - ICodec_IccModule::IccParam* pOutputParam, - ICodec_IccModule::IccParam* pProofParam = NULL, - FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL, - FX_DWORD dwFlag = Icc_FLAGS_DEFAULT, - FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, - FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING); - virtual void* CreateTransform_sRGB(const uint8_t* pProfileData, - FX_DWORD dwProfileSize, - int32_t& nComponents, - int32_t intent = 0, - FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT); - virtual void* CreateTransform_CMYK(const uint8_t* pSrcProfileData, - FX_DWORD dwSrcProfileSize, - int32_t& nSrcComponents, - const uint8_t* pDstProfileData, - FX_DWORD dwDstProfileSize, - int32_t intent = 0, - FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, - FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT); - virtual void DestroyTransform(void* pTransform); - virtual void Translate(void* pTransform, - FX_FLOAT* pSrcValues, - FX_FLOAT* pDestValues); - virtual void TranslateScanline(void* pTransform, - uint8_t* pDest, - const uint8_t* pSrc, - int pixels); - virtual void SetComponents(FX_DWORD nComponents) { + ~CCodec_IccModule() override; + + // ICodec_IccModule: + IccCS GetProfileCS(const uint8_t* pProfileData, + unsigned int dwProfileSize) override; + IccCS GetProfileCS(IFX_FileRead* pFile) override; + void* CreateTransform(ICodec_IccModule::IccParam* pInputParam, + ICodec_IccModule::IccParam* pOutputParam, + ICodec_IccModule::IccParam* pProofParam = NULL, + FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL, + FX_DWORD dwFlag = Icc_FLAGS_DEFAULT, + FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, + FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING) override; + void* CreateTransform_sRGB( + const uint8_t* pProfileData, + FX_DWORD dwProfileSize, + int32_t& nComponents, + int32_t intent = 0, + FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT) override; + void* CreateTransform_CMYK( + const uint8_t* pSrcProfileData, + FX_DWORD dwSrcProfileSize, + int32_t& nSrcComponents, + const uint8_t* pDstProfileData, + FX_DWORD dwDstProfileSize, + int32_t intent = 0, + FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, + FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT) override; + void DestroyTransform(void* pTransform) override; + void Translate(void* pTransform, + FX_FLOAT* pSrcValues, + FX_FLOAT* pDestValues) override; + void TranslateScanline(void* pTransform, + uint8_t* pDest, + const uint8_t* pSrc, + int pixels) override; + void SetComponents(FX_DWORD nComponents) override { m_nComponents = nComponents; } - virtual ~CCodec_IccModule(); protected: enum Icc_CLASS { diff --git a/core/src/fxcodec/codec/fx_codec_jbig.cpp b/core/src/fxcodec/codec/fx_codec_jbig.cpp index aa9f1811b7..8c7f1bcc7a 100644 --- a/core/src/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp @@ -14,7 +14,7 @@ class JBig2DocumentContext : public CFX_DestructObject { return &m_SymbolDictCache; } - ~JBig2DocumentContext() { + ~JBig2DocumentContext() override { for (auto it : m_SymbolDictCache) { delete it.second; } diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index 038fa30e70..718c8f0423 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -136,23 +136,23 @@ class CFX_MemoryStream final : public IFX_MemoryStream { } m_Blocks.RemoveAll(); } - virtual IFX_FileStream* Retain() override { + + // IFX_MemoryStream: + IFX_FileStream* Retain() override { m_dwCount++; return this; } - virtual void Release() override { + void Release() override { FX_DWORD nCount = --m_dwCount; if (nCount) { return; } delete this; } - virtual FX_FILESIZE GetSize() override { return (FX_FILESIZE)m_nCurSize; } - virtual FX_BOOL IsEOF() override { return m_nCurPos >= (size_t)GetSize(); } - virtual FX_FILESIZE GetPosition() override { return (FX_FILESIZE)m_nCurPos; } - virtual FX_BOOL ReadBlock(void* buffer, - FX_FILESIZE offset, - size_t size) override { + FX_FILESIZE GetSize() override { return (FX_FILESIZE)m_nCurSize; } + FX_BOOL IsEOF() override { return m_nCurPos >= (size_t)GetSize(); } + FX_FILESIZE GetPosition() override { return (FX_FILESIZE)m_nCurPos; } + FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { if (!buffer || !size) { return FALSE; } @@ -185,7 +185,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { } return TRUE; } - virtual size_t ReadBlock(void* buffer, size_t size) override { + size_t ReadBlock(void* buffer, size_t size) override { if (m_nCurPos >= m_nCurSize) { return 0; } @@ -195,9 +195,9 @@ class CFX_MemoryStream final : public IFX_MemoryStream { } return nRead; } - virtual FX_BOOL WriteBlock(const void* buffer, - FX_FILESIZE offset, - size_t size) override { + FX_BOOL WriteBlock(const void* buffer, + FX_FILESIZE offset, + size_t size) override { if (!buffer || !size) { return FALSE; } @@ -255,11 +255,11 @@ class CFX_MemoryStream final : public IFX_MemoryStream { } return TRUE; } - virtual FX_BOOL Flush() override { return TRUE; } - virtual FX_BOOL IsConsecutive() const override { + FX_BOOL Flush() override { return TRUE; } + FX_BOOL IsConsecutive() const override { return m_dwFlags & FX_MEMSTREAM_Consecutive; } - virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) override { + void EstimateSize(size_t nInitSize, size_t nGrowSize) override { if (m_dwFlags & FX_MEMSTREAM_Consecutive) { if (m_Blocks.GetSize() < 1) { uint8_t* pBlock = FX_Alloc(uint8_t, FX_MAX(nInitSize, 4096)); @@ -270,12 +270,12 @@ class CFX_MemoryStream final : public IFX_MemoryStream { m_nGrowSize = FX_MAX(nGrowSize, 4096); } } - virtual uint8_t* GetBuffer() const override { + uint8_t* GetBuffer() const override { return m_Blocks.GetSize() ? (uint8_t*)m_Blocks[0] : NULL; } - virtual void AttachBuffer(uint8_t* pBuffer, - size_t nSize, - FX_BOOL bTakeOver = FALSE) override { + void AttachBuffer(uint8_t* pBuffer, + size_t nSize, + FX_BOOL bTakeOver = FALSE) override { if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) { return; } @@ -286,7 +286,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0); } - virtual void DetachBuffer() override { + void DetachBuffer() override { if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) { return; } -- cgit v1.2.3