From b116136da234afcad018bb44a3ccb64b9ad2a554 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 9 Jun 2015 11:29:12 -0700 Subject: Merge to XFA: Remove more cruft from fx_system.h New manual edits in the following to fix compilation: fx_bmp.h, fx_gif.h, fx_graphics.h Original Review URL: https://codereview.chromium.org/1169963003 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1170103004 --- core/include/fxcrt/fx_system.h | 173 ++++++++------------- core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp | 2 +- core/src/fpdfapi/fpdf_font/ttgsubtable.h | 6 +- .../src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 16 +- core/src/fpdfdoc/tagged_int.h | 2 +- core/src/fxcodec/codec/fx_codec_jpeg.cpp | 2 + core/src/fxcodec/lbmp/fx_bmp.h | 5 +- core/src/fxcodec/lgif/fx_gif.h | 5 +- core/src/fxcrt/extension.h | 58 +++---- core/src/fxcrt/fx_arabic.h | 14 +- core/src/fxge/apple/apple_int.h | 14 +- core/src/fxge/ge/fx_ge_fontmap.cpp | 4 +- core/src/fxge/win32/fx_win32_device.cpp | 4 +- core/src/fxge/win32/fx_win32_dib.cpp | 2 +- core/src/fxge/win32/fx_win32_dwrite.cpp | 6 +- core/src/fxge/win32/fx_win32_gdipext.cpp | 4 +- core/src/fxge/win32/fx_win32_print.cpp | 2 +- fpdfsdk/include/fsdk_define.h | 11 +- fpdfsdk/include/fsdk_mgr.h | 5 +- fpdfsdk/src/fpdf_sysfontinfo.cpp | 18 +-- fpdfsdk/src/fpdfsave.cpp | 6 +- fpdfsdk/src/fpdfview.cpp | 2 +- xfa/include/fxgraphics/fx_graphics.h | 3 + 23 files changed, 166 insertions(+), 198 deletions(-) diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h index 76c6b59a52..f0ebcf90b1 100644 --- a/core/include/fxcrt/fx_system.h +++ b/core/include/fxcrt/fx_system.h @@ -1,29 +1,45 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #ifndef CORE_INCLUDE_FXCRT_FX_SYSTEM_H_ #define CORE_INCLUDE_FXCRT_FX_SYSTEM_H_ -#define _FX_WIN32_DESKTOP_ 1 -#define _FX_LINUX_DESKTOP_ 4 -#define _FX_MACOSX_ 7 -#define _FX_ANDROID_ 12 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// _FX_OS_ values: +#define _FX_WIN32_DESKTOP_ 1 +#define _FX_WIN64_DESKTOP_ 2 +#define _FX_LINUX_DESKTOP_ 4 +#define _FX_MACOSX_ 7 +#define _FX_ANDROID_ 12 -#define _FXM_PLATFORM_WINDOWS_ 1 -#define _FXM_PLATFORM_LINUX_ 2 -#define _FXM_PLATFORM_APPLE_ 3 -#define _FXM_PLATFORM_ANDROID_ 4 +// _FXM_PLATFORM_ values; +#define _FXM_PLATFORM_WINDOWS_ 1 // _FX_WIN32_DESKTOP_ or _FX_WIN64_DESKTOP_. +#define _FXM_PLATFORM_LINUX_ 2 // _FX_LINUX_DESKTOP_ always. +#define _FXM_PLATFORM_APPLE_ 3 // _FX_MACOSX_ always. +#define _FXM_PLATFORM_ANDROID_ 4 // _FX_ANDROID_ always. #ifndef _FX_OS_ #if defined(__ANDROID__) #define _FX_OS_ _FX_ANDROID_ #define _FXM_PLATFORM_ _FXM_PLATFORM_ANDROID_ -#elif defined(_WIN32) || defined(_WIN64) +#elif defined(_WIN32) #define _FX_OS_ _FX_WIN32_DESKTOP_ #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_ +#elif defined(_WIN64) +#define _FX_OS_ _FX_WIN64_DESKTOP_ +#define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_ #elif defined(__linux__) #define _FX_OS_ _FX_LINUX_DESKTOP_ #define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_ @@ -31,94 +47,56 @@ #define _FX_OS_ _FX_MACOSX_ #define _FXM_PLATFORM_ _FXM_PLATFORM_APPLE_ #endif -#endif +#endif // _FX_OS_ #if !defined(_FX_OS_) || _FX_OS_ == 0 -#error Sorry, can not figure out what OS you are targeting to. Please specify _FX_OS_ macro. +#error Sorry, can not figure out target OS. Please specify _FX_OS_ macro. #endif #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #define _CRT_SECURE_NO_WARNINGS #include #include -#endif // _FXM_PLATFORM_WINDOWS_ -#define _FX_W32_ 1 -#define _FX_W64_ 2 -#ifndef _FX_WORDSIZE_ -#if defined(_WIN64) || defined(__arm64) || defined(__arm64__) || defined(_M_AMD64) || defined(_M_X64) || defined(_M_IA64) || defined(__powerpc64__) || defined(__x86_64__) || __WORDSIZE == 64 || defined(__LP64__) -#define _FX_WORDSIZE_ _FX_W64_ -#else -#define _FX_WORDSIZE_ _FX_W32_ -#endif #endif -#include -#include -#include -#include -#include -#include -#include -#include - #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ #include -#if _FX_OS_ == _FX_MACOSX_ #include -#elif _FX_OS_ == _FX_IOS_ -#include -#include -#endif #endif #ifdef __cplusplus extern "C" { #endif -typedef void* FX_LPVOID; -typedef void const* FX_LPCVOID; -typedef void* FX_POSITION; -typedef signed char FX_INT8; -typedef unsigned char FX_UINT8; -typedef unsigned char FX_BYTE; -typedef unsigned char* FX_LPBYTE; -typedef unsigned char const* FX_LPCBYTE; -typedef short FX_INT16; -typedef unsigned short FX_UINT16; -typedef short FX_SHORT; -typedef unsigned short FX_WORD; -typedef unsigned short* FX_LPWORD; -typedef unsigned short const* FX_LPCWORD; -typedef int FX_INT32; -typedef float FX_FLOAT; -typedef int FX_BOOL; -typedef int FX_ERR; -#define FX_SUCCEEDED(Status) ((FX_ERR)(Status) >= 0) -#define FX_FAILED(Status) ((FX_ERR)(Status) < 0) -typedef char FX_CHAR; -typedef char* FX_LPSTR; -typedef char const* FX_LPCSTR; -#define FX_DWORD_MAX UINT_MAX -typedef unsigned int FX_DWORD; -typedef unsigned int* FX_LPDWORD; -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -typedef __int64 FX_INT64; -typedef unsigned __int64 FX_UINT64; -#else -typedef long long int FX_INT64; -typedef unsigned long long FX_UINT64; -#endif -#if _FX_WORDSIZE_ == _FX_W64_ -typedef FX_INT64 FX_INTPTR; -typedef FX_UINT64 FX_UINTPTR; -#else -typedef int FX_INTPTR; -typedef unsigned int FX_UINTPTR; -#endif -typedef wchar_t FX_WCHAR; -typedef wchar_t* FX_LPWSTR; -typedef wchar_t const* FX_LPCWSTR; -typedef FX_DWORD FX_UINT32; -typedef FX_UINT64 FX_QWORD; +typedef void* FX_LPVOID; // Deprecate, use with void*. +typedef void const* FX_LPCVOID; // Deprecate, use with const void*. +typedef void* FX_POSITION; // Keep until fxcrt containers gone +typedef signed char FX_INT8; // Deprecate, use int8_t. +typedef unsigned char FX_UINT8; // Deprecate, use uint8_t. +typedef unsigned char FX_BYTE; // Deprecate, use uint8_t. +typedef unsigned char* FX_LPBYTE; // Deprecate, use uint8_t*. +typedef unsigned char const* FX_LPCBYTE; // Deprecate, use const uint8_t*. +typedef short FX_INT16; // Deprecate, use int16_t. +typedef unsigned short FX_UINT16; // Deprecate, use uint16_t. +typedef short FX_SHORT; // Deprecate, use int16_t. +typedef unsigned short FX_WORD; // Keep - "an efficient small type" +typedef unsigned short* FX_LPWORD; // Deprecate, use FX_WORD*. +typedef unsigned short const* FX_LPCWORD; // Deprecate, use const FX_WORD*. +typedef int FX_INT32; // Deprecate, use int32_t. +typedef unsigned int FX_UINT32; // Deprecate, use uint32_t. +typedef unsigned int FX_DWORD; // Keep - "an efficient type" +typedef unsigned int* FX_LPDWORD; // Deprecate, use FX_DWORD*. +typedef int64_t FX_INT64; // Deprecate, use int64_t. +typedef uint64_t FX_UINT64; // Deprecate, use uint64_t. +typedef intptr_t FX_INTPTR; // Deprecate, use intptr_t. +typedef uintptr_t FX_UINTPTR; // Deprecate, use uintptr_t. +typedef float FX_FLOAT; // Keep, allow upgrade to doubles. +typedef int FX_BOOL; // Sadly not always 0 or 1. +typedef char FX_CHAR; // Keep, questionable signedness. +typedef char* FX_LPSTR; // Deprecate, use FX_CHAR*. +typedef char const* FX_LPCSTR; // Deprecate, use const FX_CHAR*. +typedef wchar_t FX_WCHAR; // Keep, maybe bad platform wchars. +typedef wchar_t* FX_LPWSTR; // Deprecate, use FX_WCHAR*. +typedef wchar_t const* FX_LPCWSTR; // Deprecate, use const FX_WCHAR*. // PDFium string sizes are limited to 2^31-1, and the value is signed to // allow -1 as a placeholder for "unknown". @@ -128,27 +106,28 @@ typedef int FX_STRSIZE; #if defined(DEBUG) && !defined(_DEBUG) #define _DEBUG #endif -#ifndef TRUE +#ifndef TRUE #define TRUE 1 #endif -#ifndef FALSE +#ifndef FALSE #define FALSE 0 #endif -#ifndef NULL +#ifndef NULL #define NULL 0 #endif + #define FXSYS_assert assert #ifndef ASSERT #ifdef _DEBUG #define ASSERT FXSYS_assert #else - #define ASSERT(a) #endif #endif + #define FX_MAX(a, b) (((a) > (b)) ? (a) : (b)) #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b)) #define FX_PI 3.1415926535897932384626433832795f @@ -192,7 +171,7 @@ void FXSYS_vsnprintf(char *str, size_t size, const char* fmt, va_list ap); #endif #else FXSYS_FILE* FXSYS_wfopen(FX_LPCWSTR filename, FX_LPCWSTR mode); -#endif +#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #ifdef __cplusplus } // extern "C" @@ -219,6 +198,7 @@ extern "C" { #define FXSYS_memchr memchr #define FXSYS_qsort qsort #define FXSYS_bsearch bsearch + #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #define FXSYS_GetACP GetACP #define FXSYS_itoa _itoa @@ -255,16 +235,13 @@ int FXSYS_stricmp(const char*, const char*); int FXSYS_wcsicmp(const wchar_t *string1, const wchar_t *string2); wchar_t* FXSYS_wcslwr(wchar_t* str); wchar_t* FXSYS_wcsupr(wchar_t* str); -#endif +#endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_ + #define FXSYS_memcpy32 FXSYS_memcpy #define FXSYS_memcmp32 FXSYS_memcmp #define FXSYS_memset32 FXSYS_memset #define FXSYS_memset8 FXSYS_memset #define FXSYS_memmove32 FXSYS_memmove -#ifdef __cplusplus -} -#endif -#include #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #define FXSYS_pow(a, b) (FX_FLOAT)powf(a, b) #else @@ -282,10 +259,6 @@ wchar_t* FXSYS_wcsupr(wchar_t* str); #define FXSYS_log10(a) (FX_FLOAT)log10(a) #define FXSYS_fmod(a, b) (FX_FLOAT)fmod(a, b) #define FXSYS_abs abs -#ifdef __cplusplus -extern "C" { -#endif -#define _FX_LSB_FIRST_ #define FXDWORD_FROM_LSBFIRST(i) (i) #define FXDWORD_FROM_MSBFIRST(i) (((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24)) #define FXDWORD_GET_LSBFIRST(p) ((((FX_LPBYTE)(p))[3] << 24) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0])) @@ -307,18 +280,6 @@ int FXSYS_round(FX_FLOAT f); #define FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b)) #ifdef __cplusplus }; - -#if defined(__clang__) || _MSC_VER >= 1700 -#define FX_FINAL final -#define FX_OVERRIDE override -#elif defined(__GNUC__) && __cplusplus >= 201103 && \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 -#define FX_FINAL final -#define FX_OVERRIDE override -#else -#define FX_FINAL -#define FX_OVERRIDE -#endif #endif // To print a size_t value in a portable way: diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index 9d0967978c..e75fd079bf 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -191,7 +191,7 @@ const FX_CharsetUnicodes g_FX_CharsetUnicodes[] = { { FXFONT_ARABIC_CHARSET, g_FX_CP1256Unicodes }, { FXFONT_BALTIC_CHARSET, g_FX_CP1257Unicodes }, }; -#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) +#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_) static void _InsertWidthArray(HDC hDC, int start, int end, CPDF_Array* pWidthArray) { int size = end - start + 1; diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.h b/core/src/fpdfapi/fpdf_font/ttgsubtable.h index adfff6756a..cee68c0029 100644 --- a/core/src/fpdfapi/fpdf_font/ttgsubtable.h +++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.h @@ -408,14 +408,14 @@ private: struct TFeatureList FeatureList; struct TLookupList LookupList; }; -class CFX_GSUBTable FX_FINAL : public IFX_GSUBTable +class CFX_GSUBTable final : public IFX_GSUBTable { public: - virtual void Release() FX_OVERRIDE + virtual void Release() override { delete this; } - virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) FX_OVERRIDE; + virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) override; CFX_CTTGSUBTable m_GsubImp; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index e54f503380..9c35615a72 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -2722,28 +2722,28 @@ void CPDF_SyntaxParser::GetBinary(FX_BYTE* buffer, FX_DWORD size) } } -class CPDF_DataAvail FX_FINAL : public IPDF_DataAvail +class CPDF_DataAvail final : public IPDF_DataAvail { public: CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead); ~CPDF_DataAvail(); - virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) FX_OVERRIDE; + virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) override; - virtual void SetDocument(CPDF_Document* pDoc) FX_OVERRIDE; + virtual void SetDocument(CPDF_Document* pDoc) override; - virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints* pHints) FX_OVERRIDE; + virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints* pHints) override; - virtual FX_INT32 IsFormAvail(IFX_DownloadHints *pHints) FX_OVERRIDE; + virtual FX_INT32 IsFormAvail(IFX_DownloadHints *pHints) override; - virtual FX_INT32 IsLinearizedPDF() FX_OVERRIDE; + virtual FX_INT32 IsLinearizedPDF() override; - virtual FX_BOOL IsLinearized() FX_OVERRIDE + virtual FX_BOOL IsLinearized() override { return m_bLinearized; } - virtual void GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize) FX_OVERRIDE; + virtual void GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize) override; protected: static const int kMaxDataAvailRecursionDepth = 64; diff --git a/core/src/fpdfdoc/tagged_int.h b/core/src/fpdfdoc/tagged_int.h index 75004e51fa..44ba527a60 100644 --- a/core/src/fpdfdoc/tagged_int.h +++ b/core/src/fpdfdoc/tagged_int.h @@ -34,7 +34,7 @@ protected: CFX_ArrayTemplate m_Kids; friend class CPDF_StructElementImpl; }; -class CPDF_StructElementImpl FX_FINAL : public CPDF_StructElement +class CPDF_StructElementImpl final : public CPDF_StructElement { public: CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree, CPDF_StructElementImpl* pParent, CPDF_Dictionary* pDict); diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp index 903d2319fd..7d18cb599f 100644 --- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "../../../include/fxcodec/fx_codec.h" #include "../../../include/fxcrt/fx_safe_types.h" #include "../../../include/fxge/fx_dib.h" diff --git a/core/src/fxcodec/lbmp/fx_bmp.h b/core/src/fxcodec/lbmp/fx_bmp.h index 1603770eb4..b7c3617182 100644 --- a/core/src/fxcodec/lbmp/fx_bmp.h +++ b/core/src/fxcodec/lbmp/fx_bmp.h @@ -4,9 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _FX_BASIC_H_ +#include + #include "../../../include/fxcrt/fx_basic.h" -#endif + #define BMP_SUPPORT_BITFIELD #define BMP_WIDTHBYTES(width,bitCount) ((width*bitCount) + 31)/32*4 #define BMP_PAL_ENCODE(a,r,g,b) (((FX_DWORD)(a) << 24) | ((r) << 16) | ((g) << 8) | (b)) diff --git a/core/src/fxcodec/lgif/fx_gif.h b/core/src/fxcodec/lgif/fx_gif.h index 3d2b232267..09c63e20f6 100644 --- a/core/src/fxcodec/lgif/fx_gif.h +++ b/core/src/fxcodec/lgif/fx_gif.h @@ -4,9 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _FX_BASIC_H_ +#include + #include "../../../include/fxcrt/fx_basic.h" -#endif + extern FX_WORD _GetWord_LSBFirst(FX_LPBYTE p); extern void _SetWord_LSBFirst(FX_LPBYTE p, FX_WORD v); extern void _BpcConvert(FX_LPCBYTE src_buf, FX_DWORD src_len, FX_INT32 src_bpc, FX_INT32 dst_bpc, diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index 0f37bbfefc..86e46eb5a0 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -66,7 +66,7 @@ protected: CFX_WideString m_path; FX_DWORD m_RefCount; }; -class CFX_CRTFileStream FX_FINAL : public IFX_FileStream +class CFX_CRTFileStream final : public IFX_FileStream { public: CFX_CRTFileStream(IFXCRT_FileAccess* pFA) : m_pFile(pFA), m_dwCount(1), m_bUseRange(FALSE), m_nOffset(0), m_nSize(0) {} @@ -76,27 +76,27 @@ public: m_pFile->Release(); } } - virtual IFX_FileStream* Retain() FX_OVERRIDE + virtual IFX_FileStream* Retain() override { m_dwCount ++; return this; } - virtual void Release() FX_OVERRIDE + virtual void Release() override { FX_DWORD nCount = -- m_dwCount; if (!nCount) { delete this; } } - virtual FX_FILESIZE GetSize() FX_OVERRIDE + virtual FX_FILESIZE GetSize() override { return m_bUseRange ? m_nSize : m_pFile->GetSize(); } - virtual FX_BOOL IsEOF() FX_OVERRIDE + virtual FX_BOOL IsEOF() override { return GetPosition() >= GetSize(); } - virtual FX_FILESIZE GetPosition() FX_OVERRIDE + virtual FX_FILESIZE GetPosition() override { FX_FILESIZE pos = m_pFile->GetPosition(); if (m_bUseRange) { @@ -104,7 +104,7 @@ public: } return pos; } - virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) FX_OVERRIDE + virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) override { if (offset < 0 || size < 0) { return FALSE; @@ -122,11 +122,11 @@ public: m_pFile->SetPosition(m_nOffset); return TRUE; } - virtual void ClearRange() FX_OVERRIDE + virtual void ClearRange() override { m_bUseRange = FALSE; } - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { if (m_bUseRange && offset < 0) { return FALSE; @@ -141,7 +141,7 @@ public: } return (FX_BOOL)m_pFile->ReadPos(buffer, size, pos.ValueOrDie()); } - virtual size_t ReadBlock(void* buffer, size_t size) FX_OVERRIDE + virtual size_t ReadBlock(void* buffer, size_t size) override { if (m_bUseRange) { FX_FILESIZE availSize = m_nOffset + m_nSize - m_pFile->GetPosition(); @@ -151,14 +151,14 @@ public: } return m_pFile->Read(buffer, size); } - virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE + virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override { if (m_bUseRange) { offset += m_nOffset; } return (FX_BOOL)m_pFile->WritePos(buffer, size, offset); } - virtual FX_BOOL Flush() FX_OVERRIDE + virtual FX_BOOL Flush() override { return m_pFile->Flush(); } @@ -171,7 +171,7 @@ public: #define FX_MEMSTREAM_BlockSize (64 * 1024) #define FX_MEMSTREAM_Consecutive 0x01 #define FX_MEMSTREAM_TakeOver 0x02 -class CFX_MemoryStream FX_FINAL : public IFX_MemoryStream +class CFX_MemoryStream final : public IFX_MemoryStream { public: CFX_MemoryStream(FX_BOOL bConsecutive) @@ -204,12 +204,12 @@ public: } m_Blocks.RemoveAll(); } - virtual IFX_FileStream* Retain() FX_OVERRIDE + virtual IFX_FileStream* Retain() override { m_dwCount ++; return this; } - virtual void Release() FX_OVERRIDE + virtual void Release() override { FX_DWORD nCount = -- m_dwCount; if (nCount) { @@ -217,15 +217,15 @@ public: } delete this; } - virtual FX_FILESIZE GetSize() FX_OVERRIDE + virtual FX_FILESIZE GetSize() override { return m_bUseRange ? (FX_FILESIZE) m_nSize : (FX_FILESIZE)m_nCurSize; } - virtual FX_BOOL IsEOF() FX_OVERRIDE + virtual FX_BOOL IsEOF() override { return m_nCurPos >= (size_t)GetSize(); } - virtual FX_FILESIZE GetPosition() FX_OVERRIDE + virtual FX_FILESIZE GetPosition() override { FX_FILESIZE pos = (FX_FILESIZE)m_nCurPos; if (m_bUseRange) { @@ -233,7 +233,7 @@ public: } return pos; } - virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) FX_OVERRIDE + virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) override { if (offset < 0 || size < 0) { return FALSE; @@ -249,11 +249,11 @@ public: m_nCurPos = m_nOffset; return TRUE; } - virtual void ClearRange() FX_OVERRIDE + virtual void ClearRange() override { m_bUseRange = FALSE; } - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { if (!buffer || !size) { return FALSE; @@ -296,7 +296,7 @@ public: } return TRUE; } - virtual size_t ReadBlock(void* buffer, size_t size) FX_OVERRIDE + virtual size_t ReadBlock(void* buffer, size_t size) override { if (m_nCurPos >= m_nCurSize) { return 0; @@ -313,7 +313,7 @@ public: } return nRead; } - virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE + virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override { if (!buffer || !size) { return FALSE; @@ -373,15 +373,15 @@ public: } return TRUE; } - virtual FX_BOOL Flush() FX_OVERRIDE + virtual FX_BOOL Flush() override { return TRUE; } - virtual FX_BOOL IsConsecutive() const FX_OVERRIDE + virtual FX_BOOL IsConsecutive() const override { return m_dwFlags & FX_MEMSTREAM_Consecutive; } - virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) FX_OVERRIDE + virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) override { if (m_dwFlags & FX_MEMSTREAM_Consecutive) { if (m_Blocks.GetSize() < 1) { @@ -393,11 +393,11 @@ public: m_nGrowSize = FX_MAX(nGrowSize, 4096); } } - virtual FX_LPBYTE GetBuffer() const FX_OVERRIDE + virtual FX_LPBYTE GetBuffer() const override { return m_Blocks.GetSize() ? (FX_LPBYTE)m_Blocks[0] : NULL; } - virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE) FX_OVERRIDE + virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE) override { if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) { return; @@ -409,7 +409,7 @@ public: m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0); ClearRange(); } - virtual void DetachBuffer() FX_OVERRIDE + virtual void DetachBuffer() override { if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) { return; diff --git a/core/src/fxcrt/fx_arabic.h b/core/src/fxcrt/fx_arabic.h index cf221301f2..66e8bc8000 100644 --- a/core/src/fxcrt/fx_arabic.h +++ b/core/src/fxcrt/fx_arabic.h @@ -180,22 +180,22 @@ void FX_BidiResolveImplicit(const CFX_Int32Array &classes, CFX_Int32Array &level void FX_BidiResolveWhitespace(FX_INT32 iBaseLevel, const CFX_Int32Array &classes, CFX_Int32Array &levels); FX_INT32 FX_BidiReorderLevel(FX_INT32 iBaseLevel, CFX_WideString &wsText, const CFX_Int32Array &levels, FX_INT32 iStart, FX_BOOL bReverse = FALSE); void FX_BidiReorder(FX_INT32 iBaseLevel, CFX_WideString &wsText, const CFX_Int32Array &levels); -class CFX_BidiChar FX_FINAL : public IFX_BidiChar +class CFX_BidiChar final : public IFX_BidiChar { public: CFX_BidiChar(); - virtual void Release() FX_OVERRIDE + virtual void Release() override { delete this; } - virtual void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) FX_OVERRIDE + virtual void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) override { m_bSeparateNeutral = bSeparateNeutral; } - virtual FX_BOOL AppendChar(FX_WCHAR wch) FX_OVERRIDE; - virtual FX_BOOL EndChar() FX_OVERRIDE; - virtual FX_INT32 GetBidiInfo(FX_INT32 &iStart, FX_INT32 &iCount) FX_OVERRIDE; - virtual void Reset() FX_OVERRIDE; + virtual FX_BOOL AppendChar(FX_WCHAR wch) override; + virtual FX_BOOL EndChar() override; + virtual FX_INT32 GetBidiInfo(FX_INT32 &iStart, FX_INT32 &iCount) override; + virtual void Reset() override; private: ~CFX_BidiChar() { } diff --git a/core/src/fxge/apple/apple_int.h b/core/src/fxge/apple/apple_int.h index 5b083d83eb..2466ecbc9a 100644 --- a/core/src/fxge/apple/apple_int.h +++ b/core/src/fxge/apple/apple_int.h @@ -186,28 +186,28 @@ protected: FX_INT32 _horzSize; FX_INT32 _vertSize; }; -class CFX_FontProvider FX_FINAL : public IFX_FileRead +class CFX_FontProvider final : public IFX_FileRead { public: - virtual void Release() FX_OVERRIDE + virtual void Release() override { delete this; } - virtual FX_FILESIZE GetSize() FX_OVERRIDE + virtual FX_FILESIZE GetSize() override { return (FX_FILESIZE)_totalSize; } - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE; + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; - virtual FX_BOOL IsEOF() FX_OVERRIDE + virtual FX_BOOL IsEOF() override { return _offSet == _totalSize; } - virtual FX_FILESIZE GetPosition() FX_OVERRIDE + virtual FX_FILESIZE GetPosition() override { return (FX_FILESIZE)_offSet; } - virtual size_t ReadBlock(void* buffer, size_t size) FX_OVERRIDE; + virtual size_t ReadBlock(void* buffer, size_t size) override; public: CFX_FontProvider(CGFontRef cgFont); ~CFX_FontProvider(); diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp index ec4530b8ed..acae306d6f 100644 --- a/core/src/fxge/ge/fx_ge_fontmap.cpp +++ b/core/src/fxge/ge/fx_ge_fontmap.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "../../../include/fxge/fx_ge.h" #include "../../../include/fxge/fx_freetype.h" #include "text_int.h" @@ -1462,7 +1464,7 @@ void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) if (GET_TT_LONG(buffer) == 0x74746366) { FX_DWORD nFaces = GET_TT_LONG(buffer + 8); - if (nFaces > FX_DWORD_MAX / 4) { + if (nFaces > std::numeric_limits::max() / 4) { FXSYS_fclose(pFile); return; } diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp index 24c72fd0ce..3372af103d 100644 --- a/core/src/fxge/win32/fx_win32_device.cpp +++ b/core/src/fxge/win32/fx_win32_device.cpp @@ -5,7 +5,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../../include/fxge/fx_ge.h" -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include "../../../include/fxge/fx_ge_win32.h" #include #include "../agg/include/fxfx_agg_clip_liang_barsky.h" @@ -16,7 +16,7 @@ #include "../agg/include/fx_agg_driver.h" #include "../../../include/fxge/fx_freetype.h" #include "../../../include/fxcodec/fx_codec.h" -class CWin32FontInfo FX_FINAL : public IFX_SystemFontInfo +class CWin32FontInfo final : public IFX_SystemFontInfo { public: CWin32FontInfo(); diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp index 40fb511a5f..0c6a7e1068 100644 --- a/core/src/fxge/win32/fx_win32_dib.cpp +++ b/core/src/fxge/win32/fx_win32_dib.cpp @@ -5,7 +5,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../../include/fxge/fx_ge.h" -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include #include "../../../include/fxge/fx_ge_win32.h" #include "win32_int.h" diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp index 1ad4f8c457..022325b5ac 100644 --- a/core/src/fxge/win32/fx_win32_dwrite.cpp +++ b/core/src/fxge/win32/fx_win32_dwrite.cpp @@ -5,7 +5,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../../include/fxge/fx_ge.h" -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include "../../../include/fxge/fx_ge_win32.h" #include "dwrite_int.h" #include @@ -26,7 +26,7 @@ inline InterfaceType* SafeAcquire(InterfaceType* newObject) } return newObject; } -class CDwFontFileStream FX_FINAL : public IDWriteFontFileStream +class CDwFontFileStream final : public IDWriteFontFileStream { public: explicit CDwFontFileStream(void const* fontFileReferenceKey, UINT32 fontFileReferenceKeySize); @@ -46,7 +46,7 @@ private: void const* resourcePtr_; DWORD resourceSize_; }; -class CDwFontFileLoader FX_FINAL : public IDWriteFontFileLoader +class CDwFontFileLoader final : public IDWriteFontFileLoader { public: virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void** ppvObject); diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp index 77d18fc5b2..d2aafe09d5 100644 --- a/core/src/fxge/win32/fx_win32_gdipext.cpp +++ b/core/src/fxge/win32/fx_win32_gdipext.cpp @@ -5,7 +5,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../../include/fxge/fx_ge.h" -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include #include namespace Gdiplus { @@ -998,7 +998,7 @@ BOOL CGdiplusExt::DrawPath(HDC hDC, const CFX_PathData* pPathData, CallFunc(GdipDeleteGraphics)(pGraphics); return TRUE; } -class GpStream FX_FINAL : public IStream +class GpStream final : public IStream { LONG m_RefCount; int m_ReadPos; diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp index c9beefe20b..149df5058c 100644 --- a/core/src/fxge/win32/fx_win32_print.cpp +++ b/core/src/fxge/win32/fx_win32_print.cpp @@ -5,7 +5,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../../include/fxge/fx_ge.h" -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include #include "../../../include/fxge/fx_ge_win32.h" #include "win32_int.h" diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h index 528801795b..fd6beca527 100644 --- a/fpdfsdk/include/fsdk_define.h +++ b/fpdfsdk/include/fsdk_define.h @@ -75,20 +75,19 @@ typedef unsigned int FX_UINT; #include "../../public/fpdfview.h" -class CPDF_CustomAccess FX_FINAL : public IFX_FileRead +class CPDF_CustomAccess final : public IFX_FileRead { public: CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess); ~CPDF_CustomAccess() {} - virtual CFX_ByteString GetFullPath() { return ""; } - virtual FX_FILESIZE GetSize() FX_OVERRIDE { return m_FileAccess.m_FileLen; } + virtual CFX_ByteString GetFullPath() { return ""; } + virtual FX_FILESIZE GetSize() override { return m_FileAccess.m_FileLen; } virtual FX_BOOL GetByte(FX_DWORD pos, FX_BYTE& ch); virtual FX_BOOL GetBlock(FX_DWORD pos, FX_LPBYTE pBuf, FX_DWORD size); - virtual void Release() FX_OVERRIDE { delete this; } - - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE; + virtual void Release() override { delete this; } + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; FPDF_FILEACCESS m_FileAccess; FX_BYTE m_Buffer[512]; diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index 7f68dd9cca..d90ab3be4f 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -30,7 +30,7 @@ class CJS_RuntimeFactory; #include "javascript/IJavaScript.h" -class CPDFDoc_Environment FX_FINAL +class CPDFDoc_Environment final { public: CPDFDoc_Environment(CPDFXFA_Document * pDoc); @@ -763,8 +763,7 @@ private: CPDF_OCContext * m_pOccontent; FX_BOOL m_bChangeMask; }; - -class CPDFSDK_PageView FX_FINAL +class CPDFSDK_PageView final { public: CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDFXFA_Page* page); diff --git a/fpdfsdk/src/fpdf_sysfontinfo.cpp b/fpdfsdk/src/fpdf_sysfontinfo.cpp index f73a7701dc..4d77794768 100644 --- a/fpdfsdk/src/fpdf_sysfontinfo.cpp +++ b/fpdfsdk/src/fpdf_sysfontinfo.cpp @@ -8,19 +8,19 @@ #include "../include/fsdk_define.h" #include "../include/pdfwindow/PWL_FontMap.h" -class CSysFontInfo_Ext FX_FINAL : public IFX_SystemFontInfo +class CSysFontInfo_Ext final : public IFX_SystemFontInfo { public: FPDF_SYSFONTINFO* m_pInfo; - virtual void Release() FX_OVERRIDE + virtual void Release() override { if (m_pInfo->Release) m_pInfo->Release(m_pInfo); delete this; } - virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) FX_OVERRIDE + virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override { if (m_pInfo->EnumFonts) { m_pInfo->EnumFonts(m_pInfo, pMapper); @@ -29,28 +29,28 @@ public: return FALSE; } - virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL& bExact) FX_OVERRIDE + virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL& bExact) override { if (m_pInfo->MapFont) return m_pInfo->MapFont(m_pInfo, weight, bItalic, charset, pitch_family, family, &bExact); return NULL; } - virtual void* GetFont(FX_LPCSTR family) FX_OVERRIDE + virtual void* GetFont(FX_LPCSTR family) override { if (m_pInfo->GetFont) return m_pInfo->GetFont(m_pInfo, family); return NULL; } - virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, FX_LPBYTE buffer, FX_DWORD size) FX_OVERRIDE + virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, FX_LPBYTE buffer, FX_DWORD size) override { if (m_pInfo->GetFontData) return m_pInfo->GetFontData(m_pInfo, hFont, table, buffer, size); return 0; } - virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) FX_OVERRIDE + virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override { if (m_pInfo->GetFaceName == NULL) return FALSE; FX_DWORD size = m_pInfo->GetFaceName(m_pInfo, hFont, NULL, 0); @@ -62,7 +62,7 @@ public: return TRUE; } - virtual FX_BOOL GetFontCharset(void* hFont, int& charset) FX_OVERRIDE + virtual FX_BOOL GetFontCharset(void* hFont, int& charset) override { if (m_pInfo->GetFontCharset) { charset = m_pInfo->GetFontCharset(m_pInfo, hFont); @@ -71,7 +71,7 @@ public: return FALSE; } - virtual void DeleteFont(void* hFont) FX_OVERRIDE + virtual void DeleteFont(void* hFont) override { if (m_pInfo->DeleteFont) m_pInfo->DeleteFont(m_pInfo, hFont); diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp index b3ab2f0df9..db9e289d9e 100644 --- a/fpdfsdk/src/fpdfsave.cpp +++ b/fpdfsdk/src/fpdfsave.cpp @@ -18,14 +18,14 @@ #include #endif -class CFX_IFileWrite FX_FINAL : public IFX_StreamWrite +class CFX_IFileWrite final : public IFX_StreamWrite { public: CFX_IFileWrite(); FX_BOOL Init( FPDF_FILEWRITE * pFileWriteStruct ); - virtual FX_BOOL WriteBlock(const void* pData, size_t size) FX_OVERRIDE; - virtual void Release() FX_OVERRIDE {} + virtual FX_BOOL WriteBlock(const void* pData, size_t size) override; + virtual void Release() override {} protected: FPDF_FILEWRITE* m_pFileWriteStruct; diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index 3d26efa11c..7e68740e59 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -299,7 +299,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); -class CMemFile FX_FINAL: public IFX_FileRead +class CMemFile final : public IFX_FileRead { public: CMemFile(FX_BYTE* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} diff --git a/xfa/include/fxgraphics/fx_graphics.h b/xfa/include/fxgraphics/fx_graphics.h index 0eb3cf4e9f..cb86116fa9 100644 --- a/xfa/include/fxgraphics/fx_graphics.h +++ b/xfa/include/fxgraphics/fx_graphics.h @@ -6,6 +6,8 @@ #ifndef __H_FX_GRAPHICS__ #define __H_FX_GRAPHICS__ + +typedef int FX_ERR; #define FX_ERR_Succeeded 0 #define FX_ERR_Indefinite -1 #define FX_ERR_Parameter_Invalid -100 @@ -19,6 +21,7 @@ #define _FX_ERR_CHECK_RETURN_IF_FAIL(arg) {if ((arg) != FX_ERR_Succeeded) return;} #define _FX_ERR_CHECK_RETURN_VALUE_IF_FAIL(arg, val) {if ((arg) != FX_ERR_Succeeded) return val;} #define _FX_ERR_CHECK_GOTO_POSITION_IF_FAIL(arg, pos) {if ((arg) != FX_ERR_Succeeded) goto pos;} + #define FX_SHADING_Steps 256 typedef FX_INT32 FX_DashStyle; enum { -- cgit v1.2.3